mirror of
https://github.com/devcode-it/openstamanager.git
synced 2024-12-15 09:57:28 +01:00
10e1301eb7
Rimozione della dipendenza UI Autocomplete in favore di una libreria indipendente, aggiornamento funzioni JS per la gestione degli allegati.
90 lines
3.2 KiB
PHP
90 lines
3.2 KiB
PHP
<?php
|
|
/*
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
* Copyright (C) DevCode s.r.l.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
use Models\Upload;
|
|
|
|
$id_allegato = filter('id_allegato');
|
|
$allegato = Upload::find($id_allegato);
|
|
|
|
// Form di inserimento riga documento
|
|
echo '
|
|
<form action="" method="post" id="modifica-allegato">
|
|
<input type="hidden" name="id_allegato" value="'.$id_allegato.'">
|
|
<input type="hidden" name="backto" value="record-edit">
|
|
<input type="hidden" name="op" value="modifica-allegato">
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
{[ "type": "text", "label": "'.tr('Nome').'", "name": "nome_allegato", "value": "'.$allegato->name.'" ]}
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
{[ "type": "text", "label": "'.tr('Categoria').'", "name": "categoria_allegato", "value": "'.$allegato->category.'", "disabled": "'.intval(in_array($allegato->category, ['Fattura Elettronica'])).'" ]}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- PULSANTI -->
|
|
<div class="row">
|
|
<div class="col-md-12 text-right">
|
|
<button type="submit" class="btn btn-primary pull-right">
|
|
<i class="fa fa-edit"></i> '.tr('Modifica').'
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>';
|
|
|
|
// Elenco categoria disponibili per l'autocompletamento
|
|
$where = '`id_module` '.(!empty($allegato['id_module']) && empty($allegato['id_plugin']) ? '= '.prepare($allegato['id_module']) : 'IS NULL').' AND `id_plugin` '.(!empty($allegato['id_plugin']) ? '= '.prepare($allegato['id_plugin']) : 'IS NULL').'';
|
|
$categories = $dbo->fetchArray('SELECT DISTINCT(BINARY `category`) AS `category` FROM `zz_files` WHERE '.$where.' ORDER BY `category`');
|
|
$source = array_clean(array_column($categories, 'category'));
|
|
|
|
echo '
|
|
<script>
|
|
var categorie = '.json_encode($source).';
|
|
|
|
// Auto-completamento categoria
|
|
$(document).ready(function () {
|
|
const input = $("#modifica-allegato #categoria_allegato")[0];
|
|
|
|
autocomplete({
|
|
minLength: 0,
|
|
input: input,
|
|
emptyMsg: globals.translations.noResults,
|
|
fetch: function (text, update) {
|
|
text = text.toLowerCase();
|
|
const suggestions = categorie.filter(n => n.toLowerCase().startsWith(text));
|
|
|
|
// Trasformazione risultati in formato leggibile
|
|
const results = suggestions.map(function (result) {
|
|
return {
|
|
label: result,
|
|
value: result
|
|
}
|
|
});
|
|
|
|
update(results);
|
|
},
|
|
onSelect: function (item) {
|
|
input.value = item.label;
|
|
},
|
|
});
|
|
});
|
|
</script>
|
|
<script>$(document).ready(init)</script>';
|