add revision preimpresion ot

This commit is contained in:
amazuecos
2025-05-02 21:02:53 +02:00
parent 5138681718
commit a88ffda50d
8 changed files with 119 additions and 20 deletions

View File

@ -287,7 +287,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery();
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.preimpresion_revisada',false);
return DataTable::of($q)
->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(

View File

@ -0,0 +1,33 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AlterOrdenesTrabajoAddCommentColumns extends Migration
{
protected array $COLUMNS = [
'preimpresion_revisada' => [
'type' => 'BOOL',
'default' => false
],
'preimpresion_revisada_by' => [
'type' => 'INT',
'unsigned' => true,
'constraint' => 11,
],
];
public function up()
{
$this->forge->addColumn('ordenes_trabajo',$this->COLUMNS);
$this->forge->addForeignKey('preimpresion_revisada_by','users','id','NULL','NULL');
$this->forge->processIndexes('ordenes_trabajo');
}
public function down()
{
$this->forge->dropForeignKey('ordenes_trabajo','ordenes_trabajo_preimpresion_revisada_by_foreign');
$this->forge->dropColumn('ordenes_trabajo',array_keys($this->COLUMNS));
}
}

View File

@ -45,6 +45,9 @@ class OrdenTrabajoEntity extends Entity
"portada_path" => null,
"is_pedido_espera" => null,
"pedido_espera_by" => null,
"preimpresion_revisada" => false,
"preimpresion_revisada_by" => null,
];
protected $casts = [
"pedido_id" => "integer",
@ -72,6 +75,7 @@ class OrdenTrabajoEntity extends Entity
"enviar_impresion" => "bool",
"portada_path" => "string",
"is_pedido_espera" => "bool",
"preimpresion_revisada" => "bool",
];
@ -178,10 +182,23 @@ class OrdenTrabajoEntity extends Entity
return null;
}
}
public function preimpresionRevisadaUser(): ?UserEntity
{
$m = model(UserModel::class);
if ($this->attributes['preimpresion_revisada_by']) {
return $m->findById($this->attributes['preimpresion_revisada_by']);
} else {
return null;
}
}
public function getPedidoEsperaBy(): ?UserEntity
{
return $this->pedidoEsperaBy();
}
public function getPreimpresionRevisadaBy(): ?UserEntity
{
return $this->preimpresionRevisadaUser();
}
public function getFullPath(): ?string
{
helper('filesystem');

View File

@ -97,6 +97,7 @@ return [
"papel_gramajes" => "Papel y gramajes",
"estado" => "Estado",
"pedido_espera" => "Pedido en espera",
"preimpresion_revisada" => "Preimpresión revisada",
"imposicion_no_label" => "Sin etiqueta",
"pliegos_de" => "pliegos de",
"size" => "Tamaño",

View File

@ -39,7 +39,10 @@ class OrdenTrabajoModel extends Model
"enviar_impresion",
"portada_path",
"is_pedido_espera",
"pedido_espera_by"
"pedido_espera_by",
"preimpresion_revisada",
"preimpresion_revisada_by",
];
protected bool $allowEmptyInserts = false;

View File

@ -259,7 +259,7 @@ class ProductionService extends BaseService
*
* @return self
*/
public function createOrdenTrabajo(): OrdenTrabajoEntity|DatabaseException
public function createOrdenTrabajo(bool $imported = false): OrdenTrabajoEntity|DatabaseException
{
$auth_user = auth()->user();
@ -272,7 +272,8 @@ class ProductionService extends BaseService
"user_created_id" => $auth_user->id,
"user_updated_id" => $auth_user->id,
"total_tirada" => $this->pedido->total_tirada,
"total_precio" => $this->pedido->total_precio
"total_precio" => $this->pedido->total_precio,
"preimpresion_revisada" => $imported
];
$id = $this->otModel->insert($data);
$this->init($id);
@ -1116,6 +1117,9 @@ class ProductionService extends BaseService
if (isset($data["is_pedido_espera"])) {
$data["pedido_espera_by"] = auth()->user()->id;
}
if (isset($data["preimpresion_revisada"])) {
$data["preimpresion_revisada_by"] = auth()->user()->id;
}
return $this->otModel->update($this->ot->id, $data);
}
public function updateOrdenTrabajoPedido($data)
@ -1906,7 +1910,7 @@ class ProductionService extends BaseService
"tarea_progress.estado as tareaEstado"
])
->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left")
// Obtener el ultimo estado de la tarea
//* Obtener el ultimo estado de la tarea
->join(
'(SELECT ot_tarea_id, estado
FROM orden_trabajo_tarea_progress_dates
@ -1922,7 +1926,8 @@ class ProductionService extends BaseService
->join("pedidos", "pedidos.id = ordenes_trabajo.pedido_id", "right")
->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left")
->where('orden_trabajo_tareas.maquina_id', $maquina_id)
// ->where('pedidos.fecha_impresion IS NOT NULL', null, false)
// ->where('pedidos.fecha_impresion IS NOT NULL', null, false) //! Dejar comentado por ahora
->where('ordenes_trabajo.preimpresion_revisada', true)
->where("orden_trabajo_tareas.deleted_at", null)
->where("tarea_progress.estado", 'P')
->orderBy("pedidos.fecha_impresion", "ASC")

View File

@ -12,15 +12,37 @@
<div id="accordionOtProgressTip" class="accordion-collapse collapse show" data-bs-parent="#accordionOtProgress">
<div class="accordion-body">
<div class="row">
<div class="col-md-12 mb-3">
<div class="row justify-content-start align-items-center">
<div class="col-md-8 mb-3">
<label class="form-label" for="ot-progress-bar-parent"><?= @lang("App.progress") ?></label>
<div class="progress" style="height: 25px;" id="ot-progress-bar-parent">
<div id="ot-progress-bar" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="col-md-2 col-6">
<div class="d-flex align-items-center">
<div class="badge rounded-pill bg-label-primary me-3 p-2">
<i class="ti ti-clock ti-lg"></i>
</div>
<div class="row">
<div class="card-info">
<h5 class="mb-0 tiempo-estimado" id="ot-tiempo-estimado"><?= $tiempo_estimado ?></h5>
<span class="fx-large"><?= @lang("Produccion.tiempo_estimado") ?></span>
</div>
</div>
</div>
<div class="col-md-2 col-6">
<div class="d-flex align-items-center">
<div class="badge rounded-pill bg-label-warning me-3 p-2">
<i class="ti ti-clock ti-lg"></i>
</div>
<div class="card-info">
<h5 class="mb-0 tiempo-estimado" id="tiempo-total"></h5>
<span class="fx-large"><?= @lang("Produccion.tiempo_consumido") ?></span>
</div>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-md-3 <?= $user_dates["pre_formato_at"] || $user_dates["pre_lomo_at"] || $user_dates["pre_solapa_at"] || $user_dates["pre_codbarras_at"] || $user_dates["pre_imposicion_at"] ? "" : "d-none" ?>">
<!-- PREIMPRESION -->
<!-- Preformato -->
@ -318,16 +340,7 @@
</div>
</div>
<div class="row">
<div class="row">
<span><?= @lang("Produccion.tiempo_estimado") ?>(HH:MM)</span>
<span class="tiempo-estimado"> <?= $tiempo_estimado ?></span>
</div>
<div class="row">
<span><?= @lang("Produccion.tiempo_consumido") ?>(HH:MM)</span>
<span id="tiempo-total"></span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="d-flex flex-row justify-content-between align-items-center">
@ -344,12 +357,31 @@
<span class="switch-label fw-lg"><?= @lang("Produccion.pedido_espera") ?></span>
<span class="badge text-bg-warning fw-lg" id="pedido_espera_by"></span>
</label>
</div>
</div>
<div class="col-md-12 mt-2">
<div class="d-flex flex-row justify-content-between align-items-center">
<label class="switch switch-success switch-lg mt-1">
<input type="checkbox" class="switch-input ot-preview" id="ot-preimpresion-revisada" name="preimpresion_revisada" data-input <?= $is_finalizada ? "disabled" : "" ?> />
<span class="switch-toggle-slider">
<span class="switch-on">
<i class="ti ti-check"></i>
</span>
<span class="switch-off">
<i class="ti ti-x"></i>
</span>
</span>
<span class="switch-label fw-lg"><?= @lang("Produccion.preimpresion_revisada") ?></span>
<span class="badge text-bg-primary fw-lg" id="preimpresion_revisada_by"></span>
</label>
<?php if ($is_finalizada): ?>
<button type="button" id="btn-reactivar-orden-pedido" class="btn btn-primary btn-block"><?= @lang("Produccion.reactivar_orden") ?></button>
<?php else: ?>
<button type="button" id="btn-finalizar-orden-pedido" class="btn btn-warning btn-block"><?= @lang("Produccion.finalizar_orden") ?></button>
<?php endif; ?>
</div>
</div>
</div>

View File

@ -25,7 +25,9 @@ class OrdenTrabajo {
this.tiempoEstimado = this.item.find('#tiempo-estimado')
this.btnResetTareas = this.item.find("#btn-reset-tareas")
this.pedidoEnEsperaCheck = this.item.find("#ot-pedido-espera");
this.otPreimpresionRevisadaCheck = this.item.find("#ot-preimpresion-revisada");
this.pedidoEnEsperaBy = this.item.find("#pedido_espera_by");
this.otPreimpresionRevisadaUser = this.item.find("#preimpresion_revisada_by");
this.otEstado = this.item.find("#ot-estado");
this.datatableColumns = [
@ -516,12 +518,18 @@ class OrdenTrabajo {
this.embalaje.setDate(this.summaryData.dates.embalaje_at)
this.envio.setDate(this.summaryData.dates.envio_at)
this.pedidoEnEsperaCheck.prop("checked", this.summaryData.ot.is_pedido_espera);
this.otPreimpresionRevisadaCheck.prop("checked", this.summaryData.ot.preimpresion_revisada);
this.tiempoProcesamiento.val(this.summaryData.tiempo_procesamiento);
if (this.summaryData.ot.pedido_espera_by) {
this.pedidoEnEsperaBy.text([this.summaryData.ot.pedido_espera_by.first_name, this.summaryData.ot.pedido_espera_by.last_name].join(" "))
} else {
this.pedidoEnEsperaBy.text("");
}
if (this.summaryData.ot.preimpresion_revisada_by) {
this.otPreimpresionRevisadaUser.text([this.summaryData.ot.preimpresion_revisada_by.first_name, this.summaryData.ot.preimpresion_revisada_by.last_name].join(" "))
} else {
this.otPreimpresionRevisadaUser.text("")
}
this.otEstado.val(this.summaryData.ot.estado)
this.preFormatoAt.setDate(this.summaryData.dates.pre_formato_at)
this.preLomoAt.setDate(this.summaryData.dates.pre_lomo_at)