Skip to content
Merged
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
6 changes: 5 additions & 1 deletion db/cats_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CREATE TABLE `activity` (
`joborder_id` int(11) DEFAULT NULL,
`site_id` int(11) NOT NULL DEFAULT '0',
`entered_by` int(11) NOT NULL DEFAULT '0',
`date_occurred` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`date_created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`type` int(11) NOT NULL DEFAULT '0',
`notes` text COLLATE utf8_unicode_ci,
Expand All @@ -51,10 +52,13 @@ CREATE TABLE `activity` (
KEY `IDX_type_id` (`data_item_type`,`data_item_id`),
KEY `IDX_joborder_id` (`joborder_id`),
KEY `IDX_date_created` (`date_created`),
KEY `IDX_date_occurred` (`date_occurred`),
KEY `IDX_date_modified` (`date_modified`),
KEY `IDX_data_item_id_type_site` (`site_id`,`data_item_id`,`data_item_type`),
KEY `IDX_site_created` (`site_id`,`date_created`),
KEY `IDX_activity_site_type_created_job` (`site_id`,`data_item_type`,`date_created`,`entered_by`,`joborder_id`)
KEY `IDX_site_occurred` (`site_id`,`date_occurred`),
KEY `IDX_activity_site_type_created_job` (`site_id`,`data_item_type`,`date_created`,`entered_by`,`joborder_id`),
KEY `IDX_activity_site_type_occurred_job` (`site_id`,`data_item_type`,`date_occurred`,`entered_by`,`joborder_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

/*Data for the table `activity` */
Expand Down
29 changes: 15 additions & 14 deletions lib/ActivityEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@ public function __construct($siteID)
* @param string Activity notes.
* @param integer Entered-by user ID.
* @param integer Job Order ID; -1 for general (stored as NULL).
* @param string Date created timestamp (YYYY-MM-DD HH:MM:SS); false for NOW().
* @param string Date occurred timestamp (YYYY-MM-DD HH:MM:SS); false for NOW().
* @return integer New Activity ID; -1 on failure.
*/
public function add($dataItemID, $dataItemType, $activityType,
$activityNotes, $enteredBy, $jobOrderID = -1, $dateCreated = false)
$activityNotes, $enteredBy, $jobOrderID = -1, $dateOccurred = false)
{
if (!ctype_digit((string) $jobOrderID) || (int) $jobOrderID <= 0)
{
$jobOrderID = -1;
}

if (is_string($dateCreated) &&
preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $dateCreated))
if (is_string($dateOccurred) &&
preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $dateOccurred))
{
$dateCreatedSQL = $this->_db->makeQueryString($dateCreated);
$dateOccurredSQL = $this->_db->makeQueryString($dateOccurred);
}
else
{
$dateCreatedSQL = 'NOW()';
$dateOccurredSQL = 'NOW()';
}

