This commit is contained in:
amazuecos
2024-12-15 16:07:54 +01:00
parent 71157bfda5
commit d5719b70a1
31 changed files with 970 additions and 502 deletions

View File

@ -80,5 +80,6 @@ class Filters extends BaseConfig
/*'jwt' => [
'before' => ['api', 'api/*']
],*/
];
}

View File

@ -9,18 +9,18 @@ const SK_PERMISSION_MATRIX = [
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"perfil.create",
"perfil.edit",
"perfil.delete",
"perfil.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
"presupuesto.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
@ -41,10 +41,6 @@ const SK_PERMISSION_MATRIX = [
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.delete",
"tarifa-extra.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
@ -61,10 +57,6 @@ const SK_PERMISSION_MATRIX = [
"paises.edit",
"paises.delete",
"paises.menu",
"formas-pago.create",
"formas-pago.edit",
"formas-pago.delete",
"formas-pago.menu",
"maquinas.create",
"maquinas.edit",
"maquinas.delete",
@ -89,36 +81,12 @@ const SK_PERMISSION_MATRIX = [
"roles-permisos.edit",
"roles-permisos.delete",
"roles-permisos.menu",
"ubicaciones.create",
"ubicaciones.edit",
"ubicaciones.delete",
"ubicaciones.menu",
"series-facturas.create",
"series-facturas.edit",
"series-facturas.delete",
"series-facturas.menu",
],
"cliente-admin" => [
"perfil.edit",
"perfil.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
],
"cliente-editor" => [
"perfil.create",
"perfil.edit",
"perfil.delete",
"perfil.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
@ -129,8 +97,15 @@ const SK_PERMISSION_MATRIX = [
"token.menu",
],
"produccion" => [
"token.token",
"token.menu",
"clientes.create",
"clientes.edit",
"clientes.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.menu",
],
"maquina" => [
"token.token",
@ -163,18 +138,18 @@ const SK_PERMISSION_MATRIX = [
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"perfil.create",
"perfil.edit",
"perfil.delete",
"perfil.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
"presupuesto.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
@ -195,10 +170,6 @@ const SK_PERMISSION_MATRIX = [
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.delete",
"tarifa-extra.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
@ -239,13 +210,5 @@ const SK_PERMISSION_MATRIX = [
"roles-permisos.edit",
"roles-permisos.delete",
"roles-permisos.menu",
"ubicaciones.create",
"ubicaciones.edit",
"ubicaciones.delete",
"ubicaciones.menu",
"series-facturas.create",
"series-facturas.edit",
"series-facturas.delete",
"series-facturas.menu",
],
];

View File

@ -9,10 +9,6 @@ const SK_PERMISSIONS = [
'plantilla-tarifa.edit' => 'Can edit',
'plantilla-tarifa.delete' => 'Can delete',
'plantilla-tarifa.menu' => 'Menu shall be visualize',
'perfil.create' => 'Can create',
'perfil.edit' => 'Can edit',
'perfil.delete' => 'Can delete',
'perfil.menu' => 'Menu shall be visualize',
'direcciones.create' => 'Can create',
'direcciones.edit' => 'Can edit',
'direcciones.delete' => 'Can delete',
@ -21,10 +17,14 @@ const SK_PERMISSIONS = [
'presupuesto.edit' => 'Can edit',
'presupuesto.delete' => 'Can delete',
'presupuesto.menu' => 'Menu shall be visualize',
'presupuesto-cliente.create' => 'Can create',
'presupuesto-cliente.edit' => 'Can edit',
'presupuesto-cliente.delete' => 'Can delete',
'presupuesto-cliente.menu' => 'Menu shall be visualize',
'pedidos-activos.view' => 'Can view',
'pedidos-activos.menu' => 'Menu shall be visualize',
'pedidos-finalizados.view' => 'Can view',
'pedidos-finalizados.menu' => 'Menu shall be visualize',
'pedidos-cancelados.view' => 'Can view',
'pedidos-cancelados.menu' => 'Menu shall be visualize',
'pedidos-todos.view' => 'Can view',
'pedidos-todos.menu' => 'Menu shall be visualize',
'tarifa-preimpresion.create' => 'Can create',
'tarifa-preimpresion.edit' => 'Can edit',
'tarifa-preimpresion.delete' => 'Can delete',
@ -45,10 +45,6 @@ const SK_PERMISSIONS = [
'tarifa-envio.edit' => 'Can edit',
'tarifa-envio.delete' => 'Can delete',
'tarifa-envio.menu' => 'Menu shall be visualize',
'tarifa-extra.create' => 'Can create',
'tarifa-extra.edit' => 'Can edit',
'tarifa-extra.delete' => 'Can delete',
'tarifa-extra.menu' => 'Menu shall be visualize',
'proveedores.create' => 'Can create',
'proveedores.edit' => 'Can edit',
'proveedores.delete' => 'Can delete',
@ -65,10 +61,6 @@ const SK_PERMISSIONS = [
'paises.edit' => 'Can edit',
'paises.delete' => 'Can delete',
'paises.menu' => 'Menu shall be visualize',
'formas-pago.create' => 'Can create',
'formas-pago.edit' => 'Can edit',
'formas-pago.delete' => 'Can delete',
'formas-pago.menu' => 'Menu shall be visualize',
'maquinas.create' => 'Can create',
'maquinas.edit' => 'Can edit',
'maquinas.delete' => 'Can delete',
@ -93,12 +85,4 @@ const SK_PERMISSIONS = [
'roles-permisos.edit' => 'Can edit',
'roles-permisos.delete' => 'Can delete',
'roles-permisos.menu' => 'Menu shall be visualize',
'ubicaciones.create' => 'Can create',
'ubicaciones.edit' => 'Can edit',
'ubicaciones.delete' => 'Can delete',
'ubicaciones.menu' => 'Menu shall be visualize',
'series-facturas.create' => 'Can create',
'series-facturas.edit' => 'Can edit',
'series-facturas.delete' => 'Can delete',
'series-facturas.menu' => 'Menu shall be visualize',
];

View File

@ -654,6 +654,8 @@ $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function (
$routes->post('cambiarestado', 'Pedido::cambiarEstado', ['as' => 'cambiarEstadoPedido']);
$routes->post('update/(:any)', 'Pedido::update/$1', ['as' => 'actualizarPedido']);
$routes->get('xml/(:num)', 'Pedido::get_xml_pedido/$1', ['as' => 'getXMLPedido']);
$routes->get('produccion/(:num)', 'Pedido::to_produccion/$1', ['as' => 'toProduccion']);
});
$routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);
@ -839,6 +841,8 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
$routes->group('ordentrabajo', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
$routes->get('', 'Ordentrabajo::index', ['as' => 'viewOrdenTrabajoIndex']);
$routes->get('edit/$1', 'Ordentrabajo::edit/$1', ['as' => 'viewOrdenTrabajoEdit']);
$routes->get('datatable', 'Ordentrabajo::datatable', ['as' => 'datatableOrdenTrabajo']);
});
});

View File

@ -4,7 +4,7 @@ namespace Config;
use App\Services\FTPService;
use CodeIgniter\Config\BaseService;
use App\Services\ProductionService;
/**
* Services Configuration file.
*
@ -30,4 +30,7 @@ class Services extends BaseService
* return new \CodeIgniter\Example();
* }
*/
public static function production(){
return new ProductionService();
}
}

View File

@ -6,6 +6,7 @@ use App\Entities\Pedidos\PedidoEntity;
use App\Models\Collection;
use App\Models\Pedidos\PedidoModel;
use App\Services\PedidoXMLService;
use App\Services\ProductionService;
class Pedido extends \App\Controllers\BaseResourceController
{
@ -388,9 +389,14 @@ class Pedido extends \App\Controllers\BaseResourceController
// $xml_service = new PedidoXMLService($this->model);
return $this->respond($data);
}
public function pedidoToProduction(int $pedido_id){
public function to_produccion($pedido_id)
{
$serviceProduction = service('production');
$pedido = $this->model->find($pedido_id);
$serviceProduction->setPedido($pedido);
return $this->respond()->setJSON($serviceProduction->createOrdenTrabajo());
}
}

View File

@ -2,8 +2,10 @@
namespace App\Controllers\Produccion;
use App\Controllers\BaseController;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Hermawan\DataTables\DataTable;
use Psr\Log\LoggerInterface;
class Ordentrabajo extends BaseController
@ -11,7 +13,7 @@ class Ordentrabajo extends BaseController
protected $format = 'json';
protected array $viewData = [];
protected OrdenTrabajoModel $otModel;
protected static $viewPath = 'themes/vuexy/form/produccion/';
protected static $controllerSlug = "orden-trabajo";
protected $indexRoute = 'viewOrdenTrabajoList';
@ -19,6 +21,7 @@ class Ordentrabajo extends BaseController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->otModel = model(OrdenTrabajoModel::class);
parent::initController($request, $response, $logger);
}
@ -52,19 +55,13 @@ class Ordentrabajo extends BaseController
return view(static::$viewPath . $this->editRoute, $this->viewData);
}
public function cien()
{
echo 'Orden trabajo 100%';
}
public function finalizado()
{
echo 'Orden trabajo finalizado';
}
public function pendiente()
{
echo 'Orden trabajo pendiente';
public function datatable(){
$q = $this->otModel->getDatatableQuery();
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("action" ,fn($q) => $q->id)
->toJson(true);
}
}

View File

@ -15,256 +15,57 @@ class OrdenTrabajoTable extends Migration
],
"pedido_id" => [
"type" => "INT",
"constraint" => 10,
"comment" => "Pedido asociado",
"unsigned" => true,
"constraint" => 16,
"comment" => "Pedido original asociado",
],
"user_created_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"comment" => "Usuario que ha pasado el pedido a producción",
],
"user_update_id" => [
"user_updated_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"comment" => "Usuario que ha actualizado la orden de trabajo",
],
"maquina_orden_negro_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true,
"comment" => "Maquina para impresion en negro",
],
"maquina_orden_color_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true,
"comment" => "Maquina para impresion en color",
],
"maquina_orden_portada_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true,
"comment" => "Maquina para impresion portada",
],
"maquina_orden_cubierta_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true,
"comment" => "Maquina para impresion cubierta",
],
"negro_forma_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
],
"color_forma_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
],
"portada_forma_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
],
"cubierta_forma_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
],
"tirada" => [
"type" => "DOUBLE",
],
"negro_pliegos_pedido" => [
"total_tirada" => [
"type" => "DOUBLE",
"null" => true
],
"color_pliegos_pedido" => [
"total_precio" => [
"type" => "DOUBLE",
"null" => true
],
"portada_pliegos_pedido" => [
"type" => "DOUBLE",
"null" => true
],
"cubierta_pliegos_pedido" => [
"type" => "DOUBLE",
"null" => true
],
"negro_clicks_pedido" => [
"type" => "DOUBLE",
],
"color_clicks_pedido" => [
"type" => "DOUBLE",
],
"portada_clicks_pedido" => [
"type" => "DOUBLE",
],
"cubierta_clicks_pedido" => [
"type" => "DOUBLE",
],
"pliegos1" => [
"type" => "INT",
"constraint" => 11,
],
"paginas1" => [
"type" => "INT",
"constraint" => 11,
],
"pliegos2" => [
"type" => "INT",
"constraint" => 11,
],
"paginas2" => [
"type" => "INT",
"constraint" => 11,
],
"negro_proveedor_nombre" => [
"type" => "VARCHAR",
"constraint" => 225
],
"color_proveedor_nombre" => [
"type" => "VARCHAR",
"constraint" => 225
],
"portada_proveedor_nombre" => [
"type" => "VARCHAR",
"constraint" => 225
],
"corte_pie" => [
"type" => "DOUBLE",
],
"lomo" => [
"type" => "INT",
"constraint" => 11,
"null" => true,
],
"tipo_entrada" => [
"type" => "ENUM",
"constraint" => ["in", "out"],
"default" => "out"
"default" => "out",
"comment" => "Tipo de entrada"
],
"fecha_entrega_real_warning" => [
"type" => "BOOLEAN",
"default" => false,
],
"fecha_entrega_warning" => [
"type" => "BOOLEAN",
"default" => false
],
"fecha_entrega_warning_revised" => [
"type" => "BOOLEAN",
"default" => false
],
"ferro_disponible" => [
"type" => "TINYINT",
"constraint" => 4,
],
"ferro_disponible_thread_id" => [
"type" => "INT",
"constraint" => 10,
],
"ferro_cp" => [
"type" => "VARCHAR",
"constraint" => 10,
"null" => true
],
"ferro_proveedor" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
],
"ferro_tracking" => [
"type" => "VARCHAR",
"constraint" => 100,
"null" => true,
],
"pre_formato" => [
"type" => "BOOLEAN",
"default" => false
],
"pre_lomo" => [
"type" => "BOOLEAN",
"default" => 0,
],
"pre_solapa" => [
"type" => "BOOLEAN",
"default" => 0,
],
"pre_isbn" => [
"type" => "BOOLEAN",
"default" => 0,
],
"pre_codbarras" => [
"type" => "BOOLEAN",
"default" => 0,
],
"pre_imposicion" => [
"type" => "BOOLEAN",
"default" => 0,
],
"pre_imprimir" => [
"type" => "BOOLEAN",
"default" => 0,
],
"pre_faltan_materiales" => [
"type" => "BOOLEAN",
"default" => 0,
],
"pre_faltan_materiales_note" => [
"type" => "TEXT",
"null" => true,
],
"progreso" => [
"type" => "DOUBLE",
"default" => 0.00,
"comment" => "Progreso de 0 a 100"
],
"message_production_send" => [
"type" => "BOOLEAN",
"default" => 0,
],
"finalizado" => [
"type" => "BOOLEAN",
"default" => 0,
"estado" => [
"type" => "ENUM",
"constraint" => ["I","F","P","E"],
"default" => "I",
"comment" => "I => INICIADO, F => FINALIZADO, P => PROGRESO , E => ERROR"
],
"comentarios" => [
"type" => "TEXT",
"null" => true,
"default" => null,
"comment" => "Comentarios orden de trabajo"
]
];
public function up()
@ -289,10 +90,10 @@ class OrdenTrabajoTable extends Migration
],
]);
$this->forge->addPrimaryKey("id");
// $this->forge->addForeignKey(["maquina_orden_portada_id"],"lg_maquinas",["id"]);
// $this->forge->addForeignKey(["maquina_orden_negro_id"],"lg_maquinas",["id"]);
// $this->forge->addForeignKey(["maquina_orden_cubierta_id"],"lg_maquinas",["id"]);
// $this->forge->addForeignKey(["maquina_orden_color_id"],"lg_maquinas",["id"]);
$this->forge->addForeignKey("pedido_id","pedidos","id");
$this->forge->addForeignKey("user_created_id","users","id");
$this->forge->addForeignKey("user_updated_id","users","id");
$this->forge->createTable("ordenes_trabajo", true);
}

