mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/settings'
# Conflicts: # ci4/app/Config/Routes.php
This commit is contained in:
43
ci4/app/Models/Collection.php
Normal file
43
ci4/app/Models/Collection.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class Collection
|
||||
{
|
||||
/**
|
||||
* Return data to colection map datatable.
|
||||
*
|
||||
* @param array $data
|
||||
* @param int $recordsTotal
|
||||
* @param int $recordsFiltered
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function datatable(array $data, int $recordsTotal, int $recordsFiltered, string $error = null)
|
||||
{
|
||||
$draw = 1;
|
||||
$req = service('request');
|
||||
if (!empty($req->getPostGet('data'))) :
|
||||
$reqData = $req->getPostGet('data');
|
||||
$draw = $reqData['draw'];
|
||||
elseif (!empty($req->getPostGet('draw'))) :
|
||||
$draw = $req->getPostGet('draw');
|
||||
endif;
|
||||
|
||||
$response = [
|
||||
'draw' => $draw,
|
||||
'recordsTotal' => $recordsTotal,
|
||||
'recordsFiltered' => $recordsFiltered,
|
||||
'data' => $data,
|
||||
'token' => csrf_hash(), // in case the CSRF token is regenerated
|
||||
];
|
||||
|
||||
if (!empty($error)) {
|
||||
$response['error'] = $error;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
115
ci4/app/Models/Configuracion/ImposicionModel.php
Normal file
115
ci4/app/Models/Configuracion/ImposicionModel.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class ImposicionModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_imposiciones";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.ancho",
|
||||
3 => "t1.alto",
|
||||
4 => "t1.unidades",
|
||||
5 => "t1.orientacion",
|
||||
6 => "t1.maquina",
|
||||
7 => "t1.etiqueta",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["ancho", "alto", "unidades", "orientacion", "maquina", "etiqueta"];
|
||||
protected $returnType = "App\Entities\Configuracion\Imposicion";
|
||||
|
||||
public static $labelField = "ancho";
|
||||
|
||||
protected $validationRules = [
|
||||
"alto" => [
|
||||
"label" => "Imposiciones.alto",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"ancho" => [
|
||||
"label" => "Imposiciones.ancho",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"etiqueta" => [
|
||||
"label" => "Imposiciones.etiqueta",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"maquina" => [
|
||||
"label" => "Imposiciones.maquina",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"orientacion" => [
|
||||
"label" => "Imposiciones.orientacion",
|
||||
"rules" => "permit_empty|in_list[H,V]",
|
||||
],
|
||||
"unidades" => [
|
||||
"label" => "Imposiciones.unidades",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alto" => [
|
||||
"integer" => "Imposiciones.validation.alto.integer",
|
||||
"required" => "Imposiciones.validation.alto.required",
|
||||
],
|
||||
"ancho" => [
|
||||
"integer" => "Imposiciones.validation.ancho.integer",
|
||||
"required" => "Imposiciones.validation.ancho.required",
|
||||
],
|
||||
"etiqueta" => [
|
||||
"max_length" => "Imposiciones.validation.etiqueta.max_length",
|
||||
],
|
||||
"maquina" => [
|
||||
"max_length" => "Imposiciones.validation.maquina.max_length",
|
||||
],
|
||||
"orientacion" => [
|
||||
"in_list" => "Imposiciones.validation.orientacion.in_list",
|
||||
],
|
||||
"unidades" => [
|
||||
"integer" => "Imposiciones.validation.unidades.integer",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.ancho AS ancho, t1.alto AS alto, t1.unidades AS unidades, t1.orientacion AS orientacion, t1.maquina AS maquina, t1.etiqueta AS etiqueta"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orlike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.unidades", $search)
|
||||
->orLike("t1.orientacion", $search)
|
||||
->orLike("t1.maquina", $search)
|
||||
->orLike("t1.etiqueta", $search)
|
||||
->orlike("t1.id", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.unidades", $search)
|
||||
->orLike("t1.orientacion", $search)
|
||||
->orLike("t1.maquina", $search)
|
||||
->orLike("t1.etiqueta", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
93
ci4/app/Models/Configuracion/PapelGenericoModel.php
Normal file
93
ci4/app/Models/Configuracion/PapelGenericoModel.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class PapelGenericoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_papel_generico";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
//0 => "t1.id",
|
||||
0 => "t1.nombre",
|
||||
1 => "t1.code",
|
||||
2 => "t1.code_ot",
|
||||
3 => "t1.show_in_client",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client","deleted_at","is_deleted"];
|
||||
protected $returnType = "App\Entities\Configuracion\PapelGenerico";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"code" => [
|
||||
"label" => "PapelGenericoes.code",
|
||||
"rules" => "trim|max_length[5]",
|
||||
],
|
||||
"code_ot" => [
|
||||
"label" => "PapelGenericoes.codeOt",
|
||||
"rules" => "trim|max_length[5]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "PapelGenericoes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"code" => [
|
||||
"max_length" => "PapelGenericoes.validation.code.max_length",
|
||||
],
|
||||
"code_ot" => [
|
||||
"max_length" => "PapelGenericoes.validation.code_ot.max_length",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "PapelGenericoes.validation.nombre.max_length",
|
||||
"required" => "PapelGenericoes.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.code_ot AS code_ot, t1.show_in_client AS show_in_client"
|
||||
)
|
||||
->where("is_deleted", 0);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
231
ci4/app/Models/Configuracion/PapelImpresionModel.php
Normal file
231
ci4/app/Models/Configuracion/PapelImpresionModel.php
Normal file
@ -0,0 +1,231 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class PapelImpresionModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_papel_impresion";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
1 => "t1.papel_generico_id",
|
||||
2 => "t1.gramaje",
|
||||
3 => "t2.nombre",
|
||||
|
||||
/*1 => "t1.id",
|
||||
2 => "t1.papel_generico_id",
|
||||
3 => "t1.nombre",
|
||||
4 => "t1.defecto",
|
||||
5 => "t1.referencia",
|
||||
6 => "t1.ancho",
|
||||
7 => "t1.alto",
|
||||
8 => "t1.mano",
|
||||
9 => "t1.espesor",
|
||||
10 => "t1.gramaje",
|
||||
11 => "t1.precio_tonelada",
|
||||
12 => "t1.margen",
|
||||
13 => "t1.peso_por_pliego",
|
||||
14 => "t1.precio_pliego",
|
||||
15 => "t1.bn",
|
||||
16 => "t1.color",
|
||||
17 => "t1.portada",
|
||||
18 => "t1.cubierta",
|
||||
19 => "t1.rotativa",
|
||||
20 => "t2.nombre",*/
|
||||
];
|
||||
|
||||
const SORTABLE2 = [
|
||||
0 => "t1.defecto",
|
||||
1 => "t1.nombre",
|
||||
2 => "t1.gramaje",
|
||||
];
|
||||
|
||||
|
||||
protected $allowedFields = [
|
||||
"papel_generico_id",
|
||||
"nombre",
|
||||
"defecto",
|
||||
"referencia",
|
||||
"ancho",
|
||||
"alto",
|
||||
"mano",
|
||||
"espesor",
|
||||
"gramaje",
|
||||
"precio_tonelada",
|
||||
"margen",
|
||||
"peso_por_pliego",
|
||||
"precio_pliego",
|
||||
"bn",
|
||||
"color",
|
||||
"portada",
|
||||
"cubierta",
|
||||
"rotativa",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_update_id",
|
||||
];
|
||||
protected $returnType = "App\Entities\Configuracion\PapelImpresion";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"alto" => [
|
||||
"label" => "PapelImpresions.alto",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"ancho" => [
|
||||
"label" => "PapelImpresions.ancho",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"espesor" => [
|
||||
"label" => "PapelImpresions.espesor",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"gramaje" => [
|
||||
"label" => "PapelImpresions.gramaje",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"mano" => [
|
||||
"label" => "PapelImpresions.mano",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"margen" => [
|
||||
"label" => "PapelImpresions.margen",
|
||||
"rules" => "required|max_length[31]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "PapelImpresions.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"peso_por_pliego" => [
|
||||
"label" => "PapelImpresions.pesoPorPliego",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_pliego" => [
|
||||
"label" => "PapelImpresions.precioPliego",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_tonelada" => [
|
||||
"label" => "PapelImpresions.precioTonelada",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"referencia" => [
|
||||
"label" => "PapelImpresions.referencia",
|
||||
"rules" => "trim|required|max_length[13]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alto" => [
|
||||
"decimal" => "PapelImpresions.validation.alto.decimal",
|
||||
"required" => "PapelImpresions.validation.alto.required",
|
||||
],
|
||||
"ancho" => [
|
||||
"decimal" => "PapelImpresions.validation.ancho.decimal",
|
||||
"required" => "PapelImpresions.validation.ancho.required",
|
||||
],
|
||||
"espesor" => [
|
||||
"decimal" => "PapelImpresions.validation.espesor.decimal",
|
||||
"required" => "PapelImpresions.validation.espesor.required",
|
||||
],
|
||||
"gramaje" => [
|
||||
"decimal" => "PapelImpresions.validation.gramaje.decimal",
|
||||
"required" => "PapelImpresions.validation.gramaje.required",
|
||||
],
|
||||
"mano" => [
|
||||
"decimal" => "PapelImpresions.validation.mano.decimal",
|
||||
"required" => "PapelImpresions.validation.mano.required",
|
||||
],
|
||||
"margen" => [
|
||||
"max_length" => "PapelImpresions.validation.margen.max_length",
|
||||
"required" => "PapelImpresions.validation.margen.required",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "PapelImpresions.validation.nombre.max_length",
|
||||
"required" => "PapelImpresions.validation.nombre.required",
|
||||
],
|
||||
"peso_por_pliego" => [
|
||||
"decimal" => "PapelImpresions.validation.peso_por_pliego.decimal",
|
||||
"required" => "PapelImpresions.validation.peso_por_pliego.required",
|
||||
],
|
||||
"precio_pliego" => [
|
||||
"decimal" => "PapelImpresions.validation.precio_pliego.decimal",
|
||||
"required" => "PapelImpresions.validation.precio_pliego.required",
|
||||
],
|
||||
"precio_tonelada" => [
|
||||
"decimal" => "PapelImpresions.validation.precio_tonelada.decimal",
|
||||
"required" => "PapelImpresions.validation.precio_tonelada.required",
|
||||
],
|
||||
"referencia" => [
|
||||
"max_length" => "PapelImpresions.validation.referencia.max_length",
|
||||
"required" => "PapelImpresions.validation.referencia.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithPapelGenerico(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS papel_generico_id FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_papel_generico t2 ON t1.papel_generico_id = t2.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . $offset;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "", $generico_id=-1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.defecto AS defecto, t1.referencia AS referencia, t1.ancho AS ancho, t1.alto AS alto, t1.mano AS mano, t1.espesor AS espesor, t1.gramaje AS gramaje, t1.precio_tonelada AS precio_tonelada, t1.margen AS margen, t1.peso_por_pliego AS peso_por_pliego, t1.precio_pliego AS precio_pliego, t1.bn AS bn, t1.color AS color, t1.portada AS portada, t1.cubierta AS cubierta, t1.rotativa AS rotativa, t2.nombre AS papel_generico_id"
|
||||
);
|
||||
|
||||
$builder->join("lg_papel_generico t2", "t1.papel_generico_id = t2.id", "left");
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
if($generico_id>0){
|
||||
$builder->where("t1.papel_generico_id", $generico_id);
|
||||
}
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.gramaje", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.gramaje", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user