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
// Lettura parametri iniziali del modulo
2017-09-22 15:19:59 +02:00
$module = Modules :: get ( $id_module );
2017-08-04 16:28:16 +02:00
if ( empty ( $module ) || empty ( $module [ 'enabled' ])) {
2017-09-04 12:02:29 +02:00
die ( tr ( 'Accesso negato' ));
2017-08-04 16:28:16 +02:00
}
$module_dir = $module [ 'directory' ];
// Inclusione elementi fondamentali del modulo
include $docroot . '/actions.php' ;
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" )}' ;
2017-08-04 16:28:16 +02:00
$advanced_sessions = get_var ( 'Attiva notifica di presenza utenti sul record' );
if ( $advanced_sessions ) {
2018-07-08 15:41:38 +02:00
$dbo -> query ( 'DELETE FROM zz_semaphores WHERE id_utente=' . prepare ( Auth :: user ()[ 'id_utente' ]) . ' AND posizione=' . prepare ( $id_module . ', ' . $id_record ));
$dbo -> query ( 'INSERT INTO zz_semaphores (id_utente, posizione, updated) VALUES (' . prepare ( Auth :: user ()[ 'id_utente' ]) . ', ' . 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 > ' ;
}
if ( empty ( $records )) {
echo '
2017-09-04 12:02:29 +02:00
< p > '.tr(' Record non trovato ').' .</ p > ' ;
2017-08-04 16:28:16 +02:00
} else {
/*
* Lettura eventuali plugins modulo da inserire come tab
*/
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 " >
2017-08-04 16:28:16 +02:00
< li class = " pull-left active header " > ' ;
// Verifico se ho impostato un nome modulo personalizzato
$name = $module [ 'title' ];
echo '
2017-08-05 21:31:18 +02:00
< a data - toggle = " tab " href = " #tab_0 " >
< i class = " '. $module['icon'] .' " ></ i > ' . $name ;
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
if ( file_exists ( $docroot . '/modules/' . $module_dir . '/add.php' ) && $module [ 'permessi' ] == 'rw' ) {
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 .' " >< i class = " fa fa-plus " ></ i ></ button > ' ;
2017-10-08 18:28:26 +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-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
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
ob_start ();
2018-06-26 14:26:40 +02:00
include Modules :: filepath ( $id_module , 'buttons.php' );
2018-02-22 11:07:52 +01:00
$buttons = ob_get_clean ();
if ( ! empty ( $buttons )) {
echo '
< div class = " pull-right " id = " pulsanti-modulo " >
'.$buttons.'
</ div >
< div class = " clearfix " ></ div >
< br > ' ;
}
// Contenuti del modulo
echo '
< div id = " module-edit " > ' ;
2017-08-04 16:28:16 +02:00
// Lettura template modulo (verifico se ci sono template personalizzati, altrimenti uso quello base)
if ( file_exists ( $docroot . '/modules/' . $module_dir . '/custom/edit.php' )) {
include $docroot . '/modules/' . $module_dir . '/custom/edit.php' ;
} elseif ( file_exists ( $docroot . '/modules/' . $module_dir . '/custom/edit.html' )) {
include $docroot . '/modules/' . $module_dir . '/custom/edit.html' ;
} elseif ( file_exists ( $docroot . '/modules/' . $module_dir . '/edit.php' )) {
include $docroot . '/modules/' . $module_dir . '/edit.php' ;
} elseif ( file_exists ( $docroot . '/modules/' . $module_dir . '/edit.html' )) {
include $docroot . '/modules/' . $module_dir . '/edit.html' ;
}
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
2017-08-04 16:28:16 +02:00
foreach ( $plugins as $plugin ) {
echo '
< div id = " tab_'. $plugin['id'] .' " class = " tab-pane " > ' ;
$id_plugin = $plugin [ 'id' ];
include $docroot . '/include/manager.php' ;
echo '
</ div > ' ;
}
echo '
</ div >
</ div > ' ;
}
2017-09-08 13:24:48 +02:00
redirectOperation ( $id_module , $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-07-04 12:57:53 +02:00
if ( Modules :: getPermission ( $id_module ) == 'r' || ! empty ( $block_edit )) {
$not = ( Modules :: getPermission ( $id_module ) == 'r' ) ? '' : '.not(".unblockable")' ;
echo '
$ ( document ) . ready ( function (){
$ ( " input, textarea, select " , " section.content " ) '.$not.' . attr ( " readonly " , " true " );
$ ( " select, input[type=checkbox] " ) '.$not.' . prop ( " disabled " , true );
$ ( " a.btn, button, input[type=button], input[type=submit] " , " section.content " ) '.$not.' . hide ();
$ ( " a.btn-info, a.btn-warning, button.btn-info, button.btn-warning, input[type=button].btn-info " , " section.content " ) '.$not.' . show ();
}); ' ;
}
?>
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 ;
});
// questo controllo blocca il modulo vendita al banco, dopo la lettura con barcode, appare il messaggio di conferma
window . onbeforeunload = function (){
if ( content_was_modified ) {
return 'Uscire senza salvare?' ;
}
};
2017-08-04 16:28:16 +02:00
< ? php
if ( $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 (){
$ . getJSON ( '<?php echo ROOTDIR; ?>/call.php' , {
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-07-02 15:41:38 +02:00
setInterval ( getActiveUsers , < ? php echo get_var ( 'Timeout notifica di presenza (minuti)' ) * 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' );