/** * 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); }
// Log what we are doing. print "Processing Yesterday ({$dayName}, {$day}).\n"; // Get the pay period containing yesterday. $payPeriodDao = new PayPeriodDao(); $payPeriod = $payPeriodDao->getContaining($day); // Make sure the pay period was found. if (isset($payPeriod)) { // Log what we are doing. print "Found associated pay period.\n"; // Get all the active employees in the system. $employeeDao = new EmployeeDao(); $employees = $employeeDao->getAll(true); // This is used to retrieve timesheets. $timesheetDao = new TimesheetDao(); // This is used to log our timesheet reviews. $auditLogDao = new AuditLogDao(); // Make sure some active employees were found. if (isset($employees) && count($employees) > 0) { // Iterate over the available employees. foreach ($employees as $employee) { // Log what we are doing. print "\nFound employee to check: " . $employee->full_name . "\n"; // Keep track of whether we need to send notification info. $notify = false; // Get the timesheet for this employee. $timesheet = $timesheetDao->getForEmployee($employee->id, $payPeriod); // Make sure the timesheet exists. if (isset($timesheet)) { // Log what we are doing. print " Found timesheet for employee.\n"; // If the timesheet has been completed, then we don't need
/** * Re-open a completed timesheet so that the hours can be modified. */ function fixAction() { // Get the id of the active timesheet. $timesheetId = $this->getInt('id'); // Get the employee's current timesheet. $timesheetDao = new TimesheetDao(); $timesheet = $timesheetDao->get($timesheetId); // Re-open the timesheet. $timesheetDao->save($timesheet->id, array('completed' => false)); // Add an audit log for this completion. $auditLogDao = new AuditLogDao(); $auditLogDao->add(array('timesheet_id' => $timesheet->id, 'log' => "Timesheet re-opened.")); // Create the JSON object to return. $json = new stdClass(); $json->success = true; $json->payPeriod = $timesheet->pp_start; $json->msg = 'Your timesheet was re-opened successfully. Refreshing ' . 'the display...'; // 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; }
/** * Re-open a completed timesheet so that the hours can be modified. */ function fixAction() { // Get the user's session. $session = new Zend_Session_Namespace('Web'); // Get the current user. $me = $session->employee; // Get the id of the active timesheet. $timesheetId = $this->getInt('id'); // Get the employee's current timesheet. $timesheetDao = new TimesheetDao(); $timesheet = $timesheetDao->get($timesheetId); // Re-open the timesheet. $timesheetDao->save($timesheet->id, array('completed' => false)); // Add an audit log for this completion. $auditLogDao = new AuditLogDao(); $auditLogDao->add(array('timesheet_id' => $timesheet->id, 'log' => "Timesheet re-opened by supervisor {$me->full_name}.")); // Create the JSON object to return. $json = new stdClass(); $json->success = true; $json->payPeriod = $timesheet->pp_start; $json->msg = 'Your timesheet was re-opened successfully.'; // Return the JSON. $this->_helper->json($json); }