/**
  * Outputs the 'value' corresponding to 'key'
  * @param string $key 'key' field where corresponding 'value' is needed
  */
 private static function _selectValue($key)
 {
     $selectTable = "`" . self::DB_TABLE_CONFIG . "`";
     $selectFields[0] = "`" . self::DB_FIELD_VALUE . "`";
     $selectConditions[0] = "`" . self::DB_FIELD_KEY . "` = '" . $key . "'";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     if ($dbConnection->dbObject->numberOfRows($result) != 1) {
         throw new Exception("Value corresponding to {$key} could not be selected");
     }
     $resultArray = $dbConnection->dbObject->getArray($result);
     return $resultArray[0];
 }
Example #2
0
 /**
  * Changes the leave status to taken if the date is before
  * or on today
  *
  * @access public
  */
 public function takeLeave()
 {
     $sqlBuilder = new SQLQBuilder();
     $selectFields[0] = '`leave_date`';
     $selectFields[1] = '`leave_status`';
     $selectFields[2] = '`leave_length_hours`';
     $selectFields[3] = '`leave_length_days`';
     $selectFields[4] = '`leave_comments`';
     $selectFields[5] = '`leave_id`';
     $selectFields[6] = '`employee_id`';
     $selectFields[7] = '`leave_type_id`';
     $selectTable = '`hs_hr_leave`';
     $selectConditions[] = "`leave_status` = " . $this->statusLeaveApproved;
     $selectConditions[] = "`leave_date` <= NOW()";
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     if (isset($result) && !empty($result)) {
         if (mysql_num_rows($result) > 0) {
             $leaveObjs = $this->_buildObjArr($result);
             foreach ($leaveObjs as $leaveObj) {
                 $leaveObj->setLeaveStatus(self::LEAVE_STATUS_LEAVE_TAKEN);
                 $leaveObj->changeLeaveToTaken();
                 $leaveObj->storeLeaveTaken();
             }
             return true;
         }
     }
     return false;
 }
 public function filterExistingMembershipInfo()
 {
     $tableName = 'hs_hr_membership';
     $selectFields[] = '`membship_code`';
     $selectFields[] = '`membtype_code`';
     $selectFields[] = '`membship_name`';
     $selectTable = $tableName;
     $selectConditions[] = "`membtype_code` = '" . $this->getMembershipTypeId() . "'";
     $selectConditions[] = "`membship_name` = '" . $this->getMembershipInfoDesc() . "'";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $cnt = 0;
     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
         $existingMembershipInfo[$cnt++] = $row;
     }
     if (isset($existingMembershipInfo)) {
         return $existingMembershipInfo;
     } else {
         $existingMembershipInfo = '';
         return $existingMembershipInfo;
     }
 }
Example #4
0
 /**
  * Returns an array containing employee first name, last name and employee id.
  */
 public static function getEmployeeMainDetails()
 {
     $selectTable = "`" . self::EMPLOYEE_TABLE_NAME . "`";
     $selectFields[0] = "`" . self::EMPLOYEE_FIELD_EMP_NUMBER . "`";
     $selectFields[1] = "`" . self::EMPLOYEE_FIELD_FIRST_NAME . "`";
     $selectFields[2] = "`" . self::EMPLOYEE_FIELD_LAST_NAME . "`";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $rowCount = $dbConnection->dbObject->numberOfRows($result);
     if ($rowCount > 0) {
         $i = 0;
         for ($i; $i < $rowCount; $i++) {
             $row = $dbConnection->dbObject->getArray($result);
             $employee[$i][0] = $row[0];
             $employee[$i][1] = $row[1];
             $employee[$i][2] = $row[2];
         }
         return $employee;
     } else {
         return null;
     }
 }
