Browse Source

Fix saving ticket due dates. Still need to contentify

merge-requests/1/head
Mike Koch 6 years ago
parent
commit
e252038b55
  1. 6
      admin/admin_ticket.php
  2. 3
      internal-api/admin/calendar/index.php
  3. 7
      internal-api/dao/calendar_dao.php
  4. 2
      internal-api/js/admin-ticket.js

6
admin/admin_ticket.php

@ -687,10 +687,12 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
<button id="due-date-button" class="btn btn-default btn-sm">Change</button>
</div>
<div id="editable-due-date" style="display: none">
<input type="text" class="form-control datepicker" name="due-date" value="<?php echo $due_date == 'None' ? '' : substr($due_date, 0, 10); ?>"><br>
<div class="form-group">
<input type="text" class="form-control datepicker" name="due-date" value="<?php echo $due_date == 'None' ? '' : substr($due_date, 0, 10); ?>">
<p class="help-block">Clear for no due date</p>
</div>
<div class="btn-group">
<button id="submit" class="btn btn-primary">Save</button>
<button id="clear" class="btn btn-danger">No Due Date</button>
<button id="cancel" class="btn btn-default">Cancel</button>
</div>
</div>

3
internal-api/admin/calendar/index.php

@ -70,6 +70,9 @@ if ($request_method === 'GET') {
return http_response_code(200);
} elseif ($action === 'update-ticket') {
$ticket['due_date'] = hesk_POST('dueDate');
if ($ticket['due_date'] == '') {
$ticket['due_date'] = NULL;
}
$ticket['trackid'] = hesk_POST('trackingId');
update_ticket_due_date($ticket, $hesk_settings);

7
internal-api/dao/calendar_dao.php

@ -133,8 +133,11 @@ function delete_event($id, $hesk_settings) {
}
function update_ticket_due_date($ticket, $hesk_settings) {
$due_date = date('Y-m-d H:i:s', strtotime($ticket['due_date']));
$sql = "UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `due_date` = '" . $due_date . "'
$due_date = 'NULL';
if ($ticket['due_date'] != NULL) {
$due_date = "'" . date('Y-m-d H:i:s', strtotime($ticket['due_date'])) . "'";
}
$sql = "UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `due_date` = {$due_date}
WHERE `trackid` = '" . hesk_dbEscape($ticket['trackid']) . "'";
hesk_dbQuery($sql);

2
internal-api/js/admin-ticket.js

@ -25,7 +25,7 @@ $(document).ready(function() {
},
success: function() {
$.jGrowl('Ticket due date successfully updated', { theme: 'alert-success', closeTemplate: '' });
$readonlyDueDateContainer.find('span#due-date').text(newDueDate);
$readonlyDueDateContainer.find('span#due-date').text(newDueDate == '' ? 'None' : newDueDate);
$readonlyDueDateContainer.show();
$editableDueDateContainer.hide();
},

Loading…
Cancel
Save