From b52ca51128e33a2d051d8e36a7dcc2c22e816020 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 4 Dec 2013 10:24:31 +0100 Subject: [PATCH] Allowing more than one document attachment. --- admin/db/attachments_db.inc | 19 +++++++++++++++++++ includes/ui/ui_controls.inc | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/admin/db/attachments_db.inc b/admin/db/attachments_db.inc index e18000fe..bb4c04c8 100644 --- a/admin/db/attachments_db.inc +++ b/admin/db/attachments_db.inc @@ -51,6 +51,25 @@ function delete_attachment($id) $sql = "DELETE FROM ".TB_PREF."attachments WHERE id = ".db_escape($id); db_query($sql, "Could not delete attachment"); } + +//---------------------------------------------------------------------------------------- + +function get_attachment_string($type, $id) +{ + global $path_to_root; + $str_return = ""; + $sql = "SELECT * FROM ".TB_PREF."attachments WHERE type_no=".db_escape($type)." AND trans_no=".db_escape($id)." ORDER BY trans_no"; + $return = db_query($sql, "Could not retrieve attachments"); + while ($attachment = db_fetch($return)) + { + if (strlen($str_return)) + $str_return = $str_return . " \n"; + $str_return .= _("Attached File:")." ID: ". + $attachment["id"] . " " . $attachment["description"]. " - ". $attachment["filename"]."
"; + } + return $str_return . "
"; +} + //---------------------------------------------------------------------------------------- function get_attached_documents($type) diff --git a/includes/ui/ui_controls.inc b/includes/ui/ui_controls.inc index 7502aba4..62506205 100644 --- a/includes/ui/ui_controls.inc +++ b/includes/ui/ui_controls.inc @@ -177,14 +177,14 @@ function hyperlink_back($center=true, $no_menu=true, $type_no=0, $trans_no=0, $f { include_once($path_to_root."/admin/db/attachments_db.inc"); $id = has_attachment($type_no, $trans_no); - } + $attach = get_attachment_string($type_no, $trans_no); + echo $attach; + } $width = ($id != 0 ? "30%" : "20%"); start_table(false, "width=$width"); start_row(); if ($no_menu) { - if ($id != 0) - echo ""._("View Attachment")."\n"; echo ""._("Print")."\n"; } echo "".($no_menu ? _("Close") : _("Back"))."\n"; -- 2.30.2