Example #5
0
 /**
  * Used to check whether the employee's status is terminated
  */
 private static function _isEmployeeTerminated($employeeId)
 {
     $selectTable = "`hs_hr_employee` a";
     $selectFields[0] = "a.`emp_status`";
     $selectConditions[0] = "a.`employee_id`= {$employeeId}";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $employeeStatus = mysql_fetch_array($result, MYSQL_NUM);
     return $employeeStatus[0] === EmploymentStatus::EMPLOYMENT_STATUS_ID_TERMINATED;
 }
 /**
  * Get a list of custom export objects with the given conditions.
  *
  * @param array   $selectCondition Array of select conditions to use.
  * @return array  Array of CustomExport objects. Returns an empty (length zero) array if none found.
  */
 private static function _getList($selectCondition = null)
 {
     $fields[0] = self::DB_FIELDS_ID;
     $fields[1] = self::DB_FIELDS_NAME;
     $fields[2] = self::DB_FIELDS_FIELDS;
     $fields[3] = self::DB_FIELDS_HEADINGS;
     $sqlBuilder = new SQLQBuilder();
     $sql = $sqlBuilder->simpleSelect(self::TABLE_NAME, $fields, $selectCondition, $fields[1], "ASC");
     $actList = array();
     $conn = new DMLFunctions();
     $result = $conn->executeQuery($sql);
     while ($result && ($row = mysql_fetch_assoc($result))) {
         $actList[] = self::_createFromRow($row);
     }
     return $actList;
 }
Example #7
0
 public function getJobStatusFromTitle($getID)
 {
     $this->getID = $getID;
     $dbConnection = new DMLFunctions();
     if ($this->getID == '0') {
         // if clicked on select
         $selectTable = "`hs_hr_empstat` a";
         $arrFieldList[0] = "a.`estat_code`";
         $arrFieldList[1] = "a.`estat_code`";
         $arrFieldList[2] = "a.`estat_name`";
         $selectConditions = null;
     } else {
         $selectTable = "`hs_hr_jobtit_empstat` a,`hs_hr_empstat` b";
         $arrFieldList[0] = "a.`jobtit_code`";
         $arrFieldList[1] = "a.`estat_code`";
         $arrFieldList[2] = "b.`estat_name`";
         // ID should not have quotes, so it's safe to escape without looking at magic quotes setting
         $selectConditions[] = "a.`jobtit_code`='" . mysql_real_escape_string($this->getID) . "'";
         $selectConditions[] = "a.`estat_code`=b.`estat_code`";
     }
     $sql_builder = new SQLQBuilder();
     $sqlQString = $sql_builder->simpleSelect($selectTable, $arrFieldList, $selectConditions, $arrFieldList[2], 'ASC');
     $result = $dbConnection->executeQuery($sqlQString);
     $i = 0;
     $fieldNum = count($arrFieldList);
     while ($line = $dbConnection->dbObject->getArray($result)) {
         for ($c = 0; $fieldNum > $c; $c++) {
             $arrayDispList[$i][$c] = $line[$c];
         }
         $i++;
     }
     if (isset($arrayDispList)) {
         return $arrayDispList;
     } else {
         $arrayDispList = '';
         return $arrayDispList;
     }
     return $arrayDispList;
 }
Example #8
0
 function getSalGrades($fetchDetailedSalGradesOnly = false)
 {
     $sql_builder = new SQLQBuilder();
     $tableName = "`hs_pr_salary_grade`";
     $arrFieldList[0] = "`sal_grd_code`";
     $arrFieldList[1] = "`sal_grd_name`";
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_select = 'true';
     $sql_builder->arr_select = $arrFieldList;
     if ($fetchDetailedSalGradesOnly) {
         $subQueryTable = "`hs_pr_salary_currency_detail`";
         $subQueryFields[0] = "DISTINCT(`sal_grd_code`)";
         $subQuery = $sql_builder->simpleSelect($subQueryTable, $subQueryFields);
         $selectConditions[0] = "{$arrFieldList[0]} IN ({$subQuery})";
         $sqlQString = $sql_builder->simpleSelect($tableName, $arrFieldList, $selectConditions);
     } else {
         $sqlQString = $sql_builder->passResultSetMessage();
     }
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     $i = 0;
     while ($line = mysql_fetch_array($message2, MYSQL_NUM)) {
         $arrayDispList[$i][0] = $line[0];
         $arrayDispList[$i][1] = $line[1];
         $i++;
     }
     if (isset($arrayDispList)) {
         return $arrayDispList;
     } else {
         //Handle Exceptions
         //Create Logs
     }
 }
 public function fetchTimesheetSubmissionPeriods()
 {
     $sql_builder = new SQLQBuilder();
     $selectTable = self::TIMESHEET_SUBMISSION_PERIOD_DB_TABLE_TIMESHEET_SUBMISSION_PERIOD . " a ";
     $selectFields[0] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_TIMESHEET_PERIOD_ID . "`";
     $selectFields[1] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_NAME . "`";
     $selectFields[2] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_FREQUENCY . "`";
     $selectFields[3] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_PERIOD . "`";
     $selectFields[4] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_START_DAY . "`";
     $selectFields[5] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_END_DAY . "`";
     $selectFields[6] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_DESCRIPTION . "`";
     $selectConditions = null;
     if ($this->getTimesheetPeriodId() != null) {
         $selectConditions[] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_TIMESHEET_PERIOD_ID . "` = {$this->getTimesheetPeriodId()}";
     }
     if ($this->getName() != null) {
         $selectConditions[] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_NAME . "` = {$this->getName()}";
     }
     if ($this->getFrequency() != null) {
         $selectConditions[] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_FREQUENCY . "` = {$this->getFrequency()}";
     }
     if ($this->getPeriod() != null) {
         $selectConditions[] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_PERIOD . "` = {$this->getPeriod()}";
     }
     if ($this->getStartDay() != null) {
         $selectConditions[] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_START_DAY . "` = {$this->getStartDay()}";
     }
     if ($this->getEndDay() != null) {
         $selectConditions[] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_END_DAY . "` = {$this->getEndDay()}";
     }
     if ($this->getDescription() != null) {
         $selectConditions[] = "a.`" . self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_DESCRIPTION . "` = {$this->getDescription()}";
     }
     $query = $sql_builder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectFields[0], 'ASC');
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $objArr = $this->_buildObjArr($result);
     return $objArr;
 }
