Esempio n. 1
0
 /**
  * Get the singleton instance of this class
  */
 public static function getInstance()
 {
     if (!is_object(self::$instance)) {
         self::$instance = new UniqueIDGenerator();
     }
     return self::$instance;
 }
Esempio n. 2
0
 /**
  * Tears down the fixture, for example, close a network connection.
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_employee_workshift`", $this->connection));
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_workshift`", $this->connection));
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_employee`", $this->connection));
     UniqueIDGenerator::getInstance()->resetIDs();
 }
Esempio n. 3
0
 /**
  * Tears down the fixture, removed database entries created during test.
  *
  * @access protected
  */
 protected function tearDown()
 {
     $this->_deleteTables();
     // Insert default geninfo, and compstructtree values
     $this->_runQuery("INSERT INTO `hs_hr_geninfo` VALUES ('001','','')");
     $this->_runQuery("INSERT INTO `hs_hr_compstructtree`(`title`, `description`, `loc_code`, `lft`, `rgt`, `id`, `parnt`, `dept_id`) VALUES ('', 'Parent Company', null , 1, 2, 1, 0, null)");
     UniqueIDGenerator::getInstance()->resetIDs();
 }
Esempio n. 4
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     $this->assertTrue(mysql_query("TRUNCATE `hs_hr_config`;", $this->connection), mysql_error());
     foreach ($this->oldValues as $row) {
         $query = "INSERT INTO `hs_hr_config` VALUES ('" . implode("', '", $row) . "')";
         $this->assertTrue(mysql_query($query));
     }
     UniqueIDGenerator::getInstance()->resetIDs();
 }
Esempio n. 5
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->classHoliday = new Holidays();
     $conf = new Conf();
     $this->connection = mysql_connect($conf->dbhost . ":" . $conf->dbport, $conf->dbuser, $conf->dbpass);
     mysql_select_db($conf->dbname);
     mysql_query("TRUNCATE TABLE `hs_hr_holidays`", $this->connection);
     mysql_query("INSERT INTO `hs_hr_holidays` (`holiday_id`, `description`, `date`, `recurring`, `length`) VALUES (10, 'Independence', '" . date('Y') . "-07-04', " . Holidays::HOLIDAYS_RECURRING . ", 8)");
     mysql_query("INSERT INTO `hs_hr_holidays` (`holiday_id`, `description`, `date`, `recurring`, `length`) VALUES (11, 'Poya', '" . date('Y') . "-01-04', " . Holidays::HOLIDAYS_NOT_RECURRING . ", 4)");
     UniqueIDGenerator::getInstance()->initTable();
 }
