trabajando en editar y rellenar el presupuesto

This commit is contained in:
jaimejimenezortega
2024-05-19 20:33:20 +02:00
parent 79d89b9718
commit e3e21d2b1e
8 changed files with 3913 additions and 97 deletions

View File

@ -102,6 +102,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta();
$datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta();
$datosPresupuesto->tipo_libro = "";
$datosPresupuesto->color_impresion = 'negro';
$datosPresupuesto->calidad_impresion = 'estandar';
$datosPresupuesto->tapa = 'blanda';
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
$this->viewData['formAction'] = route_to('crearPresupuestoCliente');
@ -152,6 +157,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta();
$datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta();
$datosPresupuesto->tipo_libro = $this->getTipoLibro($presupuestoEntity->tipo_impresion_id ?? null);
[$datosPresupuesto->color_impresion, $datosPresupuesto->calidad_impresion] =
$this->getTipoInterior($presupuestoEntity->id ?? null);
$datosPresupuesto->tapa = $this->getTapa($presupuestoEntity->tipo_impresion_id ?? null);
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
$this->viewData['formAction'] = route_to('updateCosidotapablanda', $id);
@ -160,17 +170,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
$cambios_lineas = $this->getLineasPresupuesto($presupuestoEntity)[0];
$this->viewData['updated']->cambios_lineas=$cambios_lineas;
$cambios_en_servicios = $this->getLineasServicios($presupuestoEntity)[0];
$this->viewData['updated']->cambios_servicios=$cambios_en_servicios;
$cambios_en_direcciones = $this->getLineasDirecciones($presupuestoEntity)[0];
$this->viewData['updated']->cambios_direcciones=$cambios_en_direcciones;
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
@ -1496,60 +1495,54 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return $data;
}
protected function getLineasPresupuesto($presupuestoEntity){
$lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id);
$input_data = [];
$input_data['presupuesto'] = $presupuestoEntity;
return PresupuestoService::checkLineasPresupuesto($input_data, $lineas);
}
protected function getLineasServicios($presupuestoEntity){
$serviciosPresupuesto = (object)array();
$serviciosPresupuesto->serviciosAcabado = (new PresupuestoAcabadosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$input_data = [];
$input_data['presupuesto_id'] = $presupuestoEntity->id;
$input_data['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id;
$input_data['tirada'] = $presupuestoEntity->tirada;
$input_data['POD'] = $this->getPOD();
$input_data['paginas'] = $presupuestoEntity->paginas;
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
if($presupuestoEntity->papel_formato_personalizado){
$input_data['ancho'] = $presupuestoEntity->ancho;
$input_data['alto'] = $presupuestoEntity->alto;
}
else{
$model = model("App\Models\Configuracion\PapelFormatoModel");
$papel = $model->find($presupuestoEntity->papel_formato_id);
if($papel){
$input_data['ancho'] = $papel->ancho;
$input_data['alto'] = $papel->alto;
}
else{
$input_data['ancho'] = 0;
$input_data['alto'] = 0;
}
}
return PresupuestoService::checkLineasServicios($input_data, $serviciosPresupuesto);
}
protected function getLineasDirecciones($presupuestoEntity){
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$direccionesEnvio = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll();
return PresupuestoService::checkLineasEnvios($direccionesEnvio);
}
protected function getTipoLibro($tipo_impresion_id){
if($tipo_impresion_id == 1 || $tipo_impresion_id == 2){
return 'fresado';
}
else if ($tipo_impresion_id == 3 || $tipo_impresion_id == 4){
return 'cosido';
}
else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 6){
return 'espiral';
}
else if ($tipo_impresion_id == 7 || $tipo_impresion_id == 8){
return 'wireo';
}
else if ($tipo_impresion_id == 21){
return 'grapado';
}
else
return '';
}
protected function getTipoInterior($presupuestoId){
$calidad = 'estandar';
$color = 'negro';
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
$data = $model->where('presupuestoId', $presupuestoId)->findAll();;
foreach($data as $linea){
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
$calidad='premium';
}
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
$color='color';
}
}
return [$color, $calidad];
}
protected function getTapa($tipo_impresion_id ){
$tapa = 'blanda';
if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 ||
$tipo_impresion_id == 5 || $tipo_impresion_id == 7)
$tapa = 'dura';
return $tapa;
}
}

View File

