feat colors

This commit is contained in:
amazuecos
2025-04-14 20:41:23 +02:00
parent 137d5b9db2
commit ebf0a9d5d7
6 changed files with 154 additions and 16 deletions

View File

@ -40,6 +40,18 @@ class OrdenTrabajo extends BaseConfig
"fecha_encuadernado" => "fecha_encuadernado_change_user_id",
"fecha_entrega_externo" => "fecha_entrega_externo_change_user_id",
];
public array $OT_COLORS = [
"sin_imprimir" => "#FF6363",
"impreso_int" => "#AFDDFF",
"impreso_cub" => "#3A59D1",
"plastificado" => "#FFD63A",
"solapas" => "#4F1C51",
"preparado" => "#FF0B55",
"cosido" => "#FF0B55",
"grapado" => "#FEBA17",
"encuadernado" => "#FEBA17",
"corte" => "#67AE6E"
];
public function __construct()
{

View File

@ -133,7 +133,7 @@ class Ordentrabajo extends BaseController
try {
$bodyData = $this->request->getPost();
$r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoPedido($bodyData);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r,"data" => $bodyData]);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]);
} catch (\Throwable $th) {
return $this->response->setJSON(["errors" => $th->getMessage(), "status" => false])->setStatusCode(500);
}
@ -163,7 +163,7 @@ class Ordentrabajo extends BaseController
$q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado", "F");
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
@ -178,7 +178,7 @@ class Ordentrabajo extends BaseController
$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) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
@ -193,7 +193,7 @@ class Ordentrabajo extends BaseController
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at", null);
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
@ -208,7 +208,7 @@ class Ordentrabajo extends BaseController
$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) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : ""

View File

@ -43,9 +43,38 @@ class OrdenTrabajoDateEntity extends Entity
'deleted_at',
];
protected $casts = [
];
protected $casts = [];
public function sinImprimirStatus(): bool
{
return !(
$this->attributes['interior_bn_at'] == null
&& $this->attributes['interior_color_at'] == null
&& $this->attributes['cubierta_at'] == null
);
}
public function impresionInteriorStatus():bool
{
return $this->attributes['interior_bn_at']|| $this->attributes['interior_color_at'];
}
public function impresionCubiertaStatus():bool
{
return $this->attributes['cubierta_at'] != null;
}
public function plastificadoStatus():bool
{
return $this->attributes['plastificado_at'] != null;
}
public function encuadernadoStatus():bool
{
return $this->attributes['encuadernacion_at'] != null;
}
public function preparacionInterioresStatus():bool
{
return $this->attributes['preparacion_interiores_at'] != null;
}
public function corteStatus():bool
{
return $this->attributes['corte_at'] != null;
}
}

View File