$sql = sprintf(
Expand All @@ -112,6 +112,7 @@ public function add($dataItemID, $dataItemType, $activityType,
type,
notes,
site_id,
date_occurred,
date_created,
date_modified
)
Expand All @@ -124,6 +125,7 @@ public function add($dataItemID, $dataItemType, $activityType,
%s,
%s,
%s,
NOW(),
NOW()
)",
$this->_db->makeQueryInteger($dataItemID),
Expand All @@ -133,7 +135,7 @@ public function add($dataItemID, $dataItemType, $activityType,
$this->_db->makeQueryInteger($activityType),
$this->_db->makeQueryString($activityNotes),
$this->_siteID,
$dateCreatedSQL
$dateOccurredSQL
);

$queryResult = $this->_db->query($sql);
Expand Down Expand Up @@ -253,7 +255,7 @@ public function update($activityID, $activityType, $activityNotes,
"UPDATE
activity
SET
date_created = DATE_SUB(%s, INTERVAL %s HOUR),
date_occurred = DATE_SUB(%s, INTERVAL %s HOUR),
date_modified = NOW()
WHERE
activity_id = %s
Expand Down Expand Up @@ -428,7 +430,7 @@ public function get($activityID)
activity_type.short_description AS typeDescription,
activity.notes AS notes,
DATE_FORMAT(
activity.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
) AS dateCreated,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
Expand Down Expand Up @@ -476,12 +478,11 @@ public function getAllByDataItem($dataItemID, $dataItemType)
activity.joborder_id AS jobOrderID,
activity.notes AS notes,
DATE_FORMAT(
activity.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
) AS dateCreated,
activity.date_created AS dateCreatedSort,
activity.date_occurred AS dateCreatedSort,
activity.type AS type,
activity_type.short_description AS typeDescription,
activity.date_created AS dateCreatedSort,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
IF(
Expand Down Expand Up @@ -533,9 +534,9 @@ public function getAllByCompany($companyID)
activity.joborder_id AS jobOrderID,
activity.notes AS notes,
DATE_FORMAT(
activity.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
) AS dateCreated,
activity.date_created AS dateCreatedSort,
activity.date_occurred AS dateCreatedSort,
activity.type AS type,
activity_type.short_description AS typeDescription,
entered_by_user.first_name AS enteredByFirstName,
Expand Down
4 changes: 2 additions & 2 deletions lib/Pipelines.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public function getJobOrderPipeline($jobOrderID, $orderBy = '')
SELECT
CONCAT(
'<strong>',
DATE_FORMAT(activity.date_created, '%%m-%%d-%%y'),
DATE_FORMAT(activity.date_occurred, '%%m-%%d-%%y'),
' (',
entered_by_user.first_name,
' ',
Expand All @@ -660,7 +660,7 @@ public function getJobOrderPipeline($jobOrderID, $orderBy = '')
AND
activity.joborder_id = %s
ORDER BY
activity.date_created DESC
activity.date_occurred DESC
LIMIT 1
) AS lastActivity,
IF((
Expand Down
8 changes: 4 additions & 4 deletions lib/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,20 +444,20 @@ public function getPlacementsByJobOrder($period, $jobOrderID)
public function getActivitiesByPeriod($period)
{
$criterion = $this->makePeriodCriterion(
'activity.date_created', $period
'activity.date_occurred', $period
);

$sql = sprintf(
"SELECT
activity.activity_id AS activityID,
DATE_FORMAT(
activity.date_created, '%%m'
activity.date_occurred, '%%m'
) AS month,
DATE_FORMAT(
activity.date_created, '%%d'
activity.date_occurred, '%%d'
) AS day,
DATE_FORMAT(
activity.date_created, '%%y'
activity.date_occurred, '%%y'
) AS year
FROM
activity
Expand Down
16 changes: 8 additions & 8 deletions modules/activity/dataGrids.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ public function __construct($siteID, $parameters)

if (isset($parameters['period']) && !empty($parameters['period']))
{
$this->dateCriterion .= ' AND activity.date_created >= ' . $parameters['period'] . ' ';
$this->dateCriterion .= ' AND activity.date_occurred >= ' . $parameters['period'] . ' ';
}
else
{
if (isset($parameters['startDate']) && !empty($parameters['startDate']))
{
$this->dateCriterion .= ' AND activity.date_created >= \'' .$parameters['startDate'].'\' ';
$this->dateCriterion .= ' AND activity.date_occurred >= \'' .$parameters['startDate'].'\' ';
}

if (isset($parameters['endDate']) && !empty($parameters['endDate']))
{
$this->dateCriterion .= ' AND activity.date_created <= \''.$parameters['endDate'].'\' ';
$this->dateCriterion .= ' AND activity.date_occurred <= \''.$parameters['endDate'].'\' ';
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function __construct($siteID, $parameters)
'pagerWidth' => 110,
'pagerOptional' => true,
'alphaNavigation'=> true,
'filter' => 'activity.date_created'),
'filter' => 'activity.date_occurred'),

'First Name' => array('pagerRender' => 'if ($rsData[\'dataItemType\']=='.DATA_ITEM_CANDIDATE.') {$ret = \'<img src="images/mru/candidate.gif" height="12" alt="" />\';} else if ($rsData[\'dataItemType\']=='.DATA_ITEM_CONTACT.') {$ret = \'<img src="images/mru/contact.gif" height="12">\';} else {$ret = \'<img src="images/mru/blank.gif">\';} if ($rsData[\'isHot\'] == 1) $className = \'jobLinkHot\'; else $className = \'jobLinkCold\'; if ($rsData[\'dataItemType\']=='.DATA_ITEM_CANDIDATE.') {return $ret.\'&nbsp;<a href="'.CATSUtility::getIndexName().'?m=candidates&amp;a=show&amp;candidateID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.Template::escapeAttr(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'">\'.Template::escapeHtml($rsData[\'firstName\']).\'</a>\';} else {return $ret.\'&nbsp;<a href="'.CATSUtility::getIndexName().'?m=contacts&amp;a=show&amp;contactID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.Template::escapeAttr(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'">\'.Template::escapeHtml($rsData[\'firstName\']).\'</a>\';}',
'sortableColumn' => 'firstName',
Expand Down Expand Up @@ -177,9 +177,9 @@ public function getSQL($selectSQL, $joinSQL, $whereSQL, $havingSQL, $orderSQL, $
activity.notes AS notes,
activity_type.short_description AS typeDescription,
DATE_FORMAT(
activity.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
) AS dateCreated,
activity.date_created AS dateCreatedSort,
activity.date_occurred AS dateCreatedSort,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
CONCAT(entered_by_user.last_name, entered_by_user.first_name) AS enteredBySort,
Expand Down Expand Up @@ -226,9 +226,9 @@ public function getSQL($selectSQL, $joinSQL, $whereSQL, $havingSQL, $orderSQL, $
activity.notes AS notes,
activity_type.short_description AS typeDescription,
DATE_FORMAT(
activity.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
) AS dateCreated,
activity.date_created AS dateCreatedSort,
activity.date_occurred AS dateCreatedSort,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
CONCAT(entered_by_user.last_name, entered_by_user.first_name) AS enteredBySort,
Expand Down
6 changes: 3 additions & 3 deletions modules/candidates/CandidatesUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,7 @@ private function _addActivity($isJobOrdersMode, $regardingID,

$activityNote = $this->getTrimmedInput('activityNote', $_POST);

$activityDateCreated = false;
$activityDateOccurred = false;
$dateFormatFlag = $_SESSION['CATS']->isDateDMY()
? DATE_FORMAT_DDMMYY
: DATE_FORMAT_MMDDYY;
Expand All @@ -3176,7 +3176,7 @@ private function _addActivity($isJobOrdersMode, $regardingID,
$activityHour += 12;
}

$activityDateCreated = sprintf(
$activityDateOccurred = sprintf(
'%s %02d:%02d:00',
DateUtility::convert(
'-',
Expand All @@ -3198,7 +3198,7 @@ private function _addActivity($isJobOrdersMode, $regardingID,
$activityNote,
$this->_userID,
$regardingID,
$activityDateCreated
$activityDateOccurred
);
$activityTypeDescription = ResultSetUtility::getColumnValueByIDValue(
$activityTypes, 'typeID', $activityTypeID, 'type'
Expand Down
6 changes: 3 additions & 3 deletions modules/contacts/ContactsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ private function _addActivityScheduleEvent($regardingID, $directoryOverride = ''

$activityNote = $this->getTrimmedInput('activityNote', $_POST);

$activityDateCreated = false;
$activityDateOccurred = false;
$dateFormatFlag = $_SESSION['CATS']->isDateDMY()
? DATE_FORMAT_DDMMYY
: DATE_FORMAT_MMDDYY;
Expand All @@ -1388,7 +1388,7 @@ private function _addActivityScheduleEvent($regardingID, $directoryOverride = ''
$activityHour += 12;
}

$activityDateCreated = sprintf(
$activityDateOccurred = sprintf(
'%s %02d:%02d:00',
DateUtility::convert(
'-',
Expand All @@ -1410,7 +1410,7 @@ private function _addActivityScheduleEvent($regardingID, $directoryOverride = ''
$activityNote,
$this->_userID,
$regardingID,
$activityDateCreated
$activityDateOccurred
);
$activityTypeDescription = ResultSetUtility::getColumnValueByIDValue(
$activityTypes, 'typeID', $activityTypeID, 'type'
Expand Down
16 changes: 8 additions & 8 deletions modules/home/dataGrids.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,18 @@ public function __construct($siteID, $parameters)

if (isset($parameters['period']) && !empty($parameters['period']))
{
$this->dateCriterion .= ' AND activity.date_created >= ' . $parameters['period'] . ' ';
$this->dateCriterion .= ' AND activity.date_occurred >= ' . $parameters['period'] . ' ';
}
else
{
if (isset($parameters['startDate']) && !empty($parameters['startDate']))
{
$this->dateCriterion .= ' AND activity.date_created >= \'' .$parameters['startDate'].'\' ';
$this->dateCriterion .= ' AND activity.date_occurred >= \'' .$parameters['startDate'].'\' ';
}

if (isset($parameters['endDate']) && !empty($parameters['endDate']))
{
$this->dateCriterion .= ' AND activity.date_created <= \''.$parameters['endDate'].'\' ';
$this->dateCriterion .= ' AND activity.date_occurred <= \''.$parameters['endDate'].'\' ';
}
}

Expand Down Expand Up @@ -300,9 +300,9 @@ public function getSQL($selectSQL, $joinSQL, $whereSQL, $havingSQL, $orderSQL, $
activity.notes AS notes,
activity_type.short_description AS typeDescription,
DATE_FORMAT(
activity.date_created, '%%m-%%d-%%y %%h:%%i %%p'
activity.date_occurred, '%%m-%%d-%%y %%h:%%i %%p'
) AS dateCreated,
activity.date_created AS dateCreatedSort,
activity.date_occurred AS dateCreatedSort,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
CONCAT(entered_by_user.last_name, entered_by_user.first_name) AS enteredBySort,
Expand Down Expand Up @@ -354,9 +354,9 @@ public function getSQL($selectSQL, $joinSQL, $whereSQL, $havingSQL, $orderSQL, $
activity.notes AS notes,
activity_type.short_description AS typeDescription,
DATE_FORMAT(
activity.date_created, '%%m-%%d-%%y %%h:%%i %%p'
activity.date_occurred, '%%m-%%d-%%y %%h:%%i %%p'
) AS dateCreated,
activity.date_created AS dateCreatedSort,
activity.date_occurred AS dateCreatedSort,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
CONCAT(entered_by_user.last_name, entered_by_user.first_name) AS enteredBySort,
Expand Down Expand Up @@ -410,4 +410,4 @@ public function getSQL($selectSQL, $joinSQL, $whereSQL, $havingSQL, $orderSQL, $
}
}

?>
?>
10 changes: 10 additions & 0 deletions modules/install/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,16 @@ public static function get()
`ce`.`joborder_id` IS NOT NULL AND
`jo`.`joborder_id` IS NULL;
',
'380' => '
ALTER TABLE `activity`
ADD COLUMN `date_occurred` datetime NOT NULL DEFAULT \'1000-01-01 00:00:00\'
BEFORE `date_created`;
UPDATE `activity`
SET `date_occurred` = `date_created`;
CREATE INDEX `IDX_date_occurred` ON `activity` (`date_occurred`);
CREATE INDEX `IDX_site_occurred` ON `activity` (`site_id`,`date_occurred`);
CREATE INDEX `IDX_activity_site_type_occurred_job` ON `activity` (`site_id`,`data_item_type`,`date_occurred`,`entered_by`,`joborder_id`);
',

);
}
Expand Down
13 changes: 13 additions & 0 deletions test/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ public function iWaitFor($element)
}
});
}

/**
* @Then I wait until I see :text
*/
public function iWaitUntilISee($text)
{
$this->spins(function() use ($text) {
$pageText = $this->getSession()->getPage()->getText();
if (strpos($pageText, $text) === false) {
throw new Exception(sprintf('Could not see text "%s" yet.', $text));
}
});
}

/**
* @Then /^I wait for the activity note box to appear$/
Expand Down
2 changes: 1 addition & 1 deletion test/features/job-orders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,5 @@ Feature: Job Orders
And press "Add Candidate"
And press "Close"
And I switch to the iframe ""
Then I should see "John"
Then I wait until I see "John"
And I should see "Doe"
Loading