terminado a falta de pruebas las direcciones fp en admin

This commit is contained in:
2025-07-04 12:34:10 +02:00
parent 9aa7d2e0cb
commit 45ec831f8f
11 changed files with 895 additions and 147 deletions

View File

@ -448,7 +448,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
'retractilado' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value,
'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value,
'ferro' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value,
'ferro_2' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro_2')->value,
'prototipo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value,
'prototipo_2' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo_2')->value,
'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value,
'solapas_grandes_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value,
'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value,
@ -565,7 +567,6 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$modelCliente = new ClienteModel();
$modelPapelGenerico = new PapelGenericoModel();
$presupuesto = $this->model->find($id);
$data = [];
if ($presupuesto) {
@ -630,7 +631,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$data['datosLibro']['acabadoFaja']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre;
}
$data['datosLibro']['prototipo'] = $presupuesto->prototipo;
$data['datosLibro']['prototipo2'] = $this->hasPrototipo2($id);
$data['datosLibro']['ferro'] = $presupuesto->ferro;
$data['datosLibro']['ferro2'] = $this->hasFerro2($id);
$data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital;
$data['datosLibro']['marcapaginas'] = $presupuesto->marcapaginas;
$data['datosLibro']['retractilado'] = $presupuesto->retractilado;
@ -659,6 +662,21 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
}
$data['direccionesFP'] = [];
$direccionFP1 = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id, true, 1);
if(count($direccionFP1) > 0){
$data['direccionesFP']['fp1'] = $direccionFP1;
} else {
$data['direccionesFP']['fp1'] = [];
}
$direccionFP2 = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id, true, 2);
if(count($direccionFP2) > 0){
$data['direccionesFP']['fp2'] = $direccionFP2;
} else {
$data['direccionesFP']['fp2'] = [];
}
$data['direccionesFP']['checkboxes'] = json_decode($presupuesto->getDireccionFPChecks());
$data['comentarios_cliente'] = $presupuesto->comentarios_cliente;
$data['comentarios_safekat'] = $presupuesto->comentarios_safekat;
$data['comentarios_pdf'] = $presupuesto->comentarios_pdf;
@ -1951,7 +1969,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
return PresupuestoService::checkLineasEnvios($direccionesEnvio);
}
protected function obtenerDireccionesEnvio($id, $cliente_id)
protected function obtenerDireccionesEnvio($id, $cliente_id, $is_fp = false, $num_fp = 0)
{
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
@ -1959,10 +1977,38 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
->join('lg_proveedores', 'presupuesto_direcciones.proveedor_id = lg_proveedores.id')
->join('lg_paises', 'presupuesto_direcciones.pais_id = lg_paises.id')
->select('presupuesto_direcciones.*, lg_proveedores.nombre AS proveedor, lg_paises.nombre AS pais')
->where('presupuesto_id', $id)->findAll();
->where('presupuesto_id', $id)
->where('is_ferro_prototipo', $is_fp);
if ($is_fp) {
$direcciones = $direcciones
->where('num_ferro_prototipo', $num_fp);
}
return $direcciones;
return $direcciones->findAll();
}
protected function hasPrototipo2($presupuestoId){
$servicios = (new PresupuestoServiciosExtraModel())->getResource($presupuestoId)->get()->getResultObject();
$id_servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo_2')->value;
foreach ($servicios as $servicio) {
if ($servicio->tarifa_extra_id == $id_servicio) {
return true;
}
}
return false;
}
protected function hasFerro2($presupuestoId)
{
$servicios = (new PresupuestoServiciosExtraModel())->getResource($presupuestoId)->get()->getResultObject();
$id_servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro_2')->value;
foreach ($servicios as $servicio) {
if ($servicio->tarifa_extra_id == $id_servicio) {
return true;
}
}
return false;
}
}

View File

