terminado con un mensaje de alerta cuando se duplican y tienen tipologías

This commit is contained in:
Jaime Jiménez
2024-03-09 18:48:35 +01:00
parent 6428224921
commit bd7ab73e75
9 changed files with 150 additions and 27 deletions

View File

@ -383,6 +383,69 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
} // end function edit(...)
/**
* Delete the designated resource object from the model.
*
* @param int $id
*
* @return array an array
*/
public function delete($id = null)
{
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
} else {
$objName = lang('Basic.global.record');
}
if (!$this->soft_delete){
if (!$this->model->delete($id)) {
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
}
}
else{
$datetime = (new \CodeIgniter\I18n\Time("now"));
$rawResult = $this->model->where('id',$id)
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
'is_deleted' => $this->delete_flag])
->update();
if (!$rawResult) {
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
}
}
// Se borran las lineas de presupuesto
$model = new PresupuestoLineaModel();
$model->where("presupuesto_id", $id)->delete();
// Se borran las direcciones de presupuesto
$model = new PresupuestoDireccionesModel();
$model->where("presupuesto_id", $id)->delete();
// Se borran los servicios de acabado
$model = new PresupuestoAcabadosModel();
$model->where("presupuesto_id", $id)->delete();
// Se borran los servicios de preimpresion
$model = new PresupuestoPreimpresionesModel();
$model->where("presupuesto_id", $id)->delete();
// Se borran los servicios de encuadernacion
$model = new PresupuestoEncuadernacionesModel();
$model->where("presupuesto_id", $id)->delete();
// Se borran los servicios de manipulado
$model = new PresupuestoManipuladosModel();
$model->where("presupuesto_id", $id)->delete();
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
$response = $this->respondDeleted(['id' => $id, 'msg' => $message]);
return $response;
}
public function datatable()
{

View File

@ -156,6 +156,8 @@ return [
'cantidad' => 'Quantity',
'duplicado' => 'DUPLICATED',
'duplicarConTipologias' => 'The budget contains budget lines with typology data. The budget will be duplicated with the same typologies',
'validation' => [
'decimal' => 'The {field} field must contain a decimal number.',
'integer' => 'The {field} field must contain an integer.',

View File

@ -247,6 +247,8 @@ return [
'tiradaEnvio' => 'Coste Envío',
'tiradaImpresion' => 'Coste Impresión',
'duplicado' => 'DUPLICADO',
'duplicarConTipologias' => 'El presupuesto contiene lineas de presupuesto con datos de tipologías. Se va a duplicar el presupuesto con las mismas tipologías',
'validation' => [

View File

@ -424,6 +424,8 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel
}
}
}

View File

@ -196,12 +196,14 @@ class PresupuestoService extends BaseService
$resultado_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo) ? 'color' : $tipo);
if($resultado_tarifa == null){
/*
$info = [
'maquina_id' => $maquina->maquina_id,
'uso' => $uso,
'tipo' => is_array($tipo) ? 'color' : $tipo
];
log_message("error","No se ha encontrado tarifa para la maquina {maquina_id} y el uso {uso} y el tipo {tipo}", $info);
*/
return [];
}
else{

View File

@ -0,0 +1,36 @@
<div id="modalMessage" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 id="labelTitleMessageDialog" class="modal-title"></h4>
</div>
<div class="modal-body">
<p id="labelMsgMessageDialog"></p>
</div>
<div class="modal-footer">
<button id="okButton"
type="button"
class="btn btn-primary"
><?= lang('Basic.global.ok') ?></button>
</div>
</div>
</div>
</div>
<?= $this->section('additionalInlineJs') ?>
function asyncMessageDialog(title, msg, callback) {
var $messageDialog = $("#modalMessage");
$messageDialog.modal('show');
$("#labelTitleMessageDialog").html(title);
$("#labelMsgMessageDialog").html(msg);
$("#okButton").off('click').click(function () {
callback();
$confirmDialog.modal("hide");
});
}
<?= $this->endSection() ?>

View File

@ -33,7 +33,6 @@
</div>
<!-- /Logo -->
<h3 class="mb-1 fw-bold"><?= lang("App.login_title") ?> 👋</h3>
<p class="mb-4"><?= lang("App.login_subtitle") ?></p>
<form id="formAuthentication" class="mb-3" action="<?= site_url('login/authenticate'); ?>" method="POST">
<?= csrf_field() ?>

View File

@ -2722,7 +2722,7 @@ function change_lp_rot_bn_aFavorFibra(){
}
function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=false, input_data={}){
async function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=false, input_data={}){
const dimension = getDimensionLibro();
@ -2768,7 +2768,7 @@ function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=fals
datos.amarillo= $('#lp_rot_bn_cobAmarillo').val()
}
$.ajax({
await $.ajax({
type: "POST",
url: "/cosidotapablanda/datatable",
data: datos,
@ -2826,11 +2826,12 @@ function change_lp_rot_bn_tipologia(){
){
calcularPresupuesto_rot_bn(false,true);
}
}
function por_defecto_lp_rot_bn(){
function por_defecto_lp_rot_bn(wait_result = false){
if( parseInt($('#lp_rot_bn_paginas').val())>0 &&
parseInt($('#lp_rot_bn_papel option:selected').val())>0 &&
@ -2838,7 +2839,7 @@ function por_defecto_lp_rot_bn(){
parseInt($('#lp_rot_bn_papelImpresion option:selected').val())>0
){
calcularPresupuesto_rot_bn(false);
calcularPresupuesto_rot_bn(false);
}
}

View File

@ -57,6 +57,7 @@
</div><!--//.col -->
</div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
<?= $this->endSection() ?>
@ -65,29 +66,44 @@
<!------------------------------------------->
<?php if (str_contains($formAction, 'edit')): ?>
<?= $this->section("additionalInlineJs") ?>
$('#cloneForm').on('click', function(e) {
$.ajax({
type: 'post',
url: '<?= route_to("updateDataOfCosidotapablanda") ?>',
data: {
tipo: 'duplicar',
presupuesto_id: id,
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v
},
dataType: 'json',
success:function(response){
token=response.<?= csrf_token() ?>;
yeniden(token);
// redirect
new_location = '<?= site_url("presupuestos/cosidotapablanda/edit/") ?>' + response.id
window.location.href = new_location;
$('#cloneForm').on('click', async function(e) {
// se comprueba que no haya lineas de presupuesto en el que exista la variable gotaNegro
var gotaNegro = false
$("#tableLineasPresupuesto").DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(rowData.hasOwnProperty('gotaNegro')){
gotaNegro = true
return;
}
}).fail(function (jqXHR, textStatus, error) {
// Handle error here
console.log(jqXHR)
});
})
if(gotaNegro){
asyncMessageDialog('<?= lang("Basic.global.Warning") ?>', '<?= lang("Presupuestos.duplicarConTipologias") ?>', function() {
$.ajax({
type: 'post',
url: '<?= route_to("updateDataOfCosidotapablanda") ?>',
data: {
tipo: 'duplicar',
presupuesto_id: id,
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v
},
dataType: 'json',
success:function(response){
token=response.<?= csrf_token() ?>;
yeniden(token);
// redirect
new_location = '<?= site_url("presupuestos/cosidotapablanda/edit/") ?>' + response.id
window.location.href = new_location;
}
}).fail(function (jqXHR, textStatus, error) {
// Handle error here
console.log(jqXHR)
});
})
}
});