function update_company_gl_setup($retained_act, $profit_loss_act, $debtors_act, $pyt_discount_act, $creditors_act,
$freight_act,
$exchange_diff_act,
+ $bank_charge_act,
$default_sales_act,
$default_sales_discount_act,
$default_prompt_payment_act,
creditors_act=".db_escape($creditors_act).",
freight_act=".db_escape($freight_act).",
exchange_diff_act=".db_escape($exchange_diff_act).",
+ bank_charge_act=".db_escape($bank_charge_act).",
default_sales_act=".db_escape($default_sales_act).",
default_sales_discount_act=".db_escape($default_sales_discount_act).",
default_prompt_payment_act=".db_escape($default_prompt_payment_act).",
function update_company_setup($coy_name, $coy_no, $gst_no, $tax_prd, $tax_last,
$postal_address, $phone, $fax, $email, $coy_logo, $domicile, $Dimension,
$curr_default, $f_year, $no_item_list, $no_customer_list, $no_supplier_list,
- $base_sales, $time_zone)
+ $base_sales, $time_zone, $add_pct, $round_to, $login_tout)
{
if ($f_year == null)
$f_year = 0;
curr_default=".db_escape($curr_default).",
f_year=$f_year,
base_sales=$base_sales,
- time_zone=$time_zone
+ time_zone=$time_zone,
+ add_pct=$add_pct,
+ round_to=$round_to,
+ login_tout = ".db_escape($login_tout)."
WHERE coy_code=1";
db_query($sql, "The company setup could not be updated ");
return $prefs[$pref_name];
}
-// fiscal year routines
-function add_fiscalyear($from_date, $to_date, $closed)
+function get_base_sales_type()
{
- $from = date2sql($from_date);
- $to = date2sql($to_date);
-
- $sql = "INSERT INTO ".TB_PREF."fiscal_year (begin, end, closed)
- VALUES (".db_escape($from).",".db_escape($to).", $closed)";
+ $sql = "SELECT base_sales FROM ".TB_PREF."company WHERE coy_code=1";
- db_query($sql, "could not add fiscal year");
+ $result = db_query($sql, "could not get base sales type");
+ $myrow = db_fetch($result);
+ return $myrow[0];
}
-function update_fiscalyear($id, $closed)
-{
- $sql = "UPDATE ".TB_PREF."fiscal_year SET closed=$closed
- WHERE id=".db_escape($id);
+function get_company_extensions($id = -1) {
+ global $path_to_root;
- db_query($sql, "could not update fiscal year");
+ $file = $path_to_root.($id == -1 ? '' : '/company/'.$id).'/installed_extensions.php';
+ $installed_extensions = array();
+ if (is_file($file)) {
+ include($file);
+ }
+ return $installed_extensions;
}
-function get_all_fiscalyears()
+function add_payment_terms($daysOrFoll, $terms, $dayNumber)
{
- $sql = "SELECT * FROM ".TB_PREF."fiscal_year ORDER BY begin";
-
- return db_query($sql, "could not get all fiscal years");
+ if ($daysOrFoll)
+ {
+ $sql = "INSERT INTO ".TB_PREF."payment_terms (terms,
+ days_before_due, day_in_following_month)
+ VALUES (" .
+ db_escape($terms) . ", " . db_escape($dayNumber) . ", 0)";
+ }
+ else
+ {
+ $sql = "INSERT INTO ".TB_PREF."payment_terms (terms,
+ days_before_due, day_in_following_month)
+ VALUES (" . db_escape($terms) . ",
+ 0, " . db_escape($dayNumber) . ")";
+ }
+ db_query($sql,"The payment term could not be added");
}
-function get_fiscalyear($id)
+function update_payment_terms($selected_id, $daysOrFoll, $terms, $dayNumber)
{
- $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE id=".db_escape($id);
-
- $result = db_query($sql, "could not get fiscal year");
-
- return db_fetch($result);
+ if ($daysOrFoll)
+ {
+ $sql = "UPDATE ".TB_PREF."payment_terms SET terms=" . db_escape($terms) . ",
+ day_in_following_month=0,
+ days_before_due=" . db_escape($dayNumber) . "
+ WHERE terms_indicator = " .db_escape($selected_id);
+ }
+ else
+ {
+ $sql = "UPDATE ".TB_PREF."payment_terms SET terms=" . db_escape($terms) . ",
+ day_in_following_month=" . db_escape($dayNumber) . ",
+ days_before_due=0
+ WHERE terms_indicator = " .db_escape($selected_id);
+ }
+ db_query($sql,"The payment term could not be updated");
}
-function get_current_fiscalyear()
+function delete_payment_terms($selected_id)
{
- $year = get_company_pref('f_year');
-
- $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE id=$year";
+ $sql="DELETE FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($selected_id);
+ db_query($sql,"could not delete a payment terms");
+}
- $result = db_query($sql, "could not get current fiscal year");
+function get_payment_terms($selected_id)
+{
+ $sql = "SELECT * FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($selected_id);
+ $result = db_query($sql,"could not get payment term");
return db_fetch($result);
}
-function delete_fiscalyear($id)
+function get_payment_terms_all($show_inactive)
{
- begin_transaction();
-
- $sql="DELETE FROM ".TB_PREF."fiscal_year WHERE id=".db_escape($id);
-
- db_query($sql, "could not delete fiscal year");
-
- commit_transaction();
+ $sql = "SELECT * FROM ".TB_PREF."payment_terms";
+ if (!$show_inactive) $sql .= " WHERE !inactive";
+ return db_query($sql,"could not get payment terms");
}
-function get_base_sales_type()
+function key_in_foreign_table($id, $table, $key, $escaped=false)
{
- $sql = "SELECT base_sales FROM ".TB_PREF."company WHERE coy_code=1";
-
- $result = db_query($sql, "could not get base sales type");
- $myrow = db_fetch($result);
- return $myrow[0];
+ if (!$escaped)
+ $id = db_escape($id);
+ $sql= "SELECT COUNT(*) FROM ".TB_PREF."$table WHERE $key = $id";
+ $result = db_query($sql,"check $table relations failed");
+ $myrow = db_fetch_row($result);
+ return ($myrow[0] > 0);
}
-
?>
\ No newline at end of file