@ -50,6 +50,7 @@ class ProductionService extends BaseService
protected MaquinaEntity $defaultMaquinaCorte;
protected MaquinaModel $maquinaModel;
protected OrdenTrabajo $ordenTrabajoConfig;
public string $statusColor;
/**
* Pedido Entity
@ -74,6 +75,7 @@ class ProductionService extends BaseService
$this->otFileModel = model(OrdenTrabajoFileModel::class);
$this->pedidoModel = model(PedidoModel::class);
$this->ordenTrabajoConfig = config('OrdenTrabajo');
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"];
}
public function init(int $orden_trabajo_id): self
{
@ -83,6 +85,7 @@ class ProductionService extends BaseService
$pedido = $this->ot->pedido();
$this->setPedido($pedido);
$this->defaultMaquinaCorte = $this->maquinaModel->where('nombre', $this->defaultMaquinaCorteName)->first();
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"];
return $this;
}
/**
@ -631,6 +634,7 @@ class ProductionService extends BaseService
"tareas_preimpresion" => $this->tareas_preimpresion(),
"tareas_impresion" => $this->tareas_impresion(),
"tiempo_procesamiento" => $this->getTiempoProcesamientoHHMM(),
"statusColor" => $this->getOtColorStatus(),
];
return $summary;
}
@ -1107,10 +1111,81 @@ class ProductionService extends BaseService
}
$progreso = (float) $fill_dates / $total * 100;
$status = $this->otModel->update($this->ot->id, ["progreso" => round($progreso,2)]);
}else{
$status = $this->otModel->update($this->ot->id, ["progreso" => round($progreso, 2)]);
} else {
$status = $this->otModel->update($this->ot->id, ["progreso" => 100]);
}
return $status;
}
public function getOtColorStatus(): string
{
if($this->ot->dates()){
$this->updateColor();
}
return $this->statusColor;
}
protected function otSinImprimirColor()
{
if ($this->ot->dates()->sinImprimirStatus()) {
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"];
};
}
protected function otImpresionIntColor()
{
if ($this->ot->dates()->impresionInteriorStatus()) {
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["impreso_int"];
};
}
protected function otImpresionCubiertaColor()
{
if ($this->ot->dates()->impresionCubiertaStatus()) {
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["impreso_cub"];
};
}
protected function otPlastificadoColor()
{
if ($this->ot->dates()->plastificadoStatus()) {
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["plastificado"];
};
}
protected function otSolapaColor()
{
}
protected function otEncuadernadoColor()
{
if ($this->ot->dates()->encuadernadoStatus()) {
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["encuadernado"];
};
}
protected function otPreparadoColor()
{
if ($this->ot->dates()->preparacionInterioresStatus()) {
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["preparado"];
};
}
protected function otCorteColor()
{
if ($this->ot->dates()->corteStatus()) {
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["corte"];
};
}
protected function otCosidoColor()
{
}
protected function otGrapadoColor()
{
}
protected function updateColor(){
$this->otSinImprimirColor();
$this->otImpresionIntColor();
$this->otCosidoColor();
$this->otImpresionCubiertaColor();
$this->otPlastificadoColor();
$this->otSolapaColor();
$this->otPreparadoColor();
$this->otGrapadoColor();
$this->otEncuadernadoColor();
$this->otCorteColor();
}
}

View File

@ -1,6 +1,6 @@
<div class="table-responsive">
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;">
<table id="<?= $id ?>" class="table table-hover text-dark" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Produccion.datatable.pedido_id') ?></th>

View File

@ -55,6 +55,7 @@ class OrdenTrabajoDatatable {
},
columnDefs: [
{ className: 'dt-center', targets: '_all' },
],
serverSide: true,
pageLength: 25,
@ -62,7 +63,10 @@ class OrdenTrabajoDatatable {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/produccion/ordentrabajo/datatable'
ajax: '/produccion/ordentrabajo/datatable',
createdRow: (row,data,dataIndex) => {
$(row).css("background-color",data.logo.color)
}
});
}
initPendientes() {
@ -76,6 +80,7 @@ class OrdenTrabajoDatatable {
},
columnDefs: [
{ className: 'dt-center', targets: '_all' },
],
serverSide: true,
pageLength: 25,
@ -83,7 +88,10 @@ class OrdenTrabajoDatatable {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/produccion/ordentrabajo/datatable_pendientes'
ajax: '/produccion/ordentrabajo/datatable_pendientes',
createdRow: (row,data,dataIndex) => {
$(row).css("background-color",data.logo.color)
}
});
}
initFerroPendiente() {
@ -97,11 +105,18 @@ class OrdenTrabajoDatatable {
},
serverSide: true,
pageLength: 25,
columnDefs: [
{ className: 'dt-center', targets: '_all' },
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/produccion/ordentrabajo/datatable_ferro_pendiente'
ajax: '/produccion/ordentrabajo/datatable_ferro_pendiente',
createdRow: (row,data,dataIndex) => {
$(row).css("background-color",data.logo.color)
}
});
}
initFerroOk() {
@ -114,12 +129,19 @@ class OrdenTrabajoDatatable {
bottomEnd: 'paging'
},
serverSide: true,
columnDefs: [
{ className: 'dt-center', targets: '_all' },
],
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/produccion/ordentrabajo/datatable_ferro_ok'
ajax: '/produccion/ordentrabajo/datatable_ferro_ok',
createdRow: (row,data,dataIndex) => {
$(row).css("background-color",data.logo.color)
}
});
}