public function createTercerosOp(Gyuser_Model_Operations $obj, $chequesList = null) { try { //1. create operation $data = array('type' => 2, 'client_id' => $obj->getClient_id(), 'date' => $obj->getDate(), 'amount' => $obj->getAmount(), 'state_order_id' => 2, 'tasa_porcentual' => $obj->getTasa_porcentual(), 'date_added' => date('Y-m-d H:i:s')); $opId = $this->getDbTable()->insert($data); if (!$opId) { throw Exception("Hubo un error al crear la operaciĆ³n de cheques de terceros."); } //2. insert checks $chequesMapper = new Gyuser_Model_ChequesDataMapper(); $chequesMapper->addChequesTerceros($opId, $chequesList); //3. set client to active $clientMapper = new Gyuser_Model_UserDataMapper(); $clientObj = new Gyuser_Model_User(); $clientObj->setId($obj->getClient_id()); $clientObj->setClient_type(3); //active $clientMapper->UpdateUserType($clientObj); return $opId; //********************************************************************** /* $cheques = new Gyuser_Model_Cheques(); $cheques->setOperation_id($obj->getId()); $cheques->setCheques_list($chequesList); $mapper = new Gyuser_Model_OperationsDataMapper(); $arc_hrs = $mapper->GetAcreditacionHrsByOperationId($obj); $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() ); */ /* $id = (int) $obj->getId(); if (!$id) { unset($data['id']); } else { $id = $this->getDbTable()->update($data, array('id = ?' => $id)); return $id; } * */ } catch (Exception $e) { } }
public function clientinfoAction() { $this->_helper->layout()->disableLayout(); $this->_helper->ViewRenderer->setScriptAction('client-info'); //_event_id, _operator_id,_item_id if (false === ($client_id = $this->_getParam('param1', false))) { throw new Exception('Tampered URI'); } //echo $client_id; $client = new Gyuser_Model_User(); $client->setId($client_id); $mapper = new Gyuser_Model_UserDataMapper(); $this->view->clientInfo = $mapper->ClientDetailsById($client); $model = new Gyuser_Model_CRMTasks(); $this->view->clientId = $client_id; $this->view->clientHistory = $model->getClientHistory($client_id); }
public function generatepdfAction() { try { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); $clientid = $request->clientid; $typeid = (int) $request->typeid; $status = (int) $request->status; $operationid = (int) $request->operationid; $obj = new Gyuser_Model_User(); $obj->setId($clientid); $pdf = new Gyuser_Model_PdfGeneratorDataMapper(); $pdf->CreatePDF($obj, $typeid, $status, $operationid); } catch (Exception $e) { echo $e; } }
public function GetChequeForLiquidacionesForSupplier(Gyuser_Model_Cheques $obj) { $rejClientIds = $this->RejectedChequesClientIdsByDayCount($obj); $allRejClientIds = $this->RejectedChequesClientIds(); $rejClientIdArr = array(); foreach ($allRejClientIds as $row) { $rejClientIdArr[] = $row->client_id; } $suplChequeCount = $caveChequeCount = array(); if ($obj->getCredit_provider_id()) { $suplChequeCount = $this->ChequesCountBySupplierId($obj); } $chequeFCount = 2; $table = $this->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $select->from(array('cqu' => 'cheques'), array('id as cheque_id', 'operation_id', 'date as cheque_date', 'check_n', 'amount', 'local', 'liquidacion_id', 'status as cheque_status')); $select->joinLeft(array('ops' => 'operations'), 'cqu.operation_id = ops.id', array('client_id', 'bank_account_id')); $select->joinLeft(array('bas' => 'bank_accounts'), 'ops.bank_account_id = bas.id', array('bank_name', 'zip_code', 'state')); $select->joinLeft(array('cls' => 'clients'), 'ops.client_id = cls.id', array('first_name', 'last_name')); $select->joinLeft(array('add' => 'addresses'), 'cls.id = add.client_id', array('city', 'country')); $select->joinLeft(array('chqs' => 'cheques_status'), 'cqu.status = chqs.id', array('id as cheque_state_id', 'status_list')); //$select->where('ops.cave_id = ?', $obj->getCave_id()); $select->where('cqu.liquidacion_id IS NULL'); $select->where('cqu.date >= ?', date("Y-m-d")); $select->where('cqu.status = ?', 1); $select->group('cqu.id'); foreach ($caveChequeCount as $row) { if ((int) $row->cheque_count > $chequeFCount) { $select->where('cls.id != ?', $row->client_id); } } foreach ($suplChequeCount as $row) { if ((int) $row->cheque_count > $chequeFCount) { $select->where('cls.id != ?', $row->client_id); } } foreach ($rejClientIds as $row) { $select->where('cls.id != ?', $row->client_id); } $select->where('cqu.local = ?', true); $select->order('cqu.date ASC'); $resultSet = $table->fetchAll($select); $entries = array(); foreach ($resultSet as $row) { $entry = new Gyuser_Model_Cheques(); $entry->setId($row->cheque_id); $entry->setOperation_id($row->operation_id); $entry->setDate(date("d/m/Y", strtotime($row->cheque_date))); $entry->setCheck_n($row->check_n); $entry->setAmount($row->amount); $entry->setStatus($row->cheque_status); $entry->setRej_cheque_client_ids($rejClientIdArr); $entry->setCheck_zip_code($row->zip_code); $clientObj = new Gyuser_Model_User(); $clientObj->setFirst_name($row->first_name); $clientObj->setLast_name($row->last_name); $clientObj->setId($row->client_id); $entry->setClients_obj($clientObj); $cheques_state_obj = new Gyuser_Model_ChequesStatus(); $cheques_state_obj->setId($row->cheque_state_id); $cheques_state_obj->setStatus_list($row->status_list); $entry->setCheques_status_obj($cheques_state_obj); $address_obj = new Gyuser_Model_Address(); $address_obj->setId($row->client_id); $address_obj->setCity($row->city); $address_obj->setCountry($row->country); $entry->setAddress_obj($address_obj); $_bank_accounts_obj = new Gyuser_Model_BankAccounts(); $_bank_accounts_obj->setBank_name($row->bank_name); $_bank_accounts_obj->setState($row->state); $entry->setBank_accounts_obj($_bank_accounts_obj); $entries[] = $entry; } return $entries; }
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; }