$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 // 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.
/** * Retrieve the chosen pay period and show the employee timesheets. */ function chooseAction() { // Set the page title. $this->view->title = "Payroll Timesheets"; // Get the requested date. $day = $this->getDate('day'); // Get the ids of the employees whose timesheets are to be displayed. $ids = $this->getInts('ids'); // Retrieve the current pay period and save it to the view. $payPeriodDao = new PayPeriodDao(); $this->view->payPeriod = $payPeriodDao->getContaining($day); // Save the active pay period in the session. $session = new Zend_Session_Namespace('Web'); $session->activePayPeriod = $this->view->payPeriod; // Get the DAO. $timesheetDao = new TimesheetDao(); // This will hold all the timesheets. $this->view->timesheets = array(); // Retrieve all the timesheets. foreach ($ids as $id) { $this->view->timesheets[] = $timesheetDao->getForEmployee($id, $this->view->payPeriod); } // Set the timesheet layout for this action. $this->_helper->layout->setLayout('timesheet'); // Render the view.phtml page. $this->render('view'); }
/** * Retrieve the next timesheet and show it on the timesheet page. */ function nextAction() { // Set the page title. $this->view->title = "Viewer"; // Get the current pay period start date. $currstart = $this->getStr('currstart'); // Attempt to convert the current start time into a date. if (!strtotime($currstart)) { // Throw an exception. throw new Exception("Invalid pay period start date passed into " . "the timesheet controller: {$currstart}"); } // Get the requested pay period. $payPeriodDao = new PayPeriodDao(); $payPeriod = $payPeriodDao->get($currstart); // Get the next pay period. $next = PayPeriodHelper::getNext($payPeriod); // Attempt to retrieve the next pay period from the database. $realnext = $payPeriodDao->get($next->start); // Make sure it was found. if (!isset($realnext)) { // Create the new pay period. $payPeriodDao->add(array('start' => $next->start, 'end' => $next->end, 'type' => $next->type)); $realnext = $next; } // Get the employee id. $id = $this->view->employee->id; // Get the employee's latest timesheet and save it to the view. $timesheetDao = new TimesheetDao(); $this->view->timesheet = $timesheetDao->getForEmployee($id, $realnext); // Set the timesheet layout for this action. $this->_helper->layout->setLayout('timesheet'); // Render the timesheet using the index view. $this->render('index'); }