diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index bf62404a..8654e8e5 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -806,6 +806,7 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi $routes->get('print/label/test', 'LogisticaController::print_test_label'); $routes->get('panel', 'LogisticaController::panel', ['as' => 'LogisticaPanel']); $routes->get('envios', 'LogisticaController::gestionEnvios', ['as' => 'gestionEnvios']); + $routes->get('enviosFerros', 'LogisticaController::gestionEnviosFerros', ['as' => 'gestionEnviosFerros']); $routes->get('datatableEnvios', 'LogisticaController::datatable_envios'); $routes->get('datatableLineasEnvios/(:num)', 'LogisticaController::datatable_enviosEdit/$1'); $routes->get('envio/(:num)', 'LogisticaController::editEnvio/$1'); diff --git a/ci4/app/Controllers/Logistica/LogisticaController.php b/ci4/app/Controllers/Logistica/LogisticaController.php index f293bb3e..2bd6160a 100755 --- a/ci4/app/Controllers/Logistica/LogisticaController.php +++ b/ci4/app/Controllers/Logistica/LogisticaController.php @@ -62,6 +62,22 @@ class LogisticaController extends BaseController 'currentModule' => static::$controllerSlug, 'boxTitle' => lang('Logistica.gestionEnvios'), 'usingServerSideDataTable' => true, + 'tipo_envio' => 'estandar', + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData); + } + + + public function gestionEnviosFerros() + { + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'boxTitle' => lang('Logistica.envioFerros'), + 'usingServerSideDataTable' => true, + 'tipo_envio' => 'ferro_prototipo', ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class @@ -233,9 +249,10 @@ class LogisticaController extends BaseController { $otsFilter = $this->request->getGetPost('otsFilter'); + $tipo_envio = $this->request->getGetPost('tipo_envio') ?? 'estandar'; $model = model('App\Models\Logistica\EnvioModel'); - $q = $model->getDatatableQuery(); + $q = $model->getDatatableQuery($tipo_envio); if (!empty($otsFilter)) { $q->groupStart(); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestodirecciones.php b/ci4/app/Controllers/Presupuestos/Presupuestodirecciones.php index ddbe042a..93f9b848 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestodirecciones.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestodirecciones.php @@ -54,6 +54,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController $proveedor = $reqData['proveedor'] ?? ""; $proveedor_id = $reqData['proveedor_id'] ?? ""; $entregaPieCalle = $reqData['entregaPieCalle'] ?? 0; + $is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0; $data = [ "presupuesto_id" => $presupuesto_id, @@ -73,6 +74,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController "proveedor" => $proveedor, "proveedor_id" => $proveedor_id, "entregaPieCalle" => $entregaPieCalle, + "is_ferro_prototipo" => $is_ferro_prototipo ]; $response = $this->model->insert($data); diff --git a/ci4/app/Database/Migrations/2025-04-26-180000_AddFerroProtoPresupuestoDirecciones.php b/ci4/app/Database/Migrations/2025-04-26-180000_AddFerroProtoPresupuestoDirecciones.php index a80e7131..d5fd4b58 100644 --- a/ci4/app/Database/Migrations/2025-04-26-180000_AddFerroProtoPresupuestoDirecciones.php +++ b/ci4/app/Database/Migrations/2025-04-26-180000_AddFerroProtoPresupuestoDirecciones.php @@ -7,30 +7,24 @@ use CodeIgniter\Database\Migration; use CodeIgniter\Database\RawSql; use CodeIgniter\I18n\Time; -class AddClickColumnOrdenTrabajoTarea extends Migration +class AddFerroProtoPresupuestoDirecciones extends Migration { protected array $COLUMNS = [ - "click_init" => [ - "type" => "INT", + "is_ferro_prototipo" => [ + "type" => "TINYINT", "unsigned" => true, "default" => 0, - "comment" => "Click iniciales de una tarea de impresion" - ], - "click_end" => [ - "type" => "INT", - "unsigned" => true, - "default" => 0, - "comment" => "Click finales de una tarea de impresion" + "comment" => "Indica si es una direccion para el prototipo o ferro", ], ]; public function up() { - $this->forge->addColumn('orden_trabajo_tareas', $this->COLUMNS); + $this->forge->addColumn('presupuesto_direcciones', $this->COLUMNS); } public function down() { - $this->forge->dropColumn('orden_trabajo_tareas', array_keys($this->COLUMNS)); + $this->forge->dropColumn('presupuesto_direcciones', array_keys($this->COLUMNS)); } } diff --git a/ci4/app/Entities/Logistica/EnvioEntity.php b/ci4/app/Entities/Logistica/EnvioEntity.php index e6bef114..6f22b7f7 100644 --- a/ci4/app/Entities/Logistica/EnvioEntity.php +++ b/ci4/app/Entities/Logistica/EnvioEntity.php @@ -31,5 +31,6 @@ class EnvioEntity extends Entity 'created_at' => 'datetime', 'updated_at' => 'datetime', 'cajas' => 'int', + 'tipo_envio' => 'string', ]; } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php index 65917b3e..11538041 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php @@ -25,6 +25,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity "proveedor_id" => null, "margen" => null, "entregaPieCalle" => null, + "is_ferro_prototipo" => null, ]; protected $casts = [ "presupuesto_id" => "int", @@ -38,6 +39,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity "margen" => "float", "proveedor_id" => "int", "entregaPieCalle" => "int", + "is_ferro_prototipo" => "int", ]; } diff --git a/ci4/app/Models/Logistica/EnvioModel.php b/ci4/app/Models/Logistica/EnvioModel.php index f94556c8..2222b0aa 100644 --- a/ci4/app/Models/Logistica/EnvioModel.php +++ b/ci4/app/Models/Logistica/EnvioModel.php @@ -32,13 +32,14 @@ class EnvioModel extends Model 'created_at', 'updated_at', 'cajas', + 'tipo_envio', ]; protected $useTimestamps = true; protected $createdField = 'created_at'; protected $updatedField = 'updated_at'; - public function getDatatableQuery(): BaseBuilder + public function getDatatableQuery($tipo_envio = "estandar"): BaseBuilder { $builder = $this->db ->table($this->table . " t1") @@ -51,6 +52,24 @@ class EnvioModel extends Model $builder->join("lg_paises t3", "t3.id = t1.pais_id", "left"); $builder->join("pedidos t4", "t4.id = t2.pedido_id", "left"); $builder->join('ordenes_trabajo t5', 't5.pedido_id = t4.id'); + $builder->where("t1.tipo_envio", $tipo_envio); + + $builder->groupBy("t1.id"); + return $builder; + } + + public function getDatatableQueryFerroPrototipo(): BaseBuilder + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id, GROUP_CONCAT(DISTINCT t5.id) AS ots, + t1.att, t1.direccion, t1.ciudad, t3.nombre as pais, t1.cp, t1.email, t1.telefono, t1.finalizado" + ); + $builder->join("lg_paises t3", "t3.id = t1.pais_id", "left"); + $builder->join("pedidos t4", "t4.id = t2.pedido_id", "left"); + $builder->join('ordenes_trabajo t5', 't5.pedido_id = t4.id'); + $builder->whereIn("t1.tipo_envio", ["estandar"]); $builder->groupBy("t1.id"); return $builder; diff --git a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php index cc24fb30..15f63294 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php @@ -45,6 +45,7 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel "proveedor_id", "proveedor", "entregaPieCalle", + "is_ferro_prototipo" ]; protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity"; @@ -69,7 +70,8 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t2.nombre AS pais, t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono, t1.peso AS peso, t1.cantidad AS cantidad, t1.precio AS precio, t1.margen AS margen, - t1.proveedor_id AS proveedor_id, t1.proveedor AS proveedor, t1.entregaPieCalle AS entregaPieCalle" + t1.proveedor_id AS proveedor_id, t1.proveedor AS proveedor, t1.entregaPieCalle AS entregaPieCalle, + t1.is_ferro_prototipo AS is_ferro_prototipo" ); $builder->where('t1.presupuesto_id', $presupuesto_id); diff --git a/ci4/app/Services/LogisticaService.php b/ci4/app/Services/LogisticaService.php index fe8929d2..dcbcc527 100644 --- a/ci4/app/Services/LogisticaService.php +++ b/ci4/app/Services/LogisticaService.php @@ -126,7 +126,8 @@ class LogisticaService ->join('presupuestos pr', 'pr.id=presupuesto_direcciones.presupuesto_id') ->join('pedidos_linea pl', 'pl.presupuesto_id = pr.id') ->join('pedidos p', 'pl.pedido_id=p.id') - ->where('p.id', $pedido_id); + ->where('p.id', $pedido_id) + ->where("presupuesto_direcciones.is_ferro_prototipo", 0); if ($searchVal != "") { $dirs = $dirs->groupStart() ->Like("id", $searchVal) @@ -196,6 +197,7 @@ class LogisticaService ->join('pedidos p', 'p.id = pl.pedido_id') ->join('presupuestos pr', 'pr.id = pl.presupuesto_id') ->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id') + ->where('pd.is_ferro_prototipo', 0) ->where('p.id', $pedido_id) ->whereIn('p.estado', ['finalizado', 'produccion']) ->where("TRIM(LOWER(pd.direccion)) = '$direccionNormalizada'", null, false) @@ -276,6 +278,7 @@ class LogisticaService ->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id') ->join('presupuestos', 'pedidos_linea.presupuesto_id = presupuestos.id') ->where('pedidos.id', $pedido_id) + ->where('presupuesto_direcciones.is_ferro_prototipo', 0) ->like('presupuesto_direcciones.direccion', $direccion) ->groupBy('presupuesto_direcciones.id') ->first(); diff --git a/ci4/app/Views/themes/vuexy/form/logistica/viewEnvioEditForm.php b/ci4/app/Views/themes/vuexy/form/logistica/viewEnvioEditForm.php index 23229291..28450c06 100644 --- a/ci4/app/Views/themes/vuexy/form/logistica/viewEnvioEditForm.php +++ b/ci4/app/Views/themes/vuexy/form/logistica/viewEnvioEditForm.php @@ -18,7 +18,6 @@ = view("themes/_commonPartialsBs/_alertBoxes") ?> -
| = lang('Logistica.idEnvio') ?? 'ID Envío' ?> | -= lang('Logistica.numeroOts') ?? 'Nº OTs' ?> | -= lang('Logistica.numeroLineas') ?? 'Nº Líneas' ?> | -= lang('Logistica.att') ?? 'Att' ?> | -= lang('Logistica.direccion') ?? 'Dirección' ?> | -= lang('Logistica.ciudad') ?? 'Ciudad' ?> | -= lang('Logistica.pais') ?? 'País' ?> | -= lang('Logistica.cp') ?? 'CP' ?> | -= lang('Logistica.email') ?? 'Email' ?> | -= lang('Logistica.telefono') ?? 'Teléfono' ?> | -= lang('Logistica.finalizado') ?? 'Finalizado' ?> | -= lang('Logistica.acciones') ?? 'Acciones' ?> | -
|---|