Skip to content

Commit 28c3276

Browse files
committed
refactor: ottimizzazione per traduzioni
1 parent 820adea commit 28c3276

13 files changed

Lines changed: 15 additions & 15 deletions

File tree

include/common/importa.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
$fatt_differita_vendita = Tipofattura::where('name', 'Fattura differita di vendita')->first()->id;
115115

116116
if (!empty($options['reversed'])) {
117-
$idtipodocumento = database()->fetchOne('SELECT `co_tipidocumento`.`id` FROM `co_tipidocumento` LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento_lang`.`id_record` = `co_tipidocumento`.`id` AND `co_tipidocumento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `title` = "Nota di credito" AND `dir` = \''.$dir.'\'')['id'];
117+
$idtipodocumento = database()->fetchOne('SELECT `co_tipidocumento`.`id` FROM `co_tipidocumento` WHERE `co_tipidocumento`.`name` = "Nota di credito" AND `dir` = \''.$dir.'\'')['id'];
118118
} elseif (in_array($original_module->id, [$id_module_ddt_vendita, $id_module_ddt_acquisto])) {
119119
$idtipodocumento = database()->fetchOne('SELECT `co_tipidocumento`.`id` FROM `co_tipidocumento` LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento_lang`.`id_record` = `co_tipidocumento`.`id` AND `co_tipidocumento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `co_tipidocumento`.`id` = '.($dir == 'uscita' ? $fatt_differita_acquisto : $fatt_differita_vendita).' AND `dir` = \''.$dir.'\'')['id'];
120120
} else {
@@ -179,7 +179,7 @@
179179

180180
echo '
181181
<div class="col-md-4">
182-
{[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT * ,`or_statiordine`.`id`, `or_statiordine_lang`.`title` AS descrizione FROM `or_statiordine` LEFT JOIN `or_statiordine_lang` ON (`or_statiordine`.`id` = `or_statiordine_lang`.`id_record` AND `or_statiordine_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `title` IN(\'Bozza\', \'Accettato\', \'In attesa di conferma\', \'Annullato\')", "value": "'.$stato_predefinito.'" ]}
182+
{[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT * ,`or_statiordine`.`id`, `or_statiordine_lang`.`title` AS descrizione FROM `or_statiordine` WHERE `or_statiordine`.`name` IN(\'Bozza\', \'Accettato\', \'In attesa di conferma\', \'Annullato\')", "value": "'.$stato_predefinito.'" ]}
183183
</div>';
184184
}
185185
echo '

modules/fatture/controller_before.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
$is_estera = false;
9191

9292
if (setting('Rimuovi avviso fatture estere')) {
93-
$is_estera = $database->fetchOne('SELECT `idanagrafica` FROM `an_anagrafiche` INNER JOIN `an_nazioni` ON `an_anagrafiche`.`id_nazione` = `an_nazioni`.`id` LEFT JOIN `an_nazioni_lang` ON (`an_nazioni`.`id` = `an_nazioni_lang`.`id_record` AND `an_nazioni_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `an_nazioni_lang`.`title` != "Italia" AND `an_anagrafiche`.`idanagrafica` = '.prepare($documento->idanagrafica));
93+
$is_estera = $database->fetchOne('SELECT `idanagrafica` FROM `an_anagrafiche` INNER JOIN `an_nazioni` ON `an_anagrafiche`.`id_nazione` = `an_nazioni`.`id` WHERE `an_nazioni`.`name` != "Italia" AND `an_anagrafiche`.`idanagrafica` = '.prepare($documento->idanagrafica));
9494
}
9595

9696
if ($documento->data <= $data_limite_invio && !$is_estera) {

modules/fatture/edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
if (empty($record['is_fiscale'])) {
274274
$query .= " WHERE `co_statidocumento`.`id` = $id_stato_bozza";
275275

276-
$plugin = $dbo->fetchArray('SELECT `zz_plugins`.`id` FROM `zz_plugins` LEFT JOIN `zz_plugins_lang` ON (`zz_plugins`.`id` = `zz_plugins_lang`.`id_record` AND `zz_plugins_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).") WHERE `title`='Fatturazione Elettronica' AND `idmodule_to` = ".prepare($id_module));
276+
$plugin = $dbo->fetchArray('SELECT `zz_plugins`.`id` FROM `zz_plugins` WHERE `zz_plugins`.`name`="Fatturazione Elettronica" AND `idmodule_to` = '.prepare($id_module));
277277
echo '<script> $("li.btn-default.nav-item:has(#link-tab_'.$plugin[0]['id'].')").addClass("disabled"); </script>';
278278
}
279279
// Forzo il passaggio della fattura da Bozza ad Emessa per il corretto calcolo del numero.

modules/interventi/bulk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
if (empty($id_documento)) {
159159
if (!empty($accodare)) {
160160
$where = $raggruppamento == 'sede' ? ' AND `idsede_destinazione` = '.prepare($intervento['idsede_destinazione']) : '';
161-
$documento = $dbo->fetchOne('SELECT `co_documenti`.`id` FROM `co_documenti` INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` LEFT JOIN `co_statidocumento_lang` ON (`co_statidocumento`.`id` = `co_statidocumento_lang`.`id_record` AND `co_statidocumento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') INNER JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` INNER JOIN `zz_segments` ON `zz_segments`.`id` = `co_documenti`.`id_segment` WHERE `co_statidocumento_lang`.`title` = "Bozza" AND `co_documenti`.`idanagrafica` = '.prepare($id_anagrafica).' AND `co_tipidocumento`.`id`='.prepare($tipo_documento['id']).' AND `co_documenti`.`id_segment` = '.prepare($id_segment).$where);
161+
$documento = $dbo->fetchOne('SELECT `co_documenti`.`id` FROM `co_documenti` INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` INNER JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` INNER JOIN `zz_segments` ON `zz_segments`.`id` = `co_documenti`.`id_segment` WHERE `co_statidocumento`.`name` = "Bozza" AND `co_documenti`.`idanagrafica` = '.prepare($id_anagrafica).' AND `co_tipidocumento`.`id`='.prepare($tipo_documento['id']).' AND `co_documenti`.`id_segment` = '.prepare($id_segment).$where);
162162

163163
$id_documento = $documento['id'];
164164
$id_documento_cliente[$id_anagrafica] = $id_documento;

modules/ordini/modals/duplicazione.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232
3333
<div class="col-md-3">
34-
{[ "type": "select", "label": "'.tr('Stato').'", "name": "idstatoordine", "required": 1, "values": "query=SELECT `or_statiordine`.`id`, `or_statiordine_lang`.`title` as descrizione FROM `or_statiordine` LEFT JOIN `or_statiordine_lang` ON (`or_statiordine_lang`.`id_record`=`or_statiordine`.`id` AND `or_statiordine_lang`.`id_lang`= '.prepare(Models\Locale::getDefault()->id).') WHERE `title` IN(\'Bozza\', \'Accettato\', \'In attesa di conferma\')", "value": "1" ]}
34+
{[ "type": "select", "label": "'.tr('Stato').'", "name": "idstatoordine", "required": 1, "values": "query=SELECT `or_statiordine`.`id`, `or_statiordine_lang`.`title` as descrizione FROM `or_statiordine` WHERE `or_statiordine`.`name` IN(\'Bozza\', \'Accettato\', \'In attesa di conferma\')", "value": "1" ]}
3535
</div>
3636
3737
<div class="col-md-3">

modules/pagamenti/actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
flash()->info(tr('Elemento eliminato con successo!'));
121121

122122
if ($id_record == $id) {
123-
$res = $dbo->fetchArray('SELECT * FROM `co_pagamenti` LEFT JOIN `co_pagamenti_lang` WHERE `co_pagamenti`.`id`!='.prepare($id).' AND `title`='.prepare($record['descrizione']));
123+
$res = $dbo->fetchArray('SELECT * FROM `co_pagamenti` WHERE `co_pagamenti`.`id`!='.prepare($id).' AND `co_pagamenti`.`name`='.prepare($record['descrizione']));
124124
if (count($res) != 0) {
125125
redirect_url(base_path_osm().'/editor.php?id_module='.$id_module.'&id_record='.$res[0]['id']);
126126
} else {

modules/pagamenti/edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
],
114114
];
115115

116-
$results = $dbo->fetchArray('SELECT *, `co_pagamenti`.`id` as id FROM `co_pagamenti` LEFT JOIN `co_pagamenti_lang` ON (`co_pagamenti`.`id` = `co_pagamenti_lang`.`id_record` AND `co_pagamenti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `title`='.prepare($record['name']).' ORDER BY `num_giorni` ASC');
116+
$results = $dbo->fetchArray('SELECT *, `co_pagamenti`.`id` as id FROM `co_pagamenti` WHERE `co_pagamenti`.`name`='.prepare($record['name']).' ORDER BY `num_giorni` ASC');
117117
$numero_rata = 1;
118118
foreach ($results as $result) {
119119
$tipo_scadenza_pagamento = 3;

modules/preventivi/actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
], ['id' => $idintervento]);
155155

156156
// Imposto il preventivo nello stato "In lavorazione" se inizio ad aggiungere interventi
157-
$dbo->query('UPDATE `co_preventivi` SET `idstato`=(SELECT `id` FROM `co_statipreventivi` LEFT JOIN `co_statipreventivi_lang ON (`co_statipreventivi_lang`.`id_record` = `co_statipreventivi`.`id` AND `co_statipreventivi_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).") WHERE `title`='In lavorazione') WHERE `co_preventivi`.`id`=".prepare($id_record));
157+
$dbo->query('UPDATE `co_preventivi` SET `idstato`=(SELECT `id` FROM `co_statipreventivi` WHERE `co_statipreventivi`.`name`="In lavorazione") WHERE `co_preventivi`.`id`='.prepare($id_record));
158158

159159
flash()->info(tr('Intervento _NUM_ aggiunto!', [
160160
'_NUM_' => $rs[0]['codice'],

modules/tipi_scadenze/actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$tipo->save();
3939
flash()->info(tr('Salvataggio completato.'));
4040

41-
$segmento = $dbo->fetchOne('SELECT `zz_segments`.`id` FROM `zz_segments` LEFT JOIN `zz_segments_lang` ON (`zz_segments_lang`.`id_record` = `zz_segments`.`id` AND `zz_segments_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `id_module` = '.prepare(Module::where('name', 'Scadenzario')->first()->id).' AND `clause` = "co_scadenziario.tipo=\''.$nome_prev.'\'" AND `zz_segments_lang`.`title` = "Scadenzario '.$nome_prev.'"')['id'];
41+
$segmento = $dbo->fetchOne('SELECT `zz_segments`.`id` FROM `zz_segments` WHERE `id_module` = '.prepare(Module::where('name', 'Scadenzario')->first()->id).' AND `clause` = "co_scadenziario.tipo=\''.$nome_prev.'\'" AND `zz_segments`.`name` = "Scadenzario '.$nome_prev.'"')['id'];
4242

4343
$dbo->update('zz_segments', [
4444
'clause' => 'co_scadenziario.tipo="'.$nome.'"',

plugins/importFE/generate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ function cleanup(){
336336
{[ "type": "select", "label": "'.tr('Fattura collegata').'", "name": "ref_fattura", "required": 0, "values": "query='.$query.'" ]}
337337
</div>';
338338
} elseif ($dati_generali['TipoDocumento'] == 'TD06') {
339-
$query .= 'AND `co_documenti`.`id_segment` = (SELECT `zz_segments`.`id` FROM `zz_segments` LEFT JOIN `zz_segments_lang` ON (`zz_segments_lang`.`id_record` = `zz_segments`.`id` AND `zz_segments_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).") WHERE `title` = 'Fatture pro-forma' AND `id_module` = ".prepare($id_module).')';
339+
$query .= 'AND `co_documenti`.`id_segment` = (SELECT `zz_segments`.`id` FROM `zz_segments` WHERE `zz_segments`.`name` = "Fatture pro-forma" AND `id_module` = '.prepare($id_module).')';
340340

341341
echo '
342342
<div class="col-md-3">

0 commit comments

Comments
 (0)