Exemplo n.º 1
0
 public function userformsteponeajaxAction()
 {
     try {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $request = $this->getRequest();
         if ($this->getRequest()->isPost()) {
             $id = null;
             $mapper = new Gyuser_Model_UserDataMapper();
             $pdlObj = new Gyuser_Model_User();
             if ($request->id) {
                 $pdlObj->setId($request->id);
             }
             $CUIL = $request->CUIL;
             $CUIL = str_replace('-', '', $CUIL);
             $pdlObj->setClient_type($request->client_type);
             $pdlObj->setFirst_name($request->first_name);
             $pdlObj->setLast_name($request->last_name);
             $pdlObj->setDNI($request->DNI);
             $pdlObj->setCUIL($CUIL);
             $pdlObj->setTel_cell($request->tel_cell);
             $pdlObj->setTel_lab($request->tel_lab);
             $pdlObj->setTel_otro($request->tel_otro);
             $pdlObj->setTel_part($request->tel_part);
             //$pdlObj->setTel_cell_code($request->tel_cell_code);
             $pdlObj->setTel_lab_code($request->tel_lab_code);
             $pdlObj->setTel_otro_code($request->tel_otro_code);
             $pdlObj->setTel_part_code($request->tel_part_code);
             $pdlObj->setEmail($request->email);
             $pdlObj->setActivity($request->activity);
             $pdlObj->setBusiness($request->business);
             $pdlObj->setBusiness_CUIT($request->business_CUIT);
             $pdlObj->setMulti_address_json($request->multi_address_json);
             $pdlObj->setMulti_prior_json($request->multi_prior_json);
             list($Day, $Month, $Year) = explode('/', $request->date_added);
             $stampeddate = mktime(12, 0, 0, $Month, $Day, $Year);
             $realDate = date("Y-m-d", $stampeddate);
             $pdlObj->setDate_added($realDate);
             $pdlObj->setOperator($request->operator);
             $pdlObj->setContact_point($request->contact_point);
             $pdlObj->setExtra_info($request->extra_info);
             //NOTE! if the type was changed or it is a new
             //user then set type_change equal to today
             if ($request->client_type != $request->original_type) {
                 $pdlObj->setType_change(date("Y-m-d"));
             }
             $ValidateDNI = $mapper->ValidateDNI($pdlObj);
             $ValidateEmail = $mapper->ValidateEmail($pdlObj);
             $ValidateCUIL = $mapper->ValidateCUIL($pdlObj);
             $ValidateCUIT = $mapper->ValidateCUIT($pdlObj);
             $error = array('DNI' => $ValidateDNI, 'email' => $ValidateEmail, 'CUIL' => $ValidateCUIL, 'business_CUIT' => $ValidateCUIT);
             if ($ValidateDNI === true && $ValidateEmail === true && $ValidateCUIL === true && $ValidateCUIT === true) {
                 $id = $mapper->save($pdlObj);
                 $error['valid'] = true;
                 $error['client_id'] = $id;
             } else {
                 $error['valid'] = false;
             }
             echo json_encode($error);
         }
     } catch (Exception $e) {
         echo $e;
     }
 }
