rehecho papeles impresion. Lista de tarifas a 50 elementos por defecto

This commit is contained in:
Jaime Jimenez
2023-07-28 17:26:16 +02:00
parent fa27f25d10
commit 9d6e3822e8
21 changed files with 678 additions and 449 deletions

View File

@ -184,8 +184,6 @@ $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('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']);
});
@ -194,6 +192,7 @@ $routes->resource('papelesimpresion', ['namespace' => 'App\Controllers\Configur
$routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('add', 'Papelimpresiontipologias::add', ['as' => 'newPapelImpresionTipologia']);
$routes->post('add', 'Papelimpresiontipologias::add', ['as' => 'createPapelImpresionTipologia']);
$routes->post('datatable_editor', 'Papelimpresiontipologias::datatable_editor', ['as' => 'editorOfConsumoTintas']);
$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']);
@ -245,7 +244,9 @@ $routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\
$routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->post('datatable', 'Maquinaspapelesimpresion::datatable', ['as' => 'dataTableOfMaquinasPapelesImpresion']);
$routes->post('datatable_2', 'Maquinaspapelesimpresion::datatable_2', ['as' => 'dataTableOfPapelesImpresionMaquinas']);
$routes->post('datatable_editor', 'Maquinaspapelesimpresion::datatable_editor', ['as' => 'editorOfMaquinasPapelImpresion']);
$routes->post('datatable_editor_2', 'Maquinaspapelesimpresion::datatable_editor_2', ['as' => 'editorOfPapelImpresionMaquinas']);
$routes->post('updateTableOnChange', 'Maquinaspapelesimpresion::updateTableOnChange', ['as' => 'updateMaquinaPapelOnTarifasChange']);
});
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);

View File

