2017-08-04 16:28:16 +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 />.
*/
2017-08-04 16:28:16 +02:00
2020-10-16 17:23:44 +02:00
use HTMLBuilder\HTMLBuilder ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
use Models\Plugin ;
2020-10-16 17:23:44 +02:00
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../core.php' ;
2018-09-19 10:44:32 +02:00
// Compatibilità per controller ed editor
2017-08-04 16:28:16 +02:00
if ( ! empty ( $id_plugin )) {
2024-03-05 16:01:45 +01:00
$structure = Plugin :: find ( $id_plugin );
2018-07-18 16:12:25 +02:00
} else {
2024-03-05 16:01:45 +01:00
$structure = Module :: find ( $id_module );
2018-07-18 16:12:25 +02:00
}
if ( ! empty ( $id_plugin )) {
2018-06-26 14:26:40 +02:00
// Inclusione di eventuale plugin personalizzato
2018-09-19 10:44:32 +02:00
if ( ! empty ( $structure [ 'script' ])) {
2021-04-26 09:53:41 +02:00
$path = $structure -> getEditFile ();
if ( ! empty ( $path )) {
include $path ;
}
2017-08-04 16:28:16 +02:00
return ;
}
echo '
< h4 >
2018-09-19 10:44:32 +02:00
< span class = " '.(!empty( $structure['help'] ) ? ' tip' : '').' " '.(!empty($structure[' help ']) ? ' title = " '.prepareToField( $structure['help'] ).' " data - position = " bottom " ' : ' ').' >
2024-03-22 17:11:33 +01:00
'.$structure->getTranslation(' title ').(!empty($structure[' help ']) ? ' < i class = " fa fa-question-circle-o " ></ i > ' : ' ').' </ span > ' ;
2017-08-04 16:28:16 +02:00
2018-09-19 10:44:32 +02:00
if ( $structure -> hasAddFile ()) {
2017-08-04 16:28:16 +02:00
echo '
2018-10-25 17:11:02 +02:00
< button type = " button " class = " btn btn-primary " data - toggle = " modal " data - title = " '.tr('Aggiungi').'... " data - href = " add.php?id_module='. $id_module .'&id_plugin='. $id_plugin .'&id_parent='. $id_record .' " >< i class = " fa fa-plus " ></ i ></ button > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
</ h4 > ' ;
}
2018-07-18 16:12:25 +02:00
2018-09-19 10:44:32 +02:00
$type = $structure [ 'option' ];
2017-08-04 16:28:16 +02:00
2018-07-09 12:57:55 +02:00
// Lettura risultato query del modulo
2018-09-19 10:44:32 +02:00
// include $structure->filepath('init.php');
2018-07-09 12:57:55 +02:00
2017-08-04 16:28:16 +02:00
// Caricamento file aggiuntivo su elenco record
2018-09-19 10:44:32 +02:00
$controller_before = $structure -> filepath ( 'controller_before.php' );
2018-07-19 12:47:28 +02:00
if ( ! empty ( $controller_before )) {
include $controller_before ;
}
2017-08-04 16:28:16 +02:00
2018-07-09 14:40:16 +02:00
/*
* Datatables con record
*/
2018-07-18 16:12:25 +02:00
if ( ! empty ( $type ) && $type != 'menu' && $type != 'custom' ) {
2019-02-01 17:44:31 +01:00
$total = Util\Query :: readQuery ( $structure );
2018-07-19 09:58:28 +02:00
2018-07-18 16:12:25 +02:00
if ( empty ( $id_plugin ) && count ( Modules :: getSegments ( $id_module )) > 1 ) {
2018-07-09 14:40:16 +02:00
echo '
2018-03-27 15:11:31 +02:00
< div class = " row " >
< div class = " col-md-4 pull-right " >
2022-11-28 09:27:25 +01:00
{[ " type " : " select " , " name " : " id_segment_ " , " required " : 0 , " ajax-source " : " segmenti " , " select-options " : '.json_encode([' id_module ' => $id_module]).' , " value " : " '. $_SESSION['module_'.$id_module] ['id_segment'].' " ]}
2018-03-27 15:11:31 +02:00
</ div >
</ div >
2018-07-09 14:40:16 +02:00
< br > ' ;
2018-03-27 15:11:31 +02:00
2018-07-09 14:40:16 +02:00
echo '
2018-03-27 15:11:31 +02:00
< script >
$ ( document ) . ready ( function () {
$ ( " #id_segment_ " ) . on ( " change " , function (){
2018-07-09 14:40:16 +02:00
if ( $ ( this ) . val () < 1 ){
2018-09-27 15:50:03 +02:00
session_set ( " module_'. $id_module .',id_segment " , " " , 1 , 1 );
2018-07-09 14:40:16 +02:00
} else {
2018-09-27 15:50:03 +02:00
session_set ( " module_'. $id_module .',id_segment " , $ ( this ) . val (), 0 , 1 );
2018-03-27 15:11:31 +02:00
}
});
});
2018-07-09 14:40:16 +02:00
</ script > ' ;
}
2018-03-27 15:11:31 +02:00
2020-07-08 21:12:16 +02:00
// Reset della selezione precedente
$_SESSION [ 'module_' . $id_module ][ 'selected' ] = [];
$selezione = array_keys ( $_SESSION [ 'module_' . $id_module ][ 'selected' ]);
2024-04-08 15:44:33 +02:00
$table_id = 'main_' . random_int ( 0 , 99 );
2017-08-04 16:28:16 +02:00
echo '
2023-05-20 01:19:26 +02:00
< table data - idmodule = " '. $id_module .' " data - idplugin = " '. $id_plugin .' " data - idparent = " '. $id_record .' " data - selected = " '.implode(';', $selezione ).' " id = " '. $table_id .' " width = " 100% " class = " main-records'.(!empty( $id_plugin ) ? '-plugins' : '').' table table-condensed table-bordered " >
2017-08-04 16:28:16 +02:00
< thead >
< tr >
< th id = " th_selector " ></ th > ' ;
foreach ( $total [ 'fields' ] as $key => $field ) {
$attr_td = '' ;
$name = trim ( $field );
// Check per tipologie di campi particolari
if ( preg_match ( '/^color_/' , $field )) {
$attr_td .= " width='140' " ;
$field = str_replace ( 'color_' , '' , $field );
}
// Data (larghezza fissa)
elseif ( preg_match ( '/^Data/' , $field )) {
$attr_td .= " width='100' " ;
}
// Icona di stampa
elseif ( trim ( $field ) == '_print_' ) {
$attr_td .= " width='30' " ;
$field = str_replace ( '_print_' , '' , $field );
} elseif ( preg_match ( '/^icon_/' , $field )) {
$attr_td .= " width='30' " ;
$name = str_replace ( 'icon_' , 'icon_title_' , $name );
$field = str_replace ( 'icon_' , '' , $field );
}
2023-05-26 13:16:15 +02:00
if ( isMobile ()) {
$attr_td .= " style='min-width:100px;' " ;
}
2017-08-04 16:28:16 +02:00
echo '
2018-09-27 10:15:04 +02:00
< th '.$attr_td.' id = " th_'.searchFieldName( $name ).' " ' ;
2017-08-04 16:28:16 +02:00
if ( $total [ 'search' ][ $key ] == 1 ) {
echo ' class="search"' ;
} else {
echo ' class="no-search"' ;
}
if ( $total [ 'slow' ][ $key ] == 1 ) {
echo ' data-slow="1"' ;
}
echo '>' . $field . '</th>' ;
}
echo '
</ tr >
</ thead >
< tbody >
</ tbody >
< tfoot >
< tr > ' ;
2018-04-20 15:50:57 +02:00
echo '
< td ></ td > ' ;
2017-08-04 16:28:16 +02:00
foreach ( $total [ 'fields' ] as $key => $field ) {
echo '
< td ></ td > ' ;
}
echo '
</ tr >
</ tfoot >
</ table > ' ;
2017-09-06 10:48:59 +02:00
echo '
2017-08-04 16:28:16 +02:00
< div class = " row " data - target = " '. $table_id .' " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-5 " >
2021-07-16 09:49:24 +02:00
< div class = " btn-group select-controller-container " role = " group " >
2017-09-04 12:02:29 +02:00
< button type = " button " class = " btn btn-primary btn-select-all " > '.tr(' Seleziona tutto ').' </ button >
2021-07-16 09:49:24 +02:00
< button type = " button " class = " btn btn-default btn-select-none " >
'.tr(' Deseleziona tutto ').'
< span class = " badge selected-count " > 0 </ span >
</ button >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-2 dropdown " > ' ;
2017-08-04 16:28:16 +02:00
2022-09-16 11:49:15 +02:00
if ( ! empty ( $bulk ) && $structure -> permission == 'rw' && empty ( $id_plugin )) {
2017-08-04 16:28:16 +02:00
echo '
2021-07-16 09:49:24 +02:00
< button class = " btn btn-primary btn-block dropdown-toggle actions-container disabled " type = " button " data - toggle = " dropdown " disabled > '.tr(' Azioni di gruppo ').' < span class = " caret " ></ span ></ button >
2017-08-04 16:28:16 +02:00
< ul class = " dropdown-menu " data - target = " '. $table_id .' " role = " menu " > ' ;
foreach ( $bulk as $key => $value ) {
2017-09-06 11:59:47 +02:00
$text = is_array ( $value ) ? $value [ 'text' ] : $value ;
2020-10-16 17:23:44 +02:00
$data = isset ( $value [ 'data' ]) && is_array ( $value [ 'data' ]) ? $value [ 'data' ] : [];
2017-09-06 11:59:47 +02:00
$extra = [];
foreach ( $data as $k => $v ) {
2020-10-16 17:23:44 +02:00
$extra [] = 'data-' . $k . '="' . prepareToField ( HTMLBuilder :: replace ( $v )) . '"' ;
2017-09-06 11:59:47 +02:00
}
2017-08-04 16:28:16 +02:00
echo '
2018-07-23 11:09:50 +02:00
< li role = " presentation " >< a class = " bulk-action clickable " data - op = " '.prepareToField( $key ).' " data - backto = " record-list " '.implode(' ', $extra).' > '.$text.' </ a ></ li > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
</ ul > ' ;
}
2017-09-06 11:59:47 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-5 text-right " >
2020-11-12 10:58:37 +01:00
< i class = " fa fa-question-circle-o tip " title = " '.tr('Le operazioni di esportazione, copia e stampa sono limitate alle righe selezionate e visibili della tabella').'. '.tr('Per azioni su tutti i contenuti selezionati, utilizzare le Azioni di gruppo').'. " ></ i >
2021-07-16 09:49:24 +02:00
< div class = " btn-group export-container " role = " group " > ' ;
2018-07-02 16:56:00 +02:00
2018-07-09 10:44:54 +02:00
if ( setting ( 'Abilita esportazione Excel e PDF' )) {
2018-07-02 16:56:00 +02:00
echo '
< div class = " btn-group " >
< button type = " button " class = " btn btn-primary table-btn btn-csv disabled " disabled > '.tr(' Esporta ').' </ button >
2021-07-16 09:49:24 +02:00
< button type = " button " class = " btn btn-primary table-btn disabled dropdown-toggle " data - toggle = " dropdown " aria - haspopup = " true " aria - expanded = " false " >
2018-07-02 16:56:00 +02:00
< span class = " caret " ></ span >
< span class = " sr-only " > Toggle Dropdown </ span >
</ button >
< ul class = " dropdown-menu " >
< li >< a class = " table-btn btn-pdf disabled " disabled > '.tr(' PDF ').' </ a ></ li >
< li >< a class = " table-btn btn-excel disabled " disabled > '.tr(' Excel ').' </ a ></ li >
</ ul >
</ div > ' ;
} else {
echo '
2021-07-16 09:49:24 +02:00
< button type = " button " class = " btn btn-primary table-btn btn-csv disabled " disabled > '.tr(' Esporta ').' </ button > ' ;
2018-07-02 16:56:00 +02:00
}
echo '
< button type = " button " class = " btn btn-default table-btn btn-copy disabled " disabled > '.tr(' Copia ').' </ button >
< button type = " button " class = " btn btn-default table-btn btn-print disabled " disabled > '.tr(' Stampa ').' </ button >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div > ' ;
}
/*
* Inclusione modulo personalizzato
*/
2018-07-18 16:12:25 +02:00
elseif ( $type == 'custom' ) {
2021-04-26 09:53:41 +02:00
$path = $structure -> getEditFile ();
if ( ! empty ( $path )) {
include $path ;
}
2017-08-04 16:28:16 +02:00
}
// Caricamento file aggiuntivo su elenco record
2018-09-19 10:44:32 +02:00
$controller_after = $structure -> filepath ( 'controller_after.php' );
2018-07-19 12:47:28 +02:00
if ( ! empty ( $controller_after )) {
include $controller_after ;
}