Пример #1
0
 public function providereditajaxAction()
 {
     try {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $request = $this->getRequest();
         if ($this->getRequest()->isPost()) {
             $mapper = new Gyuser_Model_ProvidersDataMapper();
             $Obj = new Gyuser_Model_Providers();
             if ($request->id) {
                 $Obj->setId($request->id);
             }
             $Obj->setName($request->name);
             $Obj->setEmail($request->email);
             $Obj->setTasa_anual($request->tasa_anual);
             $Obj->setImpuesto_al_cheque($request->impuesto_al_cheque);
             $Obj->setGastos_interior($request->gastos_interior);
             $Obj->setGastos_general($request->gastos_general);
             $Obj->setGastos_denuncia($request->gastos_denuncia);
             $Obj->setGastos_rechazo($request->gastos_rechazo);
             $Obj->setAcreditacion_capital($request->acreditacion_capital);
             $Obj->setAcreditacion_interior($request->acreditacion_interior);
             $Obj->setGastos_cheque_menor_a_1($request->gastos_cheque_menor_a_1);
             $Obj->setGastos_cheque_a_1($request->gastos_cheque_a_1);
             $Obj->setGastos_cheque_menor_a_2($request->gastos_cheque_menor_a_2);
             $Obj->setGastos_cheque_a_2($request->gastos_cheque_a_2);
             $id = $mapper->update($Obj);
             if ($id) {
                 echo $id;
             } else {
                 echo "f";
             }
         }
     } catch (Exception $e) {
         echo $e;
     }
 }
 public function getProvData($liqId)
 {
     $table = $this->getDbTable();
     $select = $table->select();
     $select->setIntegrityCheck(false);
     $select->from($table, array('id', 'provider_id', 'date', 'impuesto_al_cheque', 'tasa_anual', 'acreditacion_capital', 'acreditacion_interior', 'gastos_general', 'gastos_interior', 'gastos_menor_a_monto_1', 'gastos_menor_a_1', 'gastos_menor_a_monto_2', 'gastos_menor_a_2', 'committed'));
     $select->join(array('prov' => 'providers'), 'liquidaciones.provider_id = prov.id', array('name as provider_name', 'email'));
     $select->where('liquidaciones.id = ?', $liqId);
     $row = $table->fetchRow($select);
     if ($row) {
         $prov = new Gyuser_Model_Providers();
         $prov->setId($row->id);
         $prov->setName($row->provider_name);
         $prov->setEmail($row->email);
         $prov->setImpuesto_al_cheque($row->impuesto_al_cheque);
         $prov->setTasa_anual($row->tasa_anual);
         $prov->setAcreditacion_capital($row->acreditacion_capital);
         $prov->setAcreditacion_interior($row->acreditacion_interior);
         $prov->setGastos_general($row->gastos_general);
         $prov->setGastos_interior($row->gastos_interior);
         $prov->setGastos_cheque_menor_a_1($row->gastos_menor_a_monto_1);
         $prov->setGastos_cheque_a_1($row->gastos_menor_a_1);
         $prov->setGastos_cheque_menor_a_2($row->gastos_menor_a_monto_2);
         $prov->setGastos_cheque_a_2($row->gastos_menor_a_2);
     }
     return $prov;
 }
