$_POST['theme'] = clean_file_name($_POST['theme']);
$chg_theme = user_theme() != $_POST['theme'];
$chg_lang = $_SESSION['language']->code != $_POST['language'];
+ $chg_date_format = user_date_format() != $_POST['date_format'];
+ $chg_date_sep = user_date_sep() != $_POST['date_sep'];
set_user_prefs(get_post(
array('prices_dec', 'qty_dec', 'rates_dec', 'percent_dec',
'theme', 'page_size', 'language', 'startup_tab',
'show_gl' => 0, 'show_codes'=> 0, 'show_hints' => 0,
'rep_popup' => 0, 'graphic_links' => 0, 'sticky_doc_date' => 0,
- 'query_size' => 10.0)));
+ 'query_size' => 10.0, 'transaction_days' => 30)));
if ($chg_lang)
$_SESSION['language']->set_language($_POST['language']);
if ($chg_theme && $allow_demo_mode)
$_SESSION["wa_current_user"]->prefs->theme = $_POST['theme'];
-
- if ($chg_theme || $chg_lang)
+ if ($chg_theme || $chg_lang || $chg_date_format || $chg_date_sep)
meta_forward($_SERVER['PHP_SELF']);
check_row(_("Remember last document date:"), 'sticky_doc_date', sticky_doc_date(),
false, _('If set document date is remembered on subsequent documents, otherwise default is current date'));
+text_row_ex(_("Transaction days:"), 'transaction_days', 5, 5, '', user_transaction_days());
+
end_outer_table(1);
submit_center('setprefs', _("Update"), true, '', 'default');
/* $show_voiced_gl_trans = 0, setting this to 1 will show the voided gl trans */
$show_voided_gl_trans = 0;
-
+
/* use old style convert (income and expense in BS, PL) */
$use_oldstyle_convert = 0;
/* suppress tax rates on documents. 0 = no, 1 = yes. */
$suppress_tax_rates = 0;
-
+
+ /* allow reopening closed transactions */
+ $allow_gl_reopen = 0;
+
- $dateformats = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD");
+ $dateformats = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD","MmmDDYYYY", "DDMmmYYYY", "YYYYMmmDD");
$dateseps = array("/", ".", "-", " ");
$thoseps = array(",", ".", " ");
$decseps = array(".", ",");
if (!defined('ICON_EDIT'))
{
- define("ICON_EDIT", "edit.gif");
- define("ICON_DELETE", "delete.gif");
- define("ICON_ADD", "ok.gif");
- define("ICON_UPDATE", "ok.gif");
- define("ICON_OK", "ok.gif");
- define("ICON_CANCEL", "cancel.png");
- define("ICON_GL", "gl.png");
- define("ICON_PRINT", "print.png");
- define("ICON_PDF", "pdf.gif");
- define("ICON_DOC", "invoice.gif");
- define("ICON_CREDIT", "credit.gif");
- define("ICON_RECEIVE", "receive.gif");
- define("ICON_DOWN", "download.gif");
- define("ICON_MONEY", "money.png");
- define("ICON_REMOVE", "remove.png");
- define("ICON_REPORT", "report.png");
- define("ICON_VIEW", "view.gif");
+ define("ICON_EDIT", "edit.gif");
+ define("ICON_DELETE", "delete.gif");
+ define("ICON_ADD", "ok.gif");
+ define("ICON_UPDATE", "ok.gif");
+ define("ICON_OK", "ok.gif");
+ define("ICON_CANCEL", "cancel.png");
+ define("ICON_GL", "gl.png");
+ define("ICON_PRINT", "print.png");
+ define("ICON_PDF", "pdf.gif");
+ define("ICON_DOC", "invoice.gif");
+ define("ICON_CREDIT", "credit.gif");
+ define("ICON_RECEIVE", "receive.gif");
+ define("ICON_DOWN", "download.gif");
+ define("ICON_MONEY", "money.png");
+ define("ICON_REMOVE", "remove.png");
+ define("ICON_REPORT", "report.png");
+ define("ICON_VIEW", "view.gif");
define("ICON_SUBMIT", "ok.gif");
- define("ICON_ESCAPE", "escape.png");
+ define("ICON_ESCAPE", "escape.png");
+ define("ICON_CLOSED", "closed.png");
}
/*
*/
$login_delay = 30;
$login_max_attempts = 10;
+
+ /*
+ Choose Exchange Rate Provider
+ Default is ECB for backwards compatibility
+ */
+ $xr_providers = array("ECB", "YAHOO", "GOOGLE", "BLOOMBERG");
+ $dflt_xr_provider = 0;
+
+ ?>
start_row();
bank_accounts_list_cells(_("Account:"), 'bank_account', null);
-date_cells(_("From:"), 'TransAfterDate', '', null, -30);
+date_cells(_("From:"), 'TransAfterDate', '', null, -$_SESSION["wa_current_user"]->prefs->transaction_days());
date_cells(_("To:"), 'TransToDate');
submit_cells('Show',_("Show"),'','', 'default');
start_table(TABLESTYLE);
$th = array(_("Type"), _("#"), _("Reference"), _("Date"),
- _("Debit"), _("Credit"), _("Balance"), _("Person/Item"), "");
+ _("Debit"), _("Credit"), _("Balance"), _("Person/Item"), _("Memo"), "");
table_header($th);
$bfw = get_balance_before_for_bank_account($_POST['bank_account'], $_POST['TransAfterDate']);
label_cell($trandate);
display_debit_or_credit_cells($myrow["amount"]);
amount_cell($running_total);
- label_cell(payment_person_name($myrow["person_type_id"],$myrow["person_id"]));
+ label_cell(get_counterparty_name($myrow["type"], $myrow["trans_no"]));
+ label_cell(get_comments_string($myrow["type"], $myrow["trans_no"]));
label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"]));
end_row();
if ($myrow["amount"] > 0 )
function login($company, $loginname, $password)
{
- global $security_areas, $security_groups, $security_headings, $path_to_root;
+ global $security_areas, $security_groups, $security_headings, $path_to_root, $dflt_lang;
$this->set_company($company);
$this->logged = false;
- set_global_connection();
+ set_global_connection($company);
+ $lang = &$_SESSION['language'];
+ $lang->set_language($_SESSION['language']->code);
+ db_set_encoding($_SESSION['language']->encoding);
// Use external authentication source if any.
// Keep in mind you need to have user data set for $loginname
if ($Auth_Result)
{
$myrow = get_user_by_login($loginname);
+ if ($myrow['language'] != $dflt_lang)
+ { // refresh language and user data
+ $lang->set_language($myrow['language']);
+ db_set_encoding($_SESSION['language']->encoding);
+ $myrow = get_user_by_login($loginname);
+ }
+
$this->old_db = isset($myrow["full_access"]);
if (! @$myrow["inactive"]) {
if ($this->old_db) {
return !isset($security_groups) && is_array($this->role_set);
}
- function can_access($page_level)
+ function can_access($sec_area)
{
global $security_groups, $security_areas;
if (isset($security_groups)) {
- return $this->company == 0 &&
+ return is_admin_company() &&
in_array(20, $security_groups[$this->access]);
}
- if ($page_level === 'SA_OPEN')
+ if ($sec_area === 'SA_OPEN')
return true;
- if ($page_level === 'SA_DENIED' || $page_level === '')
+ if ($sec_area === 'SA_DENIED' || $sec_area === '')
return false;
- $code = $security_areas[$page_level][0];
+ $code = $security_areas[$sec_area][0];
// only first registered company has site admin privileges
return $code && in_array($code, $this->role_set)
return $this->can_access($page_level);
}
+ function check_application_access($waapp)
+ {
+ if (!$this->hide_inaccessible_menu_items())
+ {
+ return true;
+ }
+
+ foreach ($waapp->modules as $module)
+ {
+ if ($this->check_module_access($module))
+ {
+ return true;
+ }
+ }
+
+ return false;
+
+ }
+
+ function check_module_access($module)
+ {
+
+ if (!$this->hide_inaccessible_menu_items())
+ {
+ return true;
+ }
+
+ if (sizeof($module->lappfunctions) > 0)
+ {
+ foreach ($module->lappfunctions as $appfunction)
+ {
+ if ($appfunction->label != "" && $this->can_access_page($appfunction->access))
+ {
+ return true;
+ }
+ }
+ }
+
+ if (sizeof($module->rappfunctions) > 0)
+ {
+ foreach ($module->rappfunctions as $appfunction)
+ {
+ if ($appfunction->label != "" && $this->can_access_page($appfunction->access))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+
+ }
+
+ function hide_inaccessible_menu_items()
+ {
+ global $hide_inaccessible_menu_items;
+
+ if (!isset($hide_inaccessible_menu_items) || $hide_inaccessible_menu_items == 0)
+ {
+ return false;
+ }
+
+ else
+ {
+ return true;
+ }
+ }
+
function set_db_connection($id = -1)
{
return set_global_connection($id);
return $_SESSION["wa_current_user"]->prefs->start_up_tab();
}
+function user_transaction_days()
+{
+ return $_SESSION["wa_current_user"]->prefs->transaction_days();
+}
+
+
+function user_check_access($sec_area)
+{
+ return $_SESSION["wa_current_user"]->can_access($sec_area);
+}
+
function set_user_prefs($prefs)
{
$_SESSION["wa_current_user"]->update_prefs($prefs);
$dir = opendir($path);
if(!$dir)
return;
+
while(false !== ($fname = readdir($dir))) {
if($fname=='.' || $fname=='..' || $fname=='CVS' || (!$wipe && $fname=='index.php')) continue;
if(is_dir($path.'/'.$fname)) {
. '/'.$comp;
}
+function is_admin_company()
+{
+ return $this->company == 0;
+}
?>
function __date($year, $month, $day)
{
- global $dateseps;
+ global $dateseps, $tmonths;
$how = user_date_format();
$sep = $dateseps[user_date_sep()];
$day = (int)$day;
$month = (int)$month;
- if ($day < 10)
- $day = "0".$day;
- if ($month < 10)
- $month = "0".$month;
+ if ($how < 3)
+ {
+ if ($day < 10)
+ $day = "0".$day;
+ if ($month < 10)
+ $month = "0".$month;
+ }
if ($how == 0)
return $month.$sep.$day.$sep.$year;
elseif ($how == 1)
return $day.$sep.$month.$sep.$year;
- else
+ elseif ($how == 2)
return $year.$sep.$month.$sep.$day;
+ elseif ($how == 3)
+ return $tmonths[$month].$sep.$day.$sep.$year;
+ elseif ($how == 4)
+ return $day.$sep.$tmonths[$month].$sep.$year;
+ else
+ return $year.$sep.$tmonths[$month].$sep.$day;
}
function is_date($date_)
$sep = $dateseps[user_date_sep()];
$date_ = trim($date_);
- $date_ = str_replace($sep, "", $date_);
- if (strlen($date_) == 6)
+ $date = str_replace($sep, "", $date_);
+
+ if ($how > 2)
+ {
+ global $tmonths;
+ $dd = explode($sep, $date_);
+ if ($how == 3)
+ {
+ $day = $dd[1];
+ $month = array_search($dd[0], $tmonths);
+ $year = $dd[2];
+ }
+ elseif ($how == 4)
+ {
+ $day = $dd[0];
+ $month = array_search($dd[1], $tmonths);
+ $year = $dd[2];
+ }
+ else
+ {
+ $day = $dd[2];
+ $month = array_search($dd[1], $tmonths);
+ $year = $dd[0];
+ }
+ if ($year < 1000)
+ return 0;
+ }
+ elseif (strlen($date) == 6)
{
if ($how == 0)
{
- $day = substr($date_,2,2);
- $month = substr($date_,0,2);
- $year = substr($date_,4,2);
+ $day = substr($date,2,2);
+ $month = substr($date,0,2);
+ $year = substr($date,4,2);
}
elseif ($how == 1)
{
- $day = substr($date_,0,2);
- $month = substr($date_,2,2);
- $year = substr($date_,4,2);
+ $day = substr($date,0,2);
+ $month = substr($date,2,2);
+ $year = substr($date,4,2);
}
else
{
- $day = substr($date_,4,2);
- $month = substr($date_,2,2);
- $year = substr($date_,0,2);
+ $day = substr($date,4,2);
+ $month = substr($date,2,2);
+ $year = substr($date,0,2);
}
}
- elseif (strlen($date_) == 8)
+ elseif (strlen($date) == 8)
{
if ($how == 0)
{
- $day = substr($date_,2,2);
- $month = substr($date_,0,2);
- $year = substr($date_,4,4);
+ $day = substr($date,2,2);
+ $month = substr($date,0,2);
+ $year = substr($date,4,4);
}
elseif ($how == 1)
{
- $day = substr($date_,0,2);
- $month = substr($date_,2,2);
- $year = substr($date_,4,4);
+ $day = substr($date,0,2);
+ $month = substr($date,2,2);
+ $year = substr($date,4,4);
}
else
{
- $day = substr($date_,6,2);
- $month = substr($date_,4,2);
- $year = substr($date_,0,4);
+ $day = substr($date,6,2);
+ $month = substr($date,4,2);
+ $year = substr($date,0,4);
}
}
if (!isset($year)|| (int)$year > 9999)
return 0;
}
-
if (is_long((int)$day) && is_long((int)$month) && is_long((int)$year))
{
global $date_system;
global $path_to_root;
include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
- //Chaitanya
- if ($convert)
- $date2 = sql2date($date);
- else
- $date2 = $date;
-
- if ($_SESSION["wa_current_user"]->can_access('SA_MULTIFISCALYEARS')) // allow all open years for this one
- return is_date_in_fiscalyears($date2, false);
-
- $myrow = get_current_fiscalyear();
- if ($myrow['closed'] == 1)
- return 0;
-
- $begin = sql2date($myrow['begin']);
- $end = sql2date($myrow['end']);
- if (date1_greater_date2($begin, $date2) || date1_greater_date2($date2, $end))
- {
- return 0;
- }
- return 1;
+ if ($convert)
+ $date2 = sql2date($date);
+ else
+ $date2 = $date;
+
+ if (user_check_access('SA_MULTIFISCALYEARS')) // allow all open years for this one
+ return is_date_in_fiscalyears($date2, false);
+
+ if (is_date_closed($date2))
+ return 0;
+ $myrow = get_current_fiscalyear();
+ $begin = sql2date($myrow['begin']);
+ $end = sql2date($myrow['end']);
+ if (date1_greater_date2($begin, $date2) || date1_greater_date2($date2, $end))
+ {
+ return 0;
+ }
+ return 1;
+}
+
+function is_date_closed($date)
+{
+ return !date1_greater_date2($date, sql2date(get_company_pref('gl_closing_date')));
}
function begin_fiscalyear()
list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
return __date($year, $month, $day);
}
- return date(user_date_display(), $timet);
+ list($year, $month, $day) = explode("-", date("Y-m-d", $timet));
+ return __date($year, $month, $day);
}
function add_months($date, $months) // accepts negative values as well
list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
return __date($year, $month, $day);
}
- return date(user_date_display(), $timet);
+ list($year, $month, $day) = explode("-", date("Y-m-d", $timet));
+ return __date($year, $month, $day);
}
function add_years($date, $years) // accepts negative values as well
list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
return __date($year, $month, $day);
}
- return date(user_date_display(), $timet);
+ list($year, $month, $day) = explode("-", date("Y-m-d", $timet));
+ return __date($year, $month, $day);
}
//_______________________________________________________________
function date2sql($date_)
{
- global $dateseps, $date_system;
+ global $dateseps, $date_system, $tmonths;
/* takes a date in a the format specified in $DefaultDateFormat
and converts to a yyyy/mm/dd format */
$date_ = trim($date_);
$year = $month = $day = 0;
// Split up the date by the separator based on "how" to split it
- if ($how == 0) // MMDDYYYY
+ if ($how == 0 || $how == 3) // MMDDYYYY or MmmDDYYYY
list($month, $day, $year) = explode($sep, $date_);
- elseif ($how == 1) // DDMMYYYY
+ elseif ($how == 1 || $how == 4) // DDMMYYYY or DDMmYYYY
list($day, $month, $year) = explode($sep, $date_);
- else // $how == 2, YYYYMMDD
+ else // $how == 2 || $how == 5, YYYYMMDD or YYYYMmmDD
list($year, $month, $day) = explode($sep, $date_);
-
+ if ($how > 2)
+ {
+ global $tmonths;
+ $month = array_search($month, $tmonths);
+ }
//to modify assumption in 2030
if ($date_system == 0 || $date_system == 3)
{
$negative_trans_id = $myrow['trans_id'];
}
if ($qty >= 0)
- $flag = 0;
+ $flag = 0;
}
-
+
if ($flag == 1)
return $negative_trans_id;
else
." AND trans_id ='$from'";
$result = db_query($sql, "The deliveries could not be updated");
$cost = db_fetch_row($result);
-
+
// Adjusting QOH valuation
$sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves
WHERE stock_id=".db_escape($stock_id)." AND
trans_id<'$from' GROUP BY stock_id";
$result = db_query($sql, "The deliveries could not be updated");
$qoh = db_fetch_row($result);
-
+
$qty = $row[0] - $qoh[0]; //QOH prior to -ve stock is subtracted
$final_cost = $row[1] - $qoh[0]*$cost[0];
$new_purchase_cost = $row[0] * $material_cost;
$purchase_diff = $new_purchase_cost - $old_purchase_cost;
}
-
+
$diff = $sales_diff - $purchase_diff;
if ($diff != 0)
function void_stock_move($type, $type_no)
{
- $sql = "SELECT stock_id, standard_cost, loc_code, tran_date, reference, person_id, visible, discount_percent, price,
- sum(qty) qty FROM ".TB_PREF."stock_moves WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no)."
- GROUP BY stock_id, standard_cost, loc_code, tran_date, reference, person_id, visible, discount_percent, price HAVING sum(qty) <> 0";
+ $sql = "SELECT * from ".TB_PREF."stock_moves WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no);
+
$result = db_query($sql, "Could not void stock moves");
while ($row = db_fetch($result))
{
$trans_rate, -$row["qty"], sql2date($row["tran_date"]));
}
- //Post stock move for service items also
- add_stock_move($type, $row["stock_id"], $type_no, $row["loc_code"],
- sql2date($row["tran_date"]), $row["reference"], -$row["qty"]
- , $row["standard_cost"], $row["person_id"], $row["visible"],
- $row["price"], $row["discount_percent"]);
}
+ $sql = "DELETE FROM ".TB_PREF."stock_moves WHERE type=".db_escape($type)
+ ." AND trans_no=".db_escape($type_no);
+ db_query($sql, "The stock movement cannot be delated");
}
//--------------------------------------------------------------------------------------------------
display_db_error("could not retreive the location name for $loc_code", $sql, true);
}
-
-//--------------------------------------------------------------------------------------------------
-
-
-?>
var $graphic_links; // use graphic links
var $sticky_date; // save date on subsequent document entry
var $startup_tab; // default start-up menu tab
-
+ var $transaction_days; // transaction days in inquiries.
+
function user_prefs($user=null)
{
if ($user == null) {
$this->price_dec = 2;
$this->language = $dflt_lang;
$this->theme = 'default';
-
+ $this->transaction_days = -30;
+
} else {
$this->language = $user["language"];
$_SESSION['language']->set_language($this->language);
$this->sticky_date = 0;
$this->startup_tab = "orders";
}
+ $this->transaction_days = $user['transaction_days'];
}
}
return "m".$sep."d".$sep."Y";
elseif ($this->date_format == 1)
return "d".$sep."m".$sep."Y";
- else
+ elseif ($this->date_format == 2)
return "Y".$sep."m".$sep."d";
+ elseif ($this->date_format == 3)
+ return "M".$sep."j".$sep."Y";
+ elseif ($this->date_format == 4)
+ return "j".$sep."M".$sep."Y";
+ else
+ return "Y".$sep."M".$sep."j";
}
function tho_sep()
return $this->startup_tab;
}
+ function transaction_days()
+ {
+ return $this->transaction_days;
+ }
+
function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes)
{
$this->price_dec = $price_dec;
$user = $_SESSION["wa_current_user"]->user;
- if (@$login_delay && ($login_faillog[$user][$_SERVER['REMOTE_ADDR']] >= @$login_max_attempts) && (time() < $login_faillog[$user]['last'] + $login_delay))
+ if (@$login_delay && (@$login_faillog[$user][$_SERVER['REMOTE_ADDR']] >= @$login_max_attempts) && (time() < $login_faillog[$user]['last'] + $login_delay))
return true;
return false;
ini_set('session.gc_maxlifetime', 36000); // 10hrs
+hook_session_start(@$_POST["company_login_name"]);
+
$Session_manager = new SessionManager();
$Session_manager->sessionStart('FA'.md5(dirname(__FILE__)));
get_text_init();
// Page Initialisation
-if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_language'))
+if (!isset($_SESSION['wa_current_user']) || !$_SESSION['wa_current_user']->logged_in()
+ || !isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_language'))
{
$l = array_search_value($dflt_lang, $installed_languages, 'code');
$_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'],
include_once($path_to_root . "/includes/access_levels.inc");
include_once($path_to_root . "/version.php");
include_once($path_to_root . "/includes/main.inc");
+include_once($path_to_root . "/includes/app_entries.inc");
// Ajax communication object
$Ajax = new Ajax();
// Incorrect password
login_fail();
}
- $lang = &$_SESSION['language'];
- $lang->set_language($_SESSION['language']->code);
}
} else
- set_global_connection();
+ { set_global_connection();
+ if (db_fixed())
+ db_set_encoding($_SESSION['language']->encoding);
+ }
if (!isset($_SESSION["App"])) {
$_SESSION["App"] = new front_accounting();
// POST vars cleanup needed for direct reuse.
// We quote all values later with db_escape() before db update.
$_POST = strip_quotes($_POST);
-
-?>
//
global $systypes_array, $bank_account_types, $bank_transfer_types,
$payment_person_types, $wo_types_array, $wo_cost_types, $class_types,
- $quick_actions, $quick_entry_types, $stock_types, $tag_types;
+ $quick_actions, $quick_entry_types, $stock_types, $tag_types, $bank_owner;
$systypes_array = array (
ST_JOURNAL => _("Journal Entry"),
$wo_cost_types = array(
WO_LABOUR => _("Labour Cost"),
WO_OVERHEAD => _("Overhead Cost"),
+ WO_MATERIALS => _("Materials")
);
//----------------------------------------------------------------------------------
PTT_FOLLOWING => _("Day In Following Month")
);
+$tax_algorithms = array(
+ TCA_LINES => _("Sum per line taxes"),
+ TCA_TOTALS => _("Taxes from totals")
+);
//----------------------------------------------------------------------------------
+
+$bank_owner_types = array(
+ BO_UNKNOWN => _("Unknown"),
+ BO_COMPANY => _("Company"),
+ BO_CUSTBRANCH => _("Customer"),
+ BO_SUPPLIER => _("Supplier")
+);
+
+ // This month array is for use with the last 3 dateformats.
+ $tmonths = array("", _("Jan"),_("Feb"),_("Mar"),_("Apr"),_("May"),_("Jun"),_("Jul"),_("Aug"),_("Sep"),_("Oct"),_("Nov"),_("Dec"));
+
?>
'cancel' - cancel form entry on Escape press; dflt ICON_CANCEL
'process' - displays progress bar during call; optional icon
'nonajax' - ditto, non-ajax submit
+
$atype can contain also multiply type selectors separated by space,
however make sense only combination of 'process' and one of defualt/selector/cancel
*/
$aspect .= ' style="color:#FF0000"';
default_focus($name);
- echo "<input type=\"text\" name=\"$name\" class=\"$class\" $aspect size=\"10\" maxlength=\"12\" value=\""
+ $size = (user_date_format()>3)?11:10;
+ echo "<input type=\"text\" name=\"$name\" class=\"$class\" $aspect size=\"$size\" maxlength=\"12\" value=\""
. $_POST[$name]. "\""
.($title ? " title='$title'": '')." > $post_label";
echo "</td>\n";
."</a>", $parms);
}
+/*
+ Edit transaction link to be used in transaction inquires
+*/
+function edit_trans_link($trans_type, $trans_no, $url='')
+{
+ global $path_to_root, $trans_editors;
+
+ if (!$url) $url = @$trans_editors[$trans_type];
+
+ if (!$trans_no || !$url)
+ return '';
+
+ if (is_closed_trans($trans_type, $trans_no)) {
+ return set_icon(ICON_CLOSED, _('Closed'));
+ } else {
+ $link_text = user_graphic_links() ? set_icon(ICON_EDIT, _('Edit')) : _('Edit');
+ return "<a href='".$path_to_root . sprintf($url, $trans_no, $trans_type)."'>$link_text</a>";
+ }
+}
+
function bank_balance_row($bank_acc, $parms='')
{
global $path_to_root;
-
+
$to = add_days(Today(), 1);
$bal = get_balance_before_for_bank_account($bank_acc, $to);
label_row( _("Bank Balance:"),
{
$label = _("GL");
$icon = ICON_GL;
- }
+ }
+ $url = ($type == ST_WORKORDER && !work_order_is_closed($trans_no)) ? "manufacturing/view/wo_costs_view.php?trans_no=$trans_no"
+ : "gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no";
- return viewer_link($label,
- "gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no",
- $class, $id, $icon);
+ return viewer_link($label, $url, $class, $id, $icon);
}
//--------------------------------------------------------------------------------------
function display_footer_exit()
{
br(2);
- end_page(false, false, true);
+ end_page(false, true);
exit;
}
//--------------------------------------------------------------------------------------
-function display_allocations($alloc_result, $total, $payments=false)
+function display_allocations($alloc_result, $total, $title, $show_summary=true)
{
global $systypes_array;
if (!$alloc_result || db_num_rows($alloc_result) == 0)
return;
- display_heading2(($payments ? _("Payments") : _("Allocations")));
+ display_heading2($title);
start_table(TABLESTYLE, "width=80%");
while ($alloc_row = db_fetch($alloc_result))
{
-
alt_table_row_color($k);
label_cell($systypes_array[$alloc_row['type']]);
label_cell(_("Total Allocated:"), "align=right colspan=5");
amount_cell($total_allocated);
end_row();
- start_row();
- label_cell(_("Left to Allocate:"), "align=right colspan=5");
- $total = round2($total, user_price_dec());
- amount_cell($total - $total_allocated);
- end_row();
-
+ if ($show_summary)
+ {
+ start_row();
+ label_cell(_("Left to Allocate:"), "align=right colspan=5");
+ $total = round2($total, user_price_dec());
+ amount_cell($total - $total_allocated);
+ end_row();
+ }
end_table(1);
}
{
case PT_CUSTOMER :
$alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type);
- display_allocations($alloc_result, $total);
+ display_allocations($alloc_result, $total, _("Allocations"));
return;
case PT_SUPPLIER :
$alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type);
- display_allocations($alloc_result, $total);
+ display_allocations($alloc_result, $total, _("Allocations"));
return;
}
}
{
case PT_CUSTOMER :
$alloc_result = get_allocatable_from_cust_transactions($person_id, $type_no, $type);
- display_allocations($alloc_result, $total, true);
+ display_allocations($alloc_result, $total, $type == ST_SALESORDER ? _("Pre-Payments") : _("Payments"), false);
return;
case PT_SUPPLIER :
$alloc_result = get_allocatable_from_supp_transactions($person_id, $type_no, $type);
- display_allocations($alloc_result, $total, true);
+ display_allocations($alloc_result, $total, $type == ST_PURCHORDER ? _("Pre-Payments") : _("Payments"), false);
return;
}
}
$begin = "";
else
$begin = begin_fiscalyear(); // from fiscalyear begin
- }
+ }
$base = get_gl_trans_from_to($begin, $cart->tran_date, $qe['base_desc']);
-
+
}
if ($descr != '') $qe['description'] .= ': '.$descr;
$result = get_quick_entry_lines($id);
display_error( _("No Quick Entry lines are defined."));
set_focus('totamount');
return 0;
- }
+ }
$totrate = 0;
while ($row = db_fetch($result))
{
else
$frac = "";
return _number_to_words(intval($amount)) . $frac;
-}
+}
function get_js_open_window($width, $height)
{
if (!file_exists($fpath) || $go_debug) {
- global $dateseps, $date_system;
+ global $dateseps, $date_system, $tmonths;
$how = user_date_format(); // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
$sep = $dateseps[user_date_sep()]; // date separator
- $wstart = (($date_system == 1 || $date_system == 2 || $date_system == 3) ? 6 : ($how == 0 ? 0 : 1)); // weekstart (sun = 0, mon = 1)
+ $wstart = (($date_system == 1 || $date_system == 2 || $date_system == 3) ? 6 : ($how == 0 || $how == 3 ? 0 : 1)); // weekstart (sun = 0, mon = 1)
$months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
$wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
$wno = _("W"); // week no
var selectedDay = 0;
var months = ['$months[0]','$months[1]','$months[2]','$months[3]','$months[4]','$months[5]','$months[6]','$months[7]','$months[8]','$months[9]','$months[10]','$months[11]'];
var wdays = ['$wdays[0]', '$wdays[1]', '$wdays[2]', '$wdays[3]', '$wdays[4]', '$wdays[5]', '$wdays[6]'];
+ var tmonths = ['$tmonths[0]','$tmonths[1]','$tmonths[2]','$tmonths[3]','$tmonths[4]','$tmonths[5]','$tmonths[6]','$tmonths[7]','$tmonths[8]','$tmonths[9]','$tmonths[10]','$tmonths[11]','$tmonths[12]'];
var dateField = null;
function getProperty(p_property){
var p_elm = calendarId;
this.getWeek = getWeek;
function getWeek(year, month, day) {
";
- if ($how == 0)
+ if ($how == 0 || $how == 3)
$js .= " day++;";
$js .= "
var date = new Date(year,month-1,day);
}
this.setDate = setDate;
function setDate(year, month, day) {
- if (dateField) {
+ if (dateField){
+ ";
+ if ($how < 3)
+ $js .= "
if (month < 10) {month = '0' + month;}
if (day < 10) {day = '0' + day;}
";
- if ($how == 0)
+ else
+ $js .= "
+ month = tmonths[month];
+ ";
+ if ($how == 0 || $how == 3)
$js .= "
var dateString = month+'$sep'+day+'$sep'+year;
";
- else if ($how == 1)
+ else if ($how == 1 || $how == 4)
$js .= "
var dateString = day+'$sep'+month+'$sep'+year;
";
- else
+ else if ($how == 2 || $how == 5)
$js .= "
var dateString = year+'$sep'+month+'$sep'+day;
";
selectedMonth = parseInt(dateParts[1],10);
selectedYear = parseInt(dateParts[2],10);
";
- else
+ else if ($how == 2)
$js .= "
selectedYear = parseInt(dateParts[0],10);
selectedMonth = parseInt(dateParts[1],10);
selectedDay = parseInt(dateParts[2],10);
+ ";
+ else if ($how == 3)
+ $js .= "
+ selectedDay = parseInt(dateParts[1],10);
+ selectedMonth = parseInt(tmonths.indexOf(dateParts[0]),10);
+ selectedYear = parseInt(dateParts[2],10);
+ ";
+ else if ($how == 4)
+ $js .= "
+ selectedDay = parseInt(dateParts[0],10);
+ selectedMonth = parseInt(tmonths.indexOf(dateParts[1]),10);
+ selectedYear = parseInt(dateParts[2],10);
+ ";
+ else
+ $js .= "
+ selectedYear = parseInt(dateParts[0],10);
+ selectedMonth = parseInt(tmonths.indexOf(dateParts[1]),10);
+ selectedDay = parseInt(dateParts[2],10);
";
$js .= "
} catch(e) {}
return strtr($link, $patterns);
}
-
-?>
// for links use 'text' => 'url'
$Footer[0] = _("All amounts stated in") . " - " . @$this->formData['curr_code'];
+ if (!in_array($this->formData['doctype'], array(ST_STATEMENT, ST_WORKORDER)))
+ {
+ $id = $this->formData['payment_terms'];
+ $sql = "SELECT terms, days_before_due FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id);
+ $result = db_query($sql,"could not get paymentterms");
+ $row = db_fetch($result);
+ $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
+ if ($this->formData['doctype'] == ST_SALESINVOICE && $this->formData['prepaid'])
+ $this->formData['prepaid'] = ($row['days_before_due'] >= 0) ? 'final' : 'partial';
+ }
+
+
switch ($this->formData['doctype'])
{
case ST_SALESQUOTE:
$this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
? $this->formData['reference'] : $this->formData['order_no'];
$aux_info = array(
- _("Customers Reference") => $this->formData["customer_ref"],
+ _("Customer's Reference") => $this->formData["customer_ref"],
_("Sales Person") => get_salesman_name($this->formData['salesman']),
_("Your VAT no.") => $this->formData['tax_id'],
_("Our Quotation No") => $this->formData['order_no'],
break;
case ST_SALESORDER:
- $this->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER"));
+ $this->title = ($print_as_quote==1 ? _("QUOTE") : ($this->formData['prepaid'] ? _("PREPAYMENT ORDER") : _("SALES ORDER")));
$this->formData['document_name'] =_("Order No.");
$this->formData['document_date'] = $this->formData['ord_date'];
$this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
$this->formData['document_amount'] = $this->formData['order_no'];
$aux_info = array(
- _("Customers Reference") => $this->formData["customer_ref"],
+ _("Customer's Reference") => $this->formData["customer_ref"],
_("Sales Person") => get_salesman_name($this->formData['salesman']),
_("Your VAT no.") => $this->formData['tax_id'],
_("Our Order No") => $this->formData['order_no'],
$ref = $this->formData['order_'];
}
$aux_info = array(
- _("Customers Reference") => $this->formData["customer_ref"],
+ _("Customer's Reference") => $this->formData["customer_ref"],
_("Sales Person") => get_salesman_name($this->formData['salesman']),
_("Your VAT no.") => $this->formData['tax_id'],
_("Our Order No") => $ref,
$Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code'];
$aux_info = array(
- _("Customers Reference") => @$this->formData["customer_ref"],
+ _("Customer's Reference") => @$this->formData["customer_ref"],
_("Sales Person") => get_salesman_name($this->formData['salesman']),
_("Your VAT no.") => $this->formData['tax_id'],
_("Our Order No") => $this->formData['order_'],
break;
case ST_SALESINVOICE:
- $this->title = _("INVOICE");
+ $this->title = $this->formData['prepaid']=='partial' ? _("PREPAYMENT INVOICE")
+ : ($this->formData['prepaid']=='final' ? _("FINAL INVOICE") : _("INVOICE"));
$this->formData['document_name'] =_("Invoice No.");
$this->formData['domicile'] = $this->company['domicile'];
$Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code'];
}
}
$aux_info = array(
- _("Customers Reference") => $this->formData["customer_ref"],
+ _("Customer's Reference") => $this->formData["customer_ref"],
_("Sales Person") => get_salesman_name($this->formData['salesman']),
_("Your VAT no.") => $this->formData['tax_id'],
- _("Delivery Note No.") => implode(',', $deliveries),
- _("Due Date") => sql2date($this->formData['due_date']),
);
+ if ($this->formData['prepaid']=='partial')
+ {
+ $aux_info[_("Date of Payment")] = sql2date(get_oldest_payment_date($this->formData['trans_no']));
+ $aux_info[_("Our Order No")] = $this->formData['order_'];
+ } else {
+ if ($this->formData['prepaid'] =='final')
+ $aux_info[_("Invoice Date")] = sql2date($this->formData['tran_date']);
+ else
+ $aux_info[_("Date of Sale")] = sql2date(get_oldest_delivery_date($this->formData['trans_no']));
+ $aux_info[_("Due Date")] = sql2date($this->formData['due_date']);
+ }
break;
case ST_SUPPAYMENT:
$Addr2['address'] = '';
$aux_info = array(
- _("Customers Reference") => $this->formData['supp_account_no'],
+ _("Customer's Reference") => $this->formData['supp_account_no'],
_("Type") =>$systypes_array[$this->formData["type"]],
_("Your VAT no.") => $this->formData['tax_id'],
- _("Our Order No") => '',
+ _("Supplier's Reference") => '',
_("Due Date") => sql2date($this->formData['tran_date']),
);
$this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
? $this->formData['reference'] : $this->formData['order_no'];
$aux_info = array(
- _("Customers Reference") => $this->formData['supp_account_no'],
- _("Sales Person") => '',
- _("Your VAT no.") => '',
- _("Our Order No") => '',
- _("Due Date") => '',
+ _("Customer's Reference") => $this->formData['supp_account_no'],
+ _("Sales Person") => $this->formData['contact'],
+ _("Your VAT no.") => $this->formData['tax_id'],
+ _("Supplier's Reference") => $this->formData['requisition_no'],
+ _("Order Date") => sql2date($this->formData['document_date']),
);
$this->headers = array(_("Item Code"), _("Item Description"),
$this->formData['document_name'] =_("Receipt No.");
$Addr1['title'] = _("With thanks from");
$aux_info = array(
- _("Customers Reference") => $this->formData["debtor_ref"],
+ _("Customer's Reference") => $this->formData["debtor_ref"],
_("Type") =>$systypes_array[$this->formData["type"]],
_("Your VAT no.") => $this->formData['tax_id'],
_("Our Order No") => $this->formData['order_'],
$Payment_Terms = '';
$this->title = _("STATEMENT");
$aux_info = array(
- _("Customers Reference") => '',
+ _("Customer's Reference") => '',
_("Sales Person") => '',
_("Your VAT no.") => $this->formData['tax_id'],
_("Our Order No") => '',
$this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
? $this->formData['reference'] : @$this->formData['trans_no'];
- if (!isset($Payment_Terms))
- {
- $id = $this->formData['payment_terms'];
- $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id);
- $result = db_query($sql,"could not get paymentterms");
- $row = db_fetch($result);
- $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"];
- }
-
// footer generic content
if (@$this->formData['bank_name'])
$Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number'];
foreach(explode("\n", $this->company['legal_text']) as $line)
$Footer[] = $line;
}
-
-?>
'DebtorName', 'supp_account_no', 'wo_ref', 'debtor_ref','type', 'trans_no',
'StockItemName', 'tax_id', 'order_', 'delivery_date', 'units_issued',
'due_date', 'required_by', 'payment_terms', 'curr_code',
- 'ov_freight', 'ov_gst', 'ov_amount', 'prepaid'),
- 'ov_freight', 'ov_gst', 'ov_amount', 'requisition_no', 'contact'),
++ 'ov_freight', 'ov_gst', 'ov_amount', 'prepaid', 'requisition_no', 'contact'),
'branch' => array('br_address', 'br_name', 'salesman', 'disable_branch'),
'sales_order' => array('deliver_to', 'delivery_address', 'customer_ref'),
'bankaccount' => array('bank_name', 'bank_account_number', 'payment_service')
function get_po($order_no)
{
$sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, "
- .TB_PREF."suppliers.supp_account_no,".TB_PREF."suppliers.tax_included,".TB_PREF."suppliers.tax_algorithm,
- .TB_PREF."suppliers.supp_account_no,".TB_PREF."suppliers.tax_included,".TB_PREF."suppliers.gst_no AS tax_id,
++ .TB_PREF."suppliers.supp_account_no,".TB_PREF."suppliers.tax_included,".TB_PREF."suppliers.tax_algorithm,".TB_PREF."suppliers.gst_no AS tax_id,
".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.payment_terms, ".TB_PREF."locations.location_name,
".TB_PREF."suppliers.address, ".TB_PREF."suppliers.contact, ".TB_PREF."suppliers.tax_group_id
FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations
$rep->NewLine();
$tax_items = get_tax_for_items($items, $prices, 0,
- $myrow['tax_group_id'], $myrow['tax_included'], null);
+ $myrow['tax_group_id'], $myrow['tax_included'], null, $myrow['tax_algorithm']);
$first = true;
foreach($tax_items as $tax_item)
{
continue;
$DisplayTax = number_format2($tax_item['Value'], $dec);
- $tax_type_name = $tax_item['tax_type_name'];
+ if (isset($suppress_tax_rates) && $suppress_tax_rates == 1)
+ $tax_type_name = $tax_item['tax_type_name'];
+ else
+ $tax_type_name = $tax_item['tax_type_name']." (".$tax_item['rate']."%) ";
if ($myrow['tax_included'])
{