2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/core.php' ;
if ( empty ( $id_record ) && ! empty ( $id_module )) {
redirect ( ROOTDIR . '/controller.php?id_module=' . $id_module );
} elseif ( empty ( $id_record ) && empty ( $id_module )) {
redirect ( ROOTDIR . '/index.php' );
}
2018-06-26 09:41:43 +02:00
include_once App :: filepath ( 'include|custom|' , 'top.php' );
2017-08-04 16:28:16 +02:00
2018-07-18 16:12:25 +02:00
// Inclusione gli elementi fondamentali
include_once $docroot . '/actions.php' ;
2017-08-04 16:28:16 +02:00
2018-02-22 12:35:22 +01:00
// Widget in alto
echo '{( "name": "widgets", "id_module": "' . $id_module . '", "id_record": "' . $id_record . '", "position": "top", "place": "editor" )}' ;
2018-07-08 18:11:17 +02:00
$advanced_sessions = setting ( 'Attiva notifica di presenza utenti sul record' );
2018-08-28 15:54:29 +02:00
if ( ! empty ( $advanced_sessions )) {
2018-08-10 17:14:09 +02:00
$dbo -> query ( 'DELETE FROM zz_semaphores WHERE id_utente=' . prepare ( Auth :: user ()[ 'id' ]) . ' AND posizione=' . prepare ( $id_module . ', ' . $id_record ));
2018-07-18 16:12:25 +02:00
2018-08-10 17:14:09 +02:00
$dbo -> query ( 'INSERT INTO zz_semaphores (id_utente, posizione, updated) VALUES (' . prepare ( Auth :: user ()[ 'id' ]) . ', ' . prepare ( $id_module . ', ' . $id_record ) . ', NOW())' );
2017-08-04 16:28:16 +02:00
echo '
< div class = " box box-warning box-solid text-center info-active hide " >
< div class = " box-header with-border " >
2017-09-04 12:02:29 +02:00
< h3 class = " box-title " >< i class = " fa fa-warning " ></ i > '.tr(' Attenzione ! ').' </ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " box-body " >
2017-09-04 12:02:29 +02:00
< p > '.tr(' I seguenti utenti stanno visualizzando questa pagina ').' :</ p >
2017-08-04 16:28:16 +02:00
< ul class = " list " >
</ ul >
2017-09-04 12:02:29 +02:00
< p > '.tr(' Prestare attenzione prima di effettuare modifiche , poichè queste potrebbero essere perse a causa di multipli salvataggi contemporanei ').' .</ p >
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
}
2018-07-18 15:20:10 +02:00
if ( empty ( $record )) {
2017-08-04 16:28:16 +02:00
echo '
2017-09-04 12:02:29 +02:00
< p > '.tr(' Record non trovato ').' .</ p > ' ;
2017-08-04 16:28:16 +02:00
} else {
echo '
< div class = " nav-tabs-custom " >
2017-10-08 18:28:26 +02:00
< ul class = " nav nav-tabs pull-right " id = " tabs " role = " tablist " >
2018-07-18 16:12:25 +02:00
< li class = " pull-left active header " >
2017-08-05 21:31:18 +02:00
< a data - toggle = " tab " href = " #tab_0 " >
2018-09-19 10:44:32 +02:00
< i class = " '. $structure['icon'] .' " ></ i > '.$structure[' title ' ];
2018-07-18 16:12:25 +02:00
2017-10-08 18:28:26 +02:00
// Pulsante "Aggiungi" solo se il modulo è di tipo "table" e se esiste il template per la popup
2018-09-19 10:44:32 +02:00
if ( $structure -> hasAddFile () && $structure -> permission == 'rw' ) {
2017-10-08 18:28:26 +02:00
echo '
2018-07-18 16:12:25 +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 .' " >< i class = " fa fa-plus " ></ i ></ button > ' ;
2017-10-08 18:28:26 +02:00
}
2018-07-18 16:12:25 +02:00
2017-09-05 17:31:58 +02:00
echo '
2017-08-05 21:31:18 +02:00
</ a >
2017-08-04 16:28:16 +02:00
</ li > ' ;
2018-07-13 20:17:20 +02:00
// Tab per le informazioni sulle operazioni
if ( Auth :: admin ()) {
echo '
2018-07-14 10:59:14 +02:00
< li class = " bg-warning " >
2018-07-13 20:17:20 +02:00
< a data - toggle = " tab " href = " #tab_info " id = " link-tab_info " > '.tr(' Info ').' </ a >
</ li > ' ;
}
2018-02-07 17:15:19 +01:00
$plugins = $dbo -> fetchArray ( 'SELECT id, title FROM zz_plugins WHERE idmodule_to=' . prepare ( $id_module ) . " AND position='tab' AND enabled = 1 ORDER BY zz_plugins.order DESC " );
2017-10-08 18:28:26 +02:00
2018-07-13 20:17:20 +02:00
// Tab dei plugin
2017-08-04 16:28:16 +02:00
foreach ( $plugins as $plugin ) {
echo '
< li >
< a data - toggle = " tab " href = " #tab_'. $plugin['id'] .' " id = " link-tab_'. $plugin['id'] .' " > '.$plugin[' title '].' </ a >
</ li > ' ;
}
echo '
</ ul >
< div class = " tab-content " >
2018-02-10 17:24:16 +01:00
< div id = " tab_0 " class = " tab-pane active " > ' ;
2017-08-04 16:28:16 +02:00
2018-02-22 11:07:52 +01:00
// Pulsanti di default
2018-02-22 10:32:51 +01:00
echo '
2018-02-23 09:49:31 +01:00
< div id = " pulsanti " >
2018-02-22 10:32:51 +01:00
< a class = " btn btn-warning " href = " '.ROOTDIR.'/controller.php?id_module='. $id_module .' " >
< i class = " fa fa-chevron-left " ></ i > '.tr("Torna all' elenco " ).'
</ a >
< div class = " pull-right " >
{( " name " : " button " , " type " : " print " , " id_module " : " '. $id_module .' " , " id_record " : " '. $id_record .' " )}
{( " name " : " button " , " type " : " email " , " id_module " : " '. $id_module .' " , " id_record " : " '. $id_record .' " )}
< a class = " btn btn-success " id = " save " >
2018-05-19 00:50:06 +02:00
< i class = " fa fa-check " ></ i > '.tr(' Salva ').'
2018-02-22 10:32:51 +01:00
</ a >
</ div >
</ div >
< script >
$ ( document ) . ready ( function (){
2018-02-22 11:07:52 +01:00
var form = $ ( " #module-edit " ) . find ( " form " ) . first ();
2018-02-22 10:32:51 +01:00
// Aggiunta del submit
form . prepend ( \ ' < button type = " submit " id = " submit " class = " hide " ></ button > \ ' );
$ ( " #save " ) . click ( function (){
$ ( " #submit " ) . trigger ( " click " );
2018-02-23 09:49:31 +01:00
}); ' ;
// Pulsanti dinamici
if ( ! isMobile ()) {
echo '
$ ( " #pulsanti " ) . affix ({
offset : {
top : 200
}
2018-02-22 10:32:51 +01:00
});
2018-06-22 17:04:37 +02:00
if ( $ ( " #pulsanti " ) . hasClass ( " affix " )) {
$ ( " #pulsanti " ) . css ( " width " , $ ( " #tab_0 " ) . css ( " width " ));
}
2018-02-22 10:32:51 +01:00
$ ( " #pulsanti " ) . on ( " affix.bs.affix " , function (){
$ ( " #pulsanti " ) . css ( " width " , $ ( " #tab_0 " ) . css ( " width " ));
});
$ ( " #pulsanti " ) . on ( " affix-top.bs.affix " , function (){
$ ( " #pulsanti " ) . css ( " width " , " 100% " );
2018-02-23 09:49:31 +01:00
}); ' ;
}
echo '
2018-02-22 10:32:51 +01:00
});
</ script >
< div class = " clearfix " ></ div >
< br > ' ;
2018-02-22 11:07:52 +01:00
// Pulsanti personalizzati
2018-09-19 10:44:32 +02:00
$buttons = $structure -> filepath ( 'buttons.php' );
2018-02-22 11:07:52 +01:00
if ( ! empty ( $buttons )) {
2018-07-19 12:47:28 +02:00
ob_start ();
include $buttons ;
$buttons = ob_get_clean ();
2018-02-22 11:07:52 +01:00
echo '
< div class = " pull-right " id = " pulsanti-modulo " >
'.$buttons.'
</ div >
< div class = " clearfix " ></ div >
< br > ' ;
}
// Contenuti del modulo
echo '
< div id = " module-edit " > ' ;
2018-09-19 10:44:32 +02:00
include $structure -> getEditFile ();
2017-08-04 16:28:16 +02:00
echo '
2018-02-22 11:07:52 +01:00
</ div >
</ div > ' ;
2017-08-04 16:28:16 +02:00
2018-02-10 17:24:16 +01:00
// Campi personalizzati
echo '
2018-02-22 11:07:52 +01:00
< div class = " hide " id = " custom_fields_top-edit " >
{( " name " : " custom_fields " , " id_module " : " '. $id_module .' " , " id_record " : " '. $id_record .' " , " position " : " top " )}
</ div >
2018-02-10 17:24:16 +01:00
2018-02-22 11:07:52 +01:00
< div class = " hide " id = " custom_fields_bottom-edit " >
{( " name " : " custom_fields " , " id_module " : " '. $id_module .' " , " id_record " : " '. $id_record .' " )}
</ div >
2018-02-10 17:24:16 +01:00
2018-02-22 11:07:52 +01:00
< script >
$ ( document ) . ready ( function (){
var form = $ ( " #custom_fields_top-edit " ) . parent () . find ( " form " ) . first ();
2018-02-10 17:24:16 +01:00
2018-02-22 11:07:52 +01:00
// Campi a inizio form
form . prepend ( $ ( " #custom_fields_top-edit " ) . html ());
2018-02-15 17:30:42 +01:00
2018-02-22 11:07:52 +01:00
// Campi a fine form
var last = form . find ( " .panel " ) . last ();
if ( ! last . length ) {
last = form . find ( " .row " ) . eq ( - 2 );
}
2018-02-15 17:30:42 +01:00
2018-02-22 11:07:52 +01:00
last . after ( $ ( " #custom_fields_bottom-edit " ) . html ());
});
</ script > ' ;
2018-02-10 17:24:16 +01:00
2018-07-13 20:17:20 +02:00
// Informazioni sulle operazioni
if ( Auth :: admin ()) {
echo '
< div id = " tab_info " class = " tab-pane " >
2018-07-14 10:59:14 +02:00
< ul class = " timeline " > ' ;
2018-07-13 20:17:20 +02:00
2018-07-14 10:59:14 +02:00
$operations = $dbo -> fetchArray ( 'SELECT `zz_operations`.*, `zz_users`.`username` FROM `zz_operations` JOIN `zz_users` ON `zz_operations`.`id_utente` = `zz_users`.`id` WHERE id_module = ' . prepare ( $id_module ) . ' AND id_record = ' . prepare ( $id_record ) . ' ORDER BY `created_at` ASC LIMIT 200' );
2018-07-13 20:17:20 +02:00
foreach ( $operations as $operation ) {
2018-07-14 10:59:14 +02:00
$description = $operation [ 'op' ];
$icon = 'pencil-square-o' ;
$color = null ;
$timeline = null ;
switch ( $operation [ 'op' ]) {
case 'add' :
$description = tr ( 'Creazione' );
$icon = 'plus' ;
$color = 'success' ;
break ;
case 'update' :
$description = tr ( 'Modifica' );
$icon = 'pencil' ;
$color = 'info' ;
break ;
case 'delete' :
$description = tr ( 'Eliminazione' );
$icon = 'times' ;
$color = 'danger' ;
break ;
default :
$timeline = ' class="timeline-inverted"' ;
break ;
}
2018-07-13 20:17:20 +02:00
echo '
2018-07-14 10:59:14 +02:00
< li '.$timeline.' >
< div class = " timeline-badge '. $color .' " >< i class = " fa fa-'. $icon .' " ></ i ></ div >
< div class = " timeline-panel " >
< div class = " timeline-heading " >
< h4 class = " timeline-title " > '.$description.' </ h4 >
< p >< small class = " text-muted " >< i class = " fa fa-clock-o " ></ i > '.Translator::timestampToLocale($operation[' created_at ']).' </ small ></ p >
</ div >
< div class = " timeline-body " >
< p > '.tr(' Utente : _USER_ ' , [
'_USER_' => $operation [ 'username' ],
]) . ' </ p >
</ div >
</ div >
</ li > ' ;
2018-07-13 20:17:20 +02:00
}
echo '
</ ul >
</ div > ' ;
}
// Plugin
2018-07-18 15:20:10 +02:00
$module_record = $record ;
2017-08-04 16:28:16 +02:00
foreach ( $plugins as $plugin ) {
2018-07-18 15:20:10 +02:00
$record = $module_record ;
2017-08-04 16:28:16 +02:00
echo '
< div id = " tab_'. $plugin['id'] .' " class = " tab-pane " > ' ;
$id_plugin = $plugin [ 'id' ];
include $docroot . '/include/manager.php' ;
echo '
</ div > ' ;
}
2018-07-18 15:20:10 +02:00
$record = $module_record ;
2017-08-04 16:28:16 +02:00
echo '
</ div >
</ div > ' ;
}
2018-07-09 12:57:55 +02:00
redirectOperation ( $id_module , isset ( $id_parent ) ? $id_parent : $id_record );
2017-08-04 16:28:16 +02:00
2018-02-22 12:35:22 +01:00
// Widget in basso
echo '{( "name": "widgets", "id_module": "' . $id_module . '", "id_record": "' . $id_record . '", "position": "right", "place": "editor" )}' ;
2017-08-04 16:28:16 +02:00
echo '
< hr >
2018-02-22 10:32:51 +01:00
< a href = " '.ROOTDIR.'/controller.php?id_module='. $id_module .' " >
< i class = " fa fa-chevron-left " ></ i > '.tr(' Indietro ').'
</ a > ' ;
2017-08-04 16:28:16 +02:00
echo '
2018-07-02 15:41:38 +02:00
< script > ' ;
2017-08-04 16:28:16 +02:00
// Se l'utente ha i permessi in sola lettura per il modulo, converto tutti i campi di testo in span
2018-09-19 10:44:32 +02:00
$read_only = $structure -> permission == 'r' ;
2018-07-09 16:12:27 +02:00
if ( $read_only || ! empty ( $block_edit )) {
$not = $read_only ? '' : '.not(".unblockable")' ;
2018-07-04 12:57:53 +02:00
echo '
$ ( document ) . ready ( function (){
$ ( " input, textarea, select " , " section.content " ) '.$not.' . attr ( " readonly " , " true " );
2018-07-09 16:12:27 +02:00
$ ( " select, input[type=checkbox] " , " section.content " ) '.$not.' . prop ( " disabled " , true ); ' ;
if ( $read_only ) {
echo '
$ ( " a.btn, button, input[type=button], input[type=submit] " , " section.content " ) . hide ();
$ ( " a.btn-info, a.btn-warning, button.btn-info, button.btn-warning, input[type=button].btn-info " , " section.content " ) . show (); ' ;
}
2018-07-04 12:57:53 +02:00
2018-07-09 16:12:27 +02:00
echo '
2018-07-04 12:57:53 +02:00
}); ' ;
}
?>
2017-08-04 16:28:16 +02:00
2018-07-02 15:41:38 +02:00
var content_was_modified = false ;
//controllo se digito qualche valore o cambio qualche select
$ ( " input, textarea, select " ) . bind ( " change paste keyup " , function ( event ) {
if ( event . keyCode >= 32 ){
content_was_modified = true ;
}
});
//tolgo il controllo se sto salvando
$ ( " .btn-success, button[type=submit] " ) . bind ( " click " , function () {
content_was_modified = false ;
});
2018-08-10 17:14:09 +02:00
2018-07-31 19:20:19 +02:00
$ ( " form " ) . bind ( " submit " , function () {
content_was_modified = false ;
})
2018-07-02 15:41:38 +02:00
2018-07-26 13:10:16 +02:00
// questo controllo blocca il modulo vendita al banco, dopo la lettura con barcode, appare il messaggio di conferma
window . onbeforeunload = function ( e ){
2018-07-02 15:41:38 +02:00
if ( content_was_modified ) {
2018-07-26 13:10:16 +02:00
var dialogText = " Uscire senza salvare? " ;
e . returnValue = dialogText ;
$ ( " #main_loading " ) . fadeOut ();
return dialogText ;
2018-07-02 15:41:38 +02:00
}
};
2018-08-10 17:14:09 +02:00
2018-07-26 14:54:30 +02:00
window . addEventListener ( " unload " , function ( e ) {
2018-07-26 16:19:34 +02:00
//console.log(e);
2018-07-26 14:54:30 +02:00
$ ( " #main_loading " ) . show ();
});
2018-08-10 17:14:09 +02:00
2018-07-26 13:10:16 +02:00
2017-08-04 16:28:16 +02:00
< ? php
2018-08-28 15:54:29 +02:00
if ( ! empty ( $advanced_sessions )) {
2018-07-07 13:56:22 +02:00
?>
2017-08-04 16:28:16 +02:00
2018-07-02 15:41:38 +02:00
function getActiveUsers (){
2018-08-28 15:54:29 +02:00
$ . getJSON ( '<?php echo ROOTDIR; ?>/ajax.php?op=active_users' , {
2018-07-02 15:41:38 +02:00
id_module : < ? php echo $id_module ; ?> ,
id_record : < ? php echo $id_record ; ?>
},
function ( data ) {
if ( data . length != 0 ) {
$ ( " .info-active " ) . removeClass ( " hide " );
$ ( " .info-active .list " ) . html ( " " );
$ . each ( data , function ( key , val ) {
$ ( " .info-active .list " ) . append ( " <li> " + val . username + " </li> " );
});
}
else $ ( " .info-active " ) . addClass ( " hide " );
});
}
2017-08-04 16:28:16 +02:00
2018-07-02 15:41:38 +02:00
getActiveUsers ();
2017-08-04 16:28:16 +02:00
2018-08-28 15:54:29 +02:00
setInterval ( getActiveUsers , < ? php echo setting ( 'Timeout notifica di presenza (minuti)' ) * 60 * 1000 ; ?> );
2017-08-04 16:28:16 +02:00
< ? php
2018-07-07 13:56:22 +02:00
}
2017-08-04 16:28:16 +02:00
?>
2018-07-02 15:41:38 +02:00
</ script >
2017-08-04 16:28:16 +02:00
< ? php
2018-06-26 09:41:43 +02:00
include_once App :: filepath ( 'include|custom|' , 'bottom.php' );