1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-22 21:28:08 +01:00

Miglioramenti vari

Introduzione costante BASEURL e relativa variabile (#145).
Miglioramento della gestione delle anteprime dei PDF, ora unificate sotto PDFJS e la classe Prints.
This commit is contained in:
Thomas Zilio 2018-02-10 10:53:00 +01:00
parent baaaac7368
commit d00c50fc03
5 changed files with 85 additions and 33 deletions

View File

@ -27,8 +27,6 @@ $rootdir = str_replace('%2F', '/', rawurlencode($rootdir));
define('DOCROOT', $docroot);
define('ROOTDIR', $rootdir);
$pdfjs = '../../../..';
// Caricamento delle dipendenze e delle librerie del progetto
require_once __DIR__.'/vendor/autoload.php';
@ -39,6 +37,10 @@ if (!empty($redirectHTTPS) && !isHTTPS(true)) {
exit();
}
// Individuazione del percorso BASEURL
$baseurl = (isHTTPS(true) ? 'https' : 'http').'://'.$_SERVER['SERVER_NAME'].$rootdir;
define('BASEURL', $baseurl);
// Forzamento del debug
// $debug = true;

View File

@ -208,8 +208,8 @@ gulp.task('chartjs', function () {
gulp.task('pdfjs', function () {
gulp.src([
config.main.bowerDirectory + '/pdfjs/web/*',
'!' + config.main.bowerDirectory + '/pdfjs/web/cmaps/',
config.main.bowerDirectory + '/pdfjs/web/**/*',
'!' + config.main.bowerDirectory + '/pdfjs/web/cmaps/*',
'!' + config.main.bowerDirectory + '/pdfjs/web/*.map',
'!' + config.main.bowerDirectory + '/pdfjs/web/*.pdf',
])

View File

@ -5,7 +5,7 @@ $module_name = 'Interventi';
if (get('anteprima') !== null) {
// Lettura dati intervento
$query = "SELECT id, codice, idanagrafica, (SELECT MIN(DATE_FORMAT(`orario_inizio`, '%d/%m/%Y')) FROM in_interventi_tecnici WHERE in_interventi_tecnici.`idintervento`=in_interventi.id ) AS data_inizio, (SELECT MAX(DATE_FORMAT(`orario_inizio`, '%d/%m/%Y')) FROM in_interventi_tecnici WHERE in_interventi_tecnici.`idintervento`=in_interventi.id ) AS data_fine FROM in_interventi WHERE in_interventi.id=".prepare($id_record);
$query = 'SELECT codice FROM in_interventi WHERE id='.prepare($id_record);
$rs = $dbo->fetchArray($query);
if (empty($rs)) {
@ -13,40 +13,27 @@ if (get('anteprima') !== null) {
exit();
}
$idanagrafica = $rs[0]['idanagrafica'];
$idcliente = $rs[0]['idanagrafica'];
$data_intervento = $rs[0]['data_inizio'];
// Gestione della stampa
$rapportino_nome = sanitizeFilename('Rapportino'.$rs[0]['codice'].'.pdf');
$filename = $docroot.'/files/interventi/'.$rapportino_nome;
$id_print = Prints::getModuleMainPrint($id_record)['id'];
Prints::render($id_print, $id_record, $filename);
$id_print = Prints::getModuleMainPrint($id_module)['id'];
// HTML per la visualizzazione
echo '
<button type="button" class="btn btn-success btn-block btn-lg" id="firma" onclick="$(\'.canvas\').removeClass(\'hide\'); $(this).addClass(\'hide\'); $(\'#pdf\').addClass(\'hide\');">
<i class="fa fa-pencil"></i> '.tr('Firma').'
</button>
<div class="clearfix"></div>';
<div id="preview">
<button type="button" class="btn btn-success btn-block btn-lg" id="firma">
<i class="fa fa-pencil"></i> '.tr('Firma').'
</button>
<br>
echo '<div class="hide" id="pdf">';
<div class="clearfix"></div>
if (isMobile()) {
echo '<iframe src="'.$rootdir.'/assets/dist/pdfjs/web/viewer.html?file='.$pdfjs.'/files/interventi/'.$rapportino_nome.'" allowfullscreen="" webkitallowfullscreen="" width="100%" height="550" ></iframe>';
} else {
echo '<object data="'.$rootdir.'/files/interventi/'.$rapportino_nome.'#view=fitH&scrollbar=0&toolbar=0&navpanes=0" id ="rapportino_pdf" type="application/pdf" width="100%">
alt : <a href="'.$rootdir.'/files/interventi/'.$rapportino_nome.'" target="_blank">'.$rapportino_nome.'</a>
<span>'.tr('Plugin PDF mancante').'</span>
</object>';
}
echo '</div>';
<iframe src="'.Prints::getPreviewLink($id_print, $id_record, $filename).'" allowfullscreen="" webkitallowfullscreen="" width="100%" height="550"></iframe>
</div>';
}
?>
<form class="canvas" action="<?php echo $rootdir ?>/editor.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>" method="post" id="form-firma">
<form action="<?php echo $rootdir; ?>/editor.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>" method="post" id="form-firma" class="hide">
<input type="hidden" name="op" value="firma">
<input type="hidden" name="backto" value="record-edit">
@ -76,11 +63,11 @@ if (get('anteprima') !== null) {
<script type="text/javascript">
$(document).ready( function(){
$('button').removeClass('hide');
$('#pdf').removeClass('hide');
$('.canvas').addClass('hide');
$('#firma').removeClass('hide');
$('#rapportino_pdf').css('height', ($(window).height()-200));
$('#firma').on('click', function(){
$('#preview').addClass('hide');
$('#form-firma').removeClass('hide');
})
var wrapper = document.getElementById("signature-pad"),
clearButton = document.querySelector("[data-action=clear]"),

56
src/App.php Normal file
View File

@ -0,0 +1,56 @@
<?php
/**
* Classe per la gestione delle utenze.
*
* @since 2.4
*/
class App
{
/** @var int Identificativo del modulo corrente */
protected static $current_module;
/** @var int Identificativo dell'elemento corrente */
protected static $current_element;
/**
* Restituisce l'identificativo del modulo attualmente in utilizzo.
*
* @return int
*/
public static function getCurrentModule()
{
if (empty(self::$current_module)) {
self::$current_module = filter('id_module');
}
return self::$current_module;
}
/**
* Restituisce l'identificativo dell'elemento attualmente in utilizzo.
*
* @return int
*/
public static function getCurrentElement()
{
if (empty(self::$current_element)) {
self::$current_element = filter('id_record');
}
return self::$current_element;
}
/**
* Restituisce la configurazione dell'installazione.
*
* @return array
*/
public function getConfig()
{
if (file_exists(DOCROOT.'/config.inc.php')) {
include DOCROOT.'/config.inc.php';
}
return get_defined_vars();
}
}

View File

@ -386,4 +386,11 @@ class Prints
{
return '{( "name": "button", "type": "print", "id": "'.$print.'", "id_record": "'.$id_record.'", "label": "'.$title.'", "icon": "'.$icon.'", "parameters": "'.$get.'", "class": "'.$btn.'" )}';
}
public static function getPreviewLink($print, $id_record, $filename)
{
self::render($print, $id_record, $filename);
return ROOTDIR.'/assets/dist/pdfjs/web/viewer.html?file=../../../../'.ltrim(str_replace(DOCROOT, '', $filename), '/');
}
}