Rerun of items attachments. Including fixed assets.
authorJoe <joe.hunt.consulting@gmail.com>
Sun, 30 Apr 2023 22:50:32 +0000 (00:50 +0200)
committerJoe <joe.hunt.consulting@gmail.com>
Sun, 30 Apr 2023 22:50:32 +0000 (00:50 +0200)
admin/attachments.php
admin/db/attachments_db.inc
admin/db/transactions_db.inc
includes/sysnames.inc
includes/types.inc
includes/ui/attachment.inc
inventory/manage/items.php

index 801d9628eb2357b10f995399ca6f606265582d14..90d9da9dcdfd2e7c73d9734311d8a919991e9379 100644 (file)
@@ -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);
index bae91fe179507c00179e923ef42a8efcc22be420..c280688485957f3bcf5746fbb88fa9067acad1cf 100644 (file)
@@ -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";
index 94b3cebe099625e4dd62a4628ec2b3d4a1972cdf..6cc5ae31fb2e1f4ce123b1f8ca924ed91b770e7b 100644 (file)
@@ -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);
index b4ac947e71a5399bbeab8045f8bbbd647565de20..0bb259baadd9ad1de5281890ad33c4fa56ededfe 100644 (file)
@@ -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 (
index ad151d14fa82f70fa9391a4fca471e64d9d37139..db5cac152fe707014d04209c1d90ac8704bbf6ab 100644 (file)
@@ -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.
index a2ed7f0f058611db6b3ecac9739f5eac7c99107a..3ecf0ad0339ae6d8b72262054802eeb52e200bf9 100644 (file)
@@ -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');
index c3970a71df3676b8fac2b2d9fdb84cebf1cc0737..ae2686cdc89498a4ff99b71a8bed7aabbe2f7039 100644 (file)
@@ -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();
        };