@ -44,9 +44,11 @@
<div id="tapaDiv" class="row mt-3">
<div class="col-sm-3 mb-md-0 mb-2" id="tapaBlandaDiv">
<div id="tapaBlandaInnerDiv" class="form-check custom-option custom-option-tapa custom-option-basic checked">
<div id="tapaBlandaInnerDiv" class="form-check custom-option custom-option-tapa custom-option-basic
<?php echo ($datosPresupuesto->tapa == 'blanda' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="tapaBlanda">
<input name="tapaBlanda" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaBlanda" checked="">
<input name="tapaBlanda" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaBlanda"
<?php echo ($datosPresupuesto->tapa == 'blanda' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Tapa blanda</span>
</span>
@ -54,9 +56,11 @@
</div>
</div>
<div id="tapaDuraDiv" class="col-sm-3 mb-md-0 mb-2">
<div class="form-check custom-option custom-option-tapa custom-option-basic">
<div class="form-check custom-option custom-option-tapa custom-option-basic
<?php echo ($datosPresupuesto->tapa == 'dura' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="tapaDura">
<input name="tapaDura" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaDura">
<input name="tapaDura" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaDura"
<?php echo ($datosPresupuesto->tapa == 'dura' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Tapa Dura</span>
</span>
@ -182,7 +186,8 @@
<img style="height:120px;width:120px" src="<?= site_url("assets/img/grises.png") ?>" alt="">
</span>
</label>
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro" checked="">
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro"
<?php echo ($datosPresupuesto->color_impresion == 'negro' ? ' checked=""': ''); ?> >
</div>
</div>
@ -193,7 +198,8 @@
<img style="height:120px;width:120px" src="<?= site_url("assets/img//gamacolor.png") ?>" alt="">
</span>
</label>
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor">
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor"
<?php echo ($datosPresupuesto->color_impresion == 'color' ? ' checked=""': ''); ?> >
</div>
</div>
@ -212,9 +218,11 @@
<div class="row">
<div class="col-sm-3 mb-md-0 mb-2">
<div id="calidadEstandarDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic checked">
<div id="calidadEstandarDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="calidadEstandar">
<input name="calidadEstandar" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadEstandar" checked="">
<input name="calidadEstandar" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadEstandar"
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Estándar</span>
</span>
@ -222,9 +230,11 @@
</div>
</div>
<div class="col-sm-3">
<div id="calidadPremiumDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic">
<div id="calidadPremiumDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic"
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="calidadPremium">
<input name="calidadPremium" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadPremium">
<input name="calidadPremium" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadPremium"
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Premium</span>
</span>
@ -565,6 +575,7 @@
<?= $this->section("additionalInlineJs") ?>
window.routes_disenio_libro = {
obtenerGramaje: "<?= route_to('obtenerGramaje') ?>",
presupuestoCliente: "<?= route_to('presupuestoCliente') ?>",

View File

@ -8,7 +8,17 @@
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="cosidoDiv"
class="form-check checked custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php
if($datosPresupuesto->tipo_libro == 'cosido' || $datosPresupuesto->tipo_libro == ''){
echo ' checked"';
}
else
{
echo '"';
}
?>
>
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoCosido">
<span class="custom-option-body">
@ -17,7 +27,13 @@
</span>
</label>
<input name="cosido" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoCosido"
id="tipoCosido" checked="">
id="tipoCosido"
<?php
if($datosPresupuesto->tipo_libro == 'cosido' || $datosPresupuesto->tipo_libro == ''){
echo 'checked=""';
}
?>
>
</div>
<h4 class="text-center">Rústica cosido</h4>
</div>
@ -26,7 +42,8 @@
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="fresadoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'fresado' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoFresado">
<span class="custom-option-body">
@ -35,7 +52,7 @@
</span>
</label>
<input name="fresado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoFresado"
id="tipoFresado">
id="tipoFresado" <?php echo (($datosPresupuesto->tipo_libro)=='fresado'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Rústica fresado</h4>
</div>
@ -44,7 +61,8 @@
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="grapadoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'grapado' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoGrapado">
<span class="custom-option-body">
@ -53,7 +71,7 @@
</span>
</label>
<input name="grapado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoGrapado"
id="tipoGrapado">
id="tipoGrapado" <?php echo (($datosPresupuesto->tipo_libro)=='grapado'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Cosido con grapas</h4>
</div>
@ -64,7 +82,8 @@
<div class="col-md-4 mb-6 d-flex justify-content-center">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="espiralDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'espiral' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoEspiral">
<span class="custom-option-body">
@ -73,7 +92,7 @@
</span>
</label>
<input name="espiral" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoEspiral"
id="tipoEspiral">
id="tipoEspiral" <?php echo (($datosPresupuesto->tipo_libro)=='espiral'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Espiral</h4>
</div>
@ -82,7 +101,8 @@
<div class="col-md-4 mb-6 d-flex justify-content-center" >
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="wireoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'wireo' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoWireO">
<span class="custom-option-body">
@ -91,7 +111,7 @@
</span>
</label>
<input name="wireo" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoWireO"
id="tipoWireO">
id="tipoWireO" <?php echo (($datosPresupuesto->tipo_libro)=='wireo'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Wire-o</h4>
</div>

View File

@ -156,8 +156,6 @@ function initDisenioLibro() {
$('#papelCubierta').val('').trigger('change');
$('#papelSobrecubierta').val('').trigger('change');
$('#enableSobrecubierta').trigger('change');
}

View File

@ -327,6 +327,7 @@
break;
case 0:
window.location.href = document.location.origin + '/presupuestocliente/list';
default:
break;

View File

@ -134,6 +134,10 @@ $('#btnConfirm').on('click', function() {
});
$('#btnBack').on('click', function() {
window.location.href = document.location.origin + '/presupuestocliente/list';
});
function finalizarPresupuesto(confirmar){
let servicios = [];
$('.servicio-extra:checked').each(function () {

View File

@ -88,7 +88,7 @@
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Volver</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Siguiente</span>
@ -156,17 +156,14 @@
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
<?php endif; ?>
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
</button>
<button id="btnSave" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
</button>
<?php else: ?>
<button id="btnBack" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Volver</span><i class="ti ti-check ti-xs"></i>
</button>
<?php endif; ?>
</div>
</div>
</div>

3792
xdebug.log

File diff suppressed because one or more lines are too long