diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index b118a844..41f5c28d 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -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() { diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 071fcce8..eba24c4a 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -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.', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 6e971e3f..2231446b 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -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' => [ diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php index dbf15f72..a27d5d2a 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -424,6 +424,8 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel } } + + } diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index c85fc822..e2b865e4 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -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{ diff --git a/ci4/app/Views/themes/_commonPartialsBs/_modalMessageDialog.php b/ci4/app/Views/themes/_commonPartialsBs/_modalMessageDialog.php new file mode 100644 index 00000000..1594aa27 --- /dev/null +++ b/ci4/app/Views/themes/_commonPartialsBs/_modalMessageDialog.php @@ -0,0 +1,36 @@ + + +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"); + }); + } + +endSection() ?> + + diff --git a/ci4/app/Views/themes/backend/vuexy/form/login/index.php b/ci4/app/Views/themes/backend/vuexy/form/login/index.php index 0f7dda27..b9f0c32a 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/login/index.php +++ b/ci4/app/Views/themes/backend/vuexy/form/login/index.php @@ -33,7 +33,6 @@

👋

-

diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index bbfb8b10..49105ce8 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -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); } } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 48fe8d43..1e354ad2 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -57,6 +57,7 @@ + endSection() ?> @@ -65,29 +66,44 @@ section("additionalInlineJs") ?> - $('#cloneForm').on('click', function(e) { - $.ajax({ - type: 'post', - url: '', - - data: { - tipo: 'duplicar', - presupuesto_id: id, - : v - }, - dataType: 'json', - success:function(response){ - - token=response.; - yeniden(token); - // redirect - new_location = '' + 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('', '', function() { + $.ajax({ + type: 'post', + url: '', + + data: { + tipo: 'duplicar', + presupuesto_id: id, + : v + }, + dataType: 'json', + success:function(response){ + + token=response.; + yeniden(token); + // redirect + new_location = '' + response.id + window.location.href = new_location; + } + }).fail(function (jqXHR, textStatus, error) { + // Handle error here + console.log(jqXHR) + }); + }) + } });