@ -55,6 +55,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
$proveedor_id = $reqData['proveedor_id'] ?? "";
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
$is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0;
$num_ferro_prototipo = $reqData['num_ferro_prototipo'] ?? 0;
$data = [
"presupuesto_id" => $presupuesto_id,
@ -74,7 +75,8 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
"proveedor" => $proveedor,
"proveedor_id" => $proveedor_id,
"entregaPieCalle" => $entregaPieCalle,
"is_ferro_prototipo" => $is_ferro_prototipo
"is_ferro_prototipo" => $is_ferro_prototipo,
"num_ferro_prototipo" => $num_ferro_prototipo
];
$response = $this->model->insert($data);

View File

@ -0,0 +1,33 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class FerroPrototipo2 extends Migration
{
public function up()
{
$this->db->table('config_variables_app')->insert([
'name' => 'id_servicio_ferro_2',
'value' => '31',
'description' => 'D del servicio extra "ferro (2 unidades)" que aparece en los presupuestos',
'created_at' => date('Y-m-d H:i:s')
]);
$this->db->table('config_variables_app')->insert([
'name' => 'id_servicio_prototipo_2',
'value' => '28',
'description' => 'D del servicio extra "Prototipo (2 unidades)" que aparece en los presupuestos',
'created_at' => date('Y-m-d H:i:s')
]);
}
public function down()
{
// Borrar los nuevos campos
$this->db->table('config_variables_app')->whereIn('name', [
'id_servicio_ferro_2',
'id_servicio_prototipo_2'
])->delete();
}
}

View File

