コード例 #1
0
 /**
  * Activate a contract.
  */
 public function activateAction()
 {
     // Get the ids of the contracts to activate.
     $ids = $this->getInts('ids');
     // Determine if there are multiple contracts to activate.
     $multiple = count($ids) > 1 ? true : false;
     // Wrap the whole thing in a try/catch.
     try {
         // Get the DAO.
         $contractDao = new ContractDao();
         // Activate all the contracts.
         $count = $contractDao->activate($ids);
         // Make sure some contracts were activated.
         if (isset($count) && $count > 0) {
             // Create the JSON object to return.
             $json = new stdClass();
             $json->success = true;
             if ($multiple) {
                 $json->msg = 'The contracts were activated successfully.';
             } else {
                 $json->msg = 'The contract was activated successfully.';
             }
         } else {
             // Create the error JSON object to return.
             $json = new stdClass();
             $json->success = false;
             if ($multiple) {
                 $json->msg = 'Failed to activate the contracts.';
             } else {
                 $json->msg = 'Failed to activate 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);
 }