View File

@ -11,17 +11,60 @@ class OrdenTrabajoTareasTable extends Migration
"id" => [
"type" => "INT",
"unsigned" => true,
"autoincrement" => true
],
"tarea_servicio_id" => [
"type" => "INT",
"unsigned" => true,
"auto_increment" => true
],
"orden_trabajo_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"comment" => "Orden de trabajo a la que pertenece esta tarea",
],
"presupuesto_linea_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual",
],
"nombre" => [
"type" => "VARCHAR",
"constraint" => 255,
"comment" => "Nombre de la tarea",
],
"orden" => [
"type" => "INT",
"unsigned" => true,
"comment" => "Orden de ejecución del tarea. Por defecto el orden será la de la máquina asociada a la línea de presupuesto."
],
"maquina_id" =>
[
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Máquina asociada a la tarea. Por defecto será la asociada a la linea de presupuesto"
],
"imposicion_id" => [
"type" => "INT",
"null" => true,
"constraint" => 11,
"default" => null,
"comment" => "Imposicion aplicada a la tarea. Default null"
],
"tiempo_estimado" => [
"type" => "DOUBLE",
"default" => 0.00,
"null" => true,
"comment" => "Tiempo ejecución estimado de la tarea en minutos",
],
"tiempo_real" => [
"type" => "DOUBLE",
"default" => 0.00,
"null" => true,
"comment" => "Tiempo ejecución real de la tarea",
]
];
public function up()
{
@ -43,14 +86,17 @@ class OrdenTrabajoTareasTable extends Migration
"null" => true,
],
]);
// $this->forge->addPrimaryKey("id");
// $this->forge->addForeignKey("orden_trabajo_id","ordenes_trabajo","id");
// $this->forge->addForeignKey("tarea_servicio_id","tareas_servicio","id");
$this->forge->createTable("orden_trabajo_tareas", true);
$this->forge->addPrimaryKey("id");
$this->forge->addForeignKey("orden_trabajo_id","ordenes_trabajo","id","CASCADE","CASCADE");
$this->forge->addForeignKey("presupuesto_linea_id","presupuesto_linea","id");
$this->forge->addForeignKey("imposicion_id","lg_imposiciones","id");
$this->forge->addForeignKey("maquina_id","lg_maquinas","id");
$this->forge->createTable("orden_trabajo_tareas");
}
public function down()
{
$this->forge->dropTable("orden_trabajo_tareas");
$this->forge->dropTable("orden_trabajo_tareas",true);
}
}

