X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fpurchasing_data.php;h=f7b44c4d879e948ca33a5abc08a5ef74121e686a;hb=a0a0a0e1318042034fe5652caa69b034200c8a90;hp=8e2cb59d0e9a94e166e640506089ef62868a2b16;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 8e2cb59d..f7b44c4d 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -1,11 +1,19 @@ . +***********************************************************************/ +$page_security = 'SA_PURCHASEPRICING'; +$path_to_root = ".."; include_once($path_to_root . "/includes/session.inc"); -page(_("Supplier Purchasing Data")); +page(_($help_context = "Supplier Purchasing Data")); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); @@ -15,23 +23,12 @@ include_once($path_to_root . "/includes/data_checks.inc"); check_db_has_purchasable_items(_("There are no purchasable inventory items defined in the system.")); check_db_has_suppliers(_("There are no suppliers defined in the system.")); -if (isset($_GET['supplier_id'])) -{ - $supplier_id = strtoupper($_GET['supplier_id']); -} -elseif (isset($_POST['supplier_id'])) -{ - $supplier_id = strtoupper($_POST['supplier_id']); -} - -if (isset($_GET['stock_id'])) -{ - $_POST['stock_id'] = $_GET['stock_id']; -} +//---------------------------------------------------------------------------------------- +simple_page_mode(true); //-------------------------------------------------------------------------------------------------- -if ((isset($_POST['AddRecord']) || isset($_POST['UpdateRecord'])) && isset($supplier_id)) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { $input_error = 0; @@ -39,110 +36,96 @@ if ((isset($_POST['AddRecord']) || isset($_POST['UpdateRecord'])) && isset($supp { $input_error = 1; display_error( _("There is no item selected.")); + set_focus('stock_id'); } - elseif (!is_numeric($_POST['price']) || $_POST['price']==0) + elseif (!check_num('price', 0)) { $input_error = 1; display_error( _("The price entered was not numeric.")); + set_focus('price'); } - elseif (!is_numeric($_POST['conversion_factor'])) + elseif (!check_num('conversion_factor')) { $input_error = 1; display_error( _("The conversion factor entered was not numeric. The conversion factor is the number by which the price must be divided by to get the unit price in our unit of measure.")); + set_focus('conversion_factor'); } if ($input_error == 0) { - if (isset($_POST['AddRecord'])) + if ($Mode == 'ADD_ITEM') { - - $sql = "INSERT INTO ".TB_PREF."purch_data (supplier_id, stock_id, price, suppliers_uom, - conversion_factor, supplier_description) VALUES ("; - $sql .= "'$supplier_id', '" . $_POST['stock_id'] . "', " . $_POST['price'] . ", '" . $_POST['suppliers_uom'] . "', " . - $_POST['conversion_factor'] . ", '" . $_POST['supplier_description'] . "')"; - - db_query($sql,"The supplier purchasing details could not be added"); + add_item_purchasing_data($_POST['supplier_id'], $_POST['stock_id'], input_num('price',0), + $_POST['suppliers_uom'], input_num('conversion_factor'), $_POST['supplier_description']); display_notification(_("This supplier purchasing data has been added.")); - } - - if (isset($_POST['UpdateRecord'])) + } + else { - $sql = "UPDATE ".TB_PREF."purch_data SET price=" . $_POST['price'] . ", - suppliers_uom='" . $_POST['suppliers_uom'] . "', - conversion_factor=" . $_POST['conversion_factor'] . ", - supplier_description='" . $_POST['supplier_description'] . "' - WHERE stock_id='" . $_POST['stock_id'] . "' AND - supplier_id='$supplier_id'"; - db_query($sql,"The supplier purchasing details could not be updated"); - + update_item_purchasing_data($selected_id, $_POST['stock_id'], input_num('price',0), + $_POST['suppliers_uom'], input_num('conversion_factor'), $_POST['supplier_description']); display_notification(_("Supplier purchasing data has been updated.")); } - - if (isset($_POST['UpdateRecord']) || isset($_POST['AddRecord'])) - { - //update or insert took place and need to clear the form - unset($supplier_id); - unset($_POST['price']); - unset($_POST['suppliers_uom']); - unset($_POST['conversion_factor']); - unset($_POST['supplier_description']); - } + $Mode = 'RESET'; } } //-------------------------------------------------------------------------------------------------- -if (isset($_GET['Delete'])) +if ($Mode == 'Delete') { + delete_item_purchasing_data($selected_id, $_POST['stock_id']); + display_notification(_("The purchasing data item has been sucessfully deleted.")); + $Mode = 'RESET'; +} - $sql = "DELETE FROM ".TB_PREF."purch_data WHERE supplier_id='$supplier_id' - AND stock_id='" . $_POST['stock_id'] . "'"; - db_query($sql,"could not delete purchasing data"); +if ($Mode == 'RESET') +{ + $selected_id = -1; +} - display_note(_("The purchasing data item has been sucessfully deleted.")); - unset ($supplier_id); +if (isset($_POST['_selected_id_update']) ) +{ + $selected_id = $_POST['selected_id']; + $Ajax->activate('_page_body'); } +if (list_updated('stock_id')) + $Ajax->activate('price_table'); //-------------------------------------------------------------------------------------------------- -start_form(false, true); +start_form(); if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); echo "