2 function db_has_customers()
4 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."debtors_master");
7 function check_db_has_customers($msg)
10 if (!db_has_customers())
12 display_error($msg, true);
18 function db_has_currencies()
20 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."currencies");
23 function check_db_has_currencies($msg)
26 if (!db_has_currencies())
28 display_error($msg, true);
34 function db_has_sales_types()
36 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."sales_types");
39 function check_db_has_sales_types($msg)
42 if (!db_has_sales_types())
44 display_error($msg, true);
50 function db_has_item_tax_types()
52 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."item_tax_types");
55 function check_db_has_item_tax_types($msg)
58 if (!db_has_item_tax_types())
60 display_error($msg, true);
66 function db_has_tax_types()
68 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tax_types");
71 function check_db_has_tax_types($msg)
74 if (!db_has_tax_types())
76 display_error($msg, true);
82 function db_has_tax_groups()
84 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tax_groups");
87 function check_db_has_tax_groups($msg)
90 if (!db_has_tax_groups())
92 display_error($msg, true);
98 function db_has_movement_types()
100 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."movement_types");
103 function check_db_has_movement_types($msg)
105 global $path_to_root;
106 if (!db_has_movement_types())
108 display_error($msg, true);
114 function db_has_bank_trans_types()
116 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_trans_types");
119 function check_db_has_bank_trans_types($msg)
121 global $path_to_root;
122 if (!db_has_bank_trans_types())
124 display_error($msg, true);
130 function db_customer_has_branches($customer_id)
132 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch WHERE debtor_no='$customer_id'");
135 function db_has_customer_branches()
137 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch");
140 function check_db_has_customer_branches($msg)
142 global $path_to_root;
143 if (!db_has_customer_branches())
145 display_error($msg, true);
151 function db_has_sales_people()
153 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."salesman");
156 function check_db_has_sales_people($msg)
158 global $path_to_root;
159 if (!db_has_sales_people())
161 display_error($msg, true);
167 function db_has_sales_areas()
169 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."areas");
172 function check_db_has_sales_areas($msg)
174 global $path_to_root;
175 if (!db_has_sales_areas())
177 display_error($msg, true);
183 function db_has_shippers()
185 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."shippers");
188 function check_db_has_shippers($msg)
190 global $path_to_root;
191 if (!db_has_shippers())
193 display_error($msg, true);
199 function db_has_open_workorders()
201 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workorders WHERE closed=0");
204 function db_has_workorders()
206 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workorders");
209 function check_db_has_workorders($msg)
211 global $path_to_root;
212 if (!db_has_workorders())
214 display_error($msg, true);
220 function db_has_open_dimensions()
222 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."dimensions WHERE closed=0");
225 function db_has_dimensions()
227 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."dimensions");
230 function check_db_has_dimensions($msg)
232 global $path_to_root;
233 if (!db_has_dimensions())
235 display_error($msg, true);
242 function db_has_suppliers()
244 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."suppliers");
247 function check_db_has_suppliers($msg)
249 global $path_to_root;
250 if (!db_has_suppliers())
252 display_error($msg, true);
258 function db_has_stock_items()
260 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master");
263 function check_db_has_stock_items($msg)
265 global $path_to_root;
266 if (!db_has_stock_items())
268 display_error($msg, true);
274 function db_has_bom_stock_items()
276 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag='M' OR mb_flag='K')");
279 function check_db_has_bom_stock_items($msg)
281 global $path_to_root;
282 if (!db_has_bom_stock_items())
284 display_error($msg, true);
290 function db_has_manufacturable_items()
292 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag='M')");
295 function check_db_has_manufacturable_items($msg)
297 global $path_to_root;
298 if (!db_has_manufacturable_items())
300 display_error($msg, true);
306 function db_has_purchasable_items()
308 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='M' AND mb_flag!='K')");
311 function check_db_has_purchasable_items($msg)
313 global $path_to_root;
314 if (!db_has_purchasable_items())
316 display_error($msg, true);
322 function db_has_costable_items()
324 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='D' AND mb_flag!='K')");
327 function check_db_has_costable_items($msg)
329 global $path_to_root;
330 if (!db_has_costable_items())
332 display_error($msg, true);
338 function db_has_stock_categories()
340 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_category");
343 function check_db_has_stock_categories($msg)
345 global $path_to_root;
346 if (!db_has_stock_categories())
348 display_error($msg, true);
354 function db_has_workcentres()
356 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workcentres");
359 function check_db_has_workcentres($msg)
361 global $path_to_root;
362 if (!db_has_workcentres())
364 display_error($msg, true);
370 function db_has_locations()
372 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."locations");
375 function check_db_has_locations($msg)
377 global $path_to_root;
378 if (!db_has_locations())
380 display_error($msg, true);
386 function db_has_bank_accounts()
388 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_accounts");
391 function check_db_has_bank_accounts($msg)
393 global $path_to_root;
394 if (!db_has_bank_accounts())
396 display_error($msg, true);
402 function db_has_gl_accounts()
404 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."chart_master");
407 function db_has_gl_account_groups()
409 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."chart_types");
412 function check_db_has_gl_account_groups($msg)
414 global $path_to_root;
415 if (!db_has_gl_account_groups())
417 display_error($msg, true);
423 function db_has_quick_entries()
425 return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."quick_entries");
428 function check_empty_result($sql)
430 $result = db_query($sql, "could not do check empty query");
432 $myrow = db_fetch_row($result);
433 return $myrow[0] > 0;
436 // Integer input check
437 // Return 1 if number has proper form and is within <min, max> range
439 function check_int($postname, $min=null, $max=null) {
440 if(!isset($_POST[$postname]))
442 $num = input_num($postname);
445 if (isset($min) && ($num<$min))
447 if (isset($max) && ($num>$max))
452 // Numeric input check.
453 // Return 1 if number has proper form and is within <min, max> range
455 function check_num($postname, $min=null, $max=null) {
456 if(!isset($_POST[$postname]))
458 $num = input_num($postname);
461 if (isset($min) && ($num<$min))
463 if (isset($max) && ($num>$max))