@ -100,6 +100,42 @@ class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController
}
}
public function datatable_2() {
if ($this->request->isAJAX()) {
// modelos usados
$tarifa_model = new MaquinasTarifasImpresionModel();
$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 = MaquinasPapelesImpresionModel::SORTABLE_2[$requestedOrder >= 0 ? $requestedOrder : 1];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$papel_id = $reqData['papel_id'] ?? -1;
$ancho = $reqData['ancho'] ?? -1;
$alto = $reqData['alto'] ?? -1;
$isRotativa = $reqData['isRotativa'] ?? -1;
$resourceData = $this->model->getResource_maquinas($search, $papel_id, $isRotativa, $ancho, $alto)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource_maquinas()->countAllResults(),
$this->model->getResource_maquinas($search, $papel_id, $isRotativa, $ancho, $alto)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function updateTableOnChange(){
if ($this->request->isAJAX()) {

View File

@ -32,6 +32,8 @@ use App\Models\Configuracion\PapelImpresionModel;
use App\Models\Configuracion\PapelGenericoModel;
use App\Models\Configuracion\PapelImpresionTipologiaModel;
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
use App\Models\Configuracion\MaquinaModel;
class Papelesimpresion extends \App\Controllers\GoBaseResourceController
@ -56,6 +58,8 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
$this->viewData['pageTitle'] = lang('PapelImpresion.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
$this->viewData = ['usingServerSideDataTable' => true]; // JJO
// Se indica que este controlador trabaja con soft_delete
$this->soft_delete = true;
// Se indica el flag para los ficheros borrados
@ -92,14 +96,11 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
public function add()
{
$requestMethod = $this->request->getMethod();
if ($requestMethod === 'post') :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$nullIfEmpty = false; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
@ -134,7 +135,8 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
return redirect()->to(site_url('/configuracion/papelesimpresion/edit/' . $id))->with('sweet-success', $message);
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else :
return $this->redirect2listView('sweet-success', $message);
endif;
@ -206,8 +208,18 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
$sanitizedData['rotativa'] = false;
}
// Hay que asegurarse de que se quitan los consumos de tintas de rotativa
// en caso de que se haya deseleccionado la opción rotativa
if(!$sanitizedData['rotativa']){
$this->tpModel->removeForPapelImpresion($id);
}
// Si hay máquinas seleccionadas, hay que guardar las que cumplan las nuevas condiciones
// y borrar el resto
$this->updateMaquinas($id, $sanitizedData);
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
@ -228,7 +240,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
$papelImpresion->fill($sanitizedData);
$thenRedirect = true;
$thenRedirect = false;
endif;
if ($noException && $successfulResult) :
$id = $papelImpresion->id ?? $id;
@ -297,12 +309,22 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = PapelImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
$requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder;
$requestedOrder3 = $reqData['order']['2']['column'] ?? $requestedOrder;
$requestedOrder4 = $reqData['order']['3']['column'] ?? $requestedOrder;
$order = PapelImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
$order2 = PapelImpresionModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : 0];
$order3 = PapelImpresionModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder3 : 0];
$order4 = PapelImpresionModel::SORTABLE[$requestedOrder4 >= 0 ? $requestedOrder4 : 0];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$dir2 = $reqData['order']['1']['dir'] ?? $dir;
$dir3 = $reqData['order']['2']['dir'] ?? $dir;
$dir4 = $reqData['order']['3']['dir'] ?? $dir;
if($id_PG<0){
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->orderBy($order2, $dir2)->orderBy($order3, $dir3)
->orderBy($order4, $dir4)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
@ -325,58 +347,6 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
}
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()) {
$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
);
$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()
{
@ -428,24 +398,7 @@ 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)
{
@ -460,4 +413,23 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
endif;
return $data;
}
private function updateMaquinas($id, $data){
$ma_model = new MaquinaModel();
$ma_pa_model = new MaquinasPapelesImpresionModel();
$active_values = $ma_pa_model->getInitSelectedMachines($id, $data['rotativa'], $data['ancho'], $data['alto'])->get()->getResult('array');
$ma_pa_model->deleteForPapelImpresion($id);
// Se obtienen las máquinas que cumplen las condiciones
$rows = $ma_model->getIdMaquinasForPapelImpresion($id, $data['rotativa'], $data['ancho'], $data['alto'])->get()->getResult('array');
$ma_pa_model->insertRows($rows);
// Se actualizan los activos que había en caso de que los hubiera
if(count($active_values)>0){
$ma_pa_model->updateRows($active_values);
}
}
}

View File

@ -11,6 +11,18 @@ use App\Models\Configuracion\PapelImpresionTipologiaModel;
use App\Models\Configuracion\PapelImpresionModel;
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;
class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController {
protected $modelName = PapelImpresionTipologiaModel::class;
@ -221,6 +233,90 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController
} // end function edit(...)
public function datatable_editor() {
if ($this->request->isAJAX()) {
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
// Build our Editor instance and process the data coming from _POST
$response = Editor::inst( $db, 'lg_papel_impresion_tipologias' )
->fields(
Field::inst( 'tipo' )
->validator( Validate::values( array('negro', 'color', 'bicolor') ) ),
Field::inst( 'negro' )
->validator( 'Validate::numeric', array(
'message' => lang('ImpresionTipologias.validation.negro.decimal') )
)
->validator( 'Validate::notEmpty',array(
'message' => lang('ImpresionTipologias.validation.negro.required') )
),
Field::inst( 'cyan' )
->validator( 'Validate::numeric', array(
'message' => lang('ImpresionTipologias.validation.cyan.decimal') )
)
->validator( 'Validate::notEmpty',array(
'message' => lang('ImpresionTipologias.validation.cyan.required') )
),
Field::inst( 'magenta' )
->validator( 'Validate::numeric', array(
'message' => lang('ImpresionTipologias.validation.magenta.decimal') )
)
->validator( 'Validate::notEmpty',array(
'message' => lang('ImpresionTipologias.validation.magenta.required') )
),
Field::inst( 'amarillo' )
->validator( 'Validate::numeric', array(
'message' => lang('ImpresionTipologias.validation.amarillo.decimal') )
)
->validator( 'Validate::notEmpty',array(
'message' => lang('ImpresionTipologias.validation.amarillo.required') )
),
Field::inst( 'gota_negro' )
->validator( 'Validate::numeric', array(
'message' => lang('ImpresionTipologias.validation.gota_negro.decimal') )
)
->validator( 'Validate::notEmpty',array(
'message' => lang('ImpresionTipologias.validation.gota_negro.required') )
),
Field::inst( 'gota_color' )
->validator( 'Validate::numeric', array(
'message' => lang('ImpresionTipologias.validation.gota_color.decimal') )
)
->validator( 'Validate::notEmpty',array(
'message' => lang('ImpresionTipologias.validation.gota_color.required') )
),
Field::inst( 'papel_impresion_id' ),
)
->validator( function($editor, $action, $data){
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
foreach ($data['data'] as $pkey => $values ){
$process_data['tipo'] = $data['data'][$pkey]['tipo'];
$process_data['papel_impresion_id'] = $data['data'][$pkey]['papel_impresion_id'];
$response = $this->model->checkTipo($process_data, $pkey);
// No se pueden duplicar valores al crear o al editar
if (!empty($response)){
return $response;
}
}
}
})
->debug(true)
->process( $_POST )
->data();
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$response[$csrfTokenName] = $newTokenHash;
echo json_encode($response);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable() {
if ($this->request->isAJAX()) {

View File

@ -182,7 +182,8 @@ class LoginAuthFilter implements FilterInterface
'menuItems',
'datatable',
'datatable_editor',
'fetch_single_data',
'datatable_2',
'datatable_editor_2',
'collect',
'cast',
];

View File

@ -14,45 +14,45 @@ return [
'tipo' => 'Type',
'errorTipo' => 'Typology type already exists',
'validation' => [
'error_tipo_duplicado' => 'The \'Type\' selected already exists',
'amarillo' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
'decimal' => 'The field must contain a decimal number.',
'required' => 'The field is required.',
],
'cyan' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
'decimal' => 'The field must contain a decimal number.',
'required' => 'The field is required.',
],
'gota_color' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
'decimal' => 'The field must contain a decimal number.',
'required' => 'The field is required.',
],
'gota_negro' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
'decimal' => 'The field must contain a decimal number.',
'required' => 'The field is required.',
],
'magenta' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
'decimal' => 'The field must contain a decimal number.',
'required' => 'The field is required.',
],
'negro' => [
'decimal' => 'The {field} field must contain a decimal number.',
'required' => 'The {field} field is required.',
'decimal' => 'The field must contain a decimal number.',
'required' => 'The field is required.',
],
'tipo' => [
'in_list' => 'The {field} field must be one of: {param}.',
'required' => 'The {field} field is required.',
'required' => 'The field is required.',
],

