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
9 changes: 8 additions & 1 deletion ajax/editActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

$activityID = $_REQUEST['activityID'];
$type = $_REQUEST['type'];
$jobOrderID = $_REQUEST['jobOrderID'];
$jobOrderID = isset($_REQUEST['jobOrderID']) ? trim($_REQUEST['jobOrderID']) : null;

/* Decode and trim the activity notes from the company. */
$activityNote = trim(urldecode($_REQUEST['notes']));
Expand All @@ -78,6 +78,13 @@
return;
}

if ($jobOrderID === null || $jobOrderID === '' || $jobOrderID === 'NULL' ||
$jobOrderID === '0' || $jobOrderID === '-1' || !is_numeric($jobOrderID) ||
(int) $jobOrderID <= 0)
{
$jobOrderID = -1;
}

/* Convert formatted time to UNIX timestamp. */
$time = strtotime(
sprintf('%02d:%02d %s', $activityHour, $activityMinute, $activityAMPM)
Expand Down
26 changes: 22 additions & 4 deletions js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,20 @@ function Activity_fillTypeSelect(selectList, selectedText)
}
}

function Activity_fillRegardingSelect(selectList, jobOrderNodes, selectedText)
function Activity_fillRegardingSelect(selectList, jobOrderNodes, selectedText, selectedJobOrderID)
{
var hasValidJobOrderID = false;

if (selectedJobOrderID && selectedJobOrderID.match(/^\d+$/) && selectedJobOrderID != '0')
{
hasValidJobOrderID = true;
}

/* General option. */
generalOption = document.createElement('option');
generalOption.value = 'NULL';
generalOption.appendChild(document.createTextNode('General'));
if (selectedText == 'General')
if (!hasValidJobOrderID)
{
generalOption.setAttribute('selected', 'selected');
}
Expand Down Expand Up @@ -153,10 +160,15 @@ function Activity_fillRegardingSelect(selectList, jobOrderNodes, selectedText)

option.value = IDNode.firstChild.nodeValue;
option.appendChild(document.createTextNode(optionText));
if (selectedText == optionText)
if (hasValidJobOrderID && option.value == selectedJobOrderID)
{
option.setAttribute('selected', 'selected');
}
else if (!hasValidJobOrderID && selectedText == optionText)
{
generalOption.removeAttribute('selected');
option.setAttribute('selected', 'selected');
}
selectList.appendChild(option);
}
}
Expand Down Expand Up @@ -235,10 +247,16 @@ function Activity_editEntry(activityID, dataItemID, dataItemType, sessionCookie)

/* Create the "Regarding" select list and add options to it. */
var regardingSelectList = document.createElement('select');
var selectedJobOrderID = '';
if (regardingTD && regardingTD.getAttribute)
{
selectedJobOrderID = regardingTD.getAttribute('data-joborder-id');
}
Activity_fillRegardingSelect(
regardingSelectList,
http.responseXML.getElementsByTagName('joborder'),
regardingTD.firstChild.nodeValue
regardingTD.firstChild.nodeValue,
selectedJobOrderID
);
regardingSelectList.className = 'inputbox';

