/** * Retrieve the next pay period and go back to the payroll page. */ function nextAction() { // 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 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 next pay period. $this->view->payPeriod = $realnext; // 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 next pay period and show the employee timesheets. */ function nextAction() { // Set the page title. $this->view->title = "Employee 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'); // Flag that the timesheets should be editable. $this->view->editable = $this->getBool('edit'); if (!isset($this->view->editable)) { $this->view->editable = false; } // Retrieve the current pay period and save it to the view. $payPeriodDao = new PayPeriodDao(); $payPeriod = $payPeriodDao->getContaining($day); // Make sure the pay period was found. if (!isset($payPeriod)) { // Save an error message. $this->view->error = "Failed to find a system pay period " . "containing {$day}, so displaying the current pay period.\n"; // Retrieve the current pay period. $payPeriod = $payPeriodDao->getCurrent(); } // 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 next pay period. $this->view->payPeriod = $realnext; // 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'); }
/** * Populate the pay periods up through the current pay period. * * @return Returns the current timesheet after it is created. */ public function addThroughCurrent() { // Get the latest pay period. $latest = $this->getLatest(); // Get the milliseconds for right now. $now = strtotime(date('Y-m-d')); // Make sure the latest pay period was found. while (isset($latest) && !PayPeriodHelper::isCurrent($latest)) { // Get the next pay period. $latest = PayPeriodHelper::getNext($latest); // Add this pay period to the database. $this->add(array('start' => $latest->start, 'end' => $latest->end, 'type' => $latest->type)); } // Return the latest pay period, which is the current pay period. return $latest; }
/** * 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'); }