From 270487d423a5848a21c1666c44bfba354bf18576 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 1 May 2023 00:50:32 +0200 Subject: [PATCH] Rerun of items attachments. Including fixed assets. --- admin/attachments.php | 12 ++++++++---- admin/db/attachments_db.inc | 2 +- admin/db/transactions_db.inc | 1 + includes/sysnames.inc | 3 ++- includes/types.inc | 1 + includes/ui/attachment.inc | 4 +++- inventory/manage/items.php | 2 +- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/admin/attachments.php b/admin/attachments.php index 801d9628..90d9da9d 100644 --- a/admin/attachments.php +++ b/admin/attachments.php @@ -82,7 +82,7 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') { $filename = basename($_FILES['filename']['name']); - if ($_POST['filterType'] == ST_ITEM && $Mode == 'ADD_ITEM') + if (($_POST['filterType'] == ST_ITEM || $_POST['filterType'] == ST_FIXEDASSET) && $Mode == 'ADD_ITEM') $_POST['trans_no'] = get_item_code_id($_POST['trans_no']); if (!transaction_exists($_POST['filterType'], $_POST['trans_no'])) display_error(_("Selected transaction does not exists.")); @@ -189,6 +189,9 @@ function viewing_controls() supplier_list_cells(_("Select a supplier: "), 'trans_no', null, false, true,true); } elseif(get_post('filterType') == ST_ITEM){ stock_items_list_cells(_("Select an Item: "), 'trans_no', null, false, true,true); + } elseif(get_post('filterType') == ST_FIXEDASSET){ + stock_items_list_cells(_("Select an Item: "), 'trans_no', null, false, true,false, false, + array('fixed_asset' => 1)); } end_row(); @@ -198,7 +201,8 @@ function viewing_controls() function trans_view($trans) { - if ($trans['type_no']==ST_SUPPLIER || $trans['type_no']==ST_CUSTOMER || $trans['type_no']==ST_ITEM) + if ($trans['type_no']==ST_SUPPLIER || $trans['type_no']==ST_CUSTOMER || $trans['type_no']==ST_ITEM || + $trans['type_no']==ST_FIXEDASSET) return $trans['id']; return get_trans_view_str($trans["type_no"], $trans["trans_no"]); } @@ -226,7 +230,7 @@ function delete_link($row) function display_rows($type, $trans_no) { $sql = get_sql_for_attached_documents($type, $type==ST_SUPPLIER || $type==ST_CUSTOMER ? $trans_no : - ($type==ST_ITEM ? get_item_code_id($trans_no) : 0)); + ($type==ST_ITEM || $type==ST_FIXEDASSET ? get_item_code_id($trans_no) : 0)); $cols = array( _("#") => array('fun'=>'trans_view', 'ord'=>''), _("Doc Title") => array('name'=>'description'), @@ -278,7 +282,7 @@ if ($selected_id != -1) hidden('selected_id', $selected_id); } else { - if ($type != ST_SUPPLIER && $type != ST_CUSTOMER && $type != ST_ITEM) + if ($type != ST_SUPPLIER && $type != ST_CUSTOMER && $type != ST_ITEM && $type != ST_FIXEDASSET) text_row_ex(_("Transaction #").':', 'trans_no', 10); } text_row_ex(_("Doc Title").':', 'description', 40); diff --git a/admin/db/attachments_db.inc b/admin/db/attachments_db.inc index bae91fe1..c2806884 100644 --- a/admin/db/attachments_db.inc +++ b/admin/db/attachments_db.inc @@ -104,7 +104,7 @@ function get_sql_for_attached_documents($type, $id_no) // $_POST['trans_no'] will be used to store the customer_id or supplier_id for them $sql = "SELECT trans_no, description, filename, filesize, filetype, tran_date, id, type_no FROM ".TB_PREF."attachments WHERE type_no=".db_escape($type); - if(($type == ST_CUSTOMER || $type == ST_SUPPLIER || $type == ST_ITEM) && $id_no != null) + if(($type == ST_CUSTOMER || $type == ST_SUPPLIER || $type == ST_ITEM || $type == ST_FIXEDASSET) && $id_no != null) $sql .=" AND trans_no = ".db_escape($id_no); $sql .= " ORDER BY trans_no DESC"; diff --git a/admin/db/transactions_db.inc b/admin/db/transactions_db.inc index 94b3cebe..6cc5ae31 100644 --- a/admin/db/transactions_db.inc +++ b/admin/db/transactions_db.inc @@ -213,6 +213,7 @@ function get_systype_db_info($type) case ST_CUSTOMER : return array(TB_PREF."debtors_master", null, "debtor_no", "debtor_ref", null); case ST_SUPPLIER : return array(TB_PREF."suppliers", null, "supplier_id", "supp_ref", null); case ST_ITEM : return array(TB_PREF."item_codes", null, "id", "stock_id", null); + case ST_FIXEDASSET : return array(TB_PREF."item_codes", null, "id", "stock_id", null); } display_db_error("invalid type ($type) sent to get_systype_db_info", "", true); diff --git a/includes/sysnames.inc b/includes/sysnames.inc index b4ac947e..0bb259ba 100644 --- a/includes/sysnames.inc +++ b/includes/sysnames.inc @@ -43,7 +43,8 @@ $systypes_array = array ( ST_DIMENSION => _("Dimension"), ST_CUSTOMER => _("Customer"), ST_SUPPLIER => _("Supplier"), - ST_ITEM => _("Item") + ST_ITEM => _("Item"), + ST_FIXEDASSET => _("Fixed Asset"), ); $fa_systypes_array = array ( diff --git a/includes/types.inc b/includes/types.inc index ad151d14..db5cac15 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -49,6 +49,7 @@ define('ST_DIMENSION', 40); define('ST_CUSTOMER', 41); define('ST_SUPPLIER', 42); define('ST_ITEM', 43); +define('ST_FIXEDASSET', 44); // Don't include these defines in the $systypes_array. // They are used for documents only. diff --git a/includes/ui/attachment.inc b/includes/ui/attachment.inc index a2ed7f0f..3ecf0ad0 100644 --- a/includes/ui/attachment.inc +++ b/includes/ui/attachment.inc @@ -131,8 +131,10 @@ class attachments extends simple_crud { $id_word = _("Customer ID"); elseif($type_no==ST_SUPPLIER) // 6 $id_word = _("Supplier ID"); - elseif($type_no==ST_ITEM) // 7 + elseif($type_no==ST_ITEM) $id_word = _("Item ID"); + elseif($type_no==ST_FIXEDASSET) + $id_word = _("Fixed Asset ID"); label_row(_($id_word), $_POST['trans_no']); date_row(_("Date"), 'tran_date'); diff --git a/inventory/manage/items.php b/inventory/manage/items.php index c3970a71..ae2686cd 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -643,7 +643,7 @@ tabbed_content_start('tabs', $tabs); case 'attachments': $id = get_item_code_id($stock_id); $_GET['trans_no'] = $id; - $_GET['type_no']= ST_ITEM; + $_GET['type_no']= get_post('fixed_asset') ? ST_FIXEDASSET : ST_ITEM; $attachments = new attachments('attachment', $id, 'items'); $attachments->show(); }; -- 2.30.2