1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-15 09:57:28 +01:00
openstamanager/modules/fatture/fe/document-fe.php

242 lines
6.9 KiB
PHP
Raw Normal View History

2019-07-15 18:34:59 +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/>.
*/
2019-07-15 18:34:59 +02:00
include_once __DIR__.'/../../../core.php';
use Modules\Fatture\Fattura;
$space = str_repeat('&nbsp;', 6);
$documento = Fattura::find($id_record);
$result = $documento->toArray();
$result = array_merge($result, $documento->dati_aggiuntivi_fe);
2019-07-16 09:50:43 +02:00
echo '
<link rel="stylesheet" type="text/css" media="all" href="'.$structure->fileurl('fe/style.css').'"/>';
2019-07-15 18:34:59 +02:00
echo '
<form action="" method="post">
<input type="hidden" name="op" value="manage_documento_fe">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_module" value="'.$id_module.'">
<input type="hidden" name="id_record" value="'.$id_record.'">';
echo '
<table class="table">
<tbody>
2019-07-16 09:50:43 +02:00
<tr class="first-level">
2019-07-15 18:34:59 +02:00
<th colspan="2">
2 FatturaElettronicaBody
<button type="submit" class="btn btn-primary pull-right">
<i class="fa fa-edit"></i> '.tr('Salva').'
</button>
</th>
</tr>
2019-07-16 09:50:43 +02:00
<tr class="second-level">
2019-07-15 18:34:59 +02:00
<th colspan="2">'.str_repeat($space, 1).'2.1 DatiGenerali</th>
</tr>
2019-07-16 09:50:43 +02:00
<tr class="third-level">
2019-07-15 18:34:59 +02:00
<th colspan="2">'.str_repeat($space, 2).'2.1.1 DatiGeneraliDocumento</th>
</tr>';
// ScontoMaggiorazione
echo '
<tr class="fourth-level">
<th colspan="2" style="vertical-align: middle;">'.str_repeat($space, 3).'2.1.1.8 ScontoMaggiorazione</th>
</tr>
';
// ScontoMaggiorazione - Tipo
echo '
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).'2.1.1.8.1 Tipo</td>
<td>
{[ "type": "select", "name": "sconto_maggiorazione_tipo", "values": "list=\"SC\":\"Sconto\",\"MG\":\"Maggiorazione\"", "value": "'.$result['sconto_maggiorazione_tipo'].'" ]}
</td>
</tr>
';
// ScontoMaggiorazione - Percentuale
echo '
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).'2.1.1.8.2 Percentuale</td>
<td>
{[ "type": "number", "name": "sconto_maggiorazione_percentuale", "value": "'.$result['sconto_maggiorazione_percentuale'].'" ]}
</td>
</tr>
';
// ScontoMaggiorazione - Importo
echo '
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).'2.1.1.8.3 Importo</td>
<td>
{[ "type": "number", "name": "sconto_maggiorazione_importo", "value": "'.$result['sconto_maggiorazione_importo'].'" ]}
</td>
</tr>
';
2019-07-15 18:34:59 +02:00
// Art73
echo '
2019-07-16 09:50:43 +02:00
<tr class="fourth-level">
2019-07-15 18:34:59 +02:00
<td style="vertical-align: middle;">'.str_repeat($space, 3).'2.1.1.12 Art73</td>
<td>
{[ "type": "checkbox", "name": "art73", "value": "'.$result['art73'].'", "placeholder": "'.tr("Emesso ai sensi dell'articolo 73 del DPR 633/72").'" ]}
</td>
2019-07-16 09:50:43 +02:00
</tr>
</tbody>';
echo '
<script>
var keys = {};
var ref_keys = {};
</script>';
2019-07-15 18:34:59 +02:00
$documenti = [
'dati_ordine' => [
'code' => '2.1.2',
'name' => 'DatiOrdineAcquisto',
],
'dati_contratto' => [
'code' => '2.1.3',
'name' => 'DatiContratto',
],
'dati_convenzione' => [
'code' => '2.1.4',
'name' => 'DatiConvenzione',
],
'dati_ricezione' => [
'code' => '2.1.5',
'name' => 'DatiRicezione',
],
'dati_fatture' => [
'code' => '2.1.6',
'name' => 'DatiFattureCollegate',
],
];
foreach ($documenti as $nome => $info) {
if (empty($result[$nome])) {
$result[$nome][] = [];
}
$key = 1;
foreach ($result[$nome] as $dato) {
include __DIR__.'/components/dati_documento.php';
2019-07-16 09:50:43 +02:00
echo '
<script>
ref_keys["'.$nome.$key.'"] = '.($index - 1).';
</script>';
2019-07-16 10:01:16 +02:00
2019-07-15 18:34:59 +02:00
++$key;
}
echo '
2019-07-16 09:50:43 +02:00
<script>
keys["'.$nome.'"] = '.($key - 1).';
</script>';
2019-07-15 18:34:59 +02:00
}
echo '
2019-07-16 09:50:43 +02:00
</table>';
2019-07-15 18:34:59 +02:00
foreach ($documenti as $nome => $info) {
echo '
2020-08-26 14:28:56 +02:00
<table class="hide" id="'.$nome.'-template">';
2019-07-15 18:34:59 +02:00
$dato = [];
$key = '-id-';
include __DIR__.'/components/dati_documento.php';
echo '
2019-07-16 09:50:43 +02:00
</table>
<table class="hide">
2020-08-26 14:28:56 +02:00
<tbody id="riferimento_'.$nome.'-template">
2019-07-16 09:50:43 +02:00
<tr class="fifth-level" title="RiferimentoNumeroLinea-'.$nome.'--id-">
2019-07-15 18:34:59 +02:00
<td style="vertical-align: middle;">
'.str_repeat($space, 4).$info['code'].'.1 RiferimentoNumeroLinea - '.tr('Riga _NUM_', [
2019-07-16 09:50:43 +02:00
'_NUM_' => '-num-',
]).'
2019-07-15 18:34:59 +02:00
</td>
<td>
{[ "type": "number", "name": "'.$nome.'[-id-][riferimento_linea][]", "value": "", "maxlength": 4, "decimals": 0 ]}
</td>
</tr>
</tbody>
</table>';
}
echo '
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary">
<i class="fa fa-edit"></i> '.tr('Salva').'
</button>
</div>
</div>';
echo '
</form>';
echo '
<script>
function add_blocco(btn, nome){
2019-07-26 17:40:52 +02:00
cleanup_inputs();
2020-08-26 14:28:56 +02:00
2019-07-16 09:50:43 +02:00
var last = $(btn).closest("table").find("tr[id^=last-" + nome + "]").parent().last();
2019-07-15 18:34:59 +02:00
keys[nome]++;
2020-08-26 14:28:56 +02:00
var text = replaceAll($("#" + nome + "-template").html(), "-id-", "" + keys[nome]);
2019-07-16 09:50:43 +02:00
ref_keys[nome + keys[nome]] = 1;
2020-08-26 14:28:56 +02:00
2019-07-15 18:34:59 +02:00
last.after(text);
2019-07-26 17:40:52 +02:00
restart_inputs();
2019-07-15 18:34:59 +02:00
}
function add_riferimento(btn, nome, key) {
2019-07-26 17:40:52 +02:00
cleanup_inputs();
2020-08-26 14:28:56 +02:00
2019-07-15 18:34:59 +02:00
var last = $(btn).closest("table").find("tr[title=RiferimentoNumeroLinea-" + nome + "-" + key + "]").last();
2019-07-16 09:50:43 +02:00
ref_keys[nome + key]++;
2020-08-26 14:28:56 +02:00
var text = replaceAll($("#riferimento_" + nome + "-template").html(), "-id-", "" + key);
2019-07-16 09:50:43 +02:00
text = replaceAll(text, "-num-", "" + ref_keys[nome + key]);
2020-08-26 14:28:56 +02:00
2019-07-15 18:34:59 +02:00
last.after(text);
2019-07-26 17:40:52 +02:00
restart_inputs();
2019-07-15 18:34:59 +02:00
}
</script>
2019-07-26 17:40:52 +02:00
<script>$(document).ready(init)</script>';
$attributi_editabili = $documento['stato'] != 'Emessa' && $documento['stato'] != 'Parzialmente pagato' && $documento['stato'] != 'Pagato';
2020-06-30 13:26:15 +02:00
if (!$attributi_editabili) {
echo '<script>
$( document ).ready(function() {
$(\'.modal-body > form button\').attr(\'disabled\', \'disabled\');
$(\'.modal-body > form select\').attr(\'disabled\', \'disabled\');
$(\'.modal-body > form input\').attr(\'disabled\', \'disabled\');
});
</script>';
}