public function GetChequeForLiquidaciones(Gyuser_Model_Cheques $obj) { $rejClientIds = $this->RejectedChequesClientIdsByCave($obj); $suplChequeCount = $caveChequeCount = array(); if ($obj->getCave_id()) { $caveChequeCount = $this->ChequesCountByCaveId($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')); $select->joinLeft(array('cls' => 'clients'), 'ops.client_id = cls.id', array('first_name', 'last_name', 'business')); $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 ($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); $clientObj = new Gyuser_Model_User(); $clientObj->setFirst_name($row->first_name); $clientObj->setLast_name($row->last_name); $clientObj->setBusiness($row->business); $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); $_bank_accounts_obj = new Gyuser_Model_BankAccounts(); $_bank_accounts_obj->setBank_name($row->bank_name); $entry->setBank_accounts_obj($_bank_accounts_obj); $entries[] = $entry; } return $entries; }
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; } }
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; }