View File

@ -8,6 +8,10 @@ use CodeIgniter\Database\RawSql;
class OrdenTrabajoDatesTable extends Migration
{
protected array $COLUMNS = [
"orden_trabajo_id" => [
"type" => "INT",
"unsigned" => true,
],
"fecha_entrada_at" => [
"type" => "DATETIME",
"null" => true,
@ -33,11 +37,11 @@ class OrdenTrabajoDatesTable extends Migration
"type" => "DATE",
"null" => true,
],
"fecha_encuardernado_at" => [
"fecha_encuadernado_at" => [
"type" => "DATE",
"null" => true,
],
"fecha_externo_at" => [
"fecha_entrega_externo" => [
"type" => "DATE",
"null" => true,
],
@ -161,6 +165,8 @@ class OrdenTrabajoDatesTable extends Migration
"null" => true,
],
]);
$this->forge->addPrimaryKey('orden_trabajo_id');
$this->forge->addForeignKey("orden_trabajo_id","ordenes_trabajo","id","CASCADE","CASCADE");
$this->forge->createTable("orden_trabajo_dates", true);
}

View File

@ -1,6 +1,11 @@
<?php
namespace App\Entities\Pedidos;
use App\Entities\Presupuestos\PresupuestoEntity;
use App\Entities\Produccion\OrdenTrabajoEntity;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use App\Models\Pedidos\PedidoLineaModel;
use App\Models\Presupuestos\PresupuestoModel;
use CodeIgniter\Entity;
class PedidoEntity extends \CodeIgniter\Entity\Entity
@ -27,4 +32,35 @@ class PedidoEntity extends \CodeIgniter\Entity\Entity
"total_precio" => "float",
"total_tirada" => "float",
];
/**
* Devuelve la entidad `PedidoEntity` con sus relaciones
*
* @return self
*/
public function withAllRelations() : self
{
$this->attributes["pedido_lineas"] = $this->lineas();
$this->attributes["presupuesto"] = $this->presupuesto();
return $this;
}
public function lineas(): array
{
$q = model(PedidoLineaModel::class);
$q->where("pedido_id",$this->attributes["id"]);
return $q->findAll();
}
public function presupuesto() : PresupuestoEntity
{
$q = model(PedidoLineaModel::class);
$p = model(PresupuestoModel::class);
$presupuesto_id = $q->where("pedido_id",$this->attributes["id"])->first()->presupuesto_id;
return $p->find($presupuesto_id);
}
public function orden_trabajo() : ?OrdenTrabajoEntity
{
$m = model(OrdenTrabajoModel::class);
return $m->where("pedido_id",$this->attributes["id"])->first();
}
}

