⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hsppaymentrequest.php

📁 国外的人才求职招聘最新版
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures * all the essential functionalities required for any enterprise. * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com * * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program; * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA  02110-1301, USA * */require_once ROOT_PATH . '/lib/dao/DMLFunctions.php';require_once ROOT_PATH . '/lib/dao/SQLQBuilder.php';require_once ROOT_PATH . '/lib/logs/LogFileWriter.php';class HspPaymentRequest {	const HSP_PAYMENT_REQUEST_DB_TABLE = 'hs_hr_hsp_payment_request';	const DB_FIELD_ID = 'id';	const DB_FIELD_HSP_ID = 'hsp_id';	const DB_FIELD_EMPLOYEE_ID = 'employee_id';	const DB_FIELD_DATE_INCURRED = 'date_incurred';	const DB_FIELD_PROVIDER_NAME = 'provider_name';	const DB_FIELD_PERSON_INCURRING_EXPENSE = 'person_incurring_expense';	const DB_FIELD_EXPENSE_DESCRIPTION = 'expense_description';	const DB_FIELD_EXPENSE_AMOUNT = 'expense_amount';	const DB_FIELD_PAYMENT_MADE_TO = 'payment_made_to';	const DB_FIELD_THIRD_PARTY_ACCOUNT_NUMBER = 'third_party_account_number';	const DB_FIELD_MAIL_ADDRESS = 'mail_address';	const DB_FIELD_COMMENTS = 'comments';	const DB_FIELD_DATE_PAID = 'date_paid';	const DB_FIELD_CHECK_NUMBER = 'check_number';	const DB_FIELD_STATUS = 'status';	const DB_FIELD_HR_NOTES = 'hr_notes';	const EMP_CHILDREN_DB_TABLE = 'hs_hr_emp_children';	const DB_FIELD_EMP_NUMBER = 'emp_number';	const DB_FIELD_EMP_CHILDREN_NAME ='ec_name';	const EMP_DEPENDENT_DB_TABLE = 'hs_hr_emp_dependents';	const DB_FIELD_EMP_DEPENDENT_NAME = 'ed_name';	const HSP_PAYMENT_REQUEST_STATUS_SUBMITTED = 0;	const HSP_PAYMENT_REQUEST_STATUS_PAID = 1;	const HSP_PAYMENT_REQUEST_STATUS_DENIED = 2;	const HSP_PAYMENT_REQUEST_STATUS_DELETED = 3;	private $id;	private $hspId;	private $employeeId;	private $dateIncurred;	private $providerName;	private $personIncurringExpense;	private $expenseDescription;	private $expenseAmount;	private $paymentMadeTo;	private $thirdPartyAccountNumber;	private $mailAddress;	private $comments;	private $datePaid;	private $checkNumber;	private $status;	private $hrNotes;	private $paperWorkSubmitted;	public function getId() {		return $this->id;	}	public function setId($id) {		$this->id=$id;	}	public function getHspId() {		return $this->hspId;	}	public function setHspId($hspId) {		$this->hspId=$hspId;	}	public function getEmployeeId() {		return $this->employeeId;	}	public function setEmployeeId($employeeId) {		$this->employeeId=$employeeId;	}	public function getDateIncurred() {		return $this->dateIncurred;	}	public function setDateIncurred($dateIncurred) {		$this->dateIncurred=$dateIncurred;	}	public function getProviderName() {		return $this->providerName;	}	public function setProviderName($providerName) {		$this->providerName=$providerName;	}	public function getPersonIncurringExpense() {		return $this->personIncurringExpense;	}	public function setPersonIncurringExpense($personIncurringExpense) {		$this->personIncurringExpense=$personIncurringExpense;	}	public function getExpenseDescription() {		return $this->expenseDescription;	}	public function setExpenseDescription($expenseDescription) {		$this->expenseDescription=$expenseDescription;	}	public function getExpenseAmount() {		return $this->expenseAmount;	}	public function setExpenseAmount($expenseAmount) {		$this->expenseAmount=$expenseAmount;	}	public function getPaymentMadeTo() {		return $this->paymentMadeTo;	}	public function setPaymentMadeTo($paymentMadeTo) {		$this->paymentMadeTo=$paymentMadeTo;	}	public function getThirdPartyAccountNumber() {		return $this->thirdPartyAccountNumber;	}	public function setThirdPartyAccountNumber($thirdPartyAccountNumber) {		$this->thirdPartyAccountNumber=$thirdPartyAccountNumber;	}	public function getMailAddress() {		return $this->mailAddress;	}	public function setMailAddress($mailAddress) {		$this->mailAddress=$mailAddress;	}	public function getComments() {		return $this->comments;	}	public function setComments($comments) {		$this->comments=$comments;	}	public function getDatePaid() {		return $this->datePaid;	}	public function setDatePaid($datePaid) {		$this->datePaid=$datePaid;	}	public function getCheckNumber() {		return $this->checkNumber;	}	public function setCheckNumber($checkNumber) {		$this->checkNumber=$checkNumber;	}	public function getStatus() {		return $this->status;	}	public function setStatus($status) {		$this->status=$status;	}	public function getHrNotes() {		return $this->hrNotes;	}	public function setHrNotes($hrNotes) {		$this->hrNotes=$hrNotes;	}	public function getPaperWorkSubmitted() {		return $this->paperWorkSubmitted;	}	public function setPaperWorkSubmitted($paperWorkSubmitted) {		$this->paperWorkSubmitted=$paperWorkSubmitted;	}	public static function getHspRequest($id) {		if (!CommonFunctions::isValidId($id)) {			throw new HspPaymentRequest("Invalid id", HspPaymentRequest::INVALID_ID);		}		$sqlBuilder = new SQLQBuilder();		$selectTable = "`".self::HSP_PAYMENT_REQUEST_DB_TABLE."`";		$selectFields[] = "`".self::DB_FIELD_ID."`";		$selectFields[] = "`".self::DB_FIELD_HSP_ID."`";		$selectFields[] = "`".self::DB_FIELD_EMPLOYEE_ID."`";		$selectFields[] = "`".self::DB_FIELD_DATE_INCURRED."`";		$selectFields[] = "`".self::DB_FIELD_PROVIDER_NAME."`";		$selectFields[] = "`".self::DB_FIELD_PERSON_INCURRING_EXPENSE."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_DESCRIPTION."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_AMOUNT."`";		$selectFields[] = "`".self::DB_FIELD_PAYMENT_MADE_TO."`";		$selectFields[] = "`".self::DB_FIELD_THIRD_PARTY_ACCOUNT_NUMBER."`";		$selectFields[] = "`".self::DB_FIELD_MAIL_ADDRESS."`";		$selectFields[] = "`".self::DB_FIELD_COMMENTS."`";		$selectFields[] = "`".self::DB_FIELD_DATE_PAID."`";		$selectFields[] = "`".self::DB_FIELD_CHECK_NUMBER."`";		$selectFields[] = "`".self::DB_FIELD_STATUS."`";		$selectFields[] = "`".self::DB_FIELD_HR_NOTES."`";		$selectOrder = "ASC";		$selectOrderBy = "`".self::DB_FIELD_ID."`";		$selectConditions[] = "`".self::DB_FIELD_ID."` = $id";		$query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectOrderBy, $selectOrder);		$dbConnection = new DMLFunctions();		$result = $dbConnection->executeQuery($query);		$requests = self::_buildObjArr($result);		if (count($requests) == 1) {			return $requests[0];		} if (count($requests) > 1) {			throw new HspPaymentRequest(HspPaymentRequestException::INVALID_ROW_COUNT, 'Got more than one row. Primary key should be unique');		} else {			return null;		}	}	public function addHspRequest() {		$this->id = UniqueIDGenerator::getInstance()->getNextID(self::HSP_PAYMENT_REQUEST_DB_TABLE, self::DB_FIELD_ID);		$arrTable = '`'.self::HSP_PAYMENT_REQUEST_DB_TABLE.'`';		$insertFields[] = '`'.self::DB_FIELD_ID.'`';		$insertFields[] = '`'.self::DB_FIELD_HSP_ID.'`';		$insertFields[] = '`'.self::DB_FIELD_EMPLOYEE_ID.'`';		$insertFields[] = '`'.self::DB_FIELD_DATE_INCURRED.'`';		$insertFields[] = '`'.self::DB_FIELD_PROVIDER_NAME.'`';		$insertFields[] = '`'.self::DB_FIELD_PERSON_INCURRING_EXPENSE.'`';		$insertFields[] = '`'.self::DB_FIELD_EXPENSE_DESCRIPTION.'`';		$insertFields[] = '`'.self::DB_FIELD_EXPENSE_AMOUNT.'`';		$insertFields[] = '`'.self::DB_FIELD_PAYMENT_MADE_TO.'`';		$insertFields[] = '`'.self::DB_FIELD_THIRD_PARTY_ACCOUNT_NUMBER.'`';		$insertFields[] = '`'.self::DB_FIELD_MAIL_ADDRESS.'`';		$insertFields[] = '`'.self::DB_FIELD_COMMENTS.'`';		$insertFields[] = '`'.self::DB_FIELD_STATUS.'`';		$arrRecordsList[] = $this->id;		$arrRecordsList[] = "'". $this->hspId."'";		$arrRecordsList[] = "'". $this->employeeId."'";		$arrRecordsList[] = "'".$this->dateIncurred."'";		$arrRecordsList[] = "'".$this->providerName."'";		$arrRecordsList[] = "'". $this->personIncurringExpense."'";		$arrRecordsList[] = "'". $this->expenseDescription."'";		$arrRecordsList[] = "'". $this->expenseAmount."'";		$arrRecordsList[] = "'".$this->paymentMadeTo."'";		$arrRecordsList[] = "'".$this->thirdPartyAccountNumber."'";		$arrRecordsList[] = "'".$this->mailAddress."'";		$arrRecordsList[] = "'". $this->comments."'";		$arrRecordsList[] = "'". $this->status."'";		if ($this->datePaid != null) {			$insertFields[] = '`'.self::DB_FIELD_DATE_PAID.'`';			$arrRecordsList[] = "'".$this->datePaid."'";		}		if ($this->checkNumber != null) {			$insertFields[] = '`'.self::DB_FIELD_CHECK_NUMBER.'`';			$arrRecordsList[] = "'". $this->checkNumber."'";		}		if ($this->hrNotes != null) {			$insertFields[] = '`'.self::DB_FIELD_HR_NOTES.'`';			$arrRecordsList[] = "'". $this->hrNotes."'";		}		$sqlBuilder = new SQLQBuilder();		$query = $sqlBuilder->simpleInsert($arrTable, $arrRecordsList, $insertFields);		$dbConnection = new DMLFunctions();		$result = $dbConnection -> executeQuery($query);		//if ($result) {		//	return mysql_affected_rows();		//} else {		//	throw new HspPaymentRequestException("Error in SQL Query", HspPaymentRequestException::ERROR_IN_DB_QUERY);		//}		if ($result) {			return true;		} else {			return false;		}	}	private function _getHsp() {		if ($this->hspId != null) {			return;		}		$hsp = new Hsp();		$hsp->setEmployeeId($this->getEmployeeId());		$hsp->setAllotmentId($this->getAllotmentId());		$hspArr = $hsp->fetchHsps();		if (is_array($hspArr) && isset($hspArr[0])) {			$this->hspId = $hspArr[0]->getId();		} else {			throw new HspPaymentRequestException("No hsp", HspPaymentRequestException::NO_HSP);		}	}	public static function listUnPaidHspRequests() {		$sqlBuilder = new SQLQBuilder();		$selectTable = "`".self::HSP_PAYMENT_REQUEST_DB_TABLE."`";		$selectFields[] = "`".self::DB_FIELD_ID."`";		$selectFields[] = "`".self::DB_FIELD_HSP_ID."`";		$selectFields[] = "`".self::DB_FIELD_EMPLOYEE_ID."`";		$selectFields[] = "`".self::DB_FIELD_DATE_INCURRED."`";		$selectFields[] = "`".self::DB_FIELD_PROVIDER_NAME."`";		$selectFields[] = "`".self::DB_FIELD_PERSON_INCURRING_EXPENSE."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_DESCRIPTION."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_AMOUNT."`";		$selectFields[] = "`".self::DB_FIELD_PAYMENT_MADE_TO."`";		$selectFields[] = "`".self::DB_FIELD_THIRD_PARTY_ACCOUNT_NUMBER."`";		$selectFields[] = "`".self::DB_FIELD_MAIL_ADDRESS."`";		$selectFields[] = "`".self::DB_FIELD_COMMENTS."`";		$selectFields[] = "`".self::DB_FIELD_DATE_PAID."`";		$selectFields[] = "`".self::DB_FIELD_CHECK_NUMBER."`";		$selectFields[] = "`".self::DB_FIELD_STATUS."`";		$selectFields[] = "`".self::DB_FIELD_HR_NOTES."`";		$selectOrder = "ASC";		$selectOrderBy = "`".self::DB_FIELD_ID."`";		$selectConditions[] = "`".self::DB_FIELD_STATUS."` = ".self::HSP_PAYMENT_REQUEST_STATUS_SUBMITTED;		$query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectOrderBy, $selectOrder);		$dbConnection = new DMLFunctions();		$result = $dbConnection->executeQuery($query);		$requests = self::_buildObjArr($result);		if (count($requests) > 0) {			return $requests;		} else {			return null;		}	}	public static function listEmployeeHspRequests($year, $employeeId, $paid=false) {		if (!CommonFunctions::isValidId($employeeId)) {			throw new HspPaymentRequestException("Invalid employee id", HspPaymentRequestException::INVALID_EMPLOYEE_ID);		}		$sqlBuilder = new SQLQBuilder();		$selectTable = "`".self::HSP_PAYMENT_REQUEST_DB_TABLE."`";		$selectFields[] = "`".self::DB_FIELD_ID."`";		$selectFields[] = "`".self::DB_FIELD_HSP_ID."`";		$selectFields[] = "`".self::DB_FIELD_EMPLOYEE_ID."`";		$selectFields[] = "`".self::DB_FIELD_DATE_INCURRED."`";		$selectFields[] = "`".self::DB_FIELD_PROVIDER_NAME."`";		$selectFields[] = "`".self::DB_FIELD_PERSON_INCURRING_EXPENSE."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_DESCRIPTION."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_AMOUNT."`";		$selectFields[] = "`".self::DB_FIELD_PAYMENT_MADE_TO."`";		$selectFields[] = "`".self::DB_FIELD_THIRD_PARTY_ACCOUNT_NUMBER."`";		$selectFields[] = "`".self::DB_FIELD_MAIL_ADDRESS."`";		$selectFields[] = "`".self::DB_FIELD_COMMENTS."`";		$selectFields[] = "`".self::DB_FIELD_DATE_PAID."`";		$selectFields[] = "`".self::DB_FIELD_CHECK_NUMBER."`";		$selectFields[] = "`".self::DB_FIELD_STATUS."`";		$selectFields[] = "`".self::DB_FIELD_HR_NOTES."`";		$selectOrder = "ASC";		$selectOrderBy = "`".self::DB_FIELD_ID."`";		if (true) {			$selectConditions[] = "(`".self::DB_FIELD_STATUS."` = ".self::HSP_PAYMENT_REQUEST_STATUS_PAID .			" OR `".self::DB_FIELD_STATUS."` = " . self::HSP_PAYMENT_REQUEST_STATUS_SUBMITTED . ")";			//$selectConditions[] = "`".self::DB_FIELD_STATUS."` = ".self::HSP_PAYMENT_REQUEST_STATUS_SUBMITTED;		} else {			$selectConditions[] = "`".self::DB_FIELD_STATUS."` IN (".self::HSP_PAYMENT_REQUEST_STATUS_SUBMITTED.", ".self::HSP_PAYMENT_REQUEST_STATUS_PAID.")";		}		$selectConditions[] = "`".self::DB_FIELD_EMPLOYEE_ID."` = $employeeId";		$selectConditions[] = "`".self::DB_FIELD_DATE_INCURRED."` BETWEEN  DATE('$year-01-01') AND DATE('$year-12-31')";		$query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectOrderBy, $selectOrder);		$dbConnection = new DMLFunctions();		$result = $dbConnection->executeQuery($query);		$requests = self::_buildObjArr($result);		if (count($requests) > 0) {			return $requests;		} else {			return null;		}	}	public static function listEmployeeHspRequestsPaid($year, $employeeId) {		if (!CommonFunctions::isValidId($employeeId)) {			throw new HspPaymentRequestException("Invalid employee id", HspPaymentRequestException::INVALID_EMPLOYEE_ID);		}		$sqlBuilder = new SQLQBuilder();		$selectTable = "`".self::HSP_PAYMENT_REQUEST_DB_TABLE."`";		$selectFields[] = "`".self::DB_FIELD_ID."`";		$selectFields[] = "`".self::DB_FIELD_HSP_ID."`";		$selectFields[] = "`".self::DB_FIELD_EMPLOYEE_ID."`";		$selectFields[] = "`".self::DB_FIELD_DATE_INCURRED."`";		$selectFields[] = "`".self::DB_FIELD_PROVIDER_NAME."`";		$selectFields[] = "`".self::DB_FIELD_PERSON_INCURRING_EXPENSE."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_DESCRIPTION."`";		$selectFields[] = "`".self::DB_FIELD_EXPENSE_AMOUNT."`";		$selectFields[] = "`".self::DB_FIELD_PAYMENT_MADE_TO."`";		$selectFields[] = "`".self::DB_FIELD_THIRD_PARTY_ACCOUNT_NUMBER."`";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -