/** * Retrieve the timesheet status information. */ function jsonAction() { // Get the pay period start date. $ppstart = $this->getDate('ppStart'); // Attempt to convert the pay period start time into a date. if (!strtotime($ppstart)) { // Throw an exception. throw new Exception("Invalid date: {$ppstart}"); } // Get the requested pay period. $payPeriodDao = new PayPeriodDao(); $payPeriod = $payPeriodDao->getContaining($ppstart); // Make sure a start date was provided. if (isset($ppstart)) { // Get the user's session. $session = new Zend_Session_Namespace('Web'); // Get the current user. $me = $session->employee; // Get an instance of the TimesheetDao. $timesheetDao = new TimesheetDao(); // Retrieve the status information for the specified pay period. $status = $timesheetDao->getStatusForSupervised($payPeriod, $me); // Check to see if the status was retrieved. if (isset($status)) { // Create the JSON object to return. $json = new stdClass(); $json->status = $status; $json->success = true; $json->msg = 'The requested status information was ' . 'retrieved successfully.'; } else { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = 'Failed to retrieve the status information.'; } } else { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = 'You must specify the pay period start date.'; } // Return the JSON. $this->_helper->json($json); }
/** * 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'); }
// Get the mail configuration. $config = Bootstrap::$registry->config->mail; // Create the mail server login info. $mailconfig = array('auth' => 'login', 'port' => $config->port, 'username' => $config->user, 'password' => $config->pass); // Create the transport. $transport = new Zend_Mail_Transport_Smtp($config->host, $mailconfig); // Get yesterday. $day = gmdate('Y-m-d', strtotime(gmdate('Y-m-d') . " -0000") - 24 * 60 * 60); $dayTime = strtotime($day . " -0000"); $dayName = gmdate('D', $dayTime); // Make sure yesterday was not a weekend day. if ($dayName != "Sat" && $dayName != "Sun") { // 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.
/** * 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; }
/** * 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'); }
/** * Initialize the user session information. */ function init() { try { // Make sure the session has been created. if (!isset(self::$cachedSession)) { self::$cachedSession = new Zend_Session_Namespace('Web'); } } catch (Zend_Session_Exception $ex) { // Log the error. Logger::getLogger()->debug("Zend_Session_Exception" . $ex->getMessage()); } // Get the session. $session = self::$cachedSession; // Fix the request. self::fixRequest($this->getRequest()); // Get the request URI. $requestUri = $this->getRequest()->getRequestUri(); // Write a log of this page request. if (isset($session->employee)) { Logger::getLogger()->info("Request [" . $session->employee->login . "]: " . $requestUri); } else { Logger::getLogger()->info("Request [guest]: " . $requestUri); } // Wrap the whole thing in a try/catch. try { // Check to see if the user is trying to access an admin page. if (preg_match("/^\\/admin/i", $requestUri)) { // Make sure the employee is an administrator. if (!isset($session->employee) || !$session->employee->admin) { // Redirect to the home page. $this->_helper->redirector('index', 'index', 'default'); } } else { if (preg_match("/^\\/manager/i", $requestUri)) { // Make sure the employee is a manager. if (!isset($session->employee) || !$session->employee->manager) { // Redirect to the home page. $this->_helper->redirector('index', 'index', 'default'); } else { // Set the manage layout. $this->_helper->layout->setLayout('manage'); } } else { if (preg_match("/^\\/payroll/i", $requestUri)) { // Make sure the employee is in payroll. if (!isset($session->employee) || !$session->employee->payroll) { // Redirect to the home page. $this->_helper->redirector('index', 'index', 'default'); } else { // Set the manage layout. $this->_helper->layout->setLayout('manage'); } } else { if (preg_match("/^\\/supervisor/i", $requestUri)) { // Make sure the employee is a supervisor. if (!isset($session->employee) || !$session->employee->supervisor) { // Redirect to the home page. $this->_helper->redirector('index', 'index', 'default'); } else { // Set the manage layout. $this->_helper->layout->setLayout('manage'); } } else { if (preg_match("/^\\/user/i", $requestUri)) { // Make sure the employee is logged in. if (!isset($session->employee)) { // Redirect to the home page. $this->_helper->redirector('index', 'index', 'default'); } } } } } } // Set the pay period in the session. if (!isset($session->payPeriod)) { // Save the current pay period to the session. $payPeriodDao = new PayPeriodDao(); $session->payPeriod = $payPeriodDao->getCurrent(); // Make sure the pay period was found. if (!isset($session->payPeriod)) { // Make sure all the pay periods exist in the database, // then retrieve the current pay period. $session->payPeriod = $payPeriodDao->addThroughCurrent(); } } } catch (Zend_Exception $ex) { // Log the exception. Logger::getLogger()->debug("Base Controller Error: " . $ex->getMessage()); } // Save the pay period to the view. $this->view->payPeriod = $session->payPeriod; // Save the employee to the view. $this->view->employee = $session->employee; }
/** * 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'); }