Example #1
0
 /**
  * Used to enhance the provided timesheet with data from other tables.
  *
  * @param obj The timesheet object to enhance.
  *
  * @return Returns the enhanced timesheet.
  */
 public function enhanceTimesheet($obj)
 {
     // Set the other timesheet information.
     if (is_numeric($obj->id)) {
         // Set the bills in the timesheet.
         $billDao = new BillDao();
         $obj->bills = $billDao->getForTimesheet($obj->id, $obj->employee_id);
         // Set the employee.
         $employeeDao = new EmployeeDao();
         $obj->employee = $employeeDao->get($obj->employee_id);
         // Set the audit log info.
         $auditLogDao = new AuditLogDao();
         $obj->audit_log = $auditLogDao->getForTimesheet($obj->id);
         // Set the pay period.
         $payPeriodDao = new PayPeriodDao();
         $obj->pay_period = $payPeriodDao->get($obj->pp_start);
         // Set the employee's contracts.
         $contractDao = new ContractDao();
         $obj->contracts = $contractDao->getEmployeeContractsForPayPeriod($obj->employee_id, $obj->pay_period);
         // Set the holidays.
         $holidayDao = new HolidayDao();
         $obj->holidays = $holidayDao->getForPayPeriod($obj->pay_period);
     }
     // Perform post-processing.
     $this->postProcess($obj);
     // Return the enhanced timesheet object.
     return $obj;
 }
 /**
  * Retrieve the JSON for all the holidays.
  */
 public function jsonAction()
 {
     // Wrap the whole thing in a try/catch.
     try {
         // Get all the holidays.
         $holidayDao = new HolidayDao();
         $holidays = $holidayDao->getAll();
         // Create the JSON object to return.
         $json = new stdClass();
         $json->success = true;
         $json->holidays = $holidays;
     } catch (Zend_Exception $ex) {
         // Create the error JSON object to return.
         $json = new stdClass();
         $json->success = false;
         $json->msg = $ex->getMessage();
         $json->holidays = array();
     }
     // Return all the holidays as JSON.
     $this->_helper->json($json);
 }