mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
tarifas acabado antes de meter lineas
This commit is contained in:
@ -65,17 +65,18 @@ $routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], funct
|
||||
});
|
||||
|
||||
$routes->group('tarifaacabado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||
$routes->get('', 'Tarifaacabado::index', ['as' => 'tarifaacabadoList']);
|
||||
$routes->get('index', 'Tarifaacabado::index', ['as' => 'tarifaacabadoIndex']);
|
||||
$routes->get('list', 'Tarifaacabado::index', ['as' => 'tarifaacabadoList2']);
|
||||
$routes->get('add', 'Tarifaacabado::add', ['as' => 'newTarifaacabado']);
|
||||
$routes->post('add', 'Tarifaacabado::add', ['as' => 'createTarifaacabado']);
|
||||
$routes->get('edit/(:num)', 'Tarifaacabado::edit/$1', ['as' => 'editTarifaacabado']);
|
||||
$routes->post('edit/(:num)', 'Tarifaacabado::edit/$1', ['as' => 'updateTarifaacabado']);
|
||||
$routes->get('delete/(:num)', 'Tarifaacabado::delete/$1', ['as' => 'deleteTarifaacabado']);
|
||||
$routes->post('allmenuitems', 'Tarifaacabado::allItemsSelect', ['as' => 'select2ItemsOfTarifasacabado']);
|
||||
$routes->post('menuitems', 'Tarifaacabado::menuItems', ['as' => 'menuItemsOfTarifasacabado']);
|
||||
$routes->get('', 'Tarifaacabado::index', ['as' => 'tarifaAcabadoList']);
|
||||
$routes->get('add', 'Tarifaacabado::add', ['as' => 'newTarifaAcabado']);
|
||||
$routes->post('add', 'Tarifaacabado::add', ['as' => 'createTarifaAcabado']);
|
||||
$routes->post('create', 'Tarifaacabado::create', ['as' => 'ajaxCreateTarifaAcabado']);
|
||||
$routes->put('(:num)/update', 'Tarifaacabado::update/$1', ['as' => 'ajaxUpdateTarifaAcabado']);
|
||||
$routes->post('(:num)/edit', 'Tarifaacabado::edit/$1', ['as' => 'updateTarifaAcabado']);
|
||||
$routes->post('datatable', 'Tarifaacabado::datatable', ['as' => 'dataTableOfTarifasAcabado']);
|
||||
$routes->post('allmenuitems', 'Tarifaacabado::allItemsSelect', ['as' => 'select2ItemsOfTarifasAcabado']);
|
||||
$routes->post('menuitems', 'Tarifaacabado::menuItems', ['as' => 'menuItemsOfTarifasAcabado']);
|
||||
});
|
||||
$routes->resource('tarifaacabado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaacabado', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'Users::index', ['as' => 'userList']);
|
||||
|
||||
@ -1,46 +1,58 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php namespace App\Controllers\tarifas;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Tarifas\TarifaacabadoEntity;
|
||||
|
||||
class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
use App\Models\Tarifas\TarifaacabadoModel;
|
||||
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected static $primaryModelName = 'App\Models\Tarifas\TarifaacabadoModel';
|
||||
protected $modelName = TarifaacabadoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectNameCc = 'tarifaacabado';
|
||||
protected static $singularObjectName = 'Tarifaacabado';
|
||||
protected static $pluralObjectName = 'Tarifasacabado';
|
||||
protected static $controllerSlug = 'tarifaacabado';
|
||||
protected static $singularObjectName = 'Tarifa Acabado';
|
||||
protected static $singularObjectNameCc = 'tarifaAcabado';
|
||||
protected static $pluralObjectName = 'Tarifas Acabado';
|
||||
protected static $pluralObjectNameCc = 'tarifasAcabado';
|
||||
|
||||
protected static $controllerSlug = 'tarifasacabado';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/tarifas/acabado/';
|
||||
protected $indexRoute = 'tarifaacabadoList';
|
||||
|
||||
protected $indexRoute = 'tarifaAcabadoList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Tarifaacabado.moduleTitle');
|
||||
// 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;
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaacabado.tarifaacabado')]);
|
||||
parent::index();
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaacabado.tarifaacabado')]),
|
||||
'tarifaacabadoEntity' => new TarifaacabadoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewTarifaAcabadoList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
$session = session();
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
@ -49,13 +61,13 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
$sanitizedData['user_created_id'] = $session->id_user;
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
@ -76,47 +88,44 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]).'.';
|
||||
$message .= anchor(route_to('editTarifaacabado', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message .= anchor( "tarifasacabado/{$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('successMessage', $message);
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->viewData['successMessage'] = $message;
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifaacabado_'] = isset($sanitizedData) ? new TarifaacabadoEntity($sanitizedData) : new TarifaacabadoEntity();
|
||||
$this->viewData['tarifaacabadoEntity'] = isset($sanitizedData) ? new TarifaacabadoEntity($sanitizedData) : new TarifaacabadoEntity();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createTarifaacabado');
|
||||
$this->viewData['formAction'] = route_to('createTarifaAcabado');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifaacabado.tarifaacabado').' '.lang('Basic.global.addNewSuffix');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifaacabado.moduleTitle').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$tarifaacabado_ = $this->model->find($id);
|
||||
$tarifaacabadoEntity = $this->model->find($id);
|
||||
|
||||
if ($tarifaacabado_ == false) :
|
||||
if ($tarifaacabadoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifaacabado.tarifaacabado')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
@ -126,13 +135,10 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
@ -152,49 +158,76 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
|
||||
endif;
|
||||
|
||||
$tarifaacabado_->fill($sanitizedData);
|
||||
$tarifaacabadoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifaacabado_->id ?? $id;
|
||||
$id = $tarifaacabadoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]).'.';
|
||||
$message .= anchor(route_to('editTarifaacabado', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message .= anchor( "tarifasacabado/{$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('successMessage', $message);
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->viewData['successMessage'] = $message;
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifaacabado_'] = $tarifaacabado_;
|
||||
$this->viewData['tarifaacabadoEntity'] = $tarifaacabadoEntity;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaacabado', $id);
|
||||
$this->viewData['formAction'] = route_to('updateTarifaAcabado', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifaacabado.tarifaacabado').' '.lang('Basic.global.edit3');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifaacabado.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 = TarifaacabadoModel::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.', Select a field...', 'Select a field...', $onlyActiveOnes, false);
|
||||
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->Selectafield = '- '.lang('Basic.global.None').' -';
|
||||
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
@ -208,14 +241,14 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
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 ?? 'Select a field...'];
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
@ -233,5 +266,6 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
289
ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php
Normal file
289
ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php
Normal file
@ -0,0 +1,289 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Tarifas\TarifaAcabadoLinea;
|
||||
|
||||
use App\Models\tarifas\TarifaacabadoModel;
|
||||
|
||||
use App\Models\Tarifas\TarifaAcabadoLineaModel;
|
||||
|
||||
class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = TarifaAcabadoLineaModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Tarifa Acabado Linea';
|
||||
protected static $singularObjectNameCc = 'tarifaAcabadoLinea';
|
||||
protected static $pluralObjectName = 'Tarifa Acabado Lineas';
|
||||
protected static $pluralObjectNameCc = 'tarifaAcabadoLineas';
|
||||
|
||||
protected static $controllerSlug = 'tarifa-acabado-lineas';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/tarifas/acabado/';
|
||||
|
||||
protected $indexRoute = 'tarifaAcabadoLineaList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('TarifaAcabadoLineas.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaAcabadoLineas.tarifaAcabadoLinea')]),
|
||||
'tarifaAcabadoLinea' => new TarifaAcabadoLinea(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewTarifaAcabadoLineaList', $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('TarifaAcabadoLineas.tarifaAcabadoLinea'))]);
|
||||
$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('TarifaAcabadoLineas.tarifaAcabadoLinea'))]).'.';
|
||||
$message .= anchor( "tarifa-acabado-lineas/{$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['tarifaAcabadoLinea'] = isset($sanitizedData) ? new TarifaAcabadoLinea($sanitizedData) : new TarifaAcabadoLinea();
|
||||
$this->viewData['tarifaAcabadoList'] = $this->getTarifaAcabadoListItems($tarifaAcabadoLinea->tarifa_acabado_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('createTarifaAcabadoLinea');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaAcabadoLineas.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);
|
||||
$tarifaAcabadoLinea = $this->model->find($id);
|
||||
|
||||
if ($tarifaAcabadoLinea == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaAcabadoLineas.tarifaAcabadoLinea')), $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('TarifaAcabadoLineas.tarifaAcabadoLinea'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$tarifaAcabadoLinea->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifaAcabadoLinea->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaAcabadoLineas.tarifaAcabadoLinea'))]).'.';
|
||||
$message .= anchor( "tarifa-acabado-lineas/{$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['tarifaAcabadoLinea'] = $tarifaAcabadoLinea;
|
||||
$this->viewData['tarifaAcabadoList'] = $this->getTarifaAcabadoListItems($tarifaAcabadoLinea->tarifa_acabado_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaAcabadoLinea', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaAcabadoLineas.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 = TarifaAcabadoLineaModel::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.', tarifa_acabado_id', 'tarifa_acabado_id', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->tarifa_acabado_id = '- '.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 ?? 'tarifa_acabado_id'];
|
||||
$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 getTarifaAcabadoListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Tarifaacabado.tarifaAcabado'))])];
|
||||
if (!empty($selId)) :
|
||||
$tarifaacabadoModel = model('App\Models\tarifas\TarifaacabadoModel');
|
||||
|
||||
$selOption = $tarifaacabadoModel->where('id', $selId)->findColumn('id');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
33
ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php
Normal file
33
ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace App\Entities\Tarifas;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class TarifaAcabadoLinea extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"tarifa_acabado_id" => 0,
|
||||
"tirada_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"precio_min" => 0,
|
||||
"precio_max" => 0,
|
||||
"precio_unidad" => 0,
|
||||
"user_created_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"tarifa_acabado_id" => "int",
|
||||
"tirada_min" => "int",
|
||||
"tirada_max" => "int",
|
||||
"precio_min" => "float",
|
||||
"precio_max" => "float",
|
||||
"precio_unidad" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
@ -1,33 +1,22 @@
|
||||
<?php
|
||||
namespace App\Entities\Tarifas;
|
||||
namespace App\Entities\tarifas;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class TarifaacabadoEntity extends Entity
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class TarifaacabadoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"tirada_min" => 0,
|
||||
"precio_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"precio_max" => null,
|
||||
"ajuste" => 0,
|
||||
"formula_price" => null,
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"deleted_at" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"tirada_min" => "int",
|
||||
"precio_min" => "float",
|
||||
"tirada_max" => "int",
|
||||
"precio_max" => "float",
|
||||
"ajuste" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_update_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
|
||||
176
ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php
Normal file
176
ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
namespace App\Models\Tarifas;
|
||||
|
||||
class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "tarifa_acabado_lineas";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.tirada_min",
|
||||
2 => "t1.tirada_max",
|
||||
3 => "t1.precio_min",
|
||||
4 => "t1.precio_max",
|
||||
5 => "t1.precio_unidad",
|
||||
6 => "t1.user_created_id",
|
||||
7 => "t1.user_updated_id",
|
||||
8 => "t1.is_deleted",
|
||||
9 => "t1.created_at",
|
||||
10 => "t1.updated_at",
|
||||
11 => "t2.id",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"tirada_min",
|
||||
"tirada_max",
|
||||
"precio_min",
|
||||
"precio_max",
|
||||
"precio_unidad",
|
||||
"user_created_id",
|
||||
"is_deleted",
|
||||
];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifaAcabadoLinea";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "tarifa_acabado_id";
|
||||
|
||||
protected $validationRules = [
|
||||
"is_deleted" => [
|
||||
"label" => "TarifaAcabadoLineas.isDeleted",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"precio_max" => [
|
||||
"label" => "TarifaAcabadoLineas.precioMax",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_min" => [
|
||||
"label" => "TarifaAcabadoLineas.precioMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_unidad" => [
|
||||
"label" => "TarifaAcabadoLineas.precioUnidad",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"label" => "TarifaAcabadoLineas.tiradaMax",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"label" => "TarifaAcabadoLineas.tiradaMin",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"label" => "TarifaAcabadoLineas.userCreatedId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"is_deleted" => [
|
||||
"integer" => "TarifaAcabadoLineas.validation.is_deleted.integer",
|
||||
"required" => "TarifaAcabadoLineas.validation.is_deleted.required",
|
||||
],
|
||||
"precio_max" => [
|
||||
"decimal" => "TarifaAcabadoLineas.validation.precio_max.decimal",
|
||||
"required" => "TarifaAcabadoLineas.validation.precio_max.required",
|
||||
],
|
||||
"precio_min" => [
|
||||
"decimal" => "TarifaAcabadoLineas.validation.precio_min.decimal",
|
||||
"required" => "TarifaAcabadoLineas.validation.precio_min.required",
|
||||
],
|
||||
"precio_unidad" => [
|
||||
"decimal" => "TarifaAcabadoLineas.validation.precio_unidad.decimal",
|
||||
"required" => "TarifaAcabadoLineas.validation.precio_unidad.required",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"integer" => "TarifaAcabadoLineas.validation.tirada_max.integer",
|
||||
"required" => "TarifaAcabadoLineas.validation.tirada_max.required",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"integer" => "TarifaAcabadoLineas.validation.tirada_min.integer",
|
||||
"required" => "TarifaAcabadoLineas.validation.tirada_min.required",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"integer" => "TarifaAcabadoLineas.validation.user_created_id.integer",
|
||||
"required" => "TarifaAcabadoLineas.validation.user_created_id.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithTarifaAcabado(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.id AS tarifa_acabado FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_tarifa_acabado t2 ON t1.tarifa_acabado_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.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.precio_unidad AS precio_unidad, t1.user_created_id AS user_created_id, t1.user_updated_id AS user_updated_id, t1.is_deleted AS is_deleted, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.id AS tarifa_acabado"
|
||||
);
|
||||
$builder->join("lg_tarifa_acabado t2", "t1.tarifa_acabado_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t1.precio_min", $search)
|
||||
->orLike("t1.precio_max", $search)
|
||||
->orLike("t1.precio_unidad", $search)
|
||||
->orLike("t1.user_created_id", $search)
|
||||
->orLike("t1.user_updated_id", $search)
|
||||
->orLike("t1.is_deleted", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t1.precio_min", $search)
|
||||
->orLike("t1.precio_max", $search)
|
||||
->orLike("t1.precio_unidad", $search)
|
||||
->orLike("t1.user_created_id", $search)
|
||||
->orLike("t1.user_updated_id", $search)
|
||||
->orLike("t1.is_deleted", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace App\Models\Tarifas;
|
||||
namespace App\Models\tarifas;
|
||||
|
||||
class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
@ -11,88 +11,54 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"tirada_min",
|
||||
"precio_min",
|
||||
"tirada_max",
|
||||
"precio_max",
|
||||
"ajuste",
|
||||
"formula_price",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifaacabadoEntity";
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
protected $returnType = 'App\Entities\Tarifas\TarifaacabadoEntity';
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"ajuste" => [
|
||||
"label" => "Acabadoes.ajuste",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"formula_price" => [
|
||||
"label" => "Acabadoes.formulaPrice",
|
||||
"rules" => "trim|required|max_length[1073241]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "Acabadoes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"precio_max" => [
|
||||
"label" => "Acabadoes.precioMax",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_min" => [
|
||||
"label" => "Acabadoes.precioMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"label" => "Acabadoes.tiradaMax",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"label" => "Acabadoes.tiradaMin",
|
||||
"rules" => "required|integer",
|
||||
]
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"ajuste" => [
|
||||
"decimal" => "Acabadoes.validation.ajuste.decimal",
|
||||
"required" => "Acabadoes.validation.ajuste.required",
|
||||
],
|
||||
"formula_price" => [
|
||||
"max_length" => "Acabadoes.validation.formula_price.max_length",
|
||||
"required" => "Acabadoes.validation.formula_price.required",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Acabadoes.validation.nombre.max_length",
|
||||
"required" => "Acabadoes.validation.nombre.required",
|
||||
],
|
||||
"precio_max" => [
|
||||
"decimal" => "Acabadoes.validation.precio_max.decimal",
|
||||
"required" => "Acabadoes.validation.precio_max.required",
|
||||
],
|
||||
"precio_min" => [
|
||||
"decimal" => "Acabadoes.validation.precio_min.decimal",
|
||||
"required" => "Acabadoes.validation.precio_min.required",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"integer" => "Acabadoes.validation.tirada_max.integer",
|
||||
"required" => "Acabadoes.validation.tirada_max.required",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"integer" => "Acabadoes.validation.tirada_min.integer",
|
||||
"required" => "Acabadoes.validation.tirada_min.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");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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('Tarifaacabado.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifaacabadoEntity->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -1,56 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?=lang('Tarifaacabado.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifaacabado_->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMin" class="form-label">
|
||||
<?=lang('Tarifaacabado.tiradaMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="tiradaMin" name="tirada_min" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_min', $tarifaacabado_->tirada_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMax" class="form-label">
|
||||
<?=lang('Tarifaacabado.tiradaMax') ?>*
|
||||
</label>
|
||||
<input type="number" id="tiradaMax" name="tirada_max" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_max', $tarifaacabado_->tirada_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMin" class="form-label">
|
||||
<?=lang('Tarifaacabado.precioMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMin" name="precio_min" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('precio_min', $tarifaacabado_->precio_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMax" class="form-label">
|
||||
<?=lang('Tarifaacabado.precioMax') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMax" name="precio_max" required maxLength="31" step="0.01" class="form-control" value="<?=old('precio_max', $tarifaacabado_->precio_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ajuste" class="form-label">
|
||||
<?=lang('Tarifaacabado.ajuste') ?>*
|
||||
</label>
|
||||
<input type="number" id="ajuste" name="ajuste" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('ajuste', $tarifaacabado_->ajuste) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="formulaPrice" class="form-label">
|
||||
<?=lang('Tarifaacabado.formulaPrice') ?>*
|
||||
</label>
|
||||
<textarea rows="3" id="formulaPrice" name="formula_price" required style="height: 10em;" class="form-control"><?=old('formula_price', $tarifaacabado_->formula_price) ?></textarea>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -0,0 +1,31 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<form id="tarifaAcabadoForm" 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/tarifas/acabado/_tarifaAcabadoFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<input type="submit"
|
||||
class="btn btn-primary float-start me-sm-3 me-1"
|
||||
name="save"
|
||||
value="<?= lang("Basic.global.Save") ?>"
|
||||
/>
|
||||
<?= anchor(route_to("tarifaAcabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,99 +1,32 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?=$this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?=lang('Tarifaacabado.tarifaacabadoList') ?></h3>
|
||||
<?=anchor(route_to('newTarifaacabado'), lang('Basic.global.addNew').' '.lang('Tarifaacabado.tarifaacabado'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
<?=anchor(route_to('newTarifaAcabado'), lang('Basic.global.addNew').' '.lang('Tarifaacabado.tarifaacabado'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfTarifasacabado" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
|
||||
<table id="tableOfTarifasacabado" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifaacabado.id') ?></th>
|
||||
*/ ?>
|
||||
|
||||
<th><?= lang('Tarifaacabado.nombre') ?></th>
|
||||
<th><?= lang('Tarifaacabado.tiradaMin') ?></th>
|
||||
<th><?= lang('Tarifaacabado.tiradaMax') ?></th>
|
||||
<th><?= lang('Tarifaacabado.precioMin') ?></th>
|
||||
<th><?= lang('Tarifaacabado.precioMax') ?></th>
|
||||
<th><?= lang('Tarifaacabado.ajuste') ?></th>
|
||||
<th><?= lang('Tarifaacabado.formulaPrice') ?></th>
|
||||
|
||||
<?php /*
|
||||
<th><?= lang('Tarifaacabado.userCreatedId') ?></th>
|
||||
<th><?= lang('Tarifaacabado.userUpdateId') ?></th>
|
||||
<th><?= lang('Tarifaacabado.deletedAt') ?></th>
|
||||
<th><?= lang('Tarifaacabado.createdAt') ?></th>
|
||||
<th><?= lang('Tarifaacabado.updatedAt') ?></th>
|
||||
*/ ?>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tarifaacabadoList as $item ) : ?>
|
||||
<tr>
|
||||
<?php /*
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->ajuste) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->formula_price) || strlen($item->formula_price) < 51 ? esc($item->formula_price) : character_limiter(esc($item->formula_price), 50) ?>
|
||||
</td>
|
||||
<?php /*
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_created_id) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_update_id) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->deleted_at) ? '' : date('d/m/Y H:m:s', strtotime($item->deleted_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editTarifaacabado', $item->id), "<i class='ti ti-pencil ti-sm mx-2'></i>", ['class'=>'text-body', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', "<i class='ti ti-trash ti-sm mx-2'></i>", ['class'=>'text-body', 'data-href'=>route_to('deleteTarifaacabado', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
@ -101,6 +34,111 @@
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
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">
|
||||
<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 = $('#tableOfTarifasacabado').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
"dom": 'lfBrtip',
|
||||
"buttons": [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
stateSave: true,
|
||||
order: [[0, 'asc']],
|
||||
language: {
|
||||
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
},
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfTarifasAcabado') ?>',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
}
|
||||
],
|
||||
columns : [
|
||||
{ 'data': 'nombre' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
//window.location.href = `<?= route_to('tarifaAcabadoList') ?>/edit/${$(this).attr('data-id')}`;
|
||||
window.location.href = `/tarifas/tarifaacabado/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Tarifaacabado.tarifa acabado'))]) ?>',
|
||||
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('tarifaAcabadoList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/tarifas/tarifaacabado/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,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
<?=$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() ?>
|
||||
@ -119,40 +157,3 @@
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1;
|
||||
theTable = $('.using-exportable-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,
|
||||
"dom": 'lfBrtip', // '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'
|
||||
}
|
||||
],
|
||||
"autoWidth": true,
|
||||
"scrollX": true,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [0,lastColNr2]
|
||||
}
|
||||
]
|
||||
});
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<form id="tarifaacabadoForm" method="post" class="card-body" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/backend/vuexy/form/tarifas/acabado/_tarifaacabadoFormItems") ?>
|
||||
<div class="pt-4">
|
||||
<input type="submit"
|
||||
class="btn btn-primary float-start me-sm-3 me-1"
|
||||
name="save"
|
||||
value="<?= lang("Basic.global.Save") ?>"
|
||||
/>
|
||||
<?= anchor(route_to("tarifaacabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary"]) ?>
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
Reference in New Issue
Block a user