Show attachment size in attachment info

master
Mike Koch 6 years ago
parent 98a033798f
commit 2ffa6c130c
No known key found for this signature in database
GPG Key ID: 9BA5D7F8391455ED

@ -1193,9 +1193,9 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
echo '
<a href="../download_attachment.php?att_id=' . $att_id . '&amp;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 . '&amp;track=' . $trackingID . '">' . $att_name . '</a><br />
<a href="../download_attachment.php?att_id=' . $att_id . '&amp;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…
Cancel
Save