Foto profilo e modifica categoria in Allegati
This commit is contained in:
parent
bc1f7e02a4
commit
a88c2be5f1
12
actions.php
12
actions.php
|
@ -78,6 +78,18 @@ elseif (filter('op') == 'download_file') {
|
|||
download($upload_dir.'/'.$rs[0]['filename'], $rs[0]['original']);
|
||||
}
|
||||
|
||||
// Modifica nome della categoria degli allegati
|
||||
elseif (filter('op') == 'upload_category') {
|
||||
$category = post('category');
|
||||
$name = post('name');
|
||||
|
||||
$uploads = $structure->uploads($id_record)->where('category', $category);
|
||||
foreach ($uploads as $upload) {
|
||||
$upload->category = $name;
|
||||
$upload->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Validazione dati
|
||||
elseif (filter('op') == 'validate') {
|
||||
// Lettura informazioni di base
|
||||
|
|
|
@ -874,4 +874,9 @@ input.small-width {
|
|||
|
||||
.progress .progress-bar span{
|
||||
color:#000;
|
||||
}
|
||||
}
|
||||
|
||||
.attachment-img {
|
||||
max-width: 20px;
|
||||
max-height: 20px;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,23 @@ class FileManager implements ManagerInterface
|
|||
<div class="box box-success">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">'.(!empty($category) ? $category : tr('Generale')).'</h3>
|
||||
<div class="box-tools pull-right">
|
||||
|
||||
{[ "type": "text", "class": "hide category-name", "value": "'.$category.'" ]}
|
||||
|
||||
<div class="box-tools pull-right">';
|
||||
|
||||
if (!empty($category)) {
|
||||
$result .= '
|
||||
<button type="button" class="btn btn-box-tool category-save hide">
|
||||
<i class="fa fa-check"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn btn-box-tool category-edit">
|
||||
<i class="fa fa-edit"></i>
|
||||
</button>';
|
||||
}
|
||||
|
||||
$result .= '
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
|
@ -73,7 +89,7 @@ class FileManager implements ManagerInterface
|
|||
<tr>
|
||||
<th scope="col" >'.tr('Nome').'</th>
|
||||
<th scope="col" width="15%" >'.tr('Data').'</th>
|
||||
<th scope="col" width="15%" class="text-right"></th>
|
||||
<th scope="col" width="10%" class="text-center">#</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
|
@ -83,13 +99,29 @@ class FileManager implements ManagerInterface
|
|||
|
||||
$result .= '
|
||||
<tr>
|
||||
<td align="left">
|
||||
<td align="left">';
|
||||
|
||||
if ($file->user && $file->user->photo) {
|
||||
$result .= '
|
||||
<img class="attachment-img tip" src="'.$file->user->photo.'" title="'.$file->user->nome_completo.'">';
|
||||
} else {
|
||||
$result .= '
|
||||
|
||||
<i class="fa fa-user-circle-o attachment-img tip" title="'.tr('OpenSTAManager').'"></i>';
|
||||
}
|
||||
|
||||
$result .= '
|
||||
|
||||
<a href="'.ROOTDIR.'/view.php?file_id='.$r['id'].'" target="_blank">
|
||||
<i class="fa fa-external-link"></i> '.$r['name'].'
|
||||
</a><small> ('.$file->extension.')'.((!empty($file->size)) ? ' ('.\Util\FileSystem::formatBytes($file->size).')' : '').'</small>'.'
|
||||
</a>
|
||||
|
||||
<small> ('.$file->extension.')'.((!empty($file->size)) ? ' ('.\Util\FileSystem::formatBytes($file->size).')' : '').'</small>'.'
|
||||
</td>
|
||||
|
||||
<td>'.\Translator::timestampToLocale($r['created_at']).'</td>
|
||||
<td class="text-right">
|
||||
|
||||
<td class="text-center">
|
||||
<a class="btn btn-xs btn-primary" href="'.ROOTDIR.'/actions.php?id_module='.$options['id_module'].'&op=download_file&id='.$r['id'].'&filename='.$r['filename'].'" target="_blank">
|
||||
<i class="fa fa-download"></i>
|
||||
</a>';
|
||||
|
@ -178,7 +210,48 @@ class FileManager implements ManagerInterface
|
|||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function() {
|
||||
// Modifica categoria
|
||||
$("#'.$attachment_id.' .category-edit").click(function() {
|
||||
var nome = $(this).parent().parent().find(".box-title");
|
||||
var save_button = $(this).parent().find(".category-save");
|
||||
var input = $(this).parent().parent().find(".category-name");
|
||||
|
||||
nome.hide();
|
||||
$(this).hide();
|
||||
|
||||
input.removeClass("hide");
|
||||
save_button.removeClass("hide");
|
||||
});
|
||||
|
||||
$("#'.$attachment_id.' .category-save").click(function() {
|
||||
var nome = $(this).parent().parent().find(".box-title");
|
||||
var input = $(this).parent().parent().find(".category-name");
|
||||
|
||||
show_'.$attachment_id.'();
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
cache: false,
|
||||
type: "POST",
|
||||
data: {
|
||||
id_module: "'.$options['id_module'].'",
|
||||
id_plugin: "'.$options['id_plugin'].'",
|
||||
id_record: "'.$options['id_record'].'",
|
||||
op: "upload_category",
|
||||
category: nome.text(),
|
||||
name: input.val(),
|
||||
},
|
||||
success: function(data) {
|
||||
reload_'.$attachment_id.'();
|
||||
},
|
||||
error: function(data) {
|
||||
reload_'.$attachment_id.'();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Autocompletamento nome
|
||||
$("#'.$attachment_id.' #blob").change(function(){
|
||||
var nome = $("#'.$attachment_id.' #nome_allegato");
|
||||
|
||||
|
@ -190,8 +263,9 @@ $(document).ready(function(){
|
|||
|
||||
nome.val(filename);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Autocompletamento categoria
|
||||
$("#'.$attachment_id.' #categoria").autocomplete({
|
||||
source: '.json_encode($source).',
|
||||
minLength: 0
|
||||
|
@ -199,13 +273,14 @@ $(document).ready(function(){
|
|||
$(this).autocomplete("search", $(this).val())
|
||||
});
|
||||
|
||||
data = {
|
||||
var data = {
|
||||
op: "link_file",
|
||||
id_module: "'.$options['id_module'].'",
|
||||
id_plugin: "'.$options['id_plugin'].'",
|
||||
id_record: "'.$options['id_record'].'",
|
||||
};
|
||||
|
||||
// Upload
|
||||
$("#'.$attachment_id.' #upload").click(function(){
|
||||
$form = $("#'.$attachment_id.' #upload-form");
|
||||
|
||||
|
|
|
@ -26,12 +26,11 @@ class Upload extends Model
|
|||
*/
|
||||
public static function build($source, $data, $name = null, $category = null)
|
||||
{
|
||||
$original_name = isset($source['name']) ? $source['name'] : basename($source);
|
||||
|
||||
$model = parent::build();
|
||||
|
||||
// Informazioni di base
|
||||
$model->original_name = $original_name; // Fix per original di Eloquent
|
||||
$original_name = isset($source['name']) ? $source['name'] : basename($source);
|
||||
$model->original_name = $original_name; // Fix per "original" di Eloquent
|
||||
$model->size = $source['size'];
|
||||
|
||||
$model->name = !empty($name) ? $name : $original_name;
|
||||
|
@ -56,6 +55,7 @@ class Upload extends Model
|
|||
}
|
||||
|
||||
$model->size = \Util\FileSystem::fileSize($directory.'/'.$filename);
|
||||
$model->user()->associate(auth()->getUser());
|
||||
|
||||
$model->save();
|
||||
|
||||
|
@ -158,18 +158,6 @@ class Upload extends Model
|
|||
return $this->isImage() || $this->isFatturaElettronica() || $this->isPDF();
|
||||
}
|
||||
|
||||
/* Relazioni Eloquent */
|
||||
|
||||
public function module()
|
||||
{
|
||||
return $this->belongsTo(Module::class, 'id_module');
|
||||
}
|
||||
|
||||
public function plugin()
|
||||
{
|
||||
return $this->belongsTo(Plugin::class, 'id_plugin');
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$info = $this->info;
|
||||
|
@ -208,6 +196,23 @@ class Upload extends Model
|
|||
return pathinfo($file);
|
||||
}
|
||||
|
||||
/* Relazioni Eloquent */
|
||||
|
||||
public function module()
|
||||
{
|
||||
return $this->belongsTo(Module::class, 'id_module');
|
||||
}
|
||||
|
||||
public function plugin()
|
||||
{
|
||||
return $this->belongsTo(Plugin::class, 'id_plugin');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera casualmente il nome fisico per il file.
|
||||
*
|
||||
|
|
|
@ -236,6 +236,7 @@ class Uploads
|
|||
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
||||
'id_record' => $data['id_record'],
|
||||
'size' => $data['size'],
|
||||
'created_by' => auth()->getUser()->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -284,3 +284,6 @@ UPDATE `zz_prints` SET `options` = '{"pricing": false, "last-page-footer": true}
|
|||
|
||||
-- Widget per le notifiche delle note interne
|
||||
INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`) VALUES (NULL, 'Note interne', 'custom', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Dashboard'), 'controller_top', 'col-md-12', NULL, '#4ccc4c', 'fa fa-file-text-o ', '', './modules/dashboard/widgets/notifiche.php', 'popup', './modules/dashboard/widgets/notifiche.php', 'Notifiche interne', '1', '1');
|
||||
|
||||
-- Aggiunto collegamento degli allegati al creatore
|
||||
ALTER TABLE `zz_files` ADD `created_by` INT(11) AFTER `id_record`, ADD FOREIGN KEY (`created_by`) REFERENCES `zz_users`(`id`) ON DELETE SET NULL;
|
||||
|
|
Loading…
Reference in New Issue