diff --git a/lib/util.php b/lib/util.php index cde7af85a..0ed471c86 100755 --- a/lib/util.php +++ b/lib/util.php @@ -185,7 +185,7 @@ if (!function_exists('replace')) { */ function replace($string, $array) { - return str_replace(array_keys($array), array_values($array), $string); + return str_replace(array_keys($array), array_values($array), (string) $string); } } diff --git a/modules/eventi/actions.php b/modules/eventi/actions.php new file mode 100644 index 000000000..60712b5df --- /dev/null +++ b/modules/eventi/actions.php @@ -0,0 +1,92 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +switch (post('op')) { + case 'update': + $nome = post('nome'); + $data = post('data'); + $id_nazione = post('id_nazione'); + $id_regione = post('id_regione'); + $is_recurring = post('is_recurring'); + $is_bank_holiday = post('is_recurring'); + + if ($dbo->fetchNum('SELECT * FROM `zz_events` WHERE `nome`='.prepare($nome).' AND `id`!='.prepare($id_record)) == 0) { + + $dbo->update('zz_events', [ + 'nome' => $nome, + 'data' => $data, + 'id_nazione' =>$id_nazione, + 'id_regione' => $id_regione, + 'is_recurring' => $is_recurring, + 'is_bank_holiday' => $is_bank_holiday, + ], [ + 'id' => $id_record, + ]); + + + flash()->info(tr('Salvataggio completato.')); + } else { + flash()->error(tr("E' già presente un _TYPE_ con lo stesso nome", [ + '_TYPE_' => 'evento', + ])); + } + + break; + + case 'add': + $nome = post('nome'); + $id_nazione = post('id_nazione'); + if ($dbo->fetchNum('SELECT * FROM `zz_events` WHERE `id_nazione` = '.prepare($id_nazione).' AND `nome`='.prepare($nome)) == 0) { + + $dbo->insert('zz_events', [ + 'nome' => $nome, + 'id_nazione' => $id_nazione, + ]); + + $id_record = $dbo->lastInsertedID(); + + if (isAjaxRequest()) { + echo json_encode(['id' => $id_record, 'text' => $nome]); + } + + flash()->info(tr('Aggiunto nuovo _TYPE_', [ + '_TYPE_' => 'evento', + ])); + } else { + flash()->error(tr("E' già presente un _TYPE_ con lo stesso nome e nazione", [ + '_TYPE_' => 'evento', + ])); + } + + break; + + case 'delete': + + $dbo->delete('zz_events', [ + 'id' => $id_record, + ]); + + flash()->info(tr('_TYPE_ eliminato con successo.', [ + '_TYPE_' => 'Evento', + ])); + + break; +} diff --git a/modules/eventi/add.php b/modules/eventi/add.php new file mode 100644 index 000000000..e937fa9f0 --- /dev/null +++ b/modules/eventi/add.php @@ -0,0 +1,43 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +?>
diff --git a/modules/eventi/ajax/select.php b/modules/eventi/ajax/select.php new file mode 100644 index 000000000..d1d9dab8c --- /dev/null +++ b/modules/eventi/ajax/select.php @@ -0,0 +1,35 @@ +. + */ + +include_once __DIR__.'/../../../core.php'; + +switch ($resource) { + case 'fasce_orarie': + $query = 'SELECT id, nome AS descrizione FROM zz_events |where| ORDER BY nome ASC'; + + foreach ($elements as $element) { + $filter[] = 'id='.prepare($element); + } + + if (!empty($search)) { + $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); + } + + break; +} diff --git a/modules/eventi/edit.php b/modules/eventi/edit.php new file mode 100644 index 000000000..7371db15a --- /dev/null +++ b/modules/eventi/edit.php @@ -0,0 +1,74 @@ +. + */ + +use Carbon\Carbon; +include_once __DIR__.'/../../core.php'; + +//$block_edit = $record['is_predefined']; + +?> + + + + + + diff --git a/modules/eventi/init.php b/modules/eventi/init.php new file mode 100644 index 000000000..2b56bc5e3 --- /dev/null +++ b/modules/eventi/init.php @@ -0,0 +1,24 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +if (isset($id_record)) { + $record = $dbo->fetchOne('SELECT * FROM `zz_events` WHERE id='.prepare($id_record)); +} diff --git a/modules/fasce_orarie/actions.php b/modules/fasce_orarie/actions.php new file mode 100644 index 000000000..4ba9f1090 --- /dev/null +++ b/modules/fasce_orarie/actions.php @@ -0,0 +1,103 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +switch (post('op')) { + case 'update': + $nome = post('nome'); + $giorni = (array) post('giorni'); + $ora_inizio = post('ora_inizio'); + $ora_fine = post('ora_fine'); + $include_bank_holidays = post('include_bank_holidays'); + + if ($dbo->fetchNum('SELECT * FROM `in_fasceorarie` WHERE `nome`='.prepare($nome).' AND `id`!='.prepare($id_record)) == 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, + ], [ + 'id' => $id_record, + ]); + + + flash()->info(tr('Salvataggio completato.')); + } else { + flash()->error(tr("E' già presente una _TYPE_ con lo stesso nome", [ + '_TYPE_' => 'fascia oraria', + ])); + } + + break; + + case 'add': + $nome = post('nome'); + + if ($dbo->fetchNum('SELECT * FROM `in_fasceorarie` WHERE `nome`='.prepare($nome)) == 0) { + + $dbo->insert('in_fasceorarie', [ + 'nome' => $nome, + ]); + + $id_record = $dbo->lastInsertedID(); + + if (isAjaxRequest()) { + echo json_encode(['id' => $id_record, 'text' => $nome]); + } + + flash()->info(tr('Aggiunta nuova _TYPE_', [ + '_TYPE_' => 'fascia oraria', + ])); + } else { + flash()->error(tr("E' già presente una _TYPE_ con lo stesso nome", [ + '_TYPE_' => 'fascia oraria', + ])); + } + + break; + + case 'delete': + $tipi_interventi = $dbo->fetchNum('SELECT idtipointervento FROM in_fasceorarie_tipiintervento WHERE idfasciaoraria='.prepare($id_record)); + + if (isset($id_record) && empty($tipi_interventi)) { + + $dbo->delete('in_fasceorarie', [ + 'id' => $id_record, + 'can_delete' => 1, + ]); + + flash()->info(tr('_TYPE_ eliminata con successo.', [ + '_TYPE_' => 'Fascia oraria', + ])); + + } else { + + flash()->error(tr('Sono presenti dei tipi interventi collegate a questa fascia oraria.')); + + # soft delete + /*$dbo->update('in_fasceorarie', [ + 'deleted_at' => date('Y-m-d H:i:s'), + ], ['id' => $id_record, 'can_delete' => 1]);*/ + } + + break; +} diff --git a/modules/fasce_orarie/add.php b/modules/fasce_orarie/add.php new file mode 100644 index 000000000..afb7a3023 --- /dev/null +++ b/modules/fasce_orarie/add.php @@ -0,0 +1,38 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +?> diff --git a/modules/fasce_orarie/ajax/select.php b/modules/fasce_orarie/ajax/select.php new file mode 100644 index 000000000..26261053e --- /dev/null +++ b/modules/fasce_orarie/ajax/select.php @@ -0,0 +1,35 @@ +. + */ + +include_once __DIR__.'/../../../core.php'; + +switch ($resource) { + case 'fasce_orarie': + $query = 'SELECT id, nome AS descrizione FROM in_fasceorarie |where| ORDER BY nome ASC'; + + foreach ($elements as $element) { + $filter[] = 'id='.prepare($element); + } + + if (!empty($search)) { + $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); + } + + break; +} diff --git a/modules/fasce_orarie/edit.php b/modules/fasce_orarie/edit.php new file mode 100644 index 000000000..1123a91dc --- /dev/null +++ b/modules/fasce_orarie/edit.php @@ -0,0 +1,182 @@ +. + */ + + +include_once __DIR__.'/../../core.php'; + +//$block_edit = $record['is_predefined']; + +?> + + + + + +