mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
finalizado servicios encuadernado
This commit is contained in:
@ -70,6 +70,8 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
||||
]);
|
||||
}
|
||||
else{
|
||||
@ -77,8 +79,9 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
(object)[
|
||||
'tarifa_id'=> $tarifa['tarifa_encuadernacion_id'],
|
||||
'tarifa_nombre'=> $tarifa['tarifa_encuadernacion_nombre'],
|
||||
'precio_unidad'=> -1,
|
||||
'total'=> -1,
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'total'=> 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -106,13 +109,31 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
public function getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD){
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id);
|
||||
if($proveedor_id != -1)
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id);
|
||||
else
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto);
|
||||
if (count($tarifa_value)>0) {
|
||||
$result_data = $this->calcularTarifa($tarifa_value[0], $paginas, $POD<$tirada?false:true);
|
||||
return [
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'precio_total'=> $result_data[1],
|
||||
];
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_value[0]->tarifa_enc_id,
|
||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
||||
];
|
||||
return $ret_array;
|
||||
}
|
||||
else{
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_encuadernacion_id,
|
||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'total'=> 0,
|
||||
];
|
||||
return $ret_array;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
@ -133,14 +154,71 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
return [$precio_unidad, $total];
|
||||
}
|
||||
|
||||
public function getIdFromTarifa($tarifa_id){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id"
|
||||
);
|
||||
$builder->where('t1.tarifa_encuadernado_id', $tarifa_id);
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function delete_line($presupuesto_id){
|
||||
|
||||
public function deleteAllServicios($presupuesto_id){
|
||||
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->where('t1.presupuesto_id', $presupuesto_id)
|
||||
->delete();
|
||||
->table($this->table . " t1");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
foreach($tarifas_id as $id){
|
||||
$builder->where('tarifa_encuadernado_id !=', $id);
|
||||
}
|
||||
$builder->delete();
|
||||
}
|
||||
|
||||
public function updateTarifas($presupuesto_id, $tarifas){
|
||||
|
||||
foreach($tarifas as $tarifa){
|
||||
|
||||
$proveedor = $tarifa->proveedor_id=='undefined'?'NULL':$tarifa->proveedor_id;
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->select("id");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_encuadernado_id', $tarifa->tarifa_id);
|
||||
$result = $builder->get()->getResultObject();
|
||||
if(count($result)>0){
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)
|
||||
->where('tarifa_encuadernado_id', $tarifa->tarifa_id)
|
||||
->set('proveedor_id', $proveedor, false)
|
||||
->set('precio_unidad', $tarifa->precio_unidad)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->update();
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->set('presupuesto_id', $presupuesto_id)
|
||||
->set('tarifa_encuadernado_id', $tarifa->tarifa_id)
|
||||
->set('proveedor_id', $proveedor, false)
|
||||
->set('precio_unidad', $tarifa->precio_unidad)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->insert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -17,6 +17,8 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel
|
||||
1 => "t1.precio_min",
|
||||
2 => "t1.importe_fijo",
|
||||
3 => "t1.mostrar_en_presupuesto",
|
||||
4 => "t1.tipo_encuadernacion",
|
||||
5 => "t1.servicio_encuadernacion",
|
||||
|
||||
];
|
||||
|
||||
@ -25,6 +27,8 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel
|
||||
"precio_min",
|
||||
"importe_fijo",
|
||||
"mostrar_en_presupuesto",
|
||||
"tipo_encuadernacion",
|
||||
"servicio_encuadernacion",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
@ -82,7 +86,8 @@ class TarifaEncuadernacionModel 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,
|
||||
t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, t1.mostrar_en_presupuesto AS mostrar_en_presupuesto");
|
||||
t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, t1.mostrar_en_presupuesto AS mostrar_en_presupuesto,
|
||||
t1.tipo_encuadernacion AS tipo_encuadernacion, t1.servicio_encuadernacion AS servicio_encuadernacion");
|
||||
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
@ -106,7 +111,23 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel
|
||||
"t1.id as value, t1.nombre AS label"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
->where("t1.servicio_encuadernacion", 1);
|
||||
|
||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getNombreTarifaEncuadernacion($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();
|
||||
}
|
||||
@ -127,7 +148,7 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel
|
||||
->join("tarifa_encuadernacion_dimensiones t4", "t3.dimensiones_id = t4.id", "left")
|
||||
->join("lg_proveedores t5", "t2.proveedor_id = t5.id", "left")
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1)
|
||||
//->where("t1.mostrar_en_presupuesto", 1)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t3.is_deleted", 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user