corregidos errores

This commit is contained in:
2024-10-24 08:50:13 +02:00
parent 3dd9f8f7e3
commit 0f00649f99
4 changed files with 371 additions and 301 deletions

View File

@ -1,4 +1,5 @@
<?php namespace App\Controllers\Configuracion; <?php
namespace App\Controllers\Configuracion;
use App\Controllers\BaseResourceController; use App\Controllers\BaseResourceController;
@ -12,8 +13,8 @@ use App\Models\Configuracion\MaquinasTarifasImpresionModel;
use App\Models\Configuracion\MaquinaModel; use App\Models\Configuracion\MaquinaModel;
use use
DataTables\Editor, DataTables\Editor,
DataTables\Editor\Field; DataTables\Editor\Field;
class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
{ {
@ -69,9 +70,9 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
{ {
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -81,10 +82,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData); $successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -98,14 +99,14 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $this->model->db->insertID(); $id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -129,25 +130,25 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
return $this->displayForm(__METHOD__); return $this->displayForm(__METHOD__);
} // end function add() } // end function add()
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
if ($requestedId == null) : if ($requestedId == null):
return $this->redirect2listView(); return $this->redirect2listView();
endif; endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL); $id = filter_var($requestedId, FILTER_SANITIZE_URL);
$maquinasTarifasImpresion = $this->model->find($id); $maquinasTarifasImpresion = $this->model->find($id);
if ($maquinasTarifasImpresion == false) : if ($maquinasTarifasImpresion == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]); $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]);
return $this->redirect2listView('sweet-error', $message); return $this->redirect2listView('sweet-error', $message);
endif; endif;
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -160,10 +161,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -180,12 +181,12 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$thenRedirect = false; $thenRedirect = false;
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $maquinasTarifasImpresion->id ?? $id; $id = $maquinasTarifasImpresion->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -220,30 +221,48 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$response = Editor::inst($db, 'lg_maquinas_tarifas_impresion') $response = Editor::inst($db, 'lg_maquinas_tarifas_impresion')
->fields( ->fields(
Field::inst('uso') Field::inst('uso')
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.uso.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.uso.required')
)
), ),
Field::inst('tipo') Field::inst('tipo')
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
)
), ),
Field::inst('precio') Field::inst('precio')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')) 'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
)
), ),
Field::inst('margen') Field::inst('margen')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')) 'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
)
), ),
Field::inst('maquina_id'), Field::inst('maquina_id'),
Field::inst('user_created_id'), Field::inst('user_created_id'),
@ -269,16 +288,21 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
'maquina_id' => $values['maquina_id'], 'maquina_id' => $values['maquina_id'],
'tipo' => $values['tipo'], 'tipo' => $values['tipo'],
'uso' => $values['uso'], 'uso' => $values['uso'],
'is_deleted' => 0)); 'is_deleted' => 0
));
$id = $builder->get()->getFirstRow()->id; $id = $builder->get()->getFirstRow();
if ($id) {
$id = $id->id;
// No se pueden duplicar valores al crear o al editar
if ($builder->countAllResults() >= 1) {
if (
($action === Editor::ACTION_EDIT && $id != $pkey)
|| $action === Editor::ACTION_CREATE
) {
// No se pueden duplicar valores al crear o al editar return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
if ($builder->countAllResults() >= 1) { }
if (($action === Editor::ACTION_EDIT && $id != $pkey)
|| $action === Editor::ACTION_CREATE) {
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
} }
} }
} }
@ -413,11 +437,11 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
protected function getMaquinaListItems($selId = null) protected function getMaquinaListItems($selId = null)
{ {
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
if (!empty($selId)) : if (!empty($selId)):
$maquinaModel = model('App\Models\Configuracion\MaquinaModel'); $maquinaModel = model('App\Models\Configuracion\MaquinaModel');
$selOption = $maquinaModel->where('id', $selId)->findColumn('nombre'); $selOption = $maquinaModel->where('id', $selId)->findColumn('nombre');
if (!empty($selOption)) : if (!empty($selOption)):
$data[$selId] = $selOption[0]; $data[$selId] = $selOption[0];
endif; endif;
endif; endif;

File diff suppressed because it is too large Load Diff

View File

@ -132,7 +132,9 @@
<div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;"> <div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;">
</div> </div>
<?= view("themes/vuexy/components/chat_internal_presupuesto",data:["modelId" => $presupuestoId,"type" => "presupuesto"]) ?> <?php if($formAction == 'edit'): ?>
<?= view("themes/vuexy/components/chat_internal_presupuesto",data:["modelId" => $presupuestoId,"type" => "presupuesto"]) ?>
<?php endif; ?>
</div><!--//.row --> </div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?> <?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?> <?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>

View File

@ -79,6 +79,7 @@ class PresupuestoCliente {
} }
$(".calcular-presupuesto").on('change', this.checkForm.bind(this)); $(".calcular-presupuesto").on('change', this.checkForm.bind(this));
} }
@ -145,9 +146,21 @@ class PresupuestoCliente {
if (datos_to_check.direcciones) { if (datos_to_check.direcciones) {
delete datos_to_check.direcciones; delete datos_to_check.direcciones;
} }
if (datos_to_check.posPaginasColor) { if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
delete datos_to_check.posPaginasColor; delete datos_to_check.posPaginasColor;
} }
if(datos_to_check.cubierta.acabados.barniz == undefined){
delete datos_to_check.cubierta.acabados.barniz;
}
if(datos_to_check.cubierta.acabados.plastificado == undefined){
delete datos_to_check.cubierta.acabados.plastificado;
}
if(datos_to_check.cubierta.acabados.estampado == undefined){
delete datos_to_check.cubierta.acabados.estampado;
}
if(datos_to_check.sobrecubierta.plastificado == undefined){
delete datos_to_check.sobrecubierta.plastificado;
}
if (Object.values(datos_to_check).every(this.#isValidDataForm)) { if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try { try {
@ -352,7 +365,7 @@ class PresupuestoCliente {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click'); $(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
}, 0); }, 0);
} }
$('#loader').modal('hide');
// DEBUG // DEBUG
//console.log(response); //console.log(response);
} }
@ -420,7 +433,6 @@ class PresupuestoCliente {
cubierta: { cubierta: {
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'), tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
lomoRedondo: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0,
papelCubierta: this.disenioCubierta.getPapel(), papelCubierta: this.disenioCubierta.getPapel(),
gramajeCubierta: this.disenioCubierta.getGramaje(), gramajeCubierta: this.disenioCubierta.getGramaje(),
cabezada: this.disenioCubierta.getCabezada(), cabezada: this.disenioCubierta.getCabezada(),
@ -438,6 +450,10 @@ class PresupuestoCliente {
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0, 'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
}, },
}; };
let lomoRedondo = 0;
if(this.disenioCubierta.disenioCubierta.filter('.selected').length > 0)
lomoRedondo = this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0;
this.datos.cubierta.lomoRedondo = lomoRedondo;
if (this.datos.tipo == "cosido") { if (this.datos.tipo == "cosido") {
this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val(); this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val();