mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add comment field
This commit is contained in:
@ -22,6 +22,7 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"code",
|
||||
"comment",
|
||||
"precio_min",
|
||||
"importe_fijo",
|
||||
"mostrar_en_presupuesto",
|
||||
|
||||
@ -23,6 +23,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"code",
|
||||
"comment",
|
||||
"mostrar_en_presupuesto",
|
||||
"tipo_encuadernacion",
|
||||
"servicio_encuadernacion",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tarifas;
|
||||
|
||||
class TarifaEnvioModel extends \App\Models\BaseModel
|
||||
@ -17,7 +18,7 @@ class TarifaEnvioModel extends \App\Models\BaseModel
|
||||
1 => "t2.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["pais_id", "nombre","code","deleted_at","is_deleted"];
|
||||
protected $allowedFields = ["pais_id", "nombre", "code", "comment", "deleted_at", "is_deleted"];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifaEnvioEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -82,43 +83,43 @@ class TarifaEnvioModel extends \App\Models\BaseModel
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getTarifaEnvio($paisId, string $cp, $peso, $tipo_envio){
|
||||
public function getTarifaEnvio($paisId, string $cp, $peso, $tipo_envio)
|
||||
{
|
||||
// Si el pais es españa se tienen que tener en cuenta los postales
|
||||
// Se busca primero la tarifa a la que corresponde
|
||||
$builder = $this->db->table($this->table . " t1")
|
||||
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo")
|
||||
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
|
||||
->where("t1.pais_id", $paisId)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t2.is_deleted", 0);
|
||||
|
||||
if($paisId == 1) {// España
|
||||
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo")
|
||||
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
|
||||
->where("t1.pais_id", $paisId)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t2.is_deleted", 0);
|
||||
|
||||
if ($paisId == 1) { // España
|
||||
$builder->where("CAST(t2.cp_inicial AS UNSIGNED)<=", intval($cp))
|
||||
->where("CAST(t2.cp_final AS UNSIGNED) >=", intval($cp));
|
||||
->where("CAST(t2.cp_final AS UNSIGNED) >=", intval($cp));
|
||||
}
|
||||
$tarifas = $builder->get()->getResultObject();
|
||||
|
||||
$resultado = [];
|
||||
|
||||
|
||||
$model = model('App\Models\Tarifas\TarifaEnvioPrecioModel');
|
||||
foreach($tarifas as $tarifa){
|
||||
foreach ($tarifas as $tarifa) {
|
||||
$precio_tarifas = $model->getEnvioPrecio($tarifa->tarifa_envio_id, $peso, $tipo_envio);
|
||||
foreach($precio_tarifas as $precio_tarifa){
|
||||
foreach ($precio_tarifas as $precio_tarifa) {
|
||||
$precio_tarifa->importe_fijo = $tarifa->importe_fijo;
|
||||
array_push($resultado, $precio_tarifa);
|
||||
}
|
||||
}
|
||||
|
||||
return $resultado;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ class TarifaManipuladoModel extends \App\Models\BaseModel
|
||||
"nombre",
|
||||
"precio_min",
|
||||
"code",
|
||||
"comment",
|
||||
"importe_fijo",
|
||||
"mostrar_en_presupuesto",
|
||||
"deleted_at",
|
||||
|
||||
@ -15,6 +15,7 @@ class TarifaextraModel extends \App\Models\BaseModel
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"code",
|
||||
"comment",
|
||||
"precio",
|
||||
"margen",
|
||||
"mostrar_en_presupuesto",
|
||||
|
||||
@ -15,6 +15,7 @@ class TarifapreimpresionModel extends \App\Models\BaseModel
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"code",
|
||||
"comment",
|
||||
"precio",
|
||||
"margen",
|
||||
"mostrar_en_presupuesto",
|
||||
@ -38,6 +39,10 @@ class TarifapreimpresionModel extends \App\Models\BaseModel
|
||||
"label" => "Tarifapreimpresion.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"code" => [
|
||||
"label" => "Tarifapreimpresion.code",
|
||||
"rules" => "trim|required|max_length[5]",
|
||||
],
|
||||
"precio" => [
|
||||
"label" => "Tarifapreimpresion.precio",
|
||||
"rules" => "required|decimal",
|
||||
@ -53,6 +58,10 @@ class TarifapreimpresionModel extends \App\Models\BaseModel
|
||||
"max_length" => "Tarifapreimpresion.validation.nombre.max_length",
|
||||
"required" => "Tarifapreimpresion.validation.nombre.required",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Tarifapreimpresion.validation.code.max_length",
|
||||
"required" => "Tarifapreimpresion.validation.code.required",
|
||||
],
|
||||
"precio" => [
|
||||
"decimal" => "Tarifapreimpresion.validation.precio.decimal",
|
||||
"required" => "Tarifapreimpresion.validation.precio.required",
|
||||
|
||||
Reference in New Issue
Block a user