mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadido los archivos necesarios para proveedores
This commit is contained in:
320
ci4/app/Controllers/Compras/Proveedores.php
Normal file
320
ci4/app/Controllers/Compras/Proveedores.php
Normal file
@ -0,0 +1,320 @@
|
||||
<?php namespace App\Controllers\compras;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\compras\ProveedorEntity;
|
||||
|
||||
use App\Models\compras\ProveedorTipoModel;
|
||||
|
||||
use App\Models\compras\ProvinciaModel;
|
||||
|
||||
use App\Models\Configuracion\PaisModel;
|
||||
|
||||
use App\Models\compras\ProveedorModel;
|
||||
|
||||
class Proveedores extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = ProveedorModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Proveedor';
|
||||
protected static $singularObjectNameCc = 'proveedor';
|
||||
protected static $pluralObjectName = 'Proveedores';
|
||||
protected static $pluralObjectNameCc = 'proveedores';
|
||||
|
||||
protected static $controllerSlug = 'proveedores';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/compras/proveedores/';
|
||||
|
||||
protected $indexRoute = 'proveedorList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('LgProveedores.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('LgProveedores.proveedor')]),
|
||||
'proveedorEntity' => new ProveedorEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewProveedorList', $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('LgProveedores.proveedor'))]);
|
||||
$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('LgProveedores.proveedor'))]).'.';
|
||||
$message .= anchor( "admin/proveedores/{$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['proveedorEntity'] = isset($sanitizedData) ? new ProveedorEntity($sanitizedData) : new ProveedorEntity();
|
||||
$this->viewData['proveedorTipoList'] = $this->getProveedorTipoListItems($proveedorEntity->tipo_id ?? null);
|
||||
$this->viewData['provinciaList'] = $this->getProvinciaListItems($proveedorEntity->provincia_id ?? null);
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createProveedor');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('LgProveedores.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);
|
||||
$proveedorEntity = $this->model->find($id);
|
||||
|
||||
if ($proveedorEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('LgProveedores.proveedor')), $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('LgProveedores.proveedor'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$proveedorEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $proveedorEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('LgProveedores.proveedor'))]).'.';
|
||||
$message .= anchor( "admin/proveedores/{$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['proveedorEntity'] = $proveedorEntity;
|
||||
$this->viewData['proveedorTipoList'] = $this->getProveedorTipoListItems($proveedorEntity->tipo_id ?? null);
|
||||
$this->viewData['provinciaList'] = $this->getProvinciaListItems($proveedorEntity->provincia_id ?? null);
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateProveedor', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('LgProveedores.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 = ProveedorModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
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 getProveedorTipoListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('LgProveedoresTipos.proveedorTipo'))])];
|
||||
if (!empty($selId)) :
|
||||
$proveedorTipoModel = model('App\Models\compras\ProveedorTipoModel');
|
||||
|
||||
$selOption = $proveedorTipoModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems() {
|
||||
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||
$onlyActiveOnes = true;
|
||||
$data = $paisModel->getAllForMenu('id, nombre','nombre', $onlyActiveOnes );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getProvinciaListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])];
|
||||
if (!empty($selId)) :
|
||||
$provinciaModel = model('App\Models\compras\ProvinciaModel');
|
||||
|
||||
$selOption = $provinciaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
271
ci4/app/Controllers/Compras/ProveedoresTipos.php
Normal file
271
ci4/app/Controllers/Compras/ProveedoresTipos.php
Normal file
@ -0,0 +1,271 @@
|
||||
<?php namespace App\Controllers\compras;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\compras\ProveedorTipoEntity;
|
||||
|
||||
use App\Models\compras\ProveedorTipoModel;
|
||||
|
||||
class ProveedoresTipos extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = ProveedorTipoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Proveedor Tipo';
|
||||
protected static $singularObjectNameCc = 'proveedorTipo';
|
||||
protected static $pluralObjectName = 'Proveedores Tipos';
|
||||
protected static $pluralObjectNameCc = 'proveedoresTipos';
|
||||
|
||||
protected static $controllerSlug = 'proveedorestipos';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/compras/proveedores/';
|
||||
|
||||
protected $indexRoute = 'proveedorTipoList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('LgProveedoresTipos.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('LgProveedoresTipos.proveedorTipo')]),
|
||||
'proveedorTipoEntity' => new ProveedorTipoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewProveedorTipoList', $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('LgProveedoresTipos.proveedorTipo'))]);
|
||||
$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('LgProveedoresTipos.proveedorTipo'))]).'.';
|
||||
$message .= anchor( "admin/proveedorestipos/{$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['proveedorTipoEntity'] = isset($sanitizedData) ? new ProveedorTipoEntity($sanitizedData) : new ProveedorTipoEntity();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createProveedorTipo');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('LgProveedoresTipos.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);
|
||||
$proveedorTipoEntity = $this->model->find($id);
|
||||
|
||||
if ($proveedorTipoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('LgProveedoresTipos.proveedorTipo')), $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('LgProveedoresTipos.proveedorTipo'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$proveedorTipoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $proveedorTipoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('LgProveedoresTipos.proveedorTipo'))]).'.';
|
||||
$message .= anchor( "admin/proveedorestipos/{$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['proveedorTipoEntity'] = $proveedorTipoEntity;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateProveedorTipo', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('LgProveedoresTipos.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 = ProveedorTipoModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
32
ci4/app/Entities/Compras/ProveedorEntity.php
Normal file
32
ci4/app/Entities/Compras/ProveedorEntity.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace App\Entities\compras;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class ProveedorEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"tipo_id" => null,
|
||||
"razon_social" => null,
|
||||
"cif" => null,
|
||||
"direccion" => null,
|
||||
"cp" => null,
|
||||
"ciudad" => null,
|
||||
"provincia_id" => null,
|
||||
"pais_id" => 1,
|
||||
"persona_contacto" => null,
|
||||
"email" => null,
|
||||
"telefono" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"tipo_id" => "?int",
|
||||
"provincia_id" => "int",
|
||||
"pais_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
18
ci4/app/Entities/Compras/ProveedorTipoEntity.php
Normal file
18
ci4/app/Entities/Compras/ProveedorTipoEntity.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace App\Entities\compras;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class ProveedorTipoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
203
ci4/app/Models/Compras/ProveedorModel.php
Normal file
203
ci4/app/Models/Compras/ProveedorModel.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
namespace App\Models\compras;
|
||||
|
||||
class ProveedorModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_proveedores";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.tipo_id",
|
||||
4 => "t1.razon_social",
|
||||
5 => "t1.cif",
|
||||
6 => "t1.direccion",
|
||||
7 => "t1.cp",
|
||||
8 => "t1.ciudad",
|
||||
9 => "t1.provincia_id",
|
||||
10 => "t1.pais_id",
|
||||
11 => "t1.persona_contacto",
|
||||
12 => "t1.email",
|
||||
13 => "t1.telefono",
|
||||
14 => "t2.nombre",
|
||||
15 => "t3.nombre",
|
||||
16 => "t4.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"tipo_id",
|
||||
"razon_social",
|
||||
"cif",
|
||||
"direccion",
|
||||
"cp",
|
||||
"ciudad",
|
||||
"provincia_id",
|
||||
"pais_id",
|
||||
"persona_contacto",
|
||||
"email",
|
||||
"telefono",
|
||||
];
|
||||
protected $returnType = "App\Entities\compras\ProveedorEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"cif" => [
|
||||
"label" => "LgProveedores.cif",
|
||||
"rules" => "trim|max_length[15]",
|
||||
],
|
||||
"ciudad" => [
|
||||
"label" => "LgProveedores.ciudad",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"cp" => [
|
||||
"label" => "LgProveedores.cp",
|
||||
"rules" => "trim|max_length[10]",
|
||||
],
|
||||
"direccion" => [
|
||||
"label" => "LgProveedores.direccion",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"email" => [
|
||||
"label" => "LgProveedores.email",
|
||||
"rules" => "trim|max_length[255]|valid_email|permit_empty",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "LgProveedores.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"persona_contacto" => [
|
||||
"label" => "LgProveedores.personaContacto",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"razon_social" => [
|
||||
"label" => "LgProveedores.razonSocial",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"telefono" => [
|
||||
"label" => "LgProveedores.telefono",
|
||||
"rules" => "trim|max_length[60]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"cif" => [
|
||||
"max_length" => "LgProveedores.validation.cif.max_length",
|
||||
],
|
||||
"ciudad" => [
|
||||
"max_length" => "LgProveedores.validation.ciudad.max_length",
|
||||
],
|
||||
"cp" => [
|
||||
"max_length" => "LgProveedores.validation.cp.max_length",
|
||||
],
|
||||
"direccion" => [
|
||||
"max_length" => "LgProveedores.validation.direccion.max_length",
|
||||
],
|
||||
"email" => [
|
||||
"max_length" => "LgProveedores.validation.email.max_length",
|
||||
"valid_email" => "LgProveedores.validation.email.valid_email",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "LgProveedores.validation.nombre.max_length",
|
||||
"required" => "LgProveedores.validation.nombre.required",
|
||||
],
|
||||
"persona_contacto" => [
|
||||
"max_length" => "LgProveedores.validation.persona_contacto.max_length",
|
||||
],
|
||||
"razon_social" => [
|
||||
"max_length" => "LgProveedores.validation.razon_social.max_length",
|
||||
],
|
||||
"telefono" => [
|
||||
"max_length" => "LgProveedores.validation.telefono.max_length",
|
||||
],
|
||||
];
|
||||
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS tipo, t3.nombre AS provincia, t4.nombre AS pais FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_proveedores_tipos t2 ON t1.tipo_id = t2.id LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id LEFT JOIN lg_paises t4 ON t1.pais_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.razon_social AS razon_social, t1.cif AS cif, t1.direccion AS direccion, t1.cp AS cp, t1.ciudad AS ciudad, t1.persona_contacto AS persona_contacto, t1.email AS email, t1.telefono AS telefono, t2.nombre AS tipo, t3.nombre AS provincia, t4.nombre AS pais"
|
||||
);
|
||||
$builder->join("lg_proveedores_tipos t2", "t1.tipo_id = t2.id", "left");
|
||||
$builder->join("lg_provincias t3", "t1.provincia_id = t3.id", "left");
|
||||
$builder->join("lg_paises t4", "t1.pais_id = t4.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.razon_social", $search)
|
||||
->orLike("t1.cif", $search)
|
||||
->orLike("t1.direccion", $search)
|
||||
->orLike("t1.cp", $search)
|
||||
->orLike("t1.ciudad", $search)
|
||||
->orLike("t1.persona_contacto", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t3.id", $search)
|
||||
->orLike("t4.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo_id", $search)
|
||||
->orLike("t1.razon_social", $search)
|
||||
->orLike("t1.cif", $search)
|
||||
->orLike("t1.direccion", $search)
|
||||
->orLike("t1.cp", $search)
|
||||
->orLike("t1.ciudad", $search)
|
||||
->orLike("t1.provincia_id", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.persona_contacto", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->orLike("t3.nombre", $search)
|
||||
->orLike("t4.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
75
ci4/app/Models/Compras/ProveedorTipoModel.php
Normal file
75
ci4/app/Models/Compras/ProveedorTipoModel.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
namespace App\Models\compras;
|
||||
|
||||
class ProveedorTipoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_proveedores_tipos";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.created_at",
|
||||
4 => "t1.updated_at",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
protected $returnType = "App\Entities\compras\ProveedorTipoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "LgProveedoresTipos.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "LgProveedoresTipos.validation.nombre.max_length",
|
||||
"required" => "LgProveedoresTipos.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 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.created_at AS created_at, t1.updated_at AS updated_at");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?=lang('LgProveedores.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $proveedorEntity->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="razonSocial" class="form-label">
|
||||
<?=lang('LgProveedores.razonSocial') ?>
|
||||
</label>
|
||||
<input type="text" id="razonSocial" name="razon_social" maxLength="255" class="form-control" value="<?=old('razon_social', $proveedorEntity->razon_social) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="direccion" class="form-label">
|
||||
<?=lang('LgProveedores.direccion') ?>
|
||||
</label>
|
||||
<input type="text" id="direccion" name="direccion" maxLength="255" class="form-control" value="<?=old('direccion', $proveedorEntity->direccion) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ciudad" class="form-label">
|
||||
<?=lang('LgProveedores.ciudad') ?>
|
||||
</label>
|
||||
<input type="text" id="ciudad" name="ciudad" maxLength="255" class="form-control" value="<?=old('ciudad', $proveedorEntity->ciudad) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="paisId" class="form-label">
|
||||
<?=lang('LgProveedores.paisId') ?>*
|
||||
</label>
|
||||
<select id="paisId" name="pais_id" required class="form-control select2bs" style="width: 100%;" >
|
||||
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('LgProveedores.paisId')]) ?></option>
|
||||
|
||||
<?php foreach ($paisList as $item) : ?>
|
||||
<option value="<?=$item->id ?>"<?=$item->id==$proveedorEntity->pais_id ? ' selected':'' ?>>
|
||||
<?=$item->nombre ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">
|
||||
<?=lang('LgProveedores.email') ?>
|
||||
</label>
|
||||
<input type="email" id="email" name="email" maxLength="255" class="form-control" value="<?=old('email', $proveedorEntity->email) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="tipoId" class="form-label">
|
||||
<?=lang('LgProveedores.tipoId') ?>
|
||||
</label>
|
||||
<select id="tipoId" name="tipo_id" class="form-control select2bs2" style="width: 100%;" >
|
||||
|
||||
<?php if ( isset($proveedorTipoList) && is_array($proveedorTipoList) && !empty($proveedorTipoList) ) :
|
||||
foreach ($proveedorTipoList as $k => $v) : ?>
|
||||
<option value="<?=$k ?>"<?=$k==$proveedorEntity->tipo_id ? ' selected':'' ?>>
|
||||
<?=$v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="cif" class="form-label">
|
||||
<?=lang('LgProveedores.cif') ?>
|
||||
</label>
|
||||
<input type="text" id="cif" name="cif" maxLength="15" class="form-control" value="<?=old('cif', $proveedorEntity->cif) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="cp" class="form-label">
|
||||
<?=lang('LgProveedores.cp') ?>
|
||||
</label>
|
||||
<input type="text" id="cp" name="cp" maxLength="10" class="form-control" value="<?=old('cp', $proveedorEntity->cp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="provinciaId" class="form-label">
|
||||
<?=lang('LgProveedores.provinciaId') ?>*
|
||||
</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==$proveedorEntity->provincia_id ? ' selected':'' ?>>
|
||||
<?=$v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="personaContacto" class="form-label">
|
||||
<?=lang('LgProveedores.personaContacto') ?>
|
||||
</label>
|
||||
<input type="text" id="personaContacto" name="persona_contacto" maxLength="255" class="form-control" value="<?=old('persona_contacto', $proveedorEntity->persona_contacto) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="telefono" class="form-label">
|
||||
<?=lang('LgProveedores.telefono') ?>
|
||||
</label>
|
||||
<input type="text" id="telefono" name="telefono" maxLength="60" class="form-control" value="<?=old('telefono', $proveedorEntity->telefono) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -0,0 +1,12 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?=lang('LgProveedoresTipos.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $proveedorTipoEntity->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -0,0 +1,93 @@
|
||||
<?= $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="proveedorForm" 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/compras/proveedores/_proveedorFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("proveedorList"), 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") ?>
|
||||
|
||||
|
||||
$('#tipoId').select2({
|
||||
theme: 'bootstrap-5',
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
url: '<?= route_to("menuItemsOfProveedoresTipos") ?>',
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,183 @@
|
||||
<?=$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('LgProveedores.proveedorList') ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('Themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfProveedores" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
<th><?=lang('LgProveedores.id')?></th>
|
||||
<th><?= lang('LgProveedores.nombre') ?></th>
|
||||
<th><?= lang('LgProveedoresTipos.proveedorTipo') ?></th>
|
||||
<th><?= lang('LgProveedores.razonSocial') ?></th>
|
||||
<th><?= lang('LgProveedores.cif') ?></th>
|
||||
<th><?= lang('LgProveedores.direccion') ?></th>
|
||||
<th><?= lang('LgProveedores.cp') ?></th>
|
||||
<th><?= lang('LgProveedores.ciudad') ?></th>
|
||||
<th><?= lang('Provincias.provincia') ?></th>
|
||||
<th><?= lang('Paises.pais') ?></th>
|
||||
<th><?= lang('LgProveedores.personaContacto') ?></th>
|
||||
<th><?= lang('LgProveedores.email') ?></th>
|
||||
<th><?= lang('LgProveedores.telefono') ?></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('newProveedor'), lang('Basic.global.addNew').' '.lang('LgProveedores.proveedor'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfProveedores').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 = $('#tableOfProveedores').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('dataTableOfProveedores') ?>',
|
||||
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': 'tipo' },
|
||||
{ 'data': 'razon_social' },
|
||||
{ 'data': 'cif' },
|
||||
{ 'data': 'direccion' },
|
||||
{ 'data': 'cp' },
|
||||
{ 'data': 'ciudad' },
|
||||
{ 'data': 'provincia' },
|
||||
{ 'data': 'pais' },
|
||||
{ 'data': 'persona_contacto' },
|
||||
{ 'data': 'email' },
|
||||
{ 'data': 'telefono' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `<?= route_to('proveedorList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('LgProveedores.proveedor'))]) ?>',
|
||||
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('proveedorList') ?>/${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,26 @@
|
||||
<?= $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="proveedorTipoForm" 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/compras/proveedores/_proveedorTipoFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("proveedorTipoList"), 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() ?>
|
||||
@ -0,0 +1,185 @@
|
||||
<?=$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('LgProveedoresTipos.proveedorTipoList') ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('Themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfProveedorestipos" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
<th><?=lang('LgProveedoresTipos.id')?></th>
|
||||
<th><?= lang('LgProveedoresTipos.nombre') ?></th>
|
||||
<th><?= lang('LgProveedoresTipos.createdAt') ?></th>
|
||||
<th><?= lang('LgProveedoresTipos.updatedAt') ?></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('newProveedorTipo'), lang('Basic.global.addNew').' '.lang('LgProveedoresTipos.proveedorTipo'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfProveedorestipos').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 = $('#tableOfProveedorestipos').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('dataTableOfProveedoresTipos') ?>',
|
||||
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': 'created_at' },
|
||||
{ 'data': 'updated_at' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
theTable.on( 'draw.dt', function () {
|
||||
|
||||
const dateCols = [3, 4];
|
||||
const shortDateFormat = '<?= convertPhpDateToMomentFormat('mm/dd/YYYY')?>';
|
||||
const dateTimeFormat = '<?= convertPhpDateToMomentFormat('mm/dd/YYYY h:i a')?>';
|
||||
|
||||
for (let coln of dateCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
const datestr = cell.innerHTML;
|
||||
const dateStrLen = datestr.toString().trim().length;
|
||||
if (dateStrLen > 0) {
|
||||
let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values
|
||||
dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one
|
||||
const d = new Date(...dateTimeParts); // new Date(datestr);
|
||||
const md = moment(d);
|
||||
const usingThisFormat = dateStrLen > 11 ? dateTimeFormat : shortDateFormat;
|
||||
const formattedDateStr = md.format(usingThisFormat);
|
||||
cell.innerHTML = formattedDateStr;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `<?= route_to('proveedorTipoList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('LgProveedoresTipos.proveedor tipo'))]) ?>',
|
||||
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('proveedorTipoList') ?>/${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() ?>
|
||||
|
||||
Reference in New Issue
Block a user