From 850b2dc645b7e16d6b2f5a5e10cac03d8956180c Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 22 Mar 2009 17:02:30 +0000 Subject: [PATCH] Option to use last dcument date on subsequent new documents. --- admin/db/users_db.inc | 5 +++-- admin/display_prefs.php | 5 ++++- includes/current_user.inc | 14 ++++++++++---- includes/prefs/userprefs.inc | 11 +++++++++-- sql/alter2.2.php | 1 + sql/alter2.2.sql | 2 ++ sql/en_US-demo.sql | 5 +++-- sql/en_US-new.sql | 3 ++- 8 files changed, 34 insertions(+), 12 deletions(-) diff --git a/admin/db/users_db.inc b/admin/db/users_db.inc index 5200f2c9..c19cbd82 100644 --- a/admin/db/users_db.inc +++ b/admin/db/users_db.inc @@ -55,7 +55,7 @@ function update_user($user_id, $real_name, $phone, $email, $full_access, function update_user_display_prefs($user_id, $price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size, - $graphic_links, $lang) + $graphic_links, $lang, $stickydate) { $sql = "UPDATE ".TB_PREF."users SET prices_dec=".db_escape($price_dec).", @@ -75,7 +75,8 @@ function update_user_display_prefs($user_id, $price_dec, $qty_dec, $exrate_dec, rep_popup=$rep_popup, query_size=$query_size, graphic_links=$graphic_links, - language=".db_escape($lang)." + language=".db_escape($lang).", + sticky_doc_date=".db_escape($stickydate)." WHERE user_id = ".db_escape($user_id); db_query($sql, "could not update user display prefs for $user_id"); diff --git a/admin/display_prefs.php b/admin/display_prefs.php index 81d951ad..6d1bd6c4 100644 --- a/admin/display_prefs.php +++ b/admin/display_prefs.php @@ -42,7 +42,7 @@ if (isset($_POST['setprefs'])) $_POST['theme'], $_POST['page_size'], check_value('show_hints'), $_POST['profile'], check_value('rep_popup'), (int)($_POST['query_size']), check_value('graphic_links'), - $_POST['language']); + $_POST['language'], check_value('sticky_doc_date')); if ($chg_lang) language::set_language($_POST['language']); @@ -127,6 +127,9 @@ check_row(_("Use icons instead of text links:"), 'graphic_links', user_graphic_l text_row_ex(_("Query page size:"), 'query_size', 5, 5, '', user_query_size()); +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')); + end_outer_table(1); submit_center('setprefs', _("Update"), true, '', 'default'); diff --git a/includes/current_user.inc b/includes/current_user.inc index 023591d3..f55f248d 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -110,11 +110,11 @@ class current_user function update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size, - $graphic_links, $lang) { + $graphic_links, $lang, $stickydate) { update_user_display_prefs($this->username, $price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, - $show_hints, $profile, $rep_popup, $query_size, $graphic_links, $lang); + $show_hints, $profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate); // re-read the prefs $user = get_user($this->username); @@ -302,14 +302,19 @@ function user_graphic_links() return $_SESSION["wa_current_user"]->prefs->graphic_links(); } +function sticky_doc_date() +{ + return $_SESSION["wa_current_user"]->prefs->sticky_date(); +} + function set_user_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, - $print_profile, $rep_popup, $query_size, $graphic_links, $lang) + $print_profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate) { $_SESSION["wa_current_user"]->update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, - $print_profile, $rep_popup, $query_size, $graphic_links, $lang); + $print_profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate); } function add_user_js_data() { @@ -323,6 +328,7 @@ function add_user_js_data() { . "var user = {\n" . "theme: '". $path_to_root . '/themes/'. 'default' /*user_theme()*/.'/'."',\n" . "loadtxt: '"._('Requesting data...')."',\n" + . "date: '".Today()."',\n" . "ts: '$ts',\n" . "ds: '$ds',\n" . "pdec : " . user_price_dec() . "}\n-->"; diff --git a/includes/prefs/userprefs.inc b/includes/prefs/userprefs.inc index 43afba6f..7ba4c0c7 100644 --- a/includes/prefs/userprefs.inc +++ b/includes/prefs/userprefs.inc @@ -33,7 +33,8 @@ class user_prefs var $show_hints; var $query_size; // table pager page length var $graphic_links; // use graphic links - + var $sticky_date; // save date on subsequent document entry + function user_prefs($user=null) { if ($user == null) { @@ -65,6 +66,7 @@ class user_prefs $this->rep_popup = $user["rep_popup"]; $this->query_size = $user["query_size"]; $this->graphic_links = $user["graphic_links"]; + $this->sticky_date = $user["sticky_doc_date"]; } } @@ -169,7 +171,12 @@ class user_prefs { return $this->graphic_links; } - + + function sticky_date() + { + return $this->sticky_date; + } + function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) { $this->price_dec = $price_dec; diff --git a/sql/alter2.2.php b/sql/alter2.2.php index 3f557aae..bcd772e1 100644 --- a/sql/alter2.2.php +++ b/sql/alter2.2.php @@ -44,6 +44,7 @@ class fa2_2 { function installed($pref) { if (check_table($pref, 'company', 'default_delivery_required')) return false; if (check_table($pref, 'stock_category', 'dflt_dim2')) return false; + if (check_table($pref, 'users', 'sticky_doc_date')) return false; return true; } }; diff --git a/sql/alter2.2.sql b/sql/alter2.2.sql index 01c49685..07e80959 100644 --- a/sql/alter2.2.sql +++ b/sql/alter2.2.sql @@ -22,3 +22,5 @@ ALTER TABLE `0_stock_category` ADD COLUMN `dflt_adjustment_act` varchar(11) NOT ALTER TABLE `0_stock_category` ADD COLUMN `dflt_assembly_act` varchar(11) NOT NULL default ''; ALTER TABLE `0_stock_category` ADD COLUMN `dflt_dim1` int(11) default NULL; ALTER TABLE `0_stock_category` ADD COLUMN `dflt_dim2` int(11) default NULL; + +ALTER TABLE `0_users` ADD `sticky_doc_date` TINYINT(1) DEFAULT '0'; diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index 3bcddfff..af0448ad 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -2267,14 +2267,15 @@ CREATE TABLE `0_users` ( `pos` smallint(6) default '1', `print_profile` varchar(30) NOT NULL default '1', `rep_popup` tinyint(1) default '1', + `sticky_doc_date` tinyint(1) default '0', PRIMARY KEY (`user_id`) ) TYPE=MyISAM ; ### Data of table `0_users` ### -INSERT INTO `0_users` VALUES ('demouser', '5f4dcc3b5aa765d61d8327deb882cf99', 'Demo User', '1', '999-999-999', 'demo@demo.nu', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '3', '1', '1', '0', '0', '2008-02-06 19:02:35', '10', '1', '1', '1', '1'); -INSERT INTO `0_users` VALUES ('admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2009-01-30 09:39:03', '10', '1', '1', '', '1'); +INSERT INTO `0_users` VALUES ('demouser', '5f4dcc3b5aa765d61d8327deb882cf99', 'Demo User', '1', '999-999-999', 'demo@demo.nu', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '3', '1', '1', '0', '0', '2008-02-06 19:02:35', '10', '1', '1', '1', '1', '0'); +INSERT INTO `0_users` VALUES ('admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2009-01-30 09:39:03', '10', '1', '1', '', '1', '0'); ### Structure of table `0_voided` ### diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index f479dd7c..3131e6b7 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -1545,13 +1545,14 @@ CREATE TABLE `0_users` ( `pos` smallint(6) default '1', `print_profile` varchar(30) NOT NULL default '1', `rep_popup` tinyint(1) default '1', + `sticky_doc_date` tinyint(1) default '0', PRIMARY KEY (`user_id`) ) TYPE=MyISAM ; ### Data of table `0_users` ### -INSERT INTO `0_users` VALUES ('admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2008-04-04 12:34:29', '10', '1', '1', '1', '1'); +INSERT INTO `0_users` VALUES ('admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2008-04-04 12:34:29', '10', '1', '1', '1', '1', '0'); ### Structure of table `0_voided` ### -- 2.30.2