mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
131 lines
4.0 KiB
PHP
Executable File
131 lines
4.0 KiB
PHP
Executable File
<?php
|
|
namespace App\Models\Tarifas;
|
|
|
|
class TarifapreimpresionModel extends \App\Models\GoBaseModel
|
|
{
|
|
protected $table = "lg_tarifa_preimpresion";
|
|
|
|
/**
|
|
* Whether primary key uses auto increment.
|
|
*
|
|
* @var bool
|
|
*/
|
|
protected $useAutoIncrement = true;
|
|
|
|
protected $allowedFields = [
|
|
"nombre",
|
|
"precio",
|
|
"precio_min",
|
|
"importe_fijo",
|
|
"margen",
|
|
"mostrar_en_presupuesto",
|
|
"deleted_at",
|
|
"is_deleted",
|
|
"user_created_id",
|
|
"user_updated_id"];
|
|
protected $returnType = "App\Entities\Tarifas\TarifapreimpresionEntity";
|
|
|
|
protected $useTimestamps = true;
|
|
protected $useSoftDeletes = false;
|
|
|
|
protected $createdField = "created_at";
|
|
protected $updatedField = "updated_at";
|
|
protected $deletedField = 'deleted_at';
|
|
|
|
public static $labelField = "nombre";
|
|
|
|
protected $validationRules = [
|
|
"nombre" => [
|
|
"label" => "Tarifapreimpresion.nombre",
|
|
"rules" => "trim|required|max_length[255]",
|
|
],
|
|
"precio" => [
|
|
"label" => "Tarifapreimpresion.precio",
|
|
"rules" => "required|decimal",
|
|
],
|
|
"precio_min" => [
|
|
"label" => "Tarifapreimpresion.precioMin",
|
|
"rules" => "required|decimal",
|
|
],
|
|
"importe_fijo" => [
|
|
"label" => "Tarifapreimpresion.importeFijo",
|
|
"rules" => "required|decimal",
|
|
],
|
|
"margen" => [
|
|
"label" => "Tarifapreimpresion.margen",
|
|
"rules" => "required|decimal",
|
|
],
|
|
];
|
|
|
|
protected $validationMessages = [
|
|
"nombre" => [
|
|
"max_length" => "Tarifapreimpresion.validation.nombre.max_length",
|
|
"required" => "Tarifapreimpresion.validation.nombre.required",
|
|
],
|
|
"precio" => [
|
|
"decimal" => "Tarifapreimpresion.validation.precio.decimal",
|
|
"required" => "Tarifapreimpresion.validation.precio.required",
|
|
],
|
|
"precio_min" => [
|
|
"required" => "Tarifapreimpresion.validation.precio_min.required",
|
|
"decimal" => "Tarifapreimpresion.validation.precio_min.decimal",
|
|
],
|
|
"importe_fijo" => [
|
|
"required" => "Tarifapreimpresion.validation.importe_fijo.required",
|
|
"decimal" => "Tarifapreimpresion.validation.importe_fijo.decimal",
|
|
],
|
|
"margen" => [
|
|
"required" => "Tarifapreimpresion.validation.margen.required",
|
|
"decimal" => "Tarifapreimpresion.validation.margen.decimal",
|
|
],
|
|
];
|
|
|
|
public function getServiciosPreimpresionSelector()
|
|
{
|
|
/*
|
|
Todos los servicios de preimpresion activas que se pueden usar en presupuestos
|
|
*/
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->select(
|
|
"t1.id as value, t1.nombre AS label"
|
|
)
|
|
->where("t1.is_deleted", 0)
|
|
->where("t1.mostrar_en_presupuesto", 1);
|
|
|
|
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
|
}
|
|
|
|
public function getTarifaPresupuestoPreimpresion($tarifa_id){
|
|
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->select(
|
|
"t1.id AS tarifa_preimpresion_id, t1.nombre AS tarifa_preimpresion_nombre, t1.precio AS precio, t1.margen AS margen"
|
|
)
|
|
->where("t1.is_deleted", 0);
|
|
//->where("t1.mostrar_en_presupuesto", 1)
|
|
|
|
$builder->where('t1.id =', $tarifa_id);
|
|
|
|
return $builder->get()->getResultObject();
|
|
}
|
|
|
|
public function getNombreTarifaPreimpresion($id=-1)
|
|
{
|
|
/*
|
|
Todos los servicios de encuadernacion activas que se pueden usar en presupuestos
|
|
*/
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->select(
|
|
"t1.nombre AS nombre"
|
|
)
|
|
->where("t1.id", $id)
|
|
->where("t1.is_deleted", 0);
|
|
|
|
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
|
}
|
|
|
|
}
|