X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fui%2Fsales_credit_ui.inc;h=3267bb4343c029d6d1e2a76d9b89a5ad53dbf643;hb=99730b8d6deb7e81d2f1ebeb2ce7066d27729485;hp=751d7bd30cb8ba7debccd5a31f573705375a86fb;hpb=0c1bcd8ce3c089d7ddb3722a097f8fc8417f41e6;p=fa-stable.git diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index 751d7bd3..3267bb43 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -18,7 +18,7 @@ function display_credit_header(&$order) customer_list_row(_("Customer:"), 'customer_id', null, false, true); - if ($order->customer_id != $_POST['customer_id']) + if ($order->customer_id != $_POST['customer_id'] || $order->sales_type != $_POST['sales_type_id']) { // customer has changed @@ -45,10 +45,10 @@ function display_credit_header(&$order) if (!isset($_POST['ref'])) $_POST['ref'] = references::get_next(11); if ($_SESSION['Items']->trans_no==0) - ref_row(_("Reference:"), 'ref'); + ref_row(_("Reference").':', 'ref'); else - label_row(_("Reference"), $_POST['ref'], "class='tableheader2'"); - + label_row(_("Reference").':', $_POST['ref'] ); + echo ""; @@ -68,8 +68,8 @@ function display_credit_header(&$order) echo ""; if (!isset($_POST['sales_type_id'])) - $_POST['sales_type_id'] = $order->default_sales_type; - sales_types_list_row(_("Sales Type"), 'sales_type_id', $_POST['sales_type_id']); + $_POST['sales_type_id'] = $order->sales_type; + sales_types_list_row(_("Sales Type"), 'sales_type_id', $_POST['sales_type_id'], true); label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%"); echo "
"; @@ -101,141 +101,127 @@ function display_credit_header(&$order) function display_credit_items($title, &$order) { - 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"),''); - - if (count($order->line_items)) $th[]= ''; + global $table_style, $path_to_root; - table_header($th); + display_heading($title); + start_table("$table_style width=90%"); + $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), + _("Price"), _("Discount %"), _("Total"),''); - $subtotal = 0; - $k = 0; //row colour counter + if (count($order->line_items)) $th[]= ''; - foreach ($order->line_items as $line_no=>$line) - { - $line_total = $line->qty_dispatched * $line->price * (1 - $line->discount_percent); - if (!isset($_GET['Edit'])) - $id = -1; - else - $id = $_GET['Edit']; + table_header($th); - if ( $id != $line_no) + $subtotal = 0; + $k = 0; //row colour counter - { - alt_table_row_color($k); + $id = find_submit('Edit'); - label_cell("$line->stock_id"); - label_cell($line->item_description); - qty_cell($line->qty_dispatched); - label_cell($line->units); - amount_cell($line->price); + foreach ($order->line_items as $line_no=>$line) + { + $line_total = round($line->qty_dispatched * $line->price * (1 - $line->discount_percent), + user_price_dec()); - 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, false, get_qty_dec($line->stock_id)); + 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 = number_format2($subtotal,user_price_dec()); - 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'] = 0; + if (!isset($_POST['ChargeFreightCost']) OR ($_POST['ChargeFreightCost'] == "")) + $_POST['ChargeFreightCost'] = price_format(0); - text_row(_("Shipping"), 'ChargeFreightCost', $_POST['ChargeFreightCost'], 8, 8, "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 = number_format2(($subtotal + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec()); - label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","align=right"); + $display_total = price_format(($subtotal + $_POST['ChargeFreightCost'] + $tax_total)); + + 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'] = $order->line_items[$_GET['Edit']]->qty_dispatched; - if (!isset($_POST['price']) || ($_POST['price']=="")) - $_POST['price'] = $order->line_items[$_GET['Edit']]->price; - if (!isset($_POST['Disc']) || ($_POST['Disc']=="")) - $_POST['Disc'] = ($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['stock_id'], $dec); + $_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 { - global $no_item_list; - if ($no_item_list) - { - echo "\n"; - stock_items_list('stock_id', null, false, true); - echo "\n"; - } - else - { - text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'"); - stock_items_list_cells(null, 'stock_id', null, false, false, "onchange='return setAccount(1, true)'"); - } - $item_info = get_item_edit_info($_POST['stock_id']); + stock_items_list_cells(null,'stock_id', null, false, true); + $item_info = get_item_edit_info($_POST['stock_id']); $_POST['units'] = $item_info["units"]; - $_POST['qty'] = 0; - $_POST['price'] = get_price($_POST['stock_id'], $order->customer_id); + $_POST['qty'] = qty_format(0, $_POST['stock_id'], $dec); + $_POST['price'] = price_format(get_price($_POST['stock_id'], $order->customer_currency, + $order->sales_type, $order->price_factor, $order->document_date)); + // default to the customer's discount % - $_POST['Disc'] = $order->default_discount * 100; + $_POST['Disc'] = percent_format($order->default_discount * 100); } - text_cells(null, 'qty', $_POST['qty'], 13, 15); + qty_cells(null, 'qty', $_POST['qty'], null, null, $dec); // if ($order->trans_no!=0) { // amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done); // } label_cell($_POST['units']); - text_cells(null, 'price', null, 13, 15); - text_cells(null, 'Disc', $_POST['Disc'], 7, 5); + amount_cells(null, 'price', null); + small_amount_cells(null, 'Disc', percent_format(0), null, null, user_percent_dec()); 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); + set_focus('qty'); } else {