Exemplo n.º 2
0
 public function GetOperationsByProviderId($provider_id)
 {
     $table = $this->getDbTable();
     $select = $table->select();
     $select->setIntegrityCheck(false);
     $select->from(array('opr' => 'operations'), array('id', 'client_id', 'date', 'amount', 'observations', 'report', 'date_added', 'state_order_id', 'cave_id'));
     $select->joinLeft(array('prov' => 'providers'), 'opr.cave_id = prov.id', array('name as cave_name', 'comision_rate'));
     $select->joinLeft(array('cls' => 'clients'), 'opr.client_id = cls.id', array('first_name', 'last_name'));
     $select->where('opr.cave_id = ?', $provider_id);
     $select->where('opr.liquidacion_id IS  NULL');
     //NOTE! gus also wants to show the operations with state "En Lavalle".
     $select->where('opr.state_order_id = 8 OR opr.state_order_id = 9 OR opr.state_order_id = 10 OR opr.state_order_id = 11');
     $select->order('opr.id ASC');
     $resultSet = $table->fetchAll($select);
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Gyuser_Model_Operations();
         $entry->setId($row->id);
         $entry->setClient_id($row->client_id);
         $entry->setDate(date("d/m/Y", strtotime($row->date)));
         $entry->setAmount($row->amount);
         $entry->setState($row->state_order_id);
         $entry->setObservations($row->observations);
         $entry->setReport($row->report);
         $entry->setProv_name($row->cave_name);
         $entry->setProv_commission_rate($row->comision_rate);
         $pMapper = new Gyuser_Model_ProvidersDataMapper();
         $commissionAmt = $pMapper->calculateComisionAmt($row->amount, $row->comision_rate);
         $entry->setProv_commission_amt($commissionAmt);
         $provPayment = $pMapper->calculateProvPayment($row->amount, $commissionAmt);
         $entry->setProv_payment($provPayment);
         /*
                     $provider_obj = new Gyuser_Model_Providers();
                     $provider_obj->setName($row->cave_name);
                     $provider_obj->setComisionRate($row->comision_rate);            
                     $pMapper = new Gyuser_Model_ProvidersDataMapper();
                     $comisionAmt = $pMapper->calculateComisionAmt($row->amount, $row->comision_rate);
                     $provPayment = $pMapper->calculateProvPayment($row->amount, $comisionAmt);
                     $provider_obj->setComisionAmt($comisionAmt);
                     $provider_obj->setProvPayment($provPayment);
                     $entry->setProvider_obj($provider_obj);
         * 
         */
         $clientObj = new Gyuser_Model_User();
         $clientObj->setFirst_name($row->first_name);
         $clientObj->setLast_name($row->last_name);
         $entry->setUser_obj($clientObj);
         $entries[] = $entry;
     }
     return $entries;
 }
Exemplo n.º 3
0
 public function addChequesTerceros($opId, $chequesListJson)
 {
     try {
         //$chequesList = utf8_encode($chequesList);//html_entity_decode($chequesList);
         $chequesList = json_decode($chequesListJson);
         $chequesFlag = false;
         $adminMapper = new Gyuser_Model_AdminDataMapper();
         $adminSettings = $adminMapper->getAdminSettings();
         foreach ($chequesList as $cheque) {
             unset($clientId);
             unset($bankId);
             unset($chequeId);
             //1. add client
             $clientMapper = new Gyuser_Model_UserDataMapper();
             $client = new Gyuser_Model_User();
             $client->setFirst_name($cheque->first_name);
             $client->setLast_name($cheque->last_name);
             $client->setDNI($cheque->DNI);
             $client->setCUIL($cheque->CUIL);
             $clientId = $clientMapper->createTerceroClient($client);
             if (!$clientId) {
                 throw Exception('Error creating cheque tercero client on DB');
             }
             //2. add bank account
             $bankMapper = new Gyuser_Model_BankAccountsDataMapper();
             $bank = new Gyuser_Model_BankAccounts();
             $bank->setUser_id($clientId);
             $bank->setBank_name($cheque->bank_name);
             $bank->setAccount_n($cheque->account_n);
             $bank->setBranch($cheque->branch);
             $bank->setZip_code($cheque->zip_code);
             $bank->setLocation_capital($cheque->location_capital);
             $bank->setOpening_date($cheque->account_date);
             $bankId = $bankMapper->save($bank);
             if (!$bankId) {
                 throw Exception('Error inserting bank account for cheque tercero on DB');
             }
             //3. add cheque
             list($Day, $Month, $Year) = explode('/', $cheque->check_date);
             $stampeddate = mktime(12, 0, 0, $Month, $Day, $Year);
             $date = date("Y-m-d", $stampeddate);
             $amount = floatval($cheque->check_amount);
             if ($cheque->location_capital == '1') {
                 $acreditacionHrs = $adminSettings->getTiempo_ac_capital();
             } else {
                 $acreditacionHrs = $adminSettings->getTiempo_ac_interior();
             }
             $data = array('operation_id' => $opId, 'client_id' => $clientId, 'bank_account_id' => $bankId, 'date' => $date, 'check_n' => $cheque->check_n, 'amount' => $amount, 'acreditacion_hrs' => $acreditacionHrs, 'local' => 1, 'status' => 6);
             $chequeId = $this->getDbTable()->insert($data);
             if (!$chequeId) {
                 throw Exception('Error inserting cheque tercero on DB');
             }
         }
         return $opId;
     } catch (Exception $e) {
     }
 }
