mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/maquinas_defecto' into 'main'
Añadida funcionalidad maquinas por defecto See merge request jjimenez/safekat!30
This commit is contained in:
4
ci4/.env
4
ci4/.env
@ -22,8 +22,8 @@ CI_ENVIRONMENT = development
|
||||
# APP
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
#app.baseURL = 'https://sk-jjo.imnavajas.es'
|
||||
app.baseURL = 'https://sk-imn.imnavajas.es'
|
||||
app.baseURL = 'https://sk-jjo.imnavajas.es'
|
||||
#app.baseURL = 'https://sk-imn.imnavajas.es'
|
||||
# app.baseURL = "http://safekat.test/"
|
||||
# app.forceGlobalSecureRequests = false
|
||||
|
||||
|
||||
@ -251,6 +251,19 @@ $routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Conf
|
||||
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('maquinasdefecto', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'Maquinasdefecto::index', ['as' => 'maquinaPorDefectoList']);
|
||||
$routes->get('add', 'Maquinasdefecto::add', ['as' => 'newMaquinaPorDefecto']);
|
||||
$routes->post('add', 'Maquinasdefecto::add', ['as' => 'createMaquinaPorDefecto']);
|
||||
$routes->post('create', 'Maquinasdefecto::create', ['as' => 'ajaxCreateMaquinaPorDefecto']);
|
||||
$routes->put('(:num)/update', 'Maquinasdefecto::update/$1', ['as' => 'ajaxUpdateMaquinaPorDefecto']);
|
||||
$routes->post('edit/(:num)', 'Maquinasdefecto::edit/$1', ['as' => 'updateMaquinaPorDefecto']);
|
||||
$routes->post('datatable', 'Maquinasdefecto::datatable', ['as' => 'dataTableOfMaquinasPorDefecto']);
|
||||
$routes->post('allmenuitems', 'Maquinasdefecto::allItemsSelect', ['as' => 'select2ItemsOfMaquinasPorDefecto']);
|
||||
$routes->post('menuitems', 'Maquinasdefecto::menuItems', ['as' => 'menuItemsOfMaquinasPorDefecto']);
|
||||
});
|
||||
$routes->resource('maquinasdefecto', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinasdefecto', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||
$routes->get('', 'Profile::index', ['as' => 'profileList']);
|
||||
|
||||
341
ci4/app/Controllers/Configuracion/Maquinasdefecto.php
Normal file
341
ci4/app/Controllers/Configuracion/Maquinasdefecto.php
Normal file
@ -0,0 +1,341 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Configuracion\MaquinasDefectoEntity;
|
||||
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
|
||||
use App\Models\Configuracion\MaquinasDefectoModel;
|
||||
|
||||
class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = MaquinasDefectoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Maquina Por Defecto';
|
||||
protected static $singularObjectNameCc = 'maquinaPorDefecto';
|
||||
protected static $pluralObjectName = 'Maquinas Por Defecto';
|
||||
protected static $pluralObjectNameCc = 'maquinasPorDefecto';
|
||||
|
||||
protected static $controllerSlug = 'maquinasdefecto';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/configuracion/maquinas/';
|
||||
|
||||
protected $indexRoute = 'maquinaPorDefectoList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('MaquinasPorDefecto.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('MaquinasPorDefecto.maquinaPorDefecto')]),
|
||||
'maquinasDefectoEntity' => new MaquinasDefectoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewMaquinaPorDefectoList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_created_id'] = $session->id_user;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
// JJO: se añade que se checkeen los intervalos de ancho y tirada.
|
||||
// En caso de error se devuelve un mensaje.
|
||||
try {
|
||||
$error = $this->model->checkIntervals($sanitizedData);
|
||||
if(empty($error)){
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
}
|
||||
else{
|
||||
$successfulResult = false;
|
||||
$this->viewData['errorMessage'] = $error;
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]);
|
||||
$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('MaquinasPorDefecto.maquinaPorDefecto'))]).'.';
|
||||
$message .= anchor( "configuracion/maquinasdefecto/edit/{$id}" , 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['maquinasDefectoEntity'] = isset($sanitizedData) ? new MaquinasDefectoEntity($sanitizedData) : new MaquinasDefectoEntity();
|
||||
$this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasDefectoEntity->maquina_id ?? null);
|
||||
$this->viewData['tipoList'] = $this->getTipoOptions();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createMaquinaPorDefecto');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('MaquinasPorDefecto.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);
|
||||
$maquinasDefectoEntity = $this->model->find($id);
|
||||
|
||||
if ($maquinasDefectoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto')), $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);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
// JJO: se añade que se checkeen los intervalos de ancho y tirada.
|
||||
// En caso de error se devuelve un mensaje.
|
||||
try {
|
||||
$error = $this->model->checkIntervals($sanitizedData, $id);
|
||||
if(empty($error)){
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
}
|
||||
else{
|
||||
$successfulResult = false;
|
||||
$this->viewData['errorMessage'] = $error;
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$maquinasDefectoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $maquinasDefectoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]).'.';
|
||||
$message .= anchor( "maquinasdefecto/{$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['maquinasDefectoEntity'] = $maquinasDefectoEntity;
|
||||
$this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasDefectoEntity->maquina_id ?? null);
|
||||
$this->viewData['tipoList'] = $this->getTipoOptions();
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateMaquinaPorDefecto', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('MaquinasPorDefecto.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;
|
||||
$requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder;
|
||||
$order = MaquinasDefectoModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$order2 = MaquinasDefectoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$dir2 = $reqData['order']['1']['dir'] ?? $dir;
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->orderBy($order2, $dir2)->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.', tipo', 'tipo', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->tipo = '- '.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 ?? 'tipo'];
|
||||
$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 getMaquinaListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
|
||||
if (!empty($selId)) :
|
||||
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
|
||||
|
||||
$selOption = $maquinaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getTipoOptions() {
|
||||
$tipoOptions = [
|
||||
'' => lang('Basic.global.pleaseSelect'),
|
||||
'bn' => 'bn',
|
||||
'bnhq' => 'bnhq',
|
||||
'color' => 'color',
|
||||
'portada' => 'portada',
|
||||
'cubierta' => 'cubierta',
|
||||
'rotativa' => 'rotativa',
|
||||
];
|
||||
return $tipoOptions;
|
||||
}
|
||||
|
||||
|
||||
//sanitiezdata
|
||||
//array(10) { ["tipo"]=> string(2) "bn" ["ancho_min"]=> string(3) "100" ["alto_min"]=> string(3) "180" ["tirada_min"]=> string(2) "31" ["maquina_id"]=> string(2) "80" ["ancho_max"]=> string(3) "477" ["alto_max"]=> string(3) "316" ["tirada_max"]=> string(5) "10000" ["save"]=> string(7) "Guardar" ["user_updated_id"]=> string(1) "1" }
|
||||
}
|
||||
@ -184,8 +184,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
|
||||
|
||||
if ($this->request->getPost('defecto') == null) {
|
||||
|
||||
@ -83,9 +83,8 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_update_id)) {
|
||||
$sanitizedData['user_created_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
@ -166,9 +165,8 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_update_id)) {
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
}
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
@ -136,8 +136,8 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
if(isset($this->model->user_updated_id)){
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
|
||||
@ -80,7 +80,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
if(isset($this->model->user_updated_id)){
|
||||
$sanitizedData['user_created_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
if(isset($this->model->user_updated_id)){
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
|
||||
36
ci4/app/Entities/Configuracion/MaquinasDefectoEntity.php
Normal file
36
ci4/app/Entities/Configuracion/MaquinasDefectoEntity.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class MaquinasDefectoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"tipo" => null,
|
||||
"ancho_min" => 0.0,
|
||||
"ancho_max" => 0.0,
|
||||
"alto_min" => 0.0,
|
||||
"alto_max" => 0.0,
|
||||
"tirada_min" => 1,
|
||||
"tirada_max" => 10000,
|
||||
"maquina_id" => null,
|
||||
"user_created_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"ancho_min" => "float",
|
||||
"ancho_max" => "float",
|
||||
"alto_min" => "float",
|
||||
"alto_max" => "float",
|
||||
"tirada_min" => "int",
|
||||
"tirada_max" => "int",
|
||||
"maquina_id" => "int",
|
||||
"user_created_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
@ -10,14 +10,14 @@ class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"user_created_id" => 0,
|
||||
"user_update_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"user_created_id" => "int",
|
||||
"user_update_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
|
||||
@ -11,14 +11,14 @@ class TarifaacabadoEntity extends \CodeIgniter\Entity\Entity
|
||||
"precio_min" => 0,
|
||||
"importe_fijo" => 0,
|
||||
"user_created_id" => 0,
|
||||
"user_update_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"user_created_id" => "int",
|
||||
"user_update_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity
|
||||
"nombre" => null,
|
||||
"precio" => null,
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"user_updated_id" => 1,
|
||||
"deleted_at" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
@ -19,6 +19,6 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $casts = [
|
||||
"precio" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_update_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
];
|
||||
}
|
||||
|
||||
84
ci4/app/Language/en/MaquinasPorDefecto.php
Normal file
84
ci4/app/Language/en/MaquinasPorDefecto.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'altoMax' => 'Max Height',
|
||||
'altoMin' => 'Min Height',
|
||||
'anchoMax' => 'Max Width',
|
||||
'anchoMin' => 'Min Width',
|
||||
'bn' => 'B/W',
|
||||
'bnhq' => 'B/W HQ',
|
||||
'color' => 'Color',
|
||||
'createdAt' => 'Created At',
|
||||
'cubierta' => 'Cover',
|
||||
'deletedAt' => 'Deleted At',
|
||||
'id' => 'ID',
|
||||
'isDeleted' => 'Is Deleted',
|
||||
'maquinaId' => 'Machine',
|
||||
'maquinaPorDefecto' => 'Default Machine',
|
||||
'maquinaPorDefectoList' => 'Default Machine List',
|
||||
'maquinadefecto' => 'Default Machine',
|
||||
'maquinasPorDefecto' => 'Default Machines',
|
||||
'maquinasdefecto' => 'Default Machines',
|
||||
'moduleTitle' => 'Default Machines',
|
||||
'portada' => 'Cover',
|
||||
'rotativa' => 'Rotary',
|
||||
'tipo' => 'Type',
|
||||
'tiradaMax' => 'Max Printing',
|
||||
'tiradaMin' => 'Min Printing',
|
||||
'updatedAt' => 'Updated At',
|
||||
'userCreatedId' => 'User Created ID',
|
||||
'userUpdatedId' => 'User Updated ID',
|
||||
'validation' => [
|
||||
'error_ancho_overlap' => 'The range [Min Width, Max Width] is overlapped with another one for the selected type.',
|
||||
'error_tirada_overlap' => 'The range [Min Printing, Max Printing] is overlapped with another one for the selected type.',
|
||||
'error_ancho_range' => 'The field Min Width must be lower than the field Max Width',
|
||||
'error_tirada_range' => 'The field Min Printing must be lower than the field Max Printing',
|
||||
'alto_max' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'alto_min' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'ancho_max' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'ancho_min' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tipo' => [
|
||||
'in_list' => 'The {field} field must be one of: {param}.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_max' => [
|
||||
'integer' => 'The {field} field must contain an integer.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_min' => [
|
||||
'integer' => 'The {field} field must contain an integer.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@ -69,7 +69,7 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'user_update_id' => [
|
||||
'user_updated_id' => [
|
||||
'integer' => 'The {field} field must contain an integer.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'user_update_id' => [
|
||||
'user_updated_id' => [
|
||||
'integer' => 'The {field} field must contain an integer.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'user_update_id' => [
|
||||
'user_updated_id' => [
|
||||
'integer' => 'The {field} field must contain an integer.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
|
||||
84
ci4/app/Language/es/MaquinasPorDefecto.php
Normal file
84
ci4/app/Language/es/MaquinasPorDefecto.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'altoMax' => 'Alto Max',
|
||||
'altoMin' => 'Alto Min',
|
||||
'anchoMax' => 'Ancho Max',
|
||||
'anchoMin' => 'Ancho Min',
|
||||
'bn' => 'B/N',
|
||||
'bnhq' => 'B/N HQ',
|
||||
'color' => 'Color',
|
||||
'createdAt' => 'Created At',
|
||||
'cubierta' => 'Cubierta',
|
||||
'deletedAt' => 'Deleted At',
|
||||
'id' => 'ID',
|
||||
'isDeleted' => 'Is Deleted',
|
||||
'maquinaId' => 'Máquina',
|
||||
'maquinaPorDefecto' => 'Máquina Por Defecto',
|
||||
'maquinaPorDefectoList' => 'Lista Máquinas Por Defecto',
|
||||
'maquinadefecto' => 'Máquinas Por Defecto',
|
||||
'maquinasPorDefecto' => 'Máquinas Por Defecto',
|
||||
'maquinasdefecto' => 'Máquinas Por Defecto',
|
||||
'moduleTitle' => 'Máquinas Por Defecto',
|
||||
'portada' => 'Portada',
|
||||
'rotativa' => 'Rotativa',
|
||||
'tipo' => 'Tipo',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
'tiradaMin' => 'Tirada Min',
|
||||
'updatedAt' => 'Updated At',
|
||||
'userCreatedId' => 'User Created ID',
|
||||
'userUpdatedId' => 'User Updated ID',
|
||||
'validation' => [
|
||||
'error_ancho_overlap' => 'El rango [Ancho Min, Ancho Max] se solapa con otro existente para el tipo seleccionado.',
|
||||
'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.',
|
||||
'error_ancho_range' => 'El campo Ancho Min debe ser menor que el campo Ancho Max',
|
||||
'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max',
|
||||
'alto_max' => [
|
||||
'decimal' => 'El campo {field} debe contener un número decimal.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'alto_min' => [
|
||||
'decimal' => 'El campo {field} debe contener un número decimal.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'ancho_max' => [
|
||||
'decimal' => 'El campo {field} debe contener un número decimal.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'ancho_min' => [
|
||||
'decimal' => 'El campo {field} debe contener un número decimal.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'tipo' => [
|
||||
'in_list' => 'El campo {field} debe ser uno de: {param}.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_max' => [
|
||||
'integer' => 'El campo {field} debe contener un número entero.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_min' => [
|
||||
'integer' => 'El campo {field} debe contener un número entero.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@ -60,7 +60,7 @@ return [
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'user_update_id' => [
|
||||
'user_updated_id' => [
|
||||
'integer' => 'El campo {field} debe contener un número entero.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'user_update_id' => [
|
||||
'user_updated_id' => [
|
||||
'integer' => 'El campo {field} debe contener un número entero.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'user_update_id' => [
|
||||
'user_updated_id' => [
|
||||
'integer' => 'El campo {field} debe contener un número entero.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
|
||||
247
ci4/app/Models/Configuracion/MaquinasDefectoModel.php
Normal file
247
ci4/app/Models/Configuracion/MaquinasDefectoModel.php
Normal file
@ -0,0 +1,247 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class MaquinasDefectoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_maquina_por_defecto";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.tipo",
|
||||
1 => "t2.nombre",
|
||||
2 => "t1.ancho_min",
|
||||
3 => "t1.ancho_max",
|
||||
4 => "t1.alto_min",
|
||||
5 => "t1.alto_max",
|
||||
6 => "t1.tirada_min",
|
||||
7 => "t1.tirada_max",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"tipo",
|
||||
"ancho_min",
|
||||
"ancho_max",
|
||||
"alto_min",
|
||||
"alto_max",
|
||||
"tirada_min",
|
||||
"tirada_max",
|
||||
"maquina_id",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_updated_id"
|
||||
];
|
||||
protected $returnType = "App\Entities\Configuracion\MaquinasDefectoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "tipo";
|
||||
|
||||
protected $validationRules = [
|
||||
"alto_max" => [
|
||||
"label" => "MaquinasPorDefecto.altoMax",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"alto_min" => [
|
||||
"label" => "MaquinasPorDefecto.altoMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"ancho_max" => [
|
||||
"label" => "MaquinasPorDefecto.anchoMax",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"ancho_min" => [
|
||||
"label" => "MaquinasPorDefecto.anchoMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"tipo" => [
|
||||
"label" => "MaquinasPorDefecto.tipo",
|
||||
"rules" => "required|in_list[bn,bnhq,color,portada,cubierta,rotativa]",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"label" => "MaquinasPorDefecto.tiradaMax",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"label" => "MaquinasPorDefecto.tiradaMin",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"maquina_id" => [
|
||||
"label" => "MaquinasPorDefecto.maquinaId",
|
||||
"rules" => "required",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alto_max" => [
|
||||
"decimal" => "MaquinasPorDefecto.validation.alto_max.decimal",
|
||||
"required" => "MaquinasPorDefecto.validation.alto_max.required",
|
||||
],
|
||||
"alto_min" => [
|
||||
"decimal" => "MaquinasPorDefecto.validation.alto_min.decimal",
|
||||
"required" => "MaquinasPorDefecto.validation.alto_min.required",
|
||||
],
|
||||
"ancho_max" => [
|
||||
"decimal" => "MaquinasPorDefecto.validation.ancho_max.decimal",
|
||||
"required" => "MaquinasPorDefecto.validation.ancho_max.required",
|
||||
],
|
||||
"ancho_min" => [
|
||||
"decimal" => "MaquinasPorDefecto.validation.ancho_min.decimal",
|
||||
"required" => "MaquinasPorDefecto.validation.ancho_min.required",
|
||||
],
|
||||
"tipo" => [
|
||||
"in_list" => "MaquinasPorDefecto.validation.tipo.in_list",
|
||||
"required" => "MaquinasPorDefecto.validation.tipo.required",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"integer" => "MaquinasPorDefecto.validation.tirada_max.integer",
|
||||
"required" => "MaquinasPorDefecto.validation.tirada_max.required",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"integer" => "MaquinasPorDefecto.validation.tirada_min.integer",
|
||||
"required" => "MaquinasPorDefecto.validation.tirada_min.required",
|
||||
],
|
||||
"maquina_id" => [
|
||||
"required" => "MaquinasPorDefecto.validation.tirada_min.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS maquina FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_maquinas t2 ON t1.maquina_id = t2.id";
|
||||
if (!is_null($limit) && floatval($limit) > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
if (!is_null($offset) && floatval($offset) > 0) {
|
||||
$sql .= " OFFSET " . $offset;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tipo AS tipo, t1.ancho_min AS ancho_min, t1.ancho_max AS ancho_max, t1.alto_min AS alto_min, t1.alto_max AS alto_max, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t2.nombre AS maquina"
|
||||
);
|
||||
$builder->where('t1.is_deleted', 0);
|
||||
$builder->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.ancho_min", $search)
|
||||
->orLike("t1.ancho_max", $search)
|
||||
->orLike("t1.alto_min", $search)
|
||||
->orLike("t1.alto_max", $search)
|
||||
->orLike("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.ancho_min", $search)
|
||||
->orLike("t1.ancho_max", $search)
|
||||
->orLike("t1.alto_min", $search)
|
||||
->orLike("t1.alto_max", $search)
|
||||
->orLike("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t1.maquina_id", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function checkIntervals($data = [], $id = null){
|
||||
|
||||
if(floatval($data["ancho_min"])>= floatval($data["ancho_max"])){
|
||||
return lang('MaquinasPorDefecto.validation.error_ancho_range');
|
||||
}
|
||||
|
||||
if(floatval($data["tirada_min"])>= floatval($data["tirada_max"])){
|
||||
return lang('MaquinasPorDefecto.validation.error_tirada_range');
|
||||
}
|
||||
|
||||
$anchos = $this->db
|
||||
->table($this->table)
|
||||
->select("id, ancho_min, ancho_max")
|
||||
->where("is_deleted", 0)
|
||||
->where("tipo", $data["tipo"])
|
||||
->get()->getResultObject();
|
||||
|
||||
|
||||
foreach ($anchos as $row) {
|
||||
if (!is_null($id)){
|
||||
if($row->id == $id){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if($this->check_overlap(floatval($data["ancho_min"]), floatval($data["ancho_max"]),
|
||||
$row->ancho_min, $row->ancho_max)){
|
||||
return lang('MaquinasPorDefecto.validation.error_ancho_overlap');
|
||||
}
|
||||
}
|
||||
|
||||
$tiradas = $this->db
|
||||
->table($this->table)
|
||||
->select("id, tirada_min, tirada_max")
|
||||
->where("is_deleted", 0)
|
||||
->where("tipo", $data["tipo"])
|
||||
->get()->getResultObject();
|
||||
|
||||
foreach ($tiradas as $row) {
|
||||
if (!is_null($id)){
|
||||
if($row->id == $id){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if($this->check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]),
|
||||
$row->tirada_min, $row->tirada_max)){
|
||||
return lang('MaquinasPorDefecto.validation.error_ancho_overlap');
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// Devuelve true si los intervalos (a1,a2) (b1,b2) se solapan
|
||||
// https://stackoverflow.com/questions/3269434/whats-the-most-efficient-way-to-test-if-two-ranges-overlap
|
||||
private function check_overlap($a1, $a2, $b1, $b2){
|
||||
|
||||
if (max($a2, $b2) - min($a1, $b1) < ($a2 - $a1) + ($b2 - $b1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ class PapelImpresionModel extends \App\Models\GoBaseModel
|
||||
"isActivo",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_update_id",
|
||||
"user_updated_id",
|
||||
];
|
||||
protected $returnType = "App\Entities\Configuracion\PapelImpresion";
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
"user_updated_id",
|
||||
];
|
||||
protected $returnType = 'App\Entities\Tarifas\TarifaacabadoEntity';
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id"];
|
||||
"user_updated_id"];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifapreimpresionEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="tipo" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.tipo') ?>*
|
||||
</label>
|
||||
<select tabindex="1" id="tipo" name="tipo" class="form-control select2bs" style="width: 100%;" >
|
||||
<option value="" selected="selected"><?=lang('Basic.global.pleaseSelectOne') ?></option>
|
||||
<option value="bn"<?=$maquinasDefectoEntity->tipo == 'bn' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.bn') ?></option>
|
||||
<option value="bnhq"<?=$maquinasDefectoEntity->tipo == 'bnhq' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.bnhq') ?></option>
|
||||
<option value="color"<?=$maquinasDefectoEntity->tipo == 'color' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.color') ?></option>
|
||||
<option value="portada"<?=$maquinasDefectoEntity->tipo == 'portada' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.portada') ?></option>
|
||||
<option value="cubierta"<?=$maquinasDefectoEntity->tipo == 'cubierta' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.cubierta') ?></option>
|
||||
<option value="rotativa"<?=$maquinasDefectoEntity->tipo == 'rotativa' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.rotativa') ?></option>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="anchoMin" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.anchoMin') ?>*
|
||||
</label>
|
||||
<input tabindex="3" type="number" id="anchoMin" name="ancho_min" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_min', $maquinasDefectoEntity->ancho_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="altoMin" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.altoMin') ?>*
|
||||
</label>
|
||||
<input tabindex="5" type="number" id="altoMin" name="alto_min" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_min', $maquinasDefectoEntity->alto_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMin" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.tiradaMin') ?>*
|
||||
</label>
|
||||
<input tabindex="7" type="number" id="tiradaMin" name="tirada_min" placeholder="1" maxLength="11" class="form-control" value="<?=old('tirada_min', $maquinasDefectoEntity->tirada_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="maquinaId" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.maquinaId') ?>*
|
||||
</label>
|
||||
<select tabindex="2" id="maquinaId" name="maquina_id" class="form-control select2 form-select" style="width: 100%;" >
|
||||
|
||||
<?php if ( isset($maquinaList) && is_array($maquinaList) && !empty($maquinaList) ) :
|
||||
foreach ($maquinaList as $k => $v) : ?>
|
||||
<option value="<?=$k ?>"<?=$k==$maquinasDefectoEntity->maquina_id ? ' selected':'' ?>>
|
||||
<?=$v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="anchoMax" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.anchoMax') ?>*
|
||||
</label>
|
||||
<input tabindex="4" type="number" id="anchoMax" name="ancho_max" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_max', $maquinasDefectoEntity->ancho_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="altoMax" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.altoMax') ?>*
|
||||
</label>
|
||||
<input tabindex="6" type="number" id="altoMax" name="alto_max" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_max', $maquinasDefectoEntity->alto_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMax" class="form-label">
|
||||
<?=lang('MaquinasPorDefecto.tiradaMax') ?>*
|
||||
</label>
|
||||
<input tabindex="8" type="number" id="tiradaMax" name="tirada_max" placeholder="10000" maxLength="11" class="form-control" value="<?=old('tirada_max', $maquinasDefectoEntity->tirada_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -287,9 +287,6 @@
|
||||
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
|
||||
setTimeout(() => {
|
||||
console.log("1 Segundo esperado")
|
||||
}, 1000);
|
||||
$.ajax({
|
||||
url: '<?= route_to('updateMaquinaPapelOnTarifasChange') ?>',
|
||||
data: {
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
<?= $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="maquinaPorDefectoForm" 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/configuracion/maquinas/_maquinaPorDefectoFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="pt-4">
|
||||
<input
|
||||
type="submit"
|
||||
class="btn btn-primary float-start me-sm-3 me-1"
|
||||
name="save"
|
||||
value="<?= lang("Basic.global.Save") ?>"
|
||||
/>
|
||||
<?= anchor(route_to("maquinaPorDefectoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary"]) ?>
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
|
||||
$('#maquinaId').select2({
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
url: '<?= route_to("menuItemsOfMaquinas") ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
|
||||
data: function (params) {
|
||||
return {
|
||||
id: 'id',
|
||||
text: 'nombre',
|
||||
searchTerm: params.term,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
};
|
||||
},
|
||||
delay: 60,
|
||||
processResults: function (response) {
|
||||
|
||||
yeniden(response.<?= csrf_token() ?>);
|
||||
|
||||
return {
|
||||
results: response.menu
|
||||
};
|
||||
},
|
||||
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,185 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?=$this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?=lang('MaquinasPorDefecto.maquinaPorDefectoList') ?></h3>
|
||||
<?=anchor(route_to('newMaquinaPorDefecto'), lang('Basic.global.addNew').' '.lang('MaquinasPorDefecto.maquinaPorDefecto'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfMaquinaspordefecto" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('MaquinasPorDefecto.tipo') ?></th>
|
||||
<th><?= lang('Maquinas.maquina') ?></th>
|
||||
<th><?= lang('MaquinasPorDefecto.anchoMin') ?></th>
|
||||
<th><?= lang('MaquinasPorDefecto.anchoMax') ?></th>
|
||||
<th><?= lang('MaquinasPorDefecto.altoMin') ?></th>
|
||||
<th><?= lang('MaquinasPorDefecto.altoMax') ?></th>
|
||||
<th><?= lang('MaquinasPorDefecto.tiradaMin') ?></th>
|
||||
<th><?= lang('MaquinasPorDefecto.tiradaMax') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfMaquinaspordefecto').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 = $('#tableOfMaquinaspordefecto').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
"dom": 'lfBrtip',
|
||||
"buttons": [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
stateSave: true,
|
||||
order: [[1, 'asc']],
|
||||
language: {
|
||||
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
},
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfMaquinasPorDefecto') ?>',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
}
|
||||
],
|
||||
columns : [
|
||||
{ 'data': 'tipo', "render": function ( data, type, row, meta ) {
|
||||
if(data=='bn')
|
||||
return '<?= lang('MaquinasPorDefecto.bn') ?>';
|
||||
else if(data=='bnhq')
|
||||
return '<?= lang('MaquinasPorDefecto.bnhq') ?>';
|
||||
else if(data=='color')
|
||||
return '<?= lang('MaquinasPorDefecto.color') ?>';
|
||||
else if(data=='cubierta')
|
||||
return '<?= lang('MaquinasPorDefecto.cubierta') ?>';
|
||||
else if(data=='portada')
|
||||
return '<?= lang('MaquinasPorDefecto.portada') ?>';
|
||||
else if(data=='rotativa')
|
||||
return '<?= lang('MaquinasPorDefecto.rotativa') ?>';
|
||||
}
|
||||
},
|
||||
{ 'data': 'maquina' },
|
||||
{ 'data': 'ancho_min' },
|
||||
{ 'data': 'ancho_max' },
|
||||
{ 'data': 'alto_min' },
|
||||
{ 'data': 'alto_max' },
|
||||
{ 'data': 'tirada_min' },
|
||||
{ 'data': 'tirada_max' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `configuracion/maquinasdefecto/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('MaquinasPorDefecto.maquinadefecto'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
//url: `<?= route_to('maquinaPorDefectoList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/configuracion/maquinasdefecto/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.bootstrap5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.0/jszip.min.js" integrity="sha512-xcHCGC5tQ0SHlRX8Anbz6oy/OullASJkEhb4gjkneVpGE3/QGYejf14CUO5n5q5paiHfRFTa9HKgByxzidw2Bw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/pdfmake.min.js" integrity="sha512-rDbVu5s98lzXZsmJoMa0DjHNE+RwPJACogUCLyq3Xxm2kJO6qsQwjbE5NDk2DqmlKcxDirCnU1wAzVLe12IM3w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/vfs_fonts.js" integrity="sha512-cktKDgjEiIkPVHYbn8bh/FEyYxmt4JDJJjOCu5/FQAkW4bc911XtKYValiyzBiJigjVEvrIAyQFEbRJZyDA1wQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
<label for="userUpdateId" class="form-label">
|
||||
<?=lang('Tarifapreimpresion.userUpdateId') ?>*
|
||||
</label>
|
||||
<input type="number" id="userUpdateId" name="user_update_id" required placeholder="1" maxLength="10" class="form-control" value="<?=old('user_update_id', $tarifapreimpresionEntity->user_update_id) ?>">
|
||||
<input type="number" id="userUpdateId" name="user_updated_id" required placeholder="1" maxLength="10" class="form-control" value="<?=old('user_updated_id', $tarifapreimpresionEntity->user_updated_id) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
*/ ?>
|
||||
</div><!--//.col -->
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
<?= esc($item->user_created_id) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_update_id) ?>
|
||||
<?= esc($item->user_updated_id) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
|
||||
|
||||
@ -51,8 +51,8 @@ Pasos para añadir el soft delete a una tabla
|
||||
debajo de $sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
if(isset($this->model->user_updated_id)){
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
5b.- Con lazy-tables:
|
||||
|
||||
Reference in New Issue
Block a user