papel impresion terminado a falta de añadir maquinas y revisar UI

This commit is contained in:
Jaime Jimenez
2023-06-12 08:21:57 +02:00
parent 3932da5b84
commit 4ca43ad7ef
79 changed files with 25638 additions and 126 deletions

View File

@ -146,3 +146,4 @@ themef.path = 'themes/frontend/tivo/'
api.return = 'json'
demo.mode = false
purchase.code = '1234'

View File

@ -44,6 +44,7 @@ $routes->post('api/user/', 'Api::user/add');
$routes->put('api/user/(:segment)', 'Api::user/edit/$1');
$routes->delete('api/user/(:segment)', 'Api::user/delete/$1');
/*
* --------------------------------------------------------------------
* Route Definitions
@ -174,12 +175,23 @@ $routes->group('papelesimpresion', ['namespace' => 'App\Controllers\Configuracio
$routes->put('(:num)/update', 'Papelesimpresion::update/$1', ['as' => 'ajaxUpdatePapelImpresion']);
$routes->post('edit/(:num)', 'Papelesimpresion::edit/$1', ['as' => 'updatePapelImpresion']);
$routes->post('datatable', 'Papelesimpresion::datatable', ['as' => 'dataTableOfPapelesImpresion']);
$routes->post('datatablePG', 'Papelesimpresion::datatablePG', ['as' => 'dataTableOfPapelesImpresionPG']);
$routes->post('datatable_editor', 'Papelesimpresion::datatable_editor', ['as' => 'dataTableEditor']);
$routes->post('fetch_single_data', 'Papelesimpresion::fetch_single_data', ['as' => 'fetchTipologia']);
$routes->post('allmenuitems', 'Papelesimpresion::allItemsSelect', ['as' => 'select2ItemsOfPapelesImpresion']);
$routes->post('menuitems', 'Papelesimpresion::menuItems', ['as' => 'menuItemsOfPapelesImpresion']);
});
$routes->resource('papelesimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesimpresion', 'except' => 'show,new,create,update']);
$routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('add', 'Papelimpresiontipologias::add', ['as' => 'newPapelImpresionTipologia']);
$routes->post('add', 'Papelimpresiontipologias::add', ['as' => 'createPapelImpresionTipologia']);
$routes->get('edit/(:num)', 'Papelimpresiontipologias::edit/$1', ['as' => 'editPapelImpresionTipologia']);
$routes->post('edit/(:num)', 'Papelimpresiontipologias::edit/$1', ['as' => 'updatePapelImpresionTipologia']);
$routes->get('delete/(:num)', 'Papelimpresiontipologias::delete/$1', ['as' => 'deletePapelImpresionTipologia']);
});
$routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) {
$routes->get('', 'Profile::index', ['as' => 'profileList']);
$routes->get('index', 'Profile::index', ['as' => 'profileIndex']);

View File

@ -5,14 +5,35 @@ namespace App\Controllers\Configuracion;
use App\Controllers\GoBaseResourceController;
// DataTables PHP library
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Database,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
use App\Models\Collection;
use App\Entities\Configuracion\PapelImpresion;
use App\Models\Configuracion\PapelImpresionModel;
use App\Models\Configuracion\PapelGenericoModel;
use App\Models\Configuracion\PapelImpresionTipologiaModel;
class Papelesimpresion extends \App\Controllers\GoBaseResourceController
{
@ -30,8 +51,6 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
protected $indexRoute = 'papelImpresionList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('PapelImpresion.moduleTitle');
@ -42,6 +61,8 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
// Se indica el flag para los ficheros borrados
$this->delete_flag = 1;
$this->tpModel = new PapelImpresionTipologiaModel();
parent::initController($request, $response, $logger);
}
@ -230,6 +251,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelImpresion.moduleTitle') . ' ' . lang('Basic.global.edit3');
$this->viewData['usingServerSideDataTable'] = true; //JJO
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
@ -239,72 +261,118 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
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;
}
$id_PG = $reqData['id_PG'] ?? -1;
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = PapelImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
if($id_PG<0){
if(isset($reqData['id_PI'])){
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$id_PI = $reqData['id_PI'] ?? -1;
if($id_PI>=0){
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource()->countAllResults(),
$this->model->getResource($search)->countAllResults()
));
}else{
$resourceData = $this->model->getResource($search, $id_PG)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$data = $this->tpModel->findTipologiasForPapelImpresion($id_PI);
$resourceData = $data->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource("", $id_PG)->countAllResults(),
$this->model->getResource($search, $id_PG)->countAllResults()
));
return $this->respond(Collection::datatable(
$resourceData,
$this->tpModel->findTipologiasForPapelImpresion($id_PI)->countAllResults(),
$this->tpModel->findTipologiasForPapelImpresion($id_PI)->countAllResults()
));
}
}
else{
$id_PG = $reqData['id_PG'] ?? -1;
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = PapelImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
if($id_PG<0){
$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{
$resourceData = $this->model->getResource($search, $id_PG)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource("", $id_PG)->countAllResults(),
$this->model->getResource($search, $id_PG)->countAllResults()
));
}
}
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatablePG()
{
public function datatable_editor(){
/*if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$rows_id = array_keys($reqData['data']);
echo '<pre>' ;
var_dump($reqData['data'][$keys[0]]) ;
echo '</pre>';
}*/
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;
}
$generico_id = $reqData['id'] ?? null;
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = PapelImpresionModel::SORTABLE2[$requestedOrder >= 0 ? $requestedOrder : 1];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$resourceData = $this->model->getResource($search, $generico_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$sql_details = array(
"type" => "Mysql", // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
"user" => "sk_jjo", // Database user name
"pass" => "61tv&G1Zf^XY", // Database password
"host" => "localhost", // Database host
"port" => "", // Database connection port (can be left empty for default)
"db" => "sk_jjo", // Database name
"dsn" => "", // PHP DSN extra information. Set as `charset=utf8mb4` if you are using MySQL
"pdoAttr" => array() // PHP PDO attributes array. See the PHP documentation for all options
);
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource("", $generico_id)->countAllResults(),
$this->model->getResource($search, $generico_id)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
$db = new Database( array(
"type" => "Mysql",
"pdo" => $sql_details
) );
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'lg_papel_impresion_tipologias' )
->fields(
Field::inst( 'tipo' ),
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),//->validator( Validate::values( array('negro', 'color', 'bicolor') ) ),
Field::inst( 'negro' ),
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
Field::inst( 'cyan' ),
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
Field::inst( 'magenta' ),
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
Field::inst( 'amarillo' ),
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
Field::inst( 'gota_negro' ),
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
Field::inst( 'got_color' ),
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
)
->process( $_POST )
->json();
}
}
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
@ -355,6 +423,24 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
}
}
function fetch_single_data()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if(isset($reqData['id']))
{
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'data' => $this->tpModel->getResource($reqData['id'])->get()->getResultObject()[0],
$csrfTokenName => $newTokenHash
];
echo json_encode($data);
}
}
}
protected function getPapelGenericoListItems($selId = null)
{

View File

@ -0,0 +1,326 @@
<?php namespace App\Controllers\Configuracion;
use App\Controllers\GoBaseResourceController;
use App\Models\Collection;
use App\Entities\Configuracion\PapelImpresionTipologia;
use App\Models\Configuracion\PapelImpresionTipologiaModel;
use App\Models\Configuracion\PapelImpresionModel;
class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController {
protected $modelName = PapelImpresionTipologiaModel::class;
protected $format = 'json';
protected static $singularObjectName = 'Papel Impresion Tipologia';
protected static $singularObjectNameCc = 'papelImpresionTipologia';
protected static $pluralObjectName = 'Papel Impresion Tipologias';
protected static $pluralObjectNameCc = 'papelImpresionTipologias';
protected static $controllerSlug = 'papelimpresiontipologias';
protected static $viewPath = 'themes/backend/vuexy/form/configuracion/papel/';
protected $indexRoute = 'papelImpresionTipologiaList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
$this->viewData['pageTitle'] = lang('ImpresionTipologias.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
$viewData = [
'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ImpresionTipologias.papelImpresionTipologia')]),
'papelImpresionTipologia' => new PapelImpresionTipologia(),
'usingServerSideDataTable' => true,
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
//return view(static::$viewPath.'viewPapelImpresionTipologiaList', $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;
$successfulResult = false; // for now
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('ImpresionTipologias.papelImpresionTipologia'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$thenRedirect = false; // Change this to false if you want your user to stay on the form after submission
if ($noException && $successfulResult) :
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.';
$message .= anchor( "papelimpresiontipologias/{$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);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$output = array(
'success' => 'yes',
$csrfTokenName => $newTokenHash
);
return json_encode($output);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['papelImpresionTipologia'] = isset($sanitizedData) ? new PapelImpresionTipologia($sanitizedData) : new PapelImpresionTipologia();
$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($papelImpresionTipologia->papel_impresion_id ?? null);
$this->viewData['tipoList'] = $this->getTipoOptions();
$this->viewData['formAction'] = route_to('createPapelImpresionTipologia');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ImpresionTipologias.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$output = array(
'success' => 'no',
$csrfTokenName => $newTokenHash
);
return json_encode($output);
//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);
$papelImpresionTipologia = $this->model->find($id);
if ($papelImpresionTipologia == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia')), $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;
$successfulResult = false; // for now
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('ImpresionTipologias.papelImpresionTipologia'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$papelImpresionTipologia->fill($sanitizedData);
$thenRedirect = false;
if ($noException && $successfulResult) :
$id = $papelImpresionTipologia->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.';
$message .= anchor( "papelimpresiontipologias/{$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:
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$output = array(
'success' => 'yes',
$csrfTokenName => $newTokenHash
);
return json_encode($output);
//$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['papelImpresionTipologia'] = $papelImpresionTipologia;
$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($papelImpresionTipologia->papel_impresion_id ?? null);
$this->viewData['tipoList'] = $this->getTipoOptions();
$this->viewData['formAction'] = route_to('updatePapelImpresionTipologia', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ImpresionTipologias.moduleTitle').' '.lang('Basic.global.edit3');
//return $this->displayForm(__METHOD__, $id);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$output = array(
'success' => 'no',
$csrfTokenName => $newTokenHash
);
return json_encode($output);
} // 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 = PapelImpresionTipologiaModel::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.', papel_impresion_id', 'papel_impresion_id', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->papel_impresion_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 ?? 'papel_impresion_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 getPapelImpresionListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('PapelImpresions.papelImpresion'))])];
if (!empty($selId)) :
$papelImpresionModel = model('App\Models\Configuracion\PapelImpresionModel');
$selOption = $papelImpresionModel->where('id', $selId)->findColumn('id');
if (!empty($selOption)) :
$data[$selId] = $selOption[0];
endif;
endif;
return $data;
}
protected function getTipoOptions() {
$tipoOptions = [
'' => lang('Basic.global.pleaseSelect'),
'negro' => 'negro',
'color' => 'color',
'bicolor' => 'bicolor',
];
return $tipoOptions;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Entities\Configuracion;
use CodeIgniter\Entity;
class PapelImpresionTipologia extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
"id" => null,
"papel_impresion_id" => null,
"tipo" => null,
"negro" => 0.0,
"cyan" => 0.0,
"magenta" => 0.0,
"amarillo" => 0.0,
"gota_negro" => 0.0,
"gota_color" => 0.0,
];
protected $casts = [
"papel_impresion_id" => "int",
"negro" => "float",
"cyan" => "float",
"magenta" => "float",
"amarillo" => "float",
"gota_negro" => "float",
"gota_color" => "float",
];
}

View File

@ -177,7 +177,9 @@ class LoginAuthFilter implements FilterInterface
'allItemsSelect',
'menuItems',
'datatable',
'datatablePG',
'datatable_editor',
'fetch_single_data',
'datatableTintas',
'collect',
'cast',
];

View File

@ -79,10 +79,10 @@ return [
'sureToDeleteTitle' => 'Are you sure you want to delete this {0}?',
'text' => 'This action cannot be undone.',
'title' => 'Are you sure?',
'maxRowsReached' => 'No more lines can be added.'
],
'ok' => 'Ok',
'wait' => 'Wait',
],

