X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fdb%2Fpo_db.inc;h=41ed94f09872aa42921849ad7126c6ab85f339e3;hb=40ee20a833a502a0914202b56473fb330d5774cf;hp=a9cb932718ad7eacf7f3aa02decf55a49d3a6906;hpb=84e2f869630484bd9380e5c30647a483bce14d1e;p=fa-stable.git diff --git a/purchasing/includes/db/po_db.inc b/purchasing/includes/db/po_db.inc index a9cb9327..41ed94f0 100644 --- a/purchasing/includes/db/po_db.inc +++ b/purchasing/includes/db/po_db.inc @@ -29,14 +29,15 @@ function add_po(&$po_obj) begin_transaction(); /*Insert to purchase order header record */ - $sql = "INSERT INTO ".TB_PREF."purch_orders (supplier_id, Comments, ord_date, reference, requisition_no, into_stock_location, delivery_address) VALUES("; + $sql = "INSERT INTO ".TB_PREF."purch_orders (supplier_id, Comments, ord_date, reference, requisition_no, into_stock_location, delivery_address, total) VALUES("; $sql .= db_escape($po_obj->supplier_id) . "," . db_escape($po_obj->Comments) . ",'" . date2sql($po_obj->orig_order_date) . "', " . db_escape($po_obj->reference) . ", " . db_escape($po_obj->supp_ref) . ", " . db_escape($po_obj->Location) . ", " . - db_escape($po_obj->delivery_address) . ")"; + db_escape($po_obj->delivery_address) . ", " . + db_escape($po_obj->get_trans_total()) . ")"; db_query($sql, "The purchase order header record could not be inserted"); @@ -77,7 +78,8 @@ function update_po(&$po_obj) requisition_no= ". db_escape( $po_obj->supp_ref). ", into_stock_location=" . db_escape($po_obj->Location). ", ord_date='" . date2sql($po_obj->orig_order_date) . "', - delivery_address=" . db_escape($po_obj->delivery_address); + delivery_address=" . db_escape($po_obj->delivery_address).", + total=". db_escape($po_obj->get_trans_total()); $sql .= " WHERE order_no = " . $po_obj->order_no; db_query($sql, "The purchase order could not be updated"); @@ -103,7 +105,7 @@ function update_po(&$po_obj) // add_comments(ST_PURCHORDER, $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments); - add_audit_trail($po_obj->trans_type, $po_obj->order_no, $po_obj->document_date, _("Updated.")); + add_audit_trail($po_obj->trans_type, $po_obj->order_no, Today(), _("Updated.")); commit_transaction(); return $po_obj->order_no; @@ -113,7 +115,7 @@ function update_po(&$po_obj) function read_po_header($order_no, &$order) { - $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, + $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, ".TB_PREF."suppliers.tax_group_id, ".TB_PREF."suppliers.curr_code, ".TB_PREF."locations.location_name FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations WHERE ".TB_PREF."purch_orders.supplier_id = ".TB_PREF."suppliers.supplier_id @@ -121,7 +123,7 @@ function read_po_header($order_no, &$order) AND ".TB_PREF."purch_orders.order_no = ".db_escape($order_no); $result = db_query($sql, "The order cannot be retrieved"); - +_vd($sql); if (db_num_rows($result) == 1) { @@ -131,6 +133,8 @@ function read_po_header($order_no, &$order) $order->supplier_id = $myrow["supplier_id"]; $order->supplier_name = $myrow["supp_name"]; $order->curr_code = $myrow["curr_code"]; + $order->tax_group_id = $myrow['tax_group_id']; + $order->credit = get_current_supp_credit($order->supplier_id); $order->orig_order_date = sql2date($myrow["ord_date"]); $order->Comments = $myrow["comments"]; @@ -186,12 +190,15 @@ function read_po_items($order_no, &$order, $open_items_only=false) $units = $myrow["units"]; } - if ($order->add_to_order($order->lines_on_order+1, $myrow["item_code"], + if ($order->add_to_order($order->lines_on_order, $myrow["item_code"], $myrow["quantity_ordered"],$myrow["description"], $myrow["unit_price"],$units, sql2date($myrow["delivery_date"]), $myrow["qty_invoiced"], $myrow["quantity_received"])) { - $order->line_items[$order->lines_on_order]->po_detail_rec = $myrow["po_detail_item"]; - $order->line_items[$order->lines_on_order]->standard_cost = $myrow["std_cost_unit"]; /*Needed for receiving goods and GL interface */ + $newline = &$order->line_items[$order->lines_on_order-1]; + $newline->po_detail_rec = $myrow["po_detail_item"]; + $newline->standard_cost = $myrow["std_cost_unit"]; /*Needed for receiving goods and GL interface */ + // set for later GRN edition +// $newline->receive_qty = $newline->quantity - $newline->qty_dispatched; } } /* line po from purchase order details */ } //end of checks on returned data set