Añadida funcion clientes desde ozar

This commit is contained in:
imnavajas
2023-07-12 12:35:31 +02:00
parent 42a20b93b0
commit 90d63432d6
49 changed files with 3119 additions and 970 deletions

View File

@ -16,6 +16,14 @@
value="<?= old('alias', $clienteEntity->alias) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="cif" class="form-label">
<?= lang('Clientes.cif') ?>*
</label>
<input type="text" id="cif" name="cif" required maxLength="50" class="form-control"
value="<?= old('cif', $clienteEntity->cif) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="direccion" class="form-label">
<?= lang('Clientes.direccion') ?>
@ -36,17 +44,33 @@
<label for="comunidadAutonomaId" class="form-label">
<?= lang('Clientes.comunidadAutonomaId') ?>
</label>
<select id="comunidadAutonomaId" name="comunidad_autonoma_id">
<option value="" selected="selected"><?= lang('Basic.global.pleaseSelectOne') ?></option>
<select id="comunidadAutonomaId" name="comunidad_autonoma_id" class="select2 form-control"
style="width: 100%;">
<?php if (isset($comunidadAutonomaList) && is_array($comunidadAutonomaList) && !empty($comunidadAutonomaList)) :
foreach ($comunidadAutonomaList as $k => $v) : ?>
<option value="<?= $k ?>"<?= $k == $clienteEntity->comunidad_autonoma_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="provincia" class="form-label">
<?= lang('Clientes.provincia') ?>
<label for="provinciaId" class="form-label">
<?= lang('Clientes.provinciaId') ?>*
</label>
<input type="text" id="provincia" name="provincia" maxLength="100" class="form-control"
value="<?= old('provincia', $clienteEntity->provincia) ?>">
<select id="provinciaId" name="provincia_id" required class="form-control select2" style="width: 100%;">
<?php if (isset($provinciaList) && is_array($provinciaList) && !empty($provinciaList)) :
foreach ($provinciaList as $k => $v) : ?>
<option value="<?= $k ?>"<?= $k == $clienteEntity->provincia_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
@ -61,14 +85,15 @@
<label for="paisId" class="form-label">
<?= lang('Clientes.paisId') ?>
</label>
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;">
<option value=""><?= lang('Basic.global.pleaseSelectA', [lang('Clientes.paisId')]) ?></option>
<select id="paisId" name="pais_id" class="form-control select2" style="width: 100%;">
<?php foreach ($paisList as $item) : ?>
<option value="<?= $item->id ?>"<?= $item->id == $clienteEntity->pais_id ? ' selected' : '' ?>>
<?= $item->nombre ?>
</option>
<?php endforeach; ?>
<?php if (isset($paisList) && is_array($paisList) && !empty($paisList)) :
foreach ($paisList as $k => $v) : ?>
<option value="<?= $k ?>"<?= $k == $clienteEntity->pais_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
@ -89,33 +114,50 @@
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="salesmanId" class="form-label">
<?= lang('Clientes.salesmanId') ?>*
<label for="comercialId" class="form-label">
<?= lang('Clientes.comercialId') ?>*
</label>
<input type="number" id="salesmanId" name="salesman_id" required placeholder="1" maxLength="10"
class="form-control" value="<?= old('salesman_id', $clienteEntity->salesman_id) ?>">
<select id="comercialId" name="comercial_id" required class="form-control select2" style="width: 100%;">
<?php if (isset($userList) && is_array($userList) && !empty($userList)) :
foreach ($userList as $k => $v) : ?>
<option value="<?= $k ?>"<?= $k == $clienteEntity->comercial_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="soporteId" class="form-label">
<?= lang('Clientes.soporteId') ?>
<?= lang('Clientes.soporteId') ?>*
</label>
<input type="number" id="soporteId" name="soporte_id" maxLength="10" class="form-control"
value="<?= old('soporte_id', $clienteEntity->soporte_id) ?>">
<select id="soporteId" name="soporte_id" required class="form-control select2" style="width: 100%;">
<?php if (isset($userList2) && is_array($userList2) && !empty($userList2)) :
foreach ($userList2 as $k => $v) : ?>
<option value="<?= $k ?>"<?= $k == $clienteEntity->soporte_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="formaPagoId" class="form-label">
<?= lang('Clientes.formaPagoId') ?>
</label>
<select id="formaPagoId" name="forma_pago_id" class="form-control select2" style="width: 100%;">
<select id="formaPagoId" name="forma_pago_id" class="form-control select2bs" style="width: 100%;">
<option value=""><?= lang('Basic.global.pleaseSelectA', [lang('Clientes.formaPagoId')]) ?></option>
<?php foreach ($formaPagoList as $item) : ?>
<option value="<?= $item->id ?>"<?= $item->id == $clienteEntity->forma_pago_id ? ' selected' : '' ?>>
<?= $item->nombre ?>
</option>
<?php endforeach; ?>
<?php if (isset($formaDePagoList) && is_array($formaDePagoList) && !empty($formaDePagoList)) :
foreach ($formaDePagoList as $k => $v) : ?>
<option value="<?= $k ?>"<?= $k == $clienteEntity->forma_pago_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
@ -128,11 +170,11 @@
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="fechavencimiento" class="form-label">
<?= lang('Clientes.fechavencimiento') ?>
<label for="fechaVencimiento" class="form-label">
<?= lang('Clientes.fechaVencimiento') ?>
</label>
<input type="text" id="fechavencimiento" name="fechaVencimiento" maxLength="100" class="form-control"
value="<?= old('fechaVencimiento', $clienteEntity->fechaVencimiento) ?>">
<input type="text" id="fechaVencimiento" name="fecha_vencimiento" maxLength="100" class="form-control"
value="<?= old('fecha_vencimiento', $clienteEntity->fecha_vencimiento) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
@ -186,23 +228,23 @@
value="<?= old('limite_credito_change_at', $clienteEntity->limite_credito_change_at) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="creditoSolunion" class="form-label">
<?= lang('Clientes.creditoSolunion') ?>
</label>
<input type="text" id="creditoSolunion" name="credito_solunion" maxLength="100" class="form-control"
value="<?= old('credito_solunion', $clienteEntity->credito_solunion) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="creditosolunion" class="form-label">
<?= lang('Clientes.creditosolunion') ?>
</label>
<input type="text" id="creditosolunion" name="creditoSolunion" maxLength="100" class="form-control"
value="<?= old('creditoSolunion', $clienteEntity->creditoSolunion) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="creditoasegurado" class="form-check-label">
<input type="checkbox" id="creditoasegurado" name="creditoAsegurado" value="1"
class="form-check-input"<?= $clienteEntity->creditoAsegurado == true ? 'checked' : ''; ?>>
<?= lang('Clientes.creditoasegurado') ?>
<label for="creditoAsegurado" class="form-check-label">
<input type="checkbox" id="creditoAsegurado" name="credito_asegurado" value="1"
class="form-check-input"<?= $clienteEntity->credito_asegurado == true ? 'checked' : ''; ?>>
<?= lang('Clientes.creditoAsegurado') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
@ -216,11 +258,11 @@
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="cccCustomer" class="form-label">
<?= lang('Clientes.cccCustomer') ?>
<label for="cccCliente" class="form-label">
<?= lang('Clientes.cccCliente') ?>
</label>
<input type="text" id="cccCustomer" name="ccc_customer" maxLength="100" class="form-control"
value="<?= old('ccc_customer', $clienteEntity->ccc_customer) ?>">
<input type="text" id="cccCliente" name="ccc_cliente" maxLength="100" class="form-control"
value="<?= old('ccc_cliente', $clienteEntity->ccc_cliente) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
@ -352,6 +394,14 @@
class="form-control"><?= old('comentarios', $clienteEntity->comentarios) ?></textarea>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="isDeleted" class="form-label">
<?= lang('Clientes.isDeleted') ?>*
</label>
<input type="number" id="isDeleted" name="is_deleted" required placeholder="0" maxLength="4"
class="form-control" value="<?= old('is_deleted', $clienteEntity->is_deleted) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="userCreatedId" class="form-label">
<?= lang('Clientes.userCreatedId') ?>*

