From: Janusz Dobrowolski Date: Tue, 18 Mar 2008 14:22:36 +0000 (+0000) Subject: Line items editor uses POST method - no disappearing shippment details. X-Git-Tag: v2.4.2~19^2~2164 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=b80d3fae8ac36bf66f6f446ced6c1a692899e56e;p=fa-stable.git Line items editor uses POST method - no disappearing shippment details. --- diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index 5de3dfb9..89ccd990 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -167,9 +167,9 @@ function handle_update_item() //----------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($line_no) { - $_SESSION['Items']->remove_from_cart($_GET['Delete']); + $_SESSION['Items']->remove_from_cart($line_no); } //----------------------------------------------------------------------------- @@ -184,11 +184,9 @@ function handle_new_item() input_num('price'), input_num('Disc') / 100); } //----------------------------------------------------------------------------- -if (isset($_GET['Delete']) || isset($_GET['Edit'])) - copy_from_cn(); - -if (isset($_GET['Delete'])) - handle_delete_item(); +$id = find_submit('Delete'); +if ($id!=-1) + handle_delete_item($id); if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) copy_to_cn(); diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index 06ef1fe0..45ef3b4d 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -101,102 +101,94 @@ function display_credit_header(&$order) function display_credit_items($title, &$order) { - global $table_style, $path_to_root; + global $table_style, $path_to_root; - display_heading($title); - start_table("$table_style width=90%"); - $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), - _("Price"), _("Discount %"), _("Total"),''); + display_heading($title); + start_table("$table_style width=90%"); + $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), + _("Price"), _("Discount %"), _("Total"),''); - if (count($order->line_items)) $th[]= ''; + if (count($order->line_items)) $th[]= ''; - table_header($th); + table_header($th); - $subtotal = 0; - $k = 0; //row colour counter + $subtotal = 0; + $k = 0; //row colour counter - foreach ($order->line_items as $line_no=>$line) - { - $line_total = round($line->qty_dispatched * $line->price * (1 - $line->discount_percent), - user_price_dec()); - if (!isset($_GET['Edit'])) - $id = -1; - else - $id = $_GET['Edit']; + $id = find_submit('Edit'); - if ( $id != $line_no) - - { - alt_table_row_color($k); + foreach ($order->line_items as $line_no=>$line) + { + $line_total = round($line->qty_dispatched * $line->price * (1 - $line->discount_percent), + user_price_dec()); - label_cell("$line->stock_id"); - label_cell($line->item_description); - qty_cell($line->qty_dispatched); - label_cell($line->units); - amount_cell($line->price); - - amount_cell($line->discount_percent * 100); - amount_cell($line_total); + if ( $id != $line_no) + { + alt_table_row_color($k); - edit_link_cell(SID . "Edit=$line_no"); - delete_link_cell(SID . "Delete=$line_no"); + label_cell("$line->stock_id"); + label_cell($line->item_description, "nowrap"); + qty_cell($line->qty_dispatched); + label_cell($line->units); + amount_cell($line->price); - //labelt_cell(get_tax_free_price_for_item($line->stock_id, $line_total, $_POST['tax_group_id'])); + amount_cell($line->discount_percent * 100); + amount_cell($line_total); - end_row(); - } - else - { - credit_edit_item_controls($order, $line_no); - } + edit_button_cell("Edit$line_no", _('Edit')); + edit_button_cell("Delete$line_no", _('Delete')); - $subtotal += $line_total; + end_row(); + } + else + { + credit_edit_item_controls($order, $k, $line_no); } - if (!isset($_GET['Edit'])) - credit_edit_item_controls($order); + $subtotal += $line_total; + } + + if ($id==-1) + credit_edit_item_controls($order, $k); - $display_sub_total = price_format($subtotal); - label_row(_("Sub-total"), $display_sub_total, "colspan=6 align=right", "align=right"); + $display_sub_total = price_format($subtotal); + label_row(_("Sub-total"), $display_sub_total, "colspan=6 align=right", "align=right", 2); - if (!isset($_POST['ChargeFreightCost']) OR ($_POST['ChargeFreightCost'] == "")) - $_POST['ChargeFreightCost'] = price_format(0); + if (!isset($_POST['ChargeFreightCost']) OR ($_POST['ChargeFreightCost'] == "")) + $_POST['ChargeFreightCost'] = price_format(0); - amount_cells_ex(_("Shipping"), 'ChargeFreightCost', 8, 8, $_POST['ChargeFreightCost'], "colspan=6 align=right"); + amount_cells_ex(_("Shipping"), 'ChargeFreightCost', 8, 8, $_POST['ChargeFreightCost'], "colspan=6 align=right"); + label_cell('', 'colspan=2'); $taxes = $order->get_taxes($_POST['ChargeFreightCost']); - $tax_total = display_edit_tax_items($taxes, 6, $_SESSION['Items']->tax_included); + $tax_total = display_edit_tax_items($taxes, 6, $_SESSION['Items']->tax_included); $display_total = price_format(($subtotal + $_POST['ChargeFreightCost'] + $tax_total)); - label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","class='amount'"); + label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","class='amount'", 2); end_table(); } //--------------------------------------------------------------------------------- -function credit_edit_item_controls(&$order, $line_no=-1) +function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1) { - start_row(); - if (isset($_GET['Edit']) && $line_no != -1) - { - - if (!isset($_POST['stock_id'])) - $_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id; - if (!isset($_POST['qty']) || ($_POST['qty']=="")) - $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->qty_dispatched); - if (!isset($_POST['price']) || ($_POST['price']=="")) - $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price); - if (!isset($_POST['Disc']) || ($_POST['Disc']=="")) - $_POST['Disc'] = percent_format(($order->line_items[$_GET['Edit']]->discount_percent)*100); + alt_table_row_color($rowcounter); + $id = find_submit('Edit'); - $_POST['units'] = $order->line_items[$_GET['Edit']]->units; + if ($line_no!=-1 && $line_no == $id) + { + $_POST['stock_id'] = $order->line_items[$id]->stock_id; + $_POST['qty'] = qty_format($order->line_items[$id]->qty_dispatched); + $_POST['price'] = price_format($order->line_items[$id]->price); + $_POST['Disc'] = percent_format(($order->line_items[$id]->discount_percent)*100); + $_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, "nowrap"); } else { @@ -234,11 +226,11 @@ function credit_edit_item_controls(&$order, $line_no=-1) amount_cell($_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc']/100)); - if (isset($_GET['Edit'])) + if ($id!=-1) { - submit_cells('UpdateItem', _("Update")); - submit_cells('CancelItemChanges', _("Cancel")); - hidden('LineNo', $line_no); + edit_button_cell('UpdateItem', _("Update")); + edit_button_cell('CancelItemChanges', _("Cancel")); + hidden('line_no', $line_no); } else { diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 9329f816..0e069ad8 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -97,16 +97,14 @@ function display_order_summary($title, &$order, $editable_items=false) $total = 0; $k = 0; //row colour counter + $id = find_submit('Edit'); + foreach ($order->line_items as $line_no=>$stock_item) { $line_total = round($stock_item->qty_dispatched * $stock_item->price * (1 - $stock_item->discount_percent), user_price_dec()); - if (!isset($_GET['Edit'])) - $id = -1; - else - $id = $_GET['Edit']; if (!$editable_items || $id != $line_no) { @@ -114,7 +112,7 @@ function display_order_summary($title, &$order, $editable_items=false) view_stock_status_cell($stock_item->stock_id); - label_cell($stock_item->item_description); + label_cell($stock_item->item_description, "nowrap" ); qty_cell($stock_item->qty_dispatched); if ($order->trans_no!=0) @@ -128,25 +126,25 @@ function display_order_summary($title, &$order, $editable_items=false) if ($editable_items) { - edit_link_cell(SID . "Edit=$line_no"); - delete_link_cell(SID . "Delete=$line_no"); + edit_button_cell("Edit$line_no", _("Edit")); + edit_button_cell("Delete$line_no", _("Delete")); } end_row(); } else { - sales_order_item_controls($order, $line_no); + sales_order_item_controls($order, $k, $line_no); } $total += $line_total; } - if (!isset($_GET['Edit']) && $editable_items) - sales_order_item_controls($order); + if ($id==-1 && $editable_items) + sales_order_item_controls($order, $k); $display_total = price_format($total); label_row(_("Total Excluding Shipping"), $display_total, "colspan=6 align=right", - "nowrap align=right"); + "nowrap align=right", 2); end_table(); } @@ -191,10 +189,6 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group if ($order->customer_id != $_POST['customer_id']) { // customer has changed - - // delete all the order items - drastic but necessary because of - // change of currency, sales type, etc - // $order->clear_items(); // clear the branch selection unset($_POST['branch_id']); } @@ -299,17 +293,8 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group if ($display_tax_group) { -/* if ($editable) - { - if (!isset($_POST['tax_group_id'])) - $_POST['tax_group_id'] = $_SESSION['Items']->tax_group_id; - tax_groups_list_row(_("Tax Group:"), 'tax_group_id', $_POST['tax_group_id'], true); - } - else -*/ { - label_row(_("Tax Group:"), $order->tax_group_name); - hidden('tax_group_id', $_SESSION['Items']->tax_group_id); - } + label_row(_("Tax Group:"), $order->tax_group_name); + hidden('tax_group_id', $_SESSION['Items']->tax_group_id); } echo ""; @@ -322,24 +307,21 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group //-------------------------------------------------------------------------------- -function sales_order_item_controls(&$order, $line_no=-1) +function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1) { - start_row(); - if (isset($_GET['Edit']) && $line_no != -1) + alt_table_row_color($rowcounter); + + $id = find_submit('Edit'); + if ($line_no!=-1 && $line_no == $id) { - if (!isset($_POST['stock_id'])) - $_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id; - if (!isset($_POST['qty']) || ($_POST['qty'] == "")) - $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->qty_dispatched); - if (!isset($_POST['price']) || ($_POST['price'] == "")) - $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price); - if (!isset($_POST['Disc']) || ($_POST['Disc'] == "")) - $_POST['Disc'] = percent_format($order->line_items[$_GET['Edit']]->discount_percent*100); - - $_POST['units'] = $order->line_items[$_GET['Edit']]->units; + $_POST['stock_id'] = $order->line_items[$id]->stock_id; + $_POST['qty'] = qty_format($order->line_items[$id]->qty_dispatched); + $_POST['price'] = price_format($order->line_items[$id]->price); + $_POST['Disc'] = percent_format($order->line_items[$id]->discount_percent*100); + $_POST['units'] = $order->line_items[$id]->units; hidden('stock_id', $_POST['stock_id']); label_cell($_POST['stock_id']); - label_cell($order->line_items[$line_no]->item_description); + label_cell($order->line_items[$line_no]->item_description, "nowrap"); } else { @@ -378,10 +360,10 @@ function sales_order_item_controls(&$order, $line_no=-1) $line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100); amount_cell($line_total); - if (isset($_GET['Edit'])) + if ($id!=-1) { - submit_cells('UpdateItem', _("Update")); - submit_cells('CancelItemChanges', _("Cancel")); + edit_button_cell('UpdateItem', _("Update")); + edit_button_cell('CancelItemChanges', _("Cancel")); hidden('LineNo', $line_no); } else diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index 39a90fe5..fe40810d 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -11,7 +11,6 @@ $path_to_root=".."; include_once($path_to_root . "/sales/includes/cart_class.inc"); include_once($path_to_root . "/includes/session.inc"); -include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/sales/includes/sales_ui.inc"); include_once($path_to_root . "/sales/includes/ui/sales_order_ui.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); @@ -289,16 +288,13 @@ function handle_update_item() //-------------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($line_no) { - if ($_GET['Delete'] != ""){ - $line_no = $_GET['Delete']; - if ($_SESSION['Items']->some_already_delivered($line_no) == 0) { - $_SESSION['Items']->remove_from_cart($line_no); - } else { - display_error(_("This item cannot be deleted because some of it has already been delivered.")); - } - } + if ($_SESSION['Items']->some_already_delivered($line_no) == 0) { + $_SESSION['Items']->remove_from_cart($line_no); + } else { + display_error(_("This item cannot be deleted because some of it has already been delivered.")); + } } //-------------------------------------------------------------------------------- @@ -381,14 +377,15 @@ function create_cart($type, $trans_no) //-------------------------------------------------------------------------------- -if (isset($_GET['Delete']) || isset($_GET['Edit'])) - copy_from_cart(); // GET method need form restore +//if (isset($_GET['Delete']) || isset($_GET['Edit'])) +// copy_from_cart(); // GET method need form restore if (isset($_POST['CancelOrder'])) handle_cancel_order(); -if (isset($_GET['Delete'])) - handle_delete_item(); +$id = find_submit('Delete'); +if ($id!=-1) + handle_delete_item($id); if (isset($_POST['UpdateItem'])) handle_update_item();