diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index 5c499b73..5a22bf04 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -388,5 +388,9 @@ class Pedido extends \App\Controllers\BaseResourceController // $xml_service = new PedidoXMLService($this->model); return $this->respond($data); } + + public function pedidoToProduction(int $pedido_id){ + + } } \ No newline at end of file diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php new file mode 100644 index 00000000..68bef7a7 --- /dev/null +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -0,0 +1,114 @@ + null, + "maquina_orden_negro_id" => null, + "maquina_orden_color_id" => null, + "maquina_orden_portada_id" => null, + "maquina_orden_cubierta_id" => null, + "negro_forma_id" => null, + "color_forma_id" => null, + "portada_forma_id" => null, + "cubierta_forma_id" => null, + "tirada" => null, + "negro_pliegos_pedido" => null, + "color_pliegos_pedido" => null, + "portada_pliegos_pedido" => null, + "cubierta_pliegos_pedido" => null, + "negro_clicks_pedido" => null, + "color_clicks_pedido" => null, + "portada_clicks_pedido" => null, + "cubierta_clicks_pedido" => null, + "pliegos1" => null, + "paginas1" => null, + "pliegos2" => null, + "paginas2" => null, + "negro_proveedor_nombre" => null, + "color_proveedor_nombre" => null, + "portada_proveedor_nombre" => null, + "corte_pie" => null, + "lomo" => null, + "tipo_entrada" => null, + "fecha_entrega_real_warning" => null, + "fecha_entrega_warning" => null, + "fecha_entrega_warning_revised" => null, + "ferro_disponible" => null, + "ferro_disponible_thread_id" => null, + "ferro_cp" => null, + "ferro_proveedor" => null, + "ferro_tracking" => null, + "pre_formato" => null, + "pre_lomo" => null, + "pre_solapa" => null, + "pre_isbn" => null, + "pre_codbarras" => null, + "pre_imposicion" => null, + "pre_imprimir" => null, + "pre_faltan_materiales" => null, + "pre_faltan_materiales_note" => null, + "progreso" => null, + "message_production_send" => null, + "finalizado" => null, + "comentarios" => null + ]; + protected $casts = [ + "pedido_id" => 'integer', + "maquina_orden_negro_id" => '?integer', + "maquina_orden_color_id" => '?integer', + "maquina_orden_portada_id" => '?integer', + "maquina_orden_cubierta_id" => '?integer', + "negro_forma_id" => '?integer', + "color_forma_id" => '?integer', + "portada_forma_id" => '?integer', + "cubierta_forma_id" => '?integer', + "tirada" => 'integer', + "negro_pliegos_pedido" => '?integer', + "color_pliegos_pedido" => 'string', + "portada_pliegos_pedido" => 'string', + "cubierta_pliegos_pedido" => 'string', + "negro_clicks_pedido" => '?integer', + "color_clicks_pedido" => '?integer', + "portada_clicks_pedido" => '?integer', + "cubierta_clicks_pedido" => null, + "pliegos1" => '?integer', + "paginas1" => '?integer', + "pliegos2" => '?integer', + "paginas2" => '?integer', + "negro_proveedor_nombre" => null, + "color_proveedor_nombre" => null, + "portada_proveedor_nombre" => null, + "corte_pie" => null, + "lomo" => null, + "tipo_entrada" => 'string', + "fecha_entrega_real_warning" => 'boolean', + "fecha_entrega_warning" => 'boolean', + "fecha_entrega_warning_revised" => 'boolean', + "ferro_disponible" => 'boolean', + "ferro_disponible_thread_id" => '?integer', + "ferro_cp" => '?string', + "ferro_proveedor" => '?string', + "ferro_tracking" => '?string', + "pre_formato" => '?string', + "pre_lomo" => '?string', + "pre_solapa" => '?string', + "pre_isbn" => '?string', + "pre_codbarras" => '?string', + "pre_imposicion" => '?string', + "pre_imprimir" => 'boolean', + "pre_faltan_materiales" => 'boolean', + "pre_faltan_materiales_note" => '?string', + "progreso" => 'float', + "message_production_send" => 'boolean', + "finalizado" => 'boolean', + "comentarios" => 'string' + ]; + + + +} diff --git a/ci4/app/Language/en/Produccion.php b/ci4/app/Language/en/Produccion.php new file mode 100644 index 00000000..5e60b1ef --- /dev/null +++ b/ci4/app/Language/en/Produccion.php @@ -0,0 +1,16 @@ + "Orden de trabajo", + "ots" => "Órdenes de trabajo", + "btn_pedido_produccion_accion" => "Pasar a producción", + "datatable" => [ + "pedido_id"=> "Order ID", + "fecha_encuadernacion"=> "Bookbinding date", + "cliente"=> "Client", + "titulo"=> "Title", + "ubicacion"=> "Location", + "tirada"=> "Runs", + "impresion"=> "Printing", + ] +]; \ No newline at end of file diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php new file mode 100644 index 00000000..6bc5400b --- /dev/null +++ b/ci4/app/Language/es/Produccion.php @@ -0,0 +1,13 @@ + [ + "pedido_id"=> "Pedido ID", + "fecha_encuadernacion"=> "Fecha encuadernación", + "cliente"=> "Cliente", + "titulo"=> "Título", + "ubicacion"=> "Ubicación", + "tirada"=> "Tirada", + "impresion"=> "Impresión", + ] +]; \ No newline at end of file diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php index d6a373f0..2f36263b 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php @@ -2,15 +2,15 @@ namespace App\Models\OrdenTrabajo; +use App\Entities\Presupuestos\OrdenTrabajoEntity; use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Model; - class OrdenTrabajoModel extends Model { - protected $table = 'ots'; + protected $table = 'ordenes_trabajo'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; - protected $returnType = 'array'; + protected $returnType = OrdenTrabajoEntity::class; protected $useSoftDeletes = true; protected $protectFields = true; protected $allowedFields = [ @@ -113,12 +113,12 @@ class OrdenTrabajoModel extends Model ->join("clientes","clientes.id = presupuestos.cliente_id","left") ->join("tipos_presupuestos tp","presupuestos.tipo_impresion_id = tp.id","left") ->join("ubicaciones","ubicaciones.id = pedidos_linea.ubicacion_id","left") - - - ->groupBy("ot.id") - - - ; + ->groupBy("ot.id"); return $q; } + + public function updateMaquinas(OrdenTrabajoEntity $ot) + { + + } } diff --git a/ci4/app/Models/Pedidos/PedidoModel.php b/ci4/app/Models/Pedidos/PedidoModel.php index e67db27d..9c955f40 100644 --- a/ci4/app/Models/Pedidos/PedidoModel.php +++ b/ci4/app/Models/Pedidos/PedidoModel.php @@ -2,6 +2,9 @@ namespace App\Models\Pedidos; +use App\Entities\Presupuestos\OrdenTrabajoEntity; +use App\Models\OrdenTrabajo\OrdenTrabajoModel; + use function PHPSTORM_META\map; class PedidoModel extends \App\Models\BaseModel @@ -90,7 +93,7 @@ class PedidoModel extends \App\Models\BaseModel return $lineasPresupuesto; } - public function getPedidoPresupuestoTipoImpresion(int $presupuesto_id) : array|object|null + public function getPedidoPresupuestoTipoImpresion(int $presupuesto_id): array|object|null { $q = $this->db->table($this->table) ->select( @@ -185,15 +188,51 @@ class PedidoModel extends \App\Models\BaseModel public function getPedidoPresupuestoFicheros($pedido_id) { $query = $this->db->table($this->table) - ->select([ - 'presupuesto_ficheros.nombre as fileName', - 'presupuesto_ficheros.file_path as filePath' - ]) - ->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left') - ->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left') - ->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left') - ->where('pedidos.id', $pedido_id); - $presupuesto_ficheros = $query->get()->getFirstRow(); - return $presupuesto_ficheros; + ->select([ + 'presupuesto_ficheros.nombre as fileName', + 'presupuesto_ficheros.file_path as filePath' + ]) + ->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left') + ->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left') + ->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left') + ->where('pedidos.id', $pedido_id); + $presupuesto_ficheros = $query->get()->getFirstRow(); + return $presupuesto_ficheros; + } + + /** + * Crea una orden de trabajo asociada al pedido + * + * @param integer $pedido_id + * @return void + */ + public function createOrdenTrabajo(int $pedido_id) + { + $otModel = model(OrdenTrabajoModel::class); + $ot = new OrdenTrabajoEntity(["pedido_id" => $pedido_id]); + $existOt = $this->hasOrdenTrabajo($pedido_id); + if ($existOt) { + $ot = $otModel->find($pedido_id); + return $ot; + } + $otModel->updateMaquinas($ot); + } + + /** + * Comprueba si el pedido tiene ya una orden de trabajo asociada + * + * @param integer $pedido_id + * @return boolean + */ + public function hasOrdenTrabajo(int $pedido_id): bool + { + $hasOrdenTrabajo = false; + $q = $this->builder()->select("orden_trabajo.pedido_id") + ->join("ordenes_trabajo", "ordenes_trabajo.pedido_id = pedidos.id", "left") + ->where("ordenes_trabajo.pedido_id", $pedido_id)->countAllResults(); + if ($q > 0) { + $hasOrdenTrabajo = true; + } + return $hasOrdenTrabajo; } } diff --git a/ci4/app/Views/themes/vuexy/components/tables/ot_table.php b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php new file mode 100644 index 00000000..952bfdd8 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php index 641ad9c8..91090086 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php @@ -19,15 +19,24 @@ user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))) : ?> - + - $pedidoEntity->id,"type" => "pedido"]) ?> + $pedidoEntity->id, "type" => "pedido"]) ?> -
- "btn btn-secondary float-start"]) ?> -
+ +
+
+
+ "btn btn-secondary float-start"]) ?> +
+
+ +
+ +
+
diff --git a/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoList.php b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoList.php index 5f09fc0b..f96f068f 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoList.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoList.php @@ -3,9 +3,41 @@ include('themes/_commonPartialsBs/sweetalert') ?> include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/vuexy/main/defaultlayout') ?> -section('content'); ?> + +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + + +section('content'); ?> +
-
-
+ + + + +endSection() ?> + +section('css') ?> + +endSection() ?> + +section("additionalExternalJs") ?> + + + endSection() ?> \ No newline at end of file