2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2019-02-01 17:44:31 +01:00
use Models\Module ;
2018-07-08 18:11:17 +02:00
$enable_readonly = ! setting ( 'Modifica Viste di default' );
2017-08-04 16:28:16 +02:00
echo '
< form action = " " method = " post " role = " form " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
<!-- DATI -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2019-05-10 23:47:45 +02:00
< h3 class = " panel-title " > '.tr(' Opzioni generali ').' </ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " > ' ;
$options = ( $record [ 'options2' ] == '' ) ? $record [ 'options' ] : $record [ 'options2' ];
if ( $options == 'menu' ) {
echo '
2017-09-04 12:02:29 +02:00
< p >< strong > '.tr(' Il modulo che stai analizzando è un semplice menu ').' .</ strong ></ p > ' ;
2017-08-04 16:28:16 +02:00
} elseif ( $options == 'custom' ) {
echo '
2017-09-04 12:02:29 +02:00
< p >< strong > '.tr("Il modulo che stai analizzando possiede una struttura complessa, che prevede l' utilizzo di file personalizzati per la gestione delle viste " ).'.</strong></p>';
2017-08-04 16:28:16 +02:00
}
echo '
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " text " , " label " : " '.tr('Codice del modulo').' " , " name " : " name " , " value " : " '. $record['name'] .' " , " readonly " : " 1 " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-08 18:43:47 +02:00
{[ " type " : " text " , " label " : " '.tr('Nome del modulo').' " , " name " : " title " , " value " : " '. $record['title'] .' " , " help " : " '.tr('Il nome che identifica il modulo').' " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-12-22 11:55:55 +01:00
{[ " type " : " textarea " , " label " : " '.tr('Query di default').' " , " name " : " options " , " value " : '.json_encode(str_replace(' ]} ', ' ] } ', $record[' options '])).' , " readonly " : " 1 " , " class " : " autosize " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-12-22 11:55:55 +01:00
{[ " type " : " textarea " , " label " : " '.tr('Query personalizzata').' " , " name " : " options2 " , " value " : '.json_encode(str_replace(' ]} ', ' ] } ', $record[' options2 '])).' , " class " : " autosize " , " help " : " '.tr('La query in sostituzione a quella di default: custom, menu oppure SQL').' " ]}
2017-08-04 16:28:16 +02:00
</ div >
2017-12-22 11:55:55 +01:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
if ( $options != '' && $options != 'menu' && $options != 'custom' ) {
2019-02-01 17:44:31 +01:00
$module_query = Util\Query :: getQuery ( Module :: find ( $id_record ));
2017-08-28 15:29:03 +02:00
2017-08-04 16:28:16 +02:00
echo '
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-12 " >
2017-09-04 12:02:29 +02:00
< p >< strong > '.tr(' Query risultante ').' :</ strong ></ p >
2017-09-13 13:05:35 +02:00
< p > '.htmlentities($module_query).' </ p >
< div class = " row " >
< div class = " col-md-12 text-right " >
2018-06-29 17:26:48 +02:00
< button type = " button " class = " btn btn-warning " onclick = " testQuery() " >
< i class = " fa fa-file-text-o " ></ i > '.tr(' Testa la query ').'
</ button >
< button type = " submit " class = " btn btn-success " >
< i class = " fa fa-check " ></ i > '.tr(' Salva ').'
</ button >
2017-09-13 13:05:35 +02:00
</ div >
</ div >
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
}
echo '
</ div >
</ div >
</ form > ' ;
2018-12-29 04:53:21 +01:00
if ( ! empty ( $options ) && $options != 'custom' && $options != 'menu' ) {
2017-08-04 16:28:16 +02:00
echo '
2019-05-10 23:47:45 +02:00
< div class = " nav-tabs-custom " >
< ul class = " nav nav-tabs nav-justified " >
< li class = " active " >< a data - toggle = " tab " href = " #fields " > '.tr(' Campi ').' </ a ></ li >
< li >< a data - toggle = " tab " href = " #filters " > '.tr(' Filtri ').' </ a ></ li >
</ ul >
2017-08-04 16:28:16 +02:00
2019-05-10 23:47:45 +02:00
< div class = " tab-content " >
2017-08-04 16:28:16 +02:00
2019-05-10 23:47:45 +02:00
<!-- CAMPI -->
< div id = " fields " class = " tab-pane fade in active " > ' ;
2018-07-19 09:58:28 +02:00
2019-05-10 23:47:45 +02:00
include $module -> filepath ( 'fields.php' );
2017-08-04 16:28:16 +02:00
echo '
2019-05-10 23:47:45 +02:00
</ div >
2017-08-04 16:28:16 +02:00
2019-05-10 23:47:45 +02:00
<!-- FILTRI -->
< div id = " filters " class = " tab-pane fade " > ' ;
2018-07-19 09:58:28 +02:00
2019-05-10 23:47:45 +02:00
include $module -> filepath ( 'filters.php' );
2018-07-19 09:58:28 +02:00
2017-08-04 16:28:16 +02:00
echo '
</ div >
2018-07-19 09:58:28 +02:00
</ div >
2019-05-10 23:47:45 +02:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
echo '
< script >
2017-09-13 13:05:35 +02:00
function testQuery (){
$ ( " #main_loading " ) . fadeIn ();
$ . ajax ({
url : " '.ROOTDIR.'/actions.php?id_module= " + globals . id_module + " &id_record= " + globals . id_record + " &op=test " ,
cache : false ,
type : " post " ,
processData : false ,
contentType : false ,
dataType : " html " ,
success : function ( data ) {
$ ( " #main_loading " ) . fadeOut ();
swal ( " '.tr('Query funzionante').' " , " '.tr('La query attuale funziona correttamente!').' " , " success " );
},
error : function ( data ) {
$ ( " #main_loading " ) . fadeOut ();
swal ( " '.tr('Errore').' " , " '.tr('Errore durante il test della query!').' " , " error " );
}
})
}
2017-08-04 16:28:16 +02:00
</ script > ' ;
2018-11-30 16:10:15 +01:00
}