Esempio n. 6
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->classLeaveType = new LeaveType();
     $conf = new Conf();
     $this->connection = mysql_connect($conf->dbhost . ":" . $conf->dbport, $conf->dbuser, $conf->dbpass);
     mysql_select_db($conf->dbname);
     mysql_query("TRUNCATE TABLE `hs_hr_leavetype`");
     mysql_query("INSERT INTO `hs_hr_leavetype` VALUES ('LTY011', 'Medical', 1)");
     mysql_query("INSERT INTO `hs_hr_leavetype` VALUES ('LTY012', 'Medicals', 1)");
     mysql_query("INSERT INTO `hs_hr_leavetype` VALUES ('LTY013', 'Medicalx', 1)");
     UniqueIDGenerator::getInstance()->initTable();
 }
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->classHoliday = new Holidays();
     $conf = new Conf();
     $this->connection = mysql_connect($conf->dbhost . ":" . $conf->dbport, $conf->dbuser, $conf->dbpass);
     mysql_select_db($conf->dbname);
     mysql_query("TRUNCATE TABLE `hs_hr_holidays`", $this->connection);
     mysql_query("INSERT INTO `hs_hr_holidays` (`holiday_id`, `description`, `date`, `recurring`, `length`) VALUES (10, 'Independence', '" . date('Y') . "-07-04', " . Holidays::HOLIDAYS_RECURRING . ", 8)");
     mysql_query("INSERT INTO `hs_hr_holidays` (`holiday_id`, `description`, `date`, `recurring`, `length`) VALUES (11, 'Poya', '" . date('Y') . "-01-04', " . Holidays::HOLIDAYS_NOT_RECURRING . ", 4)");
     UniqueIDGenerator::getInstance()->initTable();
     mysql_query("INSERT INTO `hs_hr_employee`(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, emp_nick_name) " . "VALUES (18, NULL, 'Nadeeth', 'H', 'Lansakara', 'rc')");
     mysql_query("INSERT INTO `hs_hr_leavetype` VALUES ('LTY010', 'Medical', 1)");
     mysql_query("INSERT INTO `hs_hr_leave_requests` (`leave_request_id`, `leave_type_id`, `leave_type_name`, `date_applied`, `employee_id`) VALUES (11, 'LTY010', 'Medical', '" . date('Y-m-d', time() + 3600 * 24) . "', '18')");
     mysql_query("INSERT INTO `hs_hr_leave` (`leave_id`, `employee_id`, `leave_type_id`, `leave_date`, `leave_length_hours`, `leave_length_days`, `leave_status`, `leave_comments`, `leave_request_id`) VALUES (10, '18', 'LTY010', '" . date('Y-m-d', time() - 3600 * 24 * 2) . "', 4, 0.5, 3, '', 11)");
     mysql_query("INSERT INTO `hs_hr_leave` (`leave_id`, `employee_id`, `leave_type_id`, `leave_date`, `leave_length_hours`, `leave_length_days`, `leave_status`, `leave_comments`, `leave_request_id`) VALUES (11, '18', 'LTY010', '" . date('Y-m-d', time() - 3600 * 24 * 1) . "', 8, 1, 5, '', 11)");
     mysql_query("INSERT INTO `hs_hr_leave` (`leave_id`, `employee_id`, `leave_type_id`, `leave_date`, `leave_length_hours`, `leave_length_days`, `leave_status`, `leave_comments`, `leave_request_id`) VALUES (12, '18', 'LTY010', '" . date('Y-m-d', time() + 3600 * 24 * 2) . "', 8, 1, 2, '', 11)");
     mysql_query("INSERT INTO `hs_hr_leave` (`leave_id`, `employee_id`, `leave_type_id`, `leave_date`, `leave_length_hours`, `leave_length_days`, `leave_status`, `leave_comments`, `leave_request_id`) VALUES (13, '18', 'LTY010', '" . date('Y-m-d', time() + 3600 * 24 * 3) . "', 8, 1, 5, '', 11)");
 }
 /**
  * Initialize unique ID's
  */
 public static function initUniqueIDs()
 {
     self::connectDB();
     if (!mysql_select_db($_SESSION['dbInfo']['dbName'])) {
         $_SESSION['error'] = 'Unable to connect to Database!';
         error_log(date("r") . " Initializing unique id's. Error - Unable to connect to Database\n", 3, "installer/log.txt");
         return false;
     }
     /* Initialize the hs_hr_unique_id table */
     try {
         UniqueIDGenerator::getInstance()->initTable();
     } catch (IDGeneratorException $e) {
         $errMsg = $e->getMessage() . ". Trace = " . $e->getTraceAsString();
         $_SESSION['error'] = $errMsg;
         error_log(date("r") . " Initializing hs_hr_unique_id table failed with: {$errMsg}\n", 3, "log.txt");
         return false;
     }
     return true;
 }
 /**
  * Saves the given JobSpec objects in the databas
  *
  * @param array $specs Array of JobSpec objects to save.
  */
 private function _createJobSpecs($specs)
 {
     foreach ($specs as $spec) {
         $sql = sprintf("INSERT INTO hs_hr_job_spec(jobspec_id, jobspec_name, jobspec_desc, jobspec_duties) " . "VALUES(%d, '%s', '%s', '%s')", $spec->getId(), $spec->getName(), $spec->getDesc(), $spec->getDuties());
         $this->assertTrue(mysql_query($sql), mysql_error());
     }
     UniqueIDGenerator::getInstance()->initTable();
 }
 /**
  * Add new CustomExport object to database
  */
 private function _insert()
 {
     $fields[0] = self::DB_FIELDS_ID;
     $fields[1] = self::DB_FIELDS_NAME;
     $fields[2] = self::DB_FIELDS_FIELDS;
     $fields[3] = self::DB_FIELDS_HEADINGS;
     $this->id = UniqueIDGenerator::getInstance()->getNextID(self::TABLE_NAME, self::DB_FIELDS_ID);
     $values[0] = $this->id;
     $values[1] = "'{$this->name}'";
     $values[2] = "'" . implode(",", $this->assignedFields) . "'";
     $values[3] = empty($this->headings) ? "''" : "'" . implode(",", $this->headings) . "'";
     $sqlBuilder = new SQLQBuilder();
     $sqlBuilder->table_name = self::TABLE_NAME;
     $sqlBuilder->flg_insert = 'true';
     $sqlBuilder->arr_insert = $values;
     $sqlBuilder->arr_insertfield = $fields;
     $sql = $sqlBuilder->addNewRecordFeature2();
     $conn = new DMLFunctions();
     $result = $conn->executeQuery($sql);
     if (!$result || mysql_affected_rows() != 1) {
         throw new CustomExportException("Insert failed. {$sql}", CustomExportException::DB_EXCEPTION);
     }
 }
 /**
  * Add the Leave Type
  *
  */
 public function addLeaveType()
 {
     $this->leaveTypeId = UniqueIDGenerator::getInstance()->getNextID('hs_hr_leavetype', 'leave_type_id', 'LTY');
     $arrRecordsList[0] = "'" . $this->getLeaveTypeId() . "'";
     $arrRecordsList[1] = "'" . $this->getLeaveTypeName() . "'";
     $arrRecordsList[2] = $this->availableStatusFlag;
     $sqlBuilder = new SQLQBuilder();
     $arrTable = "`hs_hr_leavetype`";
     $query = $sqlBuilder->simpleInsert($arrTable, $arrRecordsList);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     return $result;
 }