Пример #3
0
 public function getProviders()
 {
     $table = $this->getDbTable();
     $select = $table->select();
     $select->setIntegrityCheck(false);
     $select->from('providers', array('id', 'name', 'email', 'balance', 'tasa_anual', 'impuesto_al_cheque', 'gastos_general', 'gastos_interior', 'gastos_denuncia', 'gastos_rechazo', 'acreditacion_capital', 'acreditacion_interior', 'gastos_menor_a_monto_1', 'gastos_menor_a_1', 'gastos_menor_a_monto_2', 'gastos_menor_a_2'));
     $select->joinLeft(array('cqu' => 'cheques'), 'cqu.provider_id = providers.id and cqu.status = 3 and cqu.rejected_liquidacion_id IS NULL', array('sum(amount) as rej_amount', 'sum(rejected_cost) as rej_cost'));
     //$select->where('cqu.status = ?', 3);
     //$select->where('cqu.rejected_liquidacion_id IS NULL');
     $select->where('providers.status = ?', true);
     $select->group('providers.id');
     $select->order('id ASC');
     $resultset = $table->fetchAll($select);
     $entires = array();
     foreach ($resultset as $row) {
         //$entry = new Gyuser_Model_SupplierOperations();
         $entry = new Gyuser_Model_Providers();
         $entry->setId($row->id);
         $entry->setName($row->name);
         $entry->setEmail($row->email);
         $entry->setBalance($row->balance);
         $entry->setTasa_anual($row->tasa_anual);
         $entry->setImpuesto_al_cheque($row->impuesto_al_cheque);
         $entry->setGastos_general($row->gastos_general);
         $entry->setGastos_interior($row->gastos_interior);
         $entry->setGastos_denuncia($row->gastos_denuncia);
         $entry->setGastos_rechazo($row->gastos_rechazo);
         $entry->setAcreditacion_capital($row->acreditacion_capital);
         $entry->setAcreditacion_interior($row->acreditacion_interior);
         $entry->setGastos_cheque_menor_a_1($row->gastos_menor_a_monto_1);
         $entry->setGastos_cheque_a_1($row->gastos_menor_a_1);
         $entry->setGastos_cheque_menor_a_2($row->gastos_menor_a_monto_2);
         $entry->setGastos_cheque_a_2($row->gastos_menor_a_2);
         $entry->setRej_check_amount(floatval($row->rej_amount) + floatval($row->rej_cost));
         $cMapper = new Gyuser_Model_ChequesDataMapper();
         $cObj = new Gyuser_Model_Cheques();
         $cObj->setStatus(4);
         $cObj->setProvider_id($row->id);
         $cAmount = $cMapper->GetTotalAmountByStats($cObj);
         $entry->setPassed_amount($cAmount);
         $entires[] = $entry;
     }
     return $entires;
 }
Пример #4
0
 public function OpTercerosStateChange($opId, $newStateId, $tasaAnual = null, $chequesListJson = null)
 {
     $success = 0;
     $obj = new Gyuser_Model_Operations();
     $obj->setId($opId);
     $opResult = $this->GetStateByOperationId($obj);
     $currentStateId = (int) $opResult['stateid'];
     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:
                 //cerrada
                 $chequesMapper = new Gyuser_Model_ChequesDataMapper();
                 $informesCompletos = $chequesMapper->checkInformesCompletos($opId);
                 if ($informesCompletos) {
                     $data = array('state_order_id' => $newStateId);
                 }
                 break;
             case 6:
                 //op. en camino
                 $opAmount = 0;
                 $opTodayVal = 0;
                 $adminMapper = new Gyuser_Model_AdminDataMapper();
                 $admin = $adminMapper->getAdminSettings();
                 $prov = new Gyuser_Model_Providers();
                 $prov->setAcreditacion_capital($admin->getTiempo_ac_capital());
                 $prov->setAcreditacion_interior($admin->getTiempo_ac_interior());
                 $prov->setGastos_general($admin->getGastos_general());
                 $prov->setGastos_interior($admin->getGastos_interior());
                 $prov->setImpuesto_al_cheque($admin->getImpuesto_al_cheque());
                 $prov->setTasa_anual($tasaAnual);
                 $chequesMapper = new Gyuser_Model_ChequesDataMapper();
                 $cheque = new Gyuser_Model_Cheques();
                 $cheques = $chequesMapper->GetChequesByOpId($opId);
                 //gets only cheques with status 7 (aprobados)
                 foreach ($cheques as $cheque) {
                     $cDetails = $chequesMapper->saveDetails($cheque->getId(), $prov);
                     $opAmount += $cDetails['amount'];
                     $opTodayVal += $cDetails['terceros_today_value'];
                 }
                 $data = array('amount' => $opAmount, 'amount_today' => $opTodayVal, 'ac_date' => date('Y-m-d'), 'tasa_porcentual' => $tasaAnual, 'state_order_id' => $newStateId);
                 break;
             case 9:
                 //consolidated / cheques en cartera
                 $chequesList = json_decode($chequesListJson);
                 $chequesMapper = new Gyuser_Model_ChequesDataMapper();
                 $chequesTotals = $chequesMapper->consolidateCheques($chequesList);
                 $data = array('amount' => $chequesTotals['amount'], 'amount_today' => $chequesTotals['todayValue'], 'state_order_id' => $newStateId);
                 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;
         }
         if ($data) {
             $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;
 }