mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-22 14:27:42 +01:00
Aggiunta possibilità di caricare allegati anche per i plugins
This commit is contained in:
parent
af4b7f3238
commit
697d4621da
19
actions.php
19
actions.php
@ -39,12 +39,18 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
else {
|
||||
// UPLOAD
|
||||
if (filter('op') == 'link_file' && !empty($_FILES) && !empty($_FILES['blob']['name'])) {
|
||||
|
||||
|
||||
|
||||
$nome = filter('nome_allegato');
|
||||
$nome = !empty($nome) ? $nome : $_FILES['blob']['name'];
|
||||
|
||||
|
||||
|
||||
$src = $_FILES['blob']['tmp_name'];
|
||||
$f = pathinfo($_FILES['blob']['name']);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$allowed = [
|
||||
// Image formats
|
||||
@ -165,17 +171,22 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
do {
|
||||
$filename = random_string().'.'.$f['extension'];
|
||||
} while (file_exists($upload_dir.'/'.$filename));
|
||||
|
||||
|
||||
|
||||
|
||||
// Creazione file fisico
|
||||
if (move_uploaded_file($src, $upload_dir.'/'.$filename)) {
|
||||
$dbo->insert('zz_files', [
|
||||
|
||||
$dbo->insert('zz_files', [
|
||||
'nome' => $nome,
|
||||
'filename' => $filename,
|
||||
'original' => $_FILES['blob']['name'],
|
||||
'id_module' => $id_module,
|
||||
'id_record' => $id_record,
|
||||
'id_plugin' => $id_plugin,
|
||||
]);
|
||||
|
||||
|
||||
$_SESSION['infos'][] = tr('File caricato correttamente!');
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Errore durante il caricamento del file!');
|
||||
|
@ -142,13 +142,16 @@ echo '
|
||||
|
||||
<?php
|
||||
|
||||
echo '</div>
|
||||
echo '
|
||||
|
||||
{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "id_plugin": "'.$id_plugin.'" )}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!--div class="col-md-8">
|
||||
{[ "type": "checkbox", "label": "'.tr('Pianifica anche date passate').'", "name": "date_passate", "value": "0", "help": "", "placeholder": "'.tr('Pianificare promemoria anche con date precedenti ad oggi: ').date('d/m/Y').'" ]}
|
||||
</div-->
|
||||
<!--div class="col-md-8">
|
||||
{[ "type": "checkbox", "label": "'.tr('Pianifica anche date passate').'", "name": "date_passate", "value": "0", "help": "", "placeholder": "'.tr('Pianificare promemoria anche con date precedenti ad oggi: ').date('d/m/Y').'" ]}
|
||||
</div-->
|
||||
|
||||
';
|
||||
|
||||
|
@ -110,9 +110,6 @@ if (count($rs2) > 0) {
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
function elimina_riga( id ){
|
||||
$.post(globals.rootdir + '/modules/contratti/plugins/actions.php', { op: 'delriga', idriga: id }, function(data, result){
|
||||
if( result=='success' ){
|
||||
|
@ -27,7 +27,10 @@ class FileManager implements ManagerInterface
|
||||
}
|
||||
|
||||
// Visualizzo l'elenco di file già caricati
|
||||
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($options['id_module']).' AND id_record='.prepare($options['id_record']));
|
||||
if (!empty($options['id_plugin']))
|
||||
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($options['id_module']).' AND id_record='.prepare($options['id_record']).' AND id_plugin='.prepare($options['id_plugin']));
|
||||
else
|
||||
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($options['id_module']).' AND id_record='.prepare($options['id_record']).' AND id_plugin = 0');
|
||||
|
||||
if (!empty($rs)) {
|
||||
$result .= '
|
||||
@ -70,15 +73,15 @@ class FileManager implements ManagerInterface
|
||||
<b>'.$options['label'].'</b>
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
{[ "type": "text", "placeholder": "'.tr('Nome').'", "name": "nome_allegato" ]}
|
||||
{[ "type": "text", "placeholder": "'.tr('Nome').'", "name": "nome_allegato", "id": "nome_allegato_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
{[ "type": "file", "placeholder": "'.tr('File').'", "name": "blob", "required": 1 ]}
|
||||
{[ "type": "file", "placeholder": "'.tr('File').'", "name": "blob", "id": "blob_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'", "required": 1 ]}
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 text-right">
|
||||
<button type="button" class="btn btn-success" onclick="saveFile();">
|
||||
<button type="button" class="btn btn-success" onclick="saveFile_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'();">
|
||||
<i class="fa fa-upload"></i> '.tr('Carica').'
|
||||
</button>
|
||||
</div>
|
||||
@ -86,19 +89,20 @@ class FileManager implements ManagerInterface
|
||||
|
||||
$result .= '
|
||||
<script>
|
||||
function saveFile(){
|
||||
if(!$("#blob").val()){
|
||||
function saveFile_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'(){
|
||||
if(!$("#blob_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'").val()){
|
||||
swal("'.addslashes(tr('Attenzione!')).'", "'.addslashes(tr('Devi selezionare un file con il tasto "Sfoglia"')).'...", "warning");
|
||||
return false;
|
||||
}
|
||||
|
||||
var file_data = $("#blob").prop("files")[0];
|
||||
var file_data = $("#blob_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'").prop("files")[0];
|
||||
var form_data = new FormData();
|
||||
form_data.append("blob", file_data);
|
||||
form_data.append("nome_allegato", $("input[name=nome_allegato]").val());
|
||||
form_data.append("nome_allegato", $("input[id=nome_allegato_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').']").val());
|
||||
form_data.append("op","link_file");
|
||||
form_data.append("id_record","'.$options['id_record'].'");
|
||||
form_data.append("id_module", "'.$options['id_module'].'");
|
||||
form_data.append("id_plugin","'.$options['id_plugin'].'");
|
||||
|
||||
$("#main_loading").fadeIn();
|
||||
|
||||
@ -111,7 +115,7 @@ class FileManager implements ManagerInterface
|
||||
dataType : "html",
|
||||
data: form_data,
|
||||
success: function(data) {
|
||||
location.href = globals.rootdir + "/editor.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].'";
|
||||
location.href = globals.rootdir + "/editor.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '').'";
|
||||
},
|
||||
error: function(data) {
|
||||
alert(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user