Aggiunta tabella zz_widgets_lang

This commit is contained in:
Pek5892 2024-03-04 12:28:16 +01:00
parent 04f0d8a20c
commit cd92b6b58f
6 changed files with 38 additions and 8 deletions

View File

@ -20,7 +20,7 @@
include_once __DIR__.'/../../../core.php';
// Trovo id_print della stampa
$id_print = $dbo->fetchOne('SELECT zz_prints.id FROM zz_prints INNER JOIN zz_modules ON zz_prints.id_module=zz_modules.id WHERE zz_modules.name="Articoli" AND zz_prints.name="Inventario magazzino"')['id'];
$id_print = $dbo->fetchOne('SELECT `zz_prints`.`id` FROM `zz_prints` INNER JOIN `zz_modules` ON `zz_prints`.`id_module`=`zz_modules`.`id` WHERE `zz_modules`.`name`="Articoli" AND `zz_prints`.`name`="Inventario magazzino"')['id'];
echo '
<form action="'.base_path().'/pdfgen.php?id_print='.$id_print.'" method="post" target="_blank">

View File

@ -31,10 +31,15 @@ echo '
</tr>
</thead>';
$widgets = $dbo->fetchArray('SELECT zz_widgets.*, zz_modules.name AS modulo
FROM zz_widgets
INNER JOIN zz_modules ON zz_widgets.id_module = zz_modules.id
ORDER BY `id_module` ASC, `zz_widgets`.`order` ASC');
$widgets = $dbo->fetchArray('SELECT
`zz_widgets`.*,
`zz_widgets_lang`.`name` as name,
`zz_modules`.`name` AS modulo
FROM zz_widgets
LEFT JOIN `zz_widgets_lang` ON (`zz_widgets`.`id` = `zz_widgets_lang`.`id_record` AND `zz_widgets_lang`.`id_lang` = "'.setting('Lingua').'")
INNER JOIN `zz_modules` ON `zz_widgets`.`id_module` = `zz_modules`.`id`
ORDER BY
`id_module` ASC, `zz_widgets`.`order` ASC');
$gruppi = collect($widgets)->groupBy('modulo');
foreach ($gruppi as $modulo => $widgets) {

View File

@ -44,7 +44,7 @@ class WidgetManager implements ManagerInterface
$database = database();
// Widget richiesto
$widget = $database->fetchArray('SELECT * FROM zz_widgets WHERE id = '.prepare($options['id']))[0];
$widget = $database->fetchArray('SELECT * FROM `zz_widgets` LEFT JOIN `zz_widgets_lang` ON (`zz_widgets`.`id` = `zz_widgets_lang`.`id_record` AND `zz_widgets_lang`.`id_lang` = '.prepare(setting('Lingua')).') WHERE `zz_widgets`.`id` = '.prepare($options['id']))[0];
$result = ' ';

View File

@ -105,7 +105,7 @@ foreach ($data['results'] as $r) {
<td>'.$r['Categoria'].'</td>
<td>'.$articolo->name.'</td>
<td class="text-right">'.moneyFormat($articolo->prezzo_vendita).'</td>
<td class="text-right">'.Translator::numberToLocale($r['qta_totale']).' '.$r['um'].'</td>
<td class="text-right">'.Translator::numberToLocale($articolo->qta).' '.$articolo->um.'</td>
<td class="text-right">'.moneyFormat($articolo->prezzo_acquisto).'</td>
<td class="text-right">'.moneyFormat($valore_magazzino).'</td>
</tr>';

View File

@ -1734,3 +1734,27 @@ INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`
INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES
(NULL, (SELECT id FROM zz_modules WHERE name = 'Articoli'), 0, 'Inventario cespiti', 'Inventario cespiti', 'Cespiti', 'magazzino_cespiti', '', '', 'fa fa-print', '', '', 0, 0, 1, 1);
-- Aggiunta tabella zz_widgets_lang
CREATE TABLE IF NOT EXISTS `zz_widgets_lang` (
`id` int NOT NULL,
`id_lang` int NOT NULL,
`id_record` int NOT NULL,
`name` VARCHAR(255) NOT NULL
);
ALTER TABLE `zz_widgets_lang`
ADD PRIMARY KEY (`id`);
ALTER TABLE `zz_widgets_lang`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
INSERT INTO `zz_widgets_lang` (`id`, `id_lang`, `id_record`, `name`) SELECT NULL, (SELECT `id` FROM `zz_langs` WHERE `iso_code` = 'it'), `id`, `name` FROM `zz_widgets`;
ALTER TABLE `zz_widgets`
DROP `name`;
ALTER TABLE `zz_widgets_lang` ADD CONSTRAINT `zz_widgets_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `zz_widgets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(co_preventivi.id) AS dato FROM co_preventivi INNER JOIN co_statipreventivi ON co_preventivi.idstato = co_statipreventivi.id LEFT JOIN co_statipreventivi_lang ON (co_statipreventivi_lang.id_record = co_statipreventivi.id AND co_statipreventivi_lang.id_lang = (SELECT valore FROM zz_settings WHERE nome = \"Lingua\")) WHERE name =\"In lavorazione\" AND default_revision=1' WHERE `zz_widgets`.`id` = (SELECT `id_record` FROM `zz_widgets_lang` WHERE `name` = 'Preventivi in lavorazione');
UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(`dati`.`id`) AS dato FROM (SELECT `co_contratti`.`id`,((SELECT SUM(`co_righe_contratti`.`qta`) FROM `co_righe_contratti` WHERE `co_righe_contratti`.`um` = \"ore\" AND `co_righe_contratti`.`idcontratto` = `co_contratti`.`id`) - IFNULL((SELECT SUM(`in_interventi_tecnici`.`ore`) FROM `in_interventi_tecnici` INNER JOIN `in_interventi` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` WHERE `in_interventi`.`id_contratto` = `co_contratti`.`id` AND `in_interventi`.`idstatointervento` IN (SELECT `in_statiintervento`.`id` FROM `in_statiintervento` WHERE `in_statiintervento`.`is_completato` = 1)),0)) AS `ore_rimanenti`, DATEDIFF(`data_conclusione`, NOW()) AS giorni_rimanenti, `data_conclusione`, `ore_preavviso_rinnovo`, `giorni_preavviso_rinnovo`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica` = `co_contratti`.`idanagrafica`) AS ragione_sociale FROM `co_contratti` INNER JOIN `co_staticontratti` ON `co_staticontratti`.`id` = `co_contratti`.`idstato` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = (SELECT `valore` FROM `zz_settings` WHERE `name` = "Lingua")) WHERE `rinnovabile` = 1 AND YEAR(`data_conclusione`) > 1970 AND `co_contratti`.`id` NOT IN (SELECT `idcontratto_prev` FROM `co_contratti` contratti) AND `co_staticontratti_lang`.`name` NOT IN (\"Concluso\", \"Rifiutato\", \"Bozza\") HAVING (`ore_rimanenti` <= `ore_preavviso_rinnovo` OR DATEDIFF(`data_conclusione`, NOW()) <= ABS(`giorni_preavviso_rinnovo`)) ORDER BY `giorni_rimanenti` ASC,`ore_rimanenti` ASC) dati' WHERE `zz_widgets`.`id` = (SELECT `id_record` FROM `zz_widgets_lang` WHERE `name` = 'Contratti in scadenza');

View File

@ -187,4 +187,5 @@ return [
'zz_user_sedi',
'zz_views',
'zz_widgets',
'zz_widgets_lang',
];