mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'feat/sk-7/planning' into 'main'
Feat/sk 7/planning See merge request jjimenez/safekat!615
This commit is contained in:
@ -293,6 +293,10 @@ $routes->group('papelesimpresion', ['namespace' => 'App\Controllers\Configuracio
|
||||
$routes->post('allmenuitems', 'Papelesimpresion::allItemsSelect', ['as' => 'select2ItemsOfPapelesImpresion']);
|
||||
$routes->post('menuitems', 'Papelesimpresion::menuItems', ['as' => 'menuItemsOfPapelesImpresion']);
|
||||
$routes->post('duplicate/(:num)', 'Papelesimpresion::duplicate/$1', ['as' => 'duplicatePapelImpresion']);
|
||||
$routes->get('select', 'Papelesimpresion::papel_impresion_select', ['as' => 'papelImpresionSelect']);
|
||||
$routes->get('show/(:num)', 'Papelesimpresion::papel_impresion_find/$1', ['as' => 'showPapelImpresion']);
|
||||
|
||||
|
||||
});
|
||||
$routes->resource('papelesimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesimpresion', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
@ -468,4 +468,15 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
}
|
||||
public function papel_impresion_select()
|
||||
{
|
||||
$q = $this->request->getGet('q');
|
||||
$data = $this->model->querySelect($q)->get()->getResultArray();
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function papel_impresion_find(int $papel_impresion_id)
|
||||
{
|
||||
$piEntity = $this->model->find($papel_impresion_id);
|
||||
return $this->response->setJSON($piEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,6 +276,13 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
$this->viewData['pedidoEntity'] = $pedidoEntity;
|
||||
|
||||
if($pedidoEntity->estado == 'validacion'){
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
$pendiente = $clienteModel->getPendienteCobro($pedidoEntity->cliente_id);
|
||||
$pendiente = $pendiente[0] + $pendiente[1];
|
||||
$this->viewData['importePendiente'] = $pendiente;
|
||||
}
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
@ -471,11 +478,12 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$pedido = $this->model->find($pedido_id);
|
||||
$serviceProduction->setPedido($pedido);
|
||||
if($pedido->orden_trabajo()){
|
||||
return $this->response->setJSON(["data"=>$pedido->orden_trabajo(),"message" => "Ya existe una orden de trabajo para este pedido"]);
|
||||
return $this->response->setJSON(["status"=>false,"data"=>$pedido->orden_trabajo(),"message" => "Ya existe una orden de trabajo para este pedido"]);
|
||||
|
||||
}else{
|
||||
$r = $serviceProduction->createOrdenTrabajo();
|
||||
return $this->response->setJSON(["data"=>$r,"message" => "Orden trabajo creada correctamente"]);
|
||||
$this->model->set(['estado' => 'produccion'])->where('id', $pedido_id)->update();
|
||||
return $this->response->setJSON(["status"=>true, "data"=>$r,"message" => "Orden trabajo creada correctamente"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -132,14 +132,14 @@ class Ordentrabajo extends BaseController
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado","F");
|
||||
$q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado", "F");
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
@ -147,14 +147,14 @@ class Ordentrabajo extends BaseController
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado",["I","PM"]);
|
||||
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"]);
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
@ -162,14 +162,14 @@ class Ordentrabajo extends BaseController
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at",null);
|
||||
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at", null);
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
@ -177,14 +177,14 @@ class Ordentrabajo extends BaseController
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at is NOT NULL",NULL,FALSE);
|
||||
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at is NOT NULL", NULL, FALSE);
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
@ -194,6 +194,8 @@ class Ordentrabajo extends BaseController
|
||||
$q = $this->produccionService->papelGramajeDatatableQuery();
|
||||
return DataTable::of($q)
|
||||
->edit("tiempoReal", fn($q) => float_seconds_to_hhmm_string($q->tiempoReal * 3600))
|
||||
->add("metros", fn($q) => $q->papel_ancho*$q->totalTirada/1000)
|
||||
->add("action", fn($q) => ["title" => lang('Produccion.datatable.filter_by_task'), 'data' => $q])
|
||||
->toJson(true);
|
||||
}
|
||||
public function reset_tareas(int $orden_trabajo_id)
|
||||
@ -262,6 +264,10 @@ class Ordentrabajo extends BaseController
|
||||
$q = $this->produccionService->planningRotativaQueryDatatable();
|
||||
return DataTable::of($q)
|
||||
->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "")
|
||||
->add("metros_check", fn($q) => $q->otId)
|
||||
->add("corte", fn($q) => $q->otId)
|
||||
->add("metros", fn($q) => $q->papel_ancho*$q->ot_tirada/1000)
|
||||
|
||||
->add("action", fn($q) => $q)
|
||||
->toJson(true);
|
||||
}
|
||||
|
||||
@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class OrdenTrabajoUsersTable extends Migration
|
||||
{
|
||||
protected array $USER_COLUMNS = [
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
"orden_trabajo_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
|
||||
"user_created_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"user_update_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"inaplazable_revised_change_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
|
||||
"ferro_disponible_hecho_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"ferro_disponible_ok_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"ferro_entregado_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pendiente_ferro_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"ferro_en_cliente_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"ferro_ok_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
|
||||
|
||||
"interior_bn_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"interior_color_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"preparacion_interior_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"cubierta_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"plastificado_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"encuadernacion_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"corte_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"embalaje_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"envio_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"entrada_manipulado_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
|
||||
"pre_formato_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
|
||||
"pre_lomo_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pre_solapa_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
|
||||
"pre_codbarras_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pre_imposicion_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"pre_imprimir_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"pre_imprimir_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
];
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->forge->dropTable('orden_trabajo_users',true);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField($this->USER_COLUMNS);
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey("orden_trabajo_id", "ordenes_trabajo","id");
|
||||
$this->forge->createTable("orden_trabajo_users");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('orden_trabajo_users');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class OrdenTrabajoDatesTable extends Migration
|
||||
{
|
||||
|
||||
protected array $COLUMNS = [
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
"orden_trabajo_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
"fecha_entrada_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"fecha_entrega_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"fecha_entrega_change_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"fecha_entrega_real_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"fecha_impresion_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"fecha_encuadernado_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"fecha_entrega_externo" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pendiente_ferro_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"ferro_en_cliente_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"ferro_ok_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"interior_bn_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"interior_color_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"preparacion_interiores_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"cubierta_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"plastificado_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"encuadernacion_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"corte_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"embalaje_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"envio_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"entrada_manipulado_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
|
||||
"ferro_disponible_hecho_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"ferro_disponible_ok_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"ferro_entregado_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"pre_formato_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pre_lomo_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pre_solapa_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pre_codbarras_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
"pre_imposicion_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->dropTable('orden_trabajo_dates',true);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey("orden_trabajo_id", "ordenes_trabajo","id");
|
||||
$this->forge->createTable("orden_trabajo_dates");
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('orden_trabajo_dates');
|
||||
}
|
||||
}
|
||||
@ -7,8 +7,8 @@ use CodeIgniter\Entity\Entity;
|
||||
class OrdenTrabajoDateEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"orden_trabajo_id" => null,
|
||||
"fecha_entrada_at" => null,
|
||||
"fecha_entrega_at" => null,
|
||||
"fecha_entrega_change_at" => null,
|
||||
"fecha_entrega_real_at" => null,
|
||||
"fecha_entrega_real_warning" => null,
|
||||
@ -29,14 +29,39 @@ class OrdenTrabajoDateEntity extends Entity
|
||||
"corte_at" => null,
|
||||
"embalaje_at" => null,
|
||||
"envio_at" => null,
|
||||
"entrada_manipulado_at" => null
|
||||
"entrada_manipulado_at" => null
|
||||
|
||||
];
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $dates = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_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 $casts = [
|
||||
// "fecha_entrada_at" => "?datetime",
|
||||
// "fecha_entrega_at" => "?datetime",
|
||||
// "fecha_entrega_change_at" => "?datetime",
|
||||
// "fecha_entrega_real_at" => "?datetime",
|
||||
// "fecha_entrega_real_warning" => "?bool",
|
||||
|
||||
@ -79,12 +79,12 @@ class OrdenTrabajoEntity extends Entity
|
||||
public function dates(): ?OrdenTrabajoDateEntity
|
||||
{
|
||||
$m = model(OrdenTrabajoDate::class);
|
||||
return $m->find($this->attributes["id"]);
|
||||
return $m->where('orden_trabajo_id',$this->attributes["id"])->first();
|
||||
}
|
||||
public function users(): ?OrdenTrabajoUserEntity
|
||||
{
|
||||
$m = model(OrdenTrabajoUser::class);
|
||||
return $m->find($this->attributes["id"]);
|
||||
return $m->where('orden_trabajo_id',$this->attributes["id"])->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,7 +8,7 @@ class OrdenTrabajoUserEntity extends Entity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
protected $attributes = [
|
||||
"orden_trabajo_id"=> null,
|
||||
"user_created_id"=> null,
|
||||
@ -36,4 +36,31 @@ class OrdenTrabajoUserEntity extends Entity
|
||||
"pre_imposicion_user_id"=> null,
|
||||
"pre_imprimir_user_id" => null
|
||||
];
|
||||
// protected array $casts = [
|
||||
// "orden_trabajo_id" => "integer",
|
||||
// "user_created_id" => "?integer",
|
||||
// "user_update_id" => "?integer",
|
||||
// "inaplazable_revised_change_user_id" => "?integer",
|
||||
// "ferro_disponible_hecho_user_id" => "?integer",
|
||||
// "ferro_disponible_ok_user_id" => "?integer",
|
||||
// "ferro_entregado_user_id" => "?integer",
|
||||
// "pendiente_ferro_user_id" => "?integer",
|
||||
// "ferro_en_cliente_user_id" => "?integer",
|
||||
// "ferro_ok_user_id" => "?integer",
|
||||
// "interior_bn_user_id" => "?integer",
|
||||
// "interior_color_user_id" => "?integer",
|
||||
// "preparacion_interior_user_id" => "?integer",
|
||||
// "cubierta_user_id" => "?integer",
|
||||
// "plastificado_user_id" => "?integer",
|
||||
// "encuadernacion_user_id" => "?integer",
|
||||
// "corte_user_id" => "?integer",
|
||||
// "embalaje_user_id" => "?integer",
|
||||
// "entrada_manipulado_user_id" => "?integer",
|
||||
// "pre_formato_user_id" => "?integer",
|
||||
// "pre_lomo_user_id" => "?integer",
|
||||
// "pre_solapa_user_id" => "?integer",
|
||||
// "pre_codbarras_user_id" => "?integer",
|
||||
// "pre_imposicion_user_id" => "?integer",
|
||||
// "pre_imprimir_user_id" => "?integer"
|
||||
// ];
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ return [
|
||||
'tiradas' => 'Tiradas',
|
||||
'total_presupuesto' => 'Total',
|
||||
'estado' => 'Estado',
|
||||
'importePendiente' => 'Importe Pendiente',
|
||||
|
||||
'validacion' => 'Validación',
|
||||
'produccion' => 'Producción',
|
||||
|
||||
@ -23,6 +23,10 @@ return [
|
||||
"tiempo" => "Tiempo",
|
||||
"progreso" => "Progreso",
|
||||
"logo" => "Logo impresion",
|
||||
"filter_by_task" => "Filtrar por tarea",
|
||||
"metros" => "Metros",
|
||||
"corte" => "Corte"
|
||||
|
||||
|
||||
],
|
||||
"task" => [
|
||||
@ -67,7 +71,7 @@ return [
|
||||
"preview_pdf" => "Previsualizar PDF",
|
||||
"imprimir_codigo_safekat" => "Imprimir código SAFEKAT",
|
||||
"imprimir_ferro" => "Imprimir ferro",
|
||||
"planning_rotativa" => "Planning rotativa",
|
||||
"planning_rotativa" => "Tareas rotativa",
|
||||
"solapa" => "Solapa",
|
||||
"papel_gramajes" => "Papel y gramajes"
|
||||
|
||||
|
||||
@ -309,9 +309,26 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
/*
|
||||
TO-DO: Implementar la lógica de negocio para el crédito disponible
|
||||
*/
|
||||
public function creditoDisponible($cliente_id)
|
||||
public function creditoDisponible($cliente_id, $total_pedido = 0)
|
||||
{
|
||||
return true;
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.limite_credito AS limite_credito"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.id", $cliente_id);
|
||||
$limite = $builder->get()->getResultObject();
|
||||
|
||||
if($limite){
|
||||
|
||||
$pendiente = $this->getPendienteCobro($cliente_id);
|
||||
$credito_disponible = floatval($limite[0]->limite_credito) - $pendiente[0] - $pendiente[1] - floatval($total_pedido);
|
||||
if($credito_disponible < 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getClienteDataFacturas($cliente_id)
|
||||
@ -402,4 +419,83 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
->groupEnd()->get()->getResultObject();
|
||||
|
||||
}
|
||||
|
||||
public function getPendienteCobro($cliente_id = -1)
|
||||
{
|
||||
|
||||
$pendiente_old = $this->getTotalPendienteOldERP($cliente_id);
|
||||
|
||||
// Subconsulta para verificar la existencia en facturas_lineas
|
||||
$subquery_facturas = "(SELECT 1
|
||||
FROM facturas_lineas fl
|
||||
JOIN facturas f2 ON fl.factura_id = f2.id
|
||||
WHERE (fl.pedido_linea_impresion_id = p.id OR fl.pedido_maquetacion_id = p.id)
|
||||
AND f2.estado = 'validada')";
|
||||
|
||||
// Subconsulta para calcular el total de pedidos pendientes
|
||||
$subquery_total_pedidos = $this->db->table('pedidos p')
|
||||
->select('SUM(p.total_precio)', false)
|
||||
->join('pedidos_linea pl', 'p.id = pl.pedido_id', 'left')
|
||||
->join('presupuestos pr', 'pl.presupuesto_id = pr.id', 'left')
|
||||
->where('pr.cliente_id', $cliente_id)
|
||||
->whereIn('p.estado', ['produccion', 'finalizado', 'enviado'])
|
||||
->where("NOT EXISTS $subquery_facturas", null, false) // Implementación manual de NOT EXISTS
|
||||
->getCompiledSelect();
|
||||
|
||||
// Construcción de la consulta principal
|
||||
$builder = $this->db->table('(SELECT DISTINCT cliente_id FROM presupuestos UNION SELECT DISTINCT cliente_id FROM facturas) c');
|
||||
$builder->select('c.cliente_id');
|
||||
$builder->select('COALESCE(SUM(f.pendiente), 0) AS total_facturas');
|
||||
$builder->select("COALESCE(($subquery_total_pedidos), 0) AS total_pedidos", false);
|
||||
$builder->select("COALESCE(SUM(f.pendiente), 0) + COALESCE(($subquery_total_pedidos), 0) AS total_pendiente", false);
|
||||
$builder->join('facturas f', 'c.cliente_id = f.cliente_id AND f.deleted_at IS NULL AND f.estado = "validada"', 'left');
|
||||
$builder->where('c.cliente_id', $cliente_id);
|
||||
$builder->groupBy('c.cliente_id');
|
||||
|
||||
$query = $builder->get();
|
||||
$valor = $query->getRow();
|
||||
|
||||
if ($valor) {
|
||||
return [round(floatval($valor->total_pendiente), 2), round(floatval($pendiente_old), 2)];
|
||||
} else {
|
||||
return [0, round(floatval($pendiente_old), 2)];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getTotalPendienteOldERP($customer_id = -1)
|
||||
{
|
||||
|
||||
$db = \Config\Database::connect('old_erp'); // Conectar a olderp
|
||||
$builder = $db->table('safekat.facturas f');
|
||||
$builder->select('f.customer_id');
|
||||
$builder->select('SUM(f.pendiente) + COALESCE((
|
||||
SELECT SUM(pl.total_raw)
|
||||
FROM safekat.pedido_libro pl
|
||||
WHERE pl.factura_id IS NULL
|
||||
AND pl.estado IN ("aceptado", "finalizado", "validado")
|
||||
AND pl.total_raw IS NOT NULL
|
||||
AND pl.total_raw != 0
|
||||
AND pl.inc_rei IS NULL
|
||||
AND pl.customer_id = f.customer_id
|
||||
), 0) AS total_pendiente');
|
||||
$builder->where('f.deleted_at IS NULL');
|
||||
$builder->where('f.estado', 'open');
|
||||
$builder->where('f.customer_id', $customer_id);
|
||||
$builder->groupBy('f.customer_id');
|
||||
|
||||
$query = $builder->get();
|
||||
$valor = $query->getRow();
|
||||
/*
|
||||
$builder = $db->table('vista_importe_pendiente_cliente t1')
|
||||
->select('*')
|
||||
->where('t1.customer_id', $customer_id);
|
||||
$query = $builder->get();
|
||||
$valor = $query->getRow();*/
|
||||
if ($valor) {
|
||||
return $valor->total_pendiente;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,5 +369,16 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
return "";
|
||||
}
|
||||
|
||||
public function querySelect(?string $query)
|
||||
{
|
||||
$q = $this->builder()->select([
|
||||
"id",
|
||||
"nombre as name",
|
||||
]);
|
||||
if ($query) {
|
||||
$q->orLike("nombre", $query);
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ use CodeIgniter\Model;
|
||||
class OrdenTrabajoDate extends Model
|
||||
{
|
||||
protected $table = 'orden_trabajo_dates';
|
||||
protected $primaryKey = 'orden_trabajo_id';
|
||||
protected $useAutoIncrement = false;
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = OrdenTrabajoDateEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
@ -62,8 +62,8 @@ class OrdenTrabajoDate extends Model
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = ["updateOrdenTrabajoUser"];
|
||||
protected $beforeUpdate = ["updateOrdenTrabajoUser"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = ["updateOrdenTrabajoUser"];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
@ -98,15 +98,15 @@ class OrdenTrabajoDate extends Model
|
||||
if(!isset($data["data"])){
|
||||
return $data;
|
||||
}else{
|
||||
$this->updateUserDateMap($data["data"]);
|
||||
$this->updateUserDateMap($data["id"],$data["data"]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
protected function updateUserDateMap($data){
|
||||
protected function updateUserDateMap($data,$values){
|
||||
$mapping = [
|
||||
"fecha_encuadernado_at" => "encuadernacion_user_id",
|
||||
// "fecha_externo_at" => "null",
|
||||
"fecha_impresion_at" => "null",
|
||||
"fecha_impresion_at" => null,
|
||||
"pendiente_ferro_at" => "pendiente_ferro_user_id",
|
||||
"ferro_en_cliente_at" => "ferro_en_cliente_user_id",
|
||||
"ferro_ok_at" => "ferro_ok_user_id",
|
||||
@ -121,12 +121,15 @@ class OrdenTrabajoDate extends Model
|
||||
];
|
||||
$otUser = model(OrdenTrabajoUser::class);
|
||||
$auth_user_id = auth()->user()->id;
|
||||
foreach ($data as $key => $value) {
|
||||
foreach ($values as $key => $value) {
|
||||
if(isset($mapping[$key])){
|
||||
if($value){
|
||||
$otUser->update($data["orden_trabajo_id"],[$mapping[$key] => $auth_user_id]);
|
||||
$otUser->where('orden_trabajo_id',$data['orden_trabajo_id'])
|
||||
->set([$mapping[$key] => $auth_user_id])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ use CodeIgniter\Model;
|
||||
class OrdenTrabajoUser extends Model
|
||||
{
|
||||
protected $table = 'orden_trabajo_users';
|
||||
protected $primaryKey = 'orden_trabajo_id';
|
||||
protected $useAutoIncrement = false;
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = OrdenTrabajoUserEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
@ -45,33 +45,7 @@ class OrdenTrabajoUser extends Model
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [
|
||||
"orden_trabajo_id" => "integer",
|
||||
"user_created_id" => "?integer",
|
||||
"user_update_id" => "?integer",
|
||||
"inaplazable_revised_change_user_id" => "?integer",
|
||||
"ferro_disponible_hecho_user_id" => "?integer",
|
||||
"ferro_disponible_ok_user_id" => "?integer",
|
||||
"ferro_entregado_user_id" => "?integer",
|
||||
"pendiente_ferro_user_id" => "?integer",
|
||||
"ferro_en_cliente_user_id" => "?integer",
|
||||
"ferro_ok_user_id" => "?integer",
|
||||
"interior_bn_user_id" => "?integer",
|
||||
"interior_color_user_id" => "?integer",
|
||||
"preparacion_interior_user_id" => "?integer",
|
||||
"cubierta_user_id" => "?integer",
|
||||
"plastificado_user_id" => "?integer",
|
||||
"encuadernacion_user_id" => "?integer",
|
||||
"corte_user_id" => "?integer",
|
||||
"embalaje_user_id" => "?integer",
|
||||
"entrada_manipulado_user_id" => "?integer",
|
||||
"pre_formato_user_id" => "?integer",
|
||||
"pre_lomo_user_id" => "?integer",
|
||||
"pre_solapa_user_id" => "?integer",
|
||||
"pre_codbarras_user_id" => "?integer",
|
||||
"pre_imposicion_user_id" => "?integer",
|
||||
"pre_imprimir_user_id" => "?integer"
|
||||
];
|
||||
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Controllers\Pedidos\Pedido;
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
@ -1877,7 +1878,7 @@ class PresupuestoService extends BaseService
|
||||
$data_pedido = [
|
||||
'total_precio' => $datos_presupuesto->total_aceptado,
|
||||
'total_tirada' => $datos_presupuesto->tirada,
|
||||
'estado' => $model_cliente->creditoDisponible($datos_presupuesto->cliente_id) ? "produccion" : "validacion",
|
||||
'estado' => $model_cliente->creditoDisponible($datos_presupuesto->cliente_id, $datos_presupuesto->total_aceptado) ? "produccion" : "validacion",
|
||||
'user_created_id' => auth()->user()->id,
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
];
|
||||
@ -1896,6 +1897,9 @@ class PresupuestoService extends BaseService
|
||||
}
|
||||
|
||||
if ($id_linea != 0 && $pedido_id != 0) {
|
||||
if($data_pedido['estado'] == "produccion"){
|
||||
$response = (new Pedido())->to_produccion($pedido_id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -33,7 +33,7 @@ class ProductionService extends BaseService
|
||||
protected array $MAPPING_DATE_USER = [
|
||||
"fecha_encuadernado_at" => "encuadernacion_user_id",
|
||||
// "fecha_externo_at" => "null",
|
||||
"fecha_impresion_at" => "null",
|
||||
"fecha_impresion_at" => null,
|
||||
"pendiente_ferro_at" => "pendiente_ferro_user_id",
|
||||
"ferro_en_cliente_at" => "ferro_en_cliente_user_id",
|
||||
"ferro_ok_at" => "ferro_ok_user_id",
|
||||
@ -44,7 +44,7 @@ class ProductionService extends BaseService
|
||||
"plastificado_at" => "plastificado_user_id",
|
||||
"corte_at" => "corte_user_id",
|
||||
"embalaje_at" => "embalaje_user_id",
|
||||
"entrada_manipulado_at" => "entrada_manipulado_user_id"
|
||||
"entrada_manipulado_at" => "entrada_manipulado_user_id"
|
||||
];
|
||||
|
||||
/**
|
||||
@ -60,13 +60,13 @@ class ProductionService extends BaseService
|
||||
*/
|
||||
protected PresupuestoEntity $presupuesto;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->otModel = model(OrdenTrabajoModel::class);
|
||||
$this->otDate = model(OrdenTrabajoDate::class);
|
||||
$this->otTarea = model(OrdenTrabajoTarea::class);
|
||||
$this->otUser = model(OrdenTrabajoUser::class);
|
||||
$this->userModel = model(UserModel::class);
|
||||
|
||||
}
|
||||
public function init(int $orden_trabajo_id): self
|
||||
{
|
||||
@ -110,7 +110,6 @@ class ProductionService extends BaseService
|
||||
{
|
||||
|
||||
$auth_user = auth()->user();
|
||||
$ot = new OrdenTrabajoEntity();
|
||||
$ot_exists = $this->pedido->orden_trabajo();
|
||||
if ($ot_exists) {
|
||||
return $ot_exists;
|
||||
@ -122,11 +121,8 @@ class ProductionService extends BaseService
|
||||
"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->init($ot_id);
|
||||
$id = $this->otModel->insert($data);
|
||||
$this->init($id);
|
||||
$this->storeOrdenTrabajoUsers();
|
||||
$this->storeOrdenTrabajoDates();
|
||||
$this->storeAllTareas();
|
||||
@ -139,7 +135,7 @@ class ProductionService extends BaseService
|
||||
* @param OrdenTrabajoEntity $ot
|
||||
* @return integer|boolean|string ID
|
||||
*/
|
||||
protected function storeOrdenTrabajoDates() : int|bool|string
|
||||
protected function storeOrdenTrabajoDates(): int|bool|string
|
||||
{
|
||||
$fecha_encuadernado = Time::now()->addDays(2)->format("Y-m-d");
|
||||
$fecha_entrega_real = Time::now()->addDays(5)->format("Y-m-d");
|
||||
@ -153,7 +149,7 @@ class ProductionService extends BaseService
|
||||
"fecha_entrega_externo" => $this->pedido->fecha_entrega_externo,
|
||||
]);
|
||||
}
|
||||
protected function storeOrdenTrabajoUsers() : int|bool|string
|
||||
protected function storeOrdenTrabajoUsers(): int|bool|string
|
||||
{
|
||||
return $this->otUser->insert([
|
||||
"orden_trabajo_id" => $this->ot->id,
|
||||
@ -355,7 +351,7 @@ class ProductionService extends BaseService
|
||||
|
||||
public function getPdf()
|
||||
{
|
||||
return view("themes/vuexy/pdfs/orden_trabajo",$this->getDataPdf());
|
||||
return view("themes/vuexy/pdfs/orden_trabajo", $this->getDataPdf());
|
||||
}
|
||||
/**
|
||||
* Query para mostrar en datatable
|
||||
@ -392,7 +388,7 @@ class ProductionService extends BaseService
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC");
|
||||
return $q;
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Query para mostrar en datatable
|
||||
*
|
||||
* @return BaseBuilder
|
||||
@ -406,8 +402,8 @@ class ProductionService extends BaseService
|
||||
"orden_trabajo_tareas.maquina_id",
|
||||
"lg_maquinas.nombre as maquina_planning_nombre",
|
||||
"ordenes_trabajo.total_tirada as ot_tirada",
|
||||
"lg_papel_formato.ancho as maquina_ancho",
|
||||
"lg_papel_formato.alto as maquina_alto",
|
||||
"lg_papel_formato.ancho as papel_ancho",
|
||||
"lg_papel_formato.alto as papel_alto",
|
||||
// "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') as maquina_ancho",
|
||||
// "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') as maquina_alto",
|
||||
"lg_papel_impresion.nombre as papel_impresion",
|
||||
@ -426,7 +422,7 @@ class ProductionService extends BaseService
|
||||
->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left")
|
||||
->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left")
|
||||
// ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo", ["lp_rot_bn","lp_rot_color"])
|
||||
->whereIn("presupuesto_linea.tipo", ["lp_rot_bn", "lp_rot_color"])
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC");
|
||||
return $q;
|
||||
@ -444,6 +440,7 @@ class ProductionService extends BaseService
|
||||
"orden_trabajo_tareas.nombre",
|
||||
"lgmp.nombre as maquina_presupuesto_linea",
|
||||
"orden_trabajo_tareas.maquina_id as maquina_tarea",
|
||||
|
||||
"lg_maquinas.nombre as maquina_nombre",
|
||||
"lg_imposiciones.id as imposicion_id",
|
||||
"orden_trabajo_tareas.tiempo_estimado",
|
||||
@ -464,20 +461,28 @@ class ProductionService extends BaseService
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC");
|
||||
return $q;
|
||||
}
|
||||
public function papelGramajeDatatableQuery() : BaseBuilder
|
||||
public function papelGramajeDatatableQuery(): BaseBuilder
|
||||
{
|
||||
$q = $this->otModel->builder()->select([
|
||||
"lg_papel_impresion.id as papelImpresionId",
|
||||
"lg_papel_impresion.nombre as papelImpresionNombre",
|
||||
"lg_papel_impresion.gramaje as papelImpresionGramaje",
|
||||
"COUNT(orden_trabajo_tareas.id) as tareasCount",
|
||||
"lg_papel_formato.ancho as papel_ancho",
|
||||
"lg_papel_formato.alto as papel_alto",
|
||||
// "CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') AS DOUBLE) as maquina_ancho",
|
||||
// "CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') AS DOUBLE) as maquina_alto",
|
||||
"SUM(ordenes_trabajo.total_tirada) as totalTirada",
|
||||
"SUM(orden_trabajo_tareas.tiempo_real) as tiempoReal"
|
||||
])
|
||||
->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left")
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->join("lg_papel_impresion","presupuesto_linea.papel_impresion_id = lg_papel_impresion.id","left")
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL,FALSE);
|
||||
->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left")
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->join("presupuestos", "presupuestos.id = presupuesto_linea.presupuesto_id", "right")
|
||||
->join("lg_papel_impresion", "presupuesto_linea.papel_impresion_id = lg_papel_impresion.id", "left")
|
||||
->join("lg_papel_formato", "lg_papel_formato.id = presupuestos.papel_formato_id", "left")
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE)
|
||||
->groupBy('lg_papel_impresion.id');
|
||||
|
||||
|
||||
|
||||
@ -518,7 +523,8 @@ class ProductionService extends BaseService
|
||||
];
|
||||
return $summary;
|
||||
}
|
||||
public function getDataPdf(){
|
||||
public function getDataPdf()
|
||||
{
|
||||
$logistica_data = $this->logistica_data();
|
||||
return [
|
||||
"ot" => $this->ot,
|
||||
@ -539,88 +545,92 @@ class ProductionService extends BaseService
|
||||
"peso_pedido" => $logistica_data["peso_pedido"]
|
||||
];
|
||||
}
|
||||
public function getTareaImpresionSobreCubierta() : array
|
||||
public function getTareaImpresionSobreCubierta(): array
|
||||
{
|
||||
$q = $this->otTarea->select('orden_trabajo_tareas.*')
|
||||
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo",["lp_sobrecubierta"])->findAll();
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo", ["lp_sobrecubierta"])->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function getTareaImpresionCubierta() : array
|
||||
public function getTareaImpresionCubierta(): array
|
||||
{
|
||||
$q = $this->otTarea->select('orden_trabajo_tareas.*')
|
||||
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo",["lp_cubierta"])->findAll();
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo", ["lp_cubierta"])->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function getTareaImpresionInteriorBn() : array
|
||||
public function getTareaImpresionInteriorBn(): array
|
||||
{
|
||||
$q = $this->otTarea->select('orden_trabajo_tareas.*')
|
||||
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo",["lp_rot_bn","lp_bn","lp_bnhq"])->findAll();
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo", ["lp_rot_bn", "lp_bn", "lp_bnhq"])->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function getTareaImpresionInteriorColor() : array
|
||||
public function getTareaImpresionInteriorColor(): array
|
||||
{
|
||||
$q = $this->otTarea->select('orden_trabajo_tareas.*')
|
||||
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo",["lp_rot_color","lp_color","lp_colorhq"])->findAll();
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
|
||||
->whereIn("presupuesto_linea.tipo", ["lp_rot_color", "lp_color", "lp_colorhq"])->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function getPresupuestoLineaImpresion(){
|
||||
}
|
||||
public function getPresupuestoLineaImpresion() {}
|
||||
public function tareas_acabado(): array
|
||||
{
|
||||
$q = $this->otTarea->where("presupuesto_acabado_id IS NOT NULL",NULL,FALSE)->findAll();
|
||||
$q = $this->otTarea->where("presupuesto_acabado_id IS NOT NULL", NULL, FALSE)->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function tareas_impresion(): array
|
||||
{
|
||||
$q = $this->otTarea->where("presupuesto_linea_id IS NOT NULL",NULL,FALSE)->findAll();
|
||||
$q = $this->otTarea->where("presupuesto_linea_id IS NOT NULL", NULL, FALSE)->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function tareas_encuadernacion(): array
|
||||
{
|
||||
$q = $this->otTarea->where("presupuesto_encuadernado_id IS NOT NULL",NULL,FALSE)->findAll();
|
||||
$q = $this->otTarea->where("presupuesto_encuadernado_id IS NOT NULL", NULL, FALSE)->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function tareas_preimpresion(): array
|
||||
{
|
||||
$q = $this->otTarea->where("presupuesto_preimpresion_id IS NOT NULL",NULL,FALSE)->findAll();
|
||||
$q = $this->otTarea->where("presupuesto_preimpresion_id IS NOT NULL", NULL, FALSE)->findAll();
|
||||
return $q;
|
||||
}
|
||||
public function tareas_manipulado(): array
|
||||
{
|
||||
$q = $this->otTarea->where("presupuesto_manipulado_id IS NOT NULL",NULL,FALSE)->findAll();
|
||||
$q = $this->otTarea->where("presupuesto_manipulado_id IS NOT NULL", NULL, FALSE)->findAll();
|
||||
return $q;
|
||||
}
|
||||
/**========================================================================
|
||||
* UPDATES
|
||||
*========================================================================**/
|
||||
|
||||
public function updateOrdenTrabajoTarea($tarea_id,$data) : bool
|
||||
public function updateOrdenTrabajoTarea($tarea_id, $data): bool
|
||||
{
|
||||
return $this->otTarea->update($tarea_id,$data);
|
||||
return $this->otTarea->update($tarea_id, $data);
|
||||
}
|
||||
|
||||
public function updateOrdenTrabajoDate($data)
|
||||
public function updateOrdenTrabajoDate($data)
|
||||
{
|
||||
// return $this->otDate->find($this->ot->id);
|
||||
$r = $this->otDate->update($this->ot->id,$data);
|
||||
// // return $this->otDate->find($this->ot->id);
|
||||
$otDate = $this->otDate->where('orden_trabajo_id', $this->ot->id)
|
||||
->set([$data['name'] => $data[$data['name']]])
|
||||
->update($data);
|
||||
$ot_users = $this->ot->users();
|
||||
$ot_users = $ot_users->toArray();
|
||||
$user_id = $ot_users[$this->MAPPING_DATE_USER[$data["name"]]];
|
||||
$user = $this->userModel->find($user_id);
|
||||
return ["user" => $user,"status" => $r];
|
||||
if($this->MAPPING_DATE_USER[$data["name"]]){
|
||||
$user_id = $ot_users->{$this->MAPPING_DATE_USER[$data["name"]]};
|
||||
$user = $this->userModel->find($user_id);
|
||||
return ["user" => $user, "status" => $otDate];
|
||||
}else{
|
||||
return ["user" => null, "status" => false];
|
||||
}
|
||||
}
|
||||
|
||||
public function updateOrdenTrabajo($data) : bool
|
||||
public function updateOrdenTrabajo($data): bool
|
||||
{
|
||||
return $this->otModel->update($this->ot->id,$data);
|
||||
return $this->otModel->update($this->ot->id, $data);
|
||||
}
|
||||
/**========================================================================
|
||||
* RELATION METHODS
|
||||
@ -678,7 +688,7 @@ class ProductionService extends BaseService
|
||||
{
|
||||
return $this->presupuesto->extras();
|
||||
}
|
||||
protected function logistica_data() : array
|
||||
protected function logistica_data(): array
|
||||
{
|
||||
$presupuesto_lineas = $this->presupuesto->presupuestoLineas();
|
||||
$peso = 0;
|
||||
@ -687,10 +697,12 @@ class ProductionService extends BaseService
|
||||
}
|
||||
return [
|
||||
"peso_unidad" => $peso,
|
||||
"peso_pedido" => $peso*$this->ot->total_tirada
|
||||
"peso_pedido" => $peso * $this->ot->total_tirada
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function actionButtonFilterTask(int $id)
|
||||
{
|
||||
return ["title" => lang('ot.filter_by_task'), 'id' => $id];
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,11 +7,23 @@
|
||||
<th><?= lang('Produccion.datatable.gramaje') ?> (gr)</th>
|
||||
<th><?= lang('Produccion.datatable.tareas') ?></th>
|
||||
<th><?= lang('Produccion.datatable.tiradas') ?></th>
|
||||
<th><?= lang('Produccion.datatable.metros') ?></th>
|
||||
<th><?= lang('Produccion.datatable.tiempo') ?>(HH:MM)</th>
|
||||
<th></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="4" style="text-align:right">Total:</th>
|
||||
<th><span class="autonumeric" id="total-metros"></span>(m)</th>
|
||||
<th id="total-tiempo-papel"></th>
|
||||
<th></th>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
@ -12,9 +12,9 @@
|
||||
<th><?= lang('Produccion.datatable.alto') ?></th>
|
||||
<th><?= lang('Produccion.datatable.papel') ?></th>
|
||||
<th><?= lang('Produccion.datatable.gramaje') ?></th>
|
||||
<!-- <th><?= lang('Produccion.datatable.corte') ?></th>
|
||||
<th><?= lang('Produccion.datatable.metros_sel') ?></th>
|
||||
<th><?= lang('Produccion.datatable.metros_papel') ?></th> -->
|
||||
<th><?= lang('Produccion.datatable.corte') ?></th>
|
||||
<th></th>
|
||||
<th><?= lang('Produccion.datatable.metros') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -25,14 +25,29 @@
|
||||
<th></th>
|
||||
<th><input type="text" class="form-control planning-filter" name="maquina_ancho" placeholder="Ancho"></th>
|
||||
<th><input type="text" class="form-control planning-filter" name="maquina_alto" placeholder="Alto"></th>
|
||||
<th><select class="form-control" name=""></select></th>
|
||||
<th><input type="text" class="form-control planning-filter" name=""></th>
|
||||
<th><select class="select2 form-select select-maquina" id="papel-impresion-select-filter" name="papel_impresion"></select></th>
|
||||
<th><input type="text" class="form-control planning-filter" name="gramaje"></th>
|
||||
<th>
|
||||
<select class="select2 form-select w-100" name="corte">
|
||||
<option value="0" default></option>
|
||||
<option value="1">Guillotina</option>
|
||||
<option value="2">Bobina</option>
|
||||
</select>
|
||||
</th>
|
||||
<th>
|
||||
<div class="form-check mt-4">
|
||||
<input class="form-check-input" id="metros-check-all" type="checkbox" value="" />
|
||||
</div>
|
||||
</th>
|
||||
<th><span class="autonumeric" id="metros-sel-total"></span></th>
|
||||
<th></th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
@ -56,7 +56,19 @@
|
||||
</div>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
<?php if($pedidoEntity->estado == 'validacion' && (!(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')))): ?>
|
||||
<div class="col-md-12 col-lg-2 px-4"></div>
|
||||
<div class="col-md-12 col-lg-4 px-4"></div>
|
||||
<div class="col-md-12 col-lg-3 px-4"></div>
|
||||
<div class="col-md-12 col-lg-3 px-4">
|
||||
<label for="estadoText" class="form-label">
|
||||
<?= lang('Pedidos.importePendiente') ?>
|
||||
</label>
|
||||
<input readonly id="importePendienteText" name="importePendienteText" tabindex="1" maxLength="11" class="form-control" value="<?= old('importePendienteText', $importePendiente) ?>" >
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))) : ?>
|
||||
<div class="accordion accordion mt-3 accordion-without-arrow" id="FechasPedido">
|
||||
<div class="card accordion-item active mt-3 mx-2">
|
||||
|
||||
@ -14,22 +14,58 @@
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link active" role="tab" id="navs-top-align-prot-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-prot"><?= lang("Produccion.planning_rotativa") ?></button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-papel-gramaje-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-papel-gramaje"><?= lang("Produccion.papel_gramajes") ?></button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="prot-datatables-container">
|
||||
<div class="tab-pane fade show active" id="navs-top-align-prot">
|
||||
<?= view("themes/vuexy/components/tables/planning_rot_table.php", ["id" => "planning-rotativa-datatable"]) ?>
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionPapelGramaje">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionPapelGramajeContainer" aria-expanded="false"
|
||||
aria-controls="accordionPapelGramajeContainer">
|
||||
<h4><?= lang("Produccion.papel_gramajes") ?></h4>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="accordionPapelGramajeContainer" class="accordion-collapse collapse show"
|
||||
data-bs-parent="#accordionPapelGramaje">
|
||||
<div class="accordion-body">
|
||||
<?= view("themes/vuexy/components/tables/planning_papel_gramaje_table.php", ["id" => "planning-papel-datatable"]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-papel-gramaje">
|
||||
<?= view("themes/vuexy/components/tables/planning_papel_gramaje_table.php", ["id" => "planning-papel-datatable"]) ?>
|
||||
<div class="tab-pane fade show active" id="navs-top-align-prot">
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionPlanningRotativa">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionPlanningRotativaContainer" aria-expanded="false"
|
||||
aria-controls="accordionPlanningRotativaContainer">
|
||||
<h4><?= lang("Produccion.planning_rotativa") ?></h4>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="accordionPlanningRotativaContainer" class="accordion-collapse collapse show"
|
||||
data-bs-parent="#accordionPlanningRotativa">
|
||||
<div class="accordion-body">
|
||||
<h6 id="papel-impresion-name-header" class="text-secondary "></h6>
|
||||
<?= view("themes/vuexy/components/tables/planning_rot_table.php", ["id" => "planning-rotativa-datatable"]) ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--//.card -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!--//.col -->
|
||||
<!--//.card -->
|
||||
</div>
|
||||
</div>
|
||||
<!--//.col -->
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
@ -3,5 +3,4 @@ import PlanningRotativa from "./planning_rotativa.js";
|
||||
$(function(){
|
||||
const planningRotativa = new PlanningRotativa($("#planning-rotativa-page"));
|
||||
planningRotativa.init();
|
||||
console.log("PL")
|
||||
})
|
||||
@ -1,21 +1,27 @@
|
||||
import ClassSelect from "../../../components/select2.js";
|
||||
import Ajax from "../../../components/ajax.js";
|
||||
|
||||
|
||||
class PlanningRotativa {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.tablePlanningRot = this.item.find("#planning-rotativa-datatable")
|
||||
this.papelGramajeTablePlanning = this.item.find("#planning-papel-datatable")
|
||||
|
||||
this.papelImpresionHeader = this.item.find('#papel-impresion-name-header')
|
||||
this.checkAllMetros = this.item.find("#metros-check-all")
|
||||
this.datatableColumns = [
|
||||
{ data: 'otId', searchable: false, sortable: false },
|
||||
{ data: 'fecha_entrega_real_at', searchable: true, sortable: false },
|
||||
{ data: 'presupuesto_titulo', searchable: true, sortable: false },
|
||||
{ data: 'maquina_planning_nombre', searchable: true, sortable: false },
|
||||
{ data: 'ot_tirada', searchable: false, sortable: false },
|
||||
{ data: 'maquina_ancho', searchable: false, sortable: false },
|
||||
{ data: 'maquina_alto', searchable: false, sortable: false },
|
||||
{ data: 'ot_tirada', searchable: false, sortable: false, },
|
||||
{ data: 'papel_ancho', searchable: false, sortable: false, render: d => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'papel_alto', searchable: false, sortable: false, render: d => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'papel_impresion', searchable: false, sortable: false },
|
||||
{ data: 'papel_gramaje', searchable: false, sortable: false },
|
||||
{ data: 'papel_gramaje', searchable: false, sortable: false, render: d => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'corte', searchable: false, sortable: false, render: d => d },
|
||||
{ data: 'metros_check', searchable: false, sortable: false, render: d => `<input class="form-check-input metros-check" data-id="${d}" type="checkbox" value="" />` },
|
||||
{ data: 'metros', searchable: false, sortable: false, render: d => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'action', searchable: false, sortable: false, render: this._renderBtnAction },
|
||||
|
||||
]
|
||||
@ -24,20 +30,39 @@ class PlanningRotativa {
|
||||
{ data: 'papelImpresionGramaje', searchable: true, sortable: true },
|
||||
{ data: 'tareasCount', searchable: true, sortable: true },
|
||||
{ data: 'totalTirada', searchable: false, sortable: false },
|
||||
{ data: 'metros', searchable: false, sortable: false, render: d => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'tiempoReal', searchable: false, sortable: false },
|
||||
{
|
||||
data: 'action', searchable: false, sortable: false, render: (d) => {
|
||||
return `<button type="button" class="btn btn-primary btn-sm w-100 papel-gramaje-btn" data-id="${d.data.papelImpresionId}" data-bs-toggle="button">${d.title}</button>`
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
]
|
||||
this.maquinaSelectFilter = new ClassSelect($("#maquina-select-filter"), `/maquinas/select`, "Seleccione una maquina", true);
|
||||
this.maquinaSelectFilter = new ClassSelect($("#maquina-select-filter"), `/maquinas/select`, "Seleccione una maquina", true, {}, $('body'));
|
||||
this.papelImpresionFilter = new ClassSelect($("#papel-impresion-select-filter"), `/papelesimpresion/select`, "Seleccione un papel", true, {}, $('body'));
|
||||
this.maquinaSelectFilter.config.dropdownParent = this.item
|
||||
}
|
||||
init() {
|
||||
this.maquinaSelectFilter.init()
|
||||
this.papelImpresionFilter.init()
|
||||
this.checkAllMetros.on('change', () => {
|
||||
let isChecked = this.checkAllMetros.prop('checked')
|
||||
this.item.find(".metros-check").prop('checked', isChecked).trigger("change")
|
||||
})
|
||||
this.papelGramajeTablePlanning.on('click', '.papel-gramaje-btn', this.filterPapelGramaje.bind(this))
|
||||
this.papelImpresionFilter.onChange(() => {
|
||||
this.papelImpresionHeader.text(this.papelImpresionFilter.getText())
|
||||
})
|
||||
|
||||
this.datatablePlanningRot = this.tablePlanningRot.DataTable({
|
||||
processing: true,
|
||||
orderCellsTop: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
topStart: 'info',
|
||||
topEnd: null,
|
||||
bottomStart: 'pageLength',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
|
||||
@ -52,10 +77,12 @@ class PlanningRotativa {
|
||||
});
|
||||
this.papelGramajeDatatable = this.papelGramajeTablePlanning.DataTable({
|
||||
processing: true,
|
||||
orderCellsTop: true,
|
||||
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
topStart: 'info',
|
||||
topEnd: null,
|
||||
bottomStart: 'pageLength',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
|
||||
@ -77,14 +104,75 @@ class PlanningRotativa {
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatablePlanningRot.column(columnIndex).search(this.maquinaSelectFilter.getText()).draw()
|
||||
})
|
||||
this.item.on("change", "#papel-impresion-select-filter", (event) => {
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatablePlanningRot.column(columnIndex).search(this.papelImpresionFilter.getText()).draw()
|
||||
})
|
||||
this.papelGramajeDatatable.on('draw', this.addTotalFooter.bind(this))
|
||||
this.tablePlanningRot.on('change', ".metros-check", this.calcMetrosCheck.bind(this))
|
||||
|
||||
}
|
||||
_renderBtnAction(d) {
|
||||
return `<a type="button" href="/produccion/ordentrabajo/edit/${d.otId}" class="btn btn-md btn-primary ot-tarea-comment" data-id="${d.otId}"><i class="ti ti-building-factory-2 ti-sm mx-2"></i> Ver orden</a>`
|
||||
return `<a href="/produccion/ordentrabajo/edit/${d.otId}" class="ot-tarea-comment" data-id="${d.otId}"><i class="ti ti-eye"></i></a>`
|
||||
}
|
||||
_columnFiltering() {
|
||||
this.api().columns()
|
||||
console.log(this.api().columns())
|
||||
}
|
||||
filterPapelGramaje(event) {
|
||||
const papelImpresionId = $(event.currentTarget).data('id')
|
||||
this.getPapelImpresion(papelImpresionId)
|
||||
}
|
||||
getPapelImpresion(papelImpresionId) {
|
||||
let ajax = new Ajax('/papelesimpresion/show/' + papelImpresionId,
|
||||
null,
|
||||
null,
|
||||
this.getPapelImpresionSuccess.bind(this),
|
||||
this.getPapelImpresionError.bind(this)
|
||||
)
|
||||
ajax.get()
|
||||
}
|
||||
getPapelImpresionSuccess(response) {
|
||||
this.papelImpresionFilter.setOption(response.id, response.nombre)
|
||||
this.papelImpresionHeader.text(response.nombre)
|
||||
}
|
||||
getPapelImpresionError(response) { }
|
||||
formatSeconds(s) {
|
||||
return [parseInt(s / 60 / 60), parseInt(s / 60 % 60)].join(':').replace(/\b(\d)\b/g, '0$1');
|
||||
}
|
||||
addTotalFooter() {
|
||||
const data = this.papelGramajeDatatable.column(5).data().reduce((a, b) => {
|
||||
let sa = a.split(":")
|
||||
let ha = parseInt(sa[0]) * 3600
|
||||
let ma = parseInt(sa[1]) * 60
|
||||
let sb = b.split(":")
|
||||
let hb = parseInt(sb[0]) * 3600
|
||||
let mb = parseInt(sb[1]) * 60
|
||||
return hb + mb + ha + ma
|
||||
})
|
||||
const metros = this.papelGramajeDatatable.column(4).data().reduce((a, b) => {
|
||||
|
||||
return a + b
|
||||
})
|
||||
$('#total-tiempo-papel').text(this.formatSeconds(data))
|
||||
$('#total-metros').text(metros)
|
||||
|
||||
}
|
||||
calcMetrosCheck() {
|
||||
const metros_sel = this.datatablePlanningRot.rows((idx, data, node) => {
|
||||
return $(node).find('input[type="checkbox"]').prop('checked');
|
||||
}).data().toArray().reduce((a, b) => {
|
||||
a = a?.metros ?? 0
|
||||
b = b?.metros ?? 0
|
||||
return a + b
|
||||
}, null)
|
||||
this.item.find('#metros-sel-total').text(metros_sel)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export default PlanningRotativa;
|
||||
@ -23,6 +23,9 @@ $(() => {
|
||||
null,
|
||||
null,
|
||||
(response) => {
|
||||
if(response.status){
|
||||
location.reload()
|
||||
}
|
||||
Swal.fire({
|
||||
title: response.message,
|
||||
icon: 'success',
|
||||
|
||||
Reference in New Issue
Block a user