Closed Maddmax76 closed 1 year ago
Thanks for reporting this. Can you send a dump of a network payload when you create an item and can you let me know what locale you are using in freescout?
Hi, I can't provide the dump, the locale is Italian IT. Thank you
Okay, then I can't see what's wrong.
thank you so much you are very kind.
All the solutions found in the various forums refer to date management, it seems that having a format other than the native one it must be converted.
For example in the following code, taken from https://stackoverflow.com/questions/25223958/laravel-unexpected-data-found-error-when-trying-to-change-format-of-carbon-cre , set both timezone and date/time format:
public function getCreatedAtAttribute($date)
{
if(Auth::check())
return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->copy()->tz(Auth::user()->timezone)->format('F j, Y @ g:i A');
else
return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->copy()->tz('America/Toronto')->format('F j, Y @ g:i A');
}
public function getUpdatedAtAttribute($date)
{
return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('F j, Y @ g:i A');
}
I hope it can help you.
Thanks again
If I don't know what is sent to the server, I don't know why Carbon would parse it wrong. Maybe it's some weird JavaScript issue due to your locale, but that's why I need to see at least one request to the server.
unfortunately I only have access to the logs, I can't do network sniffing..
Just add a calendar item with the network tab with chrome inspect elements opened. Copy the call that happens when you add the item and put it here. No need for sniffing the network.
Done, found an element in error, error 500 strict-origin-when-cross-origin, it's probably some apache security setting like X-Frame-Options... Is this information enough for you or do I have to copy something else from the network tab? But you have to explain how and what to copy because I don't know how :-(
URL Di Richiesta:
https://helpdesk.mydomain.local/calendar/ajax
Metodo Di Richiesta:
POST
Codice Di Stato:
500 Internal Server Error
Indirizzo Remoto:
192.168.1.217:443
Criterio Relativo Al Referrer:
strict-origin-when-cross-origin
I read on the internet that you could try using JSONP in your Ajax call. It will bypass the Same Origin Policy.
I don't know if this is the case, I hope it helps.
Browsing through the chrome inspector I also found this:
DevTools failed to load source map: Could not load content for https://helpdesk.mydomain.local/modules/ljpccalendarmodule/js/moment-with-locales.min.js.map: Errore HTTP: codice di stato 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
Just do it like that^
Hi Lars, :-) I love your pragmatism!
thanks for the clear example, it was very helpful to me. I report the data below:
action: create calendar[id]: 1 calendar[name]: Ufficio IT calendar[checked]: true calendar[external]: false calendar[color]: #ffffff calendar[bgColor]: #3498db calendar[borderColor]: #2980b9 calendar[dragBgColor]: #3498db schedule[id]: c4194cb8-e344-4bd9-bd18-5136d85817dd schedule[title]: prova schedule[isAllDay]: false schedule[start]: 1687332600 schedule[end]: 1687334400 schedule[category]: time schedule[dueDateClass]: schedule[color]: #ffffff schedule[bgColor]: #3498db schedule[dragBgColor]: #3498db schedule[borderColor]: #2980b9 schedule[location]: ciao schedule[isPrivate]: false schedule[state]: Occupato
Awesome! Can you try changing the following lines in Http/Controllers/LJPcCalendarModuleController.php
in the createItem
function from this:
$calendarItem->start = date( DATE_ATOM, $schedule['start'] );
$calendarItem->end = date( DATE_ATOM, $schedule['end'] );
To this:
$calendarItem->start = Carbon::createFromTimeStamp( $schedule['start'] );
$calendarItem->end = Carbon::createFromTimeStamp( $schedule['end'] );
You also need to add this to the other use
-rows at the top of the file:
use Carbon;
Let me know if that works. If it does, I will create a new version with these changes.
Thank you. Done, unfortunately it doesn't work.
I'm attaching the playload (now that I know how to get it! :-) )
action: create calendar[id]: 1 calendar[name]: Ufficio IT calendar[checked]: true calendar[external]: false calendar[color]: #ffffff calendar[bgColor]: #3498db calendar[borderColor]: #2980b9 calendar[dragBgColor]: #3498db schedule[id]: 6268adc6-04fa-460b-a068-0eb386d78a46 schedule[title]: prova schedule[isAllDay]: true schedule[start]: 1687384800 schedule[end]: 1687471199 schedule[category]: allday schedule[dueDateClass]: schedule[color]: #ffffff schedule[bgColor]: #3498db schedule[dragBgColor]: #3498db schedule[borderColor]: #2980b9 schedule[location]: schedule[isPrivate]: false schedule[state]: Occupato
Okay, is the error in the logs still the same?
No, it's changed:
Class "Carbon" not found {"userId":2,"email":"OMISS","exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Class \"Carbon\" not found at /var/www/FreeScout/Modules/LJPcCalendarModule/Http/Controllers/LJPcCalendarModuleController.php:156)
Eureka! Funziona!!
just add 'use Carbon\Carbon;' at the top of the file and it started working.
Thank you so much for your patience and support
Hi, I'm starting to populate the calendar, logically I'm not an ace, so I entered some appointments incorrectly. Going to modify the same problem arises again.
Probably it is necessary to apply the same modifications not only to the creation of the occurrence, but also to the modification.
action: update
schedule[id]: 5
schedule[title]: Max 18:50
schedule[body]: empty
Created by: OMISS
schedule[isAllDay]: 0
schedule[start][_date]: 2023-06-28T14:00:00.000Z
schedule[end][_date]: 2023-06-28T15:00:00.000Z
schedule[color]: #ffffff
schedule[isVisible]: true
schedule[bgColor]: #3498db
schedule[dragBgColor]: #3498db
schedule[borderColor]: #2980b9
schedule[calendarId]: 1
schedule[category]: time
schedule[dueDateClass]:
schedule[customStyle]:
schedule[isPending]: false
schedule[isFocused]: false
schedule[isReadOnly]: false
schedule[isPrivate]: false
schedule[location]:
schedule[recurrenceRule]:
schedule[state]: Occupato
schedule[goingDuration]: 0
schedule[comingDuration]: 0
schedule[raw][creator][id]: 2
schedule[raw][creator][name]: OMISS
schedule[raw][creator][email]: OMISS
schedule[raw][creator][avatar]: https://OMISS/img/default-avatar.png
schedule[raw][creator][phone]: 243
schedule[__fe_id]: 151
changes[title]: MAX
changes[start]: 1687971000
changes[end]: 1687973400
changes[isAllDay]: false
changes[category]: time
Check release 1.3.13
ah! meanwhile I fixed it by modifying the edit element function:
$calendarItem->start = isset( $changes['start'] ) ? Carbon::createFromTimeStamp( $schedule['start'] ) : $calendarItem->start; $calendarItem->end= isset( $changes['end'] ) ? Carbon::createFromTimeStamp( $schedule['end'] ) : $calendarItem->end;
thanks anyway for the new release, I apply it now
Hi, I'm trying your module but something is wrong. When I try to create an appointment in the calendar, it seems to work and I see the event, but if I refresh the page the event disappears, as if it can't write data. If instead I take a ticket and try to create an event in the calendar, a modal popup appears warning that there is an error in the internet connection.
In the logs I see that there are laravel errors, which I report below.
On the internet it would seem to be a problem with the date format.
Could you help me?
Thank you