mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 11:30:55 +01:00
Gestione azioni di gruppo allegati
This commit is contained in:
parent
a16e003e9c
commit
4cbb37e658
68
actions.php
68
actions.php
@ -26,6 +26,7 @@ use Modules\Checklists\Check;
|
|||||||
use Modules\Checklists\Checklist;
|
use Modules\Checklists\Checklist;
|
||||||
use Modules\Emails\Template;
|
use Modules\Emails\Template;
|
||||||
use Notifications\EmailNotification;
|
use Notifications\EmailNotification;
|
||||||
|
use Util\Zip;
|
||||||
|
|
||||||
if (empty($structure) || empty($structure['enabled'])) {
|
if (empty($structure) || empty($structure['enabled'])) {
|
||||||
exit(tr('Accesso negato'));
|
exit(tr('Accesso negato'));
|
||||||
@ -181,15 +182,62 @@ elseif (filter('op') == 'download-allegato') {
|
|||||||
include_once base_dir().'/include/modifica_allegato.php';
|
include_once base_dir().'/include/modifica_allegato.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zip allegati
|
||||||
|
elseif (filter('op') == 'download-zip-allegati') {
|
||||||
|
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($id_module).' AND id IN('.implode(',',json_decode(filter('id'))).')');
|
||||||
|
|
||||||
|
$dir = base_dir().'/'.$module->upload_directory;
|
||||||
|
directory($dir.'tmp/');
|
||||||
|
|
||||||
|
$dir = slashes($dir);
|
||||||
|
$zip = slashes($dir.'_'.time().'.zip');
|
||||||
|
|
||||||
|
// Rimozione dei contenuti precedenti
|
||||||
|
$files = glob($dir.'/*.zip');
|
||||||
|
foreach ($files as $file) {
|
||||||
|
delete($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($rs as $r) {
|
||||||
|
$allegato = Upload::find($r['id']);
|
||||||
|
$src = basename($allegato->filepath);
|
||||||
|
$dst = basename($allegato->original_name);
|
||||||
|
|
||||||
|
$file = slashes($module->upload_directory.'/'.$src);
|
||||||
|
$dest = slashes($dir.'tmp/'.$dst);
|
||||||
|
|
||||||
|
$result = copy($file, $dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creazione zip
|
||||||
|
if (extension_loaded('zip')) {
|
||||||
|
Zip::create($dir.'tmp/', $zip);
|
||||||
|
|
||||||
|
// Invio al browser il file zip
|
||||||
|
download($zip);
|
||||||
|
|
||||||
|
// Rimozione dei contenuti
|
||||||
|
delete($dir.'tmp/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Modifica dati di un allegato
|
// Modifica dati di un allegato
|
||||||
elseif (filter('op') == 'modifica-allegato') {
|
elseif (filter('op') == 'modifica-allegato') {
|
||||||
$id_allegato = filter('id_allegato');
|
$id_allegato = filter('id_allegato');
|
||||||
$upload = Upload::find($id_allegato);
|
$id_allegati = explode(';',filter('id_allegati'));
|
||||||
|
|
||||||
$upload->name = post('nome_allegato');
|
if ($id_allegato) {
|
||||||
$upload->category = post('categoria_allegato');
|
$upload = Upload::find($id_allegato);
|
||||||
|
$upload->name = post('nome_allegato');
|
||||||
$upload->save();
|
$upload->category = post('categoria_allegato');
|
||||||
|
$upload->save();
|
||||||
|
} else {
|
||||||
|
foreach ($id_allegati as $id_allegato) {
|
||||||
|
$upload = Upload::find($id_allegato);
|
||||||
|
$upload->category = post('categoria_allegato');
|
||||||
|
$upload->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifica nome della categoria degli allegati
|
// Modifica nome della categoria degli allegati
|
||||||
@ -258,12 +306,12 @@ elseif (filter('op') == 'rimuovi-nota') {
|
|||||||
elseif (filter('op') == 'copia-checklist') {
|
elseif (filter('op') == 'copia-checklist') {
|
||||||
$content = post('content');
|
$content = post('content');
|
||||||
$checklist_id = post('checklist');
|
$checklist_id = post('checklist');
|
||||||
|
|
||||||
$users = post('assigned_users');
|
$users = post('assigned_users');
|
||||||
$users = array_clean($users);
|
$users = array_clean($users);
|
||||||
|
|
||||||
$group_id = post('group_id');
|
$group_id = post('group_id');
|
||||||
|
|
||||||
$checklist = Checklist::find($checklist_id);
|
$checklist = Checklist::find($checklist_id);
|
||||||
$checklist->copia($user, $id_record, $users, $group_id);
|
$checklist->copia($user, $id_record, $users, $group_id);
|
||||||
}
|
}
|
||||||
@ -275,7 +323,7 @@ elseif (filter('op') == 'aggiungi-check') {
|
|||||||
|
|
||||||
$users = post('assigned_users');
|
$users = post('assigned_users');
|
||||||
$users = array_clean($users);
|
$users = array_clean($users);
|
||||||
|
|
||||||
$group_id = post('group_id');
|
$group_id = post('group_id');
|
||||||
|
|
||||||
$check = Check::build($user, $structure, $id_record, $content, $parent_id);
|
$check = Check::build($user, $structure, $id_record, $content, $parent_id);
|
||||||
|
@ -191,17 +191,19 @@ function ricaricaAllegati(gestione) {
|
|||||||
/**
|
/**
|
||||||
* Funzione per l'apertura della pagina di gestione dei dati dell'allegato.
|
* Funzione per l'apertura della pagina di gestione dei dati dell'allegato.
|
||||||
* @param button
|
* @param button
|
||||||
|
* @param id
|
||||||
|
* @param ids
|
||||||
*/
|
*/
|
||||||
function modificaAllegato(button) {
|
function modificaAllegato(button, id, ids) {
|
||||||
const gestione = $(button).closest(".gestione-allegati");
|
const gestione = $(button).closest(".gestione-allegati");
|
||||||
const allegato = $(button).closest("tr").data();
|
|
||||||
|
|
||||||
let params = new URLSearchParams({
|
let params = new URLSearchParams({
|
||||||
op: "visualizza-modifica-allegato",
|
op: "visualizza-modifica-allegato",
|
||||||
id_module: gestione.data('id_module'),
|
id_module: gestione.data('id_module'),
|
||||||
id_plugin: gestione.data('id_plugin'),
|
id_plugin: gestione.data('id_plugin'),
|
||||||
id_record: gestione.data('id_record'),
|
id_record: gestione.data('id_record'),
|
||||||
id_allegato: allegato.id,
|
id_allegati: ids,
|
||||||
|
id_allegato: id,
|
||||||
}).toString();
|
}).toString();
|
||||||
|
|
||||||
openModal(globals.translations.allegati.modifica, globals.rootdir + "/actions.php?" + params);
|
openModal(globals.translations.allegati.modifica, globals.rootdir + "/actions.php?" + params);
|
||||||
@ -227,6 +229,25 @@ function scaricaAllegato(button) {
|
|||||||
window.open(globals.rootdir + "/actions.php?" + params, "_blank")
|
window.open(globals.rootdir + "/actions.php?" + params, "_blank")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Funzione per gestire il download zip di allegati.
|
||||||
|
* @param button
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
function scaricaZipAllegati(button, ids) {
|
||||||
|
const gestione = $(button).closest(".gestione-allegati");
|
||||||
|
|
||||||
|
let params = new URLSearchParams({
|
||||||
|
op: "download-zip-allegati",
|
||||||
|
id_module: gestione.data('id_module'),
|
||||||
|
id_plugin: gestione.data('id_plugin'),
|
||||||
|
id_record: gestione.data('id_record'),
|
||||||
|
id: ids,
|
||||||
|
}).toString();
|
||||||
|
|
||||||
|
window.open(globals.rootdir + "/actions.php?" + params, "_blank")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Funzione per l'apertura dell'anteprima di visualizzazione allegato.
|
* Funzione per l'apertura dell'anteprima di visualizzazione allegato.
|
||||||
* @param button
|
* @param button
|
||||||
|
@ -19,24 +19,35 @@
|
|||||||
|
|
||||||
use Models\Upload;
|
use Models\Upload;
|
||||||
|
|
||||||
$id_allegato = filter('id_allegato');
|
$id_allegati = json_decode(filter('id_allegati'));
|
||||||
$allegato = Upload::find($id_allegato);
|
$id_allegato = json_decode(filter('id_allegato'));
|
||||||
|
|
||||||
// Form di inserimento riga documento
|
// Form di inserimento riga documento
|
||||||
echo '
|
echo '
|
||||||
<form action="" method="post" id="modifica-allegato">
|
<form action="" method="post" id="modifica-allegato">
|
||||||
|
<input type="hidden" name="id_allegati" value="'.implode(';',$id_allegati).'">
|
||||||
<input type="hidden" name="id_allegato" value="'.$id_allegato.'">
|
<input type="hidden" name="id_allegato" value="'.$id_allegato.'">
|
||||||
<input type="hidden" name="backto" value="record-edit">
|
<input type="hidden" name="backto" value="record-edit">
|
||||||
<input type="hidden" name="op" value="modifica-allegato">
|
<input type="hidden" name="op" value="modifica-allegato">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">';
|
||||||
|
if ($id_allegato) {
|
||||||
|
$allegato = Upload::find($id_allegato);
|
||||||
|
echo '
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{[ "type": "text", "label": "'.tr('Nome').'", "name": "nome_allegato", "value": "'.$allegato->name.'" ]}
|
{[ "type": "text", "label": "'.tr('Nome').'", "name": "nome_allegato", "value": "'.$allegato->name.'" ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{[ "type": "text", "label": "'.tr('Categoria').'", "name": "categoria_allegato", "value": "'.$allegato->category.'", "disabled": "'.intval(in_array($allegato->category, ['Fattura Elettronica'])).'" ]}
|
{[ "type": "text", "label": "'.tr('Categoria').'", "name": "categoria_allegato", "value": "'.$allegato->category.'", "disabled": "'.intval(in_array($allegato->category, ['Fattura Elettronica'])).'" ]}
|
||||||
</div>
|
</div>';
|
||||||
|
} else {
|
||||||
|
$allegato = Upload::find($id_allegati[0]);
|
||||||
|
echo '
|
||||||
|
<div class="col-md-6">
|
||||||
|
{[ "type": "text", "label": "'.tr('Categoria').'", "name": "categoria_allegato", "value": "" ]}
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- PULSANTI -->
|
<!-- PULSANTI -->
|
||||||
|
@ -119,18 +119,26 @@ class FileManager implements ManagerInterface
|
|||||||
<table class="table table-striped table-condensed ">
|
<table class="table table-striped table-condensed ">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th scope="col" width="5%" class="text-center"></th>
|
||||||
<th scope="col" >'.tr('Nome').'</th>
|
<th scope="col" >'.tr('Nome').'</th>
|
||||||
<th scope="col" width="15%" >'.tr('Data').'</th>
|
<th scope="col" width="15%" >'.tr('Data').'</th>
|
||||||
<th scope="col" width="10%" class="text-center">#</th>
|
<th scope="col" width="10%" class="text-center">#</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>';
|
<tbody class="files">';
|
||||||
|
|
||||||
foreach ($rs as $r) {
|
foreach ($rs as $r) {
|
||||||
$file = Upload::find($r['id']);
|
$file = Upload::find($r['id']);
|
||||||
|
|
||||||
$result .= '
|
$result .= '
|
||||||
<tr id="row_'.$file->id.'" data-id="'.$file->id.'" data-filename="'.$file->filename.'" data-nome="'.$file->name.'">
|
<tr id="row_'.$file->id.'" data-id="'.$file->id.'" data-filename="'.$file->filename.'" data-nome="'.$file->name.'">
|
||||||
|
<td class="text-center">';
|
||||||
|
if (!$options['readonly']) {
|
||||||
|
$result .= '
|
||||||
|
<input class="check_files" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
$result .= '
|
||||||
|
</td>
|
||||||
<td align="left">';
|
<td align="left">';
|
||||||
|
|
||||||
if ($file->user && $file->user->photo) {
|
if ($file->user && $file->user->photo) {
|
||||||
@ -173,7 +181,7 @@ class FileManager implements ManagerInterface
|
|||||||
|
|
||||||
if (!$options['readonly']) {
|
if (!$options['readonly']) {
|
||||||
$result .= '
|
$result .= '
|
||||||
<button type="button" class="btn btn-xs btn-warning" onclick="modificaAllegato(this)">
|
<button type="button" class="btn btn-xs btn-warning" onclick="modificaAllegato(this,$(this).closest(\'tr\').data(\'id\'))">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</button>';
|
</button>';
|
||||||
if (!$file->isFatturaElettronica() || $options['abilita_genera']) {
|
if (!$file->isFatturaElettronica() || $options['abilita_genera']) {
|
||||||
@ -198,10 +206,29 @@ class FileManager implements ManagerInterface
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
<br>';
|
';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$options['readonly']) {
|
||||||
|
$result .= '
|
||||||
|
<div class="btn-group">';
|
||||||
|
if (!$options['readonly']) {
|
||||||
|
$result .= '
|
||||||
|
<button type="button" class="btn btn-xs btn-default">
|
||||||
|
<input class="pull-left" id="check_all_files" type="checkbox"/>
|
||||||
|
</button>';
|
||||||
|
}
|
||||||
|
$result .= '
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="modifica_files" onclick="modificaAllegato(this,0,JSON.stringify(getSelectData()));">
|
||||||
|
<i class="fa fa-edit"></i>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="zip_files" onclick="scaricaZipAllegati(this,JSON.stringify(getSelectData()));">
|
||||||
|
<i class="fa fa-file-archive-o"></i>
|
||||||
|
</button>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
|
||||||
// Form per l'upload di un nuovo file
|
// Form per l'upload di un nuovo file
|
||||||
if (!$options['readonly']) {
|
if (!$options['readonly']) {
|
||||||
$result .= '
|
$result .= '
|
||||||
@ -267,6 +294,49 @@ $("#'.$attachment_id.' #upload").click(function(){
|
|||||||
|
|
||||||
aggiungiAllegato(container);
|
aggiungiAllegato(container);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Estraggo le righe spuntate
|
||||||
|
function getSelectData() {
|
||||||
|
let data=new Array();
|
||||||
|
$(\'.files\').find(\'.check_files:checked\').each(function (){
|
||||||
|
data.push($(this).closest(\'tr\').data(\'id\'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".check_files").on("change", function() {
|
||||||
|
let checked = 0;
|
||||||
|
$(".check_files").each(function() {
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
checked = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#zip_files").removeClass("disabled");
|
||||||
|
$("#modifica_files").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#zip_files").addClass("disabled");
|
||||||
|
$("#modifica_files").addClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_all_files").click(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(".check_files").each(function(){
|
||||||
|
if( !$(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$(".check_files").each(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user