Esempio n. 12
0
<?php

define('ROOT_PATH', dirname(__FILE__) . '/..');
require_once ROOT_PATH . '/installer/utils/DMLFunctions.php';
require_once ROOT_PATH . '/installer/utils/UniqueIDGenerator.php';
echo "Running UniqueIDGenerator\n";
$conn = new DMLFunctions();
UniqueIDGenerator::getInstance()->initTable();
echo "Finished fixing ID's\n";
 /**
  * Create job application event with the passed parameters
  *
  * @param int $id
  * @param int $applicationId
  * @param String $createdTime
  * @param String $createdBy
  * @param int $ownerId
  * @param String $eventTime
  * @param int $eventType
  * @param int $eventStatus
  * @param String $notes
  */
 private function _createEvent($id, $applicationId, $createdTime, $createdBy, $ownerId, $eventTime, $eventType, $eventStatus, $notes)
 {
     $sql = sprintf("INSERT INTO `hs_hr_job_application_events`(`id`,`application_id`,`created_time`," . "`created_by`, `owner`, `event_time`, `event_type`, `status`, `notes`) " . "VALUES (%d, %d, '%s', '%s', %d, '%s', %d, %d, '%s')", $id, $applicationId, $createdTime, $createdBy, $ownerId, $eventTime, $eventType, $eventStatus, $notes);
     $this->assertTrue(mysql_query($sql), mysql_error());
     UniqueIDGenerator::getInstance()->initTable();
 }
