Changed license type to GPLv3 in top of files
[fa-stable.git] / sales / includes / db / branches_db.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_branch($branch_id)
13 {
14         $sql = "SELECT ".TB_PREF."cust_branch.*,".TB_PREF."salesman.salesman_name 
15                 FROM ".TB_PREF."cust_branch, ".TB_PREF."salesman 
16                 WHERE ".TB_PREF."cust_branch.salesman=".TB_PREF."salesman.salesman_code 
17                 AND branch_code=$branch_id";
18         
19         $result = db_query($sql, "Cannot retreive a customer branch");
20         
21         return db_fetch($result);       
22 }
23
24 function get_branch_accounts($branch_id)
25 {
26         $sql = "SELECT receivables_account,sales_account, sales_discount_account, payment_discount_account 
27                 FROM ".TB_PREF."cust_branch WHERE branch_code=$branch_id";
28         
29         $result = db_query($sql, "Cannot retreive a customer branch");
30         
31         return db_fetch($result);       
32 }
33
34 function get_branch_name($branch_id)
35 {
36         $sql = "SELECT br_name FROM ".TB_PREF."cust_branch 
37                 WHERE branch_code = '$branch_id'";
38
39         $result = db_query($sql,"could not retreive name for branch" . $branch_id);
40
41         $myrow = db_fetch_row($result); 
42         return $myrow[0];
43 }
44
45 function get_cust_branches_from_group($group_no)
46 {
47         $sql = "SELECT branch_code, debtor_no FROM ".TB_PREF."cust_branch 
48                 WHERE group_no = '$group_no'";
49
50         return db_query($sql,"could not retreive branches for group " . $group_no);
51 }
52 ?>