mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Iniciada implementacion de recuperacion de historicos erp antiguo
This commit is contained in:
@ -8,7 +8,8 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
protected $primaryKey = 'id';
|
||||
protected $DBGroup = 'old_erp';
|
||||
|
||||
public function getClientList(){
|
||||
public function getClientList()
|
||||
{
|
||||
|
||||
$db = \Config\Database::connect($this->DBGroup); // Conectar a olderp
|
||||
$builder = $db->table('customers');
|
||||
@ -19,8 +20,9 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
public function getPresupuestosList($clienteId, $search = ""){
|
||||
|
||||
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');
|
||||
@ -28,17 +30,18 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
$builder->whereIn('estado', ['finalizado', 'validado', 'presupuesto']);
|
||||
$builder->where('deleted_at', NULL);
|
||||
$builder->orderBy('updated_at', 'DESC');
|
||||
|
||||
return empty($search) ?
|
||||
$builder->get()->getResultObject() :
|
||||
|
||||
return empty($search) ?
|
||||
$builder->get()->getResultObject() :
|
||||
$builder->groupStart()->
|
||||
like('titulo', $search)->
|
||||
orLike('id', $search)->
|
||||
orLike('id', $search)->
|
||||
groupEnd()->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getPresupuestoForImport($id){
|
||||
|
||||
public function getPresupuestoForImport($id)
|
||||
{
|
||||
|
||||
$db = \Config\Database::connect($this->DBGroup); // Conectar a olderp
|
||||
$builder = $db->table('pedido_libro t1')
|
||||
->select('t1.paginas, t1.tirada, t1.papel_formato_personalizado, t1.customer_id,
|
||||
@ -50,7 +53,7 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
->where('t1.id', $id)
|
||||
->where('t1.deleted_at', NULL);
|
||||
$query = $builder->get();
|
||||
$datosGenerales = $query->getRow();
|
||||
$datosGenerales = $query->getRow();
|
||||
|
||||
$builder = $db->table('pedido_libro_manipulado')
|
||||
->select('nombre')
|
||||
@ -69,10 +72,9 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
->where('pedido_libro_id', $id)
|
||||
->where('nombre', 'Prototipo');
|
||||
$query = $builder->countAllResults();
|
||||
if($query > 0){
|
||||
if ($query > 0) {
|
||||
$datosGenerales->prototipo = 1;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$datosGenerales->prototipo = 0;
|
||||
}
|
||||
|
||||
@ -85,7 +87,7 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
$query = $builder->get();
|
||||
$lineas = $query->getResultObject();
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'datosGenerales' => $datosGenerales,
|
||||
'manipulados' => $manipulados,
|
||||
@ -95,8 +97,9 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
|
||||
}
|
||||
|
||||
public function getDatosGuardar($id){
|
||||
|
||||
public function getDatosGuardar($id)
|
||||
{
|
||||
|
||||
$db = \Config\Database::connect($this->DBGroup); // Conectar a olderp
|
||||
$db = \Config\Database::connect($this->DBGroup); // Conectar a olderp
|
||||
$builder = $db->table('pedido_libro t1')
|
||||
@ -107,12 +110,13 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
->where('t1.id', $id)
|
||||
->where('t1.deleted_at', NULL);
|
||||
$query = $builder->get();
|
||||
$datosGenerales = $query->getRow();
|
||||
$datosGenerales = $query->getRow();
|
||||
return $query->getRow();
|
||||
}
|
||||
|
||||
public function getDirecciones($id){
|
||||
|
||||
public function getDirecciones($id)
|
||||
{
|
||||
|
||||
$db = \Config\Database::connect($this->DBGroup); // Conectar a olderp
|
||||
$builder = $db->table('pedido_libro_envios t1')
|
||||
->select('t1.ejemplares as unidades, t1.att, t1.email, t1.direccion, t1.pais,
|
||||
@ -123,6 +127,20 @@ class ImportadorModel extends \App\Models\BaseModel
|
||||
return $query->getResultObject();
|
||||
}
|
||||
|
||||
public function getHistoricoPedidosCatalogo(?int $catalogoId = null)
|
||||
{
|
||||
$db = \Config\Database::connect($this->DBGroup);
|
||||
|
||||
$builder = $db->table('pedido_libro t1')
|
||||
->select('t1.id, t1.created_at, t1.titulo, t1.paginas, t1.tirada, t1.total, t1.estado');
|
||||
|
||||
if ($catalogoId !== null) {
|
||||
$builder->where('t1.catalogo_id', $catalogoId);
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user