View File

@ -0,0 +1,63 @@
<?php
return [
'amarillo' => 'Yellow',
'bicolor' => 'Bicolor',
'color' => 'Color',
'cyan' => 'Cyan',
'gotaColor' => 'Color Drop',
'gotaNegro' => 'Black Drop',
'magenta' => 'Magenta',
'negro' => 'Black',
'tipo' => 'Type',
'errorTipo' => 'Typology type already exists',
'validation' => [
'amarillo' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
],
'cyan' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
],
'gota_color' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
],
'gota_negro' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
],
'magenta' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
],
'negro' => [
'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.',
],
],
];

View File

@ -18,8 +18,6 @@ return [
'showInClient' => 'Show in Client',
'updatedAt' => 'Updated At',
'Form_acordion_title' => 'Print papers associated',
'validation' => [
'code' => [
'max_length' => 'The {field} field cannot exceed {param} characters in length.',

View File

@ -32,6 +32,9 @@ return [
'rotativa' => 'Rotary',
'updatedAt' => 'Updated At',
'userUpdateId' => 'User Update ID',
'consumo_tintas_rotativas' => 'Rotary ink consumption',
'validation' => [
'espesor_update' => [
'max_length' => 'The {field} field cannot exceed {param} characters in length.',

View File

@ -79,9 +79,11 @@ return [
'sureToDeleteTitle' => 'Está seguro de borrar {0}?',
'text' => 'Esta acción no se puede deshacer.',
'title' => 'Está seguro?',
'maxRowsReached' => 'No se pueden añadir más líneas.'
],
'ok' => 'Ok',
'wait' => 'Espere',
],

View File

@ -0,0 +1,64 @@
<?php
return [
'amarillo' => 'Amarillo',
'bicolor' => 'Bicolor',
'color' => 'Color',
'cyan' => 'Cyan',
'gotaColor' => 'Gota Color',
'gotaNegro' => 'Gota Negro',
'magenta' => 'Magenta',
'moduleTitle' => 'Papel Impresion Tipologias',
'negro' => 'Negro',
'tipo' => 'Tipo',
'errorTipo' => 'El tipo de tipología ya existe',
'validation' => [
'amarillo' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
'cyan' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
'gota_color' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
'gota_negro' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
'magenta' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
'negro' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
'tipo' => [
'in_list' => 'El campo {field} debe ser uno de: {param}.',
'required' => 'El campo {field} es obligatorio.',
],
],
];

View File

@ -18,8 +18,6 @@ return [
'showInClient' => 'Mostrar en cliente',
'updatedAt' => 'Updated At',
'Form_acordion_title' => 'Papeles impresion asociados',
'validation' => [
'code' => [
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',

View File

@ -32,6 +32,9 @@ return [
'rotativa' => 'Rotativa',
'updatedAt' => 'Actualizado en',
'userUpdateId' => 'ID usuario actualización',
'consumo_tintas_rotativas' => 'Consumo tintas rotativas',
'validation' => [
'espesor_update' => [
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',

View File

@ -0,0 +1,134 @@
<?php
namespace App\Models\Configuracion;
class PapelImpresionTipologiaModel extends \App\Models\GoBaseModel
{
protected $table = "lg_papel_impresion_tipologias";
/**
* Whether primary key uses auto increment.
*
* @var bool
*/
protected $useAutoIncrement = true;
protected $allowedFields = [
"papel_impresion_id",
"tipo",
"negro",
"cyan",
"magenta",
"amarillo",
"gota_negro",
"gota_color",
];
protected $returnType = "App\Entities\Configuracion\PapelImpresionTipologia";
public static $labelField = "tipo";
protected $validationRules = [
"amarillo" => [
"label" => "ImpresionTipologias.amarillo",
"rules" => "required|decimal",
],
"cyan" => [
"label" => "ImpresionTipologias.cyan",
"rules" => "required|decimal",
],
"gota_color" => [
"label" => "ImpresionTipologias.gotaColor",
"rules" => "required|decimal",
],
"gota_negro" => [
"label" => "ImpresionTipologias.gotaNegro",
"rules" => "required|decimal",
],
"magenta" => [
"label" => "ImpresionTipologias.magenta",
"rules" => "required|decimal",
],
"negro" => [
"label" => "ImpresionTipologias.negro",
"rules" => "required|decimal",
],
"tipo" => [
"label" => "ImpresionTipologias.tipo",
"rules" => "required|in_list[negro,color,bicolor]",
],
];
protected $validationMessages = [
"amarillo" => [
"decimal" => "ImpresionTipologias.validation.amarillo.decimal",
"required" => "ImpresionTipologias.validation.amarillo.required",
],
"cyan" => [
"decimal" => "ImpresionTipologias.validation.cyan.decimal",
"required" => "ImpresionTipologias.validation.cyan.required",
],
"gota_color" => [
"decimal" => "ImpresionTipologias.validation.gota_color.decimal",
"required" => "ImpresionTipologias.validation.gota_color.required",
],
"gota_negro" => [
"decimal" => "ImpresionTipologias.validation.gota_negro.decimal",
"required" => "ImpresionTipologias.validation.gota_negro.required",
],
"magenta" => [
"decimal" => "ImpresionTipologias.validation.magenta.decimal",
"required" => "ImpresionTipologias.validation.magenta.required",
],
"negro" => [
"decimal" => "ImpresionTipologias.validation.negro.decimal",
"required" => "ImpresionTipologias.validation.negro.required",
],
"tipo" => [
"in_list" => "ImpresionTipologias.validation.tipo.in_list",
"required" => "ImpresionTipologias.validation.tipo.required",
],
];
public function findAllWithPapelImpresion(string $selcols = "*", int $limit = null, int $offset = 0)
{
$sql =
"SELECT t1." .
$selcols .
", t2.nombre AS papel_impresion_id FROM " .
$this->table .
" t1 LEFT JOIN lg_papel_impresion t2 ON t1.papel_impresion_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;
}
public function findTipologiasForPapelImpresion(int $papelImpresionID){
$builder = $this->db
->table($this->table )
->select("*")
->where("papel_impresion_id", $papelImpresionID);
return $builder;
}
public function getResource($id)
{
$builder = $this->db
->table($this->table)
->select("*")
->where("id", $id);
return $builder;
}
}

View File

@ -1,3 +1,4 @@
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
@ -16,23 +17,468 @@
<?= view("themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems") ?>
</div><!-- /.card-body -->
<div class="card-footer">
<?= anchor(route_to("papelImpresionList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("papelImpresionList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary"]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
<?php if(str_contains($formAction,'edit')): ?>
<?php if($papelImpresion->rotativa == true): ?>
<div class="accordion mt-3" id="accordionTipologias">
<?php else: ?>
<div class="accordion mt-3" id="accordionTipologias" style="display:none">
<?php endif; ?>
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
<p><?= lang("PapelImpresion.consumo_tintas_rotativas") ?></p>
</button>
<p class="btn btn-primary float-end me-sm-3 me-1" id="newTipologia"> <?= lang('Basic.global.addNew') ?> </p>
</h2>
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionTipologias">
<div class="accordion-body">
<table id="tableOfPapelimpresiontipologias" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ImpresionTipologias.tipo') ?></th>
<th><?= lang('ImpresionTipologias.negro') ?></th>
<th><?= lang('ImpresionTipologias.cyan') ?></th>
<th><?= lang('ImpresionTipologias.magenta') ?></th>
<th><?= lang('ImpresionTipologias.amarillo') ?></th>
<th><?= lang('ImpresionTipologias.gotaNegro') ?></th>
<th><?= lang('ImpresionTipologias.gotaColor') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?php endif; ?>
<div class="accordion mt-3" id="accordionMaquinas">
<div class="card accordion-item">
<h2 class="accordion-header" id="headingTwo">
<button
type="button"
class="accordion-button collapsed"
data-bs-toggle="collapse"
data-bs-target="#accordionMaq"
aria-expanded="false"
aria-controls="accordionMaq"
>
MAAAAQUIIIINAAAAAS<!--- lang("PapelImpresion.consumo_tintas_rotativas") ?> AÑADIR LANGUAJE MAQUINAS-->
</button>
</h2>
<div
id="accordionMaq"
class="accordion-collapse collapse"
aria-labelledby="headingTwo"
data-bs-parent="#accordionMaquinas"
>
<div class="accordion-body">
<table id="tableOfMaquinas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ImpresionTipologias.tipo') ?></th>
<th><?= lang('ImpresionTipologias.negro') ?></th>
<th><?= lang('ImpresionTipologias.cyan') ?></th>
<th><?= lang('ImpresionTipologias.magenta') ?></th>
<th><?= lang('ImpresionTipologias.amarillo') ?></th>
<th><?= lang('ImpresionTipologias.gotaNegro') ?></th>
<th><?= lang('ImpresionTipologias.gotaColor') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div><!--//.col -->
</div><!--//.row -->
<div id="tipologiaModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="tipologia_form">
<div class="modal-content">
<?= csrf_field() ?>
<div class="modal-header">
<h4 class="modal-title"><?= lang('Basic.edit') ?></h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="tipo" class="form-label">
<?=lang('ImpresionTipologias.tipo') ?>
</label>
<select id="tipologiaTipo" name="tipologia_tipo" required class="form-control select2bs2" style="width: 100%;" >
<option value=negro><?=lang('ImpresionTipologias.negro') ?></option>
<option value=color><?=lang('ImpresionTipologias.color') ?></option>
<option value=bicolor><?=lang('ImpresionTipologias.bicolor') ?></option>
</select><!--//.form-check -->
</div>
<div class="form-group">
<label for="negro" class="form-label">
<?=lang('ImpresionTipologias.negro') ?>
</label>
<input type="number" id="negro" name="negro" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="0.00">
</div>
<div class="form-group">
<label for="cyan" class="form-label">
<?=lang('ImpresionTipologias.cyan') ?>
</label>
<input type="number" id="cyan" name="cyan" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="0.00">
</div>
<div class="form-group">
<label for="magenta" class="form-label">
<?=lang('ImpresionTipologias.magenta') ?>
</label>
<input type="number" id="magenta" name="magenta" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="0.00">
</div>
<div class="form-group">
<label for="amarillo" class="form-label">
<?=lang('ImpresionTipologias.amarillo') ?>
</label>
<input type="number" id="amarillo" name="amarillo" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="0.00">
</div>
<div class="form-group">
<label for="gotaNegro" class="form-label">
<?=lang('ImpresionTipologias.gotaNegro') ?>
</label>
<input type="number" id="gotaNegro" name="gota_negro" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="0.00">
</div>
<div class="form-group">
<label for="gotaColor" class="form-label">
<?=lang('ImpresionTipologias.gotaColor') ?>
</label>
<input type="number" id="gotaColor" name="gota_color" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="0.00">
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="hidden_id" id="hidden_id" />
<input type="hidden" name="action" id="action" value="add" />
<input type="submit" name="submit" id="submit_button" class="btn btn-primary float-start me-sm-3 me-1" value="Add" />
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> <?= lang("Basic.global.Cancel") ?> </button>
</div>
</div>
</form>
</div>
</div>
<?= $this->endSection() ?>
<?= $this->section("additionalInlineJs") ?>
var theTable;
const url = window.location.href;
const url_parts = url.split('/');
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
else{
id = -1;
}
const lastColNr = $('#tableOfPapelimpresiontipologias').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<div class="action-buttons">
<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>`;
};
theTable = $('#tableOfPapelimpresiontipologias').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5],
pageLength: 5,
lengthChange: false,
searching: false,
//paging: false,
info: false,
"dom": 'lrt',
stateSave: true,
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPapelesImpresion') ?>',
data: {
id_PI: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns : [
{ 'data': 'tipo' },
{ 'data': 'negro' },
{ 'data': 'cyan' },
{ 'data': 'magenta' },
{ 'data': 'amarillo' },
{ 'data': 'gota_negro' },
{ 'data': 'gota_color' },
{ data: actionBtns}
]
});
// Add new tipología
$('#newTipologia').on("click", function(e) {
if ($('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3){
Swal.fire({
title: '<?= lang('Basic.global.sweet.maxRowsReached') ?>',
icon: 'info',
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.Close') ?>',
});
}
else{
$('#tipologiaTipo').attr('disabled', false);
$('#tipologiaTipo').val("");
$('#negro').val("0.00");
$('#cyan').val("0.00");
$('#magenta').val("0.00");
$('#amarillo').val("0.00");
$('#gotaNegro').val("0.00");
$('#gotaColor').val("0.00");
$('#action').val('add');
$('.modal-title').text('<?= lang('Basic.global.add') ?>' + ' ' + '<?= lang("PapelImpresion.consumo_tintas_rotativas") ?>');
$('#submit_button').val('<?= lang('Basic.global.Save') ?>');
$('#tipologiaModal').modal('show');
$('#hidden_id').val("");
}
});
$('#rotativa').on("click",function(el){
if(!$(this).is(':checked')){
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('PapelImpresion.papel impresion'))]) ?>',
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
cancelButtonColor: '#d33'
})
.then((result) => {
if (result.value) {
if($(this).is(':checked')){
$("#accordionTipologias").show();
}else{
$("#accordionTipologias").hide();
}
}
else{
$(this).prop('checked', true) ;
}
});
}
else{
$("#accordionTipologias").show();
}
});
$('#tipologiaModal').on('submit', function(event){
event.preventDefault();
const tipo_values = $('#tableOfPapelimpresiontipologias').DataTable().column().data().toArray();
if(tipo_values.includes($('#tipologiaTipo').val()) && $('#action').val() == 'add'){
$('#tipologiaModal').modal('hide');
Swal.fire({
title: '<?= lang('Basic.global.Error') ?>',
text: '<?= lang('ImpresionTipologias.errorTipo') ?>',
icon: 'error',
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.ok') ?>',
})
}
else
{
var formData = {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
papel_impresion_id: id,
tipo: $('#tipologiaTipo').val(),
negro: $('#negro').val(),
cyan: $('#cyan').val(),
magenta: $('#magenta').val(),
amarillo: $('#amarillo').val(),
gota_negro: $('#gotaNegro').val(),
gota_color: $('#gotaColor').val()
}
if( $('#action').val() == 'edit')
{
var url_to_go = "/configuracion/papelimpresiontipologias/edit/" + $('#hidden_id').val();
formData['id']= $('#hidden_id').val();
}
else
{
var url_to_go = "<?= route_to('createPapelImpresionTipologia'); ?>";
}
$.ajax({
url: url_to_go,
method:"POST",
data: formData,
dataType:"JSON",
encode: true,
}).done((data, textStatus, jqXHR) => {
$('#tipologiaModal').modal('hide') ;
yeniden(data.<?= csrf_token() ?>);
theTable.clearPipeline();
theTable.draw();
Toast.fire({
icon: 'success',
title: data.msg ?? jqXHR.statusText,
});
}).fail((jqXHR, textStatus, errorThrown) => {
$('#tipologiaModal').modal('hide') ;
Toast.fire({
icon: 'error',
title: jqXHR.responseJSON.messages.error,
});
})
}
});
// Activate an inline edit on click of a table cell
$(document).on('click', '.btn-edit', function(e) {
var id = $(this).attr('data-id');
$.ajax({
url:"<?= route_to('fetchTipologia'); ?>",
method:"POST",
data:{id:id,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v},
dataType:'JSON',
success:function(response)
{
yeniden(response.<?= csrf_token() ?>);
$('#tipologiaTipo').val(response.data.tipo);
$('#negro').val(response.data.negro);
$('#cyan').val(response.data.cyan);
$('#magenta').val(response.data.magenta);
$('#amarillo').val(response.data.amarillo);
$('#gotaNegro').val(response.data.gota_negro);
$('#gotaColor').val(response.data.gota_color);
$('#tipologiaTipo').attr('disabled', 'disabled');
$('#action').val('edit');
$('.modal-title').text('<?= lang('Basic.global.edit') ?>' + ' ' + '<?= lang("PapelImpresion.consumo_tintas_rotativas") ?>');
$('#submit_button').val('<?= lang('Basic.global.Save') ?>');
$('#tipologiaModal').modal('show');
$('#hidden_id').val(id);
},
cache: true
})
});
$(document).on('click', '.btn-delete', function(e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('PapelImpresion.consumo_tintas_rotativas'))]) ?>',
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: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
method: 'GET',
dataType: "json",
}).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,
});
})
}
});
});
$('#papelGenericoId').select2({
theme: 'bootstrap-5',
allowClear: false,
ajax: {
ajax: {
url: '<?= route_to("menuItemsOfPapelesGenericos") ?>',
type: 'post',
dataType: 'json',
@ -60,4 +506,25 @@
});
<?= $this->endSection() ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.min.css">
<?=$this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.0/jszip.min.js" integrity="sha512-xcHCGC5tQ0SHlRX8Anbz6oy/OullASJkEhb4gjkneVpGE3/QGYejf14CUO5n5q5paiHfRFTa9HKgByxzidw2Bw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/pdfmake.min.js" integrity="sha512-rDbVu5s98lzXZsmJoMa0DjHNE+RwPJACogUCLyq3Xxm2kJO6qsQwjbE5NDk2DqmlKcxDirCnU1wAzVLe12IM3w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/vfs_fonts.js" integrity="sha512-cktKDgjEiIkPVHYbn8bh/FEyYxmt4JDJJjOCu5/FQAkW4bc911XtKYValiyzBiJigjVEvrIAyQFEbRJZyDA1wQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<?=$this->endSection() ?>

View File

@ -45,75 +45,74 @@
<?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfPapelesimpresion').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<button class="btn btn-sm btn-warning btn-edit me-1" data-id="${data.id}"><?= lang('Basic.global.edit') ?></button>
<button class="btn btn-sm btn-danger btn-delete ms-1" data-id="${data.id}"><?= lang('Basic.global.Delete') ?></button>
</div>
</td>`;
};
theTable = $('#tableOfPapelesimpresion').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', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPapelesImpresion') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [3, 4, 5, 6, 7, lastColNr] //JJO añadidas bool cols
}
],
columns : [
{ 'data': 'nombre' },
{ 'data': 'papel_generico_id' },
{ 'data': 'gramaje' },
{ 'data': 'bn' },
{ 'data': 'color' },
{ 'data': 'portada' },
{ 'data': 'cubierta' },
{ 'data': 'rotativa' },
{ 'data': actionBtns }
]
});
theTable.on( 'draw.dt', function () {
const boolCols = [3, 4, 5, 6, 7];
for (let coln of boolCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
const lastColNr = $('#tableOfPapelesimpresion').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 = $('#tableOfPapelesimpresion').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', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPapelesImpresion') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [3, 4, 5, 6, 7, lastColNr] //JJO añadidas bool cols
}
],
columns : [
{ 'data': 'nombre' },
{ 'data': 'papel_generico_id' },
{ 'data': 'gramaje' },
{ 'data': 'bn' },
{ 'data': 'color' },
{ 'data': 'portada' },
{ 'data': 'cubierta' },
{ 'data': 'rotativa' },
{ 'data': actionBtns }
]
});
theTable.on( 'draw.dt', function () {
const boolCols = [3, 4, 5, 6, 7];
for (let coln of boolCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
});
$(document).on('click', '.btn-edit', function(e) {
//window.location.href = `<?= route_to('papelImpresionList') ?>/${$(this).attr('data-id')}/edit`;
window.location.href = `/configuracion/papelesimpresion/edit/${$(this).attr('data-id')}`;
@ -178,6 +177,5 @@ $(document).on('click', '.btn-delete', function(e) {
<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() ?>