Exemplo n.º 1
0
 public function setStatus($candidateID, $jobOrderID, $statusID, $emailAddress, $emailText)
 {
     /* Get existing status. */
     $sql = sprintf("SELECT\n                status AS oldStatusID,\n                candidate_joborder_id AS candidateJobOrderID\n            FROM\n                candidate_joborder\n            WHERE\n                joborder_id = %s\n            AND\n                candidate_id = %s\n            AND\n                site_id = %s", $this->_db->makeQueryInteger($jobOrderID), $this->_db->makeQueryInteger($candidateID), $this->_siteID);
     $rs = $this->_db->getAssoc($sql);
     if (empty($rs)) {
         return;
     }
     $candidateJobOrderID = $rs['candidateJobOrderID'];
     $oldStatusID = $rs['oldStatusID'];
     if ($oldStatusID == $statusID) {
         /* No need to update the database and scew the history if there is
          * no actual change.
          */
         return;
     }
     /* Change status. */
     $sql = sprintf("UPDATE\n                candidate_joborder\n            SET\n                status        = %s,\n                date_modified = NOW()\n            WHERE\n                candidate_joborder_id = %s\n            AND\n                site_id = %s", $this->_db->makeQueryInteger($statusID), $this->_db->makeQueryInteger($candidateJobOrderID), $this->_siteID);
     $this->_db->query($sql);
     /* Add history. */
     $historyID = $this->addStatusHistory($candidateID, $jobOrderID, $statusID, $oldStatusID);
     /* Add auditing history. */
     $historyDescription = '(USER) changed pipeline status of candidate ' . $candidateID . ' for job order ' . $jobOrderID . '.';
     $history = new History($this->_siteID);
     $history->storeHistoryData(DATA_ITEM_PIPELINE, $candidateJobOrderID, 'PIPELINE', $oldStatusID, $statusID, $historyDescription);
     if (!empty($emailAddress)) {
         /* Send e-mail notification. */
         //FIXME: Make subject configurable.
         $mailer = new Mailer($this->_siteID);
         $mailerStatus = $mailer->sendToOne(array("id" => $candidateID, "email" => array($emailAddress)), CANDIDATE_STATUSCHANGE_SUBJECT, $emailText, true);
     }
 }
Exemplo n.º 2
0
 /**
  * Removes an activity note from the system.
  *
  * @param integer Activity ID.
  * @return boolean True if successful; false otherwise.
  */
 public function delete($activityID)
 {
     $sql = sprintf("SELECT\n                activity.data_item_id AS dataItemID,\n                activity.data_item_type AS dataItemType,\n                activity.joborder_id AS jobOrderID,\n                activity.notes AS notes,\n                activity.entered_by AS enteredBy,\n                CONCAT(\n                    user.first_name, ' ', user.last_name\n                ) AS enteredByFullName\n            FROM\n                activity\n            LEFT JOIN user AS user\n                ON activity.entered_by = user.user_id\n            WHERE\n                activity.activity_id = %s\n            AND\n                activity.site_id = %s", $this->_db->makeQueryInteger($activityID), $this->_siteID);
     $activityIDRS = $this->_db->getAssoc($sql);
     if (!$activityIDRS) {
         return false;
     }
     $sql = sprintf("DELETE FROM\n                activity\n            WHERE\n                activity_id = %s\n            AND\n                site_id = %s", $this->_db->makeQueryInteger($activityID), $this->_siteID);
     $queryResult = $this->_db->query($sql);
     if (!$queryResult) {
         return false;
     }
     $history = new History($this->_siteID);
     $history->storeHistoryData($activityIDRS['dataItemType'], $activityIDRS['dataItemID'], 'ACTIVITY', $activityIDRS['notes'], '(DELETE)', '(USER) Deleted ' . $activityIDRS['enteredByFullName'] . '\'s activity.');
     /* Update the last-modified timestamp for the "parent" Data Item. */
     $this->_updateDataItemModified($activityIDRS['dataItemID'], $activityIDRS['dataItemType']);
     /* If there is a job order associated, update it's modified timestamp,
      * too.
      */
     if (!empty($activityIDRS['jobOrderID']) && ctype_digit((string) $activityIDRS['jobOrderID'])) {
         $this->_updateDataItemModified($activityIDRS['jobOrderID'], DATA_ITEM_JOBORDER);
     }
     return true;
 }