Plugin updates

Updated faveodate method to work with old configuration
This commit is contained in:
Manish Verma
2018-11-15 12:56:01 +05:30
committed by Manish Verma
parent 0a9da8d404
commit 45b2a2e8f6
2 changed files with 15 additions and 3 deletions

View File

@@ -1048,6 +1048,8 @@ class TicketController extends Controller
} }
} }
} }
\Event::fire('after.ticket.created', array(['ticket' => $ticket, 'form_data' => $form_data]));
// store collaborators // store collaborators
$this->storeCollaborators($headers, $id); $this->storeCollaborators($headers, $id);
if ($this->ticketThread($subject, $body, $id, $user_id) == true) { if ($this->ticketThread($subject, $body, $id, $user_id) == true) {

View File

@@ -191,21 +191,21 @@ function faveoDate($date = '', $format = '', $tz = '')
if (!is_object($date)) { if (!is_object($date)) {
$date = carbon($date); $date = carbon($date);
} }
if (!$format || !$tz) { if (!$format || !$tz) {
$system = App\Model\helpdesk\Settings\System::select('time_zone', 'date_time_format')->first(); $system = App\Model\helpdesk\Settings\System::select('time_zone', 'date_time_format')->first();
} }
if (!$format) { if (!$format) {
$format = $system->date_time_format; $format = is_numeric($system->date_time_format) ? DB::table('date_time_format')->where('id', $system->date_time_format)->value('format') : $system->date_time_format;
} }
if (!$tz) { if (!$tz) {
$tz = $system->time_zone; $tz = is_numeric($system->time_zone) ? DB::table('timezone')->where('id', $system->time_zone)->value('name') : $system->time_zone;
} }
try { try {
if ($format == 'human-read') { if ($format == 'human-read') {
return $date->tz($tz)->diffForHumans(); return $date->tz($tz)->diffForHumans();
} }
return $date->tz($tz)->format($format); return $date->tz($tz)->format($format);
} catch (\Exception $ex) { } catch (\Exception $ex) {
return 'invalid'; return 'invalid';
@@ -290,3 +290,13 @@ function createDB(string $dbName)
// populated // populated
\DB::disconnect('mysql'); \DB::disconnect('mysql');
} }
/**
* parse the carbon
* @param string $date
* @return \Carbon\Carbon
*/
function carbon($date)
{
return \Carbon\Carbon::parse($date);
}