mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Presupuestos;
|
|
|
|
class ImportadorModel extends \App\Models\BaseModel
|
|
{
|
|
protected $table = 'pedido_libro';
|
|
protected $primaryKey = 'id';
|
|
//protected $allowedFields = ['ticket_number', 'order_id', 'created_at', 'updated_at', 'deleted_at', 'check_in'];
|
|
|
|
// Define the alternative connection group
|
|
protected $DBGroup = 'old_erp';
|
|
|
|
public function getClientList(){
|
|
|
|
$db = \Config\Database::connect($this->DBGroup); // Conectar a olderp
|
|
$builder = $db->table('customers');
|
|
$builder->select('id, name');
|
|
$builder->where('deleted_at', NULL);
|
|
$query = $builder->get();
|
|
return $query->getResultObject();
|
|
}
|
|
|
|
|
|
public function getPresupuestosList($clienteId, $search = ""){
|
|
|
|
$db = \Config\Database::connect($this->DBGroup); // Conectar a olderp
|
|
$builder = $db->table('pedido_libro');
|
|
$builder->select('id as id, CONCAT(id, " - ", titulo) as name');
|
|
$builder->where('customer_id', $clienteId);
|
|
$builder->where('estado', 'finalizado');
|
|
$builder->where('deleted_at', NULL);
|
|
|
|
return empty($search) ?
|
|
$builder->get()->getResultObject() :
|
|
$builder->groupStart()->
|
|
like('titulo', $search)->
|
|
orLike('id', $search)->
|
|
groupEnd()->get()->getResultObject();
|
|
}
|
|
|
|
|
|
|
|
}
|