Example #1
0
 /**
  * Check if given employees job title matches the given title name.
  *
  * @param int $empNum Employee number
  * @param String $jobTitleName The job title name to check
  * @return boolean True if employee has given job title, false otherwise
  */
 public function checkEmpJobTitle($empNumber, $jobTitleName)
 {
     $titleMatches = false;
     $tables[0] = '`hs_hr_employee` a';
     $tables[1] = '`hs_hr_job_title` b';
     $joinConditions[1] = 'a.`job_title_code` = b.`jobtit_code`';
     $selectConditions[] = "a.`emp_number` = " . $empNumber;
     $selectConditions[] = "b.`jobtit_name` = '" . $jobTitleName . "'";
     $sqlBuilder = new SQLQBuilder();
     $sql = $sqlBuilder->countFromMultipleTables($tables, $joinConditions, $selectConditions);
     $conn = new DMLFunctions();
     $result = $conn->executeQuery($sql);
     if ($result) {
         $row = mysql_fetch_array($result, MYSQL_NUM);
         $count = $row[0];
         if ($count == 1) {
             $titleMatches = true;
         }
     }
     return $titleMatches;
 }
Example #2
0
 /**
  * Count job vacancys with given search conditions
  * @param string $searchStr Search string
  * @param string $searchFieldNo Integer giving which field to search on
  */
 public static function getCount($searchStr = '', $searchFieldNo = self::SORT_FIELD_NONE)
 {
     $count = 0;
     $fields[0] = "a." . self::DB_FIELD_VACANCY_ID;
     $fields[1] = "c.jobtit_name";
     $fields[2] = "CONCAT(b.`emp_firstname`, ' ', b.`emp_lastname`)";
     $fields[3] = "a." . self::DB_FIELD_ACTIVE;
     $fields[4] = "a." . self::DB_FIELD_DESCRIPTION;
     $tables[0] = self::TABLE_NAME . ' a';
     $tables[1] = 'hs_hr_employee b';
     $tables[2] = 'hs_hr_job_title c';
     $joinConditions[1] = 'a.' . self::DB_FIELD_MANAGER_ID . ' = b.emp_number';
     $joinConditions[2] = 'a.jobtit_code = c.jobtit_code';
     $selectConditions = null;
     if ($searchFieldNo >= 0 && $searchFieldNo < count($fields) && trim($searchStr) != '') {
         if ($searchFieldNo == self::SORT_FIELD_ACTIVE) {
             $active = $searchStr ? self::STATUS_ACTIVE : self::STATUS_INACTIVE;
             $selectConditions[] = "{$fields[$searchFieldNo]} = " . $active;
         } else {
             $filteredSearch = mysql_real_escape_string($searchStr);
             $selectConditions[] = "{$fields[$searchFieldNo]} LIKE '" . $filteredSearch . "%'";
         }
     }
     $sqlBuilder = new SQLQBuilder();
     $sql = $sqlBuilder->countFromMultipleTables($tables, $joinConditions, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($sql);
     if ($result) {
         $line = mysql_fetch_array($result, MYSQL_NUM);
         $count = $line[0];
     }
     return $count;
 }