2020-08-20 15:59:13 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2020-08-20 15:59:13 +02:00
include_once __DIR__ . '/../core.php' ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
2020-08-20 15:59:13 +02:00
// Compatibilità per controller ed editor
2024-03-05 16:01:45 +01:00
$structure = Module :: find ( $id_module );
2020-08-20 15:59:13 +02:00
echo '
2020-08-25 09:29:32 +02:00
< p > '.tr(' Trascina le colonne per ordinare la struttura della tabella principale , seleziona e deseleziona le colonne per renderle visibili o meno ').' .</ p >
2020-08-20 15:59:13 +02:00
< div class = " sortable " > ' ;
2024-04-18 17:44:05 +02:00
$fields = $dbo -> fetchArray ( 'SELECT *, (SELECT GROUP_CONCAT(`zz_groups_lang`.`title`) FROM `zz_group_view` INNER JOIN `zz_groups` ON `zz_group_view`.`id_gruppo` = `zz_groups`.`id` LEFT JOIN `zz_groups_lang` ON (`zz_groups`.`id` = `zz_groups_lang`.`id_record` AND `zz_groups_lang`.`id_lang` = ' . prepare ( Models\Locale :: getDefault () -> id ) . ') WHERE `zz_group_view`.`id_vista` = `zz_views`.`id`) AS gruppi_con_accesso FROM `zz_views` LEFT JOIN `zz_views_lang` ON (`zz_views`.`id` = `zz_views_lang`.`id_record` AND `zz_views_lang`.`id_lang` = ' . prepare ( Models\Locale :: getDefault () -> id ) . ') WHERE `id_module`=' . prepare ( $id_module ) . ' ORDER BY `order` ASC' );
2020-08-20 15:59:13 +02:00
foreach ( $fields as $field ) {
echo '
< div class = " panel panel-default clickable col-md-4 " data - id = " '. $field['id'] .' " >
2021-07-20 20:48:02 +02:00
< div class = " panel-body no-selection " >
2020-08-25 09:29:32 +02:00
< input type = " checkbox " name = " visibile " '.($field[' visible '] ? ' checked ' : ' ').' >
2020-08-20 15:59:13 +02:00
2021-06-10 19:31:39 +02:00
< span class = " text-'.( $field['visible'] ? 'success' : 'danger').' " > '.$field[' name '].' < br >< small > ( '.$field[' gruppi_con_accesso '].' ) </ small ></ span >
2020-08-20 15:59:13 +02:00
< i class = " fa fa-sort pull-right " ></ i >
</ div >
</ div > ' ;
}
echo '
</ div >
< div class = " clearfix " ></ div >
< script >
2020-08-25 09:29:32 +02:00
// Abilitazione dinamica delle colonne
$ ( " input[name=visibile] " ) . change ( function () {
let panel = $ ( this ) . closest ( " .panel[data-id] " );
let id = panel . data ( " id " );
// Aggiornamento effettivo
$ . post ( globals . rootdir + " /actions.php " , {
2020-12-22 16:11:48 +01:00
id_module : " '. $id_module .' " ,
op : " toggle_colonna " ,
2020-08-25 09:29:32 +02:00
id_vista : id ,
visible : $ ( this ) . is ( " :checked " ) ? 1 : 0 ,
});
// Aggiornamento grafico
let text = panel . find ( " span " );
if ( $ ( this ) . is ( " :checked " )) {
text . removeClass ( " text-danger " )
. addClass ( " text-success " );
} else {
text . removeClass ( " text-success " )
. addClass ( " text-danger " );
}
});
// Ricaricamento della pagina alla chiusura
$ ( " #modals > div button.close " ) . on ( " click " , function () {
location . reload ();
});
// Ordinamento dinamico delle colonne
2020-08-20 15:59:13 +02:00
$ ( document ) . ready ( function () {
2021-07-20 20:48:02 +02:00
sortable ( " .sortable " , {
axis : " y " ,
cursor : " move " ,
dropOnEmpty : true ,
scroll : true ,
})[ 0 ] . addEventListener ( " sortupdate " , function ( e ) {
let order = $ ( " .panel[data-id] " ) . toArray () . map ( a => $ ( a ) . data ( " id " ))
console . log ( order );
2020-08-20 15:59:13 +02:00
2021-07-20 20:48:02 +02:00
$ . post ( globals . rootdir + " /actions.php " , {
id_module : globals . id_module ,
op : " ordina_colonne " ,
order : order . join ( " , " ),
2020-08-20 15:59:13 +02:00
});
});
});
</ script > ' ;