From: Janusz Dobrowolski Date: Sat, 21 Jun 2008 08:27:17 +0000 (+0000) Subject: Ajax additions to sales and purchasing modules. X-Git-Tag: v2.4.2~19^2~1985 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=de320b43ef41373a90d9061483b6e8970947fdfa;p=fa-stable.git Ajax additions to sales and purchasing modules. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 61e35620..18168218 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,19 @@ Legend: ! -> Note $ -> Affected files +21-Jun-2008 Janusz Dobrowolski ++ Ajax additions to sales and purchasing modules +$ /purchasing/po_entry_items.php + /purchasing/supplier_payment.php + /purchasing/allocations/supplier_allocate.php + /purchasing/includes/ui/po_ui.inc + /purchasing/inquiry/po_search.php + /purchasing/inquiry/po_search_completed.php + /purchasing/inquiry/supplier_allocation_inquiry.php + /purchasing/inquiry/supplier_inquiry.php + /purchasing/manage/suppliers.php + /sales/manage/customers.php + 21-Jun-2008 Joe Hunt + Added upload functionality to company logo. Better names on lists search. $ /admin/company_preferences.php diff --git a/purchasing/allocations/supplier_allocate.php b/purchasing/allocations/supplier_allocate.php index ecb96510..7ca1a764 100644 --- a/purchasing/allocations/supplier_allocate.php +++ b/purchasing/allocations/supplier_allocate.php @@ -115,6 +115,7 @@ if (isset($_POST['Process'])) handle_process(); $_POST['Cancel'] = 1; } + $Ajax->update('_page_body'); } //-------------------------------------------------------------------------------- @@ -123,9 +124,11 @@ if (isset($_POST['Cancel'])) { clear_allocations(); meta_forward($path_to_root . "/purchasing/allocations/supplier_allocation_main.php"); - exit; } - +if (isset($_POST['UpdateDisplay'])) +{ + $Ajax->update('_page_body'); +} //-------------------------------------------------------------------------------- function get_allocations_for_transaction($type, $trans_no) @@ -244,9 +247,9 @@ function edit_allocations_for_transaction($type, $trans_no) hidden('TotalNumberOfAllocs', $counter); // hidden('left_to_allocate', $left_to_allocate); echo "
"; - submit('UpdateDisplay', _("Update")); + submit('UpdateDisplay', _("Update"), true, '', true); echo " "; - submit('Process', _("Process")); + submit('Process', _("Process"), true, '', true); echo " "; } else @@ -255,7 +258,7 @@ function edit_allocations_for_transaction($type, $trans_no) echo "
"; } - submit('Cancel', _("Back to Allocations")); + submit('Cancel', _("Back to Allocations"), true, '', true); echo "


