1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-16 19:40:44 +01:00

Completamento attributi avanzati

This commit is contained in:
Thomas Zilio 2019-07-16 09:50:43 +02:00
parent 1556292474
commit 91d052b522
6 changed files with 178 additions and 112 deletions

View File

@ -2,7 +2,8 @@
// Altri dati gestionali
echo '
<tr>
<tbody>
<tr class="fourth-level">
<th colspan="2">
'.str_repeat($space, 3).'2.2.1.16 AltriDatiGestionali - '.tr('Riga _NUM_', [
'_NUM_' => $key,
@ -21,7 +22,7 @@ echo '
// Tipo Dato
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).'2.2.1.16.1 TipoDato</td>
<td>
{[ "type": "text", "name": "altri_dati['.$key.'][tipo_dato]", "value": "'.$dato['tipo_dato'].'", "maxlength": 10 ]}
@ -30,7 +31,7 @@ echo '
// Riferimento Testo
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).'2.2.1.16.2 RiferimentoTesto</td>
<td>
{[ "type": "text", "name": "altri_dati['.$key.'][riferimento_testo]", "value": "'.$dato['riferimento_testo'].'", "maxlength": 60 ]}
@ -39,7 +40,7 @@ echo '
// Riferimento Numero
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).'2.2.1.16.3 RiferimentoNumero</td>
<td>
{[ "type": "number", "name": "altri_dati['.$key.'][riferimento_numero]", "value": "'.$dato['tipo_dato'].'" ]}
@ -48,9 +49,10 @@ echo '
// Riferimento Data
echo '
<tr id="last-altri_dati-'.$key.'">
<tr class="fifth-level" id="last-altri_dati-'.$key.'">
<td style="vertical-align: middle;">'.str_repeat($space, 4).'2.2.1.16.4 RiferimentoData</td>
<td>
{[ "type": "date", "name": "altri_dati['.$key.'][riferimento_data]", "value": "'.$dato['tipo_dato'].'"]}
</td>
</tr>';
</tr>
</tbody>';

View File

@ -2,7 +2,8 @@
// Altri dati gestionali
echo '
<tr>
<tbody>
<tr class="fourth-level">
<th colspan="2">
'.str_repeat($space, 3).$info['code'].' '.$info['name'].' - '.tr('Riga _NUM_', [
'_NUM_' => $key,
@ -27,7 +28,7 @@ if (empty($dato['riferimento_linea'])) {
$index = 1;
foreach ($dato['riferimento_linea'] as $linea) {
echo '
<tr title="RiferimentoNumeroLinea-'.$nome.'-'.$key.'">
<tr class="fifth-level" title="RiferimentoNumeroLinea-'.$nome.'-'.$key.'">
<td style="vertical-align: middle;">
'.str_repeat($space, 4).$info['code'].'.1 RiferimentoNumeroLinea - '.tr('Riga _NUM_', [
'_NUM_' => $index,
@ -52,7 +53,7 @@ foreach ($dato['riferimento_linea'] as $linea) {
// IdDocumento
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).$info['code'].'.2 IdDocumento</td>
<td>
{[ "type": "text", "name": "'.$nome.'['.$key.'][id_documento]", "value": "'.$dato['id_documento'].'", "maxlength": 20 ]}
@ -61,7 +62,7 @@ echo '
// Data
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).$info['code'].'.3 Data</td>
<td>
{[ "type": "date", "name": "'.$nome.'['.$key.'][data]", "value": "'.$dato['data'].'" ]}
@ -70,7 +71,7 @@ echo '
// NumItem
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).$info['code'].'.4 NumItem</td>
<td>
{[ "type": "text", "name": "'.$nome.'['.$key.'][num_item]", "value": "'.$dato['num_item'].'", "maxlength": 20 ]}
@ -79,7 +80,7 @@ echo '
// CodiceCommessaConvenzione
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).$info['code'].'.5 CodiceCommessaConvenzione</td>
<td>
{[ "type": "text", "name": "'.$nome.'['.$key.'][codice_commessa]", "value": "'.$dato['codice_commessa'].'", "maxlength": 100 ]}
@ -88,7 +89,7 @@ echo '
// CodiceCUP
echo '
<tr>
<tr class="fifth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 4).$info['code'].'.6 CodiceCUP</td>
<td>
{[ "type": "text", "name": "'.$nome.'['.$key.'][codice_cup]", "value": "'.$dato['codice_cup'].'", "maxlength": 15 ]}
@ -97,9 +98,10 @@ echo '
// CodiceCIG
echo '
<tr id="last-'.$nome.'-'.$key.'">
<tr class="fifth-level" id="last-'.$nome.'-'.$key.'">
<td style="vertical-align: middle;">'.str_repeat($space, 4).$info['code'].'.7 CodiceCIG</td>
<td>
{[ "type": "text", "name": "'.$nome.'['.$key.'][codice_cig]", "value": "'.$dato['codice_cig'].'", "maxlength": 15 ]}
</td>
</tr>';
</tr>
</tbody>';

