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
2024-03-12 17:16:07 +01:00
use Models\Clause ;
2024-03-22 15:52:24 +01:00
use Models\Module ;
2024-03-12 17:16:07 +01:00
use Models\View ;
2020-04-27 10:26:40 +02:00
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2020-04-27 10:26:40 +02:00
$enable_readonly = ! setting ( 'Modifica Viste di default' );
2019-02-01 17:44:31 +01:00
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 " > ' ;
2024-03-25 17:34:39 +01:00
$options = ( $record -> options2 == '' ) ? $record -> options : $record -> options2 ;
2017-08-04 16:28:16 +02:00
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 " >
2024-03-25 17:34:39 +01:00
{[ " type " : " text " , " label " : " '.tr('Codice del modulo').' " , " name " : " name " , " value " : " '. $record->getTranslation ('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 " >
2024-03-25 17:34:39 +01:00
{[ " type " : " text " , " label " : " '.tr('Nome del modulo').' " , " name " : " title " , " value " : " '. $record->getTranslation ('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 " >
2024-03-25 17:34:39 +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 " >
2024-03-25 17:34:39 +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
2019-09-06 10:20:20 +02:00
$beautiful_query = nl2br ( htmlentities ( $module_query ));
2019-09-11 08:48:37 +02:00
$beautiful_query = str_replace ( ' ' , ' ' , $beautiful_query );
2019-09-06 10:20:20 +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 >
2019-09-06 10:20:20 +02:00
< div class = " well " > '.$beautiful_query.' </ div >
2017-09-13 13:05:35 +02:00
< 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 " >
2024-03-25 17:34:39 +01:00
< li class = " active " >< a data - toggle = " tab " href = " #fields " > '.tr(' Campi ').' < span class = " badge " > '.View::where(' id_module ', $record->id)->count().' </ a ></ li >
< li >< a data - toggle = " tab " href = " #filters " > '.tr(' Filtri ').' < span class = " badge " > '.Clause::where(' idmodule ', $record->id)->count().' </ span ></ a ></ li >
2019-05-10 23:47:45 +02:00
</ 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 ({
2020-09-23 17:53:19 +02:00
url : " '.base_path().'/actions.php?id_module= " + globals . id_module + " &id_record= " + globals . id_record + " &op=test " ,
2017-09-13 13:05:35 +02:00
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
}