/** * Deactivate a contract. */ public function deactivateAction() { // Get the ids of the contracts to deactivate. $ids = $this->getInts('ids'); // Determine if there are multiple contracts to deactivate. $multiple = count($ids) > 1 ? true : false; // Wrap the whole thing in a try/catch. try { // Get the DAO. $contractDao = new ContractDao(); // Deactivate all the contracts. $count = $contractDao->deactivate($ids); // Make sure some contracts were deactivated. if (isset($count) && $count > 0) { // Create the JSON object to return. $json = new stdClass(); $json->success = true; if ($multiple) { $json->msg = 'The contracts were deactivated successfully.'; } else { $json->msg = 'The contract was deactivated successfully.'; } } else { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; if ($multiple) { $json->msg = 'Failed to deactivate the contracts.'; } else { $json->msg = 'Failed to deactivate the contract.'; } } } catch (Zend_Exception $ex) { // Create the error JSON object to return. $json = new stdClass(); $json->success = false; $json->msg = $ex->getMessage(); } // Return the JSON. $this->_helper->json($json); }