Expand Down
26 changes: 19 additions & 7 deletions lib/ActivityEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,17 @@ public function __construct($siteID)
* @param flag Activity type flag.
* @param string Activity notes.
* @param integer Entered-by user ID.
* @param integer Job Order ID; -1 for general.
* @param integer Job Order ID; -1 for general (stored as NULL).
* @return integer New Activity ID; -1 on failure.
*/
public function add($dataItemID, $dataItemType, $activityType,
$activityNotes, $enteredBy, $jobOrderID = -1)
{
if (!ctype_digit((string) $jobOrderID) || (int) $jobOrderID <= 0)
{
$jobOrderID = -1;
}

$sql = sprintf(
"INSERT INTO activity (
data_item_id,
Expand All @@ -111,7 +116,7 @@ public function add($dataItemID, $dataItemType, $activityType,
)",
$this->_db->makeQueryInteger($dataItemID),
$this->_db->makeQueryInteger($dataItemType),
$this->_db->makeQueryInteger($jobOrderID),
$this->_db->makeQueryIntegerOrNULL($jobOrderID),
$this->_db->makeQueryInteger($enteredBy),
$this->_db->makeQueryInteger($activityType),
$this->_db->makeQueryString($activityNotes),
Expand Down Expand Up @@ -142,7 +147,8 @@ public function add($dataItemID, $dataItemType, $activityType,
/* If there is a job order being associated, update it's modified
* timestamp, too.
*/
if ($jobOrderID != -1)
if (!empty($jobOrderID) && ctype_digit((string) $jobOrderID) &&
(int) $jobOrderID > 0)
{
$this->_updateDataItemModified($jobOrderID, DATA_ITEM_JOBORDER);
}
Expand All @@ -156,7 +162,7 @@ public function add($dataItemID, $dataItemType, $activityType,
* @param integer Activity ID to update.
* @param flag New activity type flag.
* @param string New activity notes.
* @param integer New Job Order ID; -1 for general.
* @param integer New Job Order ID; -1 for general (stored as NULL).
* @return boolean True if successful; false otherwise.
*/
public function update($activityID, $activityType, $activityNotes,
Expand Down Expand Up @@ -203,6 +209,11 @@ public function update($activityID, $activityType, $activityNotes,
$newJobOrderID = $jobOrderID;
}

if (!ctype_digit((string) $newJobOrderID) || (int) $newJobOrderID <= 0)
{
$newJobOrderID = -1;
}

$sql = sprintf(
"UPDATE
activity
Expand All @@ -217,7 +228,7 @@ public function update($activityID, $activityType, $activityNotes,
site_id = %s",
$this->_db->makeQueryInteger($activityType),
$this->_db->makeQueryString($activityNotes),
$this->_db->makeQueryInteger($newJobOrderID),
$this->_db->makeQueryIntegerOrNULL($newJobOrderID),
$this->_db->makeQueryInteger($activityID),
$this->_siteID
);
Expand Down Expand Up @@ -267,7 +278,8 @@ public function update($activityID, $activityType, $activityNotes,
/* If there is a job order being associated, update it's modified
* timestamp, too.
*/
if (!empty($jobOrderID) && ctype_digit((string) $jobOrderID))
if (!empty($jobOrderID) && ctype_digit((string) $jobOrderID) &&
(int) $jobOrderID > 0)
{
$this->_updateDataItemModified($jobOrderID, DATA_ITEM_JOBORDER);
}
Expand All @@ -276,7 +288,7 @@ public function update($activityID, $activityType, $activityNotes,
* is valid, update its modified timestamp, too.
*/
if (!empty($newJobOrderID) && ctype_digit((string) $newJobOrderID) &&
$jobOrderID != $newJobOrderID)
(int) $newJobOrderID > 0 && $jobOrderID != $newJobOrderID)
{
$this->_updateDataItemModified($newJobOrderID, DATA_ITEM_JOBORDER);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/candidates/Show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ use OpenCATS\UI\CandidateDuplicateQuickActionMenu;
<td align="left" valign="top" id="activityDate<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['dateCreated']) ?></td>
<td align="left" valign="top" id="activityType<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['typeDescription']) ?></td>
<td align="left" valign="top"><?php $this->_($activityData['enteredByAbbrName']) ?></td>
<td align="left" valign="top" id="activityRegarding<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['regarding']) ?></td>
<td align="left" valign="top" id="activityRegarding<?php echo($activityData['activityID']); ?>" data-joborder-id="<?php echo(isset($activityData['jobOrderID']) ? $activityData['jobOrderID'] : ''); ?>"><?php $this->_($activityData['regarding']) ?></td>
<td align="left" valign="top" id="activityNotes<?php echo($activityData['activityID']); ?>"><?php echo($activityData['notes']); ?></td>
<?php if (!$this->isPopup): ?>
<td align="center" >
Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/Show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ use OpenCATS\UI\QuickActionMenu;
<td align="left" valign="top" id="activityDate<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['dateCreated']) ?></td>
<td align="left" valign="top" id="activityType<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['typeDescription']) ?></td>
<td align="left" valign="top"><?php $this->_($activityData['enteredByAbbrName']) ?></td>
<td align="left" valign="top" id="activityRegarding<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['regarding']) ?></td>
<td align="left" valign="top" id="activityRegarding<?php echo($activityData['activityID']); ?>" data-joborder-id="<?php echo(isset($activityData['jobOrderID']) ? $activityData['jobOrderID'] : ''); ?>"><?php $this->_($activityData['regarding']) ?></td>
<td align="left" valign="top" id="activityNotes<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['notes']) ?></td>
<td align="center" >
<?php if ($this->getUserAccessLevel('contacts.editActivity') >= ACCESS_LEVEL_EDIT): ?>
Expand Down
5 changes: 5 additions & 0 deletions modules/install/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,11 @@ public static function get()
'364' => '
UPDATE user SET password = md5(password) WHERE can_change_password=1;
',
'365' => '
UPDATE `activity`
SET `joborder_id` = NULL
WHERE `joborder_id` IN (0, -1);
',

);
}
Expand Down
Loading