Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion db/cats_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ CREATE TABLE `calendar_event` (
`date_created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`date_modified` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`site_id` int(11) NOT NULL DEFAULT '0',
`joborder_id` int(11) NOT NULL DEFAULT '-1',
`joborder_id` int(11) DEFAULT NULL,
`description` text COLLATE utf8_unicode_ci,
`duration` int(11) NOT NULL DEFAULT '60',
`reminder_enabled` int(1) NOT NULL DEFAULT '0',
Expand Down
30 changes: 24 additions & 6 deletions lib/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ public function getAllEventTypes()
* if none.
* @param flag Data Item type flag corresponding with $dataItemID, or -1
* if none.
* @param integer Job Order ID with which to associate this event, or -1
* if none.
* @param integer|null Job Order ID with which to associate this event, or
* NULL if none.
* @param string Short event title.
* @param integer Event duration in minutes.
* @param boolean Enable reminders?
Expand All @@ -299,6 +299,15 @@ public function addEvent($type, $date, $description, $allDay, $enteredBy,
$reminderEnabled, $reminderEmail, $reminderTime, $isPublic,
$timeZoneOffset)
{
if ($jobOrderID === null)
{
$jobOrderIDSQL = 'NULL';
}
else
{
$jobOrderIDSQL = $this->_db->makeQueryInteger($jobOrderID);
}

$sql = sprintf(
"INSERT INTO calendar_event (
type,
Expand Down Expand Up @@ -346,7 +355,7 @@ public function addEvent($type, $date, $description, $allDay, $enteredBy,
$this->_db->makeQueryInteger($enteredBy),
$this->_db->makeQueryInteger($dataItemID),
$this->_db->makeQueryInteger($dataItemType),
$this->_db->makeQueryInteger($jobOrderID),
$jobOrderIDSQL,
$this->_siteID,
$this->_db->makeQueryString($title),
$this->_db->makeQueryInteger($duration),
Expand Down Expand Up @@ -377,8 +386,8 @@ public function addEvent($type, $date, $description, $allDay, $enteredBy,
* if none.
* @param flag Data Item type flag corresponding with $dataItemID, or -1
* if none.
* @param integer Job Order ID with which to associate this event, or -1
* if none.
* @param integer|null Job Order ID with which to associate this event, or
* NULL if none.
* @param string Short event title.
* @param integer Event duration in minutes.
* @param boolean Enable reminders?
Expand All @@ -394,6 +403,15 @@ public function updateEvent($eventID, $type, $date, $description, $allDay,
$reminderEnabled, $reminderEmail, $reminderTime, $isPublic,
$timeZoneOffset)
{
if ($jobOrderID === null)
{
$jobOrderIDSQL = 'NULL';
}
else
{
$jobOrderIDSQL = $this->_db->makeQueryInteger($jobOrderID);
}

$sql = sprintf(
"UPDATE
calendar_event
Expand Down Expand Up @@ -423,7 +441,7 @@ public function updateEvent($eventID, $type, $date, $description, $allDay,
($allDay ? '1' : '0'),
$this->_db->makeQueryInteger($dataItemID),
$this->_db->makeQueryInteger($dataItemType),
$this->_db->makeQueryInteger($jobOrderID),
$jobOrderIDSQL,
$this->_db->makeQueryString($title),
$this->_db->makeQueryInteger($duration),
($reminderEnabled ? '1' : '0'),
Expand Down
15 changes: 15 additions & 0 deletions lib/JobOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,21 @@ public function delete($jobOrderID)
$history = new History($this->_siteID);
$history->storeHistoryDeleted(DATA_ITEM_JOBORDER, $jobOrderID);

/* Clear calendar event associations for this job order. */
$sql = sprintf(
"UPDATE
calendar_event
SET
joborder_id = NULL
WHERE
joborder_id = %s
AND
site_id = %s",
$this->_db->makeQueryInteger($jobOrderID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete pipeline entries from candidate_joborder. */
$sql = sprintf(
"DELETE FROM
Expand Down
6 changes: 3 additions & 3 deletions modules/calendar/CalendarUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ private function onAddEvent()

$calendar = new Calendar($this->_siteID);
$eventID = $calendar->addEvent(
$type, $date, $description, $allDay, $this->_userID, -1, -1, -1,
$type, $date, $description, $allDay, $this->_userID, -1, -1, null,
$title, $duration, $reminderEnabled, $reminderEmail, $reminderTime,
$publicEntry, $timeZoneOffset
);
Expand Down Expand Up @@ -559,7 +559,7 @@ private function onEditEvent()
}
else
{
$jobOrderID = 'NULL';
$jobOrderID = null;
}

/* Bail out if we received an invalid date. */
Expand Down Expand Up @@ -664,7 +664,7 @@ private function onEditEvent()
/* Update the event. */
$calendar = new Calendar($this->_siteID);
if (!$calendar->updateEvent($eventID, $type, $date, $description,
$allDay, $dataItemID, $dataItemType, 'NULL', $title, $duration,
$allDay, $dataItemID, $dataItemType, $jobOrderID, $title, $duration,
$reminderEnabled, $reminderEmail, $reminderTime, $publicEntry,
$_SESSION['CATS']->getTimeZoneOffset()))
{
Expand Down
2 changes: 1 addition & 1 deletion modules/candidates/CandidatesUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3289,7 +3289,7 @@ private function _addActivity($isJobOrdersMode, $regardingID,
}
else
{
$eventJobOrderID = -1;
$eventJobOrderID = null;
}

$calendar = new Calendar($this->_siteID);
Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/ContactsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ private function _addActivityScheduleEvent($regardingID, $directoryOverride = ''
}
else
{
$eventJobOrderID = -1;
$eventJobOrderID = null;
}

$calendar = new Calendar($this->_siteID);
Expand Down
19 changes: 19 additions & 0 deletions modules/install/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,25 @@ public static function get()
SET short_description = \'Not reached\'
WHERE activity_type_id = 100;
',
'377' => '
ALTER TABLE `calendar_event` MODIFY `joborder_id` int(11) NULL DEFAULT NULL;

UPDATE `calendar_event`
SET `joborder_id` = NULL
WHERE `joborder_id` = -1;

UPDATE
`calendar_event` AS `ce`
LEFT JOIN
`joborder` AS `jo` ON
`ce`.`joborder_id` = `jo`.`joborder_id` AND
`ce`.`site_id` = `jo`.`site_id`
SET
`ce`.`joborder_id` = NULL
WHERE
`ce`.`joborder_id` IS NOT NULL AND
`jo`.`joborder_id` IS NULL;
',

);
}
Expand Down
Loading