-/* FIX // restore/init audit_trail data
- $datatbl = array (
- "gl_trans"=> array("type", "type_no","tran_date"),
- "purch_orders" => array("order_no", "'18'", "ord_date"),
- "sales_orders" => array("order_no", "'30'", "ord_date"),
- "workorders" => array("id", "'26'", "date_") );
- foreach ( $datatbl as $tblname => $tbl) {
- $sql = "SELECT {$tbl[0]} as type, {$tbl[1]} as trans, {$tbl[2]} as dat"
- . " FROM {$pref}{$tblname}";
- $result = db_query($sql);
- if (db_num_rows($result)) {
- $user = ;
- $year = ;
- while ($row = db_fetch($result)) {
- $sql2 = "INSERT INTO ".$pref."audit_trail"
- ." (type, trans_no, user, fiscal_year, gl_date, gl_seq) VALUES ("
- . "{$row['type']},{$row['trans']},$user,$year,{$row['dat']},0)";
- $res2 = db_query($sql2);
- if (!$res2) {
- display_error(_("Cannot init audit_trail data")
- .':<br>'. db_error_msg($db));
- return false;
- }
- }
- }
- }
-*/
-
- if (!($ret = db_query("SELECT MAX(`order_no`) FROM `{$pref}sales_orders`")) ||
- !db_num_rows($ret))
- {
- display_error(_('Cannot query max sales order number.'));
- return false;
- }
- $row = db_fetch($ret);
- $max_order = $row[0];
- $next_ref = $max_order+1;
- $sql = "UPDATE `{$pref}sys_types`
- SET `type_no`='$max_order',
- `next_reference`='$next_ref'
- WHERE `type_id`=30";
- if(!db_query($sql))
- {
- display_error(_('Cannot store next sales order reference.'));
- return false;
- }