mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/ui_fixing' into 'main'
Dev/ui fixing See merge request jjimenez/safekat!29
This commit is contained in:
373
ci4/app/Models/Clientes/ClienteModel.php
Normal file
373
ci4/app/Models/Clientes/ClienteModel.php
Normal file
@ -0,0 +1,373 @@
|
||||
<?php
|
||||
namespace App\Models\Clientes;
|
||||
|
||||
class ClienteModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "clientes";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
1 => "t1.alias",
|
||||
2 => "t1.cif",
|
||||
3 => "t1.email",
|
||||
4 => "t1.comercial_id",
|
||||
5 => "t1.forma_pago_id",
|
||||
6 => "t1.vencimiento",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"alias",
|
||||
"cif",
|
||||
"direccion",
|
||||
"ciudad",
|
||||
"comunidad_autonoma_id",
|
||||
"provincia_id",
|
||||
"cp",
|
||||
"pais_id",
|
||||
"telefono",
|
||||
"email",
|
||||
"comercial_id",
|
||||
"soporte_id",
|
||||
"forma_pago_id",
|
||||
"vencimiento",
|
||||
"fecha_vencimiento",
|
||||
"margen",
|
||||
"margen_pod",
|
||||
"descuento",
|
||||
"limite_credito",
|
||||
"limite_credito_user_id",
|
||||
"limite_credito_change_at",
|
||||
"credito_solunion",
|
||||
"credito_asegurado",
|
||||
"ccc",
|
||||
"ccc_cliente",
|
||||
"num_cuenta",
|
||||
"disponible_fe",
|
||||
"message_tracking",
|
||||
"message_production_start",
|
||||
"tirada_flexible",
|
||||
"descuento_tirada_flexible",
|
||||
"comentarios_tirada_flexible",
|
||||
"saturacion",
|
||||
"tienda_id",
|
||||
"margen_plantilla_id",
|
||||
"comentarios_produccion",
|
||||
"ps_customer_id",
|
||||
"lineasEnvioFactura",
|
||||
"comentarios",
|
||||
"is_deleted",
|
||||
"deleted_at",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
];
|
||||
protected $returnType = "App\Entities\Clientes\ClienteEntity";
|
||||
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"alias" => [
|
||||
"label" => "Clientes.alias",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"ccc" => [
|
||||
"label" => "Clientes.ccc",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"ccc_cliente" => [
|
||||
"label" => "Clientes.cccCliente",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"cif" => [
|
||||
"label" => "Clientes.cif",
|
||||
"rules" => "trim|required|max_length[50]",
|
||||
],
|
||||
"ciudad" => [
|
||||
"label" => "Clientes.ciudad",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"comentarios" => [
|
||||
"label" => "Clientes.comentarios",
|
||||
"rules" => "trim|max_length[16313]",
|
||||
],
|
||||
"comentarios_produccion" => [
|
||||
"label" => "Clientes.comentariosProduccion",
|
||||
"rules" => "trim|max_length[16313]",
|
||||
],
|
||||
"comentarios_tirada_flexible" => [
|
||||
"label" => "Clientes.comentariosTiradaFlexible",
|
||||
"rules" => "trim|required|max_length[16313]",
|
||||
],
|
||||
"cp" => [
|
||||
"label" => "Clientes.cp",
|
||||
"rules" => "trim|max_length[10]",
|
||||
],
|
||||
"credito_solunion" => [
|
||||
"label" => "Clientes.creditoSolunion",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"descuento" => [
|
||||
"label" => "Clientes.descuento",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"descuento_tirada_flexible" => [
|
||||
"label" => "Clientes.descuentoTiradaFlexible",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"direccion" => [
|
||||
"label" => "Clientes.direccion",
|
||||
"rules" => "trim|max_length[300]",
|
||||
],
|
||||
"email" => [
|
||||
"label" => "Clientes.email",
|
||||
"rules" => "trim|max_length[150]|valid_email|permit_empty",
|
||||
],
|
||||
"fecha_vencimiento" => [
|
||||
"label" => "Clientes.fechaVencimiento",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"is_deleted" => [
|
||||
"label" => "Clientes.isDeleted",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"limite_credito" => [
|
||||
"label" => "Clientes.limiteCredito",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"limite_credito_change_at" => [
|
||||
"label" => "Clientes.limiteCreditoChangeAt",
|
||||
"rules" => "required|valid_date",
|
||||
],
|
||||
"limite_credito_user_id" => [
|
||||
"label" => "Clientes.limiteCreditoUserId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"margen" => [
|
||||
"label" => "Clientes.margen",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"margen_plantilla_id" => [
|
||||
"label" => "Clientes.margenPlantillaId",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
"margen_pod" => [
|
||||
"label" => "Clientes.margenPod",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "Clientes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"num_cuenta" => [
|
||||
"label" => "Clientes.numCuenta",
|
||||
"rules" => "trim|max_length[10]",
|
||||
],
|
||||
"ps_customer_id" => [
|
||||
"label" => "Clientes.psCustomerId",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
"saturacion" => [
|
||||
"label" => "Clientes.saturacion",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"telefono" => [
|
||||
"label" => "Clientes.telefono",
|
||||
"rules" => "trim|max_length[60]",
|
||||
],
|
||||
"tienda_id" => [
|
||||
"label" => "Clientes.tiendaId",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"label" => "Clientes.userCreatedId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"label" => "Clientes.userUpdateId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"vencimiento" => [
|
||||
"label" => "Clientes.vencimiento",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alias" => [
|
||||
"max_length" => "Clientes.validation.alias.max_length",
|
||||
"required" => "Clientes.validation.alias.required",
|
||||
],
|
||||
"ccc" => [
|
||||
"max_length" => "Clientes.validation.ccc.max_length",
|
||||
],
|
||||
"ccc_cliente" => [
|
||||
"max_length" => "Clientes.validation.ccc_cliente.max_length",
|
||||
],
|
||||
"cif" => [
|
||||
"max_length" => "Clientes.validation.cif.max_length",
|
||||
"required" => "Clientes.validation.cif.required",
|
||||
],
|
||||
"ciudad" => [
|
||||
"max_length" => "Clientes.validation.ciudad.max_length",
|
||||
],
|
||||
"comentarios" => [
|
||||
"max_length" => "Clientes.validation.comentarios.max_length",
|
||||
],
|
||||
"comentarios_produccion" => [
|
||||
"max_length" => "Clientes.validation.comentarios_produccion.max_length",
|
||||
],
|
||||
"comentarios_tirada_flexible" => [
|
||||
"max_length" => "Clientes.validation.comentarios_tirada_flexible.max_length",
|
||||
"required" => "Clientes.validation.comentarios_tirada_flexible.required",
|
||||
],
|
||||
"cp" => [
|
||||
"max_length" => "Clientes.validation.cp.max_length",
|
||||
],
|
||||
"credito_solunion" => [
|
||||
"max_length" => "Clientes.validation.credito_solunion.max_length",
|
||||
],
|
||||
"descuento" => [
|
||||
"decimal" => "Clientes.validation.descuento.decimal",
|
||||
"required" => "Clientes.validation.descuento.required",
|
||||
],
|
||||
"descuento_tirada_flexible" => [
|
||||
"decimal" => "Clientes.validation.descuento_tirada_flexible.decimal",
|
||||
"required" => "Clientes.validation.descuento_tirada_flexible.required",
|
||||
],
|
||||
"direccion" => [
|
||||
"max_length" => "Clientes.validation.direccion.max_length",
|
||||
],
|
||||
"email" => [
|
||||
"max_length" => "Clientes.validation.email.max_length",
|
||||
"valid_email" => "Clientes.validation.email.valid_email",
|
||||
],
|
||||
"fecha_vencimiento" => [
|
||||
"max_length" => "Clientes.validation.fecha_vencimiento.max_length",
|
||||
],
|
||||
"is_deleted" => [
|
||||
"integer" => "Clientes.validation.is_deleted.integer",
|
||||
"required" => "Clientes.validation.is_deleted.required",
|
||||
],
|
||||
"limite_credito" => [
|
||||
"decimal" => "Clientes.validation.limite_credito.decimal",
|
||||
"required" => "Clientes.validation.limite_credito.required",
|
||||
],
|
||||
"limite_credito_change_at" => [
|
||||
"required" => "Clientes.validation.limite_credito_change_at.required",
|
||||
"valid_date" => "Clientes.validation.limite_credito_change_at.valid_date",
|
||||
],
|
||||
"limite_credito_user_id" => [
|
||||
"integer" => "Clientes.validation.limite_credito_user_id.integer",
|
||||
"required" => "Clientes.validation.limite_credito_user_id.required",
|
||||
],
|
||||
"margen" => [
|
||||
"decimal" => "Clientes.validation.margen.decimal",
|
||||
"required" => "Clientes.validation.margen.required",
|
||||
],
|
||||
"margen_plantilla_id" => [
|
||||
"integer" => "Clientes.validation.margen_plantilla_id.integer",
|
||||
],
|
||||
"margen_pod" => [
|
||||
"decimal" => "Clientes.validation.margen_pod.decimal",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Clientes.validation.nombre.max_length",
|
||||
"required" => "Clientes.validation.nombre.required",
|
||||
],
|
||||
"num_cuenta" => [
|
||||
"max_length" => "Clientes.validation.num_cuenta.max_length",
|
||||
],
|
||||
"ps_customer_id" => [
|
||||
"integer" => "Clientes.validation.ps_customer_id.integer",
|
||||
],
|
||||
"saturacion" => [
|
||||
"decimal" => "Clientes.validation.saturacion.decimal",
|
||||
"required" => "Clientes.validation.saturacion.required",
|
||||
],
|
||||
"telefono" => [
|
||||
"max_length" => "Clientes.validation.telefono.max_length",
|
||||
],
|
||||
"tienda_id" => [
|
||||
"integer" => "Clientes.validation.tienda_id.integer",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"integer" => "Clientes.validation.user_created_id.integer",
|
||||
"required" => "Clientes.validation.user_created_id.required",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"integer" => "Clientes.validation.user_update_id.integer",
|
||||
"required" => "Clientes.validation.user_update_id.required",
|
||||
],
|
||||
"vencimiento" => [
|
||||
"integer" => "Clientes.validation.vencimiento.integer",
|
||||
"required" => "Clientes.validation.vencimiento.required",
|
||||
],
|
||||
];
|
||||
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS comunidad_autonoma_id, t3.nombre AS provincia, t4.nombre AS pais_id, t5.first_name AS comercial, t6.last_name AS soporte, t7.nombre AS forma_pago_id FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_comunidades_autonomas t2 ON t1.comunidad_autonoma_id = t2.id LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id LEFT JOIN auth_user t5 ON t1.comercial_id = t5.id_user LEFT JOIN auth_user t6 ON t1.soporte_id = t6.id_user LEFT JOIN lg_formas_pago t7 ON t1.forma_pago_id = t7.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . intval($limit);
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . intval($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 = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.alias AS alias, t1.cif AS cif, t1.email AS email, t1.vencimiento AS vencimiento, t5.first_name AS comercial, t7.nombre AS forma_pago_id"
|
||||
)
|
||||
->where("is_deleted", 0);;
|
||||
$builder->join("auth_user t5", "t1.comercial_id = t5.id_user", "left");
|
||||
$builder->join("lg_formas_pago t7", "t1.forma_pago_id = t7.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.alias", $search)
|
||||
->orLike("t1.cif", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t1.soporte_id", $search)
|
||||
->orLike("t1.forma_pago_id", $search)
|
||||
->orLike("t1.vencimiento", $search)
|
||||
->orLike("t5.id_user", $search)
|
||||
->orLike("t5.first_name", $search)
|
||||
->orLike("t5.last_name", $search)
|
||||
->orLike("t7.id", $search)
|
||||
->orLike("t7.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
97
ci4/app/Models/Configuracion/ComunidadAutonomaModel.php
Normal file
97
ci4/app/Models/Configuracion/ComunidadAutonomaModel.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class ComunidadAutonomaModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_comunidades_autonomas";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.pais_id",
|
||||
4 => "t1.created_at",
|
||||
5 => "t1.updated_at",
|
||||
6 => "t2.id",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "pais_id"];
|
||||
protected $returnType = "App\Entities\Configuracion\ComunidadAutonomaEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "ComunidadesAutonomas.nombre",
|
||||
"rules" => "trim|required|max_length[100]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "ComunidadesAutonomas.validation.nombre.max_length",
|
||||
"required" => "ComunidadesAutonomas.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithPaises(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.id AS pais FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_paises t2 ON t1.pais_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 = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.id AS pais"
|
||||
);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
97
ci4/app/Models/Configuracion/ComunidadesAutonomasModel.php
Normal file
97
ci4/app/Models/Configuracion/ComunidadesAutonomasModel.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class ComunidadesAutonomasModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_comunidades_autonomas";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.pais_id",
|
||||
4 => "t1.created_at",
|
||||
5 => "t1.updated_at",
|
||||
6 => "t2.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "pais_id"];
|
||||
protected $returnType = "App\Entities\Configuracion\ComunidadesAutonomasEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "ComunidadesAutonomas.nombre",
|
||||
"rules" => "trim|required|max_length[100]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "ComunidadesAutonomas.validation.nombre.max_length",
|
||||
"required" => "ComunidadesAutonomas.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithPaises(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS pais FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_paises t2 ON t1.pais_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 = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.nombre AS pais"
|
||||
);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
68
ci4/app/Models/Configuracion/FormaPagoModel.php
Normal file
68
ci4/app/Models/Configuracion/FormaPagoModel.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class FormaPagoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_formas_pago";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.created_at",
|
||||
4 => "t1.updated_at",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
protected $returnType = "App\Entities\Configuracion\FormaPagoEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "FormasPagoes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "FormasPagoes.validation.nombre.max_length",
|
||||
"required" => "FormasPagoes.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.created_at AS created_at, t1.updated_at AS updated_at");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
33
ci4/app/Models/Configuracion/FormasPagoModel.php
Normal file
33
ci4/app/Models/Configuracion/FormasPagoModel.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class FormasPagoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_formas_pago";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
protected $returnType = "App\Entities\Configuracion\FormasPagoEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "FormasPagoes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "FormasPagoes.validation.nombre.max_length",
|
||||
"required" => "FormasPagoes.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -12,8 +12,20 @@ class PaisModel extends \App\Models\GoBaseModel
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.code",
|
||||
4 => "t1.code3",
|
||||
5 => "t1.moneda",
|
||||
6 => "t1.url_erp",
|
||||
7 => "t1.user_erp",
|
||||
8 => "t1.key_erp",
|
||||
9 => "t1.show_erp",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "code", "code3", "moneda", "url_erp", "user_erp", "key_erp", "show_erp"];
|
||||
protected $returnType = "App\Entities\Configuracion\Pais";
|
||||
protected $returnType = "App\Entities\Configuracion\PaisEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
@ -75,4 +87,42 @@ class PaisModel extends \App\Models\GoBaseModel
|
||||
"max_length" => "Paises.validation.user_erp.max_length",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 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.code3 AS code3, t1.moneda AS moneda, t1.url_erp AS url_erp, t1.user_erp AS user_erp, t1.key_erp AS key_erp, t1.show_erp AS show_erp"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code3", $search)
|
||||
->orLike("t1.moneda", $search)
|
||||
->orLike("t1.url_erp", $search)
|
||||
->orLike("t1.user_erp", $search)
|
||||
->orLike("t1.key_erp", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code3", $search)
|
||||
->orLike("t1.moneda", $search)
|
||||
->orLike("t1.url_erp", $search)
|
||||
->orLike("t1.user_erp", $search)
|
||||
->orLike("t1.key_erp", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
109
ci4/app/Models/Configuracion/ProvinciaModel.php
Normal file
109
ci4/app/Models/Configuracion/ProvinciaModel.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class ProvinciaModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_provincias";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.code",
|
||||
3 => "t1.nombre",
|
||||
4 => "t1.pais_id",
|
||||
5 => "t1.created_at",
|
||||
6 => "t1.updated_at",
|
||||
7 => "t2.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["code", "nombre", "pais_id"];
|
||||
protected $returnType = "App\Entities\Configuracion\ProvinciaEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"code" => [
|
||||
"label" => "Provincias.code",
|
||||
"rules" => "trim|required|max_length[2]|is_unique[lg_provincias.code,id,{id}]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "Provincias.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"code" => [
|
||||
"is_unique" => "Provincias.validation.code.is_unique",
|
||||
"max_length" => "Provincias.validation.code.max_length",
|
||||
"required" => "Provincias.validation.code.required",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Provincias.validation.nombre.max_length",
|
||||
"required" => "Provincias.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithPaises(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS pais FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_paises t2 ON t1.pais_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 = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.code AS code, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.nombre AS pais"
|
||||
);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,8 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"precio_min",
|
||||
"importe_fijo",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
@ -36,16 +38,33 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "Acabadoes.nombre",
|
||||
"label" => "TarifaAcabado.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"precio_min" => [
|
||||
"label" => "TarifaAcabado.precioMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"importe_fijo" => [
|
||||
"label" => "TarifaAcabado.importeFijo",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "Acabadoes.validation.nombre.max_length",
|
||||
"required" => "Acabadoes.validation.nombre.required",
|
||||
"max_length" => "TarifaAcabado.validation.nombre.max_length",
|
||||
"required" => "TarifaAcabado.validation.nombre.required",
|
||||
],
|
||||
"precio_min" => [
|
||||
"required" => "TarifaAcabado.validation.precio_min.required",
|
||||
"decimal" => "TarifaAcabado.validation.precio_min.decimal",
|
||||
],
|
||||
"importe_fijo" => [
|
||||
"required" => "TarifaAcabado.validation.importe_fijo.required",
|
||||
"decimal" => "TarifaAcabado.validation.importe_fijo.decimal",
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
@ -57,7 +76,9 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre");
|
||||
$builder = $this->db->table($this->table . " t1")->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo"
|
||||
);
|
||||
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
@ -68,6 +89,8 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.precio_min", $search)
|
||||
->orLike("t1.importe_fijo", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user