mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadidas las conexiones a las vistas
This commit is contained in:
@ -31,7 +31,8 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->sendMail('prueba', 'Esto es una prueba', ['jaimejimenezortega@gmail.com','jaime0jimenez0ortega@gmail.com']);
|
||||
$modelCliente = model('App\Models\Clientes\ClienteModel');
|
||||
var_dump($modelCliente->getPendienteCobro(1284));
|
||||
}
|
||||
|
||||
private function sendMail($subject, $body, $recipient)
|
||||
|
||||
@ -402,4 +402,36 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
->groupEnd()->get()->getResultObject();
|
||||
|
||||
}
|
||||
|
||||
public function getPendienteCobro($cliente_id = -1){
|
||||
|
||||
$pendiente_old = $this->getTotalPendienteOldERP($cliente_id);
|
||||
$db = \Config\Database::connect('default'); // Conectar a olderp
|
||||
$builder = $db->table('vista_importe_pendiente_cliente t1')
|
||||
->select('*')
|
||||
->where('t1.cliente_id', $cliente_id);
|
||||
$query = $builder->get();
|
||||
$valor = $query->getRow();
|
||||
if($valor){
|
||||
return [floatval($valor->total_pendiente) , floatval($pendiente_old)];
|
||||
}else{
|
||||
return [0 , floatval($pendiente_old)];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getTotalPendienteOldERP($customer_id = -1){
|
||||
|
||||
$db = \Config\Database::connect('old_erp'); // Conectar a olderp
|
||||
$builder = $db->table('vista_importe_pendiente_cliente t1')
|
||||
->select('*')
|
||||
->where('t1.customer_id', $customer_id);
|
||||
$query = $builder->get();
|
||||
$valor = $query->getRow();
|
||||
if($valor){
|
||||
return $valor->total_pendiente;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user