mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado edit
This commit is contained in:
@ -14,7 +14,7 @@ use App\Services\PresupuestoService;
|
||||
use App\Models\Configuracion\PapelImpresionModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
@ -153,150 +153,107 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$presupuestoEntity = $this->model->find($id);
|
||||
|
||||
if ($presupuestoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
if ($this->request->getPost('recoger_en_taller') == null) {
|
||||
$sanitizedData['recoger_en_taller'] = false;
|
||||
}
|
||||
if ($this->request->getPost('ferro') == null) {
|
||||
$sanitizedData['ferro'] = false;
|
||||
}
|
||||
if ($this->request->getPost('ferro_digital') == null) {
|
||||
$sanitizedData['ferro_digital'] = false;
|
||||
}
|
||||
if ($this->request->getPost('marcapaginas') == null) {
|
||||
$sanitizedData['marcapaginas'] = false;
|
||||
}
|
||||
if ($this->request->getPost('papel_formato_personalizado') == null) {
|
||||
$sanitizedData['papel_formato_personalizado'] = false;
|
||||
}
|
||||
if ($this->request->getPost('solapas') == null) {
|
||||
$sanitizedData['solapas'] = false;
|
||||
}
|
||||
if ($this->request->getPost('cosido') == null) {
|
||||
$sanitizedData['cosido'] = false;
|
||||
}
|
||||
if ($this->request->getPost('cubiertas') == null) {
|
||||
$sanitizedData['cubiertas'] = false;
|
||||
}
|
||||
if ($this->request->getPost('imagenes_bn_interior') == null) {
|
||||
$sanitizedData['imagenes_bn_interior'] = false;
|
||||
}
|
||||
if ($this->request->getPost('en_produccion') == null) {
|
||||
$sanitizedData['en_produccion'] = false;
|
||||
}
|
||||
if ($this->request->getPost('en_espera') == null) {
|
||||
$sanitizedData['en_espera'] = false;
|
||||
}
|
||||
if ($this->request->getPost('modo_comparador') == null) {
|
||||
$sanitizedData['modo_comparador'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_negro_hq') == null) {
|
||||
$sanitizedData['paginas_negro_hq'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_negro_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_negro_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_negro_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_negro_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_color_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_color_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_color_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_color_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_portada_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_portada_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_portada_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_portada_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_cubierta_papel_impresion_id') == null) {
|
||||
$sanitizedData['paginas_cubierta_papel_impresion_id'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_cubierta_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_cubierta_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_cubierta_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_cubierta_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('isDig') == null) {
|
||||
$sanitizedData['isDig'] = false;
|
||||
}
|
||||
if ($this->request->getPost('envios_recoge_cliente') == null) {
|
||||
$sanitizedData['envios_recoge_cliente'] = false;
|
||||
}
|
||||
if ($this->request->getPost('fecha_entrega_real_aviso') == null) {
|
||||
$sanitizedData['fecha_entrega_real_aviso'] = false;
|
||||
}
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$presupuestoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $presupuestoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.';
|
||||
$message .= anchor("admin/presupuestos/{$id}/edit", lang('Basic.global.continueEditing') . '?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$presupuestoEntity = $this->model->find($id);
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
if ($presupuestoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$postData['updated_at'] = gmdate('Y-m-d H:m:s', time());
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else :
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$presupuestoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $presupuestoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.';
|
||||
// $message .= anchor("admin/presupuestos/{$id}/edit", lang('Basic.global.continueEditing') . '?');
|
||||
//$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else :
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'mensaje' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
}
|
||||
|
||||
endif;
|
||||
else :
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'mensaje' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
}
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
|
||||
if(!is_null($presupuestoEntity->comparador_json_data))
|
||||
$this->viewData['comp_data'] = json_decode($presupuestoEntity->comparador_json_data);
|
||||
else
|
||||
$this->viewData['comp_data'] = "";
|
||||
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
@ -326,7 +283,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateCosidotapablanda', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
@ -603,6 +560,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
continue;
|
||||
}
|
||||
$linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa);
|
||||
if(array_key_exists('error', $linea))
|
||||
continue;
|
||||
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
|
||||
$linea['fields']['maquina'] = $maquina->maquina;
|
||||
$linea['fields']['maquina_id'] = $maquina->maquina_id;
|
||||
|
||||
@ -176,6 +176,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"deleted_at" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
"comp_tipo_impresion" => null,
|
||||
"comp_pos_paginas_color" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"version" => "int",
|
||||
|
||||
@ -194,6 +194,8 @@ class PresupuestoModel extends \App\Models\GoBaseModel
|
||||
"pedido_espera_fecha",
|
||||
"pedido_espera_user_id",
|
||||
"is_deleted",
|
||||
"comp_tipo_impresion",
|
||||
"comp_pos_paginas_color",
|
||||
];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
||||
|
||||
|
||||
@ -116,7 +116,11 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row" id="div_solapas_ancho" style="display:none;">
|
||||
<?php if($presupuestoEntity->solapas == true): ?>
|
||||
<div class="row" id="div_solapas_ancho">
|
||||
<?php else: ?>
|
||||
<div class="row" id="div_solapas_ancho" style="display:none;">
|
||||
<?php endif; ?>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="solapas_ancho" class="form-label">
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
<div id="divAlarmasComparador"></div>
|
||||
<!----------------------------------------------------------------------------->
|
||||
|
||||
<input type="hidden" name="comparador_json_data" id="comparador_json_data" class="form-control" value="<?= isset($presupuestoEntity->comparador_json_data)?$presupuestoEntity->comparador_json_data:'' ?>"></input>
|
||||
|
||||
<div class="divider divider-dark text-start mb-1">
|
||||
<div class="divider-text">
|
||||
<h5><?= lang("Presupuestos.tipoImpresion") ?></h5>
|
||||
@ -20,17 +22,17 @@
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-3 px-4 mt-1">
|
||||
<div class="mb-3">
|
||||
<select id="tipoImpresion" name="tipo_impresion" class="form-control select2bs2" style="width: 100%;">
|
||||
<option id="tipoImpresionNegro" value="negro" <?= isset($presupuestoEntity->comparador_json_data) ? ("negro" == $presupuestoEntity->comparador_json_data->tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<select id="tipoImpresion" name="comp_tipo_impresion" class="form-control select2bs2" style="width: 100%;">
|
||||
<option id="tipoImpresionNegro" value="negro" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("negro" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<?= lang('MaquinasTarifasImpresions.negro') ?>
|
||||
</option>
|
||||
<option value="negrohq" <?= isset($presupuestoEntity->comparador_json_data) ? ("negrohq" == $presupuestoEntity->comparador_json_data->tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<option value="negrohq" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("negrohq" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<?= lang('MaquinasTarifasImpresions.negrohq') ?>
|
||||
</option>
|
||||
<option value="color" <?= isset($presupuestoEntity->comparador_json_data) ? ("color" == $presupuestoEntity->comparador_json_data->tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<option value="color" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("color" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<?= lang('MaquinasTarifasImpresions.color') ?>
|
||||
</option>
|
||||
<option value="colorhq" <?= isset($presupuestoEntity->comparador_json_data) ? ("colorhq" == $presupuestoEntity->comparador_json_data->tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<option value="colorhq" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("colorhq" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
||||
<?= lang('MaquinasTarifasImpresions.colorhq') ?>
|
||||
</option>
|
||||
</select>
|
||||
@ -72,10 +74,10 @@
|
||||
<p><?= lang('MaquinasTarifasImpresions.negro') ?></p>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<input type="text" id="compPaginasNegro" name="comp_paginas_negro" placeholder="0" maxLength="5" class="form-control comp_negro_items" value="<?= isset($presupuestoEntity->comparador_json_data->negro) ? (old(0, $presupuestoEntity->comparador_json_data->negro->paginas)) : '0' ?>">
|
||||
<input type="text" id="compPaginasNegro" name="comp_paginas_negro" placeholder="0" maxLength="5" class="form-control comp_negro_items" value="<?= isset($comp_data->bn->paginas) ? (old(0, $comp_data->bn->paginas)) : '0' ?>">
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<select id="compPapelNegro" name="comp_papel_negro" class="form-control select2bs2" style="width: 100%;">
|
||||
<select id="compPapelNegro" name="comp_papel_negro" class="form-control select2bs2 comp_negro_items" style="width: 100%;">
|
||||
<?php if (isset($papelGenericoNegroList) && is_array($papelGenericoNegroList) && !empty($papelGenericoNegroList)) :
|
||||
foreach ($papelGenericoNegroList as $k => $v) : ?>
|
||||
<option value="<?= $v->id ?>">
|
||||
@ -100,7 +102,7 @@
|
||||
<p><?= lang('MaquinasTarifasImpresions.negrohq') ?></p>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<input type="text" id="compPaginasNegrohq" name="comp_paginas_negrohq" placeholder="0" maxLength="5" class="form-control comp_negrohq_items" value="<?= isset($presupuestoEntity->comparador_json_data->negro) ? (old(0, $presupuestoEntity->comparador_json_data->negro->paginas)) : '0' ?>">
|
||||
<input type="text" id="compPaginasNegrohq" name="comp_paginas_negrohq" placeholder="0" maxLength="5" class="form-control comp_negrohq_items" value="<?= isset($comp_data->bnhq->paginas) ? (old(0, $comp_data->bnhq->paginas)) : '0' ?>">
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<select id="compPapelNegrohq" name="comp_papel_negrohq" class="form-control select2bs2 comp_negrohq_items" style="width: 100%;">
|
||||
@ -128,7 +130,7 @@
|
||||
<p><?= lang('MaquinasTarifasImpresions.color') ?></p>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<input type="text" id="compPaginasColor" name="comp_paginas_color" placeholder="0" maxLength="5" class="form-control comp_color_items" value="<?= isset($presupuestoEntity->comparador_json_data->color) ? (old(0, $presupuestoEntity->comparador_json_data->color->paginas)) : '0' ?>">
|
||||
<input type="text" id="compPaginasColor" name="comp_paginas_color" placeholder="0" maxLength="5" class="form-control comp_color_items" value="<?= isset($comp_data->color->paginas) ? (old(0, $comp_data->color->paginas)) : '0' ?>">
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<select id="compPapelColor" name="comp_papel_color" class="form-control select2bs2 comp_color_items" style="width: 100%;">
|
||||
@ -156,7 +158,7 @@
|
||||
<p><?= lang('MaquinasTarifasImpresions.colorhq') ?></p>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<input type="text" id="compPaginasColorhq" name="comp_paginas_colorhq" placeholder="0" maxLength="5" class="form-control comp_colorhq_items" value="<?= isset($presupuestoEntity->comparador_json_data->color) ? (old(0, $presupuestoEntity->comparador_json_data->color->paginas)) : '0' ?>">
|
||||
<input type="text" id="compPaginasColorhq" name="comp_paginas_colorhq" placeholder="0" maxLength="5" class="form-control comp_colorhq_items" value="<?= isset($comp_data->colorhq->paginas) ? (old(0, $comp_data->colorhq->paginas)) : '0' ?>">
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<select id="compPapelColorhq" name="comp_papel_colorhq" class="form-control select2bs2 comp_colorhq_items" style="width: 100%;">
|
||||
@ -227,7 +229,7 @@
|
||||
<label for="compPosPaginasColor" class="form-label">
|
||||
<?= lang('Presupuestos.posicionPagColor') ?>
|
||||
</label>
|
||||
<input type="text" id="compPosPaginasColor" name="comp_pos_paginas_color" maxLength="20" class="form-control" value="<?= isset($presupuestoEntity->comparador_json_data->color->pospaginas) ? (old('', $presupuestoEntity->comparador_json_data->color->pospaginas)) : '' ?>">
|
||||
<input type="text" id="compPosPaginasColor" name="comp_pos_paginas_color" maxLength="20" class="form-control" value="<?= isset($presupuestoEntity->comp_pos_paginas_color) ? (old('', $presupuestoEntity->comp_pos_paginas_color)) : '' ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-8 px-4">
|
||||
@ -434,8 +436,152 @@
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
autosize($('#compCalPaginasColor'));
|
||||
|
||||
function init_comparador() {
|
||||
$('#tipoImpresion').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelNegro').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeNegro').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelNegrohq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeNegrohq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelColor').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelColorhq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeColor').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeColorhq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelCubierta').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeCubierta').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#encuadernacion').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compCarasCubierta').select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
|
||||
$('#papelFormatoId').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
updatePapelesComparador();
|
||||
const paginasColor = document.getElementById('compCalPaginasColor');
|
||||
if (paginasColor.value.length > 0) {
|
||||
computarPaginasColor(paginasColor.value);
|
||||
}
|
||||
|
||||
var comp_data = <?php echo json_encode($comp_data); ?>
|
||||
|
||||
try{
|
||||
$("#compPapelNegro").val(parseInt(comp_data.bn.papel_id)).trigger('change');
|
||||
|
||||
try{
|
||||
var newState = new Option(comp_data.bn.gramaje, comp_data.bn.gramaje, true, true);
|
||||
// Append it to the select
|
||||
$("#compGramajeNegro").append(newState).trigger('change');
|
||||
$('#compGramajeNegro').prop('disabled', false);
|
||||
}catch(e){}
|
||||
}catch(e){}
|
||||
|
||||
try{
|
||||
$("#compPapelNegrohq").val(parseInt(comp_data.bnhq.papel_id)).trigger('change');
|
||||
|
||||
try{
|
||||
var newState = new Option(comp_data.bnhq.gramaje, comp_data.bnhq.gramaje, true, true);
|
||||
// Append it to the select
|
||||
$("#compGramajeNegrohq").append(newState).trigger('change');
|
||||
$('#compGramajeNegrohq').prop('disabled', false);
|
||||
}catch(e){}
|
||||
}catch(e){}
|
||||
|
||||
try{
|
||||
$("#compPapelColor").val(parseInt(comp_data.color.papel_id)).trigger('change');
|
||||
|
||||
try{
|
||||
var newState = new Option(comp_data.color.gramaje, comp_data.color.gramaje, true, true);
|
||||
// Append it to the select
|
||||
$("#compGramajeColor").append(newState).trigger('change');
|
||||
$('#compGramajeColor').prop('disabled', false);
|
||||
}catch(e){}
|
||||
}catch(e){}
|
||||
|
||||
try{
|
||||
$("#compPapelColorhq").val(parseInt(comp_data.colorhq.papel_id)).trigger('change');
|
||||
|
||||
try{
|
||||
var newState = new Option(comp_data.colorhq.gramaje, comp_data.colorhq.gramaje, true, true);
|
||||
// Append it to the select
|
||||
$("#compGramajeColorhq").append(newState).trigger('change');
|
||||
$('#compGramajeColorhq').prop('disabled', false);
|
||||
}catch(e){}
|
||||
}catch(e){}
|
||||
|
||||
try{
|
||||
$("#compCarasCubierta").val(parseInt(comp_data.cubierta.paginas)).trigger('select2:select');
|
||||
try{
|
||||
$("#compPapelCubierta").val(parseInt(comp_data.cubierta.papel_id)).trigger('select2:select');
|
||||
|
||||
try{
|
||||
var newState = new Option(comp_data.cubierta.gramaje, comp_data.cubierta.gramaje, true, true);
|
||||
// Append it to the select
|
||||
$("#compGramajeCubierta").append(newState).trigger('change');
|
||||
$('#compGramajeCubierta').prop('disabled', false);
|
||||
}catch(e){}
|
||||
}catch(e){}
|
||||
}catch(e){}
|
||||
|
||||
var timp = '<?php echo $presupuestoEntity->comp_tipo_impresion; ?>'
|
||||
switch(timp){
|
||||
case 'negro':
|
||||
checkComparadorInt(false,false)
|
||||
break;
|
||||
case 'negrohq':
|
||||
checkComparadorInt(false,true)
|
||||
break;
|
||||
case 'color':
|
||||
checkComparadorInt(true,false)
|
||||
break;
|
||||
case 'colorhq':
|
||||
checkComparadorInt(true,true)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
computarPaginasColor($('#compPosPaginasColor').val());
|
||||
|
||||
init_comparador();
|
||||
}
|
||||
|
||||
var tableCompIntPlana = new DataTable('#tableCompIntPlana',{
|
||||
scrollX: true,
|
||||
@ -1036,40 +1182,47 @@
|
||||
|
||||
function checkComparadorInt(is_color, is_hq) {
|
||||
|
||||
clearIntLineas(is_color);
|
||||
clearIntRot();
|
||||
$('#title_int_rot').html('<?= lang("Presupuestos.compInteriorRotativa") ?>');
|
||||
$('#title_int_plana').html('<?= lang("Presupuestos.compInteriorPlana") ?>');
|
||||
|
||||
elementos = getIDsComparador(is_color, is_hq)
|
||||
try{
|
||||
|
||||
clearIntLineas(is_color);
|
||||
clearIntRot();
|
||||
$('#title_int_rot').html('<?= lang("Presupuestos.compInteriorRotativa") ?>');
|
||||
$('#title_int_plana').html('<?= lang("Presupuestos.compInteriorPlana") ?>');
|
||||
|
||||
elementos = getIDsComparador(is_color, is_hq)
|
||||
|
||||
if ($(''+ elementos.papel).select2('data').length > 0 &&
|
||||
$(''+ elementos.gramaje).select2('data').length > 0 &&
|
||||
parseInt($(''+ elementos.paginas).val()) > 0 &&
|
||||
checkDatosPedidoForComp()) {
|
||||
if ($(''+ elementos.papel).select2('data').length > 0 &&
|
||||
$(''+ elementos.gramaje).select2('data').length > 0 &&
|
||||
parseInt($(''+ elementos.paginas).val()) > 0 &&
|
||||
checkDatosPedidoForComp()) {
|
||||
|
||||
getLineasIntPlana(is_color, is_hq).then((result) =>{
|
||||
// Para rotativa, si es color el papel y el gramaje tiene que ser igual
|
||||
if(!is_color)
|
||||
{
|
||||
getLineasIntRot(is_hq);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_hq){
|
||||
if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()))
|
||||
{
|
||||
getLineasIntRot(is_hq);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#errorComRot').html('<?= lang("Presupuestos.errores.errorRotColor") ?>');
|
||||
getLineasIntPlana(is_color, is_hq).then((result) =>{
|
||||
// Para rotativa, si es color el papel y el gramaje tiene que ser igual
|
||||
if(!is_color)
|
||||
{
|
||||
getLineasIntRot(is_hq);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_hq){
|
||||
if ($('#compPapelNegro').select2('data')>0 && $('#compPapelColor').select2('data')>0 &&
|
||||
$('#compGramajeNegro').select2('data')>0 && $('#compGramajeColor').select2('data')>0)
|
||||
{
|
||||
if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()))
|
||||
{
|
||||
getLineasIntRot(is_hq);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#errorComRot').html('<?= lang("Presupuestos.errores.errorRotColor") ?>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}catch(e){}
|
||||
}
|
||||
|
||||
|
||||
@ -1314,4 +1467,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
init_comparador();
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -25,7 +25,11 @@
|
||||
<label for="created_at" class="form-label">
|
||||
<?= lang('Presupuestos.created_at') ?>
|
||||
</label>
|
||||
<input readonly style="background: #E8E8E8;" id="created_at" name="created_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->created_at)) ? $presupuestoEntity->created_at : date("d/m/Y")) ?>">
|
||||
<?php if(str_contains($formAction,'edit')): ?>
|
||||
<input readonly style="background: #E8E8E8;" id="updated_at" name="updated_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->updated_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->updated_at)) : "") ?>">
|
||||
<?php else: ?>
|
||||
<input readonly style="background: #E8E8E8;" id="created_at" name="created_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->created_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->created_at)) : "") ?>">
|
||||
<?php endif; ?>
|
||||
</div><!--//.mb-3 -->
|
||||
</div><!--//.col -->
|
||||
|
||||
|
||||
@ -2959,7 +2959,6 @@ function fill_lp_from_bbdd(){
|
||||
|
||||
if(lp.tipo == 'rot_bn' ||lp.tipo == 'rot_color'){
|
||||
|
||||
console.log(lp)
|
||||
$('#lp_' + lp.tipo + '_numPagColor').val(isNaN(parseFloat(lp.rotativa_pag_color)) ? "" : parseFloat(lp.rotativa_pag_color).toFixed(0))
|
||||
$('#lp_' + lp.tipo + '_totalLinea').val(isNaN(parseFloat(lp.rotativa_total_impresion)) ? "" : parseFloat(lp.rotativa_total_impresion).toFixed(2))
|
||||
$('#lp_' + lp.tipo + '_aFavorFibra').prop('checked', lp.rotativa_a_favor_fibra==0?false:true)
|
||||
@ -3130,6 +3129,9 @@ async function fill_bbdd_from_lp(presupuesto_id){
|
||||
token=response.<?= csrf_token() ?>;
|
||||
yeniden(token);
|
||||
}
|
||||
}).fail(function (jqXHR, textStatus, error) {
|
||||
// Handle error here
|
||||
console.log(jqXHR)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -218,15 +218,6 @@ function getRowFromLineaRot(linea) {
|
||||
|
||||
|
||||
|
||||
function init_comparador() {
|
||||
updatePapelesComparador();
|
||||
const paginasColor = document.getElementById('compCalPaginasColor');
|
||||
if (paginasColor.value.length > 0) {
|
||||
computarPaginasColor(paginasColor.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function computarPaginasColor(string) {
|
||||
|
||||
var numbers = [];
|
||||
@ -575,3 +566,97 @@ function clearCompTable(){
|
||||
$('#total_comp_plana').html('0.00')
|
||||
$('#total_comp_rot').html('0.00')
|
||||
}
|
||||
|
||||
function generateCompJSON(){
|
||||
|
||||
data = {}
|
||||
|
||||
if( $('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color')
|
||||
{
|
||||
try{
|
||||
bn_obj = {
|
||||
"bn":{
|
||||
'paginas': $('#compPaginasNegro').val(),
|
||||
'papel_id': $('#compPapelNegro').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
bn_obj = {}
|
||||
}
|
||||
$.extend( data, bn_obj );
|
||||
}
|
||||
|
||||
if( $('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq')
|
||||
{
|
||||
try{
|
||||
bnhq_obj = {
|
||||
"bnhq":{
|
||||
'paginas': $('#compPaginasNegrohq').val(),
|
||||
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
bnhq_obj = {}
|
||||
}
|
||||
$.extend( data, bnhq_obj );
|
||||
}
|
||||
|
||||
if($('#tipoImpresion').select2('data')[0].id == 'color')
|
||||
{
|
||||
try{
|
||||
color_obj = {
|
||||
"color":{
|
||||
'paginas': $('#compPaginasColor').val(),
|
||||
'papel_id': $('#compPapelColor').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
color_obj = {}
|
||||
}
|
||||
$.extend( data, color_obj );
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($('#tipoImpresion').select2('data')[0].id == 'colorhq')
|
||||
{
|
||||
try{
|
||||
colorhq_obj = {
|
||||
"colorhq":{
|
||||
'paginas': $('#compPaginasColorhq').val(),
|
||||
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
colorhq_obj = {}
|
||||
}
|
||||
$.extend( data, colorhq_obj );
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
cubierta_obj = {
|
||||
"cubierta":{
|
||||
'paginas': $('#compCarasCubierta').select2('data')[0].id,
|
||||
'papel_id': $('#compPapelCubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
cubierta_obj = {}
|
||||
}
|
||||
|
||||
$.extend( data, cubierta_obj );
|
||||
|
||||
data_str = JSON.stringify(data)
|
||||
$('#comparador_json_data').val(data_str)
|
||||
}
|
||||
@ -92,65 +92,6 @@
|
||||
});
|
||||
|
||||
|
||||
<?php if(str_contains($formAction,'edit')): ?>
|
||||
$('#papelFormatoId').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#tipoImpresion').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelNegro').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeNegro').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelNegrohq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeNegrohq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelColor').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelColorhq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeColor').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeColorhq').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compPapelCubierta').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compGramajeCubierta').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#encuadernacion').select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compCarasCubierta').select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -172,16 +113,20 @@ else{
|
||||
$('#presupuestoForm').on( "submit", function( event ) {
|
||||
event.preventDefault();
|
||||
$.when(fill_bbdd_from_lp(id).then(function (data, textStatus, jqXHR){
|
||||
generateCompJSON()
|
||||
form = $('#presupuestoForm').serialize()
|
||||
/*$.ajax({
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo $formAction; ?>",
|
||||
data: form,
|
||||
done: function (data) {
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
console.log(data);
|
||||
success: function (data) {
|
||||
yeniden(data.<?= csrf_token() ?>)
|
||||
popSuccessAlert(data.mensaje)
|
||||
}
|
||||
});*/
|
||||
}).fail(function (jqXHR, textStatus, error) {
|
||||
// Handle error here
|
||||
console.log(jqXHR)
|
||||
});;
|
||||
}))
|
||||
|
||||
return false; //stop the actual form post !important!
|
||||
|
||||
Reference in New Issue
Block a user