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, 'retractilado' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value,
'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value, 'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value,
'ferro' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->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' => 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_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_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, '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(); $modelCliente = new ClienteModel();
$modelPapelGenerico = new PapelGenericoModel(); $modelPapelGenerico = new PapelGenericoModel();
$presupuesto = $this->model->find($id); $presupuesto = $this->model->find($id);
$data = []; $data = [];
if ($presupuesto) { 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']['acabadoFaja']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre;
} }
$data['datosLibro']['prototipo'] = $presupuesto->prototipo; $data['datosLibro']['prototipo'] = $presupuesto->prototipo;
$data['datosLibro']['prototipo2'] = $this->hasPrototipo2($id);
$data['datosLibro']['ferro'] = $presupuesto->ferro; $data['datosLibro']['ferro'] = $presupuesto->ferro;
$data['datosLibro']['ferro2'] = $this->hasFerro2($id);
$data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital; $data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital;
$data['datosLibro']['marcapaginas'] = $presupuesto->marcapaginas; $data['datosLibro']['marcapaginas'] = $presupuesto->marcapaginas;
$data['datosLibro']['retractilado'] = $presupuesto->retractilado; $data['datosLibro']['retractilado'] = $presupuesto->retractilado;
@ -659,6 +662,21 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); $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_cliente'] = $presupuesto->comentarios_cliente;
$data['comentarios_safekat'] = $presupuesto->comentarios_safekat; $data['comentarios_safekat'] = $presupuesto->comentarios_safekat;
$data['comentarios_pdf'] = $presupuesto->comentarios_pdf; $data['comentarios_pdf'] = $presupuesto->comentarios_pdf;
@ -1951,7 +1969,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
return PresupuestoService::checkLineasEnvios($direccionesEnvio); 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 = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel'); $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_proveedores', 'presupuesto_direcciones.proveedor_id = lg_proveedores.id')
->join('lg_paises', 'presupuesto_direcciones.pais_id = lg_paises.id') ->join('lg_paises', 'presupuesto_direcciones.pais_id = lg_paises.id')
->select('presupuesto_direcciones.*, lg_proveedores.nombre AS proveedor, lg_paises.nombre AS pais') ->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'] ?? ""; $proveedor_id = $reqData['proveedor_id'] ?? "";
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0; $entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
$is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0; $is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0;
$num_ferro_prototipo = $reqData['num_ferro_prototipo'] ?? 0;
$data = [ $data = [
"presupuesto_id" => $presupuesto_id, "presupuesto_id" => $presupuesto_id,
@ -74,7 +75,8 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
"proveedor" => $proveedor, "proveedor" => $proveedor,
"proveedor_id" => $proveedor_id, "proveedor_id" => $proveedor_id,
"entregaPieCalle" => $entregaPieCalle, "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); $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', 'acabadoFaja' => 'Acabado Faja',
'cosido' => 'Cosido', 'cosido' => 'Cosido',
'ferro' => 'Ferro', 'ferro' => 'Ferro',
'ferro_2' => 'Ferro (2 uds.)',
'ferroDigital' => 'Ferro Digital', 'ferroDigital' => 'Ferro Digital',
'prototipo' => 'Prototipo', 'prototipo' => 'Prototipo',
'prototipo_2' => 'Prototipo (2 uds.)',
'imagenesBnInterior' => 'Imágenes B/N interior', 'imagenesBnInterior' => 'Imágenes B/N interior',
'recogerEnTaller' => 'Recoger en taller', 'recogerEnTaller' => 'Recoger en taller',
'marcapaginas' => 'Marcapáginas', 'marcapaginas' => 'Marcapáginas',

View File

@ -1,68 +1,207 @@
<div class="accordion accordion-bordered mt-3" id="accordionEnvios"> <div class="accordion accordion-bordered mt-3" id="accordionEnvios">
<div class="card accordion-item active"> <div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne"> <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> <h4><?= lang("Presupuestos.envios") ?></h4>
</button> </button>
</h2> </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 class="accordion-body">
<div id='alert-envios'></div> <div> <!-- Direcciones envio -->
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?> <div id='alert-envios'></div>
<div class='row'> <?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
<div class='col-md-12 col-lg-4 px-4 py-2'> <div class='row'>
<label for='envio_base' class='form-label'> <div class='col-md-12 col-lg-4 px-4 py-2'>
Envio base <label for='envio_base' class='form-label'>
</label> Envio base
<input readonly type='text' class='form-control' id='envio_base' name='envio_base' value='<?= $presupuestoEntity->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> <div class="row">
<div id='rowTable' class='row'> <div class="col-md-12 col-lg-4 px-4 py-2">
<table id="tableOfDireccionesEnvio" class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;"> <input class="form-check-input" type="checkbox" id="recoger_en_taller"
<thead> name="recoger_en_taller" value="1" <?= $presupuestoEntity->recoger_en_taller == true ? 'checked' : ''; ?>>
<tr> <label class="form-check-label"
<th class="lp-header">TARIFA ID</th> for="recoger_en_taller"><?= lang('Presupuestos.recogerEnTaller') ?></label>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th> </div>
<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> </div>
</div>
<div id="rowInsertar" class="row"> <div id="rowInsertar" class="row">
<div class="col-md-12 col-lg-4 px-4 py-2"> <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> <button id="insertar_direccion" type="button"
class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar") ?></button>
</div>
</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-body -->
</div> <!-- //.accordion-collapse --> </div> <!-- //.accordion-collapse -->
</div> <!-- //.accordion-item --> </div> <!-- //.accordion-item -->
</div> <!-- //.accordion --> </div> <!-- //.accordion -->

View File

@ -303,11 +303,20 @@
</label> </label>
</div><!--//.form-check --> </div><!--//.form-check -->
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
<div class="mb-3">
</div><!--//.mb-3 -->
</div><!--//.col --> </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> </div>
@ -326,6 +335,18 @@
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
</div><!--//.col --> </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="col-md-12 col-lg-3 px-4">
<div class="mb-3"> <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-dialog modal-lg modal-simple">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">

View File

@ -325,6 +325,12 @@ class PresupuestoAdminEdit {
datos.tirada_alternativa_json_data = this.tiradasAlternativas.generate_json_tiradas(); datos.tirada_alternativa_json_data = this.tiradasAlternativas.generate_json_tiradas();
datos.direcciones_fp_checks = JSON.stringify({
"addFP1isAddMain": $('#sameAddPrincipalFP1').prop('checked')? "1":"0",
"addFP2isAddMain": $('#sameAddPrincipalFP2').prop('checked')? "1":"0",
"addFP2isaddFP1": $('#sameAddFP1').prop('checked')? "1":"0",
});
return datos; return datos;
} }
@ -423,7 +429,7 @@ class PresupuestoAdminEdit {
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto); self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
self.servicios.cargar(response.data.servicios); self.servicios.cargar(response.data.servicios);
self.envios.cargar(response.data.direcciones); self.envios.cargar(response.data.direcciones, response.data.direccionesFP);
self.comparador.cargarDatos(response.data.comparador); self.comparador.cargarDatos(response.data.comparador);

View File

@ -1,5 +1,5 @@
import ClassSelect from '../../../components/select2.js';
import { getToken } from '../../../common/common.js'; import { getToken } from '../../../common/common.js';
import ClassSelect from '../../../components/select2.js';
class DatosLibro { class DatosLibro {
@ -63,7 +63,9 @@ class DatosLibro {
this.retractilado = this.domItem.find('#retractilado'); this.retractilado = this.domItem.find('#retractilado');
this.retractilado5 = this.domItem.find('#retractilado5'); this.retractilado5 = this.domItem.find('#retractilado5');
this.prototipo = this.domItem.find('#prototipo'); this.prototipo = this.domItem.find('#prototipo');
this.prototipo_2 = this.domItem.find('#prototipo_2');
this.ferro = this.domItem.find('#ferro'); this.ferro = this.domItem.find('#ferro');
this.ferro_2 = this.domItem.find('#ferro_2');
this.ferroDigital = this.domItem.find('#ferroDigital'); this.ferroDigital = this.domItem.find('#ferroDigital');
this.marcapaginas = this.domItem.find('#marcapaginas'); this.marcapaginas = this.domItem.find('#marcapaginas');
@ -157,7 +159,9 @@ class DatosLibro {
this.retractilado.on('change', this.checkRetractilado.bind(this)); this.retractilado.on('change', this.checkRetractilado.bind(this));
this.retractilado5.on('change', this.checkRetractilado.bind(this)); this.retractilado5.on('change', this.checkRetractilado.bind(this));
this.ferro.on('change', this.changeFerro.bind(this)); this.ferro.on('change', this.changeFerro.bind(this));
this.ferro_2.on('change', this.changeFerro2.bind(this));
this.prototipo.on('change', this.changePrototipo.bind(this)); this.prototipo.on('change', this.changePrototipo.bind(this));
this.prototipo_2.on('change', this.changePrototipo2.bind(this));
this.ferroDigital.on('change', this.changeFerroDigital.bind(this)); this.ferroDigital.on('change', this.changeFerroDigital.bind(this));
this.tamanio.item.on('select2:select', this.changeFormato.bind(this)); this.tamanio.item.on('select2:select', this.changeFormato.bind(this));
@ -190,7 +194,7 @@ class DatosLibro {
changeFaja() { changeFaja() {
if (this._bloqueoCambioFaja) return; if (this._bloqueoCambioFaja) return;
this._bloqueoCambioFaja = true; this._bloqueoCambioFaja = true;
if (this.faja.prop('checked')) { if (this.faja.prop('checked')) {
this.div_faja.removeClass('d-none'); this.div_faja.removeClass('d-none');
@ -246,6 +250,20 @@ class DatosLibro {
if (this.ferro.prop('checked')) { if (this.ferro.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'ferro'); $(document).trigger('add-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
$(document).trigger('update-presupuesto', { $(document).trigger('update-presupuesto', {
update_lineas: false, update_lineas: false,
update_servicios: false, update_servicios: false,
@ -256,25 +274,63 @@ class DatosLibro {
} }
else { else {
$(document).trigger('remove-servicio-lineas', 'ferro'); $(document).trigger('remove-servicio-lineas', 'ferro');
if (!this.prototipo.prop('checked')) { const table = $('#tableOfDireccionesEnvioFP1').DataTable();
const table = $('#tableOfDireccionesEnvio').DataTable(); table.clear().draw();
const rows = table.rows().data(); $('.datos-envio-fp-1').addClass('d-none');
for (let i = 0; i < rows.length; i++) { $(document).trigger('update-presupuesto', {
const rowData = rows[i]; update_lineas: false,
if (rowData.is_ferro_prototipo == 1) { update_servicios: false,
table.rows(i).remove(); update_envios: true,
table.draw(); update_resumen: true,
break; update_tiradas_alternativas: true
} });
} }
$(document).trigger('update-presupuesto', { }
update_lineas: false,
update_servicios: false, changeFerro2() {
update_envios: true,
update_resumen: true, if (this.cargando)
update_tiradas_alternativas: true return;
});
} if (this.ferro_2.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'ferro_2');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').removeClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.columns.adjust().draw();
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: false,
update_tiradas_alternativas: false
});
}
else {
$(document).trigger('remove-servicio-lineas', 'ferro_2');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
} }
} }
@ -298,6 +354,21 @@ class DatosLibro {
if (this.prototipo.prop('checked')) { if (this.prototipo.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'prototipo'); $(document).trigger('add-servicio-lineas', 'prototipo');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
table_2.columns.adjust().draw();
$(document).trigger('update-presupuesto', { $(document).trigger('update-presupuesto', {
update_lineas: false, update_lineas: false,
update_servicios: false, update_servicios: false,
@ -308,28 +379,64 @@ class DatosLibro {
} }
else { else {
$(document).trigger('remove-servicio-lineas', 'prototipo'); $(document).trigger('remove-servicio-lineas', 'prototipo');
if (!this.ferro.prop('checked')) { const table = $('#tableOfDireccionesEnvioFP1').DataTable();
const table = $('#tableOfDireccionesEnvio').DataTable(); table.clear().draw();
const rows = table.rows().data(); $('.datos-envio-fp-1').addClass('d-none');
for (let i = 0; i < rows.length; i++) { $(document).trigger('update-presupuesto', {
const rowData = rows[i]; update_lineas: false,
if (rowData.is_ferro_prototipo == 1) { update_servicios: false,
table.rows(i).remove(); update_envios: true,
table.draw(); update_resumen: true,
break; update_tiradas_alternativas: true
} });
}
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
} }
} }
changePrototipo2() {
if (this.cargando)
return;
if (this.prototipo_2.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'prototipo_2');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').removeClass('d-none');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.columns.adjust().draw();
$('.check-direccion-fp-2').prop('checked', false);
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: false,
update_tiradas_alternativas: false
});
}
else {
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
}
checkRetractilado(event) { checkRetractilado(event) {
@ -765,7 +872,9 @@ class DatosLibro {
this.retractilado.prop('checked', datos.retractilado); this.retractilado.prop('checked', datos.retractilado);
this.retractilado5.prop('checked', datos.retractilado5); this.retractilado5.prop('checked', datos.retractilado5);
this.prototipo.prop('checked', datos.prototipo); this.prototipo.prop('checked', datos.prototipo);
this.prototipo_2.prop('checked', datos.prototipo2);
this.ferro.prop('checked', datos.ferro); this.ferro.prop('checked', datos.ferro);
this.ferro_2.prop('checked', datos.ferro2);
this.ferroDigital.prop('checked', datos.ferroDigital); this.ferroDigital.prop('checked', datos.ferroDigital);
this.marcapaginas.prop('checked', datos.marcapaginas); this.marcapaginas.prop('checked', datos.marcapaginas);
} }

View File

@ -14,11 +14,15 @@ class Envios {
this.recogerTaller = $('#recoger_en_taller'); this.recogerTaller = $('#recoger_en_taller');
this.table = null; this.table = null;
this.tableFP1 = null;
this.tableFP2 = null;
this.direccionesClienteForm = new ClassSelect($('#add_clientedAdd'), '/misdirecciones/getSelect2', 'Seleccione una direccion', false, {}); this.direccionesClienteForm = new ClassSelect($('#add_clientedAdd'), '/misdirecciones/getSelect2', 'Seleccione una direccion', false, {});
this.paisesClienteForm = new ClassSelect($('#add_pais_id'), '/configuracion/paises/menuitems2', 'Seleccione país', false, {}); this.paisesClienteForm = new ClassSelect($('#add_pais_id'), '/configuracion/paises/menuitems2', 'Seleccione país', false, {});
this.modalYesNo = null; this.modalYesNo = null;
this.insertarEnvio = $('#insertar_direccion'); this.insertarEnvio = $('#insertar_direccion');
this.insertarEnvioFP1 = $('#insertar_direccion_fp1');
this.insertarEnvioFP2 = $('#insertar_direccion_fp2');
this.actionBtns_direcciones = function (data) { this.actionBtns_direcciones = function (data) {
return ` return `
@ -78,7 +82,7 @@ class Envios {
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a> <a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`; `;
}, },
className: 'row-edit dt-center' className: 'row-edit'
} }
], ],
columnDefs: [ columnDefs: [
@ -86,10 +90,12 @@ class Envios {
{ {
orderable: false, orderable: false,
searchable: false, searchable: false,
// all columns
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
//targets: [$('#tableOfDireccionesEnvio').find("tr:first th").length - 1]
}, },
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
], ],
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
@ -114,20 +120,188 @@ class Envios {
$("#costeEnvios").text(total.toFixed(2) + "€" || "0€"); $("#costeEnvios").text(total.toFixed(2) + "€" || "0€");
self.check_unidades_enviadas(null, self.recogerTaller.prop('checked')); self.check_unidades_enviadas(null, self.recogerTaller.prop('checked'));
this.api().columns.adjust();
}
});
this.tableFP1 = $('#tableOfDireccionesEnvioFP1').DataTable({
draw: 5,
serverSide: false,
processing: true,
autoWidth: true,
responsive: true,
pageLength: 20,
lengthChange: false,
searching: false,
paging: false,
info: false,
scrollX: true,
ordering: false,
columns: [
{ 'data': 'tarifa_id' },
{ 'data': 'cantidad' },
{ 'data': 'peso' },
{ 'data': 'att' },
{ 'data': 'email' },
{ 'data': 'direccion' },
{ 'data': 'cp' },
{ 'data': 'municipio' },
{ 'data': 'pais' },
{ 'data': 'pais_id', visible: false },
{ 'data': 'telefono' },
{ 'data': 'proveedor' },
{ 'data': 'proveedor_id', visible: false },
{
'data': 'precio', render: function (data, type, row) {
let coste = parseFloat(data).toFixed(2);
let precio = parseFloat(data * (1 + row.margen / 100.0)).toFixed(2);
return coste + "/" + precio;
}
},
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
{ 'data': 'entregaPieCalle' },
{
data: function (row, type, set, meta) {
return `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`;
},
className: 'row-edit'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
},
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
drawCallback: function (settings) {
const boolCols = [15];
for (let coln of boolCols) {
self.tableFP1.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
this.api().columns.adjust();
if (self.tableFP1.rows().count() > 0) {
$('#rowInsertarEnvioFP1').addClass('d-none');
} else {
$('#rowInsertarEnvioFP1').removeClass('d-none');
}
}
});
this.tableFP2 = $('#tableOfDireccionesEnvioFP2').DataTable({
draw: 5,
serverSide: false,
processing: true,
autoWidth: true,
responsive: true,
pageLength: 20,
lengthChange: false,
searching: false,
paging: false,
info: false,
scrollX: true,
ordering: false,
columns: [
{ 'data': 'tarifa_id' },
{ 'data': 'cantidad' },
{ 'data': 'peso' },
{ 'data': 'att' },
{ 'data': 'email' },
{ 'data': 'direccion' },
{ 'data': 'cp' },
{ 'data': 'municipio' },
{ 'data': 'pais' },
{ 'data': 'pais_id', visible: false },
{ 'data': 'telefono' },
{ 'data': 'proveedor' },
{ 'data': 'proveedor_id', visible: false },
{
'data': 'precio', render: function (data, type, row) {
let coste = parseFloat(data).toFixed(2);
let precio = parseFloat(data * (1 + row.margen / 100.0)).toFixed(2);
return coste + "/" + precio;
}
},
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
{ 'data': 'entregaPieCalle' },
{
data: function (row, type, set, meta) {
return `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`;
},
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
},
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
drawCallback: function (settings) {
const boolCols = [15];
for (let coln of boolCols) {
self.tableFP2.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
this.api().columns.adjust();
if (self.tableFP2.rows().count() > 0) {
$('#rowInsertarEnvioFP2').addClass('d-none');
} else {
$('#rowInsertarEnvioFP2').removeClass('d-none');
}
} }
}); });
$(document).on('click', '.btn-delete-envio', function () { $(document).on('click', '.btn-delete-envio', function () {
const rowId = $(this).closest('td').parent()[0].sectionRowIndex; const rowId = $(this).closest('td').parent()[0].sectionRowIndex;
self.table.row(rowId).remove().draw(); const table = $(this).closest('table').DataTable();
$(document).trigger('update-presupuesto', { table.row(rowId).remove().draw();
update_lineas: false, if (table.table().node().id == 'tableOfDireccionesEnvios') {
update_servicios: false, $(document).trigger('update-presupuesto', {
update_envios: false, update_lineas: false,
update_resumen: true, update_servicios: false,
update_tiradas_alternativas: true update_envios: false,
}); update_resumen: true,
update_tiradas_alternativas: true
});
}
else if (table.table().node().id == 'tableOfDireccionesEnvioFP1') {
$('#rowInsertarEnvioFP1').removeClass('d-none');
}
else if (table.table().node().id == 'tableOfDireccionesEnvioFP2') {
$('#rowInsertarEnvioFP2').removeClass('d-none');
}
}); });
$(document).on('click', '.btn-edit-envio', function () { $(document).on('click', '.btn-edit-envio', function () {
@ -164,7 +338,7 @@ class Envios {
$('#add_telefono').val(data.telefono) $('#add_telefono').val(data.telefono)
$('#add_cantidad').val(data.cantidad) $('#add_cantidad').val(data.cantidad)
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false) $('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false)
self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id }); self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
self.direccionesClienteForm.init(); self.direccionesClienteForm.init();
@ -202,6 +376,8 @@ class Envios {
this.insertarEnvio.on('click', this.addEnvio.bind(this)); this.insertarEnvio.on('click', this.addEnvio.bind(this));
this.insertarEnvioFP1.on('click', this.addEnvio.bind(this, 'fp1'));
this.insertarEnvioFP2.on('click', this.addEnvio.bind(this, 'fp2'));
this.initFormularioDireccionEnvio(); this.initFormularioDireccionEnvio();
@ -212,12 +388,17 @@ class Envios {
$(document).trigger('update-envios-completed'); $(document).trigger('update-envios-completed');
}); });
$(document).on('ckeck-lineas-envios', this.check_unidades_enviadas.bind(this)); $(document).on('ckeck-lineas-envios', this.check_unidades_enviadas.bind(this));
$('#sameAddPrincipalFP1').on('change', this.sameAddPrincipalFP1.bind(this));
$('#sameAddPrincipalFP2').on('change', this.sameAddPrincipalFP2.bind(this));
$('#sameAddFP1').on('change', this.sameAddFP1.bind(this));
} }
addEnvio() { addEnvio(table = '') {
$("#addressForm").attr('action', 'create'); $("#addressForm").attr('action', 'create');
let newAddDialog = $("#addressForm"); let newAddDialog = $("#addressForm");
this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id }); this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
this.direccionesClienteForm.init(); this.direccionesClienteForm.init();
@ -231,14 +412,26 @@ class Envios {
let cantidad_total = 0; let cantidad_total = 0;
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { $('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
let data = this.data(); let data = this.data();
cantidad_total += parseInt(data.cantidad); cantidad_total += parseInt(data.cantidad);
}); });
const restante = parseInt($('#tirada').val()) - cantidad_total; const restante = parseInt($('#tirada').val()) - cantidad_total;
$('#add_cantidad').attr('max-value', restante); $('#add_cantidad').attr('max-value', restante);
$('#add_cantidad').val(restante > 0 ? restante : 0); $('#add_cantidad').val(restante > 0 ? restante : 0);
if (table != '') {
$("#addressForm").attr('data-table', table);
$('#add_entregaPieCalle').prop('disabled', true);
$('#add_cantidad').val(1);
$('#add_cantidad').prop('disabled', true);
}
else {
$("#addressForm").attr('data-table', '');
$('#add_entregaPieCalle').prop('disabled', false);
$('#add_cantidad').prop('disabled', false);
}
newAddDialog.modal('show'); newAddDialog.modal('show');
} }
@ -287,14 +480,63 @@ class Envios {
}) })
}); });
await $('#tableOfDireccionesEnvioFP1').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
}) var data = this.data();
await $.post('/presupuestos/presupuestodirecciones/add',
{
presupuesto_id: id,
tarifa_id: data.tarifa_id,
cantidad: data.cantidad,
peso: data.peso,
att: data.att,
email: data.email,
direccion: data.direccion,
pais_id: data.pais_id,
provincia: data.provincia,
municipio: data.municipio,
cp: data.cp,
telefono: data.telefono,
precio: data.precio,
margen: data.margen,
proveedor: data.proveedor,
proveedor_id: data.proveedor_id,
entregaPieCalle: data.entregaPieCalle,
is_ferro_prototipo: 1,
num_ferro_prototipo: 1
})
});
await $('#tableOfDireccionesEnvioFP2').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
var data = this.data();
await $.post('/presupuestos/presupuestodirecciones/add',
{
presupuesto_id: id,
tarifa_id: data.tarifa_id,
cantidad: data.cantidad,
peso: data.peso,
att: data.att,
email: data.email,
direccion: data.direccion,
pais_id: data.pais_id,
provincia: data.provincia,
municipio: data.municipio,
cp: data.cp,
telefono: data.telefono,
precio: data.precio,
margen: data.margen,
proveedor: data.proveedor,
proveedor_id: data.proveedor_id,
entregaPieCalle: data.entregaPieCalle,
is_ferro_prototipo: 1,
num_ferro_prototipo: 2
})
});
});
} }
async updateTiradaBase() { async updateTiradaBase() {
if($('#noEnvioBase').val() == 1) if ($('#noEnvioBase').val() == 1)
return; return;
const self = this; const self = this;
@ -393,7 +635,7 @@ class Envios {
.draw(); .draw();
self.check_unidades_enviadas(null,null); self.check_unidades_enviadas(null, null);
$(document).trigger('update-presupuesto', { $(document).trigger('update-presupuesto', {
update_lineas: false, update_lineas: false,
@ -494,6 +736,7 @@ class Envios {
$('#add_telefono').val(""); $('#add_telefono').val("");
$('#add_saveDirection').prop('checked', false) $('#add_saveDirection').prop('checked', false)
$('#add_entregaPieCalle').prop('checked', false) $('#add_entregaPieCalle').prop('checked', false)
$('#addressForm').attr('data-table', '');
}); });
$('#cancelAdd').on('click', function () { $('#cancelAdd').on('click', function () {
@ -557,33 +800,86 @@ class Envios {
tarifa_final.cantidad = parseInt($('#add_cantidad').val()) tarifa_final.cantidad = parseInt($('#add_cantidad').val())
tarifa_final.peso = peso_envio tarifa_final.peso = peso_envio
const sourceTable = $('#addressForm').attr('data-table');
self.table.row if (sourceTable === '') {
.add({ self.table.row
'tarifa_id': tarifa_final.id, .add({
'cantidad': tarifa_final.cantidad, 'tarifa_id': tarifa_final.id,
'peso': tarifa_final.peso.toFixed(3), 'cantidad': tarifa_final.cantidad,
'att': $('#add_att').val(), 'peso': tarifa_final.peso.toFixed(3),
'email': $('#add_email').val(), 'att': $('#add_att').val(),
'direccion': $('#add_direccion').val(), 'email': $('#add_email').val(),
'cp': $('#add_cp').val(), 'direccion': $('#add_direccion').val(),
'municipio': $('#add_municipio').val(), 'cp': $('#add_cp').val(),
'provincia': $('#add_provincia').val(), 'municipio': $('#add_municipio').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id, 'provincia': $('#add_provincia').val(),
'pais': $('#add_pais_id').select2('data')[0].text, 'pais_id': $('#add_pais_id').select2('data')[0].id,
'telefono': $('#add_telefono').val(), 'pais': $('#add_pais_id').select2('data')[0].text,
'proveedor': tarifa_final.proveedor, 'telefono': $('#add_telefono').val(),
'proveedor_id': tarifa_final.proveedor_id, 'proveedor': tarifa_final.proveedor,
'precio': tarifa_final.precio, 'proveedor_id': tarifa_final.proveedor_id,
'margen': tarifa_final.margen, 'precio': tarifa_final.precio,
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0, 'margen': tarifa_final.margen,
'actionBtns_direcciones': ` 'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0,
'actionBtns_direcciones': `
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span> <span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a> <a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`, `,
}) })
.draw(); .draw();
}
else if (sourceTable === 'fp1') {
self.tableFP1.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': 0,
'margen': 0,
'entregaPieCalle': 0,
'actionBtns_direcciones': `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`,
})
.draw();
}
else {
self.tableFP2.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': 0,
'margen': 0,
'entregaPieCalle': 0,
'actionBtns_direcciones': `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`,
})
.draw();
}
// Se guarda la dirección // Se guarda la dirección
if ($('#add_saveDirection').is(":checked") && if ($('#add_saveDirection').is(":checked") &&
@ -668,13 +964,26 @@ class Envios {
return returnValue return returnValue
} }
cargar(datos) { cargar(datos, datosFP) {
if (datos.entrega_taller) { if (datos.entrega_taller) {
this.recogerTaller.prop('checked', true); this.recogerTaller.prop('checked', true);
} }
else { else {
this.table.rows.add(datos).draw(); this.table.rows.add(datos).draw();
} }
if (datosFP.fp1.length > 0) {
this.tableFP1.rows.add(datosFP.fp1).draw();
$('#rowInsertarEnvioFP1').addClass('d-none');
}
if (datosFP.fp2.length > 0) {
this.tableFP2.rows.add(datosFP.fp2).draw();
$('#rowInsertarEnvioFP2').addClass('d-none');
}
if(datosFP.checkboxes){
$('#sameAddPrincipalFP1').prop('checked', datosFP.checkboxes.addFP1isAddMain == "1"? true: false);
$('#sameAddPrincipalFP2').prop('checked', datosFP.checkboxes.addFP2isAddMain == "1"? true: false);
$('#sameAddFP1').prop('checked', datosFP.checkboxes.addFP2isaddFP1 == "1"? true: false);
}
} }
check_unidades_enviadas(event, recogerTaller = null) { check_unidades_enviadas(event, recogerTaller = null) {
@ -709,6 +1018,56 @@ class Envios {
$('#alert-envios').html(htmlString); $('#alert-envios').html(htmlString);
return true; return true;
} }
sameAddPrincipalFP1() {
this.tableFP1.clear().draw();
if ($('#sameAddPrincipalFP1').prop('checked')) {
if (this.table.rows().count() > 0) {
let data = this.table.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP1.row.add(data).draw();
}
}
}
sameAddPrincipalFP2() {
$('#sameAddFP1').prop('checked', false);
this.tableFP2.clear().draw();
if ($('#sameAddPrincipalFP2').prop('checked')) {
if (this.table.rows().count() > 0) {
let data = this.table.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP2.row.add(data).draw();
}
}
}
sameAddFP1() {
this.tableFP2.clear().draw();
$('#sameAddPrincipalFP2').prop('checked', false);
if ($('#sameAddFP1').prop('checked')) {
if (this.tableFP1.rows().count() > 0) {
let data = this.tableFP1.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP2.row.add(data).draw();
}
}
}
} }
export default Envios; export default Envios;

View File

@ -119,6 +119,11 @@ class Servicios {
if (!this.checkServiceInTable(this.serviciosExtra.table, id)) if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id); this.serviciosExtra.getPresupuestoExtra(id);
} }
else if (servicio == 'ferro_2') {
const id = $('#ferro_2').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'ferroDigital') { else if (servicio == 'ferroDigital') {
const id = $('#ferroDigital').attr('service-id'); const id = $('#ferroDigital').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id)) if (!this.checkServiceInTable(this.serviciosExtra.table, id))
@ -129,6 +134,11 @@ class Servicios {
if (!this.checkServiceInTable(this.serviciosExtra.table, id)) if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id); this.serviciosExtra.getPresupuestoExtra(id);
} }
else if (servicio == 'prototipo_2') {
const id = $('#prototipo_2').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'retractilado') { else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id'); const id = $('#retractilado').attr('service-id');
if (!this.checkServiceInTable(this.serviciosAcabado.table, id)) if (!this.checkServiceInTable(this.serviciosAcabado.table, id))
@ -201,8 +211,18 @@ class Servicios {
} }
}); });
} }
else if (servicio == 'ferro_2') {
if (servicio == 'ferroDigital') { const id = $('#ferro_2').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
let data = this.data();
if (data.tarifa_id == id) {
this.remove();
self.serviciosExtra.table.draw();
return;
}
});
}
else if (servicio == 'ferroDigital') {
const id = $('#ferroDigital').attr('service-id'); const id = $('#ferroDigital').attr('service-id');
this.serviciosExtra.table.rows().every(function () { this.serviciosExtra.table.rows().every(function () {
let data = this.data(); let data = this.data();
@ -225,6 +245,17 @@ class Servicios {
} }
}); });
} }
else if (servicio == 'prototipo_2') {
const id = $('#prototipo_2').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
var data = this.data();
if (data.tarifa_id == id) {
this.remove();
self.serviciosExtra.table.draw();
return;
}
});
}
else if (servicio == 'retractilado') { else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id'); const id = $('#retractilado').attr('service-id');
for (let i = this.serviciosAcabado.table.rows().count(); i >= 0; i--) { for (let i = this.serviciosAcabado.table.rows().count(); i >= 0; i--) {