Esempio n. 14
0
 function addJobTitles()
 {
     $tableName = 'HS_HR_JOB_TITLE';
     $this->jobId = UniqueIDGenerator::getInstance()->getNextID($tableName, 'JOBTIT_CODE', 'JOB');
     $arrRecordsList[0] = "'" . $this->getJobId() . "'";
     $arrRecordsList[1] = "'" . $this->getJobName() . "'";
     $arrRecordsList[2] = "'" . $this->getJobDesc() . "'";
     $arrRecordsList[3] = "'" . $this->getJobComm() . "'";
     $arrRecordsList[4] = "'" . $this->getJobSalGrd() . "'";
     $arrRecordsList[5] = isset($this->jobSpecId) ? $this->jobSpecId : 'null';
     $arrFieldList[0] = 'JOBTIT_CODE';
     $arrFieldList[1] = 'JOBTIT_NAME';
     $arrFieldList[2] = 'JOBTIT_DESC';
     $arrFieldList[3] = 'JOBTIT_COMM';
     $arrFieldList[4] = 'SAL_GRD_CODE';
     $arrFieldList[5] = self::DB_FIELD_JOBSPEC_ID;
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_insert = 'true';
     $sql_builder->arr_insert = $arrRecordsList;
     $sql_builder->arr_insertfield = $arrFieldList;
     $sqlQString = $sql_builder->addNewRecordFeature2();
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     $jobTitleEmpStat = new JobTitEmpStat();
     $jobTitleEmpStat->setEmpStatId(EmploymentStatus::EMPLOYMENT_STATUS_ID_TERMINATED);
     $jobTitleEmpStat->setJobTitId($this->getJobId());
     $jobTitleEmpStat->addJobTitEmpStat();
     return $message2;
 }
Esempio n. 15
0
 function addUserGroups()
 {
     $this->userGroupID = UniqueIDGenerator::getInstance()->getNextID($this->tableName, 'userg_id', 'USG');
     $arrFieldList[0] = "'" . $this->getUserGroupID() . "'";
     $arrFieldList[1] = "'" . $this->getUserGroupName() . "'";
     $arrFieldList[2] = "'" . $this->getUserGroupRepDef() . "'";
     $arrRecordsList[0] = 'userg_id';
     $arrRecordsList[1] = 'userg_name';
     $arrRecordsList[2] = 'userg_repdef';
     $this->sql_builder->table_name = $this->tableName;
     $this->sql_builder->flg_insert = 'true';
     $this->sql_builder->arr_insertfield = $arrRecordsList;
     $this->sql_builder->arr_insert = $arrFieldList;
     $sqlQString = $this->sql_builder->addNewRecordFeature2();
     $message2 = $this->dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     return $message2;
 }
Esempio n. 16
0
 /**
  * Tears down the fixture, removed database entries created during test.
  *
  * @access protected
  */
 protected function tearDown()
 {
     $this->_deleteTables();
     UniqueIDGenerator::getInstance()->resetIDs();
 }
Esempio n. 17
0
 function addSalaryGrades()
 {
     $tableName = 'HS_PR_SALARY_GRADE';
     $this->salgrdId = UniqueIDGenerator::getInstance()->getNextID($tableName, 'SAL_GRD_CODE', 'SAL');
     $arrFieldList[0] = "'" . $this->getSalGrdId() . "'";
     $arrFieldList[1] = "'" . $this->getSalGrdDesc() . "'";
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_insert = 'true';
     $sql_builder->arr_insert = $arrFieldList;
     $sqlQString = $sql_builder->addNewRecordFeature1();
     $dbConnection = new DMLFunctions();
     $message = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     if ($message) {
         return $message;
     } else {
         $errCode = mysql_errno();
         switch ($errCode) {
             case 1062:
                 $e = new SalaryGradesException('Pay Grades cannot have duplicate names', SalaryGradesException::DUPLICATE_SALARY_GRADE);
                 break;
             default:
                 $e = new SalaryGradesException('Unknown error in when adding Pay Grades', SalaryGradesException::UNKNOWN_EXCEPTION);
                 break;
         }
         throw $e;
     }
 }