Example #10
0
 public function filterExistingCustomers()
 {
     $sqlBuilder = new SQLQBuilder();
     $customerName = $sqlBuilder->quoteCorrectString($this->getCustomerName(), true, true);
     $selectFields[] = '`customer_id`';
     $selectFields[] = '`name`';
     $selectTable = self::TABLE_NAME;
     $selectConditions[] = "`name` = '{$customerName}'";
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $cnt = 0;
     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
         $existingCustomers[$cnt++] = $row;
     }
     if (isset($existingCustomers)) {
         return $existingCustomers;
     } else {
         $existingCustomers = '';
         return $existingCustomers;
     }
 }
Example #11
0
 public function isSalaryGradeNameExists($salGradeName)
 {
     $selectTable = '`ohrm_pay_grade`';
     $selectFields[] = '`sal_grd_code`';
     $selectConditions[] = "`sal_grd_name` = '{$salGradeName}'";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     if ($dbConnection->dbObject->numberOfRows($result) > 0) {
         return true;
     } else {
         return false;
     }
 }
 public function fetchHoliday($holidayId)
 {
     $selectTable = "`" . self::HOLIDAYS_TABLE . "`";
     $arrFieldList[0] = "`" . self::HOLIDAYS_TABLE_HOLIDAY_ID . "`";
     $arrFieldList[1] = "`" . self::HOLIDAYS_TABLE_DESCRIPTION . "`";
     $arrFieldList[2] = "`" . self::HOLIDAYS_TABLE_DATE . "`";
     $arrFieldList[3] = "`" . self::HOLIDAYS_TABLE_LENGTH . "`";
     $arrFieldList[4] = "`" . self::HOLIDAYS_TABLE_RECURRING . "`";
     $arrSelectConditions[0] = "`" . self::HOLIDAYS_TABLE_HOLIDAY_ID . "` = {$holidayId}";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $arrFieldList, $arrSelectConditions, null, null, 1);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     return self::_buildObjArr($result);
 }
 public function filterExistingEducations()
 {
     $selectFields[] = '`edu_code`';
     $selectFields[] = '`edu_uni`';
     $selectFields[] = '`edu_deg`';
     $selectTable = $this->tableName;
     $selectConditions[] = "`edu_deg` = '" . $this->getEduDeg() . "'";
     $selectConditions[] = "`edu_uni` = '" . $this->getEduUni() . "'";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $cnt = 0;
     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
         $existingEducations[$cnt++] = $row;
     }
     if (isset($existingEducations)) {
         return $existingEducations;
     } else {
         $existingEducations = '';
         return $existingEducations;
     }
 }
Example #14
0
 public function fetchUserEmail($userId)
 {
     $sqlQBuilder = new SQLQBuilder();
     $arrFields[0] = '`email1`';
     $arrTable = "`hs_hr_users`";
     $selectConditions[1] = "`id` = '{$userId}'";
     $query = $sqlQBuilder->simpleSelect($arrTable, $arrFields, $selectConditions, $arrFields[0], 'ASC');
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $row = mysql_fetch_row($result);
     return $row[0];
 }
