예제 #1
0
 public function interestdeleteajaxAction()
 {
     try {
         $request = $this->getRequest();
         if ($this->getRequest()->isPost()) {
             $mapper = new Gyuser_Model_InterestsDataMapper();
             $Obj = new Gyuser_Model_Interests();
             $Obj->setId($request->id);
             $this->_helper->layout->disableLayout();
             $this->_helper->viewRenderer->setNoRender();
             $result = $mapper->delete($Obj);
             if ($result) {
                 echo $result;
             } else {
                 echo "f";
             }
         }
     } catch (Exception $e) {
         echo $e;
     }
 }
예제 #2
0
 public function OperationStateChange(Gyuser_Model_Operations $obj, $chequesList = null, $chequeId = null)
 {
     $success = 0;
     $opResult = $this->GetStateByOperationId($obj);
     $currentStateId = (int) $opResult['stateid'];
     $newStateId = $obj->getState();
     //fix get op client_id and bank_account_id
     $op = $this->getDetailsByOpId($obj->getId());
     $obj->setClient_id($op->getClient_id());
     $obj->setBank_account_id($op->getBank_account_id());
     if ($currentStateId < $newStateId) {
         switch ($newStateId) {
             case 2:
                 $data = array('state_order_id' => $obj->getState(), 'cave_id' => $obj->getCave_id());
                 break;
             case 3:
             case 4:
                 $data = array('state_order_id' => $obj->getState(), 'report' => $obj->getReport());
                 break;
             case 5:
                 $mapper = new Gyuser_Model_OperationsDataMapper();
                 $arc_hrs = $mapper->GetAcreditacionHrsByOperationId($obj);
                 $chequesMapper = new Gyuser_Model_ChequesDataMapper();
                 $cheques = new Gyuser_Model_Cheques();
                 $cheques->setOperation_id($obj->getId());
                 $cheques->setClient_id($obj->getClient_id());
                 $cheques->setBank_account_id($obj->getBank_account_id());
                 $cheques->setAcreditacion_hrs($arc_hrs);
                 $cheques->setCheques_list($chequesList);
                 $result = $chequesMapper->SaveCheques($cheques);
                 $iMapper = new Gyuser_Model_InterestsDataMapper();
                 $interests = new Gyuser_Model_Interests();
                 $interests = $iMapper->getInterestRate($obj->getInterests_id());
                 $data = array('state_order_id' => $obj->getState(), 'amount' => $obj->getAmount(), 'plan_id' => $obj->getPlan_id(), 'interests_id' => $obj->getInterests_id(), 'tasa_porcentual' => $interests->getRate());
                 break;
             case 8:
             case 9:
                 $chequesMapper = new Gyuser_Model_ChequesDataMapper();
                 $cheques = new Gyuser_Model_Cheques();
                 $cheques->setId($chequeId);
                 $cheques->setOperation_id($obj->getId());
                 $cheques->setClient_id($obj->getClient_id());
                 $cheques->setBank_account_id($obj->getBank_account_id());
                 $cheques->setCheques_list($chequesList);
                 $chequesResult = $chequesMapper->SaveCheques($cheques);
                 $data = array('amount' => $obj->getAmount(), 'plan_id' => $obj->getPlan_id(), 'state_order_id' => $obj->getState());
                 break;
             case 6:
             case 7:
                 $chequesMapper = new Gyuser_Model_ChequesDataMapper();
                 $cheques = new Gyuser_Model_Cheques();
                 $cheques->setOperation_id($obj->getId());
                 $data = array('state_order_id' => $obj->getState());
                 break;
             case 99:
                 $chequesMapper = new Gyuser_Model_ChequesDataMapper();
                 $cheques = new Gyuser_Model_Cheques();
                 $cheques->setOperation_id($obj->getId());
                 $result = $chequesMapper->deleteByOperationId($cheques);
                 $data = array('state_order_id' => $obj->getState());
                 break;
             default:
                 $data = array('state_order_id' => $obj->getState());
                 break;
         }
         $id = (int) $obj->getId();
         $id = $this->getDbTable()->update($data, array('id = ?' => $id));
         $success = 1;
     } elseif ($currentStateId >= $newStateId) {
         //new state is smaller or equal to current state
         $success = 2;
     }
     //2 = the state has already been changed.
     return $success;
 }