"; end_form(); diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index f9a5071c..f9f1b3f4 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -41,7 +41,7 @@ function create_new_po() function display_po_header(&$order) { - global $table_style2; + global $table_style2, $Ajax; $editable = ($order->order_no == 0); @@ -62,6 +62,7 @@ function display_po_header(&$order) // delete all the order items - drastic but necessary because of // change of currency, etc $order->clear_items(); + // FIX } } else @@ -70,16 +71,24 @@ function display_po_header(&$order) label_row(_("Supplier:"), $order->supplier_name); } - //if ($editable || ($order->supplier_id != $_POST['supplier_id'])) - get_supplier_details_to_order($order, $_POST['supplier_id']); - + if ($order->supplier_id != get_post('supplier_id',-1)) { + get_supplier_details_to_order($order, $_POST['supplier_id']); + // supplier default price update + foreach ($order->line_items as $line_no=>$item) { + $line = &$order->line_items[$line_no]; + $line->price = get_purchase_price ($order->supplier_id, $_POST['stock_id']); + } + $Ajax->activate('items_table'); + } set_global_supplier($_POST['supplier_id']); if (!is_company_currency($order->curr_code)) { +//FIX div currency ? label_row(_("Supplier Currency:"), $order->curr_code); exchange_rate_display($order->curr_code, get_company_currency(), $_POST['OrderDate']); + } if ($editable) @@ -118,13 +127,11 @@ function display_po_header(&$order) echo "" . _("Receive Into:") . ""; echo ""; - locations_list('StkLocation', null); - echo " "; - submit('GetAddress', _("Get Address")); + locations_list('StkLocation', null, false, true); echo ""; if (!isset($_POST['StkLocation']) || $_POST['StkLocation'] == "" || - isset($_POST['GetAddress']) || !isset($_POST['delivery_address']) || + isset($_POST['_StkLocation_update']) || !isset($_POST['delivery_address']) || $_POST['delivery_address'] == "") { /*If this is the first time the form loaded set up defaults */ @@ -137,13 +144,14 @@ function display_po_header(&$order) { $loc_row = db_fetch($result); $_POST['delivery_address'] = $loc_row["delivery_address"]; + $Ajax->activate('delivery_address'); $_SESSION['PO']->Location = $_POST['StkLocation']; $_SESSION['PO']->delivery_address = $_POST['delivery_address']; } else { /*The default location of the user is crook */ - echo "
" . _("The default stock location set up for this user is not a currently defined stock location. Your system administrator needs to amend your user record."); + display_error(_("The default stock location set up for this user is not a currently defined stock location. Your system administrator needs to amend your user record.")); } } @@ -162,6 +170,7 @@ function display_po_items(&$order, $editable=true) display_heading(_("Order Items")); + div_start('items_table'); start_table("$table_style width=80%"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), @@ -170,15 +179,17 @@ function display_po_items(&$order, $editable=true) if (count($order->line_items)) $th[] = ''; table_header($th); + $id = find_submit('Edit'); $total = 0; $k = 0; - foreach ($order->line_items as $po_line) + foreach ($order->line_items as $line_no => $po_line) { if ($po_line->Deleted == false) { $line_total = round($po_line->quantity * $po_line->price, user_price_dec()); - if (!$editable || !isset($_GET['Edit']) || $_GET['Edit'] != $po_line->line_no) +// if (!$editable || ($id != $po_line->line_no)) + if (!$editable || ($id != $line_no)) { alt_table_row_color($k); label_cell($po_line->stock_id); @@ -191,8 +202,12 @@ function display_po_items(&$order, $editable=true) if ($editable) { - edit_link_cell(SID."Edit=" . $po_line->line_no); - delete_link_cell(SID."Delete=" . $po_line->line_no); + edit_button_cell("Edit$line_no", _("Edit"), + _('Edit document line')); + edit_button_cell("Delete$line_no", _("Delete"), + _('Remove line from document')); +// edit_link_cell(SID."Edit=" . $po_line->line_no); +// delete_link_cell(SID."Delete=" . $po_line->line_no); } end_row(); } @@ -204,7 +219,7 @@ function display_po_items(&$order, $editable=true) } } - if (!isset($_GET['Edit']) && $editable) + if ($id==-1 && $editable) po_item_controls($order); $display_total = price_format($total); @@ -212,6 +227,7 @@ function display_po_items(&$order, $editable=true) "nowrap align=right"); end_table(1); + div_end(); } //--------------------------------------------------------------------------------------------------- @@ -269,35 +285,47 @@ function display_po_summary(&$po, $is_self=false, $editable=false) function po_item_controls(&$order, $stock_id=null) { + global $Ajax; start_row(); - if (isset($_GET['Edit']) && $stock_id != null) + $id = find_submit('Edit'); + if ($id && $stock_id != null) { - hidden('line_no', $_GET['Edit']); + hidden('line_no', $id); if (!isset($_POST['stock_id'])) - $_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id; + $_POST['stock_id'] = $order->line_items[$id]->stock_id; + $dec = get_qty_dec($_POST['stock_id']); if (!isset($_POST['qty']) || ($_POST['qty'] == "")) - $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->quantity, $_POST['stock_id'], $dec); + $_POST['qty'] = qty_format($order->line_items[$id]->quantity, $_POST['stock_id'], $dec); if (!isset($_POST['price']) || ($_POST['price'] == "")) - $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price); + $_POST['price'] = price_format($order->line_items[$id]->price); if (!isset($_POST['req_del_date']) || ($_POST['req_del_date'] == "")) - $_POST['req_del_date'] = $order->line_items[$_GET['Edit']]->req_del_date; + $_POST['req_del_date'] = $order->line_items[$id]->req_del_date; - $_POST['units'] = $order->line_items[$_GET['Edit']]->units; + $_POST['units'] = $order->line_items[$id]->units; hidden('stock_id', $_POST['stock_id']); label_cell($_POST['stock_id']); - label_cell($order->line_items[$_GET['Edit']]->item_description); + label_cell($order->line_items[$id]->item_description); + $Ajax->activate('items_table'); } else { hidden('line_no', ($_SESSION['PO']->lines_on_order + 1)); stock_purchasable_items_list_cells(null, 'stock_id', null, false, true); + if(isset($_POST['_stock_id_update'])) { + $Ajax->activate('price'); + $Ajax->activate('units'); + $Ajax->activate('qty'); + $Ajax->activate('req_del_date'); + $Ajax->activate('line_total'); + } $item_info = get_item_edit_info($_POST['stock_id']); $_POST['units'] = $item_info["units"]; + $dec = get_qty_dec($_POST['stock_id']); $_POST['qty'] = qty_format(1, $_POST['stock_id'], $dec); $_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id'])); $_POST['req_del_date'] = add_days(Today(), 10); @@ -305,22 +333,26 @@ function po_item_controls(&$order, $stock_id=null) qty_cells(null, 'qty', null, null, null, $dec); - label_cell($_POST['units']); + label_cell($_POST['units'], '', 'units'); date_cells(null, 'req_del_date', '', null, 0, 0, 0); amount_cells(null, 'price', null); //$line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100); $line_total = round(input_num('qty') * input_num('price'), user_price_dec()); - amount_cell($line_total); + amount_cell($line_total, false, '','line_total'); - if (isset($_GET['Edit'])) + if ($id!=-1) { - submit_cells('UpdateLine', _("Update")); - submit_cells('CancelUpdate', _("Cancel")); + edit_button_cell('UpdateLine', _("Update"), + _('Confirm changes')); + edit_button_cell('CancelUpdate', _("Cancel"), + _('Cancel changes')); + set_focus('qty'); } else { - submit_cells('EnterLine', _("Add Item"), "colspan=2"); + submit_cells('EnterLine', _("Add Item"), "colspan=2", + _('Add new item to document'), true); } end_row(); diff --git a/purchasing/inquiry/po_search.php b/purchasing/inquiry/po_search.php index 93dcffe9..b4bac802 100644 --- a/purchasing/inquiry/po_search.php +++ b/purchasing/inquiry/po_search.php @@ -18,6 +18,30 @@ if (isset($_GET['order_number'])) { $_POST['order_number'] = $_GET['order_number']; } +//----------------------------------------------------------------------------------- +// Ajax updates +// +if (get_post('SearchOrders')) +{ + $Ajax->activate('orders_tbl'); +} elseif (get_post('_order_number_changed')) +{ + $disable = get_post('order_number') !== ''; + + $Ajax->addDisable(true, 'OrdersAfterDate', $disable); + $Ajax->addDisable(true, 'OrdersToDate', $disable); + $Ajax->addDisable(true, 'StockLocation', $disable); + $Ajax->addDisable(true, '_SelectStockFromList_edit', $disable); + $Ajax->addDisable(true, 'SelectStockFromList', $disable); + + if ($disable) { + $Ajax->addFocus(true, 'order_number'); + } else + $Ajax->addFocus(true, 'OrdersAfterDate'); + + $Ajax->activate('orders_tbl'); +} + //--------------------------------------------------------------------------------------------- @@ -25,7 +49,7 @@ start_form(false, true); start_table("class='tablestyle_noborder'"); start_row(); -ref_cells(_("#:"), 'order_number'); +ref_cells(_("#:"), 'order_number', '',null, '', true); date_cells(_("from:"), 'OrdersAfterDate', '', null, -30); date_cells(_("to:"), 'OrdersToDate'); @@ -34,7 +58,7 @@ locations_list_cells(_("Location:"), 'StockLocation', null, true); stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true); -submit_cells('SearchOrders', _("Search")); +submit_cells('SearchOrders', _("Search"),'',_('Select documents'), true); end_row(); end_table(); @@ -104,6 +128,7 @@ print_hidden_script(18); /*show a table of the orders returned by the sql */ +div_start('orders_tbl'); start_table("$table_style colspan=7 width=80%"); if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == $all_items) @@ -164,6 +189,6 @@ end_table(); if ($overdue_items) display_note(_("Marked orders have overdue items."), 0, 1, "class='overduefg'"); - +div_end(); end_page(); ?> diff --git a/purchasing/inquiry/po_search_completed.php b/purchasing/inquiry/po_search_completed.php index 160763db..7e2f7f61 100644 --- a/purchasing/inquiry/po_search_completed.php +++ b/purchasing/inquiry/po_search_completed.php @@ -18,13 +18,36 @@ if (isset($_GET['order_number'])) $order_number = $_GET['order_number']; } +//----------------------------------------------------------------------------------- +// Ajax updates +// +if (get_post('SearchOrders')) +{ + $Ajax->activate('orders_tbl'); +} elseif (get_post('_order_number_changed')) +{ + $disable = get_post('order_number') !== ''; + + $Ajax->addDisable(true, 'OrdersAfterDate', $disable); + $Ajax->addDisable(true, 'OrdersToDate', $disable); + $Ajax->addDisable(true, 'StockLocation', $disable); + $Ajax->addDisable(true, '_SelectStockFromList_edit', $disable); + $Ajax->addDisable(true, 'SelectStockFromList', $disable); + + if ($disable) { + $Ajax->addFocus(true, 'order_number'); + } else + $Ajax->addFocus(true, 'OrdersAfterDate'); + + $Ajax->activate('orders_tbl'); +} //--------------------------------------------------------------------------------------------- start_form(false, true); start_table("class='tablestyle_noborder'"); start_row(); -ref_cells(_("#:"), 'order_number'); +ref_cells(_("#:"), 'order_number', '',null, '', true); date_cells(_("from:"), 'OrdersAfterDate', '', null, -30); date_cells(_("to:"), 'OrdersToDate'); @@ -33,7 +56,7 @@ locations_list_cells(_("into location:"), 'StockLocation', null, true); stock_items_list_cells(_("for item:"), 'SelectStockFromList', null, true); -submit_cells('SearchOrders', _("Search")); +submit_cells('SearchOrders', _("Search"),'',_('Select documents'), true); end_row(); end_table(); @@ -97,6 +120,7 @@ $result = db_query($sql,"No orders were returned"); print_hidden_script(18); +div_start('orders_tbl'); start_table("$table_style colspan=7 width=80%"); if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == reserved_words::get_all()) @@ -138,7 +162,7 @@ while ($myrow = db_fetch($result)) } end_table(2); - +div_end(); //--------------------------------------------------------------------------------------------------- end_page(); diff --git a/purchasing/inquiry/supplier_allocation_inquiry.php b/purchasing/inquiry/supplier_allocation_inquiry.php index 8d306f1c..1604f8f9 100644 --- a/purchasing/inquiry/supplier_allocation_inquiry.php +++ b/purchasing/inquiry/supplier_allocation_inquiry.php @@ -44,7 +44,7 @@ supp_allocations_list_cells("filterType", null); check_cells(_("show settled:"), 'showSettled', null); -submit_cells('Refresh Inquiry', _("Search")); +submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true); set_global_supplier($_POST['supplier_id']); @@ -109,33 +109,37 @@ function get_transactions() //------------------------------------------------------------------------------------------------ $result = get_transactions(); - -if (db_num_rows($result) == 0) +//------------------------------------------------------------------------------------------------ +if(get_post('RefreshInquiry')) { - display_note(_("There are no transactions to display for the given dates."), 1, 1); - end_page(); - exit; + $Ajax->activate('doc_tbl'); } //------------------------------------------------------------------------------------------------ /*show a table of the transactions returned by the sql */ -start_table("$table_style width=90%"); -if ($_POST['supplier_id'] == reserved_words::get_all()) +div_start('doc_tbl'); +if (db_num_rows($result) == 0) +{ + display_note(_("There are no transactions to display for the given dates."), 1, 1); +} else +{ + start_table("$table_style width=90%"); + if ($_POST['supplier_id'] == reserved_words::get_all()) $th = array(_("Type"), _("Number"), _("Reference"), _("Supplier"), _("Supp Reference"), _("Date"), _("Due Date"), _("Currency"), _("Debit"), _("Credit"), _("Allocated"), _("Balance"), ""); -else + else $th = array(_("Type"), _("Number"), _("Reference"), _("Supp Reference"), _("Date"), _("Due Date"), _("Debit"), _("Credit"), _("Allocated"), _("Balance"), ""); -table_header($th); + table_header($th); -$j = 1; -$k = 0; //row colour counter -$over_due = false; -while ($myrow = db_fetch($result)) -{ + $j = 1; + $k = 0; //row colour counter + $over_due = false; + while ($myrow = db_fetch($result)) + { if ($myrow['OverDue'] == 1) { @@ -193,13 +197,14 @@ while ($myrow = db_fetch($result)) $j = 1; table_header($th); } -//end of page full new headings if -} -//end of while loop + //end of page full new headings if + } + //end of while loop -end_table(1); -if ($over_due) + end_table(1); + if ($over_due) display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'"); - +} +div_end(); end_page(); ?> diff --git a/purchasing/inquiry/supplier_inquiry.php b/purchasing/inquiry/supplier_inquiry.php index 09e59926..543a5cc1 100644 --- a/purchasing/inquiry/supplier_inquiry.php +++ b/purchasing/inquiry/supplier_inquiry.php @@ -40,7 +40,7 @@ date_cells(_("To:"), 'TransToDate'); supp_allocations_list_cells("filterType", null); -submit_cells('Refresh Inquiry', _("Search")); +submit_cells('Refresh Inquiry', _("Search"),'',_('Refresh Inquiry'), true); end_row(); end_table(); @@ -134,43 +134,50 @@ function get_transactions() //------------------------------------------------------------------------------------------------ +div_start('totals_tbl'); if (($_POST['supplier_id'] != "") && ($_POST['supplier_id'] != reserved_words::get_all())) { $supplier_record = get_supplier_details($_POST['supplier_id']); display_supplier_summary($supplier_record); } +div_end(); //------------------------------------------------------------------------------------------------ $result = get_transactions(); -if (db_num_rows($result) == 0) +if(get_post('Refresh Inquiry')) { - display_note(_("There are no transactions to display for the given dates."), 1, 1); - end_page(); - exit; + $Ajax->activate('trans_tbl'); + $Ajax->activate('totals_tbl'); } //------------------------------------------------------------------------------------------------ /*show a table of the transactions returned by the sql */ -start_table("$table_style width=80%"); -if ($_POST['supplier_id'] == reserved_words::get_all()) +div_start('trans_tbl'); +if (db_num_rows($result) == 0) +{ + display_note(_("There are no transactions to display for the given dates."), 1, 1); +} else +{ + start_table("$table_style width=80%"); + if ($_POST['supplier_id'] == reserved_words::get_all()) $th = array(_("Type"), _("#"), _("Reference"), _("Supplier"), _("Supplier's Reference"), _("Date"), _("Due Date"), _("Currency"), _("Debit"), _("Credit"), ""); -else + else $th = array(_("Type"), _("#"), _("Reference"), _("Supplier's Reference"), _("Date"), _("Due Date"), _("Debit"), _("Credit"), ""); -table_header($th); + table_header($th); -$j = 1; -$k = 0; //row colour counter -$over_due = false; -while ($myrow = db_fetch($result)) -{ + $j = 1; + $k = 0; //row colour counter + $over_due = false; + while ($myrow = db_fetch($result)) + { if ($myrow['OverDue'] == 1) { @@ -213,14 +220,14 @@ while ($myrow = db_fetch($result)) $j=1; table_header($th); } -//end of page full new headings if -} -//end of while loop + //end of page full new headings if + } + //end of while loop -end_table(1); -if ($over_due) + end_table(1); + if ($over_due) display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'"); - - +} +div_end(); end_page(); ?> diff --git a/purchasing/manage/suppliers.php b/purchasing/manage/suppliers.php index fbaabbca..1748de25 100644 --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@ -12,15 +12,7 @@ include($path_to_root . "/includes/ui.inc"); check_db_has_tax_groups(_("There are no tax groups defined in the system. At least one tax group is required before proceeding.")); -if (isset($_GET['New']) || !isset($_POST['supplier_id'])) -{ - $_POST['New'] = "1"; -} - -if (isset($_POST['SelectSupplier'])) -{ - unset($_POST['New']); -} +$new_supplier = get_post('supplier_id') == ''; if (isset($_POST['submit'])) { @@ -43,7 +35,7 @@ if (isset($_POST['submit'])) if ($input_error !=1 ) { - if (!isset($_POST['New'])) + if (!$new_supplier) { $sql = "UPDATE ".TB_PREF."suppliers SET supp_name=".db_escape($_POST['supp_name']) . ", @@ -60,10 +52,10 @@ if (isset($_POST['submit'])) tax_group_id=".db_escape($_POST['tax_group_id']) . " WHERE supplier_id = '" . $_POST['supplier_id'] . "'"; db_query($sql,"The supplier could not be updated"); - + display_notification(_("Supplier has been updated.")); } else - { //not a new supplier + { $sql = "INSERT INTO ".TB_PREF."suppliers (supp_name, address, email, bank_account, dimension_id, dimension2_id, curr_code, payment_terms, payable_account, purchase_account, payment_discount_account, tax_group_id) @@ -81,9 +73,12 @@ if (isset($_POST['submit'])) .db_escape($_POST['tax_group_id']). ")"; db_query($sql,"The supplier could not be added"); + $_POST['supplier_id'] = db_insert_id(); + $new_supplier = false; + display_notification(_("A new supplier has been added.")); + $Ajax->activate('supplier_id'); + $Ajax->activate('controls'); } - - meta_forward($_SERVER['PHP_SELF']); } } @@ -122,7 +117,8 @@ elseif (isset($_POST['delete']) && $_POST['delete'] != "") db_query($sql,"check failed"); unset($_SESSION['supplier_id']); - meta_forward($_SERVER['PHP_SELF']); + $new_supplier = true; + $Ajax->activate('_page_body'); } //end if Delete supplier } @@ -131,10 +127,9 @@ start_form(); if (db_has_suppliers()) { start_table("", 3); - start_row(); - supplier_list_cells(_("Select a supplier: "), 'supplier_id', null); - submit_cells('SelectSupplier', _("Edit Supplier")); - end_row(); +// start_table("class = 'tablestyle_noborder'"); + supplier_list_row(_("Select a supplier: "), 'supplier_id', null, + _('New supplier'), true); end_table(); } else @@ -142,15 +137,12 @@ else hidden('supplier_id', $_POST['supplier_id']); } -hyperlink_params($_SERVER['PHP_SELF'], _("Enter a new supplier"), "New=1"); -echo "
"; - //start_table("class='tablestyle2'", 0, 3); start_table("class='tablestyle'", 3); table_section_title(_("Supplier")); -if (isset($_POST['supplier_id']) && !isset($_POST['New'])) +if (!$new_supplier) { //SupplierID exists - either passed when calling the form or from the form itself $myrow = get_supplier($_POST['supplier_id']); @@ -171,11 +163,16 @@ if (isset($_POST['supplier_id']) && !isset($_POST['New'])) } else { - // its a new supplier being added - hidden('New', 'Yes'); + $_POST['supp_name'] = $_POST['address'] = $_POST['tax_group_id'] = ''; + $_POST['dimension_id'] = 0; + $_POST['dimension2_id'] = 0; + $_POST['sales_type'] = -1; + $_POST['email'] = $_POST['bank_account'] = ''; + $_POST['payment_terms'] = ''; + $_POST['credit_limit'] = price_format(sys_prefs::default_credit_limit()); $company_record = get_company_prefs(); - + $_POST['curr_code'] = $company_record["curr_default"]; $_POST['payable_account'] = $company_record["creditors_act"]; $_POST['purchase_account'] = $company_record["default_cogs_act"]; $_POST['payment_discount_account'] = $company_record['pyt_discount_act']; @@ -187,7 +184,7 @@ text_row(_("Email:"), 'email', null, 42, 40); text_row(_("Bank Account:"), 'bank_account', null, 42, 40); // Sherifoz 23.09.03 currency can't be changed if editing -if (isset($_POST['supplier_id']) && !isset($_POST['New'])) +if (!$new_supplier) { label_row(_("Supplier's Currency:"), $_POST['curr_code']); hidden('curr_code', $_POST['curr_code']); @@ -224,17 +221,19 @@ if ($dim < 2) hidden('dimension2_id', 0); end_table(1); - -if (!isset($_POST['New'])) +div_start('controls'); +if (!$new_supplier) { - submit_center_first('submit', _("Update Supplier")); - submit_center_last('delete', _("Delete Supplier")); + submit_center_first('submit', _("Update Supplier"), + _('Update supplier data'), true); + submit_center_last('delete', _("Delete Supplier"), + _('Delete supplier data if have been never used'), true); } else { - submit_center('submit', _("Add New Supplier Details")); + submit_center('submit', _("Add New Supplier Details"), true, '', true); } - +div_end(); end_form(); end_page(); diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index 13897245..74469db9 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -52,6 +52,13 @@ if (isset($_GET['AddedID'])) display_footer_exit(); } +//-------------------------------------------------------------------------------------------------- +function line_start_focus() { + global $Ajax; + + $Ajax->activate('items_table'); + set_focus('_stock_id_edit'); +} //-------------------------------------------------------------------------------------------------- function copy_to_po() @@ -89,9 +96,8 @@ function unset_form_variables() { //--------------------------------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($line_no) { - $line_no = $_GET['Delete']; if($_SESSION['PO']->some_already_received($line_no) == 0) { $_SESSION['PO']->remove_from_order($line_no); @@ -101,6 +107,7 @@ function handle_delete_item() { display_error(_("This item cannot be deleted because some of it has already been received.")); } + line_start_focus(); } //--------------------------------------------------------------------------------------------------- @@ -135,17 +142,6 @@ function handle_cancel_po() exit; } -//--------------------------------------------------------------------------------------------------- -if (isset($_GET['Delete']) || isset($_GET['Edit'])) -{ - copy_from_po(); -} - -if (isset($_GET['Delete'])) -{ - handle_delete_item(); -} - //--------------------------------------------------------------------------------------------------- function check_data() @@ -191,6 +187,7 @@ function handle_update_item() $_SESSION['PO']->update_order_item($_POST['line_no'], input_num('qty'), input_num('price'), $_POST['req_del_date']); unset_form_variables(); + line_start_focus(); } //--------------------------------------------------------------------------------------------------- @@ -203,15 +200,15 @@ function handle_add_new_item() { if (count($_SESSION['PO']->line_items) > 0) { - foreach ($_SESSION['PO']->line_items AS $order_item) + foreach ($_SESSION['PO']->line_items as $order_item) { /* do a loop round the items on the order to see that the item is not already on this order */ if (($order_item->stock_id == $_POST['stock_id']) && - ($order_item->Deleted==False)) + ($order_item->Deleted == false)) { - $allow_update = False; + $allow_update = false; display_error(_("The selected item is already on this order.")); } } /* end of the foreach loop to look for pre-existing items of the same code */ @@ -226,7 +223,7 @@ function handle_add_new_item() if (db_num_rows($result) == 0) { - $allow_update = False; + $allow_update = false; } if ($allow_update) @@ -237,7 +234,7 @@ function handle_add_new_item() $_POST['req_del_date'], 0, 0); unset_form_variables(); - $_POST['StockID2'] = $_POST['stock_id'] = ""; + $_POST['stock_id'] = ""; } else { @@ -246,6 +243,7 @@ function handle_add_new_item() } /* end of if not already on the order and allow input was true*/ } + line_start_focus(); } //--------------------------------------------------------------------------------------------------- @@ -264,14 +262,14 @@ function can_commit() if (!references::is_valid($_SESSION['PO']->reference)) { display_error(_("There is no reference entered for this purchase order.")); - set_focus('ref'); + set_focus('ref'); return false; } if (!is_new_reference($_SESSION['PO']->reference, systypes::po())) { display_error(_("The entered reference is already in use.")); - set_focus('ref'); + set_focus('ref'); return false; } } @@ -331,47 +329,39 @@ function handle_commit_order() } } } - //--------------------------------------------------------------------------------------------------- +$id = find_submit('Delete'); +if ($id != -1) + handle_delete_item($id); +if (isset($_POST['Delete']) || isset($_POST['Edit'])) +{ + copy_from_po(); +} + if (isset($_POST['Commit'])) { handle_commit_order(); } - -//--------------------------------------------------------------------------------------------------- - if (isset($_POST['UpdateLine'])) { copy_to_po(); handle_update_item(); } - -//--------------------------------------------------------------------------------------------------- - -If (isset($_POST['EnterLine'])) +if (isset($_POST['EnterLine'])) { copy_to_po(); handle_add_new_item(); } - -//--------------------------------------------------------------------------------------------------- - if (isset($_POST['CancelOrder'])) { handle_cancel_po(); } - -//--------------------------------------------------------------------------------------------------- - if (isset($_POST['CancelUpdate'])) { copy_to_po(); unset_form_variables(); } - -//--------------------------------------------------------------------------------------------------- - if (isset($_GET['ModifyOrderNumber']) && $_GET['ModifyOrderNumber'] != "") { create_new_po(); @@ -382,6 +372,9 @@ if (isset($_GET['ModifyOrderNumber']) && $_GET['ModifyOrderNumber'] != "") read_po($_SESSION['PO']->order_no, $_SESSION['PO']); copy_from_po(); } +if (isset($_POST['CancelUpdate']) || isset($_POST['UpdateLine'])) { + line_start_focus(); +} //-------------------------------------------------------------------------------- @@ -414,6 +407,8 @@ start_table($table_style2); textarea_row(_("Memo:"), 'Comments', null, 70, 4); end_table(1); + +div_start('controls', 'items_table'); if ($_SESSION['PO']->order_has_items()) { if ($_SESSION['PO']->order_no) @@ -424,7 +419,7 @@ if ($_SESSION['PO']->order_has_items()) } else submit_center('CancelOrder', _("Cancel Order")); - +div_end(); //--------------------------------------------------------------------------------------------------- end_form(); diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index 5994a2d3..a6021942 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -101,7 +101,7 @@ function display_controls() echo ""; end_table(1); // outer table - submit_center('ProcessSuppPayment',_("Enter Payment")); + submit_center('ProcessSuppPayment',_("Enter Payment"), true, '', true); if ($bank_currency != $supplier_currency) { diff --git a/sales/manage/customers.php b/sales/manage/customers.php index 4693aa08..8f1eccb8 100644 --- a/sales/manage/customers.php +++ b/sales/manage/customers.php @@ -71,7 +71,6 @@ function handle_submit() db_query($sql,"The customer could not be updated"); display_notification(_("Customer has been updated.")); - } else { //it is a new customer @@ -95,7 +94,8 @@ function handle_submit() display_notification(_("A new customer has been added.")); - $Ajax->activate('_page_body'); + $Ajax->activate('customer_id'); + $Ajax->activate('controls'); } } @@ -270,7 +270,7 @@ end_row(); end_table(); end_table(1); // outer table - +div_start('controls'); if ($new_customer) { submit_center('submit', _("Add New Customer"), true, '', true); @@ -280,9 +280,9 @@ else submit_center_first('submit', _("Update Customer"), _('Update customer data'), true); submit_center_last('delete', _("Delete Customer"), - _('Delete user data if have been never used'), true); + _('Delete customer data if have been never used'), true); } - +div_end(); end_form(); end_page();