Esempio n. 18
0
 public function testListUnPaidHspRequests()
 {
     $expected[] = array(11, 10, 11, date('Y-m-d', time() - 3600 * 24), 'Test provider 1', 'Tester 1', 'Just testing 1', '100', 'TestX 1', '12345GD', '1231, Test Grove, Test City 1', 'Test 1', null, null, 0);
     $paymentRequests = HspPaymentRequest::listUnPaidHspRequests();
     $this->assertNotNull($paymentRequests);
     for ($i = 0; $i < count($paymentRequests); $i++) {
         $this->assertNotNull($paymentRequests[$i]);
         $this->assertEquals($expected[$i][0], $paymentRequests[$i]->getId());
         $this->assertEquals($expected[$i][1], $paymentRequests[$i]->getHspId());
         $this->assertEquals($expected[$i][2], $paymentRequests[$i]->getEmployeeId());
         $this->assertEquals($expected[$i][3], $paymentRequests[$i]->getDateIncurred());
         $this->assertEquals($expected[$i][4], $paymentRequests[$i]->getProviderName());
         $this->assertEquals($expected[$i][5], $paymentRequests[$i]->getPersonIncurringExpense());
         $this->assertEquals($expected[$i][6], $paymentRequests[$i]->getExpenseDescription());
         $this->assertEquals($expected[$i][7], $paymentRequests[$i]->getExpenseAmount());
         $this->assertEquals($expected[$i][8], $paymentRequests[$i]->getPaymentMadeTo());
         $this->assertEquals($expected[$i][9], $paymentRequests[$i]->getThirdPartyAccountNumber());
         $this->assertEquals($expected[$i][10], $paymentRequests[$i]->getMailAddress());
         $this->assertEquals($expected[$i][11], $paymentRequests[$i]->getComments());
         $this->assertEquals($expected[$i][12], $paymentRequests[$i]->getDatePaid());
         $this->assertEquals($expected[$i][13], $paymentRequests[$i]->getCheckNumber());
         $this->assertEquals($expected[$i][14], $paymentRequests[$i]->getStatus());
     }
     $this->assertTrue(mysql_query("DELETE FROM `hs_hr_hsp_payment_request` WHERE `id` IN (11);", $this->connection), mysql_error());
     UniqueIDGenerator::getInstance()->resetIDs();
     $paymentRequests = HspPaymentRequest::listUnPaidHspRequests();
     $this->assertNull($paymentRequests);
 }
Esempio n. 19
0
 /**
  * Insert new object to database
  */
 private function _insert()
 {
     $this->id = UniqueIDGenerator::getInstance()->getNextID(self::TABLE_NAME, self::DB_FIELD_ID);
     if (empty($this->appliedDateTime)) {
         $this->appliedDateTime = date(LocaleUtil::STANDARD_TIMESTAMP_FORMAT);
     }
     $sqlBuilder = new SQLQBuilder();
     $sqlBuilder->table_name = self::TABLE_NAME;
     $sqlBuilder->flg_insert = 'true';
     $sqlBuilder->arr_insert = $this->_getFieldValuesAsArray();
     $sqlBuilder->arr_insertfield = $this->dbFields;
     $sql = $sqlBuilder->addNewRecordFeature2();
     $conn = new DMLFunctions();
     $result = $conn->executeQuery($sql);
     if (!$result || mysql_affected_rows() != 1) {
         throw new JobApplicationException("Insert failed. ", JobApplicationException::DB_ERROR);
     }
     return $this->id;
 }
