From b9a1b7fe6baf30d710ae50b26146fe0f565245cb Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 13 Jan 2016 22:08:08 -0500 Subject: [PATCH] Add ability to retrieve events. Also change dates to epoch format --- install/mods-for-hesk/sql/installSql.php | 6 +++--- internal-api/admin/calendar/index.php | 27 ++++++++++++++++++++++++ internal-api/dao/calendar_dao.php | 25 ++++++++++++++++++++++ js/calendar/mods-for-hesk-calendar.js | 17 ++++++++++++++- 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 internal-api/admin/calendar/index.php create mode 100644 internal-api/dao/calendar_dao.php diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 2d82c026..3517bc08 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -722,13 +722,13 @@ function execute260Scripts() `date_uploaded` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `start` TIMESTAMP, - `end` TIMESTAMP, + `start` INT, + `end` INT, `all_day` ENUM('0','1') NOT NULL, `name` VARCHAR(255) NOT NULL, `location` VARCHAR(255), `comments` MEDIUMTEXT, - `create_ticket_date` TIMESTAMP NOT NULL, + `create_ticket_date` INT, `create_ticket_assign_to` INT) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.6.0' WHERE `Key` = 'modsForHeskVersion'"); } \ No newline at end of file diff --git a/internal-api/admin/calendar/index.php b/internal-api/admin/calendar/index.php new file mode 100644 index 00000000..bab7dab2 --- /dev/null +++ b/internal-api/admin/calendar/index.php @@ -0,0 +1,27 @@ += " . intval($start) + . " AND `end` <= " . intval($end); + + $rs = hesk_dbQuery($sql); + + $events = []; + while ($row = hesk_dbFetchAssoc($rs)) { + $event['id'] = intval($row['id']); + $event['start'] = intval($row['start']); + $event['end'] = intval($row['end']); + $event['all_day'] = $row['all_day'] ? true : false; + $event['name'] = $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; + $events[] = $event; + } + + return $events; +} \ No newline at end of file diff --git a/js/calendar/mods-for-hesk-calendar.js b/js/calendar/mods-for-hesk-calendar.js index 38cf6c72..9bc140d9 100644 --- a/js/calendar/mods-for-hesk-calendar.js +++ b/js/calendar/mods-for-hesk-calendar.js @@ -6,6 +6,21 @@ $(document).ready(function() { right: 'month,agendaWeek,agendaDay' }, editable: true, - eventLimit: true + eventLimit: true, + events: function(start, end, timezone, callback) { + console.log('in events'); + $.ajax({ + url: getHelpdeskUrl() + '/internal-api/admin/calendar/?start=' + start + '&end=' + end, + method: 'GET', + dataType: 'json', + success: function(data) { + console.info(data); + //callback w/events here! + }, + error: function(data) { + console.error(data); + } + }); + } }); }); \ No newline at end of file