a736f129f2cf31927963a9874a0c168a415e28a0
[fa-stable.git] / includes / systypes.inc
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 Function get_next_trans_no ($trans_type){
13
14     // sql to get the next display transaction number
15         //these are maintained in the table sys_types
16     // Also updates the transaction number
17
18     $sql = "SELECT type_no FROM ".TB_PREF."sys_types WHERE type_id = " . $trans_type;
19
20     $result = db_query($sql,"The next transaction number for $trans_type could not be retrieved");
21
22     $myrow = db_fetch_row($result);
23
24     $next_number = $myrow[0] + 1;
25
26     $sql = "UPDATE ".TB_PREF."sys_types SET type_no = $next_number WHERE type_id = $trans_type
27         AND type_no = ". $myrow[0]; //concurrency paranoic protection
28
29     db_query($sql,"The next transaction number for $trans_type could not be updated");
30
31     return $next_number;
32 }
33
34 //-----------------------------------------------------------------------------
35
36 function get_systype_db_info($type)
37 {
38         switch ($type)
39         {
40         case      0 : return array("".TB_PREF."gl_trans", "type", "type_no", null, "tran_date");
41         case      1 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date");
42         case      2 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date");
43         case      3 : return null;
44         case      4 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date");
45         case     10 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date");
46         case     11 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date");
47         case     12 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date");
48         case     13 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date");
49         case     16 : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date");
50         case     17 : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date");
51         case     18 : return array("".TB_PREF."purch_orders", null, "order_no", "reference", "tran_date");
52         case     20 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date");
53         case     21 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date");
54         case     22 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date");
55         case     25 : return array("".TB_PREF."grn_batch", null, "id", "reference", "delivery_date");
56         case     26 : return array("".TB_PREF."workorders", null, "id", "wo_ref", "released_date");
57         case     28 : return array("".TB_PREF."wo_issues", null, "issue_no", "reference", "issue_date");
58         case     29 : return array("".TB_PREF."wo_manufacture", null, "id", "reference", "date_");
59         case     30 : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date");
60         case     31 : return array("".TB_PREF."service_orders", null, "order_no", "cust_ref", "date");
61         case     32 : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date");
62         case     40 : return array("".TB_PREF."dimensions", null, "id", "reference", "date_");
63         case     35 : return null;
64         }
65
66         display_db_error("invalid type ($type) sent to get_systype_db_info", "", true);
67 }
68
69 function get_systypes()
70 {
71         $sql = "SELECT * FROM ".TB_PREF."sys_types";
72         $result = db_query($sql, "could not query systypes table");
73         return $result;
74 }
75
76 ?>