Añadido datatable de cliente_contactos

This commit is contained in:
imnavajas
2023-08-08 12:22:50 +02:00
parent 1db71f8564
commit 7d61213f28
7 changed files with 175 additions and 27 deletions

View File

@ -15,6 +15,7 @@
Ficha de Cliente
</button>
</li>
<?php if ($formAction !== site_url('cliente/add')){ ?>
<li class="nav-item">
<button
type="button"
@ -27,6 +28,7 @@
Contactos
</button>
</li>
<?php } ?>
<li class="nav-item">
<button
type="button"
@ -135,8 +137,7 @@
name="direccion"
style="height: 10em;"
class="form-control"
>
<?= old('direccion', $clienteEntity->direccion) ?>
><?= old('direccion', $clienteEntity->direccion) ?>
</textarea>
</div>
<div class="col-md-4">
@ -417,7 +418,8 @@
<div class="col-md-3">
<div class="form-check">
<label for="disponibleFe" class="form-check-label">
<input type="checkbox" id="disponibleFe" name="disponible_fe" value="1"
<input type="checkbox" id="disponibleFe" name="disponible_fe"
value="1"
class="form-check-input"<?= $clienteEntity->disponible_fe == true ? 'checked' : ''; ?>>
<?= lang('Clientes.disponibleFe') ?>
</label>
@ -426,7 +428,8 @@
<div class="col-md-3">
<div class="form-check">
<label for="messageTracking" class="form-check-label">
<input type="checkbox" id="messageTracking" name="message_tracking" value="1"
<input type="checkbox" id="messageTracking" name="message_tracking"
value="1"
class="form-check-input"<?= $clienteEntity->message_tracking == true ? 'checked' : ''; ?>>
<?= lang('Clientes.messageTracking') ?>
</label>
@ -435,7 +438,8 @@
<div class="col-md-3">
<div class="form-check">
<label for="messageProductionStart" class="form-check-label">
<input type="checkbox" id="messageProductionStart" name="message_production_start" value="1"
<input type="checkbox" id="messageProductionStart"
name="message_production_start" value="1"
class="form-check-input"<?= $clienteEntity->message_production_start == true ? 'checked' : ''; ?>>
<?= lang('Clientes.messageProductionStart') ?>
</label>
@ -444,7 +448,8 @@
<div class="col-md-3">
<div class="form-check">
<label for="tiradaFlexible" class="form-check-label">
<input type="checkbox" id="tiradaFlexible" name="tirada_flexible" value="1"
<input type="checkbox" id="tiradaFlexible" name="tirada_flexible"
value="1"
class="form-check-input"<?= $clienteEntity->tirada_flexible == true ? 'checked' : ''; ?>>
<?= lang('Clientes.tiradaFlexible') ?>
</label>
@ -479,9 +484,25 @@
</div>
</div>
<?php if ($formAction !== site_url('cliente/add')){ ?>
<div class="tab-pane fade" id="contactos" role="tabpanel">
<h3>Proximanente</h3>
<table id="tableOfClienteContactos"
class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ClienteContactos.nombre') ?></th>
<th><?= lang('ClienteContactos.apellidos') ?></th>
<th><?= lang('ClienteContactos.cargo') ?></th>
<th><?= lang('ClienteContactos.telefono') ?></th>
<th><?= lang('ClienteContactos.email') ?></th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<?php } ?>
<div class="tab-pane fade" id="domicilio-entrega" role="tabpanel">
<h3>Proximanente</h3>
@ -509,7 +530,6 @@
</div>
</div>
<div class="row">
@ -536,11 +556,12 @@
<label for="descuento" class="form-label">
<?= lang('Clientes.descuento') ?>*
</label>
<input type="number" id="descuento" name="descuento" required placeholder="0.00" maxLength="8" step="0.01"
<input type="number" id="descuento" name="descuento" required placeholder="0.00" maxLength="8"
step="0.01"
class="form-control" value="<?= old('descuento', $clienteEntity->descuento) ?>">
</div><!--//.mb-3 -->
<?php /* A implementar en el controller
<?php /* A implementar en el controller
<div class="mb-3">
<label for="limiteCreditoUserId" class="form-label">
<?= lang('Clientes.limiteCreditoUserId') ?>*
@ -591,7 +612,8 @@
<label for="margenPlantillaId" class="form-label">
<?= lang('Clientes.margenPlantillaId') ?>
</label>
<input type="number" id="margenPlantillaId" name="margen_plantilla_id" maxLength="10" class="form-control"
<input type="number" id="margenPlantillaId" name="margen_plantilla_id" maxLength="10"
class="form-control"
value="<?= old('margen_plantilla_id', $clienteEntity->margen_plantilla_id) ?>">
</div><!--//.mb-3 -->
@ -627,5 +649,101 @@
</div><!-- //.row -->
<?php if ($formAction !== site_url('cliente/add')){ ?>
<?= $this->section("additionalInlineJs") ?>
const lastColNr = $('#tableOfClienteContactos').find("tr:first th").length - 1;
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;
}
const actionBtns = function(data) {
return `
<span class="edit"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></span>
<span class="cancel"></span>
<span class="remove"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></span>
`;
};
var theTable = $('#tableOfClienteContactos').DataTable( {
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ], [ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: false,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfClienteContactos') ?>',
data: {
id_cliente: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'nombre' },
{ 'data': 'apellidos' },
{ 'data': 'cargo' },
{ 'data': 'telefono' },
{ 'data': 'email' },
{
data: actionBtns,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
},
{
"orderData": [ 0, 1 ],
"targets": 0
},
],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
/*buttons: [ {
className: 'btn btn-primary float-end me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<i class="ti ti-device-floppy"/>'
}
} ]*/
} );
<?=$this->endSection() ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
<?=$this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.0/jszip.min.js" integrity="sha512-xcHCGC5tQ0SHlRX8Anbz6oy/OullASJkEhb4gjkneVpGE3/QGYejf14CUO5n5q5paiHfRFTa9HKgByxzidw2Bw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/pdfmake.min.js" integrity="sha512-rDbVu5s98lzXZsmJoMa0DjHNE+RwPJACogUCLyq3Xxm2kJO6qsQwjbE5NDk2DqmlKcxDirCnU1wAzVLe12IM3w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/vfs_fonts.js" integrity="sha512-cktKDgjEiIkPVHYbn8bh/FEyYxmt4JDJJjOCu5/FQAkW4bc911XtKYValiyzBiJigjVEvrIAyQFEbRJZyDA1wQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?=$this->endSection() ?>
<?php } ?>

View File

@ -1,3 +1,4 @@
<?= $this->include("themes/_commonPartialsBs/datatables") ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
@ -26,7 +27,7 @@
<?= anchor(route_to("clienteList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>
@ -208,5 +209,5 @@
}
});
<?= $this->endSection() ?>

View File

@ -25,7 +25,7 @@
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!-- //.card -->
</div><!--//.col -->
<?php if($formAction == site_url('tarifas/tarifasencuadernacion/add')): ?>