@ -80,8 +80,10 @@ return [
'acabadoFaja' => 'Acabado Faja',
'cosido' => 'Cosido',
'ferro' => 'Ferro',
'ferro_2' => 'Ferro (2 uds.)',
'ferroDigital' => 'Ferro Digital',
'prototipo' => 'Prototipo',
'prototipo_2' => 'Prototipo (2 uds.)',
'imagenesBnInterior' => 'Imágenes B/N interior',
'recogerEnTaller' => 'Recoger en taller',
'marcapaginas' => 'Marcapáginas',

View File

@ -1,68 +1,207 @@
<div class="accordion accordion-bordered mt-3" id="accordionEnvios">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionEnviosTip" aria-expanded="false" aria-controls="accordionEnviosTip">
<button type="button" class="accordion-button" data-bs-toggle="collapse"
data-bs-target="#accordionEnviosTip" aria-expanded="false" aria-controls="accordionEnviosTip">
<h4><?= lang("Presupuestos.envios") ?></h4>
</button>
</h2>
<div id="accordionEnviosTip" class="accordion-collapse collapse show" data-bs-parent="#accordionEnvios">
<div id="accordionEnviosTip" class="accordion-collapse collapse show" data-bs-parent="#accordionEnvios">
<div class="accordion-body">
<div id='alert-envios'></div>
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
<div class='row'>
<div class='col-md-12 col-lg-4 px-4 py-2'>
<label for='envio_base' class='form-label'>
Envio base
</label>
<input readonly type='text' class='form-control' id='envio_base' name='envio_base' value='<?= $presupuestoEntity->envio_base ?>' />
<div> <!-- Direcciones envio -->
<div id='alert-envios'></div>
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
<div class='row'>
<div class='col-md-12 col-lg-4 px-4 py-2'>
<label for='envio_base' class='form-label'>
Envio base
</label>
<input readonly type='text' class='form-control' id='envio_base' name='envio_base'
value='<?= $presupuestoEntity->envio_base ?>' />
</div>
</div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvio"
class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto"
style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header">
<?= lang('Basic.global.Action') ?>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvio" class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-12 col-lg-4 px-4 py-2">
<input class="form-check-input" type="checkbox" id="recoger_en_taller" name="recoger_en_taller" value="1" <?= $presupuestoEntity->recoger_en_taller == true ? 'checked' : ''; ?> >
<label class="form-check-label" for="recoger_en_taller"><?= lang('Presupuestos.recogerEnTaller') ?></label>
<div class="row">
<div class="col-md-12 col-lg-4 px-4 py-2">
<input class="form-check-input" type="checkbox" id="recoger_en_taller"
name="recoger_en_taller" value="1" <?= $presupuestoEntity->recoger_en_taller == true ? 'checked' : ''; ?>>
<label class="form-check-label"
for="recoger_en_taller"><?= lang('Presupuestos.recogerEnTaller') ?></label>
</div>
</div>
</div>
<div id="rowInsertar" class="row">
<div class="col-md-12 col-lg-4 px-4 py-2">
<button id="insertar_direccion" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
<div id="rowInsertar" class="row">
<div class="col-md-12 col-lg-4 px-4 py-2">
<button id="insertar_direccion" type="button"
class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar") ?></button>
</div>
</div>
</div>
</div> <!-- //.Direcciones envio -->
<div id="div-envio-fp-1" class="mt-3 datos-envio-fp-1"> <!-- Direcciones envio fp 1 -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h6>
Dirección de envío ferro/prototipo
</h6>
</div>
</div>
<div id='alert-envio-fp1'></div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvioFP1"
class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto"
style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header">
<?= lang('Basic.global.Action') ?>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-12 col-lg-4 px-4 py-2">
<input class="form-check-input check-direccion-fp" type="checkbox" id="sameAddPrincipalFP1"
name="sameAddPrincipalFP1" value="1" >
<label class="form-check-label"
for="sameAddPrincipalFP1"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
</div>
</div>
<div id="rowInsertarEnvioFP1" class="row datos-envio-fp-1">
<div class="col-md-12 col-lg-4 px-4 py-2">
<button id="insertar_direccion_fp1" type="button"
class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar") ?></button>
</div>
</div>
</div> <!-- //.Direcciones envio fp1-->
<div id="div-envio-fp-2" class="mt-3 datos-envio-fp-2"> <!-- Direcciones envio fp 2 -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h6>
Dirección de envío ferro/prototipo 2
</h6>
</div>
</div>
<div id='alert-envio-fp2'></div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvioFP2"
class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto"
style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header">
<?= lang('Basic.global.Action') ?>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="row d-flex justify-content-start">
<div class="col-auto px-2 py-2">
<input class="form-check-input check-direccion-fp-2" type="checkbox" id="sameAddPrincipalFP2"
name="sameAddPrincipalFP2" value="1" >
<label class="form-check-label"
for="sameAddPrincipalFP2"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
</div>
<div class="col-auto px-2 py-2">
<input class="form-check-input check-direccion-fp-2" type="checkbox" id="sameAddFP1" name="sameAddFP1" value="1"
>
<label class="form-check-label"
for="sameAddFP1"><?= lang('PresupuestosDirecciones.sameAddFP1') ?></label>
</div>
</div>
<div id="rowInsertarEnvioFP2" class="row datos-envio-fp-2">
<div class="col-md-12 col-lg-4 px-4 py-2">
<button id="insertar_direccion_fp2" type="button"
class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar") ?></button>
</div>
</div>
</div> <!-- //.Direcciones envio fp2-->
</div> <!-- //.accordion-body -->
</div> <!-- //.accordion-collapse -->
</div> <!-- //.accordion-item -->
</div> <!-- //.accordion -->
</div> <!-- //.accordion -->

View File

@ -303,11 +303,20 @@
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="prototipo_2" class="form-check-label">
<input type="checkbox" id="prototipo_2" name="prototipo_2" value="1"
class="form-check-input" service="extra"
service-id=<?= $serviciosAutomaticos['prototipo_2'] ?>>
<?= lang('Presupuestos.prototipo_2') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div>
@ -326,6 +335,18 @@
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferro_2" class="form-check-label">
<input type="checkbox" id="ferro_2" name="ferro_2" value="1" class="form-check-input"
service="extra" service-id=<?= $serviciosAutomaticos['ferro_2'] ?>>
<?= lang('Presupuestos.ferro_2') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">

View File

@ -1,4 +1,4 @@
<div id="addressForm" action='create' class="modal fade addModal">
<div id="addressForm" action='create' data-table="" class="modal fade addModal">
<div class="modal-dialog modal-lg modal-simple">
<div class="modal-content">
<div class="modal-header">