mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado tarifas envio
This commit is contained in:
@ -207,8 +207,9 @@ class ProveedorModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS value, t1.nombre AS label")
|
||||
->where("tipo_id", $tipoId);
|
||||
"t1.id AS value, t1.nombre AS label, t1.propiedades AS options")
|
||||
->where("tipo_id", $tipoId)
|
||||
->orderBy('t1.nombre', 'asc');
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
public function getResource(string $search = "", $zona_envio_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -126,7 +126,8 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
|
||||
);
|
||||
$builder->join("tarifas_envios_zonas t2", "t1.zona_envio_id = t2.id", "left");
|
||||
$builder->join("lg_proveedores t3", "t1.proveedor_id = t3.id", "left");
|
||||
|
||||
$builder->where("t1.zona_envio_id", $zona_envio_id);
|
||||
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
@ -148,4 +149,50 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
|
||||
->orLike("t3.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
public function checkIntervals($data = [], $precio_id = null, $zona_id = null){
|
||||
|
||||
helper('general');
|
||||
|
||||
if(floatval($data["peso_min"])>= floatval($data["peso_max"])){
|
||||
return lang('TarifasEnviosPrecios.validation.error_precio_range');
|
||||
}
|
||||
|
||||
$rows = $this->db
|
||||
->table($this->table)
|
||||
->select("id, proveedor_id, tipo_envio, peso_min, peso_max")
|
||||
->where("is_deleted", 0)
|
||||
->where("zona_envio_id", $zona_id)
|
||||
->get()->getResultObject();
|
||||
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (!is_null($precio_id)){
|
||||
if($row->id == $precio_id){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if($row->proveedor_id == $data["proveedor_id"] && $row->tipo_envio == $data["tipo_envio"]){
|
||||
if(check_overlap(floatval($data["peso_min"]), floatval($data["peso_max"]),
|
||||
$row->peso_min, $row->peso_max)){
|
||||
return lang('TarifasEnviosPrecios.validation.error_precio_overlap');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public function removeAllPrecioLineas($zona_id = -1, $datetime = null, $delete_flag=1){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $delete_flag])
|
||||
->where('zona_envio_id',$zona_id)
|
||||
->update();
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
|
||||
2 => "t1.importe_fijo",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["tarifa_envio_id", "cp_inicial", "cp_final", "importe_fijo"];
|
||||
protected $allowedFields = ["tarifa_envio_id", "cp_inicial", "cp_final", "importe_fijo", "is_deleted", "deleted_at"];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifaEnvioZonaEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -88,14 +88,15 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
public function getResource(string $search = "", $tarifa_envio_id=-1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.cp_inicial AS cp_inicial, t1.cp_final AS cp_final, t1.importe_fijo AS importe_fijo, t2.id AS tarifa_envio"
|
||||
"t1.id as id, t1.cp_inicial AS cp_inicial, t1.cp_final AS cp_final, t1.importe_fijo AS importe_fijo, t2.id AS tarifa_envio"
|
||||
);
|
||||
$builder->join("lg_tarifas_envios t2", "t1.tarifa_envio_id = t2.id", "left");
|
||||
$builder->where("t1.tarifa_envio_id", $tarifa_envio_id);
|
||||
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
Reference in New Issue
Block a user