mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/delete-ui' into 'main'
Terminada funcionalidad eliminar basada en Modal y SweetAlert. Aplicada a... See merge request jjimenez/safekat!41
This commit is contained in:
@ -328,6 +328,7 @@ $routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function
|
||||
$routes->post('create', 'Cliente::create', ['as' => 'ajaxCreateCliente']);
|
||||
$routes->put('(:num)/update', 'Cliente::update/$1', ['as' => 'ajaxUpdateCliente']);
|
||||
$routes->post('(:num)/edit', 'Cliente::edit/$1', ['as' => 'updateCliente']);
|
||||
$routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'deleteCliente']);
|
||||
$routes->post('datatable', 'Cliente::datatable', ['as' => 'dataTableOfClientes']);
|
||||
$routes->post('allmenuitems', 'Cliente::allItemsSelect', ['as' => 'select2ItemsOfClientes']);
|
||||
$routes->post('menuitems', 'Cliente::menuItems', ['as' => 'menuItemsOfClientes']);
|
||||
|
||||
@ -41,6 +41,12 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
|
||||
$this->viewData['pageTitle'] = lang('Clientes.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_clientes"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
@ -68,8 +74,7 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
|
||||
294
ci4/app/Controllers/Clientes/Clientecontactos.php
Normal file
294
ci4/app/Controllers/Clientes/Clientecontactos.php
Normal file
@ -0,0 +1,294 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Clientes\ClienteContactoEntity;
|
||||
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
|
||||
use App\Models\Clientes\ClienteContactoModel;
|
||||
|
||||
class Clientecontactos extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = ClienteContactoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Contacto de cliente';
|
||||
protected static $singularObjectNameCc = 'contactoDeCliente';
|
||||
protected static $pluralObjectName = 'Contactos de cliente';
|
||||
protected static $pluralObjectNameCc = 'contactosDeCliente';
|
||||
|
||||
protected static $controllerSlug = 'cliente-contactos';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/clientes/contactos/';
|
||||
|
||||
protected $indexRoute = 'contactoDeClienteList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('ClienteContactos.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteContactos.contactoDeCliente')]),
|
||||
'clienteContactoEntity' => new ClienteContactoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewContactoDeClienteList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]).'.';
|
||||
$message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['clienteContactoEntity'] = isset($sanitizedData) ? new ClienteContactoEntity($sanitizedData) : new ClienteContactoEntity();
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('createContactoDeCliente');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$clienteContactoEntity = $this->model->find($id);
|
||||
|
||||
if ($clienteContactoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ClienteContactos.contactoDeCliente')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$clienteContactoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $clienteContactoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]).'.';
|
||||
$message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['clienteContactoEntity'] = $clienteContactoEntity;
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateContactoDeCliente', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
|
||||
public function datatable() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$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();
|
||||
foreach ($resourceData as $item) :
|
||||
if (isset($item->apellidos) && strlen($item->apellidos) > 100) :
|
||||
$item->apellidos = character_limiter($item->apellidos, 100);
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getClienteListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])];
|
||||
if (!empty($selId)) :
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
|
||||
$selOption = $clienteModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
332
ci4/app/Controllers/Clientes/Clientedistribuidores.php
Normal file
332
ci4/app/Controllers/Clientes/Clientedistribuidores.php
Normal file
@ -0,0 +1,332 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Clientes\ClienteDistribuidorEntity;
|
||||
|
||||
use App\Models\Configuracion\PaisModel;
|
||||
|
||||
use App\Models\Clientes\ClienteDistribuidorModel;
|
||||
|
||||
use App\Models\Configuracion\ProvinciaModel;
|
||||
|
||||
use App\Models\Configuracion\ComunidadAutonomaModel;
|
||||
|
||||
class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = ClienteDistribuidorModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Distribuidor de cliente';
|
||||
protected static $singularObjectNameCc = 'distribuidorDeCliente';
|
||||
protected static $pluralObjectName = 'Distribuidores de cliente';
|
||||
protected static $pluralObjectNameCc = 'distribuidoresDeCliente';
|
||||
|
||||
protected static $controllerSlug = 'cliente-distribuidores';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/clientes/distribuidores/';
|
||||
|
||||
protected $indexRoute = 'distribuidorDeClienteList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('ClienteDistribuidores.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteDistribuidores.distribuidorDeCliente')]),
|
||||
'clienteDistribuidorEntity' => new ClienteDistribuidorEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewDistribuidorDeClienteList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]).'.';
|
||||
$message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['clienteDistribuidorEntity'] = isset($sanitizedData) ? new ClienteDistribuidorEntity($sanitizedData) : new ClienteDistribuidorEntity();
|
||||
$this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null);
|
||||
$this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null);
|
||||
$this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('createDistribuidorDeCliente');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$clienteDistribuidorEntity = $this->model->find($id);
|
||||
|
||||
if ($clienteDistribuidorEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$clienteDistribuidorEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $clienteDistribuidorEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]).'.';
|
||||
$message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['clienteDistribuidorEntity'] = $clienteDistribuidorEntity;
|
||||
$this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null);
|
||||
$this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null);
|
||||
$this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateDistribuidorDeCliente', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
|
||||
public function datatable() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = ClienteDistribuidorModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
foreach ($resourceData as $item) :
|
||||
if (isset($item->direccion) && strlen($item->direccion) > 100) :
|
||||
$item->direccion = character_limiter($item->direccion, 100);
|
||||
endif;if (isset($item->horarios_entrega) && strlen($item->horarios_entrega) > 100) :
|
||||
$item->horarios_entrega = character_limiter($item->horarios_entrega, 100);
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getComunidadAutonomaListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])];
|
||||
if (!empty($selId)) :
|
||||
$comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel');
|
||||
|
||||
$selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
|
||||
if (!empty($selId)) :
|
||||
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||
|
||||
$selOption = $paisModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getProvinciaListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])];
|
||||
if (!empty($selId)) :
|
||||
$provinciaModel = model('App\Models\Configuracion\ProvinciaModel');
|
||||
|
||||
$selOption = $provinciaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -234,7 +234,8 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon
|
||||
|
||||
}
|
||||
|
||||
$message = lang('Basic.global.deleteSuccess', [$objName]);
|
||||
// $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;
|
||||
}
|
||||
|
||||
24
ci4/app/Entities/Clientes/ClienteContactoEntity.php
Normal file
24
ci4/app/Entities/Clientes/ClienteContactoEntity.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace App\Entities\Clientes;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class ClienteContactoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"cliente_id" => null,
|
||||
"cargo" => null,
|
||||
"nombre" => null,
|
||||
"apellidos" => null,
|
||||
"telefono" => null,
|
||||
"email" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"cliente_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
34
ci4/app/Entities/Clientes/ClienteDistribuidorEntity.php
Normal file
34
ci4/app/Entities/Clientes/ClienteDistribuidorEntity.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace App\Entities\Clientes;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class ClienteDistribuidorEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"cif" => null,
|
||||
"direccion" => null,
|
||||
"ciudad" => null,
|
||||
"cp" => null,
|
||||
"email" => null,
|
||||
"pais_id" => null,
|
||||
"provincia_id" => null,
|
||||
"comunidad_autonoma_id" => null,
|
||||
"telefono" => null,
|
||||
"horarios_entrega" => null,
|
||||
"persona_contacto" => null,
|
||||
"precio" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"pais_id" => "int",
|
||||
"provincia_id" => "int",
|
||||
"comunidad_autonoma_id" => "?int",
|
||||
"precio" => "?float",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
54
ci4/app/Language/en/ClienteContactos.php
Normal file
54
ci4/app/Language/en/ClienteContactos.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'apellidos' => 'Apellidos',
|
||||
'cargo' => 'Cargo',
|
||||
'cliente' => 'Cliente ID',
|
||||
'cliente-contactos' => 'Contactos de cliente',
|
||||
'clienteId' => 'Cliente ID',
|
||||
'contactoDeCliente' => 'Contacto de cliente',
|
||||
'contactoDeClienteList' => 'Contacto de cliente List',
|
||||
'contactosDeCliente' => 'Contactos de cliente',
|
||||
'createdAt' => 'Created At',
|
||||
'deletedAt' => 'Deleted At',
|
||||
'email' => 'Email',
|
||||
'id' => 'ID',
|
||||
'isDeleted' => 'Is Deleted',
|
||||
'moduleTitle' => 'Cliente Contactos',
|
||||
'nombre' => 'Nombre',
|
||||
'telefono' => 'Telefono',
|
||||
'updatedAt' => 'Updated At',
|
||||
'validation' => [
|
||||
'apellidos' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'cargo' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'nombre' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'telefono' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'email' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'valid_email' => 'The {field} field must contain a valid email address.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
86
ci4/app/Language/en/ClienteDistribuidores.php
Normal file
86
ci4/app/Language/en/ClienteDistribuidores.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'cif' => 'Cif',
|
||||
'ciudad' => 'Ciudad',
|
||||
'cliente-distribuidores' => 'Distribuidores de cliente',
|
||||
'comunidadAutonoma' => 'Comunidad Autonoma',
|
||||
'cp' => 'Cp',
|
||||
'createdAt' => 'Created At',
|
||||
'deletedAt' => 'Deleted At',
|
||||
'direccion' => 'Direccion',
|
||||
'distribuidorDeCliente' => 'Distribuidor de cliente',
|
||||
'distribuidorDeClienteList' => 'Distribuidor de cliente List',
|
||||
'distribuidoresDeCliente' => 'Distribuidores de cliente',
|
||||
'email' => 'Email',
|
||||
'horariosEntrega' => 'Horarios Entrega',
|
||||
'id' => 'ID',
|
||||
'isDeleted' => 'Is Deleted',
|
||||
'moduleTitle' => 'Distribuidores de cliente',
|
||||
'nombre' => 'Nombre',
|
||||
'pais' => 'Pais',
|
||||
'personaContacto' => 'Persona Contacto',
|
||||
'precio' => 'Precio',
|
||||
'provincia' => 'Provincia',
|
||||
'telefono' => 'Telefono',
|
||||
'updatedAt' => 'Updated At',
|
||||
'validation' => [
|
||||
'cif' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'ciudad' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'cp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'direccion' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'horarios_entrega' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'persona_contacto' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'precio' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
|
||||
],
|
||||
|
||||
'telefono' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'email' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'valid_email' => 'The {field} field must contain a valid email address.',
|
||||
|
||||
],
|
||||
|
||||
'nombre' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
54
ci4/app/Language/es/ClienteContactos.php
Normal file
54
ci4/app/Language/es/ClienteContactos.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'apellidos' => 'Apellidos',
|
||||
'cargo' => 'Cargo',
|
||||
'cliente' => 'Cliente ID',
|
||||
'cliente-contactos' => 'Contactos de cliente',
|
||||
'clienteId' => 'Cliente ID',
|
||||
'contactoDeCliente' => 'Contacto de cliente',
|
||||
'contactoDeClienteList' => 'Contacto de cliente List',
|
||||
'contactosDeCliente' => 'Contactos de cliente',
|
||||
'createdAt' => 'Created At',
|
||||
'deletedAt' => 'Deleted At',
|
||||
'email' => 'Email',
|
||||
'id' => 'ID',
|
||||
'isDeleted' => 'Is Deleted',
|
||||
'moduleTitle' => 'Cliente Contactos',
|
||||
'nombre' => 'Nombre',
|
||||
'telefono' => 'Telefono',
|
||||
'updatedAt' => 'Updated At',
|
||||
'validation' => [
|
||||
'apellidos' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'cargo' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'nombre' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'telefono' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'email' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'valid_email' => 'The {field} field must contain a valid email address.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
86
ci4/app/Language/es/ClienteDistribuidores.php
Normal file
86
ci4/app/Language/es/ClienteDistribuidores.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'cif' => 'Cif',
|
||||
'ciudad' => 'Ciudad',
|
||||
'cliente-distribuidores' => 'Distribuidores de cliente',
|
||||
'comunidadAutonoma' => 'Comunidad Autonoma',
|
||||
'cp' => 'Cp',
|
||||
'createdAt' => 'Created At',
|
||||
'deletedAt' => 'Deleted At',
|
||||
'direccion' => 'Direccion',
|
||||
'distribuidorDeCliente' => 'Distribuidor de cliente',
|
||||
'distribuidorDeClienteList' => 'Distribuidor de cliente List',
|
||||
'distribuidoresDeCliente' => 'Distribuidores de cliente',
|
||||
'email' => 'Email',
|
||||
'horariosEntrega' => 'Horarios Entrega',
|
||||
'id' => 'ID',
|
||||
'isDeleted' => 'Is Deleted',
|
||||
'moduleTitle' => 'Distribuidores de cliente',
|
||||
'nombre' => 'Nombre',
|
||||
'pais' => 'Pais',
|
||||
'personaContacto' => 'Persona Contacto',
|
||||
'precio' => 'Precio',
|
||||
'provincia' => 'Provincia',
|
||||
'telefono' => 'Telefono',
|
||||
'updatedAt' => 'Updated At',
|
||||
'validation' => [
|
||||
'cif' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'ciudad' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'cp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'direccion' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'horarios_entrega' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'persona_contacto' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'precio' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
|
||||
],
|
||||
|
||||
'telefono' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'email' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'valid_email' => 'The {field} field must contain a valid email address.',
|
||||
|
||||
],
|
||||
|
||||
'nombre' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
138
ci4/app/Models/Clientes/ClienteContactoModel.php
Normal file
138
ci4/app/Models/Clientes/ClienteContactoModel.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
namespace App\Models\Clientes;
|
||||
|
||||
class ClienteContactoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "cliente_contactos";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
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",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["cliente_id", "cargo", "nombre", "apellidos", "telefono", "email"];
|
||||
protected $returnType = "App\Entities\Clientes\ClienteContactoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"apellidos" => [
|
||||
"label" => "ClienteContactos.apellidos",
|
||||
"rules" => "trim|max_length[500]",
|
||||
],
|
||||
"cargo" => [
|
||||
"label" => "ClienteContactos.cargo",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"email" => [
|
||||
"label" => "ClienteContactos.email",
|
||||
"rules" => "trim|max_length[150]|valid_email|permit_empty",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "ClienteContactos.nombre",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"telefono" => [
|
||||
"label" => "ClienteContactos.telefono",
|
||||
"rules" => "trim|max_length[20]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"apellidos" => [
|
||||
"max_length" => "ClienteContactos.validation.apellidos.max_length",
|
||||
],
|
||||
"cargo" => [
|
||||
"max_length" => "ClienteContactos.validation.cargo.max_length",
|
||||
],
|
||||
"email" => [
|
||||
"max_length" => "ClienteContactos.validation.email.max_length",
|
||||
"valid_email" => "ClienteContactos.validation.email.valid_email",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "ClienteContactos.validation.nombre.max_length",
|
||||
],
|
||||
"telefono" => [
|
||||
"max_length" => "ClienteContactos.validation.telefono.max_length",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithClientes(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS cliente_id FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN clientes t2 ON t1.cliente_id = t2.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . $offset;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$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"
|
||||
);
|
||||
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.cargo", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.apellidos", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.cliente_id", $search)
|
||||
->orLike("t1.cargo", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.apellidos", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
214
ci4/app/Models/Clientes/ClienteDistribuidorModel.php
Normal file
214
ci4/app/Models/Clientes/ClienteDistribuidorModel.php
Normal file
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
namespace App\Models\Clientes;
|
||||
|
||||
class ClienteDistribuidorModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "cliente_distribuidores";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.cif",
|
||||
4 => "t1.direccion",
|
||||
5 => "t1.ciudad",
|
||||
6 => "t1.cp",
|
||||
7 => "t1.email",
|
||||
8 => "t1.pais_id",
|
||||
9 => "t1.provincia_id",
|
||||
10 => "t1.comunidad_autonoma_id",
|
||||
11 => "t1.telefono",
|
||||
12 => "t1.horarios_entrega",
|
||||
13 => "t1.persona_contacto",
|
||||
14 => "t1.precio",
|
||||
15 => "t2.nombre",
|
||||
16 => "t3.nombre",
|
||||
17 => "t4.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"cif",
|
||||
"direccion",
|
||||
"ciudad",
|
||||
"cp",
|
||||
"email",
|
||||
"pais_id",
|
||||
"provincia_id",
|
||||
"comunidad_autonoma_id",
|
||||
"telefono",
|
||||
"horarios_entrega",
|
||||
"persona_contacto",
|
||||
"precio",
|
||||
];
|
||||
protected $returnType = "App\Entities\Clientes\ClienteDistribuidorEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"cif" => [
|
||||
"label" => "ClienteDistribuidores.cif",
|
||||
"rules" => "trim|max_length[50]",
|
||||
],
|
||||
"ciudad" => [
|
||||
"label" => "ClienteDistribuidores.ciudad",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"cp" => [
|
||||
"label" => "ClienteDistribuidores.cp",
|
||||
"rules" => "trim|max_length[10]",
|
||||
],
|
||||
"direccion" => [
|
||||
"label" => "ClienteDistribuidores.direccion",
|
||||
"rules" => "trim|max_length[300]",
|
||||
],
|
||||
"email" => [
|
||||
"label" => "ClienteDistribuidores.email",
|
||||
"rules" => "trim|max_length[150]|valid_email|permit_empty",
|
||||
],
|
||||
"horarios_entrega" => [
|
||||
"label" => "ClienteDistribuidores.horariosEntrega",
|
||||
"rules" => "trim|max_length[300]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "ClienteDistribuidores.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"persona_contacto" => [
|
||||
"label" => "ClienteDistribuidores.personaContacto",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"precio" => [
|
||||
"label" => "ClienteDistribuidores.precio",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"telefono" => [
|
||||
"label" => "ClienteDistribuidores.telefono",
|
||||
"rules" => "trim|max_length[60]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"cif" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.cif.max_length",
|
||||
],
|
||||
"ciudad" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.ciudad.max_length",
|
||||
],
|
||||
"cp" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.cp.max_length",
|
||||
],
|
||||
"direccion" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.direccion.max_length",
|
||||
],
|
||||
"email" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.email.max_length",
|
||||
"valid_email" => "ClienteDistribuidores.validation.email.valid_email",
|
||||
],
|
||||
"horarios_entrega" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.horarios_entrega.max_length",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.nombre.max_length",
|
||||
"required" => "ClienteDistribuidores.validation.nombre.required",
|
||||
],
|
||||
"persona_contacto" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.persona_contacto.max_length",
|
||||
],
|
||||
"precio" => [
|
||||
"decimal" => "ClienteDistribuidores.validation.precio.decimal",
|
||||
],
|
||||
"telefono" => [
|
||||
"max_length" => "ClienteDistribuidores.validation.telefono.max_length",
|
||||
],
|
||||
];
|
||||
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS pais, t3.nombre AS provincia, t4.nombre AS comunidad_autonoma FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_paises t2 ON t1.pais_id = t2.id LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id LEFT JOIN lg_comunidades_autonomas t4 ON t1.comunidad_autonoma_id = t4.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . intval($limit);
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . intval($offset);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.cif AS cif, t1.direccion AS direccion, t1.ciudad AS ciudad, t1.cp AS cp, t1.email AS email, t1.telefono AS telefono, t1.horarios_entrega AS horarios_entrega, t1.persona_contacto AS persona_contacto, t1.precio AS precio, t2.nombre AS pais, t3.nombre AS provincia, t4.nombre AS comunidad_autonoma"
|
||||
);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
$builder->join("lg_provincias t3", "t1.provincia_id = t3.id", "left");
|
||||
$builder->join("lg_comunidades_autonomas t4", "t1.comunidad_autonoma_id = t4.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.cif", $search)
|
||||
->orLike("t1.direccion", $search)
|
||||
->orLike("t1.ciudad", $search)
|
||||
->orLike("t1.cp", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t1.horarios_entrega", $search)
|
||||
->orLike("t1.persona_contacto", $search)
|
||||
->orLike("t1.precio", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t3.id", $search)
|
||||
->orLike("t4.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.cif", $search)
|
||||
->orLike("t1.direccion", $search)
|
||||
->orLike("t1.ciudad", $search)
|
||||
->orLike("t1.cp", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.provincia_id", $search)
|
||||
->orLike("t1.comunidad_autonoma_id", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t1.horarios_entrega", $search)
|
||||
->orLike("t1.persona_contacto", $search)
|
||||
->orLike("t1.precio", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->orLike("t3.nombre", $search)
|
||||
->orLike("t4.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -1,33 +1,14 @@
|
||||
<?php
|
||||
|
||||
// Open-Source License Information:
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
$errorMessage = $errorMessage ?? session('errorMessage');
|
||||
$warningMessage = session('warningMessage');
|
||||
|
||||
Copyright (c) 2020 Ozar (https://www.ozar.net/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
$errorMessage = $errorMessage ?? session('errorMessage');
|
||||
$warningMessage = session('warningMessage');
|
||||
|
||||
if (session()->has('message')) {
|
||||
$successMessage = session('message');
|
||||
}
|
||||
if (session()->has('error')) {
|
||||
$errorMessage = is_array(session('error')) ? implode(session('error')) : session('error');
|
||||
} /* // Uncomment this block if you want the errors listed line by line in the alert
|
||||
if (session()->has('message')) {
|
||||
$successMessage = session('message');
|
||||
}
|
||||
if (session()->has('error')) {
|
||||
$errorMessage = is_array(session('error')) ? implode(session('error')) : session('error');
|
||||
} /* // Uncomment this block if you want the errors listed line by line in the alert
|
||||
elseif (session()->has('errors')) {
|
||||
$errorMessage = '<ul class="text-start">';
|
||||
foreach (session('errors') as $error) :
|
||||
@ -39,43 +20,95 @@
|
||||
?>
|
||||
|
||||
<?php if (isset($successMessage) && $successMessage): ?>
|
||||
|
||||
<div class="alert alert-success" role="alert">
|
||||
<svg class="bi mt-1 me-3 float-start" width="24" height="24" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
|
||||
<button type="button" class="btn-close float-end" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
<div>
|
||||
<h4><?=lang('Basic.global.Success')?>!</h4>
|
||||
<?= $successMessage; ?>
|
||||
<div class="alert alert-success alert-dismissible d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-check ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Success') ?></h5>
|
||||
<p class="mb-0"><?= $successMessage; ?></p>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($errorMessage) && $errorMessage): ?>
|
||||
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<svg class="bi mt-1 me-3 float-start" width="24" height="24" role="img" aria-label="Error:"><use xlink:href="#exclamation-triangle-fill"/></svg>
|
||||
<button type="button" class="btn-close float-end" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
<div>
|
||||
<h4><?=lang('Basic.global.Error')?>!</h4>
|
||||
<?= $errorMessage; ?>
|
||||
<div class="alert alert-danger alert-dismissible d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-ban ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Error') ?></h5>
|
||||
<p class="mb-0"><?= $errorMessage; ?></p>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<?php if (isset($warningMessage) && $warningMessage): ?>
|
||||
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<svg class="bi mt-1 me-3 float-start" width="24" height="24" role="img" aria-label="Error:"><use xlink:href="#exclamation-triangle-fill"/></svg>
|
||||
<button type="button" class="btn-close float-end" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
<div>
|
||||
<h4 class="text-start"><?=lang('Basic.global.Warning')?></h4>
|
||||
<?= $warningMessage ?>
|
||||
<div class="alert alert-warning alert-dismissible d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-bell ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Warning') ?></h5>
|
||||
<p class="mb-0"><?= $warningMessage; ?></p>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="sk-alert">
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
|
||||
function popSuccessAlert(successMsg){
|
||||
var htmlString = `
|
||||
<div class="alert alert-success d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-check ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Success') ?></h5>
|
||||
<p class="mb-0">` + successMsg + `</p>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
$(window).scrollTop(0);
|
||||
$('#sk-alert').hide().empty().html(htmlString).fadeIn("slow", function(){
|
||||
setTimeout(function(){
|
||||
$('#sk-alert').fadeOut("slow");
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
function popErrorAlert(errorMsg){
|
||||
var htmlString = `
|
||||
<div class="alert alert-error d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-error ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Error') ?></h5>
|
||||
<p class="mb-0">` + errorMsg + `</p>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
$(window).scrollTop(0);
|
||||
$('#sk-alert').hide().empty().html(htmlString).fadeIn("slow", function(){
|
||||
setTimeout(function(){
|
||||
$('#sk-alert').fadeOut("slow");
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?php endif; ?>
|
||||
@ -11,30 +11,9 @@
|
||||
<?= lang('Basic.global.deleteConfirmationQuestion') ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-bs-dismiss="modal"><?= lang('Basic.global.deleteConfirmationCancel') ?></button>
|
||||
<a class="btn btn-danger btn-confirm"><?= lang('Basic.global.deleteConfirmationButton') ?></a>
|
||||
</div><!--//.modal-footer -->
|
||||
</div><!--//.modal-content -->
|
||||
</div><!--//.modal-dialog -->
|
||||
</div><!--//.modal -->
|
||||
<?php
|
||||
} else { ?>
|
||||
<div id="confirm2delete" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="confirm2deleteLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="confirm2deleteLabel"><?= lang('Basic.global.deleteConfirmation') ?></h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<?= lang('Basic.global.deleteConfirmationQuestion') ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?= lang('Basic.global.deleteConfirmationCancel') ?></button>
|
||||
<a class="btn btn-danger btn-confirm">><?= lang('Basic.global.deleteConfirmationButton') ?></a>
|
||||
<button type="button" class="btn btn-default"
|
||||
data-bs-dismiss="modal"><?= lang('Basic.global.deleteConfirmationCancel') ?></button>
|
||||
<a href="javascript:void(0);" class="btn btn-danger btn-confirm btn-remove"><?= lang('Basic.global.deleteConfirmationButton') ?></a>
|
||||
</div><!--//.modal-footer -->
|
||||
</div><!--//.modal-content -->
|
||||
</div><!--//.modal-dialog -->
|
||||
|
||||
@ -18,6 +18,5 @@
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
@ -17,167 +17,165 @@
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
|
||||
moment.locale('<?= $currentLocale ?? config('App')->defaultLocale ?>');
|
||||
moment.locale('<?= $currentLocale ?? config('App')->defaultLocale ?>');
|
||||
|
||||
<?php if (isset($usingServerSideDataTable) && $usingServerSideDataTable) : ?>
|
||||
// Pipelining function for DataTables. To be used to the `ajax` option of DataTables
|
||||
$.fn.dataTable.pipeline = function (opts) {
|
||||
// Configuration options
|
||||
let conf = $.extend({
|
||||
pages: 5, // number of pages to cache
|
||||
url: '',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'}
|
||||
}, opts);
|
||||
// Pipelining function for DataTables. To be used to the `ajax` option of DataTables
|
||||
$.fn.dataTable.pipeline = function (opts) {
|
||||
// Configuration options
|
||||
let conf = $.extend({
|
||||
pages: 5, // number of pages to cache
|
||||
url: '',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'}
|
||||
}, opts);
|
||||
|
||||
// Private variables for storing the cache
|
||||
let cacheLower = -1;
|
||||
let cacheUpper = null;
|
||||
let cacheLastRequest = null;
|
||||
let cacheLastJson = null;
|
||||
// Private variables for storing the cache
|
||||
let cacheLower = -1;
|
||||
let cacheUpper = null;
|
||||
let cacheLastRequest = null;
|
||||
let cacheLastJson = null;
|
||||
|
||||
return function (request, drawCallback, settings) {
|
||||
let ajax = false;
|
||||
let requestStart = request.start;
|
||||
let drawStart = request.start;
|
||||
let requestLength = request.length;
|
||||
let requestEnd = requestStart + requestLength;
|
||||
return function (request, drawCallback, settings) {
|
||||
let ajax = false;
|
||||
let requestStart = request.start;
|
||||
let drawStart = request.start;
|
||||
let requestLength = request.length;
|
||||
let requestEnd = requestStart + requestLength;
|
||||
|
||||
if (settings.clearCache) {
|
||||
// API requested that the cache be cleared
|
||||
ajax = true;
|
||||
settings.clearCache = false;
|
||||
} else if (cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper) {
|
||||
// outside cached data - need to make a request
|
||||
ajax = true;
|
||||
} else if (JSON.stringify(request.order) !== JSON.stringify(cacheLastRequest.order) ||
|
||||
JSON.stringify(request.columns) !== JSON.stringify(cacheLastRequest.columns) ||
|
||||
JSON.stringify(request.search) !== JSON.stringify(cacheLastRequest.search)
|
||||
) {
|
||||
// properties changed (ordering, columns, searching)
|
||||
ajax = true;
|
||||
}
|
||||
|
||||
// Store the request for checking next time around
|
||||
cacheLastRequest = $.extend(true, {}, request);
|
||||
|
||||
if (ajax) {
|
||||
// Need data from the server
|
||||
if (requestStart < cacheLower) {
|
||||
requestStart = requestStart - (requestLength * (conf.pages - 1));
|
||||
|
||||
if (requestStart < 0) {
|
||||
requestStart = 0;
|
||||
}
|
||||
}
|
||||
|
||||
cacheLower = requestStart;
|
||||
cacheUpper = requestStart + (requestLength * conf.pages);
|
||||
|
||||
request.start = requestStart;
|
||||
request.length = requestLength * conf.pages;
|
||||
|
||||
// Provide the same `data` options as DataTables.
|
||||
if (typeof conf.data === 'function') {
|
||||
// As a function it is executed with the data object as an arg
|
||||
// for manipulation. If an object is returned, it is used as the
|
||||
// data object to submit
|
||||
let d = conf.data(request);
|
||||
if (d) {
|
||||
$.extend(request, d);
|
||||
}
|
||||
} else if ($.isPlainObject(conf.data)) {
|
||||
// As an object, the data given extends the default
|
||||
$.extend(request, conf.data);
|
||||
}
|
||||
|
||||
request.<?=csrf_token()?> = <?=csrf_token()?>v;
|
||||
|
||||
return $.ajax({
|
||||
"type": conf.method,
|
||||
"url": conf.url,
|
||||
"data": request,
|
||||
"dataType": "json",
|
||||
"cache": false,
|
||||
"success": function (json) {
|
||||
cacheLastJson = $.extend(true, {}, json);
|
||||
|
||||
if (cacheLower != drawStart) {
|
||||
json.data.splice(0, drawStart - cacheLower);
|
||||
}
|
||||
if (requestLength >= -1) {
|
||||
json.data.splice(requestLength, json.data.length);
|
||||
}
|
||||
|
||||
drawCallback(json);
|
||||
|
||||
yeniden(json.token);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
|
||||
$('.dataTables_processing').hide();
|
||||
const theData = jqXHR.responseJSON;
|
||||
drawCallback(theData);
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: errorThrown,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let json = $.extend(true, {}, cacheLastJson);
|
||||
json.draw = request.draw; // Update the echo for each response
|
||||
json.data.splice(0, requestStart - cacheLower);
|
||||
json.data.splice(requestLength, json.data.length);
|
||||
|
||||
drawCallback(json);
|
||||
}
|
||||
if (settings.clearCache) {
|
||||
// API requested that the cache be cleared
|
||||
ajax = true;
|
||||
settings.clearCache = false;
|
||||
} else if (cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper) {
|
||||
// outside cached data - need to make a request
|
||||
ajax = true;
|
||||
} else if (JSON.stringify(request.order) !== JSON.stringify(cacheLastRequest.order) ||
|
||||
JSON.stringify(request.columns) !== JSON.stringify(cacheLastRequest.columns) ||
|
||||
JSON.stringify(request.search) !== JSON.stringify(cacheLastRequest.search)
|
||||
) {
|
||||
// properties changed (ordering, columns, searching)
|
||||
ajax = true;
|
||||
}
|
||||
};
|
||||
|
||||
// Register an API method that will empty the pipelined data, forcing an Ajax
|
||||
// fetch on the next draw (i.e. `table.clearPipeline().draw()`)
|
||||
$.fn.dataTable.Api.register('clearPipeline()', function () {
|
||||
return this.iterator('table', function (settings) {
|
||||
settings.clearCache = true;
|
||||
});
|
||||
// Store the request for checking next time around
|
||||
cacheLastRequest = $.extend(true, {}, request);
|
||||
|
||||
if (ajax) {
|
||||
// Need data from the server
|
||||
if (requestStart < cacheLower) {
|
||||
requestStart = requestStart - (requestLength * (conf.pages - 1));
|
||||
|
||||
if (requestStart < 0) {
|
||||
requestStart = 0;
|
||||
}
|
||||
}
|
||||
|
||||
cacheLower = requestStart;
|
||||
cacheUpper = requestStart + (requestLength * conf.pages);
|
||||
|
||||
request.start = requestStart;
|
||||
request.length = requestLength * conf.pages;
|
||||
|
||||
// Provide the same `data` options as DataTables.
|
||||
if (typeof conf.data === 'function') {
|
||||
// As a function it is executed with the data object as an arg
|
||||
// for manipulation. If an object is returned, it is used as the
|
||||
// data object to submit
|
||||
let d = conf.data(request);
|
||||
if (d) {
|
||||
$.extend(request, d);
|
||||
}
|
||||
} else if ($.isPlainObject(conf.data)) {
|
||||
// As an object, the data given extends the default
|
||||
$.extend(request, conf.data);
|
||||
}
|
||||
|
||||
request.<?=csrf_token()?> = <?=csrf_token()?>v;
|
||||
|
||||
return $.ajax({
|
||||
"type": conf.method,
|
||||
"url": conf.url,
|
||||
"data": request,
|
||||
"dataType": "json",
|
||||
"cache": false,
|
||||
"success": function (json) {
|
||||
cacheLastJson = $.extend(true, {}, json);
|
||||
|
||||
if (cacheLower != drawStart) {
|
||||
json.data.splice(0, drawStart - cacheLower);
|
||||
}
|
||||
if (requestLength >= -1) {
|
||||
json.data.splice(requestLength, json.data.length);
|
||||
}
|
||||
|
||||
drawCallback(json);
|
||||
|
||||
yeniden(json.token);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
|
||||
$('.dataTables_processing').hide();
|
||||
const theData = jqXHR.responseJSON;
|
||||
drawCallback(theData);
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: errorThrown,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let json = $.extend(true, {}, cacheLastJson);
|
||||
json.draw = request.draw; // Update the echo for each response
|
||||
json.data.splice(0, requestStart - cacheLower);
|
||||
json.data.splice(requestLength, json.data.length);
|
||||
|
||||
drawCallback(json);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Register an API method that will empty the pipelined data, forcing an Ajax
|
||||
// fetch on the next draw (i.e. `table.clearPipeline().draw()`)
|
||||
$.fn.dataTable.Api.register('clearPipeline()', function () {
|
||||
return this.iterator('table', function (settings) {
|
||||
settings.clearCache = true;
|
||||
});
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($usingClientSideDataTable) && $usingClientSideDataTable) { ?>
|
||||
let lastColNr = $(".using-data-table").find("tr:first th").length - 1;
|
||||
theTable = $('.using-data-table').DataTable({
|
||||
"responsive": true,
|
||||
"paging": true,
|
||||
"lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
|
||||
"pageLength": 10,
|
||||
"lengthChange": true,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": true,
|
||||
"scrollX": true,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [0,lastColNr]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
let lastColNr = $(".using-data-table").find("tr:first th").length - 1;
|
||||
theTable = $('.using-data-table').DataTable({
|
||||
"responsive": true,
|
||||
"paging": true,
|
||||
"lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
|
||||
"pageLength": 10,
|
||||
"lengthChange": true,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": true,
|
||||
"scrollX": true,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [0,lastColNr]
|
||||
}
|
||||
]
|
||||
});
|
||||
<?php } ?>
|
||||
|
||||
$('#confirm2delete').on('show.bs.modal', function (e) {
|
||||
$(this).find('.btn-confirm').attr('href', $(e.relatedTarget).data('href'));
|
||||
});
|
||||
|
||||
$('#confirm2delete').on('show.bs.modal', function (e) {
|
||||
$(this).find('.btn-confirm').attr('href', $(e.relatedTarget).data('href'));
|
||||
});
|
||||
|
||||
function toggleAllCheckboxes($cssClass, $io=null) {
|
||||
$('.'+$cssClass).prop('checked', $io);
|
||||
}
|
||||
function toggleAllCheckboxes($cssClass, $io=null) {
|
||||
$('.'+$cssClass).prop('checked', $io);
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,8 +1,9 @@
|
||||
<?=$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'); ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card card-info">
|
||||
@ -46,8 +47,8 @@
|
||||
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>
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
@ -101,47 +102,30 @@
|
||||
|
||||
|
||||
$(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') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: `<?= route_to('clienteList') ?>/${dataId}`,
|
||||
method: 'DELETE',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/clientes/cliente/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="clienteId" class="form-label">
|
||||
<?=lang('ClienteContactos.cliente') ?>*
|
||||
</label>
|
||||
<select id="clienteId" name="cliente_id" required class="form-control select2bs2" style="width: 100%;" >
|
||||
|
||||
<?php if ( isset($clienteList) && is_array($clienteList) && !empty($clienteList) ) :
|
||||
foreach ($clienteList as $k => $v) : ?>
|
||||
<option value="<?=$k ?>"<?=$k==$clienteContactoEntity->cliente_id ? ' selected':'' ?>>
|
||||
<?=$v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="cargo" class="form-label">
|
||||
<?=lang('ClienteContactos.cargo') ?>
|
||||
</label>
|
||||
<input type="text" id="cargo" name="cargo" maxLength="100" class="form-control" value="<?=old('cargo', $clienteContactoEntity->cargo) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?=lang('ClienteContactos.nombre') ?>
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" maxLength="100" class="form-control" value="<?=old('nombre', $clienteContactoEntity->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="apellidos" class="form-label">
|
||||
<?=lang('ClienteContactos.apellidos') ?>
|
||||
</label>
|
||||
<textarea rows="3" id="apellidos" name="apellidos" style="height: 10em;" class="form-control"><?=old('apellidos', $clienteContactoEntity->apellidos) ?></textarea>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="telefono" class="form-label">
|
||||
<?=lang('ClienteContactos.telefono') ?>
|
||||
</label>
|
||||
<input type="text" id="telefono" name="telefono" maxLength="20" class="form-control" value="<?=old('telefono', $clienteContactoEntity->telefono) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">
|
||||
<?=lang('ClienteContactos.email') ?>
|
||||
</label>
|
||||
<input type="email" id="email" name="email" maxLength="150" class="form-control" value="<?=old('email', $clienteContactoEntity->email) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -0,0 +1,65 @@
|
||||
<?= $this->include("Themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->include("Themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?= $this->extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/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="contactoDeClienteForm" 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/contactos/_contactoDeClienteFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("contactoDeClienteList"), 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() ?>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
|
||||
$('#clienteId').select2({
|
||||
theme: 'bootstrap-5',
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
url: '<?= route_to("menuItemsOfClientes") ?>',
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,171 @@
|
||||
<?=$this->include('Themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?=$this->include('Themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('Themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?=$this->extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/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('ClienteContactos.contactoDeClienteList') ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('Themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfContactosdecliente" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
<th><?=lang('ClienteContactos.id')?></th>
|
||||
<th><?= lang('Clientes.cliente') ?></th>
|
||||
<th><?= lang('ClienteContactos.cargo') ?></th>
|
||||
<th><?= lang('ClienteContactos.nombre') ?></th>
|
||||
<th><?= lang('ClienteContactos.apellidos') ?></th>
|
||||
<th><?= lang('ClienteContactos.telefono') ?></th>
|
||||
<th><?= lang('ClienteContactos.email') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
<?=anchor(route_to('newContactoDeCliente'), lang('Basic.global.addNew').' '.lang('ClienteContactos.contactoDeCliente'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfContactosdecliente').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 = $('#tableOfContactosdecliente').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": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
|
||||
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
|
||||
"buttons": [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
stateSave: true,
|
||||
order: [[1, 'asc']],
|
||||
language: {
|
||||
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
},
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfContactosDeCliente') ?>',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [0,lastColNr]
|
||||
}
|
||||
],
|
||||
columns : [
|
||||
{ 'data': actionBtns },
|
||||
{ 'data': 'id' },
|
||||
{ 'data': 'cliente_id' },
|
||||
{ 'data': 'cargo' },
|
||||
{ 'data': 'nombre' },
|
||||
{ 'data': 'apellidos' },
|
||||
{ 'data': 'telefono' },
|
||||
{ 'data': 'email' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `<?= route_to('contactoDeClienteList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('ClienteContactos.contacto de cliente'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: `<?= route_to('contactoDeClienteList') ?>/${dataId}`,
|
||||
method: 'DELETE',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.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.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.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>
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $clienteDistribuidorEntity->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="cif" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.cif') ?>
|
||||
</label>
|
||||
<input type="text" id="cif" name="cif" maxLength="50" class="form-control" value="<?=old('cif', $clienteDistribuidorEntity->cif) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="direccion" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.direccion') ?>
|
||||
</label>
|
||||
<textarea rows="3" id="direccion" name="direccion" style="height: 10em;" class="form-control"><?=old('direccion', $clienteDistribuidorEntity->direccion) ?></textarea>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ciudad" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.ciudad') ?>
|
||||
</label>
|
||||
<input type="text" id="ciudad" name="ciudad" maxLength="100" class="form-control" value="<?=old('ciudad', $clienteDistribuidorEntity->ciudad) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="cp" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.cp') ?>
|
||||
</label>
|
||||
<input type="text" id="cp" name="cp" maxLength="10" class="form-control" value="<?=old('cp', $clienteDistribuidorEntity->cp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.email') ?>
|
||||
</label>
|
||||
<input type="email" id="email" name="email" maxLength="150" class="form-control" value="<?=old('email', $clienteDistribuidorEntity->email) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="paisId" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.pais') ?>*
|
||||
</label>
|
||||
<select id="paisId" name="pais_id" required class="form-control select2bs2" style="width: 100%;" >
|
||||
|
||||
<?php if ( isset($paisList) && is_array($paisList) && !empty($paisList) ) :
|
||||
foreach ($paisList as $k => $v) : ?>
|
||||
<option value="<?=$k ?>"<?=$k==$clienteDistribuidorEntity->pais_id ? ' selected':'' ?>>
|
||||
<?=$v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="provinciaId" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.provincia') ?>*
|
||||
</label>
|
||||
<select id="provinciaId" name="provincia_id" required class="form-control select2bs2" style="width: 100%;" >
|
||||
|
||||
<?php if ( isset($provinciaList) && is_array($provinciaList) && !empty($provinciaList) ) :
|
||||
foreach ($provinciaList as $k => $v) : ?>
|
||||
<option value="<?=$k ?>"<?=$k==$clienteDistribuidorEntity->provincia_id ? ' selected':'' ?>>
|
||||
<?=$v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="comunidadAutonomaId" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.comunidadAutonoma') ?>
|
||||
</label>
|
||||
<select id="comunidadAutonomaId" name="comunidad_autonoma_id" class="form-control select2bs2" style="width: 100%;" >
|
||||
|
||||
<?php if ( isset($comunidadAutonomaList) && is_array($comunidadAutonomaList) && !empty($comunidadAutonomaList) ) :
|
||||
foreach ($comunidadAutonomaList as $k => $v) : ?>
|
||||
<option value="<?=$k ?>"<?=$k==$clienteDistribuidorEntity->comunidad_autonoma_id ? ' selected':'' ?>>
|
||||
<?=$v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="telefono" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.telefono') ?>
|
||||
</label>
|
||||
<input type="text" id="telefono" name="telefono" maxLength="60" class="form-control" value="<?=old('telefono', $clienteDistribuidorEntity->telefono) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="horariosEntrega" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.horariosEntrega') ?>
|
||||
</label>
|
||||
<textarea rows="3" id="horariosEntrega" name="horarios_entrega" style="height: 10em;" class="form-control"><?=old('horarios_entrega', $clienteDistribuidorEntity->horarios_entrega) ?></textarea>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="personaContacto" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.personaContacto') ?>
|
||||
</label>
|
||||
<input type="text" id="personaContacto" name="persona_contacto" maxLength="100" class="form-control" value="<?=old('persona_contacto', $clienteDistribuidorEntity->persona_contacto) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precio" class="form-label">
|
||||
<?=lang('ClienteDistribuidores.precio') ?>
|
||||
</label>
|
||||
<input type="number" id="precio" name="precio" maxLength="31" step="0.01" class="form-control" value="<?=old('precio', $clienteDistribuidorEntity->precio) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -0,0 +1,125 @@
|
||||
<?= $this->include("Themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->include("Themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?= $this->extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/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="distribuidorDeClienteForm" 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/distribuidores/_distribuidorDeClienteFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("distribuidorDeClienteList"), 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() ?>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
|
||||
$('#comunidadAutonomaId').select2({
|
||||
theme: 'bootstrap-5',
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
$('#provinciaId').select2({
|
||||
theme: 'bootstrap-5',
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
$('#paisId').select2({
|
||||
theme: 'bootstrap-5',
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,185 @@
|
||||
<?=$this->include('Themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?=$this->include('Themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('Themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?=$this->extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/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('ClienteDistribuidores.distribuidorDeClienteList') ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('Themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfDistribuidoresdecliente" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
<th><?=lang('ClienteDistribuidores.id')?></th>
|
||||
<th><?= lang('ClienteDistribuidores.nombre') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.cif') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.direccion') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.ciudad') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.cp') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.email') ?></th>
|
||||
<th><?= lang('Paises.pais') ?></th>
|
||||
<th><?= lang('Provincias.provincia') ?></th>
|
||||
<th><?= lang('ComunidadesAutonomas.comunidadAutonoma') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.telefono') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.horariosEntrega') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.personaContacto') ?></th>
|
||||
<th><?= lang('ClienteDistribuidores.precio') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
<?=anchor(route_to('newDistribuidorDeCliente'), lang('Basic.global.addNew').' '.lang('ClienteDistribuidores.distribuidorDeCliente'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfDistribuidoresdecliente').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 = $('#tableOfDistribuidoresdecliente').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": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
|
||||
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
|
||||
"buttons": [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
stateSave: true,
|
||||
order: [[1, 'asc']],
|
||||
language: {
|
||||
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
},
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfDistribuidoresDeCliente') ?>',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [0,lastColNr]
|
||||
}
|
||||
],
|
||||
columns : [
|
||||
{ 'data': actionBtns },
|
||||
{ 'data': 'id' },
|
||||
{ 'data': 'nombre' },
|
||||
{ 'data': 'cif' },
|
||||
{ 'data': 'direccion' },
|
||||
{ 'data': 'ciudad' },
|
||||
{ 'data': 'cp' },
|
||||
{ 'data': 'email' },
|
||||
{ 'data': 'pais' },
|
||||
{ 'data': 'provincia' },
|
||||
{ 'data': 'comunidad_autonoma' },
|
||||
{ 'data': 'telefono' },
|
||||
{ 'data': 'horarios_entrega' },
|
||||
{ 'data': 'persona_contacto' },
|
||||
{ 'data': 'precio' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `<?= route_to('distribuidorDeClienteList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('ClienteDistribuidores.distribuidor de cliente'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: `<?= route_to('distribuidorDeClienteList') ?>/${dataId}`,
|
||||
method: 'DELETE',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.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.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.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>
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?=$this->section('content'); ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
@ -43,25 +44,26 @@
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfMaquinas').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>`;
|
||||
};
|
||||
theTable = $('#tableOfMaquinas').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',
|
||||
const lastColNr = $('#tableOfMaquinas').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">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
theTable = $('#tableOfMaquinas').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',
|
||||
@ -99,62 +101,40 @@
|
||||
});
|
||||
|
||||
|
||||
theTable.on( 'draw.dt', function () {
|
||||
const boolCols = [];
|
||||
for (let coln of boolCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
cell.innerHTML = cell.innerHTML == '1' ? '<i class="text-success bi bi-check-lg"></i>' : '';
|
||||
});
|
||||
}
|
||||
|
||||
theTable.on( 'draw.dt', function () {
|
||||
const boolCols = [];
|
||||
for (let coln of boolCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
cell.innerHTML = cell.innerHTML == '1' ? '<i class="text-success bi bi-check-lg"></i>' : '';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
//window.location.href = `<?= route_to('maquinaList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `/configuracion/maquinas/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Maquinas.maquina'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
//url: `<?= route_to('maquinaList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/configuracion/maquinas/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/configuracion/maquinas/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?=$this->section('content'); ?>
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
@ -50,8 +50,8 @@
|
||||
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>
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
@ -120,51 +120,35 @@
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `/configuracion/maquinasdefecto/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('MaquinasPorDefecto.maquinadefecto'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
//url: `<?= route_to('maquinaPorDefectoList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/configuracion/maquinasdefecto/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/configuracion/maquinasdefecto/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
||||
<?=$this->endSection() ?>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
|
||||
@ -174,5 +158,5 @@
|
||||
<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() ?>
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?=$this->section('content'); ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $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('PapelGenerico.papelGenericoList') ?></h3>
|
||||
@ -29,7 +29,6 @@
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
@ -41,13 +40,15 @@
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
const lastColNr = $('#tableOfPapelesgenericos').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>`;
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
|
||||
theTable = $('#tableOfPapelesgenericos').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
@ -105,53 +106,37 @@
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
//window.location.href = `<?= route_to('papelGenericoList') ?>/edit/${$(this).attr('data-id')}`;
|
||||
window.location.href = `/configuracion/papelesgenericos/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('PapelGenerico.papel generico'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
//url: `<?= route_to('papelGenericoList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/configuracion/papelesgenericos/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/configuracion/papelesgenericos/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
||||
<?=$this->endSection() ?>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
@ -162,5 +147,5 @@
|
||||
<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() ?>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?=$this->section('content'); ?>
|
||||
@ -49,12 +49,13 @@
|
||||
|
||||
const lastColNr = $('#tableOfPapelesimpresion').find("tr:first th").length - 1;
|
||||
const actionBtns = function(data) {
|
||||
return `<td class="text-right py-0 align-middle">
|
||||
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>
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
</td>`;
|
||||
};
|
||||
theTable = $('#tableOfPapelesimpresion').DataTable({
|
||||
processing: true,
|
||||
@ -107,78 +108,56 @@
|
||||
});
|
||||
|
||||
|
||||
theTable.on( 'draw.dt', function () {
|
||||
theTable.on( 'draw.dt', function () {
|
||||
const boolCols = [3, 4, 5, 6, 7, 8];
|
||||
for (let coln of boolCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
||||
});
|
||||
}
|
||||
});
|
||||
for (let coln of boolCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
//window.location.href = `<?= route_to('papelImpresionList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `/configuracion/papelesimpresion/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('PapelImpresion.papel impresion'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
//url: `<?= route_to('papelImpresionList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/configuracion/papelesimpresion/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/configuracion/papelesimpresion/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
||||
<?=$this->endSection() ?>
|
||||
<?= $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.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.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>
|
||||
<?=$this->endSection() ?>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<?= $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">
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?php //$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
@ -40,23 +40,17 @@
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
|
||||
const lastColNr = $('#tableOfTarifasacabado').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">
|
||||
<!-- <a href="--><?php //= site_url('/tarifas/tarifaacabado/edit/') ?><!--${data.id}" class="text-body" data-id="${data.id}">-->
|
||||
<!-- <i class="ti ti-pencil ti-sm mx-2"></i>-->
|
||||
<!-- </a>-->
|
||||
<!-- <a class="text-body" data-href="${data.id}" data-bs-toggle="modal" data-bs-target="#exampleModal">-->
|
||||
<!-- <i class="ti ti-trash ti-sm mx-2"></i>-->
|
||||
<!-- </a>-->
|
||||
<i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i>
|
||||
<i class="ti ti-trash ti-sm btn-del mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#exampleModal"></i>
|
||||
<!-- <i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i>-->
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
|
||||
theTable = $('#tableOfTarifasacabado').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
@ -105,11 +99,11 @@
|
||||
window.location.href = `/tarifas/tarifaacabado/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-del', function(e) {
|
||||
$(".btn-imn").attr('data-id', $(this).attr('data-id'));
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-imn', function(e) {
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
@ -117,24 +111,16 @@
|
||||
url: `/tarifas/tarifaacabado/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?=$this->section('content'); ?>
|
||||
<div class="row">
|
||||
@ -43,8 +43,8 @@
|
||||
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>
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
@ -94,49 +94,31 @@
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
//window.location.href = `<?= route_to('tarifaManipuladoList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
window.location.href = `/tarifas/tarifasmanipulado/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Tarifamanipulado.tarifa manipulado'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
//url: `<?= route_to('tarifaManipuladoList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/tarifas/tarifasmanipulado/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/tarifas/tarifasmanipulado/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user