/** * Retrieve the JSON for all the employees assigned to a contract as of a * specific day. */ public function contractAction() { // Get the id of the contract for which employees are to be retrieved. $id = $this->getInt('id'); // Get the day for which employee data is to be retrieved. $day = $this->getDate('day'); // Wrap the whole thing in a try/catch. try { // Check to see if the provided contract id is valid. if (isset($id) && is_numeric($id)) { // Used to retrieve the necessary pay period. $payPeriodDao = new PayPeriodDao(); // Used to retrieve the employees. $employeeDao = new EmployeeDao(); // Get the employees for the specified contract. $employees = $employeeDao->getContractEmployees($id, $day); // Create the JSON object to return. $json = new stdClass(); $json->success = true; $json->msg = 'The assigned employees were ' . 'retrieved successfully.'; $json->employees = $employees; } else { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = 'A valid contract id must be specified.'; } } catch (Zend_Exception $ex) { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = $ex->getMessage(); $json->employees = array(); } // Return all the employees as JSON. $this->_helper->json($json); }