View File

@ -35,6 +35,9 @@ return [
'userUpdateId' => 'User Update ID',
'consumo_tintas_rotativas' => 'Rotary ink consumption',
'maquinas_papel' => 'Selected machines',
'sureToChangeRotativaTitle' => 'Are you sure to change this option?',
'sureToChangeRotativaText' => 'This operation can\'t undone, the machines list and the rotary ink consumption will change.',
'validation' => [
'espesor_update' => [

View File

@ -15,45 +15,45 @@ return [
'tipo' => 'Tipo',
'errorTipo' => 'El tipo de tipología ya existe',
'validation' => [
'error_tipo_duplicado' => 'El \'Tipo\' seleccionado ya existe',
'amarillo' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
'decimal' => 'El campo debe ser un número entero.',
'required' => 'El campo es obligatorio.',
],
'cyan' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
'decimal' => 'El campo debe ser un número entero.',
'required' => 'El campo es obligatorio.',
],
'gota_color' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
'decimal' => 'El campo debe ser un número entero.',
'required' => 'El campo es obligatorio.',
],
'gota_negro' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
'decimal' => 'El campo debe ser un número entero.',
'required' => 'El campo es obligatorio.',
],
'magenta' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
'decimal' => 'El campo debe ser un número entero.',
'required' => 'El campo es obligatorio.',
],
'negro' => [
'decimal' => 'El campo {field} debe ser un número entero.',
'required' => 'El campo {field} es obligatorio.',
'decimal' => 'El campo debe ser un número entero.',
'required' => 'El campo es obligatorio.',
],
'tipo' => [
'in_list' => 'El campo {field} debe ser uno de: {param}.',
'required' => 'El campo {field} es obligatorio.',
'required' => 'El campo es obligatorio.',
],

View File

