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
|
|
|
|
2020-08-17 09:47:18 +02:00
|
|
|
include_once __DIR__.'/../../../core.php';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
if (get('anteprima') !== null) {
|
|
|
|
// Lettura dati intervento
|
2018-02-10 10:53:00 +01:00
|
|
|
$query = 'SELECT codice FROM in_interventi WHERE id='.prepare($id_record);
|
2017-08-04 16:28:16 +02:00
|
|
|
$rs = $dbo->fetchArray($query);
|
|
|
|
|
|
|
|
if (empty($rs)) {
|
2017-09-04 12:02:29 +02:00
|
|
|
echo tr('Intervento inesistente!');
|
2024-01-15 15:30:45 +01:00
|
|
|
exit;
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Gestione della stampa
|
2020-09-23 13:36:37 +02:00
|
|
|
$directory = base_dir().'/files/interventi/';
|
2018-09-26 12:20:06 +02:00
|
|
|
$id_print = setting('Stampa per anteprima e firma');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// HTML per la visualizzazione
|
|
|
|
echo '
|
2018-02-10 10:53:00 +01:00
|
|
|
<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>
|
2017-12-20 14:05:14 +01:00
|
|
|
|
2018-02-10 10:53:00 +01:00
|
|
|
<div class="clearfix"></div>
|
|
|
|
|
2019-07-10 11:53:35 +02:00
|
|
|
<iframe src="'.Prints::getPreviewLink($id_print, $id_record, $directory).'" frameborder="0" width="100%" height="550"></iframe>
|
2018-02-10 10:53:00 +01:00
|
|
|
</div>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
2024-01-19 09:06:25 +01:00
|
|
|
if ((setting('Sistema di firma') == 'Base') || isMobile() ){
|
2023-08-04 14:54:28 +02:00
|
|
|
?>
|
2023-07-28 14:17:04 +02:00
|
|
|
<form action="<?php echo base_path(); ?>/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">
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
{[ "type": "text", "label": "<?php echo tr('Nome e cognome'); ?>", "name": "firma_nome", "required": 1 ]}
|
2018-11-21 00:06:56 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-28 14:17:04 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div id="signature-pad" class="signature-pad">
|
|
|
|
<canvas id="canvas" onselectstart="return false"></canvas>
|
|
|
|
<input type="hidden" name="firma_base64" id="firma_base64" value="">
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-11-21 00:06:56 +01:00
|
|
|
</div>
|
2023-07-28 14:17:04 +02:00
|
|
|
<br>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
|
|
|
<button type="button" class="btn btn-danger" data-action="clear">
|
|
|
|
<i class="fa fa-eraser"></i> <?php echo tr('Cancella firma'); ?>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<button type="submit" class="btn btn-success pull-right" data-action="save">
|
|
|
|
<i class="fa fa-check"></i> <?php echo tr('Salva firma'); ?>
|
|
|
|
</button>
|
|
|
|
</div>
|
2018-11-21 00:06:56 +01:00
|
|
|
</div>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
</form>
|
|
|
|
<div class="clearfix"></div>
|
2018-02-10 10:53:00 +01:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready( function() {
|
|
|
|
$('#firma').on('click', function() {
|
|
|
|
$('#preview').addClass('hide');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
$('#form-firma').removeClass('hide');
|
|
|
|
})
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
var wrapper = document.getElementById("signature-pad"),
|
|
|
|
clearButton = document.querySelector("[data-action=clear]"),
|
|
|
|
saveButton = document.querySelector("[data-action=save]"),
|
|
|
|
canvas = document.getElementById("canvas");
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
var signaturePad = new SignaturePad(canvas, {
|
|
|
|
backgroundColor: 'rgb(255,255,255)'
|
|
|
|
});
|
2017-08-30 11:50:46 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
function resizeCanvas() {
|
|
|
|
image_data = signaturePad.toDataURL();
|
2017-08-30 11:50:46 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
var ratio = Math.max(window.devicePixelRatio || 1, 1);
|
|
|
|
canvas.width = canvas.offsetWidth * ratio;
|
|
|
|
canvas.height = canvas.offsetHeight * ratio;
|
|
|
|
canvas.getContext("2d").scale(ratio, ratio);
|
|
|
|
signaturePad.clear();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
signaturePad.fromDataURL(image_data);
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
window.addEventListener("resize", resizeCanvas);
|
|
|
|
$('#firma').click(resizeCanvas);
|
|
|
|
|
|
|
|
clearButton.addEventListener("click", function (event) {
|
|
|
|
signaturePad.clear();
|
|
|
|
});
|
|
|
|
|
|
|
|
saveButton.addEventListener("click", function (event) {
|
|
|
|
if (signaturePad.isEmpty()) {
|
|
|
|
alert(globals.translations.signatureMissing);
|
|
|
|
event.preventDefault();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
image_data = signaturePad.toDataURL("image/jpeg", 100);
|
|
|
|
$('#firma_base64').val(image_data);
|
|
|
|
}
|
|
|
|
});
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
2023-07-28 14:17:04 +02:00
|
|
|
</script>
|
|
|
|
<?php
|
2023-08-04 14:54:28 +02:00
|
|
|
} elseif (setting('Sistema di firma') == 'Tavoletta Wacom') {
|
2024-01-15 15:30:45 +01:00
|
|
|
echo '
|
2023-07-28 14:17:04 +02:00
|
|
|
<div id="firma-div"></div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2023-07-28 18:07:24 +02:00
|
|
|
|
|
|
|
$(document).ready( function() {
|
2023-07-28 14:17:04 +02:00
|
|
|
$("#firma").on("click", function() {
|
|
|
|
$("#preview").addClass("hide");
|
2023-07-28 18:07:24 +02:00
|
|
|
try {
|
|
|
|
// Check if navigator.hid is available
|
|
|
|
if (navigator.hid) {
|
|
|
|
caricaTavoletta()
|
|
|
|
} else {
|
|
|
|
// Handle the case when navigator.hid is undefined
|
2023-08-04 14:54:28 +02:00
|
|
|
swal("'.tr('Errore').'", "'.tr('navigator.hid non è supportato da questo browser!').'", "error");
|
2023-07-28 18:13:39 +02:00
|
|
|
$("#modals > div").modal("hide");
|
2023-07-28 18:07:24 +02:00
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
// Handle any other errors that may occur
|
|
|
|
console.error("An error occurred:", error);
|
|
|
|
}
|
2023-07-28 18:13:39 +02:00
|
|
|
});
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
2023-07-28 14:17:04 +02:00
|
|
|
|
|
|
|
function caricaTavoletta(){
|
|
|
|
let container = $("#firma-div");
|
|
|
|
localLoading(container, true);
|
|
|
|
return $.get("'.$structure->fileurl('modals/firma_tavoletta.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) {
|
|
|
|
container.html(data);
|
|
|
|
localLoading(container, false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>';
|
2024-01-15 15:30:45 +01:00
|
|
|
}
|