Merge branch 'attachment-download-size' into '3-3-0'
Show attachment size in attachment info See merge request mike-koch/Mods-for-HESK!90
This commit is contained in:
commit
d2cb5ad251
@ -1193,9 +1193,9 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
||||
|
||||
echo '
|
||||
<a href="../download_attachment.php?att_id=' . $att_id . '&track=' . $trackingID . '">
|
||||
<i class="fa fa-paperclip" style="font-size:16px;" data-toggle="tooltip" data-placement="top" data-original-title="' . $hesklang['dnl'] . ' ' . $att_name . '"></i>
|
||||
<i class="fa fa-paperclip" style="font-size:16px;" data-toggle="tooltip" data-placement="top" data-original-title="' . $hesklang['dnl'] . '"></i>
|
||||
</a>
|
||||
<a href="../download_attachment.php?att_id=' . $att_id . '&track=' . $trackingID . '">' . $att_name . '</a><br />
|
||||
<a href="../download_attachment.php?att_id=' . $att_id . '&track=' . $trackingID . '">' . $att_name . ' (' . mfh_getAttachmentFileSize($att_id) . ')' . '</a><br />
|
||||
';
|
||||
}
|
||||
}
|
||||
|
@ -2131,6 +2131,31 @@ function mfh_getNumberOfDownloadsForAttachment($att_id, $table = 'attachments')
|
||||
return $rec['download_count'];
|
||||
}
|
||||
|
||||
function mfh_getAttachmentFileSize($att_id, $table = 'attachments') {
|
||||
global $hesk_settings;
|
||||
|
||||
$res = hesk_dbQuery('SELECT `size` FROM `' . hesk_dbEscape($hesk_settings['db_pfix'] . $table) . "` WHERE `att_id` = " . intval($att_id));
|
||||
$rec = hesk_dbFetchAssoc($res);
|
||||
return human_filesize($rec['size']);
|
||||
}
|
||||
|
||||
function human_filesize($bytes, $decimals = 2) {
|
||||
global $hesklang;
|
||||
|
||||
$sz = 'BKMGTP';
|
||||
$factor = floor((strlen($bytes) - 1) / 3);
|
||||
|
||||
if ($factor < strlen($sz)) {
|
||||
$factorName = @$sz[$factor];
|
||||
if ($factorName !== 'B') {
|
||||
$factorName .= 'B';
|
||||
}
|
||||
|
||||
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . $factorName;
|
||||
}
|
||||
return $hesklang['unknown'];
|
||||
}
|
||||
|
||||
function mfh_getSettings()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
@ -24,6 +24,7 @@ function mfh_listAttachments($attachments = '', $reply = 0, $is_staff)
|
||||
if ($is_staff) {
|
||||
echo '<th>' . $hesklang['download_count'] . '</th>';
|
||||
}
|
||||
echo '<th>' . 'File size' . '</th>';
|
||||
echo '<th>' . $hesklang['action'] . '</th>
|
||||
</tr>
|
||||
</thead>';
|
||||
@ -72,6 +73,7 @@ function mfh_listAttachments($attachments = '', $reply = 0, $is_staff)
|
||||
if ($is_staff) {
|
||||
echo '<td>' . mfh_getNumberOfDownloadsForAttachment($att_id) . '</td>';
|
||||
}
|
||||
echo '<td>' . mfh_getAttachmentFileSize($att_id) . '</td>';
|
||||
echo '<td>
|
||||
<div class="btn-group">';
|
||||
/* Can edit and delete tickets? */
|
||||
|
Loading…
x
Reference in New Issue
Block a user