mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
97 lines
2.8 KiB
PHP
97 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Presupuestos;
|
|
|
|
class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|
{
|
|
protected $table = "presupuesto_encuadernaciones";
|
|
|
|
/**
|
|
* Whether primary key uses auto increment.
|
|
*
|
|
* @var bool
|
|
*/
|
|
protected $useAutoIncrement = true;
|
|
|
|
const SORTABLE = [
|
|
0 => "t2.nombre",
|
|
1 => "t1.precio_unidad",
|
|
2 => "t1.precio_total"
|
|
];
|
|
|
|
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad"];
|
|
protected $returnType = "App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity";
|
|
|
|
protected $useTimestamps = true;
|
|
protected $useSoftDeletes = false;
|
|
|
|
protected $createdField = "created_at";
|
|
protected $updatedField = "updated_at";
|
|
|
|
public static $labelField = "nombre";
|
|
|
|
protected $validationRules = [
|
|
"precio_total" => [
|
|
"label" => "Presupuestos.precioTotal",
|
|
"rules" => "decimal|required",
|
|
],
|
|
];
|
|
|
|
protected $validationMessages = [
|
|
"precio_total" => [
|
|
"decimal" => "Presupuestos.validation.decimal",
|
|
"requerido" => "Presupuestos.validation.decimal",
|
|
],
|
|
];
|
|
|
|
|
|
|
|
public function initPresupuesto($id_presupuesto,$tipoPresupuesto, $solapas, $tirada, $paginas){
|
|
|
|
$model = model('App\Models\Presupuestos\TipoPresupuestoTarifaEncuadernacionModel');
|
|
$tarifas_ids = $model->get_tarifas($tipo_presupuesto,$solapas);
|
|
|
|
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
|
|
|
foreach($tarifas_ids as $tarifa){
|
|
/* $data = [
|
|
'id' => new RawSql('DEFAULT'),
|
|
'title' => 'My title',
|
|
'name' => 'My Name',
|
|
'date' => '2022-01-01',
|
|
'last_update' => new RawSql('CURRENT_TIMESTAMP()'),
|
|
];
|
|
$modelTarifa->getMejorPrecio($tirada, $paginas)*/
|
|
}
|
|
}
|
|
|
|
public function delete($presupuesto_id){
|
|
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->where('t1.presupuesto_id', $presupuesto_id)
|
|
->delete();
|
|
}
|
|
|
|
/**
|
|
* Get resource data.
|
|
*
|
|
* @param string $search
|
|
*
|
|
* @return \CodeIgniter\Database\BaseBuilder
|
|
*/
|
|
public function getResource($presupuesto_id = -1)
|
|
{
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->select(
|
|
"t1.id AS id, t1.tarifa_encuadernado_id AS tarifa_encuadernado_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
|
|
);
|
|
|
|
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
|
$builder->join("tarifa_encuadernacion t2", "t1.tarifa_encuadernado_id = t2.id", "left");
|
|
|
|
return $builder;
|
|
}
|
|
}
|