añadidas las conexiones a las vistas

This commit is contained in:
2025-03-26 14:50:45 +01:00
parent f2aa8f6287
commit 77093e7311
2 changed files with 34 additions and 1 deletions

View File

@ -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)

View File

@ -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;
}
}
}