X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fui%2Fpo_ui.inc;h=ed696468740f8aa4a517b3ca262ea1bebaf953ea;hb=5b8f4c4b4aa8cf996bc071f116bfce1273200fa2;hp=5f09dc10a52d5476e8f459e2ba4c6b78f00030ae;hpb=1265917ba03e48dffcb309dcbf496c67deb3d2d7;p=fa-stable.git diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 5f09dc10..ed696468 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -19,14 +19,17 @@ function copy_from_cart() $_POST['supplier_id'] = $cart->supplier_id; $_POST['OrderDate'] = $cart->orig_order_date; - if ($cart->trans_type==ST_SUPPINVOICE) + if ($cart->trans_type == ST_SUPPINVOICE) $_POST['due_date'] = $cart->due_date; $_POST['supp_ref'] = $cart->supp_ref; $_POST['ref'] = $cart->reference; $_POST['Comments'] = $cart->Comments; $_POST['StkLocation'] = $cart->Location; $_POST['delivery_address'] = $cart->delivery_address; + $_POST['tax_algorithm'] = $cart->tax_algorithm; + $_POST['prep_amount'] = price_format($cart->prep_amount); $_POST['_ex_rate'] = $cart->ex_rate; + $_POST['cash_account'] = $cart->cash_account; foreach($cart->tax_overrides as $id => $value) $_POST['mantax'][$id] = price_format($value); } @@ -37,13 +40,19 @@ function copy_to_cart() $cart->supplier_id = $_POST['supplier_id']; $cart->orig_order_date = $_POST['OrderDate']; - if ($cart->trans_type==ST_SUPPINVOICE) + if ($cart->trans_type == ST_SUPPINVOICE) + { $cart->due_date = $_POST['due_date']; + $cart->cash_account = get_post('cash_account'); + } $cart->reference = $_POST['ref']; $cart->supp_ref = $_POST['supp_ref']; $cart->Comments = $_POST['Comments']; $cart->Location = $_POST['StkLocation']; $cart->delivery_address = $_POST['delivery_address']; + if (isset($_POST['tax_algorithm'])) + $cart->tax_algorithm = $_POST['tax_algorithm']; + $cart->prep_amount = input_num('prep_amount', 0); $cart->ex_rate = input_num('_ex_rate', null); if (isset($_POST['mantax'])) { @@ -51,36 +60,6 @@ function copy_to_cart() $cart->tax_overrides[$id] = user_numeric($_POST['mantax'][$id]); } } } -// ------------------------------------------------------------------------------ - -function get_supplier_details_to_order(&$order, $supplier_id) -{ - $sql = "SELECT curr_code, supp_name, tax_group_id, supp.tax_included, - supp.credit_limit - Sum(IFNULL(ov_amount + ov_gst + ov_discount,0)) as cur_credit, - terms.terms, terms.days_before_due, terms.day_in_following_month - FROM ".TB_PREF."suppliers supp - LEFT JOIN ".TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id - LEFT JOIN ".TB_PREF."payment_terms terms ON supp.payment_terms=terms.terms_indicator - WHERE supp.supplier_id = ".db_escape($supplier_id)." - GROUP BY - supp.supp_name"; - - $result = db_query($sql, "The supplier details could not be retreived"); - - $myrow = db_fetch($result); - $order->credit = $myrow["cur_credit"]; - $order->terms = array( - 'description' => $myrow['terms'], - 'days_before_due' => $myrow['days_before_due'], - 'day_in_following_month' => $myrow['day_in_following_month'] ); - - $_POST['supplier_id'] = $supplier_id; - $_POST['supplier_name'] = $myrow["supp_name"]; - $_POST['curr_code'] = $myrow["curr_code"]; - - $order->set_supplier($supplier_id, $myrow["supp_name"], $myrow["curr_code"], - $myrow["tax_group_id"], $myrow["tax_included"]); -} //--------------------------------------------------------------------------------------------------- @@ -137,6 +116,7 @@ function display_po_header(&$order) get_supplier_details_to_order($order, $_POST['supplier_id']); get_duedate_from_terms($order); $_POST['due_date'] = $order->due_date; + $_POST['tax_algorithm'] = $order->tax_algorithm; // supplier default price update foreach ($order->line_items as $line_no=>$item) { @@ -148,6 +128,7 @@ function display_po_header(&$order) } $Ajax->activate('items_table'); $Ajax->activate('due_date'); + $Ajax->activate('tax_algorithm'); } set_global_supplier($_POST['supplier_id']); @@ -166,7 +147,7 @@ function display_po_header(&$order) if (!is_company_currency($order->curr_code)) { label_row(_("Supplier Currency:"), $order->curr_code); - exchange_rate_display($order->curr_code, get_company_currency(), + exchange_rate_display(get_company_currency(), $order->curr_code, $_POST['OrderDate']); } @@ -197,13 +178,9 @@ function display_po_header(&$order) { /*If this is the first time the form loaded set up defaults */ - //$_POST['StkLocation'] = $_SESSION['UserStockLocation']; - $sql = "SELECT delivery_address, phone FROM ".TB_PREF."locations WHERE loc_code=".db_escape($_POST['StkLocation']); - $result = db_query($sql,"could not get location info"); - - if (db_num_rows($result) == 1) + $loc_row = get_item_location(get_post('StkLocation')); + if ($loc_row) { - $loc_row = db_fetch($result); $_POST['delivery_address'] = $loc_row["delivery_address"]; $Ajax->activate('delivery_address'); $_SESSION['PO']->Location = $_POST['StkLocation']; @@ -345,6 +322,14 @@ function display_po_summary(&$po, $is_self=false, $editable=false) label_row(_("Delivery Address"), $po->delivery_address, "class='tableheader2'", "colspan=9"); + if (!$editable && ($po->prep_amount > 0)) + { + start_row(); + label_cells(_("Required Pre-Payment"), price_format($po->prep_amount), "class='tableheader2'"); + label_cells(_("Pre-Payments Allocated"), price_format($po->alloc), "class='tableheader2'"); + end_row(); + } + if ($po->Comments != "") label_row(_("Order Comments"), $po->Comments, "class='tableheader2'", "colspan=9"); @@ -412,7 +397,7 @@ function po_item_controls(&$order, &$rowcounter, $line_no=-1) //$_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id'])); $_POST['price'] = price_decimal_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']), $dec2); if ($order->trans_type == ST_PURCHORDER) - $_POST['req_del_date'] = add_days(Today(), $SysPrefs->default_delivery_required_by()); + $_POST['req_del_date'] = add_days(Today(), $SysPrefs->default_receival_required_by()); $qty_rcvd = ''; } @@ -454,6 +439,28 @@ function po_item_controls(&$order, &$rowcounter, $line_no=-1) //--------------------------------------------------------------------------------------------------- +function display_po_footer(&$trans) +{ + global $Ajax; + +start_table(TABLESTYLE2); + +if (list_updated('tax_algorithm')) { + $trans->tax_algorithm = $_POST['tax_algorithm']; + $Ajax->activate('items_table'); +} + +if ($trans->trans_type == ST_SUPPINVOICE) { + tax_algorithm_list_row(_("Tax algorithm:"), 'tax_algorithm', null, true); + cash_accounts_list_row(_("Payment:"), 'cash_account', null, false, _('Delayed')); +} elseif ($trans->trans_type == ST_PURCHORDER) + amount_row(_("Pre-Payment Required:"), 'prep_amount'); + +textarea_row(_("Memo:"), 'Comments', null, 70, 4); + +end_table(); +} +//--------------------------------------------------------------------------------------------------- + -?> \ No newline at end of file