Example #15
0
 /**
  * Check whether leave balance is zero 
  * @param $employeeId String Employee Id
  * @param $leaveTypeId String Leave Type Id
  * @return bool true if balnace is zero, false other wise  
  */
 public function isBalanceZero()
 {
     $selectTable = "`" . self::LEAVEQUOTA_DB_TABLE_EMPLOYEE_LEAVE_QUOTA . "`";
     $selectFields[0] = "`" . self::LEAVEQUOTA_DB_FIELD_NO_OF_DAYS_ALLOTED . "`";
     $selectFields[1] = "`" . self::LEAVEQUOTA_DB_FIELD_LEAVE_TAKEN . "`";
     $selectFields[2] = "`" . self::LEAVEQUOTA_DB_FIELD_LEAVE_BROUGHT_FORWARD . "`";
     $selectConditions[0] = "`" . self::LEAVEQUOTA_DB_FIELD_YEAR . "` = '" . $this->getYear() . "'";
     $selectConditions[1] = "`" . self::LEAVEQUOTA_DB_FIELD_LEAVE_TYPE_ID . "` = '" . $this->getLeaveTypeId() . "'";
     $selectConditions[2] = "`" . self::LEAVEQUOTA_DB_FIELD_EMPLOYEE_ID . "` = '" . $this->getEmployeeId() . "'";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions, NULL, NULL, 1);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $row = $dbConnection->dbObject->getArray($result);
     if ($row[self::LEAVEQUOTA_DB_FIELD_NO_OF_DAYS_ALLOTED] + $row[self::LEAVEQUOTA_DB_FIELD_LEAVE_BROUGHT_FORWARD] == $row[self::LEAVEQUOTA_DB_FIELD_LEAVE_TAKEN]) {
         return true;
     } else {
         return false;
     }
 }
 public function filterExistingProjects()
 {
     $selectFields[] = "`" . self::PROJECT_DB_FIELD_PROJECT_ID . "`";
     $selectFields[] = "`" . self::PROJECT_DB_FIELD_CUSTOMER_ID . "`";
     $selectFields[] = "`" . self::PROJECT_DB_FIELD_NAME . "`";
     $selectTable = self::TABLE_NAME;
     $selectConditions[] = "`" . self::PROJECT_DB_FIELD_CUSTOMER_ID . "`= '" . $this->getCustomerId() . "'";
     $selectConditions[] = "`" . self::PROJECT_DB_FIELD_NAME . "`= '" . $this->getProjectName() . "'";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $cnt = 0;
     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
         $existingProjects[$cnt++] = $row;
     }
     if (isset($existingProjects)) {
         return $existingProjects;
     } else {
         $existingProjects = '';
         return $existingProjects;
     }
 }
Example #17
0
 /**
  * Check for given date in approved timesheet for given employee
  * @param string $date
  * @param string $empId
  * @return bool Returns true if record found, false other wise
  */
 public static function checkDateInApprovedTimesheet($date, $empId)
 {
     $sqlBuilder = new SQLQBuilder();
     $selectTable = "`" . self::TIMESHEET_DB_TABLE_TIMESHEET . "` a ";
     $selectFields[0] = "a.`" . self::TIMESHEET_DB_FIELD_TIMESHEET_ID . "`";
     $selectConditions[0] = "a.`" . self::TIMESHEET_DB_FIELD_START_DATE . "` <= '{$date}'";
     $selectConditions[1] = "a.`" . self::TIMESHEET_DB_FIELD_END_DATE . "` >= '{$date}'";
     $selectConditions[2] = "a.`" . self::TIMESHEET_DB_FIELD_STATUS . "` = '" . self::TIMESHEET_STATUS_APPROVED . "'";
     $selectConditions[3] = "a.`" . self::TIMESHEET_DB_FIELD_EMPLOYEE_ID . "` = {$empId}";
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions, NULL, NULL, 1);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     if (mysql_num_rows($result) > 0) {
         return true;
     } else {
         return false;
     }
 }
