/** * Used to retrieve timesheet status information for a supervisor's * employees for a specific pay period. * * @param pp The pay period for which the timesheet status information will * be retrieved. * * @param supervisor The supervisor for which timesheets status will be * retrieved. * * @return Returns the requested timesheet status information. */ public function getStatusForSupervised($pp, $supervisor) { // Make sure the pay period is valid. if (!isset($pp) || !isset($pp->start) || !isset($supervisor) || !isset($supervisor->id)) { return null; } // Get the database adapter. $db = $this->getAdapter(); // Set the fetch mode. $db->setFetchMode(Zend_Db::FETCH_OBJ); // Get the select object. $select = $db->select(); // Get the DAOs we are joining across. $employeeDao = new EmployeeDao(); $supervisorDao = new SupervisorDao(); // Build the query. $select->from(array('e' => $employeeDao->_name), array('division', 'email', 'first_name', 'last_name', 'login', 'personnel_type', 'active'))->join(array('s' => $supervisorDao->_name), 'e.id = s.employee_id')->joinLeft(array('t' => $this->_name), 'e.id = t.employee_id')->where('(t.pp_start = ? OR t.pp_start IS NULL)', $pp->start)->where('s.supervisor_id = ?', $supervisor->id)->order('last_name')->order('first_name'); // Add ordering. $this->setDefaultOrder($select); // Retrieve all the objects. $objs = $db->query($select)->fetchAll(); // Perform post-processing on all the objects. if (isset($objs) && count($objs) > 0) { foreach ($objs as $obj) { // Post-process the timesheet. $this->postProcess($obj); // Post-process the employee. $employeeDao->postProcess($obj); // Add the timesheet summary information. $this->addSummary($obj, $pp); } } // Return the objects. return $objs; }