4 function update_company_gl_setup($debtors_act, $pyt_discount_act, $creditors_act,
7 $default_sales_discount_act,
8 $default_prompt_payment_act,
9 $default_inventory_act,
12 $default_inv_sales_act,
13 $default_assembly_act,
14 $allow_negative_stock,
18 $default_credit_limit,
19 $default_workorder_required,
20 $default_dim_required)
22 $sql = "UPDATE ".TB_PREF."company SET
23 debtors_act=".db_escape($debtors_act).", pyt_discount_act=".db_escape($pyt_discount_act).",
24 creditors_act=".db_escape($creditors_act).",
25 freight_act=".db_escape($freight_act).",
26 default_sales_act=".db_escape($default_sales_act).",
27 default_sales_discount_act=".db_escape($default_sales_discount_act).",
28 default_prompt_payment_act=".db_escape($default_prompt_payment_act).",
29 default_inventory_act=".db_escape($default_inventory_act).",
30 default_cogs_act=".db_escape($default_cogs_act).",
31 default_adj_act=".db_escape($default_adj_act).",
32 default_inv_sales_act=".db_escape($default_inv_sales_act).",
33 default_assembly_act=".db_escape($default_assembly_act).",
34 allow_negative_stock=$allow_negative_stock,
35 po_over_receive=$po_over_receive,
36 po_over_charge=$po_over_charge,
37 past_due_days=$past_due_days,
38 default_credit_limit=$default_credit_limit,
39 default_workorder_required=$default_workorder_required,
40 default_dim_required=$default_dim_required
43 db_query($sql, "The company gl setup could not be updated ");
46 function update_company_setup($coy_name, $coy_no, $gst_no, $tax_prd, $tax_last, $postal_address, $phone, $fax, $email,
47 $coy_logo, $domicile, $Dimension, $custom1_name, $custom2_name, $custom3_name,
48 $custom1_value, $custom2_value, $custom3_value, $curr_default, $f_year, $no_item_list, $no_customer_list,
49 $no_supplier_list, $base_sales)
53 $sql = "UPDATE ".TB_PREF."company SET coy_name=".db_escape($coy_name).",
54 coy_no = ".db_escape($coy_no).",
55 gst_no=".db_escape($gst_no).",
58 postal_address =".db_escape($postal_address).",
59 phone=".db_escape($phone).", fax=".db_escape($fax).",
60 email=".db_escape($email).",
61 coy_logo=".db_escape($coy_logo).",
62 domicile=".db_escape($domicile).",
63 use_dimension=$Dimension,
64 no_item_list=$no_item_list,
65 no_customer_list=$no_customer_list,
66 no_supplier_list=$no_supplier_list,
67 custom1_name=".db_escape($custom1_name).",
68 custom2_name=".db_escape($custom2_name).",
69 custom3_name=".db_escape($custom3_name).",
70 custom1_value=".db_escape($custom1_value).",
71 custom2_value=".db_escape($custom2_value).",
72 custom3_value=".db_escape($custom3_value).",
73 curr_default=".db_escape($curr_default).",
75 base_sales=$base_sales
78 db_query($sql, "The company setup could not be updated ");
81 function get_company_prefs()
83 $sql = "SELECT * FROM ".TB_PREF."company WHERE coy_code=1";
84 $result = db_query($sql, "The company preferences could not be retrieved");
86 if (db_num_rows($result) == 0)
87 display_db_error("FATAL : Could not find company prefs", $sql);
89 return db_fetch($result);
92 function get_company_pref($pref_name)
94 $prefs = get_company_prefs();
95 return $prefs[$pref_name];
98 // fiscal year routines
99 function add_fiscalyear($from_date, $to_date, $closed)
101 $from = date2sql($from_date);
102 $to = date2sql($to_date);
104 $sql = "INSERT INTO ".TB_PREF."fiscal_year (begin, end, closed)
105 VALUES (".db_escape($from).",".db_escape($to).", $closed)";
107 db_query($sql, "could not add fiscal year");
110 function update_fiscalyear($id, $closed)
112 $sql = "UPDATE ".TB_PREF."fiscal_year SET closed=$closed
113 WHERE id=".db_escape($id);
115 db_query($sql, "could not update fiscal year");
118 function get_all_fiscalyears()
120 $sql = "SELECT * FROM ".TB_PREF."fiscal_year ORDER BY begin";
122 return db_query($sql, "could not get all fiscal years");
125 function get_fiscalyear($id)
127 $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE id=".db_escape($id);
129 $result = db_query($sql, "could not get fiscal year");
131 return db_fetch($result);
134 function get_current_fiscalyear()
136 $year = get_company_pref('f_year');
138 $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE id=$year";
140 $result = db_query($sql, "could not get current fiscal year");
142 return db_fetch($result);
145 function delete_fiscalyear($id)
149 $sql="DELETE FROM ".TB_PREF."fiscal_year WHERE id=".db_escape($id);
151 db_query($sql, "could not delete fiscal year");
153 commit_transaction();
156 function get_base_sales_type()
158 $sql = "SELECT base_sales FROM ".TB_PREF."company WHERE coy_code=1";
160 $result = db_query($sql, "could not get base sales type");
161 $myrow = db_fetch($result);