mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
falta funcionalidad tabla pivote. al pulsar isRotativa hay que añadir un dialog. actualizar tabla papeles con tarifas
This commit is contained in:
@ -254,6 +254,7 @@ $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_editor', 'Maquinaspapelesimpresion::datatable_editor', ['as' => 'editorOfMaquinasPapelImpresion']);
|
||||
});
|
||||
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
// Para saber si el papel que se tiene que mostrar es para rotativa
|
||||
$isRotativa= $reqData['isRotativa'] ?? 0;
|
||||
|
||||
$resourceData = $this->model->getResource("", $isRotativa)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$resourceData = $this->model->getResource($search, $isRotativa)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
@ -92,4 +92,70 @@ class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
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_maquinas_tarifas_impresion' )
|
||||
->fields(
|
||||
Field::inst( 'maquina_id' ),
|
||||
Field::inst( 'papel_impresion_id' ),
|
||||
Field::inst( 'active' )
|
||||
|
||||
)
|
||||
->validator( function($editor, $action, $data){
|
||||
/*if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
|
||||
foreach ($data['data'] as $pkey => $values ){
|
||||
// Si no se quiere borrar...
|
||||
if($data['data'][$pkey]['is_deleted'] != 1)
|
||||
{
|
||||
// Cubierta y sobrecubierta sólo pueden ser en color
|
||||
if($values['uso'] != 'interior' && $values['tipo'] != 'color'){
|
||||
return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color');
|
||||
}
|
||||
|
||||
$builder = $this->model->select('*')
|
||||
->where(array(
|
||||
'maquina_id'=> $values['maquina_id'],
|
||||
'tipo'=> $values['tipo'],
|
||||
'uso'=> $values['uso'],
|
||||
'is_deleted'=> 0));
|
||||
|
||||
if ($builder->countAllResults() >= 1){
|
||||
if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey)
|
||||
|| $action === Editor::ACTION_CREATE)
|
||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
})
|
||||
->debug(true)
|
||||
->process( $_POST )
|
||||
->data();
|
||||
|
||||
|
||||
/*// if unique key is set in DB
|
||||
if(isset($response['error'])){
|
||||
if(str_contains($response['error'], "tirada_min_tirada_max") &&
|
||||
str_contains($response['error'], "Duplicate entry ")){
|
||||
$response['error'] = lang('TarifaAcabadoLineas.validation.duplicated_tirada');
|
||||
}
|
||||
}*/
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -277,6 +277,52 @@
|
||||
});
|
||||
|
||||
|
||||
editor2 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfMaquinasPapelImpresion') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfMaquinaspapelesimpresion",
|
||||
fields: [
|
||||
{
|
||||
"name": "maquina_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "papel_generico_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "active",
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
|
||||
editor2.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['maquina_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['maquina_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
editor2.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
/*editor2.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
|
||||
theTable2.clearPipeline();
|
||||
theTable2.draw();
|
||||
});*/
|
||||
|
||||
|
||||
var theTable = $('#tableOfMaquinastarifasimpresion').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
@ -361,7 +407,7 @@
|
||||
lengthChange: true,
|
||||
searching: true,
|
||||
paging: true,
|
||||
info: false,
|
||||
info: true,
|
||||
dom: "lftp",
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfMaquinasPapelesImpresion') ?>',
|
||||
@ -369,17 +415,20 @@
|
||||
d.id_maquina = id;
|
||||
d.isRotativa = isRotativa.watch;
|
||||
},
|
||||
/*{
|
||||
id_maquina: id,
|
||||
//tarifas: [{'uso':'interior', 'tipo':'negro'}],
|
||||
isRotativa: isRotativa.watch,
|
||||
},*/
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{ 'data': 'active'},
|
||||
{ 'data': 'active',
|
||||
render: function (data, type, row) {
|
||||
if (type === 'display') {
|
||||
return '<input type="checkbox" class="editor-active">';
|
||||
}
|
||||
return data;
|
||||
},
|
||||
className: 'dt-body-center'
|
||||
},
|
||||
{ 'data': 'papel_generico'},
|
||||
{ 'data': 'papel_impresion'},
|
||||
{ 'data': 'gramaje'},
|
||||
@ -389,9 +438,19 @@
|
||||
{ 'data': 'sobrecubierta'},
|
||||
{ 'data': 'rotativa'}
|
||||
],
|
||||
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,3,4,5,6,7,8]
|
||||
}
|
||||
],
|
||||
} );
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user