/**
  * View the specified timesheets.
  */
 function viewAction()
 {
     // Set the page title.
     $this->view->title = "Payroll Timesheets";
     // Get the ids of the timesheets to verify.
     $ids = $this->getInts('ids');
     // Get the user's session.
     $session = new Zend_Session_Namespace('Web');
     // Get the current user.
     $me = $session->employee;
     // Get the DAO.
     $timesheetDao = new TimesheetDao();
     // Retrieve all the requested timesheets and save them in the view.
     $this->view->timesheets = $timesheetDao->getGroup($ids);
     // Save the pay period to the view.
     if (isset($this->view->timesheets) && count($this->view->timesheets) > 0) {
         $this->view->payPeriod = $this->view->timesheets[0]->pay_period;
     }
     // Get the AuditLogDao instance used to log timesheet actions.
     $auditLogDao = new AuditLogDao();
     // Add audit log entries for viewing the timesheet.
     foreach ($ids as $id) {
         $auditLogDao->add(array('timesheet_id' => $id, 'log' => "Payroll {$me->full_name} viewing timesheet."));
     }
     // Set the timesheet layout for this action.
     $this->_helper->layout->setLayout('timesheet');
 }
Пример #2
0
 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
         // to do anything.
         if ($timesheet->completed == "1") {
             // Audit log that we reviewed this timesheet.
             $auditLogDao->add(array('timesheet_id' => $timesheet->id, 'log' => "Daily timesheet review: " . "Timesheet has been completed."));
             print "  Timesheet already completed.\n";
             // Continue to the next timesheet.
             continue;
         }
         // Determine whether the timesheet contains
         // non-administrative contracts that haven't expired.
         print "  Checking administrative status of contracts...\n";
         $allAdminContracts = true;
         foreach ($timesheet->contracts as $contract) {
             $allAdminContracts &= $contract->admin == "1" || TimesheetHelper::isExpired($timesheet, $dayTime, $contract->id);
         }
         print "  Contracts are all admin or expired? " . ($allAdminContracts ? "Yes" : "No") . "\n";
         // Check to see if this is a billable employee.
         if (!$allAdminContracts) {
             // This will keep track of the last time an employee
 /**
  * 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);
 }
Пример #4
0
 /**
  * Add the provided array of data as a row in the database.
  *
  * @param arr An array of the values to insert into the database.
  *
  * @return Returns the auto-generated id of the inserted row.
  */
 public function add($arr)
 {
     // Get the database adapter.
     $db = $this->getAdapter();
     // Insert the object into the database.
     $db->insert($this->_name, $arr);
     // Retrieve the last insert id.
     $id = $db->lastInsertId();
     // Get the AuditLogDao instance.
     $auditLogDao = new AuditLogDao();
     // Add an audit log for this timesheet creation.
     $auditLogDao->add(array('timesheet_id' => $id, 'log' => 'Initial empty timesheet creation.'));
     // Return the id of the new timesheet.
     return $id;
 }
 /**
  * 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);
 }