Esempio n. 20
0
 /**
  * Add a new timesheet
  *
  * Status will be overwritten
  */
 public function addTimesheet()
 {
     $newId = UniqueIDGenerator::getInstance()->getNextID(self::TIMESHEET_DB_TABLE_TIMESHEET, self::TIMESHEET_DB_FIELD_TIMESHEET_ID);
     $this->setTimesheetId($newId);
     if ($this->getStartDate() == '' || $this->getEndDate() == '') {
         $this->_getNewDates();
     }
     $this->setStatus(self::TIMESHEET_STATUS_NOT_SUBMITTED);
     $sql_builder = new SQLQBuilder();
     $insertTable = self::TIMESHEET_DB_TABLE_TIMESHEET;
     $insertFields[0] = "`" . self::TIMESHEET_DB_FIELD_TIMESHEET_ID . "`";
     $insertFields[1] = "`" . self::TIMESHEET_DB_FIELD_EMPLOYEE_ID . "`";
     $insertFields[2] = "`" . self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID . "`";
     $insertFields[3] = "`" . self::TIMESHEET_DB_FIELD_START_DATE . "`";
     $insertFields[4] = "`" . self::TIMESHEET_DB_FIELD_END_DATE . "`";
     $insertFields[5] = "`" . self::TIMESHEET_DB_FIELD_STATUS . "`";
     $insertValues[0] = $this->getTimesheetId();
     $insertValues[1] = $this->getEmployeeId();
     $insertValues[2] = $this->getTimesheetPeriodId();
     $insertValues[3] = "'" . $this->getStartDate() . "'";
     $insertValues[4] = "'" . $this->getEndDate() . "'";
     $insertValues[5] = $this->getStatus();
     $insertValues = $sql_builder->quoteCorrect($insertValues);
     $query = $sql_builder->simpleInsert($insertTable, $insertValues, $insertFields);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     if ($result && mysql_affected_rows() > 0) {
         return true;
     }
     return false;
 }
 /**
  * Add new project
  *
  * Deleted will be overwritten to NOT_DELETED
  */
 public function addProject()
 {
     if ($this->_isDuplicateName()) {
         throw new ProjectsException("Duplicate name", 1);
     }
     $this->projectID = UniqueIDGenerator::getInstance()->getNextID(self::TABLE_NAME, self::PROJECT_DB_FIELD_PROJECT_ID);
     $arrRecord[0] = "'" . $this->getProjectId() . "'";
     $arrRecord[1] = "'" . $this->getCustomerId() . "'";
     $arrRecord[2] = "'" . $this->getProjectName() . "'";
     $arrRecord[3] = "'" . $this->getProjectDescription() . "'";
     $arrRecord[4] = self::PROJECT_NOT_DELETED;
     $tableName = self::TABLE_NAME;
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_insert = 'true';
     $sql_builder->arr_insert = $arrRecord;
     $sqlQString = $sql_builder->addNewRecordFeature1();
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     if ($message2 && mysql_affected_rows() > 0) {
         return true;
     }
     return false;
 }
 /**
  * Saves the given JobApplication objects in the database
  *
  * @param array $applications Array of JobApplication objects to save.
  */
 private function _createJobApplications($applications)
 {
     foreach ($applications as $application) {
         $sql = sprintf("INSERT INTO hs_hr_job_application(application_id, vacancy_id, firstname, middlename, " . "lastname, street1, street2, city, country_code, province, zip, " . "phone, mobile, email, qualifications) " . "VALUES(%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $application->getId(), $application->getVacancyId(), $application->getFirstName(), $application->getMiddleName(), $application->getLastName(), $application->getStreet1(), $application->getStreet2(), $application->getCity(), $application->getCountry(), $application->getProvince(), $application->getZip(), $application->getPhone(), $application->getMobile(), $application->getEmail(), $application->getQualifications());
         $this->assertTrue(mysql_query($sql), mysql_error());
     }
     UniqueIDGenerator::getInstance()->initTable();
 }
Esempio n. 23
0
 private function _insert()
 {
     $fields[0] = self::DB_FIELD_ACTIVITY_ID;
     $fields[1] = self::DB_FIELD_NAME;
     $fields[2] = self::DB_FIELD_PROJECT_ID;
     $fields[3] = self::DB_FIELD_DELETED;
     $this->id = UniqueIDGenerator::getInstance()->getNextID(self::TABLE_NAME, self::DB_FIELD_ACTIVITY_ID);
     $values[0] = $this->id;
     $values[1] = "'{$this->name}'";
     $values[2] = "'{$this->projectId}'";
     $values[3] = "'" . intval($this->deleted) . "'";
     $sqlBuilder = new SQLQBuilder();
     $sqlBuilder->table_name = self::TABLE_NAME;
     $sqlBuilder->flg_insert = 'true';
     $sqlBuilder->arr_insert = $values;
     $sqlBuilder->arr_insertfield = $fields;
     $sql = $sqlBuilder->addNewRecordFeature2();
     $conn = new DMLFunctions();
     $result = $conn->executeQuery($sql);
     if (!$result || mysql_affected_rows() != 1) {
         throw new ProjectActivityException("Insert failed. ");
     }
 }
 function addEmpStat()
 {
     $tableName = 'HS_HR_EMPSTAT';
     $this->empStatId = UniqueIDGenerator::getInstance()->getNextID($tableName, 'ESTAT_CODE', 'EST');
     $arrFieldList[0] = "'" . $this->getEmpStatId() . "'";
     $arrFieldList[1] = "'" . $this->getEmpStatName() . "'";
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_insert = 'true';
     $sql_builder->arr_insert = $arrFieldList;
     $sqlQString = $sql_builder->addNewRecordFeature1();
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     return $message2;
 }
Esempio n. 25
0
 function addEmpMain()
 {
     $tableName = 'HS_HR_EMPLOYEE';
     $this->empId = UniqueIDGenerator::getInstance()->getNextID($tableName, 'EMP_NUMBER');
     $arrRecordsList[0] = "'" . $this->getEmpId() . "'";
     $arrRecordsList[1] = "'" . $this->getEmpLastName() . "'";
     $arrRecordsList[2] = "'" . $this->getEmpFirstName() . "'";
     $arrRecordsList[3] = "'" . $this->getEmpNickName() . "'";
     $arrRecordsList[4] = "'" . $this->getEmpMiddleName() . "'";
     $arrRecordsList[5] = "'" . $this->getEmployeeId() . "'";
     $arrFieldList[0] = 'EMP_NUMBER';
     $arrFieldList[1] = 'EMP_LASTNAME';
     $arrFieldList[2] = 'EMP_FIRSTNAME';
     $arrFieldList[3] = 'EMP_NICK_NAME';
     $arrFieldList[4] = 'EMP_MIDDLE_NAME';
     $arrFieldList[5] = 'EMPLOYEE_ID';
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_insert = 'true';
     $sql_builder->arr_insert = $arrRecordsList;
     $sql_builder->arr_insertfield = $arrFieldList;
     $sqlQString = $sql_builder->addNewRecordFeature2();
     //echo $sqlQString;
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     return $message2;
 }
Esempio n. 26
0
 function addEducation()
 {
     $tableName = 'hs_hr_education';
     $this->eduId = UniqueIDGenerator::getInstance()->getNextID($tableName, 'edu_code', 'EDU');
     $arrFieldList[0] = "'" . $this->getEduId() . "'";
     $arrFieldList[1] = "'" . $this->getEduUni() . "'";
     $arrFieldList[2] = "'" . $this->getEduDeg() . "'";
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_insert = 'true';
     $sql_builder->arr_insert = $arrFieldList;
     $sqlQString = $sql_builder->addNewRecordFeature1();
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     return $message2;
     echo $message2;
 }
 function addMembershipInfo()
 {
     if ($this->_isDuplicateName()) {
         throw new MembershipInfoException("Duplicate name", 1);
     }
     $tableName = 'hs_hr_membership';
     $this->membershipId = UniqueIDGenerator::getInstance()->getNextID($tableName, 'membship_code', 'MME');
     $arrFieldList[0] = "'" . $this->getMembershipInfoId() . "'";
     $arrFieldList[1] = "'" . $this->getMembershipTypeId() . "'";
     $arrFieldList[2] = "'" . $this->getMembershipInfoDesc() . "'";
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_insert = 'true';
     $sql_builder->arr_insert = $arrFieldList;
     $sqlQString = $sql_builder->addNewRecordFeature1();
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     return $message2;
 }
Esempio n. 28
0
 /**
  * Saves the given Project Activity objects in the databas
  *
  * @param ProjectActivity $activities ProjectActivity objects to save.
  */
 private function _createActivites($activities)
 {
     foreach ($activities as $activity) {
         $sql = sprintf("INSERT INTO ohrm_project_activity(activity_id, project_id, name, is_deleted) " . "VALUES(%d, %d, '%s', %d)", $activity->getId(), $activity->getProjectId(), $activity->getName(), $activity->isDeleted() ? 1 : 0);
         mysql_query($sql);
         UniqueIDGenerator::getInstance()->initTable();
     }
 }
Esempio n. 29
0
 /**
  * Add new time event
  *
  * Time event id will be over written
  *
  * @throws TimeEventException Overlapping time period 2
  */
 public function addTimeEvent()
 {
     if ($this->getStartTime() != null && $this->getEmployeeId() != null) {
         $this->_checkStartTimeInTimeEvent();
     }
     $this->_isOverlapping();
     $newId = UniqueIDGenerator::getInstance()->getNextID(self::TIME_EVENT_DB_TABLE_TIME_EVENT, self::TIME_EVENT_DB_FIELD_TIME_EVENT_ID);
     $this->setTimeEventId($newId);
     $insertTable = "`" . self::TIME_EVENT_DB_TABLE_TIME_EVENT . "`";
     $insertFields[0] = "`" . self::TIME_EVENT_DB_FIELD_TIME_EVENT_ID . "`";
     $insertFields[1] = "`" . self::TIME_EVENT_DB_FIELD_PROJECT_ID . "`";
     $insertFields[2] = "`" . self::TIME_EVENT_DB_FIELD_ACTIVITY_ID . "`";
     $insertFields[3] = "`" . self::TIME_EVENT_DB_FIELD_EMPLOYEE_ID . "`";
     $insertFields[4] = "`" . self::TIME_EVENT_DB_FIELD_TIMESHEET_ID . "`";
     $insertValues[0] = $this->getTimeEventId();
     $insertValues[1] = $this->getProjectId();
     $insertValues[2] = $this->getActivityId();
     $insertValues[3] = $this->getEmployeeId();
     $insertValues[4] = $this->getTimesheetId();
     if ($this->getStartTime() != null) {
         $insertFields[] = "`" . self::TIME_EVENT_DB_FIELD_START_TIME . "`";
         $insertValues[] = "'" . $this->getStartTime() . "'";
     }
     if ($this->getEndTime() != null) {
         $insertFields[] = "`" . self::TIME_EVENT_DB_FIELD_END_TIME . "`";
         $insertValues[] = "'" . $this->getEndTime() . "'";
     }
     if ($this->getReportedDate() != null) {
         $insertFields[] = "`" . self::TIME_EVENT_DB_FIELD_REPORTED_DATE . "`";
         $insertValues[] = "'" . $this->getReportedDate() . "'";
     }
     if ($this->getDuration() != null) {
         $insertFields[] = "`" . self::TIME_EVENT_DB_FIELD_DURATION . "`";
         $insertValues[] = $this->getDuration();
     }
     if ($this->getDescription() != null) {
         $insertFields[] = "`" . self::TIME_EVENT_DB_FIELD_DESCRIPTION . "`";
         $insertValues[] = "'" . $this->getDescription() . "'";
     }
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleInsert($insertTable, $insertValues, $insertFields);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     if ($result) {
         if (mysql_affected_rows() > 0) {
             return true;
         }
     }
     return false;
 }
Esempio n. 30
0
 private function _insert()
 {
     $fields[0] = self::DB_FIELD_WORKSHIFT_ID;
     $fields[1] = self::DB_FIELD_NAME;
     $fields[2] = self::DB_FIELD_HOURS;
     $this->workshiftId = UniqueIDGenerator::getInstance()->getNextID(self::WORKSHIFT_TABLE, self::DB_FIELD_WORKSHIFT_ID);
     $values[0] = $this->workshiftId;
     $values[1] = "'{$this->name}'";
     $values[2] = "'{$this->hoursPerDay}'";
     $sqlBuilder = new SQLQBuilder();
     $sqlBuilder->table_name = self::WORKSHIFT_TABLE;
     $sqlBuilder->flg_insert = 'true';
     $sqlBuilder->arr_insert = $values;
     $sqlBuilder->arr_insertfield = $fields;
     $sql = $sqlBuilder->addNewRecordFeature2();
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($sql);
     if (!$result) {
         throw new WorkshiftException("Workshift not inserted", WorkshiftException::ERROR_IN_DB_QUERY);
     }
     if (mysql_affected_rows() != 1) {
         throw new WorkshiftException("Workshift not inserted", WorkshiftException::INVALID_ROW_COUNT);
     }
     return mysql_affected_rows();
 }