View File

@ -0,0 +1,212 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="clienteForm" method="post" class="card-body" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/backend/vuexy/form/clientes/cliente/_clienteFormItems") ?>
</div><!-- /.card-body -->
<div class="pt-4">
<input
type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
>
<?= anchor(route_to("clienteList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->section("additionalInlineJs") ?>
$('#soporteId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfUsers") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
id: 'id_user',
text: 'first_name',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
$('#formaPagoId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfFormasDePagos") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
id: 'id',
text: 'nombre',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
$('#paisId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfPaises") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
id: 'id',
text: 'nombre',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
$('#provinciaId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfProvincias") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
id: 'id',
text: 'nombre',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
$('#comunidadAutonomaId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfComunidadesAutonomas") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
id: 'id',
text: 'nombre',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
$('#comercialId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfUsers") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
id: 'id_user',
text: 'first_name',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
<?= $this->endSection() ?>

View File

@ -1,26 +1,26 @@
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?=$this->section('content'); ?>
<div class="row">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?=lang('Clientes.clienteList') ?></h3>
<?=anchor(route_to('newCliente'), lang('Basic.global.addNew').' '.lang('Clientes.cliente'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfClientes" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Clientes.nombre') ?></th>
<th><?= lang('Clientes.alias') ?></th>
<th><?= lang('Clientes.cif') ?></th>
<th><?= lang('Clientes.email') ?></th>
<th><?= lang('Clientes.salesmanId') ?></th>
<th><?= lang('FormasPago.formaPago') ?></th>
<th><?= lang('Users.comercial') ?></th>
<th><?= lang('FormasPagoes.formaDePago') ?></th>
<th><?= lang('Clientes.vencimiento') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
@ -31,7 +31,6 @@
</table>
</div><!--//.card-body -->
<div class="card-footer">
<?=anchor(route_to('newCliente'), lang('Basic.global.addNew').' '.lang('Clientes.cliente'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
@ -41,68 +40,72 @@
<?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfClientes').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i>
<i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i>
</div>
</td>`;
};
const lastColNr = $('#tableOfClientes').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<button class="btn btn-sm btn-warning btn-edit me-1" data-id="${data.id}"><?= lang('Basic.global.edit') ?></button>
<button class="btn btn-sm btn-danger btn-delete ms-1" data-id="${data.id}"><?= lang('Basic.global.Delete') ?></button>
</div>
</td>`;
};
theTable = $('#tableOfClientes').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
lengthChange: true,
"dom": 'lfBrtip',
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= site_url('cliente/datatable') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
}
],
columns : [
{ 'data': 'nombre' },
{ 'data': 'alias' },
{ 'data': 'email' },
{ 'data': 'salesman_id' },
{ 'data': 'forma_pago' },
{ 'data': 'vencimiento' },
{ 'data': actionBtns }
]
});
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `<?= route_to('clienteList') ?>/${$(this).attr('data-id')}/edit`;
theTable = $('#tableOfClientes').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
lengthChange: true,
"dom": 'lfBrtip',
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[0, 'asc']],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfClientes') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
}
],
columns : [
{ 'data': 'nombre' },
{ 'data': 'alias' },
{ 'data': 'cif' },
{ 'data': 'email' },
{ 'data': 'comercial' },
{ 'data': 'forma_pago_id' },
{ 'data': 'vencimiento' },
{ 'data': actionBtns }
]
});
$(document).on('click', '.btn-delete', function(e) {
$(document).on('click', '.btn-edit', function(e) {
//window.location.href = `<?= site_url('/cliente/edit') ?>/${$(this).attr('data-id')}/edit`;
window.location.href = `/clientes/cliente/edit/${$(this).attr('data-id')}`;
});
$(document).on('click', '.btn-delete', function(e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Clientes.cliente'))]) ?>',
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
@ -125,7 +128,7 @@ $(document).on('click', '.btn-delete', function(e) {
icon: 'success',
title: data.msg ?? jqXHR.statusText,
});
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
@ -137,11 +140,14 @@ $(document).on('click', '.btn-delete', function(e) {
}
});
});
<?=$this->endSection() ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
<?=$this->endSection() ?>
@ -153,5 +159,5 @@ $(document).on('click', '.btn-delete', function(e) {
<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>
<?= $this->endSection() ?>
<?=$this->endSection() ?>

View File

@ -1,27 +0,0 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="clienteForm" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/backend/vuexy/form/clientes/_clienteFormItems") ?>
</div><!-- /.card-body -->
<div class="card-footer">
<?= anchor(route_to("clienteList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>