@ -35,6 +35,9 @@ return [
'userUpdateId' => 'ID usuario actualización',
'consumo_tintas_rotativas' => 'Consumo tintas rotativas',
'maquinas_papel' => 'Máquinas seleccionadas',
'sureToChangeRotativaTitle' => 'Está seguro de cambiar esta opción?',
'sureToChangeRotativaText' => 'Está operación no se puede deshacer, cambiará la lista de máquinas y el consumo de tintas.',
'validation' => [
'espesor_update' => [

View File

@ -252,6 +252,19 @@ class MaquinaModel extends \App\Models\GoBaseModel
return $result;
}
public function getIdMaquinasForPapelImpresion($papel_impresion_id, $rotativa, $ancho, $alto){
$builder = $this->db
->table($this->table . " t1")
->select(
"'".$papel_impresion_id."'". " as papel_impresion_id, t1.id AS maquina_id, '0' as active"
);
$builder->where("t1.is_rotativa", $rotativa);
$builder->where("t1.ancho >", $ancho);
$builder->where("t1.alto >", $alto);
return $builder;
}
/**
* Get resource data.
*

View File

@ -26,6 +26,12 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
8 => "t3.rotativa",
];
const SORTABLE_2 = [
0 => "t1.active",
1 => "t2.nombre",
];
protected $allowedFields = ["maquina_id", "papel_impresion_id", "active"];
protected $returnType = "App\Entities\Configuracion\MaquinasPapelesImpresionEntity";
@ -99,6 +105,42 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
->groupEnd();
}
/**
* Get resource data for Papeles impresion.
*
* @param string $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource_maquinas(string $search = "", $papel_id = -1, $isRotativa = -1, $ancho =-1, $alto = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.maquina_id AS maquina_id, t1.papel_impresion_id AS papel_impresion_id, t1.active AS active, t2.nombre AS maquina,
t2.ancho AS ancho, t2.alto AS alto, t2.ancho_impresion AS anchoimpresion, t2.alto_impresion AS altoimpresion"
)
->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left")
->join("lg_papel_impresion t3", "t1.papel_impresion_id = t3.id", "left");
$builder->where("t1.papel_impresion_id", $papel_id);
$builder->where("t2.is_deleted", 0);
$builder->where("t2.is_rotativa", $isRotativa);
$builder->where("t2.ancho >", $ancho);
$builder->where("t2.alto >", $alto);
$builder->where("t3.is_deleted", 0);
$builder->where("t3.isActivo", 1);
return empty($search)
? $builder
: $builder
->groupStart()
->like("t2.nombre", $search)
->groupEnd();
}
public function getInitData($isRotativa = 0, $tarifas = [], $maquina_id = -1)
{
$builder = $this->db
@ -148,6 +190,38 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
return $builder;
}
// Funcion para obtener todas las máquinas seleccionadas para un papel
public function getInitSelectedMachines($papel_impresion_id= -1, $isRotativa, $ancho, $alto)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.*"
);
$builder->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left");
$builder->where("t1.papel_impresion_id", $papel_impresion_id);
$builder->where("t1.active", 1);
// Se aplican las condiciones que tienen que cumplir
$builder->where("t2.is_rotativa", $isRotativa);
$builder->where("t2.ancho >", $ancho);
$builder->where("t2.alto >", $alto);
return $builder;
}
// Borrar todas las filas para un papel impresion determinado
public function deleteForPapelImpresion($papel_impresion_id= -1){
$this->db
->table($this->table . " t1")
->where("papel_impresion_id", $papel_impresion_id)
->delete();
}
// Funcion para consultar los papeles activos con un gramaje
// determinado seleccionados para una máquina
public function getPapelActivo($maquina_id=-1, $gramaje=-1){

View File

@ -59,6 +59,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
],
];
public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0)
{
$sql =

View File

@ -15,8 +15,8 @@ class PapelImpresionModel extends \App\Models\GoBaseModel
const SORTABLE = [
0 => "t1.nombre",
1 => "t2.nombre",
2 => "t1.bn",
3 => "t1.gramaje",
2 => "t1.gramaje",
3 => "t1.bn",
4 => "t1.color",
5 => "t1.cubierta",
6 => "t1.sobrecubierta",

View File

@ -121,6 +121,14 @@ class PapelImpresionTipologiaModel extends \App\Models\GoBaseModel
}
public function removeForPapelImpresion($papel_impresion_id){
$builder = $this->db
->table($this->table . " t1")
->where('papel_impresion_id', $papel_impresion_id)
->delete();
}
public function getResource($id)
{
$builder = $this->db
@ -131,4 +139,23 @@ class PapelImpresionTipologiaModel extends \App\Models\GoBaseModel
return $builder;
}
public function checkTipo($data, $id){
$builder = $this->db
->table($this->table)
->select("id")
->where("papel_impresion_id", $data["papel_impresion_id"])
->where("tipo", $data["tipo"]);
if ($builder->countAllResults() > 0){
if($builder->get()->getResultObject()[0]->id!=$id){
return lang('ImpresionTipologias.validation.error_tipo_duplicado');
}
}
return "";
}
}

View File

@ -30,18 +30,21 @@
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="pesoPorPliego" class="form-label">
<?= lang('PapelImpresion.pesoPorPliego') ?>*
<label for="precioTonelada" class="form-label">
<?= lang('PapelImpresion.precioTonelada') ?>*
</label>
<input type="number" id="pesoPorPliego" name="peso_por_pliego" required maxLength="31" step="0.01" class="form-control" value="<?= old('peso_por_pliego', $papelImpresion->peso_por_pliego) ?>">
<input type="number" id="precioTonelada" name="precio_tonelada" required maxLength="31" step="0.01" class="form-control" value="<?= old('precio_tonelada', $papelImpresion->precio_tonelada) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="pesoPorPliego" class="form-label">
<?= lang('PapelImpresion.pesoPorPliego') ?>
</label>
<input readonly style="background-color:#d6d6d6;" id="pesoPorPliego" name="peso_por_pliego" required maxLength="31" class="form-control" value="<?= old('peso_por_pliego', $papelImpresion->peso_por_pliego) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="margen" class="form-label">
<?= lang('PapelImpresion.margen') ?>*
</label>
<input type="number" id="margen" name="margen" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?= old('margen', $papelImpresion->margen) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
@ -86,6 +89,8 @@
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="papelGenericoId" class="form-label">
@ -124,20 +129,26 @@
<input type="number" id="espesor" name="espesor" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?= old('espesor', $papelImpresion->espesor) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="precioPliego" class="form-label">
<?= lang('PapelImpresion.precioPliego') ?>*
<div class="mb-3">
<label for="margen" class="form-label">
<?= lang('PapelImpresion.margen') ?>*
</label>
<input type="number" id="precioPliego" name="precio_pliego" required maxLength="31" step="0.01" class="form-control" value="<?= old('precio_pliego', $papelImpresion->precio_pliego) ?>">
<input type="number" id="margen" name="margen" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?= old('margen', $papelImpresion->margen) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="precioTonelada" class="form-label">
<?= lang('PapelImpresion.precioTonelada') ?>*
<label for="precioPliego" class="form-label">
<?= lang('PapelImpresion.precioPliego') ?>
</label>
<input type="number" id="precioTonelada" name="precio_tonelada" required maxLength="31" step="0.01" class="form-control" value="<?= old('precio_tonelada', $papelImpresion->precio_tonelada) ?>">
<input readonly style="background-color:#d6d6d6; id="precioPliego" name="precio_pliego" required maxLength="31" class="form-control" value="<?= old('precio_pliego', $papelImpresion->precio_pliego) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">

View File

@ -1,6 +1,7 @@
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
@ -24,7 +25,7 @@
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!-- //.card -->
<?php if(str_contains($formAction,'edit') && $papelImpresion->rotativa == true): ?>
@ -37,7 +38,6 @@
<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">
@ -65,8 +65,11 @@
</div>
</div> <!-- //.accordion -->
<div class="accordion mt-3" id="accordionMaquinas">
<?php if(str_contains($formAction,'edit')): ?>
<div class="accordion mt-3" id="accordionMaquinas">
<?php else: ?>
<div class="accordion mt-3" id="accordionMaquinas" style="display:none">
<?php endif; ?>
<div class="card accordion-item">
<h2 class="accordion-header" id="headingTwo">
<button
@ -77,117 +80,34 @@
aria-expanded="false"
aria-controls="accordionMaq"
>
MAAAAQUIIIINAAAAAS<!--- lang("PapelImpresion.consumo_tintas_rotativas") ?> AÑADIR LANGUAJE MAQUINAS-->
<p><?= lang("PapelImpresion.maquinas_papel") ?></p>
</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 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('MaquinasPapelImpresion.activo') ?></th>
<th><?= lang('Maquinas.nombre') ?></th>
<th><?= lang('Maquinas.ancho') ?></th>
<th><?= lang('Maquinas.alto') ?></th>
<th><?= lang('Maquinas.anchoImpresion') ?></th>
<th><?= lang('Maquinas.altoImpresion') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</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 select2" 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() ?>
@ -206,15 +126,84 @@
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>`;
return `
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
<span class="cancel"></span>
`;
};
if(url_parts[url_parts.length-2] == 'edit'){
tipoTypes = [
{label:'<?= lang('ImpresionTipologias.negro') ?>', value:'negro'},
{label:'<?= lang('ImpresionTipologias.color') ?>', value: 'color'},
{label:'<?= lang('ImpresionTipologias.bicolor') ?>', value: 'bicolor'}
];
editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfConsumoTintas') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfPapelimpresiontipologias",
idSrc: 'id',
fields: [ {
name: "tipo",
type: "select",
options: tipoTypes
}, {
name: "negro",
attr: {
type: "number"
}
},{
name: "cyan",
attr: {
type: "number"
}
},{
name: "magenta",
attr: {
type: "number"
}
},{
name: "amarillo",
attr: {
type: "number"
}
},{
name: "gota_negro",
attr: {
type: "number"
}
},{
name: "gota_color",
attr: {
type: "number"
}
}, {
"name": "papel_impresion_id",
"type": "hidden"
}
]
} );
editor.on( 'initCreate', function () {
if ($('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3){
Swal.fire({
title: '<?= lang('Basic.global.sweet.maxRowsReached') ?>',
icon: 'info',
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.Close') ?>',
});
}
} );
theTable = $('#tableOfPapelimpresiontipologias').DataTable({
processing: true,
serverSide: true,
@ -224,10 +213,9 @@
lengthMenu: [ 5],
pageLength: 5,
lengthChange: false,
searching: false,
//paging: false,
searching: false,
info: false,
"dom": 'lrt',
"dom": '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
stateSave: true,
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
@ -242,237 +230,96 @@
async: true,
}),
columns : [
{ 'data': 'tipo' },
{ 'data': 'tipo', "render": function ( data, type, row, meta ) {
if(data=='negro')
return '<?= lang('ImpresionTipologias.negro') ?>';
else if (data=='color')
return '<?= lang('ImpresionTipologias.color') ?>';
else if (data=='bicolor')
return '<?= lang('ImpresionTipologias.bicolor') ?>';
}
},
{ 'data': 'negro' },
{ 'data': 'cyan' },
{ 'data': 'magenta' },
{ 'data': 'amarillo' },
{ 'data': 'gota_negro' },
{ 'data': 'gota_color' },
{ data: actionBtns}
]
{ data: actionBtns,
className: 'row-edit dt-center'}
],
buttons: [ {
className: 'btn btn-primary float-end me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
});
// Activate an inline edit on click of a table cell
$(document).on('click', '.btn-edit', function(e) {
editor.inline(
theTable.cells(this.parentNode.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
}
// 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();
}
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['papel_impresion_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['papel_impresion_id'] = id;
}
else{
$(this).prop('checked', true) ;
}
});
}
else{
$("#accordionTipologias").show();
}
});
}
});
$('#tipologiaModal').on('submit', function(event){
editor.on( 'postSubmit', function ( e, json, data, action ) {
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()
}
yeniden(json.<?= csrf_token() ?>);
});
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'); ?>";
}
editor.on( 'submitSuccess', function ( e, json, data, action ) {
theTable.clearPipeline();
theTable.draw();
});
$.ajax({
url: url_to_go,
method:"POST",
data: formData,
dataType:"JSON",
encode: true,
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
}).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');
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if (result.value) {
if ($.isNumeric(dataId)) {
$.ajax({
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
method: 'GET',
dataType: "json",
}).done((data, textStatus, jqXHR) => {
Toast.fire({
icon: 'success',
title: data.msg ?? jqXHR.statusText,
});
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
Toast.fire({
icon: 'error',
title: jqXHR.responseJSON.messages.error,
});
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
});
}
$('#papelGenericoId').select2({
@ -504,13 +351,153 @@
}
});
var theTable2 = $('#tableOfMaquinas').DataTable( {
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25],
order: [[ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: true,
paging: true,
info: true,
dom: "lftp",
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPapelesImpresionMaquinas') ?>',
data: function (d) {
d.papel_id = id;
d.isRotativa = $('#rotativa').is(':checked')?1:0;
d.ancho = document.getElementById("ancho").value;
d.alto = document.getElementById("alto").value;
d.webguard_token = '<?= csrf_hash() ?>';
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'active',
render: function (data, type, row) {
if (type === 'display') {
return '<input type="checkbox" class="editor-active" id="check_' + row.papel_impresion_id + '">';
}
return data;
},
className: 'dt-body-center'
},
{ 'data': 'maquina'},
{ 'data': 'ancho'},
{ 'data': 'alto'},
{ 'data': 'anchoimpresion'},
{ 'data': 'altoimpresion'},
],
rowCallback: function (row, data) {
// Set the checked state of the checkbox in the table
$('input.editor-active', row).prop('checked', data.active == 1);
},
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
columnDefs: [
{
searchable: false,
targets: [0,2,3,4,5]
}
],
} );
editor2 = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfMaquinasPapelImpresion') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfMaquinas",
idSrc: 'papel_impresion_id',
fields: [
{
name: "active",
type: "checkbox",
separator: "|",
ipOpts: [
{ label: '', value: 1 }
]
},{
"name": "papel_impresion_id",
"type": "hidden"
},{
"name": "gramaje",
"type": "hidden"
},{
"name": "maquina_id",
"type": "hidden"
}
]
} );
editor2.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
if(json.error){
document.getElementById("check_" + json.data.papel_impresion_id).checked = false;
Swal.fire({
icon: 'error',
title: '<?= lang('Basic.global.sweet.error_tittle') ?>',
text: json.error,
});
}
});
// Cuando se clica en un checkbox hacer submit en el editor
theTable2.on( 'change', 'input.editor-active', function () {
editor2
.edit( $(this).closest('tr'), false )
.set( 'active', $(this).prop( 'checked' ) ? 1 : 0 )
.submit();
} );
// Para los calculos del precio
$("#ancho").on('input', function () {
updateValue();
});
$("#alto").on('input', function () {
updateValue();
});
$("#gramaje").on('input', function () {
updateValue();
});
$("#precioTonelada").on('input', function () {
updateValue();
});
function updateValue() {
let value = parseFloat($("#gramaje").val()) * parseFloat($("#ancho").val())*parseFloat($("#alto").val())/1E6;
value = value.toFixed(2);
$('#pesoPorPliego').val(value);
let value2 = parseFloat($("#precioTonelada").val()) *value/1E6;
value2 = value2.toFixed(6);
$('#precioPliego').val(value2);
}
<?= $this->endSection() ?>
<?=$this->section('css') ?>
<?php /*
<link rel="stylesheet" href="<?= site_url('themes/vuexy/ccs/datatables-editor/editor.dataTables.min.css') ?>">
-*/ ?>
<link rel="stylesheet" href="https://editor.datatables.net/extensions/Editor/css/editor.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
<?=$this->endSection() ?>
@ -522,5 +509,8 @@
<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>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.js') ?>"></script>
<?=$this->endSection() ?>

View File

@ -58,7 +58,7 @@ const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
pageLength: 50,
lengthChange: true,
"dom": 'lfBrtip',
"buttons": [

View File

@ -56,7 +56,7 @@
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
pageLength: 50,
lengthChange: true,
"dom": 'lfBrtip',
"buttons": [

View File

@ -56,7 +56,7 @@
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
pageLength: 50,
lengthChange: true,
"dom": 'lfBrtip',
"buttons": [

View File

@ -85,7 +85,7 @@
"responsive": true,
"paging": true,
"lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
"pageLength": 10,
"pageLength": 50,
"lengthChange": true,
"searching": true,
"ordering": true,

File diff suppressed because one or more lines are too long