Edit modal working. Fixed some other issues
This commit is contained in:
parent
1173b23838
commit
4c5d9416cb
@ -253,6 +253,196 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php // End create modal, begin edit modal ?>
|
||||
<div class="modal fade" id="edit-event-modal" tabindex="-1" role="dialog" style="overflow: hidden">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="cursor: move">
|
||||
<button type="button" class="close cancel-callback" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Edit Event</h4>
|
||||
</div>
|
||||
<form id="edit-form" class="form-horizontal" data-toggle="validator">
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-3 control-label">
|
||||
Title
|
||||
<i class="fa fa-question-circle settingsquestionmark"
|
||||
data-toggle="tooltip"
|
||||
title="The title of the event"></i></label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" name="name" class="form-control" placeholder="Title"
|
||||
data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
|
||||
required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="location" class="col-sm-3 control-label">
|
||||
Location
|
||||
<i class="fa fa-question-circle settingsquestionmark"
|
||||
data-toggle="tooltip"
|
||||
title="The location of the event"></i>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" name="location" class="form-control" placeholder="Location"
|
||||
data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
|
||||
required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="start-date" class="col-sm-6 control-label">
|
||||
Start
|
||||
<i class="fa fa-question-circle settingsquestionmark"
|
||||
data-toggle="tooltip"
|
||||
title="The starting date (and time) of the event"></i>
|
||||
</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="start-date" class="form-control datepicker" placeholder="Start Date"
|
||||
data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
|
||||
required>
|
||||
<input type="text" name="start-time" class="form-control clockpicker" placeholder="Start Time" data-placement="left" data-align="top" data-autoclose="true">
|
||||
<div class="help-block with-errors"></div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="all-day"> All day
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="end-date" class="col-sm-6 control-label">
|
||||
End
|
||||
<i class="fa fa-question-circle settingsquestionmark"
|
||||
data-toggle="tooltip"
|
||||
title="The ending date (and time) of the event"></i>
|
||||
</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="end-date" class="form-control datepicker" placeholder="End Date"
|
||||
data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
|
||||
required>
|
||||
<input type="text" name="end-time" class="form-control clockpicker" data-placement="left" data-align="top" data-autoclose="true" placeholder="End Time">
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="comments" class="col-sm-3 control-label">
|
||||
Comments
|
||||
<i class="fa fa-question-circle settingsquestionmark"
|
||||
data-toggle="tooltip"
|
||||
title="Additional comments about the event"></i>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<textarea name="comments" class="form-control" placeholder="Comments"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="create-ticket-date" class="col-sm-6 control-label">
|
||||
Create Ticket Date
|
||||
<i class="fa fa-question-circle settingsquestionmark"
|
||||
data-toggle="tooltip"
|
||||
title="Date to create a ticket for this event. Leave empty to not create a ticket.
|
||||
Set this value to today to create a ticket immediately."></i>
|
||||
</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="create-ticket-date" class="form-control datepicker" placeholder="Create Ticket Date">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<?php
|
||||
if (hesk_checkPermission('can_assign_others',0)) {
|
||||
$admins = array();
|
||||
$result = hesk_dbQuery("SELECT `id`,`name`,`isadmin`,`categories`,`heskprivileges` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `active` = '1' ORDER BY `name` ASC");
|
||||
while ($row = hesk_dbFetchAssoc($result)) {
|
||||
/* Is this an administrator? */
|
||||
if ($row['isadmin']) {
|
||||
$admins[$row['id']] = $row['name'];
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Not admin, is user allowed to view tickets? */
|
||||
if (strpos($row['heskprivileges'], 'can_view_tickets') !== false) {
|
||||
$admins[$row['id']] = $row['name'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="assign-to" class="col-sm-6 control-label">
|
||||
Assign To
|
||||
<i class="fa fa-question-circle settingsquestionmark"
|
||||
data-toggle="tooltip"
|
||||
title="User to assign the ticket to when it is created."></i>
|
||||
</label>
|
||||
<div class="col-sm-6">
|
||||
<select name="assign-to" class="form-control">
|
||||
<?php
|
||||
if ($hesk_settings['autoassign']) {
|
||||
echo '<option value="-2"> > ' . $hesklang['aass'] . ' < </option>';
|
||||
}
|
||||
|
||||
$owner = isset($_SESSION['as_owner']) ? intval($_SESSION['as_owner']) : 0;
|
||||
|
||||
foreach ($admins as $k=>$v) {
|
||||
if ($k == $owner) {
|
||||
echo '<option value="'.$k.'" selected>'.$v.'</option>';
|
||||
} else {
|
||||
echo '<option value="'.$k.'">'.$v.'</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php } elseif (hesk_checkPermission('can_assign_self',0)) { ?>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-6 col-sm-offset-3">
|
||||
<label><input type="checkbox" name="assign-to" value="<?php echo $_SESSION['id']; ?>"> Assign to myself</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input type="hidden" name="action" value="create">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-danger">
|
||||
<i class="fa fa-trash"></i>
|
||||
<span>Delete</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-default cancel-callback" data-dismiss="modal">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
<span>Cancel</span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-success callback-btn">
|
||||
<i class="fa fa-check-circle"></i>
|
||||
<span>Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
|
@ -1820,6 +1820,8 @@ function mfh_log($location, $message, $severity, $user) {
|
||||
$sql = "INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "logging` (`username`, `message`, `severity`, `location`, `timestamp`)
|
||||
VALUES ('" . hesk_dbEscape($user) . "',
|
||||
'" . hesk_dbEscape($message) . "', " . intval($severity) . ", '" . hesk_dbEscape($location) . "', NOW())";
|
||||
|
||||
hesk_dbQuery($sql);
|
||||
}
|
||||
|
||||
function mfh_log_debug($location, $message, $user) {
|
||||
|
@ -23,7 +23,6 @@ if ($request_method === 'GET') {
|
||||
|
||||
return output($events);
|
||||
} elseif ($request_method === 'POST') {
|
||||
// Create or save event
|
||||
$action = hesk_POST('action');
|
||||
|
||||
if ($action === 'create') {
|
||||
|
@ -171,12 +171,13 @@ function hesk_dbQuery($query)
|
||||
}
|
||||
elseif ($hesk_settings['debug_mode'])
|
||||
{
|
||||
$message = $hesklang['mysql_said'] . ': ' . mysqli_error($hesk_db_link);
|
||||
$message = 'Error executing SQL: ' . $query . '; ' . $hesklang['mysql_said'] . ': ' . mysqli_error($hesk_db_link);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $hesklang['contact_webmaster'] . $hesk_settings['webmaster_email'];
|
||||
}
|
||||
mfh_log_error('Internal API', $message, $_SESSION['id']);
|
||||
header('Content-Type: application/json');
|
||||
print_error($hesklang['cant_sql'], $message);
|
||||
die(http_response_code(500));
|
||||
|
@ -16,8 +16,8 @@ function get_events($start, $end, $hesk_settings) {
|
||||
$event['title'] = $row['name'];
|
||||
$event['location'] = $row['location'];
|
||||
$event['comments'] = $row['comments'];
|
||||
$event['create_ticket_date'] = $row['create_ticket_date'] != null ? intval($row['create_ticket_date']) : null;
|
||||
$event['create_ticket_assign_to'] = $row['create_ticket_assign_to'] != null ? intval($row['create_ticket_assign_to']) : null;
|
||||
$event['createTicketDate'] = $row['create_ticket_date'] != null ? $row['create_ticket_date'] : null;
|
||||
$event['assignTo'] = $row['create_ticket_assign_to'] != null ? intval($row['create_ticket_assign_to']) : null;
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
@ -33,7 +33,9 @@ function create_event($event, $hesk_settings) {
|
||||
|
||||
$event['start'] = date('Y-m-d H:i:s', strtotime($event['start']));
|
||||
$event['end'] = date('Y-m-d H:i:s', strtotime($event['end']));
|
||||
if ($event['create_ticket_date'] != null) {
|
||||
$event['create_ticket_date'] = date('Y-m-d H:i:s', strtotime($event['create_ticket_date']));
|
||||
}
|
||||
$event['all_day'] = $event['all_day'] ? 1 : 0;
|
||||
$event['assign_to'] = $event['assign_to'] != null ? intval($event['assign_to']) : 'NULL';
|
||||
|
||||
|
@ -7,6 +7,8 @@ $(document).ready(function() {
|
||||
},
|
||||
editable: true,
|
||||
eventLimit: true,
|
||||
timeFormat: 'H:mm',
|
||||
axisFormat: 'H:mm',
|
||||
events: function(start, end, timezone, callback) {
|
||||
$.ajax({
|
||||
url: getHelpdeskUrl() + '/internal-api/admin/calendar/?start=' + start + '&end=' + end,
|
||||
@ -18,8 +20,6 @@ $(document).ready(function() {
|
||||
events.push(buildEvent(this.id, this));
|
||||
});
|
||||
callback(events);
|
||||
|
||||
//callback w/events here!
|
||||
},
|
||||
error: function(data) {
|
||||
console.error(data);
|
||||
@ -28,6 +28,9 @@ $(document).ready(function() {
|
||||
},
|
||||
dayClick: function(date, jsEvent, view) {
|
||||
displayCreateModal(date, view.name);
|
||||
},
|
||||
eventClick: function(event) {
|
||||
displayEditModal(event);
|
||||
}
|
||||
});
|
||||
|
||||
@ -37,6 +40,12 @@ $(document).ready(function() {
|
||||
$('#create-form .clockpicker').css('display', hideTimeFields ? 'none' : 'block');
|
||||
});
|
||||
|
||||
$('#edit-form input[name="all-day"]').change(function() {
|
||||
var hideTimeFields = $(this).is(':checked');
|
||||
|
||||
$('#edit-form .clockpicker').css('display', hideTimeFields ? 'none' : 'block');
|
||||
});
|
||||
|
||||
$('#create-form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
@ -95,6 +104,10 @@ function addToCalendar(id, event) {
|
||||
}
|
||||
|
||||
function buildEvent(id, dbObject) {
|
||||
var createTicketDate = null;
|
||||
if (dbObject.createTicketDate != null) {
|
||||
createTicketDate = moment(dbObject.createTicketDate);
|
||||
}
|
||||
return {
|
||||
id: id,
|
||||
title: dbObject.title,
|
||||
@ -102,17 +115,18 @@ function buildEvent(id, dbObject) {
|
||||
start: moment(dbObject.startTime),
|
||||
end: moment(dbObject.endTime),
|
||||
comments: dbObject.comments,
|
||||
createTicketDate: dbObject.createTicketDate,
|
||||
createTicketDate: createTicketDate,
|
||||
assignTo: dbObject.assignTo,
|
||||
location: dbObject.location
|
||||
};
|
||||
}
|
||||
|
||||
function displayCreateModal(date, viewName) {
|
||||
$('#create-form input[name="name"]').val('');
|
||||
$('#create-form input[name="location"]').val('');
|
||||
$('#create-form textarea[name="comments"]').val('');
|
||||
$('#create-form input[name="create-ticket-date"]').val('');
|
||||
var $form = $('#create-form');
|
||||
$form.find('input[name="name"]').val('').end()
|
||||
.find('input[name="location"]').val('').end()
|
||||
.find('textarea[name="comments"]').val('').end()
|
||||
.find('input[name="create-ticket-date"]').val('').end();
|
||||
|
||||
var $modal = $('#create-event-modal');
|
||||
var formattedDate = date.format('YYYY-MM-DD');
|
||||
@ -120,16 +134,48 @@ function displayCreateModal(date, viewName) {
|
||||
.find('input[name="end-date"]').val(formattedDate).end();
|
||||
if (viewName === 'month') {
|
||||
// Select "All Day"
|
||||
$('#create-form input[name="all-day"]').prop('checked', true);
|
||||
$('#create-form .clockpicker').hide();
|
||||
$form.find('input[name="all-day"]').prop('checked', true).end()
|
||||
.find('.clockpicker').hide();
|
||||
} else {
|
||||
$('#create-form input[name="all-day"]').prop('checked', false);
|
||||
$('#create-form .clockpicker').show();
|
||||
var formattedTime = date.format('h:mm:ss');
|
||||
$form.find('input[name="all-day"]').prop('checked', false).end()
|
||||
.find('.clockpicker').show();
|
||||
var formattedTime = date.format('H:mm:ss');
|
||||
var selectedHour = date.hour();
|
||||
$modal.find('input[name="start-time"]').val(formattedTime).end()
|
||||
.find('input[name="end-time"]').val(date.hour(selectedHour + 1).format('h:mm:ss'));
|
||||
.find('input[name="end-time"]').val(date.hour(selectedHour + 1).format('H:mm:ss'));
|
||||
}
|
||||
|
||||
$('#create-event-modal').modal('show');
|
||||
$modal.modal('show');
|
||||
}
|
||||
|
||||
function displayEditModal(date) {
|
||||
var $form = $('#edit-form');
|
||||
|
||||
if (date.end === null) {
|
||||
// FullCalendar will set the end date to null if it is the same as the start date.
|
||||
date.end = date.start.clone();
|
||||
}
|
||||
|
||||
if (date.allDay) {
|
||||
$form.find('input[name="all-day"]').prop('checked', true).end()
|
||||
.find('input[name="start-time"]').hide().end()
|
||||
.find('input[name="end-time"]').hide().end();
|
||||
} else {
|
||||
$form.find('input[name="all-day"]').prop('checked', false).end()
|
||||
.find('.clockpicker').show().end()
|
||||
.find('input[name="start-time"]').val(date.start.format('H:mm:ss')).end()
|
||||
.find('input[name="end-time"]').val(date.end.format('H:mm:ss')).end();
|
||||
}
|
||||
|
||||
if (date.createTicketDate != null) {
|
||||
$form.find('input[name="create-ticket-date"]').val(date.createTicketDate.format('YYYY-MM-DD')).end();
|
||||
}
|
||||
|
||||
$form.find('input[name="name"]').val(date.title).end()
|
||||
.find('input[name="location"]').val(date.location).end()
|
||||
.find('textarea[name="comments"]').val(date.comments).end()
|
||||
.find('input[name="start-date"]').val(date.start.format('YYYY-MM-DD')).end()
|
||||
.find('input[name="end-date"]').val(date.end.format('YYYY-MM-DD')).end();
|
||||
|
||||
$('#edit-event-modal').modal('show');
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user