mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
colores header pdf ot
This commit is contained in:
@ -16,6 +16,7 @@ use CodeIgniter\Config\BaseService;
|
||||
use App\Entities\Configuracion\Maquina as MaquinaEntity;
|
||||
use App\Entities\Produccion\OrdenTrabajoFileEntity;
|
||||
use App\Entities\Produccion\OrdenTrabajoTareaEntity;
|
||||
use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity;
|
||||
use App\Models\Configuracion\ConfigVariableModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoFileModel;
|
||||
@ -46,7 +47,10 @@ class ProductionService extends BaseService
|
||||
protected OrdenTrabajoFileModel $otFileModel;
|
||||
protected PedidoModel $pedidoModel;
|
||||
protected UserModel $userModel;
|
||||
protected ConfigVariableModel $configVariableModel;
|
||||
protected string $defaultMaquinaCorteName = 'HT-1000';
|
||||
protected int $podValue = 0;
|
||||
protected bool $isPOD = false;
|
||||
protected MaquinaEntity $defaultMaquinaCorte;
|
||||
protected MaquinaModel $maquinaModel;
|
||||
protected OrdenTrabajo $ordenTrabajoConfig;
|
||||
@ -76,6 +80,8 @@ class ProductionService extends BaseService
|
||||
$this->pedidoModel = model(PedidoModel::class);
|
||||
$this->ordenTrabajoConfig = config('OrdenTrabajo');
|
||||
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"];
|
||||
$this->configVariableModel = model(ConfigVariableModel::class);
|
||||
$this->podValue = $this->configVariableModel->getVariable('POD')->value;
|
||||
}
|
||||
public function init(int $orden_trabajo_id): self
|
||||
{
|
||||
@ -106,6 +112,7 @@ class ProductionService extends BaseService
|
||||
$this->otModel = model(OrdenTrabajoModel::class);
|
||||
$this->otDate = model(OrdenTrabajoDate::class);
|
||||
$this->otTarea = model(OrdenTrabajoTarea::class);
|
||||
$this->isPOD = $this->presupuesto->tirada <= $this->podValue;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
@ -179,8 +186,7 @@ class ProductionService extends BaseService
|
||||
public function reInsertOrdenTrabajoUsers(): int|bool|string
|
||||
{
|
||||
$status = false;
|
||||
if($this->otUser->where('orden_trabajo_id',$this->ot->id)->countAllResults() == 0)
|
||||
{
|
||||
if ($this->otUser->where('orden_trabajo_id', $this->ot->id)->countAllResults() == 0) {
|
||||
$status = $this->storeOrdenTrabajoUsers();
|
||||
}
|
||||
return $status;
|
||||
@ -188,8 +194,7 @@ class ProductionService extends BaseService
|
||||
public function reInsertOrdenTrabajoDates(): int|bool|string
|
||||
{
|
||||
$status = false;
|
||||
if($this->otDate->where('orden_trabajo_id',$this->ot->id)->countAllResults() == 0)
|
||||
{
|
||||
if ($this->otDate->where('orden_trabajo_id', $this->ot->id)->countAllResults() == 0) {
|
||||
$status = $this->storeOrdenTrabajoDates();
|
||||
}
|
||||
return $status;
|
||||
@ -683,6 +688,10 @@ class ProductionService extends BaseService
|
||||
"peso_pedido" => $logistica_data["peso_pedido"],
|
||||
"imposicion" => $this->getImposicionTareaImpresion(),
|
||||
"tiempo_procesamiento" => $this->getTiempoProcesamientoHHMM(),
|
||||
"tiempo_impresion" => $this->getTiempoTareasImpresionHHMM(),
|
||||
"colors" => $this->getPdfColors(),
|
||||
"isPOD" => $this->isPOD,
|
||||
"uvi" => $this->getUVI()
|
||||
|
||||
];
|
||||
}
|
||||
@ -774,7 +783,7 @@ class ProductionService extends BaseService
|
||||
{
|
||||
$result = [];
|
||||
$otDate = $this->otDate->where('orden_trabajo_id', $this->ot->id)
|
||||
->set($data['name'],$data[$data['name']])
|
||||
->set($data['name'], $data[$data['name']])
|
||||
->update();
|
||||
$this->otDate->updateUserDateMap($this->ot->id, $data);
|
||||
$ot_users = $this->ot->users();
|
||||
@ -1117,6 +1126,24 @@ class ProductionService extends BaseService
|
||||
$seconds = array_sum($time_tareas_seconds);
|
||||
return float_seconds_to_hhmm_string($seconds);
|
||||
}
|
||||
public function getTiempoTareasImpresionHHMM():string {
|
||||
$tareas_impresion = $this->ot->tareas_impresion();
|
||||
$time_tareas_seconds = array_map(fn($q) => $q->tiempo_estimado ?? 0, $tareas_impresion);
|
||||
$seconds = array_sum($time_tareas_seconds);
|
||||
return float_seconds_to_hhmm_string($seconds);
|
||||
|
||||
}
|
||||
public function getUVI() : ?TarifaAcabadoEntity
|
||||
{
|
||||
$uvi = null;
|
||||
$acabados = $this->presupuesto->acabados();
|
||||
foreach ($acabados as $key => $acabado) {
|
||||
if($acabado->tarifa()->isUVI()){
|
||||
$uvi = $acabado->tarifa();
|
||||
}
|
||||
}
|
||||
return $uvi;
|
||||
}
|
||||
public function updateProgress(): bool
|
||||
{
|
||||
$userDates = $this->ordenTrabajoConfig->DATE_USER_MAPPING;
|
||||
@ -1142,7 +1169,7 @@ class ProductionService extends BaseService
|
||||
}
|
||||
public function getOtColorStatus(): string
|
||||
{
|
||||
if($this->ot->dates()){
|
||||
if ($this->ot->dates()) {
|
||||
$this->updateColor();
|
||||
}
|
||||
return $this->statusColor;
|
||||
@ -1207,7 +1234,8 @@ class ProductionService extends BaseService
|
||||
$this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["grapado"];
|
||||
};
|
||||
}
|
||||
protected function updateColor(){
|
||||
protected function updateColor()
|
||||
{
|
||||
$this->otSinImprimirColor();
|
||||
$this->otImpresionIntColor();
|
||||
$this->otCosidoColor();
|
||||
@ -1219,4 +1247,141 @@ class ProductionService extends BaseService
|
||||
$this->otEncuadernadoColor();
|
||||
$this->otCorteColor();
|
||||
}
|
||||
public function getEncuadernacionCode(): ?string
|
||||
{
|
||||
$code = "";
|
||||
$encuadernaciones = $this->presupuesto->encuadernaciones();
|
||||
if (isset($encuadernaciones[0])) {
|
||||
$code = $encuadernaciones[0]->tarifa()->code;
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
public function getEncuadernacionColor(): array
|
||||
{
|
||||
$color = $this->ordenTrabajoConfig->OT_ENCUADERNACION_COLOR["default"];
|
||||
$encuadernacion_code = $this->getEncuadernacionCode();
|
||||
if ($encuadernacion_code) {
|
||||
if (isset($this->ordenTrabajoConfig->OT_ENCUADERNACION_COLOR[$encuadernacion_code])) {
|
||||
$color = $this->ordenTrabajoConfig->OT_ENCUADERNACION_COLOR[$encuadernacion_code];
|
||||
}
|
||||
}
|
||||
return $color;
|
||||
}
|
||||
public function getWeekDayColor(): array
|
||||
{
|
||||
$color = $this->ordenTrabajoConfig->OT_WEEK_COLOR_DAY[0];
|
||||
if ($this->ot->pedido()->fecha_encuadernado) {
|
||||
$week_day = Time::createFromFormat("Y-m-d H:i:s", $this->ot->pedido()->fecha_encuadernado)->getDayOfWeek();
|
||||
$color = $this->ordenTrabajoConfig->OT_WEEK_COLOR_DAY[$week_day];
|
||||
}
|
||||
return $color;
|
||||
}
|
||||
public function getGeneralBackgroundColor()
|
||||
{
|
||||
$color = $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['default'];
|
||||
$is_ferro_or_prototipo = ($this->presupuesto->ferro || $this->presupuesto->ferro_digital || $this->presupuesto->prototipo);
|
||||
$color = $is_ferro_or_prototipo ? $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['ferro'] : $color;
|
||||
$color = $this->isPOD ? $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['pod'] : $color;
|
||||
$color = $this->pedido->inaplazable ? $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['inaplazable'] : $color;
|
||||
return $color;
|
||||
}
|
||||
public function getPapelImpresionBackgroundColor()
|
||||
{
|
||||
$papel = $this->presupuesto->presupuestoLineaImpresion()->papel_generico();
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['default'];
|
||||
$papel_code = $papel->code_ot;
|
||||
if ($papel_code) {
|
||||
if (strpos($papel_code, "BCLOF")) {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
|
||||
}
|
||||
if (strpos($papel_code, "AH") && $papel->code == "OFF2") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['ahuesado'];
|
||||
}
|
||||
if (strpos($papel_code, "MARF")) {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['marfil'];
|
||||
}
|
||||
if (strpos($papel_code, "VOLAH")) {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['volumen_ahuesado'];
|
||||
}
|
||||
if ($papel_code == "EM") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['estucado_mate'];
|
||||
}
|
||||
if ($papel_code == "CGE") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['cartulina'];
|
||||
}
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
public function getPapelImpresionCubiertaBackgroundColor()
|
||||
{
|
||||
$papel = $this->presupuesto->presupuestoLineaCubierta()->papel_generico();
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['default'];
|
||||
$papel_code = $papel->code_ot;
|
||||
if ($papel_code) {
|
||||
if (strpos($papel_code, "BCLOF")) {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
|
||||
}
|
||||
if (strpos($papel_code, "AH") && $papel->code == "OFF2") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['ahuesado'];
|
||||
}
|
||||
if (strpos($papel_code, "MARF")) {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['marfil'];
|
||||
}
|
||||
if (strpos($papel_code, "VOLAH")) {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['volumen_ahuesado'];
|
||||
}
|
||||
if ($papel_code == "EM") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['estucado_mate'];
|
||||
}
|
||||
if ($papel_code == "CGE") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['cartulina'];
|
||||
}
|
||||
}
|
||||
return $color;
|
||||
}
|
||||
public function getPlastificadoColor()
|
||||
{
|
||||
$acabados = $this->presupuesto->acabados();
|
||||
$color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['default'];
|
||||
foreach ($acabados as $key => $acabado) {
|
||||
$tarifa_acabado = $acabado->tarifa();
|
||||
if ($tarifa_acabado->code) {
|
||||
$plastificado_code = $tarifa_acabado->code;
|
||||
if ($plastificado_code == "BRIL") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['BRIL'];
|
||||
}
|
||||
if ($plastificado_code == "MATE") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['MATE'];
|
||||
}
|
||||
if ($plastificado_code == "ANTI") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['ANTIRAYADO'];
|
||||
}
|
||||
if ($plastificado_code == "SAND") {
|
||||
$color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['SANDY'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $color;
|
||||
}
|
||||
public function getImpresionInteriorPPALColor()
|
||||
{
|
||||
$isRotativa = $this->presupuesto->presupuestoLineaImpresion()->isRotativa();
|
||||
$color = $isRotativa ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['ROTATIVA'] : $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['GENERAL'] ;
|
||||
$color = $this->isPOD ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['POD'] : $color;
|
||||
return $color;
|
||||
|
||||
}
|
||||
public function getPdfColors(): array
|
||||
{
|
||||
return [
|
||||
"general" => $this->getGeneralBackgroundColor(),
|
||||
"week_day" => $this->getWeekDayColor(),
|
||||
"ot" => $this->getEncuadernacionColor(),
|
||||
"papel_interior" => $this->getPapelImpresionBackgroundColor(),
|
||||
"papel_cubierta" => $this->getPapelImpresionCubiertaBackgroundColor(),
|
||||
"plastificado" => $this->getPlastificadoColor(),
|
||||
"impresion_interior_ppal" => $this->getImpresionInteriorPPALColor()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user