3 function db_has_customers()
5 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."debtors_master");
8 function check_db_has_customers($msg)
11 if (!db_has_customers())
13 display_error($msg, true);
19 function db_has_currencies()
21 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."currencies");
24 function check_db_has_currencies($msg)
27 if (!db_has_currencies())
29 display_error($msg, true);
35 function db_has_sales_types()
37 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."sales_types");
40 function check_db_has_sales_types($msg)
43 if (!db_has_sales_types())
45 display_error($msg, true);
51 function db_has_item_tax_types()
53 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."item_tax_types");
56 function check_db_has_item_tax_types($msg)
59 if (!db_has_item_tax_types())
61 display_error($msg, true);
67 function db_has_tax_types()
69 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tax_types");
72 function check_db_has_tax_types($msg)
75 if (!db_has_tax_types())
77 display_error($msg, true);
83 function db_has_tax_groups()
85 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tax_groups");
88 function check_db_has_tax_groups($msg)
91 if (!db_has_tax_groups())
93 display_error($msg, true);
99 function db_has_movement_types()
101 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."movement_types");
104 function check_db_has_movement_types($msg)
106 global $path_to_root;
107 if (!db_has_movement_types())
109 display_error($msg, true);
115 function db_has_bank_trans_types()
117 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_trans_types");
120 function check_db_has_bank_trans_types($msg)
122 global $path_to_root;
123 if (!db_has_bank_trans_types())
125 display_error($msg, true);
131 function db_customer_has_branches($customer_id)
133 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch WHERE debtor_no=$customer_id");
136 function db_has_customer_branches()
138 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch");
141 function check_db_has_customer_branches($msg)
143 global $path_to_root;
144 if (!db_has_customer_branches())
146 display_error($msg, true);
152 function db_has_sales_people()
154 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."salesman");
157 function check_db_has_sales_people($msg)
159 global $path_to_root;
160 if (!db_has_sales_people())
162 display_error($msg, true);
168 function db_has_sales_areas()
170 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."areas");
173 function check_db_has_sales_areas($msg)
175 global $path_to_root;
176 if (!db_has_sales_areas())
178 display_error($msg, true);
184 function db_has_shippers()
186 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."shippers");
189 function check_db_has_shippers($msg)
191 global $path_to_root;
192 if (!db_has_shippers())
194 display_error($msg, true);
200 function db_has_open_workorders()
202 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workorders WHERE closed=0");
205 function db_has_workorders()
207 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workorders");
210 function check_db_has_workorders($msg)
212 global $path_to_root;
213 if (!db_has_workorders())
215 display_error($msg, true);
221 function db_has_open_dimensions()
223 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."dimensions WHERE closed=0");
226 function db_has_dimensions()
228 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."dimensions");
231 function check_db_has_dimensions($msg)
233 global $path_to_root;
234 if (!db_has_dimensions())
236 display_error($msg, true);
243 function db_has_suppliers()
245 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."suppliers");
248 function check_db_has_suppliers($msg)
250 global $path_to_root;
251 if (!db_has_suppliers())
253 display_error($msg, true);
259 function db_has_stock_items()
261 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master");
264 function check_db_has_stock_items($msg)
266 global $path_to_root;
267 if (!db_has_stock_items())
269 display_error($msg, true);
275 function db_has_bom_stock_items()
277 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag='M' OR mb_flag='K')");
280 function check_db_has_bom_stock_items($msg)
282 global $path_to_root;
283 if (!db_has_bom_stock_items())
285 display_error($msg, true);
291 function db_has_manufacturable_items()
293 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag='M')");
296 function check_db_has_manufacturable_items($msg)
298 global $path_to_root;
299 if (!db_has_manufacturable_items())
301 display_error($msg, true);
307 function db_has_purchasable_items()
309 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='M' AND mb_flag!='K')");
312 function check_db_has_purchasable_items($msg)
314 global $path_to_root;
315 if (!db_has_purchasable_items())
317 display_error($msg, true);
323 function db_has_costable_items()
325 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='D' AND mb_flag!='K')");
328 function check_db_has_costable_items($msg)
330 global $path_to_root;
331 if (!db_has_costable_items())
333 display_error($msg, true);
339 function db_has_stock_categories()
341 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_category");
344 function check_db_has_stock_categories($msg)
346 global $path_to_root;
347 if (!db_has_stock_categories())
349 display_error($msg, true);
355 function db_has_workcentres()
357 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workcentres");
360 function check_db_has_workcentres($msg)
362 global $path_to_root;
363 if (!db_has_workcentres())
365 display_error($msg, true);
371 function db_has_locations()
373 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."locations");
376 function check_db_has_locations($msg)
378 global $path_to_root;
379 if (!db_has_locations())
381 display_error($msg, true);
387 function db_has_bank_accounts()
389 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_accounts");
392 function check_db_has_bank_accounts($msg)
394 global $path_to_root;
395 if (!db_has_bank_accounts())
397 display_error($msg, true);
403 function db_has_gl_accounts()
405 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."chart_master");
408 function db_has_gl_account_groups()
410 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."chart_types");
413 function check_db_has_gl_account_groups($msg)
415 global $path_to_root;
416 if (!db_has_gl_account_groups())
418 display_error($msg, true);
424 function check_empty_result($sql)
426 $result = db_query($sql, "could not do check empty query");
428 $myrow = db_fetch_row($result);
429 return $myrow[0] > 0;