/** * Retrieve the previous pay period and go back to the payroll page. */ function prevAction() { // Set the page title. $this->view->title = "Payroll Management"; // Get the requested date. $day = $this->getDate('day'); // Retrieve the current pay period and save it to the view. $payPeriodDao = new PayPeriodDao(); $payPeriod = $payPeriodDao->getContaining($day); // Get the previous pay period. $prev = PayPeriodHelper::getPrev($payPeriod); // Attempt to retrieve the previous pay period from the database. $realprev = $payPeriodDao->get($prev->start); // Make sure it was found. if (!isset($realprev)) { // Create the new pay period. $payPeriodDao->add(array('start' => $prev->start, 'end' => $prev->end, 'type' => $prev->type)); $realprev = $prev; } // Get the previous pay period. $this->view->payPeriod = $realprev; // Save the active pay period in the session. $session = new Zend_Session_Namespace('Web'); $session->activePayPeriod = $this->view->payPeriod; // Set the manage layout for this action. $this->_helper->layout->setLayout('manage'); // Include the payroll management scripts on the page. $this->view->scripts = "payroll"; // Use the index view. $this->render('index'); }
/** * Retrieve the previous pay period and show the employee timesheets. */ function prevAction() { // 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(); $payPeriod = $payPeriodDao->getContaining($day); // Get the previous pay period. $prev = PayPeriodHelper::getPrev($payPeriod); // Attempt to retrieve the previous pay period from the database. $realprev = $payPeriodDao->get($prev->start); // Make sure it was found. if (!isset($realprev)) { // Create the new pay period. $payPeriodDao->add(array('start' => $prev->start, 'end' => $prev->end, 'type' => $prev->type)); $realprev = $prev; } // Get the previous pay period. $this->view->payPeriod = $realprev; // 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 previous timesheet and show it on the timesheet page. */ function prevAction() { // 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 previous pay period. $prev = PayPeriodHelper::getPrev($payPeriod); // Attempt to retrieve the previous pay period from the database. $realprev = $payPeriodDao->get($prev->start); // Make sure it was found. if (!isset($realprev)) { // Create the new pay period. $payPeriodDao->add(array('start' => $prev->start, 'end' => $prev->end, 'type' => $prev->type)); $realprev = $prev; } // 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, $realprev); // Set the timesheet layout for this action. $this->_helper->layout->setLayout('timesheet'); // Render the timesheet using the index view. $this->render('index'); }