añadida entrega a pie de calle y lomo_cubierta

This commit is contained in:
2024-05-13 14:00:43 +02:00
parent 4a12aad3dc
commit 0c78f0af7a
7 changed files with 5032 additions and 16 deletions

View File

@ -983,16 +983,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$direccionId = $reqData['id'] ?? 0; $direccionId = $reqData['id'] ?? 0;
$peso = $reqData['peso'] ?? 0; $peso = $reqData['peso'] ?? 0;
$unidades = $reqData['unidades'] ?? 0; $unidades = $reqData['unidades'] ?? 0;
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
$model = model('App\Models\Clientes\ClienteDireccionesModel'); $model = model('App\Models\Clientes\ClienteDireccionesModel');
$data = $model->getDireccion($direccionId); $data = $model->getDireccion($direccionId);
$modelTarifaEnvio = model('App\Models\Tarifas\TarifaEnvioModel'); $modelTarifaEnvio = model('App\Models\Tarifas\TarifaEnvioModel');
$coste = 0; $coste = 0;
if ($data > 0) { if ($data > 0) {
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $peso, $unidades, 'cajas'); $tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $peso, $unidades, $entregaPieCalle?'palets':'cajas');
for ($i = 0; $i < count($tarifas_envio); $i++) { for ($i = 0; $i < count($tarifas_envio); $i++) {
if ($peso > $tarifas_envio[$i]->peso_max) { if ($peso > $tarifas_envio[$i]->peso_max) {
$tarifas_envio[$i]->precio = number_format($tarifas_envio[$i]->peso_min + ($peso - $data[$i]->peso_min) * $data[$i]->precio_adicional, 2); $tarifas_envio[$i]->precio = number_format($tarifas_envio[$i]->peso_min + ($peso - $tarifas_envio[$i]->peso_min) * $tarifas_envio[$i]->precio_adicional, 2);
} }
// si no se calcula linealmente // si no se calcula linealmente
else { else {
@ -1016,7 +1017,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
$data[0]->coste = $coste; if(count($data)>0){
$data[0]->coste = $coste;
$data[0]->tipo = $entregaPieCalle?'palets':'cajas';
}
return $this->respond([ return $this->respond([
'data' => $data, 'data' => $data,

View File

@ -1,11 +1,8 @@
<div class="col-12 pb-2"> <div class="col-12 pb-2">
<div id="containerTiradasEnvios" class="row mb-3"> <div id="containerTiradasEnvios" class="row mb-3">
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-sm-4 mb-3"> <div class="col-sm-4 mb-3">
@ -25,6 +22,14 @@
</div> </div>
</div> </div>
<div class="row mb-3">
<div class="col-sm-4 mb-3">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="entregaPieCalle" name="entregaPieCalle" value="1">
<label class="form-check-label" for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
</div>
</div>
</div>
<div id="divDirecciones" class="col-12 pb-2"> <div id="divDirecciones" class="col-12 pb-2">
@ -35,8 +40,8 @@
<?= $this->section("additionalInlineJs") ?> <?= $this->section("additionalInlineJs") ?>
window.routes_direcciones = { window.routes_direcciones = {
direcciones: "<?= route_to('getDirecciones') ?>", direcciones: "<?= route_to('getDirecciones') ?>",
getDatos: "<?= route_to('getDatosDireccion') ?>", getDatos: "<?= route_to('getDatosDireccion') ?>",
nuevaDireccion: "<?= route_to('nuevaDireccion') ?>", nuevaDireccion: "<?= route_to('nuevaDireccion') ?>",
} }
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -1,5 +1,8 @@
<div class="col-12 pb-2"> <div class="col-12 pb-2">
<div class="tipo_libro"> <div class="tipo_libro">
<input hidden readonly id="lomo_cubierta" name="lomo_cubierta" maxLength="12" class="form-control" value="<?= old('lomoCubierta', $presupuestoEntity->lomoCubierta) ?>">
<div class="row row-cols-3 mb-6 d-flex justify-content-center d-flex justify-content-center"> <div class="row row-cols-3 mb-6 d-flex justify-content-center d-flex justify-content-center">
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;"> <div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">

View File

@ -141,10 +141,13 @@ $('#insertarDireccion').on('click', function() {
data = { data = {
id: $('#direcciones').val(), id: $('#direcciones').val(),
peso: $('#env_tiradaPrecio' + number[0]).attr('peso'), peso: $('#env_tiradaPrecio' + number[0]).attr('peso'),
unidades: unidades unidades: unidades,
entregaPieCalle: $('#entregaPieCalle').is(':checked')?1:0,
}, },
data = Object.assign(data, window.token_ajax) data = Object.assign(data, window.token_ajax)
$('#loader').show();
$.ajax({ $.ajax({
url: window.routes_direcciones.getDatos, url: window.routes_direcciones.getDatos,
type: 'POST', type: 'POST',
@ -152,7 +155,7 @@ $('#insertarDireccion').on('click', function() {
success: function(response) { success: function(response) {
if(response.data.length > 0) { if(response.data.length > 0) {
let html = ''; let html = '';
html += '<div id="envioId' + response.data[0].id + '" p= ' +response.data[0].coste + ' class="row mb-3">'; html += '<div id="envioId' + response.data[0].id + '" t= ' +response.data[0].tipo + '" p= ' +response.data[0].coste + ' class="row mb-3">';
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">'; html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">'; html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
html += '<span class="custom-option-header mb-2">'; html += '<span class="custom-option-header mb-2">';
@ -176,10 +179,12 @@ $('#insertarDireccion').on('click', function() {
$('#divDirecciones').append(html); $('#divDirecciones').append(html);
$('#errorDirecciones').hide(); $('#errorDirecciones').hide();
$('#loader').hide();
} }
}, },
error: function() { error: function() {
$("#direcciones").empty(); $("#direcciones").empty();
$('#loader').hide();
}, },
}); });
} }
@ -259,7 +264,6 @@ function saveAdd_callback(){
cp: $('#add_cp').val(), cp: $('#add_cp').val(),
telefono: $('#add_telefono').val(), telefono: $('#add_telefono').val(),
} }
console.log(data);
data = Object.assign(data, window.token_ajax) data = Object.assign(data, window.token_ajax)
$.ajax({ $.ajax({

View File

@ -711,6 +711,8 @@ async function calcularPresupuesto() {
$('#divTiradasPrecio').empty(); $('#divTiradasPrecio').empty();
$('#lomo_cubierta').val(response.lomo_cubierta);
$('#precios').show(); $('#precios').show();
for (i = 0; i < response.tiradas.length; i++) { for (i = 0; i < response.tiradas.length; i++) {
@ -719,7 +721,6 @@ async function calcularPresupuesto() {
let html = ''; let html = '';
html += '<div id="' + label + '" peso="' +response.peso[i]+ '" class="list-group" >'; html += '<div id="' + label + '" peso="' +response.peso[i]+ '" class="list-group" >';
html += '<a href="javascript:void(0);" class="list-group-item list-group-item-action">'; html += '<a href="javascript:void(0);" class="list-group-item list-group-item-action">';
html += '<div class="li-wrapper d-flex justify-content-start align-items-center" >'; html += '<div class="li-wrapper d-flex justify-content-start align-items-center" >';

View File

@ -33,7 +33,7 @@ function generarResumen(){
let papelCubierta = $('#papelCubierta option:selected').text().trim() + ' ' + let papelCubierta = $('#papelCubierta option:selected').text().trim() + ' ' +
$('#gramajeCubierta option:selected').text(); $('#gramajeCubierta option:selected').text();
papelCubierta += 'gr/m<sup>2</sup>'; papelCubierta += 'gr/m²';
$('#resumenPapelCubierta').text(papelCubierta); $('#resumenPapelCubierta').text(papelCubierta);
$('#resumenCarasCubierta').text('Impresión: ' + $('#carasCubierta option:selected').text()) $('#resumenCarasCubierta').text('Impresión: ' + $('#carasCubierta option:selected').text())
$('#resumenAcabadoCubierta').text('Acabado: ' + $('#acabadosCubierta option:selected').text()) $('#resumenAcabadoCubierta').text('Acabado: ' + $('#acabadosCubierta option:selected').text())

4998
xdebug.log

File diff suppressed because one or more lines are too long