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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user