2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../core.php';
|
|
|
|
|
|
|
|
// Lettura parametri iniziali del modulo
|
|
|
|
if (!empty($id_plugin)) {
|
2018-02-14 11:10:03 +01:00
|
|
|
$element = Plugins::get($id_plugin);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-02-14 11:10:03 +01:00
|
|
|
if (!empty($element['script'])) {
|
2017-08-04 16:28:16 +02:00
|
|
|
// Inclusione di eventuale plugin personalizzato
|
2018-02-14 11:10:03 +01:00
|
|
|
if (file_exists($docroot.'/modules/'.$element['module_dir'].'/plugins/custom/'.$element['script'])) {
|
|
|
|
include $docroot.'/modules/'.$element['module_dir'].'/plugins/custom/'.$element['script'];
|
|
|
|
} elseif (file_exists($docroot.'/modules/'.$element['module_dir'].'/plugins/'.$element['script'])) {
|
|
|
|
include $docroot.'/modules/'.$element['module_dir'].'/plugins/'.$element['script'];
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<h4>
|
2018-02-14 11:10:03 +01:00
|
|
|
'.$element['name'];
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-02-14 11:10:03 +01:00
|
|
|
if (file_exists($docroot.'/plugins/'.$element['directory'].'/add.php')) {
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2017-09-04 12:02:29 +02:00
|
|
|
<button type="button" class="btn btn-primary" data-toggle="modal" data-title="'.tr('Aggiungi').'..." data-target="#bs-popup" 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-02-14 11:10:03 +01:00
|
|
|
$directory = '/plugins/'.$element['directory'];
|
2017-08-04 16:28:16 +02:00
|
|
|
} else {
|
2018-02-14 11:10:03 +01:00
|
|
|
$element = Modules::get($id_module);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-02-14 11:10:03 +01:00
|
|
|
$directory = '/modules/'.$element['directory'];
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
2018-02-14 11:10:03 +01:00
|
|
|
$total = App::readQuery($element);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-02-14 11:10:03 +01:00
|
|
|
$module_options = (!empty($element['options2'])) ? $element['options2'] : $element['options'];
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Caricamento file aggiuntivo su elenco record
|
|
|
|
if (file_exists($docroot.$directory.'/custom/controller_before.php')) {
|
|
|
|
include $docroot.$directory.'/custom/controller_before.php';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/controller_before.php')) {
|
|
|
|
include $docroot.$directory.'/controller_before.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Datatables con record
|
|
|
|
*/
|
|
|
|
if (!empty($module_options) && $module_options != 'menu' && $module_options != 'custom') {
|
|
|
|
$table_id = 'main_'.rand(0, 99);
|
|
|
|
echo '
|
|
|
|
<table data-idmodule="'.$id_module.'" data-idplugin="'.$id_plugin.'" data-idparent="'.$id_record.'" id="'.$table_id.'" width="100%" class="main-records table table-condensed table-bordered">
|
|
|
|
<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);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<th'.$attr_td.' id="th_'.str_replace([' ', '.'], ['-', ''], $name).'"';
|
|
|
|
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>';
|
|
|
|
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.'">
|
|
|
|
<div class="col-xs-12 col-md-5">
|
|
|
|
<div class="btn-group" role="group">
|
2017-09-04 12:02:29 +02:00
|
|
|
<button type="button" class="btn btn-primary btn-select-all">'.tr('Seleziona tutto').'</button>
|
|
|
|
<button type="button" class="btn btn-default btn-select-none">'.tr('Deseleziona tutto').'</button>
|
2017-08-04 16:28:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-xs-12 col-md-2 dropdown">';
|
|
|
|
|
|
|
|
if (!empty($bulk)) {
|
|
|
|
echo '
|
2017-09-04 12:02:29 +02:00
|
|
|
<button class="btn btn-primary btn-block dropdown-toggle bulk-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;
|
|
|
|
|
|
|
|
$data = is_array($value) ? $value['data'] : [];
|
|
|
|
$extra = [];
|
|
|
|
foreach ($data as $k => $v) {
|
|
|
|
$extra[] = 'data-'.$k.'="'.$v.'"';
|
|
|
|
}
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2017-09-07 16:51:14 +02:00
|
|
|
<li role="presentation"><a class="bulk-action" data-op="'.$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>
|
|
|
|
|
|
|
|
<div class="col-xs-12 col-md-5 text-right">
|
|
|
|
<div class="btn-group" role="group">
|
2017-09-04 12:02:29 +02:00
|
|
|
<button type="button" class="btn btn-primary btn-csv disabled" disabled>'.tr('Esporta').'</button>
|
|
|
|
<button type="button" class="btn btn-default btn-copy disabled" disabled>'.tr('Copia').'</button>
|
|
|
|
<button type="button" class="btn btn-default btn-print disabled" disabled>'.tr('Stampa').'</button>
|
2017-08-04 16:28:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Inclusione modulo personalizzato
|
|
|
|
*/
|
|
|
|
elseif ($module_options == 'custom') {
|
|
|
|
// Lettura template modulo (verifico se ci sono template personalizzati, altrimenti uso quello base)
|
|
|
|
if (file_exists($docroot.$directory.'/custom/edit.php')) {
|
|
|
|
include $docroot.$directory.'/custom/edit.php';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/custom/edit.html')) {
|
|
|
|
include $docroot.$directory.'/custom/edit.html';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/edit.php')) {
|
|
|
|
include $docroot.$directory.'/edit.php';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/edit.html')) {
|
|
|
|
include $docroot.$directory.'/edit.html';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Caricamento file aggiuntivo su elenco record
|
|
|
|
if (file_exists($docroot.$directory.'/custom/controller_after.php')) {
|
|
|
|
include $docroot.$directory.'/custom/controller_after.php';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/controller_after.php')) {
|
|
|
|
include $docroot.$directory.'/controller_after.php';
|
|
|
|
}
|