View File

@ -11,6 +11,9 @@ $documento = Fattura::find($id_record);
$result = $documento->toArray();
$result = array_merge($result, $documento->dati_aggiuntivi_fe);
echo '
<link rel="stylesheet" type="text/css" media="all" href="'.$structure->fileurl('fe/style.css').'"/>';
echo '
<form action="" method="post">
<input type="hidden" name="op" value="manage_documento_fe">
@ -21,7 +24,7 @@ echo '
echo '
<table class="table">
<tbody>
<tr>
<tr class="first-level">
<th colspan="2">
2 FatturaElettronicaBody
<button type="submit" class="btn btn-primary pull-right">
@ -29,21 +32,28 @@ echo '
</button>
</th>
</tr>
<tr>
<tr class="second-level">
<th colspan="2">'.str_repeat($space, 1).'2.1 DatiGenerali</th>
</tr>
<tr>
<tr class="third-level">
<th colspan="2">'.str_repeat($space, 2).'2.1.1 DatiGeneraliDocumento</th>
</tr>';
// Art73
echo '
<tr>
<tr class="fourth-level">
<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>
</tr>';
</tr>
</tbody>';
echo '
<script>
var keys = {};
var ref_keys = {};
</script>';
$documenti = [
'dati_ordine' => [
@ -76,57 +86,41 @@ foreach ($documenti as $nome => $info) {
foreach ($result[$nome] as $dato) {
include __DIR__.'/components/dati_documento.php';
echo '
<script>
ref_keys["'.$nome.$key.'"] = '.($index - 1).';
</script>';
++$key;
}
$documenti[$nome]['key'] = $key;
$documenti[$nome]['index'] = $index;
echo '
<script>
keys["'.$nome.'"] = '.($key - 1).';
</script>';
}
echo '
</tbody>
</table>';
echo '
<script>
var keys = {';
foreach ($documenti as $nome => $info) {
echo '
'.$nome.': '.($info['key'] - 1).',';
}
echo '
};
var ref = {';
foreach ($documenti as $nome => $info) {
echo '
'.$nome.($info['key'] - 1).': '.($info['index'] - 1).',';
}
echo '
};
</script>';
foreach ($documenti as $nome => $info) {
echo '
<table class="hide">
<tbody id="'.$nome.'-templace">';
<table class="hide" id="'.$nome.'-templace">';
$dato = [];
$key = '-id-';
include __DIR__.'/components/dati_documento.php';
echo '
</tbody>
</table>
<table class="hide">
<tbody id="riferimento_'.$nome.'-templace">
<tr title="RiferimentoNumeroLinea-'.$nome.'--id-">
<tr class="fifth-level" title="RiferimentoNumeroLinea-'.$nome.'--id-">
<td style="vertical-align: middle;">
'.str_repeat($space, 4).$info['code'].'.1 RiferimentoNumeroLinea - '.tr('Riga _NUM_', [
'_NUM_' => '-num-',
]).'
'_NUM_' => '-num-',
]).'
</td>
<td>
{[ "type": "number", "name": "'.$nome.'[-id-][riferimento_linea][]", "value": "", "maxlength": 4, "decimals": 0 ]}
@ -157,12 +151,12 @@ function replaceAll(str, find, replace) {
function add_blocco(btn, nome){
$("#template .superselect, #template .superselectajax").select2().select2("destroy");
var last = $(btn).closest("table").find("tr[id^=last-" + nome + "]").last();
var last = $(btn).closest("table").find("tr[id^=last-" + nome + "]").parent().last();
keys[nome]++;
var text = replaceAll($("#" + nome + "-templace").html(), "-id-", "" + keys[nome]);
ref[nome + keys[nome]] = 1;
ref_keys[nome + keys[nome]] = 1;
last.after(text);
@ -174,9 +168,9 @@ function add_riferimento(btn, nome, key) {
$("#template .superselect, #template .superselectajax").select2().select2("destroy");
var last = $(btn).closest("table").find("tr[title=RiferimentoNumeroLinea-" + nome + "-" + key + "]").last();
ref[nome + key]++;
ref_keys[nome + key]++;
var text = replaceAll($("#riferimento_" + nome + "-templace").html(), "-id-", "" + key);
text = replaceAll(text, "-num-", "" + ref[nome + key]);
text = replaceAll(text, "-num-", "" + ref_keys[nome + key]);
last.after(text);

View File

@ -34,6 +34,9 @@ $riga = $documento->getRighe()->find($id_riga);
$result = $riga->toArray();
$result = array_merge($result, $riga->dati_aggiuntivi_fe);
echo '
<link rel="stylesheet" type="text/css" media="all" href="'.$structure->fileurl('fe/style.css').'"/>';
echo '
<form action="" method="post">
<input type="hidden" name="op" value="manage_riga_fe">
@ -44,7 +47,7 @@ echo '
echo '
<table class="table">
<tbody>
<tr>
<tr class="first-level">
<th colspan="2">
2 FatturaElettronicaBody
<button type="submit" class="btn btn-primary pull-right">
@ -52,16 +55,16 @@ echo '
</button>
</th>
</tr>
<tr>
<tr class="second-level">
<th colspan="2">'.str_repeat($space, 1).'2.2 DatiBeniServizi</th>
</tr>
<tr>
<tr class="third-level">
<th colspan="2">'.str_repeat($space, 2).'2.2.1 DettaglioLinee</th>
</tr>';
// Tipo Cessione Prestazione
echo '
<tr>
<tr class="fourth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 3).'2.2.1.2 TipoCessionePrestazione</td>
<td>
{[ "type": "select", "name": "tipo_cessione_prestazione", "value": "'.$result['tipo_cessione_prestazione'].'", "values": '.json_encode($tipi_cessione_prestazione).' ]}
@ -70,7 +73,7 @@ echo '
// Data inizio periodo
echo '
<tr>
<tr class="fourth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 3).'2.2.1.7 DataInizioPeriodo</td>
<td>
{[ "type": "date", "name": "data_inizio_periodo", "value": "'.$result['data_inizio_periodo'].'" ]}
@ -79,7 +82,7 @@ echo '
// Data fine periodo
echo '
<tr>
<tr class="fourth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 3).'2.2.1.8 DataFinePeriodo</td>
<td>
{[ "type": "date", "name": "data_fine_periodo", "value": "'.$result['data_fine_periodo'].'" ]}
@ -88,12 +91,13 @@ echo '
// Riferimento amministrazione
echo '
<tr>
<tr class="fourth-level">
<td style="vertical-align: middle;">'.str_repeat($space, 3).'2.2.1.15 RiferimentoAmministrazione</td>
<td>
{[ "type": "text", "name": "riferimento_amministrazione", "value": "'.$result['riferimento_amministrazione'].'", "maxlength": 20 ]}
</td>
</tr>';
</tr>
</tbody>';
if (empty($result['altri_dati'])) {
$result['altri_dati'][] = [];
@ -107,7 +111,7 @@ foreach ($result['altri_dati'] as $dato) {
}
echo '
</tbody>
</table>';
echo '
@ -119,27 +123,24 @@ function replaceAll(str, find, replace) {
var n = '.($key - 1).';
function add_altri_dati(btn){
$("#template .superselect, #template .superselectajax").select2().select2("destroy");
var last = $(btn).closest("table").find("tr[id^=last-altri_dati]").last();
var last = $(btn).closest("table").find("tr[id^=last-altri_dati]").parent().last();
n++;
var text = replaceAll($("#altri_dati-templace").html(), "-id-", "" + n);
last.after(text);
console.log(text);
start_superselect();
};
</script>
<table class="hide">
<tbody id="altri_dati-templace">';
<table class="hide" id="altri_dati-templace">';
$dato = [];
$key = '-id-';
include __DIR__.'/components/altri_dati.php';
echo '
</tbody>
</table>';
echo '

View File

@ -0,0 +1,22 @@
.first-level{
background-color: #ffffff;
}
.second-level{
background-color: rgba(192,192,192, 0.1);
}
.third-level{
background-color: rgba(192,192,192, 0.15);
}
.fourth-level{
background-color: rgba(192,192,192, 0.25);
}
.fifth-level{
background-color: rgba(192,192,192, 0.4);
}
.first-level td,
.second-level td,
.third-level td,
.fourth-level td{
vertical-align: middle;
}

View File

@ -120,13 +120,17 @@ class FatturaElettronica
$documento = $this->getDocumento();
$database = database();
$contratti = $database->fetchArray('SELECT `id_documento_fe`, `num_item`, `codice_cig`, `codice_cup` FROM `co_contratti` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idcontratto` = `co_contratti`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$contratti = $database->fetchArray('SELECT `id_documento_fe` AS id_documento, `num_item`, `codice_cig`, `codice_cup` FROM `co_contratti` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idcontratto` = `co_contratti`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$preventivi = $database->fetchArray('SELECT `id_documento_fe`, `num_item`, `codice_cig`, `codice_cup` FROM `co_preventivi` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idpreventivo` = `co_preventivi`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$preventivi = $database->fetchArray('SELECT `id_documento_fe` AS id_documento, `num_item`, `codice_cig`, `codice_cup` FROM `co_preventivi` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idpreventivo` = `co_preventivi`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$interventi = $database->fetchArray('SELECT `id_documento_fe`, `num_item`, `codice_cig`, `codice_cup` FROM `in_interventi` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idintervento` = `in_interventi`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$interventi = $database->fetchArray('SELECT `id_documento_fe` AS id_documento, `num_item`, `codice_cig`, `codice_cup` FROM `in_interventi` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idintervento` = `in_interventi`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$this->contratti = array_unique(array_merge($contratti, $preventivi, $interventi));
$dati_aggiuntivi = $documento->dati_aggiuntivi_fe;
$dati = $dati_aggiuntivi['dati_contratto'] ?: [];
$this->contratti = array_unique(array_merge($contratti, $preventivi, $interventi, $dati));
}
return $this->contratti;
@ -143,9 +147,12 @@ class FatturaElettronica
$documento = $this->getDocumento();
$database = database();
$ordini = $database->fetchArray('SELECT `id_documento_fe`, `num_item`, `codice_cig`, `codice_cup` FROM `or_ordini` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idordine` = `or_ordini`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$ordini = $database->fetchArray('SELECT `id_documento_fe` AS id_documento, `num_item`, `codice_cig`, `codice_cup` FROM `or_ordini` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idordine` = `or_ordini`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL');
$this->ordini = $ordini;
$dati_aggiuntivi = $documento->dati_aggiuntivi_fe;
$dati = $dati_aggiuntivi['dati_ordine'] ?: [];
$this->ordini = array_merge($ordini, $dati);
}
return $this->ordini;
@ -162,9 +169,12 @@ class FatturaElettronica
$documento = $this->getDocumento();
$database = database();
$note_accredito = $database->fetchArray('SELECT numero_esterno, data FROM co_documenti WHERE id='.prepare($documento['ref_documento']));
$note_accredito = $database->fetchArray('SELECT numero_esterno AS id_documento, data FROM co_documenti WHERE id='.prepare($documento['ref_documento']));
$this->fatture_collegate = $note_accredito;
$dati_aggiuntivi = $documento->dati_aggiuntivi_fe;
$dati = $dati_aggiuntivi['dati_fatture'] ?: [];
$this->fatture_collegate = array_merge($note_accredito, $dati);
}
return $this->fatture_collegate;
@ -756,22 +766,34 @@ class FatturaElettronica
*
* @return array
*/
protected static function getDatiOrdineAcquisto($fattura)
protected static function getDatiOrdineAcquisto($fattura, $lista = null)
{
$ordini = $fattura->getOrdiniAcquisto();
$lista = isset($lista) ? $lista : $fattura->getOrdiniAcquisto();
$result = [];
foreach ($ordini as $element) {
if (!empty($element['id_documento_fe'])) {
$dati = [
'IdDocumento' => $element['id_documento_fe'],
foreach ($lista as $element) {
$dati = [];
foreach ($element['riferimento_linea'] as $linea){
$dati[] = [
'RiferimentoNumeroLinea' => $linea,
];
}
$dati['IdDocumento'] = $element['id_documento'];
if (!empty($element['data'])) {
$dati['Data'] = $element['data'];
}
if (!empty($element['num_item'])) {
$dati['NumItem'] = $element['num_item'];
}
if (!empty($element['codice_commessa'])) {
$dati['CodiceCommessaConvenzione'] = $element['codice_commessa'];
}
if (!empty($element['codice_cig'])) {
$dati['CodiceCIG'] = $element['codice_cig'];
}
@ -795,30 +817,37 @@ class FatturaElettronica
{
$contratti = $fattura->getContratti();
$result = [];
foreach ($contratti as $element) {
if (!empty($element['id_documento_fe'])) {
$dati = [
'IdDocumento' => $element['id_documento_fe'],
];
}
return self::getDatiOrdineAcquisto($fattura, $contratti);
}
if (!empty($element['num_item'])) {
$dati['NumItem'] = $element['num_item'];
}
/**
* Restituisce l'array responsabile per la generazione del tag DatiConvenzione.
*
* @return array
*/
protected static function getDatiConvenzione($fattura)
{
$documento = $fattura->getDocumento();
if (!empty($element['codice_cup'])) {
$dati['CodiceCUP'] = $element['codice_cup'];
}
$dati_aggiuntivi = $documento->dati_aggiuntivi_fe;
$dati = $dati_aggiuntivi['dati_convenzione'] ?: [];
if (!empty($element['codice_cig'])) {
$dati['CodiceCIG'] = $element['codice_cig'];
}
return self::getDatiOrdineAcquisto($fattura, $dati);
}
$result[] = $dati;
}
/**
* Restituisce l'array responsabile per la generazione del tag DatiRicezione.
*
* @return array
*/
protected static function getDatiRicezione($fattura)
{
$documento = $fattura->getDocumento();
return $result;
$dati_aggiuntivi = $documento->dati_aggiuntivi_fe;
$dati = $dati_aggiuntivi['dati_ricezione'] ?: [];
return self::getDatiOrdineAcquisto($fattura, $dati);
}
/**
@ -830,15 +859,7 @@ class FatturaElettronica
{
$fatture = $fattura->getFattureCollegate();
$result = [];
foreach ($fatture as $element) {
$result[] = [
'IdDocumento' => $element['numero_esterno'],
'Data' => $element['data'],
];
}
return $result;
return self::getDatiOrdineAcquisto($fattura, $fatture);
}
/**
@ -879,6 +900,30 @@ class FatturaElettronica
}
}
// Controllo le le righe per la fatturazione di contratti
$dati_convenzioni = static::getDatiConvenzione($fattura);
if (!empty($dati_convenzioni)) {
foreach ($dati_convenzioni as $dato) {
if (!empty($dato)) {
$result[] = [
'DatiConvenzione' => $dato,
];
}
}
}
// Controllo le le righe per la fatturazione di contratti
$dati_ricezioni = static::getDatiRicezione($fattura);
if (!empty($dati_ricezioni)) {
foreach ($dati_ricezioni as $dato) {
if (!empty($dato)) {
$result[] = [
'DatiRicezione' => $dato,
];
}
}
}
// Controllo le le righe per la fatturazione di contratti
$dati_fatture_collegate = static::getDatiFattureCollegate($fattura);
if (!empty($dati_fatture_collegate)) {