2020-02-24 15:37:27 +01: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 />.
*/
2020-02-24 15:37:27 +01:00
include_once __DIR__ . '/../../core.php' ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
2024-03-22 15:52:24 +01:00
use Models\PrintTemplate ;
2021-05-18 13:04:42 +02:00
2023-09-15 18:06:15 +02:00
$id_files = $dbo -> select ( 'zz_files_print' , 'id_file' , [], [ 'id_print' => $id_record ]);
2023-06-29 11:11:41 +02:00
2020-02-24 15:37:27 +01:00
?> <form action="" method="post" id="edit-form">
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
< input type = " hidden " name = " id_record " value = " <?php echo $id_record ; ?> " >
<!-- DATI SEGMENTO -->
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
2024-05-17 12:11:00 +02:00
< div class = " card-header " >
2024-05-16 18:02:50 +02:00
< h3 class = " card-title " >< ? php echo tr ( 'Informazioni della stampa' ); ?> </h3>
2020-02-24 15:37:27 +01:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2020-02-24 15:37:27 +01:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Titolo'); ?> " , " name " : " title " , " required " : 1 , " value " : " $title $ " ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Nome del file'); ?> " , " name " : " filename " , " required " : 1 , " value " : " $filename $ " ]}
</ div >
2021-05-18 12:34:22 +02:00
2020-02-24 15:37:27 +01:00
</ div >
2021-05-18 12:34:22 +02:00
< div class = " row " >
2023-06-29 11:11:41 +02:00
< div class = " col-md-6 " >
2024-04-18 17:44:05 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Modulo'); ?> " , " name " : " module " , " required " : 1 , " values " : " query=SELECT `zz_modules`.`id`, `title` AS descrizione FROM `zz_modules` LEFT JOIN `zz_modules_lang` ON (`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = <?php echo prepare(Models \ Locale::getDefault()->id); ?>) WHERE (`enabled` = 1 AND `options` != 'custom') OR `zz_modules`.`id` = <?php echo $record['id_module'] ; ?> ORDER BY `title` ASC " , " value " : " <?php echo $record['id_module'] ; ?> " , " disabled " : " 1 " ]}
2021-05-18 12:34:22 +02:00
</ div >
2023-06-29 11:11:41 +02:00
< div class = " col-md-6 " >
2024-05-14 16:29:55 +02:00
{[ " type " : " select " , " multiple " : " 1 " , " label " : " <?php echo tr('File da accodare'); ?> " , " name " : " id_files[] " , " value " : " <?php echo implode(',', array_column( $id_files , 'id_file')); ?> " , " help " : " <?php echo tr('I file selezionati saranno accodati in fase di generazione della stampa'); ?> " , " ajax-source " : " allegati " , " select-options " : < ? php echo json_encode ([ 'id_module' => $id_module , 'id_record' => $id_record ]); ?> , "link": "allegato" ]}
2023-06-29 11:11:41 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-4 " >
2021-05-18 12:34:22 +02:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Attiva'); ?> " , " name " : " enabled " , " value " : " $enabled $ " , " disabled " : " 1 " ]}
</ div >
2023-06-29 11:11:41 +02:00
< div class = " col-md-4 " >
2021-05-18 12:34:22 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Ordine'); ?> " , " name " : " order " , " required " : 0 , " value " : " $order $ " , " decimals " : 0 ]}
</ div >
2021-05-18 13:04:42 +02:00
< ? php
2021-09-02 16:09:07 +02:00
$stampa_predefinita = PrintTemplate :: where ( 'predefined' , true )
-> where ( 'id_module' , $record [ 'id_module' ])
-> orderBy ( 'id' )
-> first ();
2024-01-15 15:30:45 +01:00
if ( ! empty ( $stampa_predefinita )) {
2024-04-18 17:44:05 +02:00
$nome_stampa_predefinita = $stampa_predefinita -> getTranslation ( 'title' );
2024-01-15 15:30:45 +01:00
} else {
$nome_stampa_predefinita = 'Nessuna' ;
}
?>
2021-09-02 16:09:07 +02:00
2023-06-29 11:11:41 +02:00
< div class = " col-md-4 " >
2021-09-02 16:09:07 +02:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Predefinita'); ?> " , " help " : " <?php echo tr('Attiva per impostare questa stampa come predefinita. Attualmente la stampa predefinita per questo modulo è: '. $nome_stampa_predefinita ); ?> " , " name " : " predefined " , " value " : " $predefined $ " , " disabled " : " <?php echo intval( $record['predefined'] ); ?> " ]}
2021-05-18 12:34:22 +02:00
</ div >
</ div >
2020-02-24 15:37:27 +01:00
< div class = " row " >
< div class = " col-md-12 " >
2023-02-24 14:59:46 +01:00
< ? php
2024-01-15 15:30:45 +01:00
echo input ([
'type' => 'textarea' ,
'label' => tr ( 'Opzioni' ),
'name' => 'options' ,
'value' => $record [ 'options' ],
'help' => tr ( 'Impostazioni personalizzabili della stampa, in formato JSON' ),
]);
?>
2023-02-24 14:59:46 +01:00
</ div >
2020-02-24 15:37:27 +01:00
</ div >
</ div >
</ div >
</ form >
2020-03-19 13:35:04 +01:00
< ? php
2023-03-10 16:10:36 +01:00
// Opzioni utilizzabili
// Lettura delle opzioni per il template di stampa
echo '
<!-- Istruzioni per il contenuto -->
2024-05-16 18:02:50 +02:00
< div class = " card card-info " >
< div class = " card-header " >
< h3 class = " card-title " > '.tr(' Opzioni ').' </ h3 >
2023-03-10 16:10:36 +01:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " > ' ;
2023-03-10 16:10:36 +01:00
if ( ! empty ( $record [ 'available_options' ])) {
2024-05-23 11:36:25 +02:00
$available_options = json_decode (( string ) $record [ 'available_options' ]);
2023-03-10 16:10:36 +01:00
echo '
< p > '.tr(' Puoi utilizzare le seguenti opzioni per generare la stampa ').' :</ p >
< ul > ' ;
foreach ( $available_options as $option => $value ) {
echo '
2024-05-16 18:02:50 +02:00
< li >< code > '.$option.' </ code > '.((!empty($value)) ? ' < span class = " badge badge-default " > '.$value.' </ span > ' : ' ').' </ li > ' ;
2023-03-10 16:10:36 +01:00
}
echo '
</ ul > ' ;
} else {
echo '
< p >< i class = " fa fa-warning " ></ i > '.tr(' Non sono state definite opzioni da utilizzare per la stampa ').' .</ p > ' ;
}
echo '
</ div >
</ div > ' ;
2020-03-19 13:35:04 +01:00
// Variabili utilizzabili
2024-03-05 16:01:45 +01:00
$module = Module :: find ( $record [ 'id_module' ]);
2021-03-29 09:11:17 +02:00
$variables = $module -> getPlaceholders ( $id_record );
2020-03-19 13:35:04 +01:00
echo '
<!-- Istruzioni per il contenuto -->
2024-05-16 18:02:50 +02:00
< div class = " card card-info " >
< div class = " card-header " >
< h3 class = " card-title " > '.tr(' Variabili ').' </ h3 >
2020-03-19 13:35:04 +01:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " > ' ;
2020-03-19 13:35:04 +01:00
if ( ! empty ( $variables )) {
echo '
2020-03-31 20:34:31 +02:00
< p > '.tr(' Puoi utilizzare le seguenti variabili per generare il nome del file ').' :</ p >
2020-03-19 13:35:04 +01:00
< ul > ' ;
foreach ( $variables as $variable => $value ) {
echo '
2021-09-17 14:34:10 +02:00
< li >< code > '.$variable.' </ code ></ li > ' ;
2020-03-19 13:35:04 +01:00
}
echo '
</ ul > ' ;
} else {
echo '
< p >< i class = " fa fa-warning " ></ i > '.tr(' Non sono state definite variabili da utilizzare nel template ').' .</ p > ' ;
}
echo '
</ div >
</ div >
2023-06-29 11:11:41 +02:00
< hr >
2020-03-19 13:35:04 +01:00
2023-06-29 11:11:41 +02:00
{( " name " : " filelist_and_upload " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )} ' ;
2020-09-07 15:04:06 +02:00
?>