Example #18
0
 /**
  * Get a list of History items with the given conditions.
  *
  * @param array   $selectCondition Array of select conditions to use.
  * @return array  Array of History objects. Returns an empty (length zero) array if none found.
  */
 private function _getList($selectCondition = null)
 {
     $fields[0] = self::DB_FIELD_ID;
     $fields[1] = self::DB_FIELD_EMP_NUMBER;
     $fields[2] = self::DB_FIELD_CODE;
     $fields[3] = self::DB_FIELD_NAME;
     $fields[4] = self::DB_FIELD_START_DATE;
     $fields[5] = self::DB_FIELD_END_DATE;
     $sqlBuilder = new SQLQBuilder();
     $sql = $sqlBuilder->simpleSelect($this->tableName, $fields, $selectCondition);
     $histList = array();
     $conn = new DMLFunctions();
     $result = $conn->executeQuery($sql);
     while ($result && ($row = mysql_fetch_assoc($result))) {
         $histList[] = self::_createFromRow($row);
     }
     return $histList;
 }
Example #19
0
 public static function isUnfinishedTimesheet($timesheetId)
 {
     $selectTable = "`" . self::TIME_EVENT_DB_TABLE_TIME_EVENT . "`";
     $selectFields[0] = "`" . self::TIME_EVENT_DB_FIELD_TIME_EVENT_ID . "`";
     $selectConditions[0] = "`" . self::TIME_EVENT_DB_FIELD_DURATION . "` IS NULL";
     $selectConditions[1] = "`" . self::TIME_EVENT_DB_FIELD_TIMESHEET_ID . "` = {$timesheetId}";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     if ($dbConnection->dbObject->numberOfRows($result) > 0) {
         return true;
     } else {
         return false;
     }
 }
Example #20
0
 public function filterExistingMembershipTypes()
 {
     $selectFields[] = '`membtype_code`';
     $selectFields[] = '`membtype_name`';
     $selectTable = $this->tableName;
     $sqlBuilder = new SQLQBuilder();
     $description = $sqlBuilder->quoteCorrectString($this->getMemDescription());
     $selectConditions[] = "`membtype_name` = {$description}";
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $cnt = 0;
     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
         $existingMembershipTypes[$cnt++] = $row;
     }
     if (isset($existingMembershipTypes)) {
         return $existingMembershipTypes;
     } else {
         $existingMembershipTypes = '';
         return $existingMembershipTypes;
     }
 }
 public function fetchLeaveTypes($all = false)
 {
     $sql_builder = new SQLQBuilder();
     $selectTable = "`hs_hr_leavetype` ";
     $selectFields[0] = '`leave_type_id`';
     $selectFields[1] = '`leave_type_name`';
     if (!$all) {
         $selectConditions[0] = "`available_flag` = '" . $this->availableStatusFlag . "'";
     } else {
         $selectConditions = null;
         $selectFields[2] = '`available_flag`';
     }
     $selectOrder = "ASC";
     $selectOrderBy = $selectFields[1];
     $query = $sql_builder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectOrderBy, $selectOrder, null);
     //echo $query."\n";
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $leaveTypeArr = $this->_buildObjArr($result);
     return $leaveTypeArr;
 }
 public function filterExistingEeoJobs()
 {
     $selectFields[0] = '`eec_code`';
     $selectFields[1] = '`eec_desc`';
     $selectTable = $this->tableName;
     $selectConditions[] = "`eec_desc` = '" . $this->getEEOJobCatDesc() . "'";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $cnt = 0;
     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
         $existingEeo[$cnt++] = $row;
     }
     if (isset($existingEeo)) {
         return $existingEeo;
     } else {
         $existingEeo = '';
         return $existingEeo;
     }
 }
