*** empty log message ***
[fa-stable.git] / includes / systypes.inc
1 <?php
2
3 Function get_next_trans_no ($trans_type){
4
5     // sql to get the next display transaction number
6         //these are maintained in the table sys_types
7     // Also updates the transaction number
8
9     $sql = "SELECT type_no FROM ".TB_PREF."sys_types WHERE type_id = " . $trans_type;
10
11     $result = db_query($sql,"The next transaction number for $trans_type could not be retrieved");
12
13     $myrow = db_fetch_row($result);
14
15     $next_number = $myrow[0] + 1;
16
17     $sql = "UPDATE ".TB_PREF."sys_types SET type_no = $next_number WHERE type_id = $trans_type";
18
19     db_query($sql,"The next transaction number for $trans_type could not be updated");
20
21     return $next_number;
22 }
23
24 //-----------------------------------------------------------------------------
25
26 function get_systype_db_info($type)
27 {
28         switch ($type)
29         {
30         case      0 : return array("".TB_PREF."gl_trans", "type", "type_no", null, "tran_date");
31         case      1 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date");
32         case      2 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date");
33         case      3 : return null;
34         case      4 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date");
35         case     10 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date");
36         case     11 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date");
37         case     12 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date");
38         case     16 : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date");
39         case     17 : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date");
40         case     18 : return array("".TB_PREF."purch_orders", null, "order_no", "reference", "tran_date");
41         case     20 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date");
42         case     21 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date");
43         case     22 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date");
44         case     25 : return array("".TB_PREF."grn_batch", null, "id", "reference", "delivery_date");
45         case     26 : return array("".TB_PREF."workorders", null, "id", "wo_ref", "released_date");
46         case     28 : return array("".TB_PREF."wo_issues", null, "issue_no", "reference", "issue_date");
47         case     29 : return array("".TB_PREF."wo_manufacture", null, "id", "reference", "date_");
48         case     30 : return array("".TB_PREF."sales_orders", null, "order_no", "customer_ref", "ord_date");
49         case     40 : return array("".TB_PREF."dimensions", null, "id", "reference", "date_");
50         case     35 : return null;
51         }
52
53         display_db_error("invalid type ($type) sent to get_systype_db_info", "", true);
54 }
55
56 function get_systypes()
57 {
58         $sql = "SELECT * FROM ".TB_PREF."sys_types";
59         $result = db_query($sql, "could not query systypes table");
60         return $result;
61 }
62
63 ?>