corregido bug que no permitia guardar presupuesto

This commit is contained in:
75134972k
2024-03-13 14:29:39 +01:00
parent b645fb030c
commit 231a0c7cb2
16 changed files with 71 additions and 131 deletions

View File

@ -60,14 +60,18 @@ class Maquinascalles extends \App\Controllers\GoBaseResourceController
'message' => lang('MaquinasCalles.validation.formas.required'))
),
Field::inst('internas')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator('Validate::numeric', array(
"decimal" => ',',
'message' => lang('MaquinasCalles.validation.internas.decimal'))
)
->validator('Validate::notEmpty', array(
'message' => lang('MaquinasCalles.validation.internas.required'))
),
Field::inst('externas')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator('Validate::numeric', array(
"decimal" => ',',
'message' => lang('MaquinasCalles.validation.externas.decimal'))
)
->validator('Validate::notEmpty', array(

View File

@ -718,14 +718,7 @@ $(document).on('click', '.btn-remove', function(e) {
}
});
const url = window.location.href;
const url_parts = url.split('/');
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else{
id = -1;
}
<?=$this->endSection() ?>

View File

@ -79,12 +79,11 @@
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else{
id = -1;
}
const actionBtns_lineas = function(data) {
return `

View File

@ -313,12 +313,10 @@
const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else{
id = -1;
}
const actionBtns = function(data) {
return `

View File

@ -66,11 +66,10 @@
// JJO
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else
id = -1;
const lastColNr = $('#tableOfPapelesimpresion').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle">

View File

@ -148,12 +148,10 @@
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else{
id = -1;
}
$('#papelGenericoId').select2({

View File

@ -279,7 +279,7 @@ $('#recoger_en_taller').change(function(){
})
var tableEnvios = $('#tableOfDireccionesEnvio').DataTable( {
let tableEnvios = $('#tableOfDireccionesEnvio').DataTable( {
draw:5,
serverSide: false,
processing: true,
@ -346,11 +346,14 @@ var tableEnvios = $('#tableOfDireccionesEnvio').DataTable( {
function save_datos_envios(){
var id = $('#presupuesto_id').val()
$.post( window.routes_envios.dataTableOfPresupuestoDirecciones,
Object.assign({tipo: "clear_lineas", presupuesto_id: id}, window.token_ajax))
.done(function( data ) {
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
$.post( '/presupuestos/presupuestodirecciones/add',
Object.assign({

View File

@ -1,44 +0,0 @@
// Test case 1: Valid inputs
const peso = 10;
const paisId = 1;
const cp = "12345";
const tipo_envio = "express";
get_precio_envio(peso, paisId, cp, tipo_envio)
.then(data => {
console.log("Test case 1 - Result:", data);
// Add your assertions here
})
.catch(error => {
console.error("Test case 1 - Error:", error);
});
// Test case 2: Invalid inputs
const peso = -5;
const paisId = 0;
const cp = "";
const tipo_envio = "standard";
get_precio_envio(peso, paisId, cp, tipo_envio)
.then(data => {
console.log("Test case 2 - Result:", data);
// Add your assertions here
})
.catch(error => {
console.error("Test case 2 - Error:", error);
});
// Test case 3: Network error
const peso = 20;
const paisId = 2;
const cp = "54321";
const tipo_envio = "priority";
get_precio_envio(peso, paisId, cp, tipo_envio)
.then(data => {
console.log("Test case 3 - Result:", data);
// Add your assertions here
})
.catch(error => {
console.error("Test case 3 - Error:", error);
});

View File

@ -28,7 +28,7 @@ $('#paginas').on("change", function () {
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
})
})
}
});
@ -103,7 +103,9 @@ function calcular_mermas(){
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang("Presupuestos.validation.no_lp_for_merma") ?></h5>
<h5 class="alert-heading mb-2">` +
window.Presupuestos.validation.no_lp_for_merma +
`</h5>
</div>
</div>`;
@ -119,10 +121,6 @@ function calcular_mermas(){
}
$('#papelFormatoId').select2({
allowClear: false,
});
$('#papelFormatoPersonalizado').on("click",function(){
var checkbox = document.getElementById('papelFormatoPersonalizado');
if(checkbox.checked == true){
@ -131,8 +129,8 @@ $('#papelFormatoPersonalizado').on("click",function(){
$('#papelFormatoId').next(".select2-container").hide();
$('#papelFormatoId').val(0).change();
document.getElementById("label_papelFormatoId").innerHTML =
"<?=lang('Presupuestos.papelFormatoId') ?> (" +
"<?=lang('Presupuestos.papelFormatoAncho') ?> x <?=lang('Presupuestos.papelFormatoAncho') ?>)*";
window.Presupuestos.papelFormatoId + " (" +
window.Presupuestos.papelFormatoAncho + " x " + window.Presupuestos.papelFormatoAncho + ")*";
}
else{
document.getElementById("papelFormatoAncho").value= "";
@ -141,6 +139,7 @@ $('#papelFormatoPersonalizado').on("click",function(){
document.getElementById("papelFormatoAlto").style.display = "none";
$('#papelFormatoId').next(".select2-container").show();
document.getElementById("label_papelFormatoId").innerHTML =
"<?=lang('Presupuestos.papelFormatoId') ?>*";
window.Presupuestos.papelFormatoId + '*';
}
});
});

View File

@ -327,15 +327,9 @@
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
let initTamanioPersonalizado = <?php echo ($presupuestoEntity->papel_formato_personalizado==true?1:0); ?>;
if(initTamanioPersonalizado != null){
if ( initTamanioPersonalizado){
$('#papelFormatoId').next(".select2-container").hide();
}
}
$('#papelFormatoId').select2({
allowClear: false,
});
<?php if(str_contains($formAction,'edit')): ?>
var ancho_libro = getDimensionLibro().ancho;
@ -431,4 +425,11 @@ $("#solapas_sobrecubierta").on("click", function () {
$('#serv_default').click()
});
let initTamanioPersonalizado = <?php echo ($presupuestoEntity->papel_formato_personalizado==true?1:0); ?>;
if(initTamanioPersonalizado != null){
if ( initTamanioPersonalizado){
$('#papelFormatoId').next(".select2-container").hide();
}
}
<?= $this->endSection() ?>

View File

@ -82,11 +82,9 @@ function save_servicios(){
const url = window.location.href;
const url_parts = url.split('/');
var id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
const id = url_parts[url_parts.length-1];
}
else{
const id = -1;
id = url_parts[url_parts.length-1];
}
fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , {
@ -424,11 +422,9 @@ async function get_servAcabados_tiradasAlternativas(tirada){
const url = window.location.href;
const url_parts = url.split('/');
var id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
const id = url_parts[url_parts.length-1];
}
else{
const id = -1;
id = url_parts[url_parts.length-1];
}
var serviciosAcabados ={
@ -822,11 +818,9 @@ async function get_servEncuadernacion_tiradasAlternativas(tirada, paginas, ancho
const url = window.location.href;
const url_parts = url.split('/');
var id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
const id = url_parts[url_parts.length-1];
}
else{
const id = -1;
id = url_parts[url_parts.length-1];
}
var serviciosEncuadernacion ={
@ -1083,11 +1077,9 @@ async function get_servManipulado_tiradasAlternativas(tirada){
const url = window.location.href;
const url_parts = url.split('/');
var id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
const id = url_parts[url_parts.length-1];
}
else{
const id = -1;
id = url_parts[url_parts.length-1];
}
var serviciosManipulado ={
@ -1342,11 +1334,9 @@ async function get_servPreimpresion_tiradasAlternativas(){
const url = window.location.href;
const url_parts = url.split('/');
var id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
const id = url_parts[url_parts.length-1];
}
else{
const id = -1;
id = url_parts[url_parts.length-1];
}
var serviciosPreimpresion ={
@ -1388,11 +1378,9 @@ async function actualizar_servicios(update_preimpresion=false){
const domain = window.location.origin
const url = window.location.href;
const url_parts = url.split('/');
var id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
const id = url_parts[url_parts.length-1];
}
else{
const id = -1;
id = url_parts[url_parts.length-1];
}
const dimension = getDimensionLibro();

View File

@ -309,7 +309,9 @@ function checkPaginasPresupuesto(){
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang("Presupuestos.errores.paginasLP") ?></h5>
<h5 class="alert-heading mb-2">` +
window.Presupuestos.errores.paginasLP +
`</h5>
</div>
</div>`;
}
@ -1257,7 +1259,7 @@ $('.insertarLinea').on("click", function (e) {
if(row.tipo == 'cubierta'){
fill_lp_cubierta(row, true);
if($('#acabado_cubierta_id').val() > 0)
insertar_acabado_exterior($('#acabado_cubierta_id').val(), '<?= lang("Presupuestos.cubierta") ?>')
insertar_acabado_exterior($('#acabado_cubierta_id').val(), window.Presupuestos.cubierta)
}
}
@ -1267,7 +1269,7 @@ $('.insertarLinea').on("click", function (e) {
if(row.tipo == 'sobrecubierta'){
fill_lp_sobrecubierta(row, true);
if($('#acabado_sobrecubierta_id').val() > 0)
insertar_acabado_exterior($('#acabado_sobrecubierta_id').val(), '<?= lang("Presupuestos.sobrecubierta") ?>')
insertar_acabado_exterior($('#acabado_sobrecubierta_id').val(), window.Presupuestos.sobrecubierta)
}
}
}
@ -1284,7 +1286,12 @@ $('.insertarLinea').on("click", function (e) {
}
update_servicios()
updatePresupuesto({
update_lineas: false,
update_servicios: true,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true})
});

View File

@ -177,19 +177,23 @@ async function add_tirada_alternativa(tirada_alt) {
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang("Presupuestos.errores.tirada_alt_duplicada") ?></h5>
<h5 class="alert-heading mb-2">` +
window.Presupuestos.errores.tirada_alt_duplicada +
`</h5>
</div>
</div>`;
}
else{
else{
htmlString = `
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang("Presupuestos.errores.tirada_alt_tipo") ?></h5>
<h5 class="alert-heading mb-2">` +
window.Presupuestos.errores.tirada_alt_tipo +
`</h5>
</div>
</div>`;
}

View File

@ -13,6 +13,8 @@
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<input type="hidden" name="presupuesto_id" id="presupuesto_id" class="form-control"
value="<?= $presupuestoEntity->id ?>"></input>
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control"
value="<?= $tipo_impresion_id ?>"></input>
<input type="hidden" name="isCosido" id="isCosido" class="form-control"
@ -240,15 +242,6 @@
<!------------------------------------------->
<!-- Acciones antes de submit... -->
<!------------------------------------------->
const url = window.location.href;
const url_parts = url.split('/');
if (url_parts[url_parts.length - 2] == 'edit') {
id = url_parts[url_parts.length - 1];
} else {
id = -1;
}
<?php if (str_contains($formAction, 'edit')): ?>
<?= $this->section("additionalInlineJs") ?>
@ -263,7 +256,9 @@ if (url_parts[url_parts.length - 2] == 'edit') {
save_servicios();
save_datos_envios();
$.when(fill_bbdd_from_lp(id).then(function(data, textStatus, jqXHR) {
var presupuesto_id = $('#presupuesto_id').val()
$.when(fill_bbdd_from_lp(presupuesto_id).then(function(data, textStatus, jqXHR) {
generateCompJSON()
generate_json_tiradas()
form = $('#presupuestoForm').serialize()

View File

@ -71,12 +71,10 @@
const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else{
id = -1;
}
const actionBtns = function(data) {
return `

View File

@ -71,12 +71,10 @@
const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else{
id = -1;
}
const actionBtns = function(data) {
return `