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 {
|
||||
public $id;
|
||||
|
||||
public $startTime;
|
||||
|
||||
public $title;
|
||||
|
@ -4,8 +4,6 @@ namespace BusinessLogic\Calendar;
|
||||
|
||||
|
||||
class CalendarEvent extends AbstractEvent {
|
||||
public $id;
|
||||
|
||||
public $type = 'CALENDAR';
|
||||
|
||||
public $endTime;
|
||||
|
@ -30,4 +30,8 @@ class Helpers extends \BaseClass {
|
||||
static function boolval($val) {
|
||||
return $val == true;
|
||||
}
|
||||
|
||||
static function heskHtmlSpecialCharsDecode($in) {
|
||||
return str_replace(array('&', '<', '>', '"'), array('&', '<', '>', '"'), $in);
|
||||
}
|
||||
}
|
@ -53,7 +53,11 @@ class StaffTicketController extends \BaseClass {
|
||||
/* @var $ticketEditor TicketEditor */
|
||||
$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) {
|
||||
|
@ -8,6 +8,7 @@ use BusinessLogic\Calendar\CalendarEvent;
|
||||
use BusinessLogic\Calendar\ReminderUnit;
|
||||
use BusinessLogic\Calendar\SearchEventsFilter;
|
||||
use BusinessLogic\Calendar\TicketEvent;
|
||||
use BusinessLogic\Helpers;
|
||||
use BusinessLogic\Security\UserContext;
|
||||
use Core\Constants\Priority;
|
||||
use DataAccess\CommonDao;
|
||||
@ -61,15 +62,15 @@ class CalendarGateway extends CommonDao {
|
||||
$event->id = intval($row['id']);
|
||||
$event->startTime = $row['start'];
|
||||
$event->endTime = $row['end'];
|
||||
$event->allDay = $row['all_day'] ? true : false;
|
||||
$event->allDay = Helpers::boolval($row['all_day']);
|
||||
$event->title = $row['name'];
|
||||
$event->location = $row['location'];
|
||||
$event->comments = $row['comments'];
|
||||
$event->categoryId = intval($row['category']);
|
||||
$event->categoryName = $row['category_name'];
|
||||
$event->categoryName = Helpers::heskHtmlSpecialCharsDecode($row['category_name']);
|
||||
$event->backgroundColor = $row['background_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->reminderUnits = $row['reminder_unit'] === null ? null : ReminderUnit::getByValue($row['reminder_unit']);
|
||||
|
||||
@ -83,7 +84,7 @@ class CalendarGateway extends CommonDao {
|
||||
$currentDate = hesk_date();
|
||||
$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`,
|
||||
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`
|
||||
@ -116,16 +117,17 @@ class CalendarGateway extends CommonDao {
|
||||
$rs = hesk_dbQuery($sql);
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
$event = new TicketEvent();
|
||||
$event->id = intval($row['id']);
|
||||
$event->trackingId = $row['trackid'];
|
||||
$event->subject = $row['subject'];
|
||||
$event->title = $row['subject'];
|
||||
$event->startTime = $row['due_date'];
|
||||
$event->url = $heskSettings['hesk_url'] . '/' . $heskSettings['admin_dir'] . '/admin_ticket.php?track=' . $event->trackingId;
|
||||
$event->categoryId = intval($row['category']);
|
||||
$event->categoryName = $row['category_name'];
|
||||
$event->categoryName = Helpers::heskHtmlSpecialCharsDecode($row['category_name']);
|
||||
$event->backgroundColor = $row['background_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->priority = Priority::getByValue($row['priority']);
|
||||
|
||||
|
@ -194,6 +194,7 @@ Link::all(array(
|
||||
'/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::clazz(), RequestMethod::all(), SecurityHandler::OPEN),
|
||||
// Tickets - Staff
|
||||
'/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
|
||||
'/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()),
|
||||
|
@ -482,15 +482,19 @@ function updateCategoryVisibility() {
|
||||
|
||||
function respondToDragAndDrop(event, delta, revertFunc) {
|
||||
var heskPath = $('p#hesk-path').text();
|
||||
|
||||
if (event.type === 'TICKET') {
|
||||
var uri = 'api/v1/staff/tickets/' + event.id + '/due-date';
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: heskPath + 'internal-api/admin/calendar/',
|
||||
data: {
|
||||
trackingId: event.trackingId,
|
||||
action: 'update-ticket',
|
||||
dueDate: event.start.format('YYYY-MM-DD')
|
||||
url: heskPath + uri,
|
||||
headers: {
|
||||
'X-Internal-Call': true,
|
||||
'X-HTTP-Method-Override': 'PATCH'
|
||||
},
|
||||
data: JSON.stringify({
|
||||
dueDate: event.start.format('YYYY-MM-DD')
|
||||
}),
|
||||
success: function() {
|
||||
event.fontIconMarkup = getIcon({
|
||||
startTime: event.start
|
||||
@ -519,7 +523,6 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
||||
end += ' ' + event.end.format('HH:mm:ss');
|
||||
}
|
||||
var data = {
|
||||
id: event.id,
|
||||
title: event.title,
|
||||
location: event.location,
|
||||
startTime: start,
|
||||
@ -533,8 +536,12 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
||||
};
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: heskPath + 'internal-api/admin/calendar/',
|
||||
data: data,
|
||||
url: heskPath + 'api/v1/calendar/events/staff/' + event.id,
|
||||
data: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-Internal-Call': true,
|
||||
'X-HTTP-Method-Override': 'PUT'
|
||||
},
|
||||
success: function() {
|
||||
mfhAlert.success(mfhLang.text('event_updated'));
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user