/** * 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 specified timesheet and show it on the timesheet page. */ function viewAction() { // Set the page title. $this->view->title = "Viewer"; // Get the date within the pay period. $date = $this->getStr('date'); // Attempt to convert the current start time into a date. if (!strtotime($date)) { // Throw an exception. throw new Exception("Invalid date passed into " . "the timesheet controller: {$date}"); } // Get the requested pay period. $payPeriodDao = new PayPeriodDao(); $payPeriod = $payPeriodDao->getContaining($date); // 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 {$date}, so displaying the current pay period.\n"; // Retrieve the current pay period. $payPeriod = $payPeriodDao->getCurrent(); } // 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, $payPeriod); // Make sure a timesheet was found. if (!isset($this->view->timesheet)) { // Throw an exception if we couldn't find the timesheet. throw new Exception("Failed to find a timesheet for the " . "requested pay period."); } // Set the timesheet layout for this action. $this->_helper->layout->setLayout('timesheet'); // Render the timesheet using the index view. $this->render('index'); }
/** * 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'); }
$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. foreach ($employees as $employee) {
/** * 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'); }