From 039e2f9b14460f2c1fd0c3cbe2b39983b1b7e93b Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Fri, 11 Oct 2019 10:24:50 +0200 Subject: [PATCH] Additional fixes to supplier//customer attachments. --- admin/attachments.php | 39 +++++++++++++++------------------ purchasing/manage/suppliers.php | 7 +++--- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/admin/attachments.php b/admin/attachments.php index 565e4b1e..b96f3e4e 100644 --- a/admin/attachments.php +++ b/admin/attachments.php @@ -80,12 +80,6 @@ if (isset($_GET['trans_no'])) if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') { - if($_POST['filterType'] == ST_CUSTOMER){ - $_POST['trans_no'] = $_POST['customer_id']; - }elseif($_POST['filterType'] == ST_SUPPLIER){ - $_POST['trans_no'] = $_POST['supplier_id']; - } - if (!transaction_exists($_POST['filterType'], $_POST['trans_no'])) display_error(_("Selected transaction does not exists.")); elseif ($Mode == 'ADD_ITEM' && !isset($_FILES['filename'])) @@ -162,7 +156,6 @@ if ($Mode == 'Delete') if ($Mode == 'RESET') { - unset($_POST['trans_no']); unset($_POST['description']); $selected_id = -1; } @@ -179,9 +172,9 @@ function viewing_controls() $selected_id = -1; if(get_post('filterType') == ST_CUSTOMER ){ - customer_list_cells(_("Select a customer: "), 'customer_id', null, _('Select customer'), true, true); + customer_list_cells(_("Select a customer: "), 'trans_no', null, false, true, true); } elseif(get_post('filterType') == ST_SUPPLIER){ - supplier_list_cells(_("Select a supplier: "), 'supplier_id', null, _('Select supplier'), true,true); + supplier_list_cells(_("Select a supplier: "), 'trans_no', null, false, true,true); } end_row(); @@ -214,11 +207,11 @@ function delete_link($row) return button('Delete'.$row["id"], _("Delete"), _("Delete"), ICON_DELETE); } -function display_rows($type, $id_no) +function display_rows($type, $trans_no) { - $sql = get_sql_for_attached_documents($type, $id_no); + $sql = get_sql_for_attached_documents($type, $type==ST_SUPPLIER || $type==ST_CUSTOMER ? $trans_no : 0); $cols = array( - _("#") => array('fun'=>'trans_view', 'ord'=>''), + _("#") => $type == ST_SUPPLIER || $type == ST_CUSTOMER? 'skip' : array('fun'=>'trans_view', 'ord'=>''), _("Description") => array('name'=>'description'), _("Filename") => array('name'=>'filename'), _("Size") => array('name'=>'filesize'), @@ -229,20 +222,25 @@ function display_rows($type, $id_no) array('insert'=>true, 'fun'=>'download_link'), array('insert'=>true, 'fun'=>'delete_link') ); - $table =& new_db_pager('trans_tbl', $sql, $cols); - $table->width = "60%"; + $table =& new_db_pager('trans_tbl', $sql, $cols); + + $table->width = "60%"; - display_db_pager($table); + display_db_pager($table); } //---------------------------------------------------------------------------------------- +if (list_updated('filterType') || list_updated('trans_no')) + $Ajax->activate('_page_body'); start_form(true); viewing_controls(); -$id_no = ($_POST['filterType'] == ST_CUSTOMER) ? get_post('customer_id') : get_post('supplier_id'); -display_rows($_POST['filterType'], $id_no); + +$type = get_post('filterType'); + +display_rows($type, get_post('trans_no')); br(2); @@ -257,15 +255,14 @@ if ($selected_id != -1) $_POST['description'] = $row["description"]; hidden('trans_no', $row['trans_no']); hidden('unique_name', $row['unique_name']); - label_row(_("Transaction #"), $row['trans_no']); + if ($type != ST_SUPPLIER && $type != ST_CUSTOMER) + label_row(_("Transaction #"), $row['trans_no']); } hidden('selected_id', $selected_id); } else { - if( $id_no == 0 ) + if ($type != ST_SUPPLIER && $type != ST_CUSTOMER) text_row_ex(_("Transaction #").':', 'trans_no', 10); - else - hidden('trans_no', $id_no); } text_row_ex(_("Description").':', 'description', 40); file_row(_("Attached File") . ":", 'filename', 'filename'); diff --git a/purchasing/manage/suppliers.php b/purchasing/manage/suppliers.php index b0c7c35b..d20e1ac6 100644 --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@ -13,7 +13,7 @@ $page_security = 'SA_SUPPLIER'; $path_to_root = "../.."; include($path_to_root . "/includes/db_pager.inc"); include_once($path_to_root . "/includes/session.inc"); -include_once($path_to_root . "/includes/ui/attachment.inc"); + $js = ""; if ($SysPrefs->use_popup_windows) $js .= get_js_open_window(900, 500); @@ -24,6 +24,7 @@ page(_($help_context = "Suppliers"), false, false, "", $js); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/ui/contacts_view.inc"); +include_once($path_to_root . "/includes/ui/attachment.inc"); check_db_has_tax_groups(_("There are no tax groups defined in the system. At least one tax group is required before proceeding.")); @@ -280,14 +281,14 @@ function supplier_settings(&$supplier_id) if ($supplier_id) { submit_center_first('submit', _("Update Supplier"), - _('Update supplier data'), $page_nested ? true : 'false'); + _('Update supplier data'), $page_nested ? true : false); submit_return('select', get_post('supplier_id'), _("Select this supplier and return to document entry.")); submit_center_last('delete', _("Delete Supplier"), _('Delete supplier data if have been never used'), true); } else { - submit_center('submit', _("Add New Supplier Details"), true, '', 'false'); + submit_center('submit', _("Add New Supplier Details"), true, '', false); } div_end(); } -- 2.30.2