Update due date mostly done... just need to fix the buildEvent function
This commit is contained in:
parent
bd5b3e1322
commit
0514965040
@ -4,6 +4,8 @@ namespace BusinessLogic\Calendar;
|
|||||||
|
|
||||||
|
|
||||||
class AbstractEvent {
|
class AbstractEvent {
|
||||||
|
public $id;
|
||||||
|
|
||||||
public $startTime;
|
public $startTime;
|
||||||
|
|
||||||
public $title;
|
public $title;
|
||||||
|
@ -4,8 +4,6 @@ namespace BusinessLogic\Calendar;
|
|||||||
|
|
||||||
|
|
||||||
class CalendarEvent extends AbstractEvent {
|
class CalendarEvent extends AbstractEvent {
|
||||||
public $id;
|
|
||||||
|
|
||||||
public $type = 'CALENDAR';
|
public $type = 'CALENDAR';
|
||||||
|
|
||||||
public $endTime;
|
public $endTime;
|
||||||
|
@ -30,4 +30,8 @@ class Helpers extends \BaseClass {
|
|||||||
static function boolval($val) {
|
static function boolval($val) {
|
||||||
return $val == true;
|
return $val == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function heskHtmlSpecialCharsDecode($in) {
|
||||||
|
return str_replace(array('&', '<', '>', '"'), array('&', '<', '>', '"'), $in);
|
||||||
|
}
|
||||||
}
|
}
|
@ -53,7 +53,11 @@ class StaffTicketController extends \BaseClass {
|
|||||||
/* @var $ticketEditor TicketEditor */
|
/* @var $ticketEditor TicketEditor */
|
||||||
$ticketEditor = $applicationContext->get(TicketEditor::clazz());
|
$ticketEditor = $applicationContext->get(TicketEditor::clazz());
|
||||||
|
|
||||||
|
$json = JsonRetriever::getJsonData();
|
||||||
|
|
||||||
|
$dueDate = date('Y-m-d H:i:s', strtotime(Helpers::safeArrayGet($json, 'dueDate')));
|
||||||
|
|
||||||
|
$ticketEditor->updateDueDate($id, $dueDate, $userContext, $hesk_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getEditTicketModel($id, $jsonRequest) {
|
private function getEditTicketModel($id, $jsonRequest) {
|
||||||
|
@ -8,6 +8,7 @@ use BusinessLogic\Calendar\CalendarEvent;
|
|||||||
use BusinessLogic\Calendar\ReminderUnit;
|
use BusinessLogic\Calendar\ReminderUnit;
|
||||||
use BusinessLogic\Calendar\SearchEventsFilter;
|
use BusinessLogic\Calendar\SearchEventsFilter;
|
||||||
use BusinessLogic\Calendar\TicketEvent;
|
use BusinessLogic\Calendar\TicketEvent;
|
||||||
|
use BusinessLogic\Helpers;
|
||||||
use BusinessLogic\Security\UserContext;
|
use BusinessLogic\Security\UserContext;
|
||||||
use Core\Constants\Priority;
|
use Core\Constants\Priority;
|
||||||
use DataAccess\CommonDao;
|
use DataAccess\CommonDao;
|
||||||
@ -61,15 +62,15 @@ class CalendarGateway extends CommonDao {
|
|||||||
$event->id = intval($row['id']);
|
$event->id = intval($row['id']);
|
||||||
$event->startTime = $row['start'];
|
$event->startTime = $row['start'];
|
||||||
$event->endTime = $row['end'];
|
$event->endTime = $row['end'];
|
||||||
$event->allDay = $row['all_day'] ? true : false;
|
$event->allDay = Helpers::boolval($row['all_day']);
|
||||||
$event->title = $row['name'];
|
$event->title = $row['name'];
|
||||||
$event->location = $row['location'];
|
$event->location = $row['location'];
|
||||||
$event->comments = $row['comments'];
|
$event->comments = $row['comments'];
|
||||||
$event->categoryId = intval($row['category']);
|
$event->categoryId = intval($row['category']);
|
||||||
$event->categoryName = $row['category_name'];
|
$event->categoryName = Helpers::heskHtmlSpecialCharsDecode($row['category_name']);
|
||||||
$event->backgroundColor = $row['background_color'];
|
$event->backgroundColor = $row['background_color'];
|
||||||
$event->foregroundColor = $row['foreground_color'];
|
$event->foregroundColor = $row['foreground_color'];
|
||||||
$event->displayBorder = $row['display_border'] === '1';
|
$event->displayBorder = Helpers::boolval($row['display_border']);
|
||||||
$event->reminderValue = $row['reminder_value'] === null ? null : floatval($row['reminder_value']);
|
$event->reminderValue = $row['reminder_value'] === null ? null : floatval($row['reminder_value']);
|
||||||
$event->reminderUnits = $row['reminder_unit'] === null ? null : ReminderUnit::getByValue($row['reminder_unit']);
|
$event->reminderUnits = $row['reminder_unit'] === null ? null : ReminderUnit::getByValue($row['reminder_unit']);
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ class CalendarGateway extends CommonDao {
|
|||||||
$currentDate = hesk_date();
|
$currentDate = hesk_date();
|
||||||
$heskSettings['timeformat'] = $oldTimeSetting;
|
$heskSettings['timeformat'] = $oldTimeSetting;
|
||||||
|
|
||||||
$sql = "SELECT `trackid`, `subject`, `due_date`, `category`, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
|
$sql = "SELECT `tickets`.`id` AS `id`, `trackid`, `subject`, `due_date`, `category`, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
|
||||||
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border`,
|
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border`,
|
||||||
CASE WHEN `due_date` < '{$currentDate}' THEN 1 ELSE 0 END AS `overdue`, `owner`.`name` AS `owner_name`, `tickets`.`owner` AS `owner_id`,
|
CASE WHEN `due_date` < '{$currentDate}' THEN 1 ELSE 0 END AS `overdue`, `owner`.`name` AS `owner_name`, `tickets`.`owner` AS `owner_id`,
|
||||||
`tickets`.`priority` AS `priority`
|
`tickets`.`priority` AS `priority`
|
||||||
@ -116,16 +117,17 @@ class CalendarGateway extends CommonDao {
|
|||||||
$rs = hesk_dbQuery($sql);
|
$rs = hesk_dbQuery($sql);
|
||||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||||
$event = new TicketEvent();
|
$event = new TicketEvent();
|
||||||
|
$event->id = intval($row['id']);
|
||||||
$event->trackingId = $row['trackid'];
|
$event->trackingId = $row['trackid'];
|
||||||
$event->subject = $row['subject'];
|
$event->subject = $row['subject'];
|
||||||
$event->title = $row['subject'];
|
$event->title = $row['subject'];
|
||||||
$event->startTime = $row['due_date'];
|
$event->startTime = $row['due_date'];
|
||||||
$event->url = $heskSettings['hesk_url'] . '/' . $heskSettings['admin_dir'] . '/admin_ticket.php?track=' . $event->trackingId;
|
$event->url = $heskSettings['hesk_url'] . '/' . $heskSettings['admin_dir'] . '/admin_ticket.php?track=' . $event->trackingId;
|
||||||
$event->categoryId = intval($row['category']);
|
$event->categoryId = intval($row['category']);
|
||||||
$event->categoryName = $row['category_name'];
|
$event->categoryName = Helpers::heskHtmlSpecialCharsDecode($row['category_name']);
|
||||||
$event->backgroundColor = $row['background_color'];
|
$event->backgroundColor = $row['background_color'];
|
||||||
$event->foregroundColor = $row['foreground_color'];
|
$event->foregroundColor = $row['foreground_color'];
|
||||||
$event->displayBorder = $row['display_border'] === '0';
|
$event->displayBorder = Helpers::boolval($row['display_border']);
|
||||||
$event->owner = $row['owner_name'];
|
$event->owner = $row['owner_name'];
|
||||||
$event->priority = Priority::getByValue($row['priority']);
|
$event->priority = Priority::getByValue($row['priority']);
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ Link::all(array(
|
|||||||
'/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::clazz(), RequestMethod::all(), SecurityHandler::OPEN),
|
'/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::clazz(), RequestMethod::all(), SecurityHandler::OPEN),
|
||||||
// Tickets - Staff
|
// Tickets - Staff
|
||||||
'/v1/staff/tickets/{i}' => action(\Controllers\Tickets\StaffTicketController::clazz(), RequestMethod::all()),
|
'/v1/staff/tickets/{i}' => action(\Controllers\Tickets\StaffTicketController::clazz(), RequestMethod::all()),
|
||||||
|
'/v1/staff/tickets/{i}/due-date' => action(\Controllers\Tickets\StaffTicketController::clazz() . '::updateDueDate', array(RequestMethod::PATCH), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
// Attachments
|
// Attachments
|
||||||
'/v1/tickets/{a}/attachments/{i}' => action(\Controllers\Attachments\PublicAttachmentController::clazz() . '::getRaw', RequestMethod::all()),
|
'/v1/tickets/{a}/attachments/{i}' => action(\Controllers\Attachments\PublicAttachmentController::clazz() . '::getRaw', RequestMethod::all()),
|
||||||
'/v1/staff/tickets/{i}/attachments' => action(\Controllers\Attachments\StaffTicketAttachmentsController::clazz(), RequestMethod::all()),
|
'/v1/staff/tickets/{i}/attachments' => action(\Controllers\Attachments\StaffTicketAttachmentsController::clazz(), RequestMethod::all()),
|
||||||
|
@ -482,15 +482,19 @@ function updateCategoryVisibility() {
|
|||||||
|
|
||||||
function respondToDragAndDrop(event, delta, revertFunc) {
|
function respondToDragAndDrop(event, delta, revertFunc) {
|
||||||
var heskPath = $('p#hesk-path').text();
|
var heskPath = $('p#hesk-path').text();
|
||||||
|
|
||||||
if (event.type === 'TICKET') {
|
if (event.type === 'TICKET') {
|
||||||
|
var uri = 'api/v1/staff/tickets/' + event.id + '/due-date';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: heskPath + 'internal-api/admin/calendar/',
|
url: heskPath + uri,
|
||||||
data: {
|
headers: {
|
||||||
trackingId: event.trackingId,
|
'X-Internal-Call': true,
|
||||||
action: 'update-ticket',
|
'X-HTTP-Method-Override': 'PATCH'
|
||||||
dueDate: event.start.format('YYYY-MM-DD')
|
|
||||||
},
|
},
|
||||||
|
data: JSON.stringify({
|
||||||
|
dueDate: event.start.format('YYYY-MM-DD')
|
||||||
|
}),
|
||||||
success: function() {
|
success: function() {
|
||||||
event.fontIconMarkup = getIcon({
|
event.fontIconMarkup = getIcon({
|
||||||
startTime: event.start
|
startTime: event.start
|
||||||
@ -519,7 +523,6 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
|||||||
end += ' ' + event.end.format('HH:mm:ss');
|
end += ' ' + event.end.format('HH:mm:ss');
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
id: event.id,
|
|
||||||
title: event.title,
|
title: event.title,
|
||||||
location: event.location,
|
location: event.location,
|
||||||
startTime: start,
|
startTime: start,
|
||||||
@ -533,8 +536,12 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
|||||||
};
|
};
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: heskPath + 'internal-api/admin/calendar/',
|
url: heskPath + 'api/v1/calendar/events/staff/' + event.id,
|
||||||
data: data,
|
data: JSON.stringify(data),
|
||||||
|
headers: {
|
||||||
|
'X-Internal-Call': true,
|
||||||
|
'X-HTTP-Method-Override': 'PUT'
|
||||||
|
},
|
||||||
success: function() {
|
success: function() {
|
||||||
mfhAlert.success(mfhLang.text('event_updated'));
|
mfhAlert.success(mfhLang.text('event_updated'));
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user