Aggiunta tabella in_fasceorarie_lang

This commit is contained in:
Pek5892 2024-02-28 11:39:12 +01:00
parent b1fbc4ce21
commit 088f520374
7 changed files with 58 additions and 18 deletions

View File

@ -28,21 +28,22 @@ switch (post('op')) {
$include_bank_holidays = post('include_bank_holidays');
$is_predefined = post('is_predefined');
if ($dbo->fetchNum('SELECT * FROM `in_fasceorarie` WHERE `nome`='.prepare($nome).' AND `id`!='.prepare($id_record)) == 0) {
if ($dbo->fetchNum('SELECT * FROM `in_fasceorarie` LEFT JOIN `in_fasceorarie_lang` ON (`in_fasceorarie_lang`.`id_record` = `in_fasceorarie`.`id` AND `in_fasceorarie_lang`.`id_lang` = '.prepare(setting('Lingua')).') WHERE `name`='.prepare($nome).' AND `in_fasceorarie`.`id`!='.prepare($id_record)) == 0) {
if (!empty($is_predefined)) {
$dbo->query('UPDATE in_fasceorarie SET is_predefined = 0');
$dbo->query('UPDATE `in_fasceorarie` SET `is_predefined` = 0');
}
$dbo->update('in_fasceorarie', [
'nome' => $nome,
'giorni' => $giorni ? implode(',', $giorni) : null,
'ora_inizio' => $ora_inizio,
'ora_fine' => $ora_fine,
'include_bank_holidays' => $include_bank_holidays,
'is_predefined' => $is_predefined,
], [
'id' => $id_record,
]);
], ['id' => $id_record]);
$dbo->update('in_fasceorarie_lang', [
'name' => $nome
], ['id_record' => $id_record, 'id_lang' => setting('Lingua')]);
flash()->info(tr('Salvataggio completato.'));
} else {
@ -58,14 +59,17 @@ switch (post('op')) {
$ora_inizio = post('ora_inizio');
$ora_fine = post('ora_fine');
if ($dbo->fetchNum('SELECT * FROM `in_fasceorarie` WHERE `nome`='.prepare($nome)) == 0) {
if ($dbo->fetchNum('SELECT * FROM `in_fasceorarie` LEFT JOIN `in_fasceorarie_lang` ON (`in_fasceorarie_lang`.`id_record` = `in_fasceorarie`.`id` AND `in_fasceorarie_lang`.`id_lang` = '.prepare(setting('Lingua')).') WHERE `name`='.prepare($nome)) == 0) {
$dbo->insert('in_fasceorarie', [
'nome' => $nome,
'ora_inizio' => $ora_inizio,
'ora_fine' => $ora_fine,
]);
$id_record = $dbo->lastInsertedID();
$dbo->insert('in_fasceorarie_lang', [
'name' => $nome,
'id_record' => $id_record,
'id_lang' => setting('Lingua'),
]);
$tipi_intervento = $dbo->select('in_tipiintervento', '*');
foreach ($tipi_intervento as $tipo_intervento) {

View File

@ -21,17 +21,17 @@ include_once __DIR__.'/../../../core.php';
switch ($resource) {
case 'fasce_orarie':
$query = 'SELECT id, nome AS descrizione FROM in_fasceorarie |where| ORDER BY nome ASC';
$query = 'SELECT `in_fasceorarie`.`id`, `name` AS `descrizione` FROM `in_fasceorarie` LEFT JOIN `in_fasceorarie_lang` ON (`in_fasceorarie_lang`.`id_record` = `in_fasceorarie`.`id` AND `in_fasceorarie_lang`.`id_lang` = '.prepare(setting('Lingua')).') |where| ORDER BY `name` ASC';
foreach ($elements as $element) {
$filter[] = 'id='.prepare($element);
$filter[] = '`in_fasceorarie`.`id`='.prepare($element);
}
if (empty($filter)) {
$where[] = 'in_fasceorarie.deleted_at IS NULL';
$where[] = '`in_fasceorarie`.`deleted_at` IS NULL';
}
if (!empty($search)) {
$search_fields[] = 'nome LIKE '.prepare('%'.$search.'%');
$search_fields[] = '`name` LIKE '.prepare('%'.$search.'%');
}
break;

View File

@ -38,7 +38,7 @@ use Modules\Pagamenti\Pagamento;
<div class="panel-body">
<div class="row">
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$nome$" ]}
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$name$" ]}
</div>
<div class="col-md-6">
@ -140,7 +140,7 @@ function aggiungiData() {
<?php
$elementi = $dbo->fetchArray('SELECT in_tipiintervento.codice, in_tipiintervento.descrizione, in_tipiintervento.idtipointervento FROM in_tipiintervento LEFT JOIN in_fasceorarie_tipiintervento ON in_tipiintervento.idtipointervento=in_fasceorarie_tipiintervento.idtipointervento WHERE in_fasceorarie_tipiintervento.idfasciaoraria='.prepare($id_record));
$elementi = $dbo->fetchArray('SELECT `in_tipiintervento`.`codice`, `in_tipiintervento`.`descrizione`, `in_tipiintervento`.`idtipointervento` FROM `in_tipiintervento` LEFT JOIN `in_fasceorarie_tipiintervento` ON `in_tipiintervento`.`idtipointervento`=`in_fasceorarie_tipiintervento`.`idtipointervento` WHERE `in_fasceorarie_tipiintervento`.`idfasciaoraria`='.prepare($id_record));
if (!empty($elementi)) {
echo '

View File

@ -20,5 +20,5 @@
include_once __DIR__.'/../../core.php';
if (isset($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM `in_fasceorarie` WHERE id='.prepare($id_record));
$record = $dbo->fetchOne('SELECT * FROM `in_fasceorarie` LEFT JOIN `in_fasceorarie_lang` ON (`in_fasceorarie_lang`.`id_record` = `in_fasceorarie`.`id` AND `in_fasceorarie_lang`.`id_lang` = '.prepare(setting('Lingua')).') WHERE `in_fasceorarie`.`id`='.prepare($id_record));
}

View File

@ -7,7 +7,7 @@ if (file_exists(__DIR__.'/../../../core.php')) {
}
// Fasce orarie per il tipo di attività
$fasce_orarie = $dbo->fetchArray("SELECT *, CONCAT (in_fasceorarie.nome, ' (', DATE_FORMAT(ora_inizio, '%H:%i'), '-', DATE_FORMAT(ora_fine, '%H:%i'), ')') AS descrizione FROM in_fasceorarie_tipiintervento INNER JOIN in_fasceorarie ON in_fasceorarie_tipiintervento.idfasciaoraria = in_fasceorarie.id WHERE idtipointervento=".prepare($id_record));
$fasce_orarie = $dbo->fetchArray("SELECT *, CONCAT (`in_fasceorarie_lang`.`name`, ' (', DATE_FORMAT(`ora_inizio`, '%H:%i'), '-', DATE_FORMAT(`ora_fine`, '%H:%i'), ')') AS descrizione FROM `in_fasceorarie_tipiintervento` INNER JOIN `in_fasceorarie` ON `in_fasceorarie_tipiintervento`.`idfasciaoraria` = `in_fasceorarie`.`id` LEFT JOIN `in_fasceorarie_lang` ON (`in_fasceorarie_lang`.`id_record` = `in_fasceorarie`.`id` AND `in_fasceorarie_lang`.`id_lang` = ".prepare(setting('Lingua')).") WHERE `idtipointervento`=".prepare($id_record));
echo '
<table class="table table-striped table-condensed table-hover table-bordered">

View File

@ -1255,4 +1255,39 @@ INSERT INTO `fe_tipi_documento_lang` (`id`, `id_lang`, `id_record`, `name`) SELE
ALTER TABLE `fe_tipi_documento`
DROP `descrizione`;
ALTER TABLE `fe_tipi_documento_lang` ADD CONSTRAINT `fe_tipi_documento_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `fe_tipi_documento`(`codice`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `fe_tipi_documento_lang` ADD CONSTRAINT `fe_tipi_documento_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `fe_tipi_documento`(`codice`) ON DELETE CASCADE ON UPDATE RESTRICT;
-- Aggiunta tabella in_fasceorarie_lang
CREATE TABLE IF NOT EXISTS `in_fasceorarie_lang` (
`id` int NOT NULL,
`id_lang` int NOT NULL,
`id_record` int NOT NULL,
`name` VARCHAR(255) NOT NULL
);
ALTER TABLE `in_fasceorarie_lang`
ADD PRIMARY KEY (`id`);
ALTER TABLE `in_fasceorarie_lang`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
INSERT INTO `in_fasceorarie_lang` (`id`, `id_lang`, `id_record`, `name`) SELECT NULL, (SELECT `id` FROM `zz_langs` WHERE `iso_code` = 'it'), `id`, `nome` FROM `in_fasceorarie`;
ALTER TABLE `in_fasceorarie`
DROP `nome`;
ALTER TABLE `in_fasceorarie` CHANGE `id` `id` INT NOT NULL AUTO_INCREMENT;
ALTER TABLE `in_fasceorarie_lang` ADD CONSTRAINT `in_fasceorarie_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `in_fasceorarie`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
-- Allineamento vista Fasce orarie
UPDATE `zz_modules` SET `options` = "
SELECT
|select|
FROM
`in_fasceorarie`
LEFT JOIN `in_fasceorarie_lang` ON (`in_fasceorarie_lang`.`id_record` = `in_fasceorarie`.`id` AND `in_fasceorarie_lang`.|lang|)
WHERE
1=1 AND deleted_at IS NULL
HAVING
2=2" WHERE `name` = 'Fasce orarie';
UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = '`in_fasceorarie_lang`.`name`' WHERE `zz_modules`.`name` = 'Fasce orarie' AND `zz_views`.`name` = 'nOME';

View File

@ -113,6 +113,7 @@ return [
'in_tipiintervento',
'in_vociservizio',
'in_fasceorarie',
'in_fasceorarie_lang',
'in_fasceorarie_tipiintervento',
'mg_articoli',
'mg_fornitore_articolo',