mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into feat/sk-31
This commit is contained in:
@ -385,4 +385,21 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getIdName($search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS name"
|
||||
)
|
||||
->where("is_deleted", 0);
|
||||
return empty($search)
|
||||
? $builder->get()->getResultObject()
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->groupEnd()->get()->getResultObject();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,6 +49,18 @@ class TipoPresupuestoModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
public function getLibros($search = ""){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.id as id, t1.encuadernacion as name")
|
||||
->where('t1.codigo LIKE', 'libro%')
|
||||
->where('t1.is_deleted', 0);
|
||||
|
||||
return empty($search) ?
|
||||
$builder->get()->getResultObject() :
|
||||
$builder->groupStart()->
|
||||
like('t1.codigo', $search)->
|
||||
groupEnd()->get()->getResultObject();
|
||||
}
|
||||
}
|
||||
|
||||
128
ci4/app/Models/Presupuestos/ImportadorModel.php
Normal file
128
ci4/app/Models/Presupuestos/ImportadorModel.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class ImportadorModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = 'pedido_libro';
|
||||
protected $primaryKey = 'id';
|
||||
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->whereIn('estado', ['finalizado', 'validado']);
|
||||
$builder->where('deleted_at', NULL);
|
||||
$builder->orderBy('updated_at', 'DESC');
|
||||
|
||||
return empty($search) ?
|
||||
$builder->get()->getResultObject() :
|
||||
$builder->groupStart()->
|
||||
like('titulo', $search)->
|
||||
orLike('id', $search)->
|
||||
groupEnd()->get()->getResultObject();
|
||||
}
|
||||
|
||||
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.papel_formato_ancho as papel_formato_personalizado_ancho,
|
||||
t1.papel_formato_alto as papel_formato_personalizado_alto,
|
||||
t2.ancho as papel_formato_ancho, t2.alto as papel_formato_alto,
|
||||
t1.ferro as ferro,t1.ferro_digital as ferro_digital, t1.marcapaginas as marcapaginas')
|
||||
->join('papel_formato t2', 't1.papel_formato_id = t2.id', 'left')
|
||||
->where('t1.id', $id)
|
||||
->where('t1.deleted_at', NULL);
|
||||
$query = $builder->get();
|
||||
$datosGenerales = $query->getRow();
|
||||
|
||||
$builder = $db->table('pedido_libro_manipulado')
|
||||
->select('nombre')
|
||||
->where('pedido_libro_id', $id);
|
||||
$query = $builder->get();
|
||||
$manipulados = $query->getResultObject();
|
||||
|
||||
$builder = $db->table('pedido_libro_acabado')
|
||||
->select('nombre')
|
||||
->where('pedido_libro_id', $id);
|
||||
$query = $builder->get();
|
||||
$acabados = $query->getResultObject();
|
||||
|
||||
$builder = $db->table('pedido_libro_preimpresion')
|
||||
->select('nombre')
|
||||
->where('pedido_libro_id', $id)
|
||||
->where('nombre', 'Prototipo');
|
||||
$query = $builder->countAllResults();
|
||||
if($query > 0){
|
||||
$datosGenerales->prototipo = 1;
|
||||
}
|
||||
else{
|
||||
$datosGenerales->prototipo = 0;
|
||||
}
|
||||
|
||||
$builder = $db->table('pedido_libro_linea t1')
|
||||
->select('t1.tipo as tipo, t1.hq as hq, t1.paginas as paginas, t1.papel_id as papel_id,
|
||||
t2.nombre as papel_nombre, t2.code as papel_code, t1.gramaje as gramaje, t1.rotativa_pag_color as rotativa_pag_color,
|
||||
t1.rotativa_impresion as rotativa_impresion, t1.solapas_ancho as solapas_ancho')
|
||||
->join('papel_generico t2', 't1.papel_id = t2.id', 'left')
|
||||
->where('pedido_libro_id', $id);
|
||||
$query = $builder->get();
|
||||
$lineas = $query->getResultObject();
|
||||
|
||||
|
||||
return [
|
||||
'datosGenerales' => $datosGenerales,
|
||||
'manipulados' => $manipulados,
|
||||
'acabados' => $acabados,
|
||||
'lineas' => $lineas
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
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')
|
||||
->select('
|
||||
t1.titulo, t1.autor, t1.coleccion, t1.isbn, t1.customer_reference as referencia_cliente,
|
||||
t1.envios_recogecliente as entrega_taller, t1.comentarios as comentarios_cliente, t1.comentarios_safekat, t1.comentarios_pdf')
|
||||
->join('papel_formato t2', 't1.papel_formato_id = t2.id', 'left')
|
||||
->where('t1.id', $id)
|
||||
->where('t1.deleted_at', NULL);
|
||||
$query = $builder->get();
|
||||
$datosGenerales = $query->getRow();
|
||||
return $query->getRow();
|
||||
}
|
||||
|
||||
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,
|
||||
t2.nombre as provincia, t1.ciudad as municipio, t1.cp, t1.telefono')
|
||||
->join(('provincias t2'), 't1.provincia = t2.code', 'left')
|
||||
->where('t1.pedido_libro_id', $id);
|
||||
$query = $builder->get();
|
||||
return $query->getResultObject();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -481,7 +481,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$cuadernillos_libro = $paginas / 4;
|
||||
$cuadernillos_pedido = $cuadernillos_libro * $tirada;
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id);
|
||||
return round($cuadernillos_pedido / ($velocidad * 60.0), 2);
|
||||
$temp = round($cuadernillos_pedido / ($velocidad * 60.0), 2);
|
||||
if ($temp < 0.01)
|
||||
return 0.01;
|
||||
else
|
||||
return $temp;
|
||||
|
||||
}
|
||||
|
||||
private function calcularTiempoCosido($maquina_id, $paginas, $tirada, $cuadernillos_por_pagina = 32)
|
||||
@ -491,6 +496,10 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id); // cuadernillos por minuto
|
||||
$cuadernillos_libro = ceil($paginas / intval($cuadernillos_por_pagina));
|
||||
$cuadernillos_pedido = $cuadernillos_libro * $tirada;
|
||||
return round($cuadernillos_pedido / ($velocidad * 60.0), 2); // tiempo en segundos
|
||||
$temp = round($cuadernillos_pedido / ($velocidad * 60.0), 2);
|
||||
if ($temp < 0.01)
|
||||
return 0.01;
|
||||
else
|
||||
return $temp;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user