Browse Source

Getting started on reminders

merge-requests/1/head
Mike Koch 6 years ago
parent
commit
31a69cebe9
  1. 23
      admin/calendar.php
  2. 6
      install/mods-for-hesk/sql/installSql.php
  3. 4
      internal-api/admin/calendar/index.php
  4. 12
      internal-api/dao/calendar_dao.php
  5. 16
      js/calendar/mods-for-hesk-calendar.js

23
admin/calendar.php

@ -200,6 +200,29 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="reminder" class="col-sm-3 control-label">
Reminder
<i class="fa fa-question-circle settingsquestionmark"
data-toggle="tooltip"
title="Receive an e-mail reminder for this event. Only you will receive this reminder email."></i>
</label>
<div class="col-sm-2">
<input type="text" name="reminder-value" class="form-control" placeholder="#">
</div>
<div class="col-sm-4">
<select name="reminder-unit" class="form-control">
<option value="0">minutes before event</option>
<option value="1">hours before event</option>
<option value="2">days before event</option>
<option value="3">weeks before event</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">

6
install/mods-for-hesk/sql/installSql.php

@ -729,6 +729,12 @@ function execute260Scripts()
`location` VARCHAR(255),
`comments` MEDIUMTEXT,
`category` INT NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`event_id` INT NOT NULL,
`amount` INT NOT NULL,
`unit` INT NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `due_date` DATETIME");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ADD COLUMN `color` VARCHAR(7)");
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.6.0' WHERE `Key` = 'modsForHeskVersion'");

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

@ -33,6 +33,10 @@ if ($request_method === 'GET') {
$event['all_day'] = hesk_POST('allDay') === 'true';
$event['comments'] = hesk_POST('comments');
$event['category'] = hesk_POST('categoryId');
$event['reminder_amount'] = hesk_POST('reminderValue');
$event['reminder_amount'] = $event['reminder_amount'] == '' ? null : $event['reminder_amount'];
$event['reminder_units'] = hesk_POST('reminderUnits');
$event['reminder_user'] = $_SESSION['id'];
$id = create_event($event, $hesk_settings);

12
internal-api/dao/calendar_dao.php

@ -64,7 +64,17 @@ function create_event($event, $hesk_settings) {
" . intval($event['category']) . ")";
hesk_dbQuery($sql);
return hesk_dbInsertID();
$event_id = hesk_dbInsertID();
if ($event['reminder_amount'] != null) {
$sql = "INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` (`user_id`, `event_id`,
`amount`, `unit`) VALUES (" . intval($event['reminder_user']) . ", " . intval($event_id) . ", " . intval($event['reminder_amount']) . ",
" . intval($event['reminder_units']) . ")";
hesk_dbQuery($sql);
}
return $event_id;
}
function update_event($event, $hesk_settings) {

16
js/calendar/mods-for-hesk-calendar.js

@ -76,7 +76,9 @@ $(document).ready(function() {
allDay: event.allDay,
comments: event.comments,
categoryId: event.categoryId,
action: 'update'
action: 'update',
reminderValue: event.reminderValue,
reminderUnits: event.reminderUnits
};
$.ajax({
method: 'POST',
@ -205,7 +207,9 @@ $(document).ready(function() {
action: 'create',
type: 'CALENDAR',
categoryColor: $('#create-form select[name="category"] :selected').attr('data-color'),
categoryName: $('#create-form select[name="category"] :selected').text().trim()
categoryName: $('#create-form select[name="category"] :selected').text().trim(),
reminderValue: $('#create-form input[name="reminder-value"]').val(),
reminderUnits: $('#create-form select[name="reminder-unit"]').val()
};
$.ajax({
@ -249,7 +253,9 @@ $(document).ready(function() {
categoryId: $form.find('select[name="category"]').val(),
categoryColor: $form.find('select[name="category"] :selected').attr('data-color'),
categoryName: $form.find('select[name="category"] :selected').text().trim(),
action: 'update'
action: 'update',
reminderValue: $form.find('input[name="reminder-value"]').val(),
reminderUnits: $form.find('select[name="reminder-units"]').val()
};
$.ajax({
@ -315,7 +321,9 @@ function buildEvent(id, dbObject) {
categoryName: dbObject.categoryName,
className: 'category-' + dbObject.categoryId,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
textColor: calculateTextColor(dbObject.categoryColor)
textColor: calculateTextColor(dbObject.categoryColor),
reminderValue: dbObject.reminderValue == null ? '' : dbObject.reminderValue,
reminderUnits: dbObject.reminderUnits
};
}

Loading…
Cancel
Save