mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadido datatable de cliente_contactos
This commit is contained in:
@ -378,6 +378,24 @@ $routes->group('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Ta
|
||||
});
|
||||
$routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']);
|
||||
|
||||
$routes->group('clientecontactos', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->get('', 'Clientecontactos::index', ['as' => 'ClienteContactosList']);
|
||||
$routes->get('add', 'Clientecontactos::add', ['as' => 'newClienteContactos']);
|
||||
$routes->post('add', 'Clientecontactos::add', ['as' => 'createClienteContactos']);
|
||||
$routes->post('create', 'Clientecontactos::create', ['as' => 'ajaxCreateClienteContactos']);
|
||||
$routes->put('(:num)/update', 'Clientecontactos::update/$1', ['as' => 'ajaxUpdateClienteContactos']);
|
||||
$routes->post('(:num)/edit', 'Clientecontactos::edit/$1', ['as' => 'updateClienteContactos']);
|
||||
$routes->post('datatable', 'Clientecontactos::datatable', ['as' => 'dataTableOfClienteContactos']);
|
||||
$routes->post('datatable_editor', 'Clientecontactos::datatable_editor', ['as' => 'editorOfClienteContactos']);
|
||||
$routes->post('allmenuitems', 'Clientecontactos::allItemsSelect', ['as' => 'select2ItemsOfClienteContactos']);
|
||||
$routes->post('menuitems', 'Clientecontactos::menuItems', ['as' => 'menuItemsOfClienteContactos']);
|
||||
});
|
||||
$routes->resource('ClienteContactos', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'ClienteContactos', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
|
||||
@ -47,6 +47,7 @@ class Cliente extends \App\Controllers\GoBaseResourceController
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true]; // JJO
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
@ -136,7 +137,7 @@ class Cliente extends \App\Controllers\GoBaseResourceController
|
||||
$this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null);
|
||||
$this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('createCliente');
|
||||
$this->viewData['formAction'] = site_url('cliente/add'); // route_to('createCliente'); IMN
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
@ -209,17 +209,21 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController
|
||||
$order = ClienteContactoModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$id_C = $reqData['id_cliente'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_C)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
/*$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
foreach ($resourceData as $item) :
|
||||
if (isset($item->apellidos) && strlen($item->apellidos) > 100) :
|
||||
$item->apellidos = character_limiter($item->apellidos, 100);
|
||||
endif;
|
||||
endforeach;
|
||||
endforeach;*/
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
$this->model->getResource($search, $id_C)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Clientes;
|
||||
|
||||
class ClienteContactoModel extends \App\Models\GoBaseModel
|
||||
@ -13,14 +14,12 @@ class ClienteContactoModel extends \App\Models\GoBaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.cliente_id",
|
||||
3 => "t1.cargo",
|
||||
4 => "t1.nombre",
|
||||
5 => "t1.apellidos",
|
||||
6 => "t1.telefono",
|
||||
7 => "t1.email",
|
||||
8 => "t2.nombre",
|
||||
0 => "t1.cargo",
|
||||
1 => "t1.nombre",
|
||||
2 => "t1.apellidos",
|
||||
3 => "t1.telefono",
|
||||
4 => "t1.email",
|
||||
5 => "t2.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["cliente_id", "cargo", "nombre", "apellidos", "telefono", "email"];
|
||||
@ -105,13 +104,20 @@ class ClienteContactoModel extends \App\Models\GoBaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
public function getResource(string $search = "", $cliente_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.cargo AS cargo, t1.nombre AS nombre, t1.apellidos AS apellidos, t1.telefono AS telefono, t1.email AS email, t2.nombre AS cliente_id"
|
||||
);
|
||||
|
||||
// IMN
|
||||
if ($cliente_id != -1) {
|
||||
$builder->where('cliente_id', $cliente_id);
|
||||
}
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
|
||||
@ -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 } ?>
|
||||
|
||||
@ -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() ?>
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
|
||||
<?php if($formAction == site_url('tarifas/tarifasencuadernacion/add')): ?>
|
||||
|
||||
Reference in New Issue
Block a user