View File

@ -191,4 +191,5 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
return $q;
}
}

View File

@ -1,7 +1,17 @@
<?php
namespace App\Entities\Presupuestos;
use App\Models\Configuracion\MaquinaModel;
use CodeIgniter\Entity;
use App\Entities\Configuracion\Maquina as MaquinaEntity;
use App\Entities\Configuracion\MaquinasTarifasImpresionEntity;
use App\Entities\Configuracion\PapelGenerico;
use App\Entities\Configuracion\PapelImpresion;
use App\Entities\Tarifas\TarifapreimpresionEntity;
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
use App\Models\Configuracion\PapelGenericoModel;
use App\Models\Configuracion\PapelImpresionModel;
class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity
{
@ -141,5 +151,45 @@ class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity
"precio_impresion" => "double",
"total_linea" => "double",
];
/**
* Devuelve la entity MaquinaEntity asociada a esta linea de presupuesto
*
* @return MaquinaEntity
*/
public function maquina(): MaquinaEntity
{
$m = model(MaquinaModel::class);
return $m->find($this->attributes["maquina_id"]);
}
/**
* Devuelve la entity PapelImpresion asociada a esta linea de presupuesto.
*
* @return PapelImpresion
*/
public function papel_impresion(): PapelImpresion
{
$m = model(PapelImpresionModel::class);
return $m->find($this->attributes['papel_impresion_id']);
}
/**
* Devuelve la entity PapelGenerico asociada a esta linea de presupuesto.
*
* @return PapelGenerico
*/
public function papel_generico(): PapelGenerico
{
$m = model(PapelGenericoModel::class);
return $m->find($this->attributes['papel_id']);
}
/**
* Devuelve la entity MaquinasTarifasImpresionEntity asociada a esta linea de presupuesto.
*
* @return MaquinasTarifasImpresionEntity
*/
public function tarifa_impresion(): MaquinasTarifasImpresionEntity
{
$m = model(MaquinasTarifasImpresionModel::class);
return $m->find($this->attributes['tarifa_impresion_id']);
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace App\Entities\Produccion;
use CodeIgniter\Entity\Entity;
class OrdenTrabajoDateEntity extends Entity
{
protected $attributes = [
"fecha_entrada_at" => null,
"fecha_entrega_at" => null,
"fecha_entrega_change_at" => null,
"fecha_entrega_real_at" => null,
"fecha_entrega_real_warning" => null,
"fecha_impresion_at" => null,
"fecha_encuadernado_at" => null,
"fecha_externo_at" => null,
"fecha_entrega_warning" => null,
"fecha_entrega_warning_revised" => null,
"pendiente_ferro_at" => null,
"ferro_en_cliente_at" => null,
"ferro_ok_at" => null,
"interior_bn_at" => null,
"interior_color_at" => null,
"preparacion_interiores_at" => null,
"cubierta_at" => null,
"plastificado_at" => null,
"encuadernacion_at" => null,
"corte_at" => null,
"embalaje_at" => null,
"envio_at" => null,
"entrada_manipulado_at" => null
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [
"fecha_entrada_at" => "?datetime",
"fecha_entrega_at" => "?datetime",
"fecha_entrega_change_at" => "?datetime",
"fecha_entrega_real_at" => "?datetime",
"fecha_entrega_real_warning" => "?bool",
"fecha_impresion_at" => "?datetime",
"fecha_encuadernado_at" => "?datetime",
"fecha_externo_at" => "?datetime",
"fecha_entrega_warning" => "?bool",
"fecha_entrega_warning_revised" => "?bool",
"pendiente_ferro_at" => "?datetime",
"ferro_en_cliente_at" => "?datetime",
"ferro_ok_at" => "?datetime",
"interior_bn_at" => "?datetime",
"interior_color_at" => "?datetime",
"preparacion_interiores_at" => "?datetime",
"cubierta_at" => "?datetime",
"plastificado_at" => "?datetime",
"encuadernacion_at" => "?datetime",
"corte_at" => "?datetime",
"embalaje_at" => "?datetime",
"envio_at" => "?datetime",
"entrada_manipulado_at" => "?datetime"
];
}

View File

@ -1,6 +1,11 @@
<?php
namespace App\Entities\Produccion;
use App\Database\Migrations\OrdenTrabajoDatesTable;
use App\Entities\Pedidos\PedidoEntity;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use App\Models\Pedidos\PedidoModel;
use CodeIgniter\Entity\Entity;
@ -8,107 +13,61 @@ class OrdenTrabajoEntity extends Entity
{
protected $attributes = [
"pedido_id" => 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
"user_created_id" => null,
"user_updated_id" => null,
"total_tirada" => null,
"total_precio" => null,
"tipo_entrada" => "out",
"progreso" => 0.00,
"estado" => "I",
"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'
"pedido_id" => "integer",
"user_created_id" => "integer",
"user_updated_id" => "?integer",
"total_tirada" => "float",
"total_precio" => "float",
"tipo_entrada" => "string",
"progreso" => "float",
"estado" => "string",
"comentarios" => "string",
];
/**
* Devuelve las tareas de la orden de trabajo.
*
* @return array<OrdenTrabajoTarea>
*/
public function tareas(): array
{
$m = model(OrdenTrabajoTarea::class);
return $m->where("orden_trabajo_id", $this->attributes["id"])->findAll();
}
/**
* Devuelve el pedido de la orden de trabajo
*
* @return PedidoEntity
*/
public function pedido(): PedidoEntity
{
$m = model(PedidoModel::class);
return $m->find($this->attributes["pedido_id"]);
}
/**
* Almacena en la tabla `orden_trabajo_dates` las fechas correspondientes del pedido.
* Se almacenan en una tabla externa porque puede haber modificaciones de estas fechas
* en la orden del trabajo, pero en el pedido quedarán fijas.
*
* @todo Falta implementacion
* @return boolean
*/
public function storeDates($data): self
{
$ot_dates = new OrdenTrabajoDateEntity();
$this->attributes["dates"] = $ot_dates->fill($data);
return $this;
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Entities\Produccion;
use CodeIgniter\Entity\Entity;
class OrdenTrabajoMaquetacionEntity extends Entity
{
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Entities\Produccion;
use CodeIgniter\Entity\Entity;
class OrdenTrabajoMaquetacionMovimientoEntity extends Entity
{
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

View File

@ -0,0 +1,88 @@
<?php
namespace App\Entities\Produccion;
use App\Entities\Configuracion\Maquina;
use App\Entities\Presupuestos\PresupuestoLineaEntity;
use App\Models\Configuracion\MaquinaModel;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use App\Models\Presupuestos\PresupuestoLineaModel;
use CodeIgniter\Entity\Entity;
class OrdenTrabajoTareaEntity extends Entity
{
protected $attributes = [
"id" => null,
"orden_trabajo_id" => null,
"presupuesto_linea_id" => null,
"nombre" => null,
"orden" => null,
"maquina_id" => null,
"imposicion_id" => null,
"tiempo_estimado" => null,
"tiempo_real" => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [
"id" => "integer",
"orden_trabajo_id" => "integer",
"presupuesto_linea_id" => "?integer",
"nombre" => "string",
"orden" => "integer",
"maquina_id" => "?integer",
"imposicion_id" => "?integer",
"tiempo_estimado" => "?float",
"tiempo_real" => "?float"
];
/**
* Orden de trabajo de la tarea
*
* @return OrdenTrabajoEntity
*/
public function orden_trabajo() : OrdenTrabajoEntity
{
$m = model(OrdenTrabajoModel::class);
return $m->find($this->attributes["orden_trabajo_id"]);
}
/**
* Tarea orden de trabajo con orden de trabajo
*
* @return self
*/
public function withOrdenTrabajo() : self
{
$this->attributes["orden_trabajo"] = $this->orden_trabajo();
return $this;
}
/**
* Devuelve la maquina actual de esta tarea
*
* @return Maquina
*/
public function maquina_actual() : Maquina
{
$m = model(MaquinaModel::class);
return $m->find($this->attributes["maquina_id"]);
}
/**
* Devuelve el presupuesto linea origen de esta tarea
*
* @return PresupuestoLineaEntity
*/
public function presupuesto_linea() : PresupuestoLineaEntity
{
$m = model(PresupuestoLineaModel::class);
return $m->find($this->attributes["presupuesto_linea_id"]);
}
/**
* Devuelve la maquina original del presupuesto linea
*
* @return Maquina
*/
public function maquina_presupuesto_linea() : Maquina
{
return $this->presupuesto_linea()->maquina();
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Entities\Produccion;
use CodeIgniter\Entity\Entity;
class OrdenTrabajoUserEntity extends Entity
{
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

View File

@ -9,5 +9,14 @@ return [
"ubicacion"=> "Ubicación",
"tirada"=> "Tirada",
"impresion"=> "Impresión",
],
"task" => [
"order" => "Orden",
"task" => "Tarea",
"note" => "Nota",
"maquina_presupuesto" => "Máquina presupuesto",
"maquina_actual" => "Máquina actual",
"tiempo_estimado" => "Tiempo estimado",
"tiempo" => "Tiempo"
]
];

View File

@ -0,0 +1,97 @@
<?php
namespace App\Models\OrdenTrabajo;
use App\Entities\Produccion\OrdenTrabajoDateEntity;
use CodeIgniter\Database\MySQLi\Builder;
use CodeIgniter\Model;
class OrdenTrabajoDate extends Model
{
protected $table = 'orden_trabajo_dates';
protected $primaryKey = 'orden_trabajo_id';
protected $useAutoIncrement = true;
protected $returnType = OrdenTrabajoDateEntity::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
protected $allowedFields = [
"orden_trabajo_id",
"fecha_entrada_at",
"fecha_entrega_at",
"fecha_entrega_change_at",
"fecha_entrega_real_at",
"fecha_entrega_real_warning",
"fecha_impresion_at",
"fecha_encuadernado_at",
"fecha_externo_at",
"fecha_entrega_warning" ,
"fecha_entrega_warning_revised",
"pendiente_ferro_at",
"ferro_en_cliente_at",
"ferro_ok_at",
"interior_bn_at",
"interior_color_at",
"preparacion_interiores_at",
"cubierta_at",
"plastificado_at",
"encuadernacion_at",
"corte_at",
"embalaje_at",
"envio_at",
"entrada_manipulado_at"
];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
protected array $castHandlers = [];
// Dates
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
/**
* Query datatable
*
* @return Builder
*/
protected function getQueryDatatable() : Builder
{
$q = $this->builder()
->select([
"orden_trabajo_tareas.orden",
"mp.nombre as maquina_presupuesto",
"m.nombre as maquina_tarea",
"orden_trabajo_tareas.tiempo_estimado",
"orden_trabajo_tareas.tiempo_real"
])
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
->join("lg_maquinas m","lg_maquinas.id = orden_trabajo_tareas.maquina_id","left")
->join("lg_maquinas mp","lg_maquinas.id = presupuesto_linea.maquina_id","left")
->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id" , "left")
->where("orden_trabajo_tareas.deleted_at" , NULL);
return $q;
}
}

View File

@ -15,54 +15,14 @@ class OrdenTrabajoModel extends Model
protected $protectFields = true;
protected $allowedFields = [
"pedido_id",
"maquina_orden_negro_id",
"maquina_orden_color_id",
"maquina_orden_portada_id",
"maquina_orden_cubierta_id",
"negro_forma_id",
"color_forma_id",
"portada_forma_id",
"cubierta_forma_id",
"tirada",
"negro_pliegos_pedido",
"color_pliegos_pedido",
"portada_pliegos_pedido",
"cubierta_pliegos_pedido",
"negro_clicks_pedido",
"color_clicks_pedido",
"portada_clicks_pedido",
"cubierta_clicks_pedido",
"pliegos1",
"paginas1",
"pliegos2",
"paginas2",
"negro_proveedor_nombre",
"color_proveedor_nombre",
"portada_proveedor_nombre",
"corte_pie",
"lomo",
"user_created_id",
"user_updated_id",
"total_tirada",
"total_precio",
"tipo_entrada",
"fecha_entrega_real_warning",
"fecha_entrega_warning",
"fecha_entrega_warning_revised",
"ferro_disponible",
"ferro_disponible_thread_id",
"ferro_cp",
"ferro_proveedor",
"ferro_tracking",
"pre_formato",
"pre_lomo",
"pre_solapa",
"pre_isbn",
"pre_codbarras",
"pre_imposicion",
"pre_imprimir",
"pre_faltan_materiales",
"pre_faltan_materiales_note",
"progreso",
"message_production_send",
"finalizado",
"comentarios"
"estado",
"comentarios",
];
protected bool $allowEmptyInserts = false;
@ -97,23 +57,26 @@ class OrdenTrabajoModel extends Model
public function getDatatableQuery() : BaseBuilder
{
$q = $this->builder("ordenes_trabajo ot")
$q = $this->builder()
->select([
"pedidos.id",
"ordenes_trabajo.id",
"ordenes_trabajo.pedido_id",
"orden_trabajo_dates.fecha_encuadernado_at",
"clientes.nombre as client_name",
"presupuestos.titulo as presupuesto_title",
"tp.codigo as tipo_presupuesto_impresion",
"ubicaciones.nombre as ubicacion_name",
"clientes.nombre as cliente_nombre",
"presupuestos.titulo as presupuesto_titulo",
"ubicaciones.nombre as ubicacion_nombre",
"pedidos.total_tirada",
"tipos_presupuestos.codigo as tipo_presupuesto_impresion",
])
->join("orden_trabajo_dates otdates","otdates.orden_trabajo_id = ot.id","left")
->join("pedidos","pedidos.id = ot.pedido_id","left")
->join("orden_trabajo_dates","orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id","left")
->join("pedidos","pedidos.id = ordenes_trabajo.pedido_id","left")
->join("pedidos_linea","pedidos.id = pedidos_linea.pedido_id","left")
->join("presupuestos","presupuestos.id = pedidos_linea.presupuesto_id","left")
->join("clientes","clientes.id = presupuestos.cliente_id","left")
->join("tipos_presupuestos tp","presupuestos.tipo_impresion_id = tp.id","left")
->join("tipos_presupuestos","presupuestos.tipo_impresion_id = tipos_presupuestos.id","left")
->join("ubicaciones","ubicaciones.id = pedidos_linea.ubicacion_id","left")
->groupBy("ot.id");
->where("ordenes_trabajo.deleted_at",null)
->groupBy("ordenes_trabajo.id");
return $q;
}

View File

@ -0,0 +1,81 @@
<?php
namespace App\Models\OrdenTrabajo;
use App\Entities\Produccion\OrdenTrabajoTareaEntity;
use CodeIgniter\Database\MySQLi\Builder;
use CodeIgniter\Model;
class OrdenTrabajoTarea extends Model
{
protected $table = 'orden_trabajo_tareas';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = OrdenTrabajoTareaEntity::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
protected $allowedFields = [
"orden_trabajo_id",
"presupuesto_linea_id",
"nombre",
"orden",
"maquina_id",
"imposicion_id",
"tiempo_estimado",
"tiempo_real"
];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
protected array $castHandlers = [];
// Dates
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
/**
* Query datatable
*
* @return Builder
*/
protected function getQueryDatatable() : Builder
{
$q = $this->builder()
->select([
"orden_trabajo_tareas.orden",
"mp.nombre as maquina_presupuesto",
"m.nombre as maquina_tarea",
"orden_trabajo_tareas.tiempo_estimado",
"orden_trabajo_tareas.tiempo_real"
])
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
->join("lg_maquinas m","lg_maquinas.id = orden_trabajo_tareas.maquina_id","left")
->join("lg_maquinas mp","lg_maquinas.id = presupuesto_linea.maquina_id","left")
->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id" , "left")
->where("orden_trabajo_tareas.deleted_at" , NULL);
return $q;
}
}

View File

@ -5,10 +5,13 @@ declare(strict_types=1);
namespace App\Models;
use App\Entities\Usuarios\UsersEntity;
use CodeIgniter\Shield\Authentication\Traits\HasAccessTokens;
use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;
class UserModel extends ShieldUserModel
{
use HasAccessTokens;
protected function initialize(): void
{
parent::initialize();

View File

@ -0,0 +1,202 @@
<?php
namespace App\Services;
use App\Database\Migrations\OrdenTrabajoUsers;
use App\Entities\Configuracion\Maquina;
use App\Entities\Pedidos\PedidoEntity;
use App\Entities\Presupuestos\PresupuestoEntity;
use App\Entities\Presupuestos\PresupuestoLineaEntity;
use App\Entities\Produccion\OrdenTrabajoEntity;
use App\Models\OrdenTrabajo\OrdenTrabajoDate;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use CodeIgniter\Config\BaseService;
use CodeIgniter\Database\BaseBuilder;
use CodeIgniter\Database\Exceptions\DatabaseException;
/**
* Clase con las funcionalidades necesarias trabajar con las ordenes de trabajo.
*/
class ProductionService extends BaseService
{
protected OrdenTrabajoModel $otModel;
protected OrdenTrabajoTarea $otTarea;
protected OrdenTrabajoDate $otDate;
/**
* Pedido Entity
*
* @var PedidoEntity
*/
protected PedidoEntity $pedido;
/**
* Presupuesto Entity
*
* @var PresupuestoEntity
*/
protected PresupuestoEntity $presupuesto;
/**
* Establece el pedido sobre el que se va a trabajar
*
* @param PedidoEntity $pedido
* @return self
*/
public function setPedido(PedidoEntity $pedido): self
{
$this->pedido = $pedido;
$this->presupuesto = $this->pedido->presupuesto();
$this->otModel = model(OrdenTrabajoModel::class);
$this->otDate = model(OrdenTrabajoDate::class);
$this->otTarea = model(OrdenTrabajoTarea::class);
return $this;
}
/**
* Obtiene el pedido asociado a esta clase
*
* @return PedidoEntity
*/
public function getPedido(): PedidoEntity
{
return $this->pedido;
}
public function getPresupuesto(): PresupuestoEntity
{
return $this->presupuesto;
}
/**
* Crea una instancia de la orden de trabajo
*
* @return self
*/
public function createOrdenTrabajo(): OrdenTrabajoEntity|DatabaseException
{
$auth_user = auth()->user();
$ot = new OrdenTrabajoEntity();
$ot_exists = $this->pedido->orden_trabajo();
if ($ot_exists) {
return $ot_exists;
}
$data = [
"pedido_id" => $this->pedido->id,
"user_created_id" => $auth_user->id,
"user_updated_id" => $auth_user->id,
"total_tirada" => $this->pedido->total_tirada,
"total_precio" => $this->pedido->total_precio
];
$ot->fill($data);
$this->otModel->save($ot);
$ot_id = $this->otModel->getInsertID();
$ot->id = $ot_id;
$this->storeOrdenTrabajoDates($ot);
$this->storeOrdenTrabajoTareas($ot);
return $ot;
}
/**
* Inserta las fechas del pedido asociado a la orden de trabajo en `orden_trabajo_tareas`
*
* @param OrdenTrabajoEntity $ot
* @return integer|boolean|string ID
*/
protected function storeOrdenTrabajoDates(OrdenTrabajoEntity $ot): bool|int|string
{
return $this->otDate->insert([
"orden_trabajo_id" => $ot->id,
"fecha_encuadernado_at" => $this->pedido->fecha_encuadernado,
"fecha_entrega_real_at" => $this->pedido->fecha_entrega_real,
"fecha_impresion_at" => $this->pedido->fecha_impresion,
"fecha_entrega_externo" => $this->pedido->fecha_entrega_externo,
]);
}
/**
* Inserta las tareas de la orden de trabajo.
* Acepta como argumento una entidad de la orden de trabajo OrdenTrabajoEntity
*
*
* @param OrdenTrabajoEntity $ot
* @return integer|boolean Numero de registro insertados o `FALSE` si error
*/
protected function storeOrdenTrabajoTareas(OrdenTrabajoEntity $ot): int|bool
{
$p_lineas = $this->presupuesto->presupuestoLineas();
$ot_tareas = [];
foreach ($p_lineas as $key => $p_linea) {
$p_linea_maquina = $p_linea->maquina();
$ot_tareas["orden_trabajo_id"] = $ot->id;
$ot_tareas["presupuesto_linea_id"] = $p_linea->id;
//TODO : Por ahora nombre maquina, asignar nombre tarea en
//TODO : base a la tarifa asociada a la linea de presupuesto
$ot_tareas["nombre"] = $p_linea_maquina->nombre;
$ot_tareas["orden"] = $p_linea_maquina->orden_planning;
$ot_tareas["maquina_id"] = $p_linea_maquina->id;
$ot_tareas["imposicion_id"] = null;
$ot_tareas["tiempo_estimado"] = $p_linea->horas_maquina;
$ot_tareas["tiempo_real"] = $p_linea->horas_maquina; //? Tiempo real se inserta manual?
$insert_query_result = $this->otTarea->insert($ot_tareas);
$ot_tareas = [];
}
return $insert_query_result;
}
/**
* Devuelve las lineas de presupuesto con la máquina asociada a cada una
*
* @return array<PresupuestoLineaEntity>
*/
protected function getPresupuestoLineasWithMaquina(): array
{
$presupuesto_lineas = $this->presupuesto->presupuestoLineas();
foreach ($presupuesto_lineas as $key => $linea) {
$linea->maquina = $linea->maquina();
}
return $presupuesto_lineas;
}
public function getTareas(): array
{
$p_lineas_with_maquina = $this->getPresupuestoLineasWithMaquina();
$tareas = [];
$tarea = [];
foreach ($p_lineas_with_maquina as $key => $linea) {
$tarea["orden"] = $linea->maquina->orden_planning;
$tarea["maquina_tipo"] = $linea->maquina->tipo;
$tarea["maquina_nombre"] = $linea->maquina->nombre;
$tarea["nota"] = null;
$tareas[] = $tarea;
$tarea = [];
}
return ["tareas" => $tareas];
}
/**
* Query para mostrar en datatable
*
* @param integer $ot_id Primary key de la orden de trabajo
* @return BaseBuilder
*/
public function taskDatatableQuery(int $ot_id): BaseBuilder
{
$q = $this->otModel->builder()->select([
"orden_trabajo_tareas.orden",
"orden_trabajo_tareas.nombre",
"presupuesto_lineas.maquina_id as maquina_tarea",
"orden_trabajo_tareas.maquina_id as maquina_presupuesto_linea",
"lg_imposiciones.id",
"orden_trabajo_tareas.tiempo_estimado",
"orden_trabajo_tareas.tiempo_real"
])
->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left")
->join("presupuesto_lineas", "presupuesto_lineas.id = orden_trabajo_tareas.presupuesto_linea_id")
->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id")
->where("orden_trabajo_tareas.orden_trabajo_id", $ot_id)
->where("orden_trabajo_tareas.deleted_at", null)
->orderBy("orden_trabajo_tareas.orden", "DESC");
return $q;
}
}

View File

@ -0,0 +1,16 @@
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Produccion.task.order') ?></th>
<th><?= lang('Produccion.task.task') ?></th>
<th><?= lang('Produccion.task.note') ?></th>
<th><?= lang('Produccion.task.maquina_presupuesto') ?></th>
<th><?= lang('Produccion.task.maquina_actual') ?></th>
<th><?= lang('Produccion.task.tiempo_estimado') ?></th>
<th><?= lang('Produccion.task.tiempo') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>

View File

@ -31,9 +31,11 @@
<div class="pt-4">
<?= anchor(route_to("listaPresupuestos"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
</div><!-- /.card-footer -->
<div class="pt-4">
<button class="btn btn-primary btn-md"><span> <i class="ti ti-building-factory-2 ti-xs"></i> <?= lang("Produccion.btn_pedido_produccion_accion") ?> </span></button>
</div><!-- /.card-footer -->
<?php if ($pedidoEntity->estado == 'finalizado') : ?>
<div class="pt-4">
<button class="btn btn-primary btn-md"><span> <i class="ti ti-building-factory-2 ti-xs"></i> <?= lang("Produccion.btn_pedido_produccion_accion") ?> </span></button>
</div><!-- /.card-footer -->
<?php endif; ?>
</div>
</div>

View File

@ -35,7 +35,7 @@
<div class="tab-content p-0">
<!-- TAREAS -->
<div class="tab-pane fade show active" id="nav-ot-task-general" role="tabpanel">
<?= view("themes/vuexy/components/tables/ot_task_table",["id" => "ot-task-table"]) ?>
</div>
<!-- PREIMPRESION -->
<div class="tab-pane fade" id="nav-ot-task-preimpresion" role="tabpanel">

View File

@ -37,6 +37,7 @@
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url("assets/js/safekat/pages/produccion/index.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>

View File

@ -0,0 +1,45 @@
class OrdenTrabajoDatatable {
constructor(domItem) {
this.datatableItem = domItem
this.datatableColumns = [
{ data: 'pedido_id',searchable: false, sortable: false },
{ data: 'fecha_encuadernado_at', searchable: false, sortable: false },
{ data: 'cliente_nombre', searchable: false, sortable: false },
{ data: 'presupuesto_titulo', searchable: false, sortable: false },
{ data: 'ubicacion_nombre', searchable: false, sortable: false },
{ data: 'total_tirada', searchable: false, sortable: false },
{ data: 'tipo_presupuesto_impresion', searchable: false, sortable: false },
{
data: 'action', searchable: false, sortable: false,
render: (d, t) => {
return `<div class="btn-group btn-group-sm">
<a href="/produccion/ordentrabajo/edit/${d}" class="ot-edit"><i class="ti ti-eye ti-sm mx-2"></i></a>
</div>`
}
}
]
}
init() {
this.datatable = this.datatableItem.DataTable({
processing: true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
serverSide: true,
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/produccion/ordentrabajo/datatable'
});
}
}
export default OrdenTrabajoDatatable;

View File

@ -0,0 +1,6 @@
import OrdenTrabajoDatatable from '../../components/datatables/otDatatable.js'
$(function() {
const otDatatable = new OrdenTrabajoDatatable($("#ot-datatable"))
otDatatable.init()
})