{[ "type": "select", "label": "", "name": "idagente", "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Agente' AND deleted=0 ORDER BY ragione_sociale", "value": "$idagente$" ]}
';
- } else {
- $result = self::getLink($prints[0]['id'], $id_record, $class);
- }
-
- return $result;
+ return '{( "name": "button", "type": "print", "id": "'.$print.'", "id_record": "'.$id_record.'", "label": "'.$title.'", "icon": "'.$icon.'", "parameters": "'.$get.'", "class": "'.$btn.'" )}';
}
}
diff --git a/templates/info.php b/templates/info.php
index ef6df0011..c7fa55f1f 100644
--- a/templates/info.php
+++ b/templates/info.php
@@ -33,19 +33,7 @@ $keys = [];
// Predisposizione delle informazioni delle anagrafiche per la sostituzione automatica
foreach ($replace as $prefix => $values) {
- // Individuazione dei campi minimi
$values = (array) $values;
- if ($prefix == 'c_') {
- $keys = array_keys($values);
- }
-
- // Se l'azienda predefinita non è impostata
- if (empty($values) && $prefix == 'f_') {
- $values = [];
- foreach ($keys as $key) {
- $values[$key] = '';
- }
- }
// Rinominazione dei campi
foreach ($rename as $key => $value) {
@@ -53,11 +41,6 @@ foreach ($replace as $prefix => $values) {
unset($values[$key]);
}
- // Salvataggio dei campi come variabili PHP
- foreach ($values as $key => $value) {
- ${$prefix.$key} = $value;
- }
-
// Eventuali estensioni dei contenuti
$citta = '';
if (!empty($values['cap'])) {
@@ -72,13 +55,25 @@ foreach ($replace as $prefix => $values) {
$values['citta_full'] = $citta;
- // Completamento dei campi minimi
- if ($key == 'c_') {
- $keys = array_unique(array_merge($keys, array_keys($values)));
+ $replace[$prefix] = $values;
+
+ // Individuazione dei campi minimi
+ $keys = array_merge($keys, array_keys($values));
+}
+
+$keys = array_unique($keys);
+
+foreach ($replace as $prefix => $values) {
+ // Impostazione di default per le informazioni mancanti
+ foreach ($keys as $key) {
+ if (!isset($values[$key])) {
+ $values[$key] = '';
+ }
}
- // Aggiunta delle informazioni per la sostituzione automatica
+ // Salvataggio dei campi come variabili PHP e aggiunta delle informazioni per la sostituzione automatica
foreach ($values as $key => $value) {
+ ${$prefix.$key} = $value;
$replaces[$prefix.$key] = $value;
}
}
@@ -93,3 +88,5 @@ $replaces = array_merge($replaces, [
'footer' => !empty($footer) ? $footer : '',
'dicitura_fissa_fattura' => get_var('Dicitura fissa fattura'),
]);
+
+unset($replace);
diff --git a/templates/interventi/init.php b/templates/interventi/init.php
index 115ea8f08..70b7f73bd 100644
--- a/templates/interventi/init.php
+++ b/templates/interventi/init.php
@@ -7,7 +7,7 @@ include_once $docroot.'/modules/interventi/modutil.php';
$module_name = 'Interventi';
// carica intervento
-$query = 'SELECT in_interventi.*, (SELECT numero FROM co_contratti WHERE id=(SELECT idcontratto FROM co_righe_contratti WHERE idintervento=in_interventi.id)) AS numero_contratto, (SELECT numero FROM co_preventivi WHERE id=(SELECT idpreventivo FROM co_preventivi_interventi WHERE idintervento=in_interventi.id ORDER BY idpreventivo DESC LIMIT 0,1)) AS numero_preventivo, (SELECT SUM(prezzo_dirittochiamata) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_dirittochiamata`, (SELECT SUM(km) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_km`, (SELECT SUM(ore*prezzo_ore_unitario) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_ore_consuntivo`, (SELECT SUM(prezzo_km_consuntivo) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_km_consuntivo`, in_interventi.descrizione AS `descrizione_intervento`, richiesta, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento) AS tipointervento FROM in_interventi INNER JOIN in_tipiintervento ON in_interventi.idtipointervento=in_tipiintervento.idtipointervento WHERE id='.prepare($idintervento).' '.Modules::getAdditionalsQuery('Interventi');
+$query = 'SELECT in_interventi.*, (SELECT numero FROM co_contratti WHERE id=(SELECT idcontratto FROM co_righe_contratti WHERE idintervento=in_interventi.id)) AS numero_contratto, (SELECT numero FROM co_preventivi WHERE id=(SELECT idpreventivo FROM co_preventivi_interventi WHERE idintervento=in_interventi.id ORDER BY idpreventivo DESC LIMIT 0,1)) AS numero_preventivo, (SELECT SUM(prezzo_dirittochiamata) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_dirittochiamata`, (SELECT SUM(km) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_km`, (SELECT SUM(ore*prezzo_ore_unitario) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_ore_consuntivo`, (SELECT SUM(prezzo_km_consuntivo) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_km_consuntivo`, in_interventi.descrizione AS `descrizione_intervento`, richiesta, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento) AS tipointervento FROM in_interventi INNER JOIN in_tipiintervento ON in_interventi.idtipointervento=in_tipiintervento.idtipointervento WHERE id='.prepare($id_record).' '.Modules::getAdditionalsQuery('Interventi');
$records = $dbo->fetchArray($query);
$costi_intervento = get_costi_intervento($id_record);
diff --git a/templates/partitario_mastrino/pdfgen.partitario_mastrino.php b/templates/partitario_mastrino/pdfgen.partitario_mastrino.php
index d38a2f96d..8c777110b 100644
--- a/templates/partitario_mastrino/pdfgen.partitario_mastrino.php
+++ b/templates/partitario_mastrino/pdfgen.partitario_mastrino.php
@@ -51,11 +51,11 @@ if ($_GET['lev'] == '3') {
\n";
- // Inizializzo saldo finale
- $saldo_finale = 0;
+ // Inizializzo saldo finale
+ $saldo_finale = 0;
- // Calcolo saldo iniziale
- $rs = $dbo->fetchArray('SELECT SUM(totale) AS totale FROM co_movimenti WHERE idconto="'.$idconto.'" AND data < "'.$_SESSION['period_start'].'"');
+ // Calcolo saldo iniziale
+ $rs = $dbo->fetchArray('SELECT SUM(totale) AS totale FROM co_movimenti WHERE idconto="'.$idconto.'" AND data < "'.$_SESSION['period_start'].'"');
$saldo_iniziale = $rs[0]['totale'];
$saldo_finale = $saldo_iniziale;
@@ -93,8 +93,8 @@ if ($_GET['lev'] == '3') {
$avere = '';
}
- // Mostro il saldo finale
- $body .= "
\n";
- // Ciclo fra i sotto-conti di livello 2
- $rs3 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2="'.$idconto.'"');
+ // Ciclo fra i sotto-conti di livello 2
+ $rs3 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2="'.$idconto.'"');
for ($z = 0; $z < sizeof($rs3); ++$z) {
// Inizializzo saldo finale
- $saldo_finale = 0;
+ $saldo_finale = 0;
- // Calcolo saldo iniziale
- $rs = $dbo->fetchArray('SELECT SUM(totale) AS totale FROM co_movimenti WHERE idconto="'.$rs3[$z]['id'].'" AND data < "'.$_SESSION['period_start'].'"');
+ // Calcolo saldo iniziale
+ $rs = $dbo->fetchArray('SELECT SUM(totale) AS totale FROM co_movimenti WHERE idconto="'.$rs3[$z]['id'].'" AND data < "'.$_SESSION['period_start'].'"');
$saldo_iniziale = $rs[0]['totale'];
$saldo_finale = $saldo_iniziale;
@@ -146,8 +146,8 @@ elseif ($_GET['lev'] == '2') {
$avere = Translator::numberToLocale(abs($totale));
}
- // Mostro il saldo finale del conto di livello 3
- $body .= "
\n";
- // Ciclo fra il conto principale scelto (Economico o Patrimoniale)
- $rs1 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti1 WHERE id="'.$idconto.'" ORDER BY numero DESC');
+ // Ciclo fra il conto principale scelto (Economico o Patrimoniale)
+ $rs1 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti1 WHERE id="'.$idconto.'" ORDER BY numero DESC');
for ($x = 0; $x < sizeof($rs1); ++$x) {
// Ciclo fra i sotto-conti di livello 1
- $rs2 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti2 WHERE idpianodeiconti1="'.$rs1[$x]['id'].'"');
+ $rs2 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti2 WHERE idpianodeiconti1="'.$rs1[$x]['id'].'"');
for ($y = 0; $y < sizeof($rs2); ++$y) {
$body .= "
\n";
- // Ciclo fra i sotto-conti di livello 2
- $rs3 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2="'.$rs2[$y]['id'].'"');
+ // Ciclo fra i sotto-conti di livello 2
+ $rs3 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2="'.$rs2[$y]['id'].'"');
for ($z = 0; $z < sizeof($rs3); ++$z) {
$dare = 0;
@@ -206,8 +206,8 @@ elseif ($_GET['lev'] == '1') {
$ricavi += abs($avere);
}
- // Mostro il saldo finale del conto di livello 3
- $body .= "