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

📄 timesheet.php

📁 国外的人才求职招聘最新版
💻 PHP
📖 第 1 页 / 共 2 页
字号:
	public function rejectTimesheet() {		if ($this->getStatus() != self::TIMESHEET_STATUS_SUBMITTED) {			return false;		}		$this->setStatus(self::TIMESHEET_STATUS_REJECTED);		$this->setComment($this->getComment());		return $this->_changeTimesheetStatus();	}	/**	 * Change the status of the filled timesheet	 */	private function _changeTimesheetStatus() {		$sql_builder = new SQLQBuilder();		$updateTable = self::TIMESHEET_DB_TABLE_TIMESHEET;		$updateFields[0] = "`".self::TIMESHEET_DB_FIELD_STATUS."`";		$updateValues[0] = $this->getStatus();		if ($this->getComment() != null) {			$updateFields[] = "`".self::TIMESHEET_DB_FIELD_COMMENT."`";			$updateValues[] = "'".$this->getComment()."'";		}		$updateConditions[] = "`".self::TIMESHEET_DB_FIELD_TIMESHEET_ID."` = {$this->getTimesheetId()}";		$query = $sql_builder->simpleUpdate($updateTable, $updateFields, $updateValues, $updateConditions);		$dbConnection = new DMLFunctions();		$result = $dbConnection -> executeQuery($query);		if ($result) {			return true;		}		return false;	}	/**	 * Fetch the next/previous Timesheet Id	 *	 * This will fetch the next or previous timesheet id of the current	 * timesheet (start date and end date of the current timesheet)	 *	 * @param int direction	 */	public function fetchTimesheetId($direction) {		$sql_builder = new SQLQBuilder();		$selectTable = self::TIMESHEET_DB_TABLE_TIMESHEET." a ";		$selectFields[0] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_ID."`";		$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_EMPLOYEE_ID."` = {$this->getEmployeeId()}";        $order = "ASC" ;		switch ($direction) {			case self::TIMESHEET_DIRECTION_NEXT :                                                    $order = "DESC" ;													$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_START_DATE."` > '{$this->getEndDate()}'";													break;			case self::TIMESHEET_DIRECTION_PREV :                                                    $order = "ASC" ;													$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_START_DATE."` < '{$this->getStartDate()}'";													break;		}		if ($this->getStatuses() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."` IN(".implode(", ", $this->getStatuses()).")";		} else if ($this->getStatus() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."` = '{$this->getStatus()}'";		}		$query = $sql_builder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectFields[0],  $order , 1);		$dbConnection = new DMLFunctions();		$result = $dbConnection->executeQuery($query);		if ($result) {			if ($row = mysql_fetch_assoc($result)) {				return $row[self::TIMESHEET_DB_FIELD_TIMESHEET_ID];			}		}		return false;	}	/**	 * Retrieve timesheets in bulk	 *	 * Introduced for printing timesheets	 *	 * @param Integer page Page number	 * @param String[] employeeIds Array of employee ids	 */	public function fetchTimesheetsBulk($page, $employeeIds) {		$sql_builder = new SQLQBuilder();		$selectTable = self::TIMESHEET_DB_TABLE_TIMESHEET." a ";		$selectFields[0] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_ID."`";		$selectFields[1] = "a.`".self::TIMESHEET_DB_FIELD_EMPLOYEE_ID."`";		$selectFields[2] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID."`";		$selectFields[3] = "a.`".self::TIMESHEET_DB_FIELD_START_DATE."`";		$selectFields[4] = "a.`".self::TIMESHEET_DB_FIELD_END_DATE."`";		$selectFields[5] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."`";		$selectFields[6] = "a.`".self::TIMESHEET_DB_FIELD_COMMENT."`";        $selectConditions = null;        $selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_EMPLOYEE_ID."` IN('".implode("', '", $employeeIds)."')";		if ($this->getTimesheetPeriodId() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID."` = {$this->getTimesheetPeriodId()}";		}		if ($this->getStartDate() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_START_DATE."` >= '{$this->getStartDate()}'";		}		if ($this->getEndDate() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_END_DATE."` <= '{$this->getEndDate()}'";		}		if ($this->getStatuses() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."` IN('".implode("', '", $this->getStatuses())."')";		}		$sysConfObj = new sysConf();		if ($page == 0) {			$selectLimit=null;		} else {			$selectLimit = (($page-1)*$sysConfObj->itemsPerPage).", $sysConfObj->itemsPerPage";		}		$query = $sql_builder->simpleSelect($selectTable, $selectFields, $selectConditions, "{$selectFields[1]}, {$selectFields[3]}", 'ASC', $selectLimit);		$dbConnection = new DMLFunctions();		$result = $dbConnection->executeQuery($query);		$objArr = $this->_buildObjArr($result);		return $objArr;	}	/**	 * Count timesheets in bulk	 *	 * Introduced for printing timesheets	 *	 * @param String[] employeeIds Array of employee ids	 */	public function countTimesheetsBulk($employeeIds) {		$sql_builder = new SQLQBuilder();		$selectTable = self::TIMESHEET_DB_TABLE_TIMESHEET." a ";		$selectFields[0] = "COUNT(a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_ID."`)";        $selectConditions = null;		if ($employeeIds != null) {        	$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_EMPLOYEE_ID."` IN('".implode("', '", $employeeIds)."')";		} else {			return 0; // If no empoyee is there, no need to continue in querying.		}		if ($this->getTimesheetPeriodId() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID."` = {$this->getTimesheetPeriodId()}";		}		if ($this->getStartDate() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_START_DATE."` >= '{$this->getStartDate()}'";		}		if ($this->getEndDate() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_END_DATE."` <= '{$this->getEndDate()}'";		}		if ($this->getStatuses() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."` IN('".implode("', '", $this->getStatuses())."')";		}		$query = $sql_builder->simpleSelect($selectTable, $selectFields, $selectConditions);		$dbConnection = new DMLFunctions();		$result = $dbConnection->executeQuery($query);		if ($row = mysql_fetch_row($result)) {			return $row[0];		}		return 0;	}	/**	 * Fetch timesheets	 *	 * If any atributes are set records will searched against them	 *	 * @return Timesheet[] array of timesheets	 */	public function fetchTimesheets($current=false) {		$sql_builder = new SQLQBuilder();		if ($current) {			$this->_getNewDates();		}		$selectTable = self::TIMESHEET_DB_TABLE_TIMESHEET." a ";		$selectFields[0] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_ID."`";		$selectFields[1] = "a.`".self::TIMESHEET_DB_FIELD_EMPLOYEE_ID."`";		$selectFields[2] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID."`";		$selectFields[3] = "a.`".self::TIMESHEET_DB_FIELD_START_DATE."`";		$selectFields[4] = "a.`".self::TIMESHEET_DB_FIELD_END_DATE."`";		$selectFields[5] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."`";		$selectFields[6] = "a.`".self::TIMESHEET_DB_FIELD_COMMENT."`";        $selectConditions = null;		if ($this->getTimesheetId() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_ID."` = {$this->getTimesheetId()}";		}		if ($this->getEmployeeId() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_EMPLOYEE_ID."` = {$this->getEmployeeId()}";		}		if ($this->getTimesheetPeriodId() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID."` = {$this->getTimesheetPeriodId()}";		}		if ($this->getStartDate() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_START_DATE."` = '{$this->getStartDate()}'";		}		if ($this->getEndDate() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_END_DATE."` = '{$this->getEndDate()}'";		}		if ($this->getStatuses() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."` IN('".implode("', '", $this->getStatuses())."')";		} else if ($this->getStatus() != null) {			$selectConditions[] = "a.`".self::TIMESHEET_DB_FIELD_STATUS."` = '{$this->getStatus()}'";		}		$query = $sql_builder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectFields[0], 'ASC');		$dbConnection = new DMLFunctions();		$result = $dbConnection->executeQuery($query);		$objArr = $this->_buildObjArr($result);		return $objArr;	}	/**	 * Build the object with fetched records	 *	 * @access private	 * @return Timesheet[] array of timesheets	 */	private function _buildObjArr($result) {		$objArr = null;		while ($row = mysql_fetch_assoc($result)) {			$tmpTimeArr = new Timesheet();			$tmpTimeArr->setTimesheetId($row[self::TIMESHEET_DB_FIELD_TIMESHEET_ID]);			$tmpTimeArr->setEmployeeId($row[self::TIMESHEET_DB_FIELD_EMPLOYEE_ID]);			$tmpTimeArr->setTimesheetPeriodId($row[self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID]);			$tmpTimeArr->setStartDate(date('Y-m-d', strtotime($row[self::TIMESHEET_DB_FIELD_START_DATE])));			$tmpTimeArr->setEndDate(date('Y-m-d', strtotime($row[self::TIMESHEET_DB_FIELD_END_DATE])));			$tmpTimeArr->setStatus($row[self::TIMESHEET_DB_FIELD_STATUS]);			$tmpTimeArr->setComment($row[self::TIMESHEET_DB_FIELD_COMMENT]);			$objArr[] = $tmpTimeArr;		}		return $objArr;	}}?>

⌨️ 快捷键说明

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