+ if (!$this->beta) {
+ $n += 3;
+ if (!check_table($pref, 'comments', 'type', array('Key'=>'MUL'))) $patchcnt++;
+ if (!check_table($pref, 'sys_prefs')) $patchcnt++;
+ if (!check_table($pref, 'sales_orders', 'payment_terms')) $patchcnt++;
+ }
+ if (!check_table($pref, 'purch_orders', 'tax_included')) $patchcnt++;
+ return $n == $patchcnt ? true : ($patchcnt ? ($patchcnt.'/'. $n) : 0);
+ }
+ //=========================================================================================
+ // 2.3 specific update functions
+ //
+
+ /*
+ Update order totals
+ */
+ function update_totals($pref)
+ {
+ global $path_to_root;
+
+ include_once("$path_to_root/sales/includes/cart_class.inc");
+ include_once("$path_to_root/purchasing/includes/po_class.inc");
+ $cart = new cart(ST_SALESORDER);
+ $sql = "SELECT order_no, trans_type FROM {$pref}sales_orders";
+ $orders = db_query($sql);
+ if (!$orders)
+ return false;
+ while ($order = db_fetch($orders)) {
+ read_sales_order($order['order_no'], $cart, $order['trans_type']);
+ $result = db_query("UPDATE {$pref}sales_orders
+ SET total=".$cart->get_trans_total()
+ ." WHERE order_no=".$order[0]);
+ unset($cart->line_items);
+ }
+ unset($cart);
+ $cart = new purch_order();
+ $sql = "SELECT order_no FROM {$pref}purch_orders";
+ $orders = db_query($sql);
+ if (!$orders)
+ return false;
+ while ($order_no = db_fetch($orders)) {
+ read_po($order_no[0], $cart);
+ $result = db_query("UPDATE {$pref}purch_orders SET total=".$cart->get_trans_total());
+ unset($cart->line_items);
+ }
+ return true;
+ }
+
+ //------------------------------------------------------------------------------
+ // Retreive parent document number(s) for given transaction
+ //
+ function get_parent_trans_2_2($trans_type, $trans_no) {
+
+ $sql = 'SELECT trans_link FROM
+ '.TB_PREF.'debtor_trans WHERE trans_no='.db_escape($trans_no)
+ .' AND type='.db_escape($trans_type).' AND trans_link!=0';
+
+ $result = db_query($sql, 'Parent document numbers cannot be retrieved');
+
+ if (db_num_rows($result)) {
+ $link = db_fetch($result);
+ return array($link['trans_link']);
+ }
+ if ($trans_type!=ST_SALESINVOICE) return 0; // this is credit note with no parent invoice
+ // invoice: find batch invoice parent trans.
+ $sql = 'SELECT trans_no FROM
+ '.TB_PREF.'debtor_trans WHERE
+ (trans_link='.db_escape($trans_no).' AND type='. get_parent_type($trans_type) .')';
+
+ $result = db_query($sql, 'Delivery links cannot be retrieved');