Exemplo n.º 4
0
 public function findClient(Gyuser_Model_User $obj)
 {
     /*$table = $this->getDbTable();
       $row = $table->fetchRow(
               $table->select()
                     ->join(array('client_types' => 'CT'),'clients.client_type = CT.id')
                     ->where('id = ?', $obj->getId())
       );*/
     /*
     * TRY THIS
     * $select->from(array('opr' => 'operations'), array('*'));
             $select->joinLeft(array('ocvs' => 'other_caves'), 'opr.cave_id = ocvs.id', array('name as cave_name'));
     */
     $db = Zend_Db_Table::getDefaultAdapter();
     $stmt = $db->query("SELECT C.*, CT.name AS client_type_name FROM clients C JOIN client_types CT on C.client_type = CT.id WHERE C.id =" . $obj->getId());
     $rows = $stmt->fetchAll();
     if ($rows) {
         $row = $rows[0];
         $CUIL = $row['CUIL'];
         if ($CUIL) {
             $CUIL1 = substr($CUIL, 0, 2);
             $CUIL2 = substr($CUIL, 2, 8);
             $CUIL3 = substr($CUIL, 10, 1);
             $CUIL = $CUIL1 . '-' . $CUIL2 . '-' . $CUIL3;
         }
         $tel_cell = $this->LandPhoneFormat($row['tel_cell']);
         $tel_otro = $this->LandPhoneFormat($row['tel_otro']);
         $tel_lab = $this->LandPhoneFormat($row['tel_lab']);
         $tel_part = $this->LandPhoneFormat($row['tel_part']);
         //$tel_cell_code = $this->CellPhoneAreaCodeFormat($row['tel_cell_code'];
         $tel_otro_code = $this->areaCodeOut($row['tel_otro_code, $tel_otro']);
         $tel_lab_code = $this->areaCodeOut($row['tel_lab_code, $tel_lab']);
         $tel_part_code = $this->areaCodeOut($row['tel_part_code, $tel_part']);
         $entry = new Gyuser_Model_User();
         $entry->setId($row['id']);
         $entry->setClient_type($row['client_type']);
         //$entry->setClient_type_name($row['client_type_name']);
         $entry->setFirst_name($row['first_name']);
         $entry->setLast_name($row['last_name']);
         $entry->setDNI($row['DNI']);
         $entry->setCUIL($CUIL);
         $entry->setTel_cell($tel_cell);
         $entry->setTel_lab($tel_lab);
         $entry->setTel_otro($tel_otro);
         $entry->setTel_part($tel_part);
         //$entry->setTel_cell_code($tel_cell_code']);
         $entry->setTel_lab_code($tel_lab_code);
         $entry->setTel_otro_code($tel_otro_code);
         $entry->setTel_part_code($tel_part_code);
         $entry->setEmail($row['email']);
         $entry->setActivity($row['activity']);
         $entry->setDate_added(date("d/m/Y", strtotime($row['date_added'])));
         $entry->setOperator($row['operator']);
         $entry->setContact_point($row['contact_point']);
         $entry->setExtra_info($row['extra_info']);
         $entry->setBusiness($row['business']);
         $entry->setBusiness_CUIT($row['business_CUIT']);
         $entry->setType_change($row['type_change']);
     }
     return $entry;
 }