/** * Retrieve the audit logs for a timesheet. */ function auditAction() { // Get the id of the timesheet for which audit log information will be // retrieved. $id = $this->getInt('id'); // Wrap the whole thing in a try/catch. try { // Get the DAO. $auditLogDao = new AuditLogDao(); // Make sure the id is valid. if (isset($id) && is_numeric($id)) { // Retrieve all the audit logs. $logs = $auditLogDao->getForTimesheet($id); // Create the JSON object to return. $json = new stdClass(); $json->logs = $logs; $json->success = true; $json->msg = 'The audit log info was retrieved successfully.'; } else { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = 'Invalid timesheet id specified.'; } } catch (Zend_Exception $ex) { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = $ex->getMessage(); } // Return the JSON. $this->_helper->json($json); }
/** * 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; }