/** * Retrieve the JSON for all the contracts assigned to an employee as of a * specific day. */ public function employeeAction() { // Get the id of the employee for which contracts are to be retrieved. $id = $this->getInt('id'); // Get the day for which contract data is to be retrieved. $day = $this->getDate('day'); // Determine whether administrative contracts should be retrieved. $regularOnly = $this->getBool('regularOnly'); // Wrap the whole thing in a try/catch. try { // Check to see if the provided employee id is valid. if (isset($id) && is_numeric($id)) { // Used to retrieve the necessary pay period. $payPeriodDao = new PayPeriodDao(); // Used to retrieve the contracts. $contractDao = new ContractDao(); // Get the contracts for the specified employee. $contracts = $contractDao->getEmployeeContracts($id, $day, $regularOnly); // Create the JSON object to return. $json = new stdClass(); $json->success = true; $json->msg = 'The assigned contracts were ' . 'retrieved successfully.'; $json->contracts = $contracts; } else { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = 'A valid employee 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 contracts as JSON. $this->_helper->json($json); }