2023-03-31 17:24:59 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.r.l.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../../core.php';
|
|
|
|
|
2024-03-06 10:56:09 +01:00
|
|
|
use Models\PrintTemplate;
|
2024-03-22 15:52:24 +01:00
|
|
|
use Modules\Interventi\Intervento;
|
2023-03-31 17:24:59 +02:00
|
|
|
|
|
|
|
$id_records = explode(';', get('id_records'));
|
|
|
|
$id_print = setting('Stampa per anteprima e firma');
|
2024-04-18 17:44:05 +02:00
|
|
|
$template = PrintTemplate::find($id_print)->getTranslation('title');
|
2023-03-31 17:24:59 +02:00
|
|
|
|
|
|
|
$interventi_completati = [];
|
|
|
|
$interventi_firmati = [];
|
|
|
|
$interventi_da_firmare = [];
|
|
|
|
$records = [];
|
|
|
|
foreach ($id_records as $id) {
|
|
|
|
$intervento = Intervento::find($id);
|
|
|
|
|
|
|
|
if ($intervento->stato->is_completato) {
|
2023-08-04 14:54:28 +02:00
|
|
|
$interventi_completati[] = $id;
|
2023-03-31 17:24:59 +02:00
|
|
|
} elseif ($intervento->firma_file) {
|
|
|
|
$interventi_firmati[] = $id;
|
|
|
|
$records[] = $id;
|
|
|
|
} else {
|
|
|
|
$interventi_da_firmare[] = $id;
|
|
|
|
$records[] = $id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-4">
|
|
|
|
<div class="box box-success">
|
|
|
|
<div class="box-header">
|
|
|
|
<h3 class="box-title">'.tr('Interventi da firmare').'</h3>
|
|
|
|
</div>
|
|
|
|
<div class="box-body">';
|
2024-01-15 15:30:45 +01:00
|
|
|
if ($interventi_da_firmare) {
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
<table class="table table-hover table-bordered table-condensed">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>'.tr('Interventi').'</th>
|
|
|
|
<th class="text-center">#</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>';
|
2024-01-15 15:30:45 +01:00
|
|
|
foreach ($interventi_da_firmare as $id) {
|
|
|
|
$intervento = Intervento::find($id);
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
'.Modules::link('Interventi', $intervento->id, tr('Intervento num. _NUM_ del _DATE_', [
|
2024-03-22 15:52:24 +01:00
|
|
|
'_NUM_' => $intervento->codice,
|
|
|
|
'_DATE_' => Translator::dateToLocale($intervento->inizio),
|
|
|
|
])).'
|
2023-03-31 17:24:59 +02:00
|
|
|
</td>
|
|
|
|
<td class="text-center">
|
|
|
|
'.Prints::getLink($template, $id, 'btn btn-xs btn-primary', '', 'fa fa-print').'
|
|
|
|
</td>
|
|
|
|
<tr>';
|
2024-01-15 15:30:45 +01:00
|
|
|
}
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
</tbody>
|
|
|
|
</table>';
|
2024-01-15 15:30:45 +01:00
|
|
|
} else {
|
2024-03-06 18:57:19 +01:00
|
|
|
echo tr('Nessun Intervento.');
|
2024-01-15 15:30:45 +01:00
|
|
|
}
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-4">
|
|
|
|
<div class="box box-warning">
|
|
|
|
<div class="box-header">
|
|
|
|
<h3 class="box-title">'.tr('Interventi firmati non completati').'</h3>
|
|
|
|
</div>
|
|
|
|
<div class="box-body">';
|
2024-01-15 15:30:45 +01:00
|
|
|
if ($interventi_firmati) {
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
<table class="table table-hover table-bordered table-condensed">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>'.tr('Interventi').'</th>
|
|
|
|
<th class="text-center">#</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>';
|
2024-01-15 15:30:45 +01:00
|
|
|
foreach ($interventi_firmati as $id) {
|
|
|
|
$intervento = Intervento::find($id);
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
'.Modules::link('Interventi', $intervento->id, tr('Intervento num. _NUM_ del _DATE_', [
|
2024-03-22 15:52:24 +01:00
|
|
|
'_NUM_' => $intervento->codice,
|
|
|
|
'_DATE_' => Translator::dateToLocale($intervento->inizio),
|
|
|
|
])).'
|
2023-03-31 17:24:59 +02:00
|
|
|
</td>
|
|
|
|
<td class="text-center">
|
|
|
|
'.Prints::getLink($template, $id, 'btn btn-xs btn-primary', '', 'fa fa-print').'
|
|
|
|
</td>
|
|
|
|
<tr>';
|
2024-01-15 15:30:45 +01:00
|
|
|
}
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
</tbody>
|
|
|
|
</table>';
|
2024-01-15 15:30:45 +01:00
|
|
|
} else {
|
2024-03-06 18:57:19 +01:00
|
|
|
echo tr('Nessun Intervento.');
|
2024-01-15 15:30:45 +01:00
|
|
|
}
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-4">
|
|
|
|
<div class="box box-danger">
|
|
|
|
<div class="box-header">
|
|
|
|
<h3 class="box-title">'.tr('Interventi completati').'</h3>
|
|
|
|
</div>
|
|
|
|
<div class="box-body">';
|
2024-01-15 15:30:45 +01:00
|
|
|
if ($interventi_completati) {
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
<table class="table table-hover table-bordered table-condensed">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>'.tr('Interventi').'</th>
|
|
|
|
<th class="text-center">#</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>';
|
2024-01-15 15:30:45 +01:00
|
|
|
foreach ($interventi_completati as $id) {
|
|
|
|
$intervento = Intervento::find($id);
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
'.Modules::link('Interventi', $intervento->id, tr('Intervento num. _NUM_ del _DATE_', [
|
2024-03-22 15:52:24 +01:00
|
|
|
'_NUM_' => $intervento->codice,
|
|
|
|
'_DATE_' => Translator::dateToLocale($intervento->inizio),
|
|
|
|
])).'
|
2023-03-31 17:24:59 +02:00
|
|
|
</td>
|
|
|
|
<td class="text-center">
|
|
|
|
'.Prints::getLink($template, $id, 'btn btn-xs btn-primary', '', 'fa fa-print').'
|
|
|
|
</td>
|
|
|
|
<tr>';
|
2024-01-15 15:30:45 +01:00
|
|
|
}
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<br>
|
|
|
|
<div class="alert alert-warning">
|
2023-08-04 14:54:28 +02:00
|
|
|
<i class="fa fa-warning"></i> '.tr('Questi interventi non verranno firmati').'
|
2023-03-31 17:24:59 +02:00
|
|
|
</div>';
|
2024-01-15 15:30:45 +01:00
|
|
|
} else {
|
2024-03-06 18:57:19 +01:00
|
|
|
echo tr('Nessun Intervento.');
|
2024-01-15 15:30:45 +01:00
|
|
|
}
|
|
|
|
echo '
|
2023-03-31 17:24:59 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
// HTML per la visualizzazione
|
|
|
|
echo '
|
|
|
|
<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>
|
|
|
|
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
?>
|
|
|
|
<form action="" method="post" id="form-firma" class="hide">
|
|
|
|
<input type="hidden" name="op" value="firma_bulk">
|
|
|
|
<input type="hidden" name="backto" value="record-list">
|
|
|
|
<input type="hidden" name="records" value="<?php echo implode(';', $records ?: ''); ?>">
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
{[ "type": "text", "label": "<?php echo tr('Nome e cognome'); ?>", "name": "firma_nome", "required": 1 ]}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready( function() {
|
|
|
|
$('#firma').on('click', function() {
|
|
|
|
$('#preview').addClass('hide');
|
|
|
|
|
|
|
|
$('#form-firma').removeClass('hide');
|
|
|
|
})
|
|
|
|
|
|
|
|
var wrapper = document.getElementById("signature-pad"),
|
|
|
|
clearButton = document.querySelector("[data-action=clear]"),
|
|
|
|
saveButton = document.querySelector("[data-action=save]"),
|
|
|
|
canvas = document.getElementById("canvas");
|
|
|
|
|
|
|
|
var signaturePad = new SignaturePad(canvas, {
|
|
|
|
backgroundColor: 'rgb(255,255,255)'
|
|
|
|
});
|
|
|
|
|
|
|
|
function resizeCanvas() {
|
|
|
|
image_data = signaturePad.toDataURL();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
signaturePad.fromDataURL(image_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|