Example #23
0
 /**
  * Retrieves Project Id of a given Activity Id.
  * @param integer $activityId
  * @return integer Returns Project Id on success, Null on failiure
  */
 public function retrieveActivityProjectId($activityId)
 {
     $selectTable = "`" . self::TABLE_NAME . "`";
     $selectFields[0] = "`" . self::DB_FIELD_PROJECT_ID . "`";
     $selectConditions[0] = "`" . self::DB_FIELD_ACTIVITY_ID . "` = {$activityId}";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $row = $dbConnection->dbObject->getArray($result);
     if (isset($row[0])) {
         return $row[0];
     } else {
         return null;
     }
 }
 /**
  * Searches for subdivisions that match the given conditions
  *
  * @param selectConditions the select conditions to search for
  * @return Array of subdivisions that match the select conditions,
  *         or null if no matches found.
  */
 private function _getMatchingSubdivisions($selectConditions)
 {
     $tableName = '`hs_hr_compstructtree`';
     $arrFieldList[0] = '`title`';
     $arrFieldList[1] = '`description`';
     $arrFieldList[2] = '`loc_code`';
     $arrFieldList[3] = '`lft`';
     $arrFieldList[4] = '`rgt`';
     $arrFieldList[5] = '`id`';
     $arrFieldList[6] = '`parnt`';
     $sql_builder = new SQLQBuilder();
     $sqlQString = $sql_builder->simpleSelect($tableName, $arrFieldList, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($sqlQString);
     $subdivisionArray = null;
     if ($result) {
         $rowNum = 0;
         while ($row = mysql_fetch_assoc($result)) {
             $subdivisionArray[$rowNum] = $row;
             $rowNum++;
         }
     }
     return $subdivisionArray;
 }
Example #25
0
 function getEmpSalGrade($empID)
 {
     $tableName = 'hs_hr_emp_basicsalary';
     $arrFieldList[0] = 'SAL_GRD_CODE';
     $selectCondition[0] = "`EMP_NUMBER` = '" . $empID . "'";
     $sql_builder = new SQLQBuilder();
     $sqlQString = $sql_builder->simpleSelect($tableName, $arrFieldList, $selectCondition, $arrFieldList[0], 'ASC');
     //echo $sqlQString;
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     if (isset($message2)) {
         while ($row = mysql_fetch_assoc($message2)) {
             if (isset($row['SAL_GRD_CODE'])) {
                 return $row['SAL_GRD_CODE'];
             }
         }
     }
 }
Example #26
0
 /**
  * This function returns an array, each element containing another
  * array. First element of sub array is a 'HSP Plan Year' and second element
  * is again another array containing 'HSP Plan IDs' of that year.
  *
  * Return years include only this year and future years
  *
  * Ex:
  *
  * $both[0]['year'] = 2008;
  * $both[0]['plan'][0] = 1;
  * $both[0]['plan'][1] = 3;
  * $both[1]['year'] = 2009;
  * $both[1]['plan'][0] = 1;
  * $both[1]['plan'][1] = 3;
  *
  */
 public static function getYearsAndPlans()
 {
     $selectTable = "`" . parent::DB_TABLE_HSP_SUMMARY . "`";
     $selectFields[0] = "DISTINCT(`" . parent::DB_FIELD_HSP_PLAN_YEAR . "`)";
     $selectConditions[0] = "`" . parent::DB_FIELD_HSP_PLAN_YEAR . "` >= " . date('Y');
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     while ($row = $dbConnection->dbObject->getArray($result)) {
         $years[] = $row[0];
     }
     $count = count($years);
     for ($i = 0; $i < $count; $i++) {
         $both[$i]['year'] = $years[$i];
         $selectTable = "`" . parent::DB_TABLE_HSP_SUMMARY . "`";
         $selectFields[0] = "DISTINCT(`" . parent::DB_FIELD_HSP_PLAN_ID . "`)";
         $selectConditions[0] = "`" . parent::DB_FIELD_HSP_PLAN_YEAR . "` = " . $years[$i];
         $sqlBuilder = new SQLQBuilder();
         $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
         $dbConnection = new DMLFunctions();
         $result = $dbConnection->executeQuery($query);
         while ($row = $dbConnection->dbObject->getArray($result)) {
             $both[$i]['plan'][] = $row[0];
         }
     }
     return $both;
 }
Example #27
0
 /**
  * Check whether the given date is a weekend.
  * @param date $date
  * @return bool true on success and false on failiure
  */
 public static function isWeekend($date)
 {
     $dayNumber = date('N', strtotime($date));
     $selectTable = "`" . self::WEEKENDS_TABLE . "`";
     $selectFields[0] = "`" . self::WEEKENDS_TABLE_LENGTH . "`";
     $selectConditions[0] = "`" . self::WEEKENDS_TABLE_DAY . "` = {$dayNumber}";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $row = $dbConnection->dbObject->getArray($result);
     if ($row[0] == self::WEEKENDS_LENGTH_WEEKEND) {
         return true;
     } else {
         return false;
     }
 }
Example #28
0
 /**
  * Get work shift with given id
  * @param int $workshiftId Work shift id
  * @return Workshift workshift object or null if not found
  */
 public static function getWorkshift($workShiftId)
 {
     if (!CommonFunctions::isValidId($workShiftId)) {
         throw new WorkshiftException("Invalid id", WorkshiftException::INVALID_ID);
     }
     $sqlBuilder = new SQLQBuilder();
     $selectTable = self::WORKSHIFT_TABLE;
     $selectFields[0] = self::DB_FIELD_WORKSHIFT_ID;
     $selectFields[1] = self::DB_FIELD_NAME;
     $selectFields[2] = self::DB_FIELD_HOURS;
     $selectConditions[0] = self::DB_FIELD_WORKSHIFT_ID . " = " . $workShiftId;
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $numResults = mysql_num_rows($result);
     if ($numResults == 1) {
         $objs = self::_getWorkshiftsFromResults($result);
         return $objs[0];
     } else {
         if ($numResults == 0) {
             throw new WorkshiftException("Invalid number of results returned.", WorkshiftException::WORKSHIFT_NOT_FOUND);
         } else {
             throw new WorkshiftException("Invalid number of results returned.", WorkshiftException::INVALID_ROW_COUNT);
         }
     }
 }
 private function _fetchEmployeesAndLeaveTypes($searchBy = "employee")
 {
     $selectFields[0] = "c.`emp_number` as emp_number";
     $selectFields[1] = "CONCAT(c.`emp_firstname`, ' ', c.`emp_lastname`) as employee_name";
     $selectFields[2] = "d.`leave_type_id` as leave_type_id";
     $selectFields[3] = "d.`leave_type_name` as leave_type_name";
     $selectFields[4] = "d.`available_flag` as available_flag";
     $selectTable = "`hs_hr_employee` c, `hs_hr_leavetype` d ";
     $selectConditions = null;
     $employeeId = $this->getEmployeeId();
     if (!empty($employeeId) && $this->getEmployeeId() != self::LEAVESUMMARY_CRITERIA_ALL) {
         $selectConditions[] = "c.`emp_number` = {$this->getEmployeeId()}";
     }
     $leaveTypeId = $this->getLeaveTypeId();
     if (!empty($leaveTypeId) && $this->getLeaveTypeId() != self::LEAVESUMMARY_CRITERIA_ALL) {
         $selectConditions[] = "d.`leave_type_id` = '{$this->getLeaveTypeId()}'";
     }
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $resultArr = null;
     while ($row = mysql_fetch_assoc($result)) {
         $row['no_of_days_allotted'] = 0;
         $row['leave_taken'] = 0;
         $row['leave_available'] = 0;
         if ($searchBy == "leaveType") {
             $resultArr[$row['leave_type_id']][$row['emp_number']] = $row;
         } else {
             $resultArr[$row['emp_number']][$row['leave_type_id']] = $row;
         }
     }
     return $resultArr;
 }
 /**
  * Triggers a download of the resume for give application id
  * @param integer $applicationId Id of the application
  * @return sting Outputs the resume only if it's availabe
  */
 public static function downloadResume($applicationId)
 {
     $selectTable = "`" . self::TABLE_NAME . "`";
     $selectFields[0] = "`" . self::DB_FIELD_RESUME_NAME . "`";
     $selectFields[1] = "`" . self::DB_FIELD_RESUME_DATA . "`";
     $selectConditions[0] = "`" . self::DB_FIELD_ID . "` = {$applicationId}";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $row = $dbConnection->dbObject->getArray($result);
     if (!empty($row[self::DB_FIELD_RESUME_DATA])) {
         $name = $row[self::DB_FIELD_RESUME_NAME];
         $extension = array_pop(explode(".", $name));
         $mimeTypes = array('doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'odt' => 'application/vnd.oasis.opendocument.text', 'pdf' => 'application/pdf', 'rtf' => 'application/rtf', 'txt' => 'text/plain');
         $contentType = isset($mimeTypes[$extension]) ? $mimeTypes[$extension] : null;
         $content = $row[self::DB_FIELD_RESUME_DATA];
         $size = strlen($content);
         @ob_clean();
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: private", false);
         header("Content-type: {$contentType}");
         header("Content-Disposition: attachment; filename=\"" . $name . "\";");
         header("Content-Transfer-Encoding: binary");
         header("Content-length: {$size}");
         echo $content;
     }
 }