mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado plantillas
This commit is contained in:
@ -567,7 +567,7 @@
|
||||
|
||||
<?php if ($formAction !== site_url('cliente/add')){ ?>
|
||||
<div class="tab-pane fade" id="tarifascliente" role="tabpanel">
|
||||
|
||||
<?= view("themes/backend/vuexy/form/clientes/cliente/convert2templateModal") ?>
|
||||
<div class='row'>
|
||||
<div class="col-md-12 col-lg-4 px-4">
|
||||
<div class="mb-3">
|
||||
@ -1055,6 +1055,19 @@ else{
|
||||
})
|
||||
})
|
||||
|
||||
editorPrecios.on ('postCreate', function ( e, json, data, action ) {
|
||||
const domain = window.location.origin
|
||||
fetch(domain + "/clientes/clienteprecios/update/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
var theTablePrecios = $('#tableOfPrecios').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
@ -1153,15 +1166,12 @@ else{
|
||||
} ]
|
||||
} );
|
||||
|
||||
theTablePrecios.on( 'draw', function () {
|
||||
if(theTablePrecios.rows().count()){
|
||||
$('#plantillas').select2('data', { id: theTablePrecios.row(0).data().plantilla_id , label:'plantilla'});
|
||||
$('#plantillas').val(theTablePrecios.row(0).data().plantilla_id)
|
||||
console.log(theTablePrecios.row(0).data().plantilla_id)
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
const initPrecioTemplate = <?php echo json_encode($precioTemplate);?>;
|
||||
if(initPrecioTemplate != null){
|
||||
var newOption = new Option(initPrecioTemplate.label, initPrecioTemplate.value, false, false);
|
||||
$('#plantillas').append(newOption);
|
||||
}
|
||||
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
@ -1198,10 +1208,7 @@ else{
|
||||
}
|
||||
}
|
||||
|
||||
$('#plantillas').select2('data', {id:103, label:'ENABLED_FROM_JS'});
|
||||
$('#plantillas').val(103).trigger();
|
||||
|
||||
|
||||
|
||||
$('#plantillas').on('change.select2', function(){
|
||||
const data = $('#plantillas').select2('data');
|
||||
if(data.length>0){
|
||||
@ -1223,6 +1230,14 @@ else{
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#convert2template').on('click', function(){
|
||||
var newAddDialog = $('#convert2Template')
|
||||
newAddDialog.modal("show");
|
||||
|
||||
})
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
<div id="convert2Template" class="modal fade addModal">
|
||||
<div class="modal-dialog modal-lg modal-simple">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 id="labelTitleConfirmDialog" class="modal-title"><?= lang('ClientePrecios.convertir2plantilla') ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id='error-nombre'></div>
|
||||
|
||||
<div class="mb-3">
|
||||
<p><?= lang('ClientePrecios.convertir2plantillaText') ?></p>
|
||||
<p><?= lang('ClientePrecios.convertir2plantillaText2') ?></p>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="nombre_plantilla" class="form-label">
|
||||
<?= lang('ClientePrecios.nombrePlantilla') ?>
|
||||
</label>
|
||||
<input type="text" id="nombre_plantilla" maxLength="100" class="form-control new-address">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="saveTemplate"
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
><?= lang('App.global_save') ?></button>
|
||||
<button id="cancelTemplate"
|
||||
type="button"
|
||||
class="btn btn-default"
|
||||
><?= lang('App.user_delete_btn_cancel') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
$('#saveTemplate').on('click', function(){
|
||||
if($('#nombre_plantilla').val().length == 0){
|
||||
popErrorAlert('<?= lang('ClientePrecios.errors.error_nombre_template') ?>', 'error-nombre')
|
||||
}
|
||||
else{
|
||||
data = new FormData();
|
||||
data.append('cliente_id', id)
|
||||
data.append('nombre', $('#nombre_plantilla').val())
|
||||
data.append('<?= csrf_token() ?? "token" ?>', <?= csrf_token() ?>v)
|
||||
fetch('<?= route_to("createClienteplantillaprecios");?>' , {
|
||||
method: "POST",
|
||||
body: data,
|
||||
})
|
||||
.then(data => {
|
||||
$('#convert2Template').modal("hide");
|
||||
var newOption = new Option($('#nombre_plantilla').val(), "", false, false);
|
||||
$('#plantillas').append(newOption);
|
||||
$('#nombre_plantilla').val("");
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$('#cancelTemplate').on('click', function(){
|
||||
$('#convert2Template').modal("hide");
|
||||
})
|
||||
<?=$this->endSection() ?>
|
||||
@ -41,8 +41,11 @@
|
||||
{ e.preventDefault()
|
||||
if($('#addressForm').hasClass('show')){
|
||||
$("#saveAdd").click();
|
||||
|
||||
}else{
|
||||
}
|
||||
else if ($('#convert2Template').hasClass('show')){
|
||||
$("#saveTemplate").click();
|
||||
}
|
||||
else{
|
||||
$('#saveForm').click();
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,6 +86,19 @@
|
||||
$('#confirm2delete').modal('toggle');
|
||||
tablePLantillaPrecios.clearPipeline();
|
||||
tablePLantillaPrecios.row($(row)).invalidate().draw();
|
||||
|
||||
// Se borran las lineas asociadas
|
||||
const domain = window.location.origin
|
||||
fetch(domain + "/clientes/clienteplantillaprecios/update/" + dataId , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
|
||||
Reference in New Issue
Block a user