From 3f7b883010137fea43308c7beee7458d2abfcfd7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 10 May 2012 14:32:02 +0530 Subject: [PATCH 01/11] reload reports --- erpnext/patches/may_2012/reload_reports.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 erpnext/patches/may_2012/reload_reports.py diff --git a/erpnext/patches/may_2012/reload_reports.py b/erpnext/patches/may_2012/reload_reports.py new file mode 100644 index 0000000000..3ac6960d76 --- /dev/null +++ b/erpnext/patches/may_2012/reload_reports.py @@ -0,0 +1,6 @@ +def execute(): + import webnotes + from webnotes.modules import reload_doc + reload_doc('selling', 'search_criteria', 'itemwise_sales_details') + reload_doc('selling', 'search_criteria', 'itemwise_delivery_details') + From 91d6d1423dc21831cf5b36676071e23c92f953a5 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 10 May 2012 14:32:56 +0530 Subject: [PATCH 02/11] reload reports --- erpnext/patches/patch_list.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index ea8e5d6588..ea4840a55a 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -337,5 +337,10 @@ patch_list = [ 'patch_file': 'stock_reco_patch', 'description': 'stock reco patch: store diff info in field' }, + { + 'patch_module': 'patches.may_2012', + 'patch_file': 'reload_reports', + 'description': 'reload reports: itemwise sales/delivery details' + }, ] From 3156ad8143272ed69fb47246bc32a7b0dce62e39 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 May 2012 17:29:13 +0530 Subject: [PATCH 03/11] fix in Suggest type field's autosuggest --- js/all-app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/all-app.js b/js/all-app.js index 68206443da..5d3e0eb064 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -830,7 +830,7 @@ me.format_input();if(in_list(['Currency','Float','Int'],me.df.fieldtype)){if(flt me.last_value=val;me.run_trigger();} this.input.set_input=function(val){if(val==null)val='';me.input.value=val;if(me.format_input)me.format_input();} if(this.df.options=='Suggest'){if(this.suggest_icon)$di(this.suggest_icon);$(me.input).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':repl('SELECT DISTINCT `%(fieldname)s` FROM \ - `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50',{fieldname:me.df.fieldname,dt:me.df.parent})},callback:function(r){response(r.results);}});}});}} + `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50',{fieldname:me.df.fieldname,dt:me.df.parent})},callback:function(r){response(r.results);}});},select:function(event,ui){me.set(ui.item.value);}});}} DataField.prototype.validate=function(v){if(this.df.options=='Phone'){if(v+''=='')return'';v1='' v=v.replace(/ /g,'').replace(/-/g,'').replace(/\(/g,'').replace(/\)/g,'');if(v&&v.substr(0,1)=='+'){v1='+';v=v.substr(1);} if(v&&v.substr(0,2)=='00'){v1+='00';v=v.substr(2);} @@ -1521,7 +1521,7 @@ me.format_input();if(in_list(['Currency','Float','Int'],me.df.fieldtype)){if(flt me.last_value=val;me.run_trigger();} this.input.set_input=function(val){if(val==null)val='';me.input.value=val;if(me.format_input)me.format_input();} if(this.df.options=='Suggest'){if(this.suggest_icon)$di(this.suggest_icon);$(me.input).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':repl('SELECT DISTINCT `%(fieldname)s` FROM \ - `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50',{fieldname:me.df.fieldname,dt:me.df.parent})},callback:function(r){response(r.results);}});}});}} + `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50',{fieldname:me.df.fieldname,dt:me.df.parent})},callback:function(r){response(r.results);}});},select:function(event,ui){me.set(ui.item.value);}});}} DataField.prototype.validate=function(v){if(this.df.options=='Phone'){if(v+''=='')return'';v1='' v=v.replace(/ /g,'').replace(/-/g,'').replace(/\(/g,'').replace(/\)/g,'');if(v&&v.substr(0,1)=='+'){v1='+';v=v.substr(1);} if(v&&v.substr(0,2)=='00'){v1+='00';v=v.substr(2);} From ef85c4e5569bc3e1980eef8510f832dbcfb8f611 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 10 May 2012 17:48:34 +0530 Subject: [PATCH 04/11] posting time fixes in stock ledger entry --- .../stock/doctype/stock_ledger_entry/stock_ledger_entry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index d6f700032f..b545d7d9c6 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -94,13 +94,13 @@ class DocType: def validate_posting_time(self): """ Validate posting time format""" - if self.doc.posting_time and len(cstr(self.doc.posting_time)) == 8 and cstr(self.doc.posting_time)[-2:] != '00': + if self.doc.posting_time and len(self.doc.posting_time.split(':')) > 2: msgprint("Wrong format of posting time, can not complete the transaction. If you think \ you entered posting time correctly, please contact ERPNext support team.") raise Exception def scrub_posting_time(self): - if not self.doc.posting_time or self.doc.posting_time == '12:0': + if not self.doc.posting_time or self.doc.posting_time == '00:0': self.doc.posting_time = '00:00' if len(self.doc.posting_time.split(':')) > 2: self.doc.posting_time = '00:00' From 02c0eaf99a5127edafbfbc3214db58eecbb4470f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 May 2012 18:48:15 +0530 Subject: [PATCH 05/11] don't show currency in journal voucher's listview --- erpnext/accounts/doctype/journal_voucher/listview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_voucher/listview.js b/erpnext/accounts/doctype/journal_voucher/listview.js index 5d7f85a7d9..6fe4cde234 100644 --- a/erpnext/accounts/doctype/journal_voucher/listview.js +++ b/erpnext/accounts/doctype/journal_voucher/listview.js @@ -25,7 +25,7 @@ wn.doclistviews['Journal Voucher'] = wn.views.ListView.extend({ { width: '18%', content: function(parent, data) { - $(parent).html(sys_defaults.currency + ' ' + fmt_money(data.total_debit)) + $(parent).html(fmt_money(data.total_debit)) }, css: {'text-align':'right'} }, From df74d30cf180e9c26db35e0b224816b31adb6e77 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 May 2012 19:19:31 +0530 Subject: [PATCH 06/11] fix in listview of journal voucher --- erpnext/accounts/doctype/journal_voucher/listview.js | 5 +++-- erpnext/startup/event_handlers.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/journal_voucher/listview.js b/erpnext/accounts/doctype/journal_voucher/listview.js index 6fe4cde234..f3c6a74607 100644 --- a/erpnext/accounts/doctype/journal_voucher/listview.js +++ b/erpnext/accounts/doctype/journal_voucher/listview.js @@ -4,7 +4,8 @@ wn.doclistviews['Journal Voucher'] = wn.views.ListView.extend({ this.fields = this.fields.concat([ '`tabJournal Voucher`.voucher_type', '`tabJournal Voucher`.remark', - '`tabJournal Voucher`.total_debit' + '`tabJournal Voucher`.total_debit', + '`tabJournal Voucher`.company', ]); this.stats = this.stats.concat(['voucher_type']); }, @@ -25,7 +26,7 @@ wn.doclistviews['Journal Voucher'] = wn.views.ListView.extend({ { width: '18%', content: function(parent, data) { - $(parent).html(fmt_money(data.total_debit)) + $(parent).html(wn.boot.company[data.company].default_currency + ' ' + fmt_money(data.total_debit)) }, css: {'text-align':'right'} }, diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index a67a2148b9..9f4ff9b7f5 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -88,6 +88,13 @@ def boot_session(bootinfo): if hasattr(conf, 'max_users'): bootinfo['max_users'] = conf.max_users if hasattr(conf, 'expires_on'): bootinfo['expires_on'] = conf.expires_on + company = webnotes.conn.sql("select name, default_currency from `tabCompany`", as_dict=1) + company_dict = {} + for c in company: + company_dict.setdefault(c['name'], {}).update(c) + + bootinfo['company'] = company_dict + def get_letter_heads(): """load letter heads with startup""" From 41526227e33a0985fe5b4a98f319cf4640a832ab Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 11 May 2012 11:11:46 +0530 Subject: [PATCH 07/11] page role series pacth --- erpnext/patches/may_2012/page_role_series_fix.py | 5 +++++ erpnext/patches/patch_list.py | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 erpnext/patches/may_2012/page_role_series_fix.py diff --git a/erpnext/patches/may_2012/page_role_series_fix.py b/erpnext/patches/may_2012/page_role_series_fix.py new file mode 100644 index 0000000000..5e66ac3b79 --- /dev/null +++ b/erpnext/patches/may_2012/page_role_series_fix.py @@ -0,0 +1,5 @@ +def execute(): + import webnotes + sr = webnotes.conn.sql("select max(name) from `tabPage Role`") + if sr and sr[0][0].startswith('PR'): + sql("update tabSeries set current = %s where name = 'PR'", int(sr[0][0][2:])) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index ea4840a55a..6f2f8cefd5 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -342,5 +342,10 @@ patch_list = [ 'patch_file': 'reload_reports', 'description': 'reload reports: itemwise sales/delivery details' }, + { + 'patch_module': 'patches.may_2012', + 'patch_file': 'page_role_series_fix', + 'description': 'reset series of page role at max' + }, ] From 43dd041ced5341e4885cf5ccf1ef7d5adbb530b5 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 11 May 2012 11:47:18 +0530 Subject: [PATCH 08/11] page role series pacth --- erpnext/patches/may_2012/page_role_series_fix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches/may_2012/page_role_series_fix.py b/erpnext/patches/may_2012/page_role_series_fix.py index 5e66ac3b79..a44e0f8fba 100644 --- a/erpnext/patches/may_2012/page_role_series_fix.py +++ b/erpnext/patches/may_2012/page_role_series_fix.py @@ -2,4 +2,4 @@ def execute(): import webnotes sr = webnotes.conn.sql("select max(name) from `tabPage Role`") if sr and sr[0][0].startswith('PR'): - sql("update tabSeries set current = %s where name = 'PR'", int(sr[0][0][2:])) + webnotes.conn.sql("update tabSeries set current = %s where name = 'PR'", int(sr[0][0][2:])) From bd3d3ca1eb8e143ee71316fff1e3b2e31fc31033 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 11 May 2012 13:36:17 +0530 Subject: [PATCH 09/11] error fixed in sending mail on submitting of sal slip --- erpnext/hr/doctype/salary_slip/salary_slip.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 03504043e2..63b1810ba6 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -17,7 +17,7 @@ # Please edit this list and import only required elements import webnotes -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add +from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, set_default, str_esc_quote, user_format, validate_email_add from webnotes.model import db_exists from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType from webnotes.model.doclist import getlist, copy_doclist @@ -188,6 +188,7 @@ class DocType(TransactionBase): # Send mail #======================================================= def send_mail_funct(self): + from webnotes.utils.email_lib import sendmail emailid_ret=sql("select company_email from `tabEmployee` where name = '%s'"%self.doc.employee) if emailid_ret: receiver = cstr(emailid_ret[0][0]) @@ -278,6 +279,6 @@ class DocType(TransactionBase): Net Pay(in words) : %s '''%(cstr(letter_head[0][0]),cstr(self.doc.employee), cstr(self.doc.employee_name), cstr(self.doc.month), cstr(self.doc.fiscal_year), cstr(self.doc.department), cstr(self.doc.branch), cstr(self.doc.designation), cstr(self.doc.grade), cstr(self.doc.bank_account_no), cstr(self.doc.bank_name), cstr(self.doc.arrear_amount), cstr(self.doc.payment_days), earn_table, ded_table, cstr(flt(self.doc.gross_pay)), cstr(flt(self.doc.total_deduction)), cstr(flt(self.doc.net_pay)), cstr(self.doc.total_in_words)) - sendmail([receiver], sender='automail@erpnext.com', subject=subj, parts=[['text/plain', msg]]) + sendmail([receiver], subject=subj, msg = msg) else: msgprint("Company Email ID not found.") From 956eeb1361736dfae741b3715b372bbfa5347982 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 11 May 2012 14:45:02 +0530 Subject: [PATCH 10/11] fetch defaults after mapping from prev document --- .../doctype/purchase_invoice/purchase_invoice.py | 10 +++++++++- .../doctype/sales_invoice/sales_invoice.py | 5 ++--- erpnext/selling/doctype/quotation/quotation.py | 2 +- .../selling/doctype/sales_common/sales_common.py | 16 ++++++++++++++++ .../selling/doctype/sales_order/sales_order.py | 2 +- .../stock/doctype/delivery_note/delivery_note.py | 2 +- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 66df40fcd8..b459b64d69 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -97,10 +97,18 @@ class DocType(TransactionBase): self.validate_duplicate_docname('purchase_order') self.doclist = get_obj('DocType Mapper', 'Purchase Order-Purchase Invoice').dt_map('Purchase Order', 'Purchase Invoice', self.doc.purchase_order_main, self.doc, self.doclist, "[['Purchase Order', 'Purchase Invoice'],['Purchase Order Item', 'Purchase Invoice Item'], ['Purchase Taxes and Charges','Purchase Taxes and Charges']]") - ret = self.get_credit_to() + self.get_expense_account('entries') + ret = self.get_credit_to() if ret.has_key('credit_to'): self.doc.credit_to = ret['credit_to'] + + def get_expense_account(self, doctype): + for d in getlist(self.doclist, doctype): + if d.item_code: + item = webnotes.conn.sql("select purchase_account, cost_center from tabItem where name = '%s'" %(d.item_code), as_dict=1) + d.expense_head = item and item[0]['purchase_account'] or '' + d.cost_center = item and item[0]['cost_center'] or '' # Get Item Details diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 59ec9c223a..5f09a432d1 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -177,14 +177,13 @@ class DocType(TransactionBase): arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; - ret = obj.get_item_details(arg, self) - ret = self.get_pos_details(arg, ret) + ret = self.get_pos_details(arg) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] - def get_pos_details(self, args, ret): + def get_pos_details(self, args, ret = {}): if args['item_code'] and cint(self.doc.is_pos) == 1: dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where user = '%s' and company = '%s'" % (session['user'], self.doc.company), as_dict=1) if not dtl: diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index a99f5d7a97..511a74dc22 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -83,7 +83,7 @@ class DocType(TransactionBase): if doc.fields.get('item_code'): arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; - ret = obj.get_item_details(arg, self) + ret = obj.get_item_defaults(arg, self) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index 1a60a06fd2..0a038b12fb 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -156,6 +156,22 @@ class DocType(TransactionBase): ret['base_ref_rate'] = flt(base_ref_rate) ret['basic_rate'] = flt(base_ref_rate) return ret + + + def get_item_defaults(self, args): + item = webnotes.conn.sql("""select default_warehouse, default_income_account, default_sales_cost_center from `tabItem` + where name = '%s' and (ifnull(end_of_life,'') = '' or end_of_life > now() or end_of_life = '0000-00-00') + and (is_sales_item = 'Yes' or is_service_item = 'Yes') """ % (args['item_code']), as_dict=1) + ret = { + 'reserved_warehouse' : item and item[0]['default_warehouse'] or '', + 'warehouse' : item and item[0]['default_warehouse'] or args.get('warehouse'), + 'income_account' : item and item[0]['default_income_account'] or args.get('income_account'), + 'cost_center' : item and item[0]['default_sales_cost_center'] or args.get('cost_center') + } + + return ret + + # ***************** Get Ref rate as entered in Item Master ******************** def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate): diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 320131cd3a..7a19528153 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -100,7 +100,7 @@ class DocType(TransactionBase): if doc.fields.get('item_code'): arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; - ret = obj.get_item_details(arg, self) + ret = obj.get_item_defaults(arg, self) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index e2d2ca3f53..c1bb92dd27 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -117,7 +117,7 @@ class DocType(TransactionBase): if doc.fields.get('item_code'): arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; - ret = obj.get_item_details(arg, self) + ret = obj.get_item_defaults(arg, self) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] From 3d3e4d753c62010b4bea61dabc9f1a92f8438377 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 11 May 2012 17:52:22 +0530 Subject: [PATCH 11/11] fix in posting time issue --- js/all-app.js | 4 ++-- js/all-web.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/all-app.js b/js/all-app.js index 5d3e0eb064..ddbbc48978 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -612,11 +612,11 @@ return(hh.length==1?'0'+hh:hh)+':'+(mm.length==1?'0'+mm:mm);}} wn.datetime.only_date=function(val){if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');var d=tmp[0].split('-');}else{var d=val.split('-');} if(d.length==3) val=d[2]+'-'+d[1]+'-'+d[0];return val;} -wn.datetime.time_to_ampm=function(v){if(!v){var d=new Date();var t=[d.getHours(),cint(d.getMinutes()/5)*5]}else{var t=v.split(':');} +wn.datetime.time_to_ampm=function(v){if(!v){var d=new Date();var t=[d.getHours(),cint(d.getMinutes()/5)*5+'']}else{var t=v.split(':');} if(t.length!=2){show_alert('[set_time] Incorect time format');return;} if(cint(t[0])==0)var ret=['12',t[1],'AM'];else if(cint(t[0])<12)var ret=[cint(t[0])+'',t[1],'AM'];else if(cint(t[0])==12)var ret=['12',t[1],'PM'];else var ret=[(cint(t[0])-12)+'',t[1],'PM'];return ret;} wn.datetime.time_to_hhmm=function(hh,mm,am){if(am=='AM'&&hh=='12'){hh='00';}else if(am=='PM'&&hh!='12'){hh=cint(hh)+12;} -return hh+':'+mm;} +if(!mm)mm='00';if(!hh)hh='00';return hh+':'+mm;} function prettyDate(time){if(!time)return'' var date=time;if(typeof(time)=="string") date=new Date((time||"").replace(/-/g,"/").replace(/[TZ]/g," ").replace(/\.[0-9]*/,""));var diff=(((new Date()).getTime()-date.getTime())/1000),day_diff=Math.floor(diff/86400);if(isNaN(day_diff)||day_diff<0) diff --git a/js/all-web.js b/js/all-web.js index 41a208d97f..877b541657 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -499,11 +499,11 @@ return(hh.length==1?'0'+hh:hh)+':'+(mm.length==1?'0'+mm:mm);}} wn.datetime.only_date=function(val){if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');var d=tmp[0].split('-');}else{var d=val.split('-');} if(d.length==3) val=d[2]+'-'+d[1]+'-'+d[0];return val;} -wn.datetime.time_to_ampm=function(v){if(!v){var d=new Date();var t=[d.getHours(),cint(d.getMinutes()/5)*5]}else{var t=v.split(':');} +wn.datetime.time_to_ampm=function(v){if(!v){var d=new Date();var t=[d.getHours(),cint(d.getMinutes()/5)*5+'']}else{var t=v.split(':');} if(t.length!=2){show_alert('[set_time] Incorect time format');return;} if(cint(t[0])==0)var ret=['12',t[1],'AM'];else if(cint(t[0])<12)var ret=[cint(t[0])+'',t[1],'AM'];else if(cint(t[0])==12)var ret=['12',t[1],'PM'];else var ret=[(cint(t[0])-12)+'',t[1],'PM'];return ret;} wn.datetime.time_to_hhmm=function(hh,mm,am){if(am=='AM'&&hh=='12'){hh='00';}else if(am=='PM'&&hh!='12'){hh=cint(hh)+12;} -return hh+':'+mm;} +if(!mm)mm='00';if(!hh)hh='00';return hh+':'+mm;} function prettyDate(time){if(!time)return'' var date=time;if(typeof(time)=="string") date=new Date((time||"").replace(/-/g,"/").replace(/[TZ]/g," ").replace(/\.[0-9]*/,""));var diff=(((new Date()).getTime()-date.getTime())/1000),day_diff=Math.floor(diff/86400);if(isNaN(day_diff)||day_diff<0)