Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait 2012-06-04 14:04:57 +05:30
commit 9ec73ccf1e
9 changed files with 273 additions and 315 deletions

View File

@ -125,6 +125,7 @@ erpnext.desktop.show_pending_notifications = function() {
add_circle('support', 'open_support_tickets', 'Open Support Tickets');
add_circle('todo', 'things_todo', 'Things To Do');
add_circle('calendar', 'todays_events', 'Todays Events');
add_circle('project', 'open_tasks', 'Open Tasks');
erpnext.update_messages();

View File

@ -59,13 +59,6 @@ class DocType:
def validate(self):
if not self.doc.opening_date:
msgprint("Please enter Opening Date.")
raise Exception
elif getdate(self.doc.opening_date) > getdate(nowdate()):
msgprint("Opening date can not be future date")
raise Exception
if self.doc.exp_start_date and self.doc.exp_end_date and getdate(self.doc.exp_start_date) > getdate(self.doc.exp_end_date):
msgprint("'Expected Start Date' can not be greater than 'Expected End Date'")
raise Exception
@ -73,43 +66,32 @@ class DocType:
if self.doc.act_start_date and self.doc.act_end_date and getdate(self.doc.act_start_date) > getdate(self.doc.act_end_date):
msgprint("'Actual Start Date' can not be greater than 'Actual End Date'")
raise Exception
if self.doc.opening_date and self.doc.review_date and getdate(self.doc.opening_date) > getdate(self.doc.review_date):
msgprint("Review Date should be greater than or equal to Opening Date ")
raise Exception
if self.doc.closing_date and self.doc.review_date and getdate(self.doc.closing_date) < getdate(self.doc.review_date):
msgprint("Closing Date should be greater than or equal to Review Date ")
raise Exception
# on update
#--------------------------------------------
def on_update(self):
if self.doc.status =='Open' and self.doc.allocated_to:
if self.doc.task_email_notify and (self.doc.allocated_to != self.doc.allocated_to_old):
self.doc.sent_reminder = 0
self.doc.allocated_to_old = self.doc.allocated_to
self.sent_notification()
if self.doc.task_email_notify:
self.send_notification()
if self.doc.exp_start_date:
sql("delete from tabEvent where ref_type='Task' and ref_name=%s", self.doc.name)
self.add_calendar_event()
else:
msgprint("An Expeted start date has not been set for this task.Please set 'Expected Start date'\
to add an event to allocated persons calender.You can save a task without this also.")
msgprint("Tip: Add an expected start date to create a calendar event.")
def validate_for_pending_review(self):
if not self.doc.allocated_to:
msgprint("Please enter allocated_to.")
msgprint("Please enter Allocated To.")
raise Exception
self.validate_with_timesheet_dates()
#Sent Notification
def sent_notification(self):
def send_notification(self):
i = {
'name' : self.doc.name,
'senders_name': self.doc.allocated_to,
'senders_name': self.doc.senders_name,
'opening_date': self.doc.opening_date,
'exp_start_date': self.doc.exp_start_date,
'exp_end_date' : self.doc.exp_end_date,
@ -119,8 +101,12 @@ class DocType:
'description': self.doc.description
}
task_label = '[Task Updated] '
if self.doc.creation==self.doc.modified:
task_label = '[New Task] '
msg2="""<h2>%(name)s</h2>
<p>This is a Notification for the task %(name)s that has been assigned to you
<p>This is a Notification for the task %(name)s that has been assigned / updated to you
by %(senders_name)s on %(opening_date)s</p>
<p><b>Subject:</b> %(subject)s </p>
<p><b>Project:</b> %(project)s</p>
@ -128,11 +114,9 @@ class DocType:
<p><b>Expected Start Date:</b> %(exp_start_date)s</p>
<p><b>Expected End Date:</b> %(exp_end_date)s</p>
<p><b>Details:</b> %(description)s</p>
<p>You will also recieve another reminder 2 days before the commencement of the task</p>
<p>Good Luck!</p>
<p>(This notification is autogenerated)</p>""" % i
sendmail(self.doc.allocated_to, sender='automail@webnotestech.com', msg=msg2,send_now=1,\
subject='A task has been assigned')
subject= task_label + self.doc.subject)

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:06',
'creation': '2012-04-02 16:02:06',
'docstatus': 0,
'modified': '2012-03-27 14:36:06',
'modified': '2012-06-04 12:33:35',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -26,7 +26,7 @@
'show_in_menu': 0,
'subject': u'%(subject)s',
'tag_fields': u'status',
'version': 254
'version': 1
},
# These values are common for all DocField
@ -62,6 +62,7 @@
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'All',
'submit': 0,
'write': 1
},
@ -75,6 +76,7 @@
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
@ -115,6 +117,79 @@
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'allocated_to',
'fieldtype': u'Link',
'label': u'Allocated To',
'oldfieldname': u'allocated_to',
'oldfieldtype': u'Link',
'options': u'Profile',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'task_email_notify',
'fieldtype': u'Check',
'label': u'Send Mail Notification',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_start_date',
'fieldtype': u'Date',
'label': u'Expected Start Date',
'oldfieldname': u'exp_start_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_end_date',
'fieldtype': u'Date',
'in_filter': 1,
'label': u'Expected End Date',
'oldfieldname': u'exp_end_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'project',
'fieldtype': u'Link',
'label': u'Project',
'oldfieldname': u'project',
'oldfieldtype': u'Link',
'options': u'Project',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
@ -129,46 +204,6 @@
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'opening_date',
'fieldtype': u'Date',
'label': u'Creation Date',
'oldfieldname': u'opening_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed" || doc.status == "Pending Review"',
'doctype': u'DocField',
'fieldname': u'review_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Review Date',
'oldfieldname': u'review_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed"',
'doctype': u'DocField',
'fieldname': u'closing_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Closing Date',
'oldfieldname': u'closing_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
@ -186,16 +221,60 @@
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'project',
'fieldtype': u'Link',
'label': u'Project',
'oldfieldname': u'project',
'oldfieldtype': u'Link',
'options': u'Project',
'fieldname': u'allocated_to_name',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Allocated To Name',
'oldfieldname': u'allocated_to_name',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'oldfieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text Editor',
'label': u'Details',
'oldfieldname': u'description',
'oldfieldtype': u'Text Editor',
'permlevel': 0,
'trigger': u'Client'
'reqd': 0,
'width': u'300px'
},
# DocField
{
'colour': u'White:FFF',
'description': u'If linked to a Customer',
'doctype': u'DocField',
'fieldname': u'customer_details',
'fieldtype': u'Section Break',
'label': u'Customer Details',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'external_or_internal',
'fieldtype': u'Select',
'label': u'External or Internal',
'oldfieldname': u'external_or_internal',
'oldfieldtype': u'Select',
'options': u'External\nInternal',
'permlevel': 0
},
# DocField
@ -223,73 +302,6 @@
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'allocated_to_old',
'fieldtype': u'Link',
'hidden': 1,
'label': u'Allocated To Old',
'no_copy': 1,
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'allocated_to',
'fieldtype': u'Link',
'label': u'Allocated To',
'oldfieldname': u'allocated_to',
'oldfieldtype': u'Link',
'options': u'Profile',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'task_email_notify',
'fieldtype': u'Check',
'label': u'Sent Mail Notification',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'allocated_to_name',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Allocated To Name',
'oldfieldname': u'allocated_to_name',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sent_reminder',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Sent Reminder',
'no_copy': 1,
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
@ -316,6 +328,14 @@
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break25',
'fieldtype': u'Column Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
@ -337,102 +357,6 @@
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'external_or_internal',
'fieldtype': u'Select',
'label': u'External or Internal',
'oldfieldname': u'external_or_internal',
'oldfieldtype': u'Select',
'options': u'External\nInternal',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Amended From',
'no_copy': 1,
'oldfieldname': u'amended_from',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Amendment Date',
'no_copy': 1,
'oldfieldname': u'amendment_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'oldfieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text Editor',
'label': u'Details',
'oldfieldname': u'description',
'oldfieldtype': u'Text Editor',
'permlevel': 0,
'reqd': 0,
'width': u'300px'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'first_creation_flag',
'fieldtype': u'Int',
'hidden': 1,
'in_filter': 0,
'label': u'First Creation Flag',
'no_copy': 1,
'oldfieldname': u'first_creation_flag',
'oldfieldtype': u'Int',
'permlevel': 0,
'print_hide': 1,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'second_creation_flag',
'fieldtype': u'Int',
'hidden': 1,
'label': u'Second Creation Flag',
'no_copy': 1,
'oldfieldname': u'second_creation_flag',
'oldfieldtype': u'Int',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
@ -455,32 +379,6 @@
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_start_date',
'fieldtype': u'Date',
'label': u'Expected Start Date',
'oldfieldname': u'exp_start_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_end_date',
'fieldtype': u'Date',
'in_filter': 1,
'label': u'Expected End Date',
'oldfieldname': u'exp_end_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
@ -557,5 +455,84 @@
'oldfieldname': u'actual_budget',
'oldfieldtype': u'Currency',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'more_details',
'fieldtype': u'Section Break',
'label': u'More Details',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'opening_date',
'fieldtype': u'Date',
'label': u'Creation Date',
'oldfieldname': u'opening_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed" || doc.status == "Pending Review"',
'doctype': u'DocField',
'fieldname': u'review_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Review Date',
'oldfieldname': u'review_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed"',
'doctype': u'DocField',
'fieldname': u'closing_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Closing Date',
'oldfieldname': u'closing_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Amended From',
'no_copy': 1,
'oldfieldname': u'amended_from',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Amendment Date',
'no_copy': 1,
'oldfieldname': u'amendment_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
}
]
]

View File

@ -164,6 +164,13 @@ GanttGrid = function(chart, s_date, e_date) {
this.make();
}
GanttGrid.prototype.make = function() {
this.body = make_table(this.wrapper, 1, 2, '100%', ['30%','70%']);
this.make_grid();
this.make_labels();
this.y_labels = $a($td(this.body, 0, 0), 'div', '', {marginTop:'2px', position:'relative'});
}
GanttGrid.prototype.make_grid = function() {
// grid -----------
var ht = this.chart.tasks.length * 40 + 'px';
@ -191,17 +198,12 @@ GanttGrid.prototype.make_labels = function() {
if(d.getDate()==today.getDate() && d.getMonth()==today.getMonth() && d.getYear() == today.getYear()) {
$y($td(this.grid_tab,0,i),{borderLeft:'2px solid #000'})
}
var d = date.add_days(this.start_date, 1);
var d = date.str_to_obj(date.add_days(this.start_date, 1));
}
this.start_date = date.str_to_obj(date.user_to_str(this.s_date));
}
GanttGrid.prototype.make = function() {
this.body = make_table(this.wrapper, 1, 2, '100%', ['30%','70%']);
this.make_grid();
this.make_labels();
this.y_labels = $a($td(this.body, 0, 0), 'div', '', {marginTop:'2px', position:'relative'});
}
GanttGrid.prototype.get_x = function(dt) {
var d = date.str_to_obj(dt); // convert to obj
@ -256,33 +258,18 @@ GanttTask = function(grid, data, idx) {
}
GanttTask.prototype.make_tooltip = function(d) {
var t = '<div>';
if(d[0]) t += '<b>Task: </b>' + d[0];
if(d[5]) t += '<br><b>Priority: </b>' + d[5];
if(d[6]) t += '<br><b>Status: </b>' + d[6];
if(d[1]) t += '<br><b>Allocated To: </b>' + d[1];
if(d[2]) t += '<br><b>Project: </b>' + d[2];
if(d[3]) t += '<br><b>From: </b>' + date.str_to_user(d[3]);
if(d[4]) t += '<br><b>To: </b>' + date.str_to_user(d[4]);
t += '</div>';
$(this.body).click(function() {
var t = '<div>';
if(d[0]) t += '<b>Task: </b>' + d[0];
if(d[5]) t += '<br><b>Priority: </b>' + d[5];
if(d[6]) t += '<br><b>Status: </b>' + d[6];
if(d[1]) t += '<br><b>Allocated To: </b>' + d[1];
if(d[2]) t += '<br><b>Project: </b>' + d[2];
if(d[3]) t += '<br><b>From: </b>' + date.str_to_user(d[3]);
if(d[4]) t += '<br><b>To: </b>' + date.str_to_user(d[4]);
t += '</div>';
$(this.body).qtip({
content:t,
position:{
corner:{
tooltip: 'topMiddle', // Use the corner...
target: 'bottomMiddle' // ...and opposite corner
}
},
style:{
border: {
width: 5,
radius: 10
},
padding: 10,
tip: true, // Give it a speech bubble tip with automatic corner detection
name: 'green' // Style it according to the preset 'cream' style
}
msgprint(t)
})
}

View File

@ -4,12 +4,12 @@
<h1>Projects</h1>
<hr>
<div style="width: 48%; float: left;">
<h4><a href="#!List/Project">Project</a></h4>
<p class="help">Project master</p>
<br>
<h4><a href="#!List/Task">Task</a></h4>
<p class="help">Project activity / task</p>
<br>
<h4><a href="#!List/Project">Project</a></h4>
<p class="help">Project master</p>
<br>
<h4><a href="#!List/Timesheet">Timesheet</a></h4>
<p class="help">Timesheet for tasks</p>
</div>

View File

@ -135,6 +135,7 @@ erpnext.update_messages = function(reset) {
show_in_circle('open_support_tickets', r.message.open_support_tickets);
show_in_circle('things_todo', r.message.things_todo);
show_in_circle('todays_events', r.message.todays_events);
show_in_circle('open_tasks', r.message.open_tasks);
} else {
clearInterval(wn.updates.id);

View File

@ -20,6 +20,15 @@ def get_open_support_tickets():
WHERE status = 'Open'""")
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
def get_open_tasks():
"""
Returns a count of open tasks
"""
from webnotes.utils import cint
return webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabTask`
WHERE status = 'Open'""")[0][0]
def get_things_todo():
"""
Returns a count of incomplete todos
@ -51,4 +60,5 @@ def get_global_status_messages(arg=None):
'open_support_tickets': get_open_support_tickets(),
'things_todo': get_things_todo(),
'todays_events': get_todays_events(),
'open_tasks': get_open_tasks()
}

View File

@ -473,9 +473,8 @@ var doc_link=DocLink;function roundNumber(num,dec){var result=Math.round(num*Mat
function same_day(d1,d2){if(d1.getFullYear()==d2.getFullYear()&&d1.getMonth()==d2.getMonth()&&d1.getDate()==d2.getDate())return true;else return false;}
var month_list=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];var month_last={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
var month_list_full=['January','February','March','April','May','June','July','August','September','October','November','December'];var week_list=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];var week_list_full=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];function int_to_str(i,len){i=''+i;if(i.length<len)for(c=0;c<(len-i.length);c++)i='0'+i;return i}
wn.datetime={str_to_obj:function(d){if(!d)return new Date();var tm=[null,null];if(d.search(' ')!=-1){var tm=d.split(' ')[1].split(':');var d=d.split(' ')[0];}
if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else if(d.search('/')!=-1){var t=d.split('/');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else{return new Date();}},obj_to_str:function(d){return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-'+int_to_str(d.getDate(),2);},obj_to_user:function(d){return dateutil.str_to_user(dateutil.obj_to_str(d));},get_diff:function(d1,d2){if(typeof d1=='string')d1=dateutil.str_to_obj(d1);if(typeof d2=='string')d2=dateutil.str_to_obj(d2);return((d1-d2)/86400000);},get_day_diff:function(d1,d2){return dateutil.get_diff(new Date(d1.getYear(),d1.getMonth(),d1.getDate(),0,0),new Date(d2.getYear(),d2.getMonth(),d2.getDate(),0,0))},add_days:function(d,days){dt=dateutil.str_to_obj(d)
dt.setTime(dt.getTime()+(days*24*60*60*1000));return dateutil.obj_to_str(dt);},add_months:function(d,months){dt=dateutil.str_to_obj(d)
wn.datetime={str_to_obj:function(d){if(typeof d=="object")return d;if(!d)return new Date();var tm=[null,null];if(d.search(' ')!=-1){var tm=d.split(' ')[1].split(':');var d=d.split(' ')[0];}
if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else if(d.search('/')!=-1){var t=d.split('/');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else{return new Date();}},obj_to_str:function(d){if(typeof d=='string')return d;return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-'+int_to_str(d.getDate(),2);},obj_to_user:function(d){return dateutil.str_to_user(dateutil.obj_to_str(d));},get_diff:function(d1,d2){if(typeof d1=='string')d1=dateutil.str_to_obj(d1);if(typeof d2=='string')d2=dateutil.str_to_obj(d2);return((d1-d2)/86400000);},get_day_diff:function(d1,d2){return dateutil.get_diff(new Date(d1.getYear(),d1.getMonth(),d1.getDate(),0,0),new Date(d2.getYear(),d2.getMonth(),d2.getDate(),0,0))},add_days:function(d,days){var dt=dateutil.str_to_obj(d);var new_dt=new Date(dt.getTime()+(days*24*60*60*1000));return dateutil.obj_to_str(new_dt);},add_months:function(d,months){dt=dateutil.str_to_obj(d)
new_dt=new Date(dt.getFullYear(),dt.getMonth()+months,dt.getDate())
if(new_dt.getDate()!=dt.getDate()){return dateutil.month_end(new Date(dt.getFullYear(),dt.getMonth()+months,1))}
return dateutil.obj_to_str(new_dt);},month_start:function(){var d=new Date();return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-01';},month_end:function(d){if(!d)var d=new Date();var m=d.getMonth()+1;var y=d.getFullYear();last_date=month_last[m];if(m==2&&(y%4)==0&&((y%100)!=0||(y%400)==0))
@ -582,7 +581,7 @@ wn.urllib={get_arg:function(name){name=name.replace(/[\[]/,"\\\[").replace(/[\]]
return"";else
return decodeURIComponent(results[1]);},get_dict:function(){var d={}
var t=window.location.href.split('?')[1];if(!t)return d;if(t.indexOf('#')!=-1)t=t.split('#')[0];if(!t)return d;t=t.split('&');for(var i=0;i<t.length;i++){var a=t[i].split('=');d[decodeURIComponent(a[0])]=decodeURIComponent(a[1]);}
return d;},get_base_url:function(){var url=window.location.href.split('#')[0].split('?')[0].split('index.cgi')[0];if(url.substr(url.length-1,1)=='/')url=url.substr(0,url.length-1)
return d;},get_base_url:function(){var url=window.location.href.split('#')[0].split('?')[0].split('app.html')[0];if(url.substr(url.length-1,1)=='/')url=url.substr(0,url.length-1)
return url},get_file_url:function(file_id){return repl('files/%(fn)s',{fn:file_id})}}
get_url_arg=wn.urllib.get_arg;get_url_dict=wn.urllib.get_dict;
/*
@ -2270,7 +2269,7 @@ $('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
href="http://erpnext.com" target="_blank"></a>')}
erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);}else{clearInterval(wn.updates.id);}}
wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{erpnext.toolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
wn.updates.id=setInterval(erpnext.update_messages,60000);}

View File

@ -360,9 +360,8 @@ var doc_link=DocLink;function roundNumber(num,dec){var result=Math.round(num*Mat
function same_day(d1,d2){if(d1.getFullYear()==d2.getFullYear()&&d1.getMonth()==d2.getMonth()&&d1.getDate()==d2.getDate())return true;else return false;}
var month_list=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];var month_last={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
var month_list_full=['January','February','March','April','May','June','July','August','September','October','November','December'];var week_list=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];var week_list_full=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];function int_to_str(i,len){i=''+i;if(i.length<len)for(c=0;c<(len-i.length);c++)i='0'+i;return i}
wn.datetime={str_to_obj:function(d){if(!d)return new Date();var tm=[null,null];if(d.search(' ')!=-1){var tm=d.split(' ')[1].split(':');var d=d.split(' ')[0];}
if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else if(d.search('/')!=-1){var t=d.split('/');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else{return new Date();}},obj_to_str:function(d){return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-'+int_to_str(d.getDate(),2);},obj_to_user:function(d){return dateutil.str_to_user(dateutil.obj_to_str(d));},get_diff:function(d1,d2){if(typeof d1=='string')d1=dateutil.str_to_obj(d1);if(typeof d2=='string')d2=dateutil.str_to_obj(d2);return((d1-d2)/86400000);},get_day_diff:function(d1,d2){return dateutil.get_diff(new Date(d1.getYear(),d1.getMonth(),d1.getDate(),0,0),new Date(d2.getYear(),d2.getMonth(),d2.getDate(),0,0))},add_days:function(d,days){dt=dateutil.str_to_obj(d)
dt.setTime(dt.getTime()+(days*24*60*60*1000));return dateutil.obj_to_str(dt);},add_months:function(d,months){dt=dateutil.str_to_obj(d)
wn.datetime={str_to_obj:function(d){if(typeof d=="object")return d;if(!d)return new Date();var tm=[null,null];if(d.search(' ')!=-1){var tm=d.split(' ')[1].split(':');var d=d.split(' ')[0];}
if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else if(d.search('/')!=-1){var t=d.split('/');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else{return new Date();}},obj_to_str:function(d){if(typeof d=='string')return d;return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-'+int_to_str(d.getDate(),2);},obj_to_user:function(d){return dateutil.str_to_user(dateutil.obj_to_str(d));},get_diff:function(d1,d2){if(typeof d1=='string')d1=dateutil.str_to_obj(d1);if(typeof d2=='string')d2=dateutil.str_to_obj(d2);return((d1-d2)/86400000);},get_day_diff:function(d1,d2){return dateutil.get_diff(new Date(d1.getYear(),d1.getMonth(),d1.getDate(),0,0),new Date(d2.getYear(),d2.getMonth(),d2.getDate(),0,0))},add_days:function(d,days){var dt=dateutil.str_to_obj(d);var new_dt=new Date(dt.getTime()+(days*24*60*60*1000));return dateutil.obj_to_str(new_dt);},add_months:function(d,months){dt=dateutil.str_to_obj(d)
new_dt=new Date(dt.getFullYear(),dt.getMonth()+months,dt.getDate())
if(new_dt.getDate()!=dt.getDate()){return dateutil.month_end(new Date(dt.getFullYear(),dt.getMonth()+months,1))}
return dateutil.obj_to_str(new_dt);},month_start:function(){var d=new Date();return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-01';},month_end:function(d){if(!d)var d=new Date();var m=d.getMonth()+1;var y=d.getFullYear();last_date=month_last[m];if(m==2&&(y%4)==0&&((y%100)!=0||(y%400)==0))
@ -469,7 +468,7 @@ wn.urllib={get_arg:function(name){name=name.replace(/[\[]/,"\\\[").replace(/[\]]
return"";else
return decodeURIComponent(results[1]);},get_dict:function(){var d={}
var t=window.location.href.split('?')[1];if(!t)return d;if(t.indexOf('#')!=-1)t=t.split('#')[0];if(!t)return d;t=t.split('&');for(var i=0;i<t.length;i++){var a=t[i].split('=');d[decodeURIComponent(a[0])]=decodeURIComponent(a[1]);}
return d;},get_base_url:function(){var url=window.location.href.split('#')[0].split('?')[0].split('index.cgi')[0];if(url.substr(url.length-1,1)=='/')url=url.substr(0,url.length-1)
return d;},get_base_url:function(){var url=window.location.href.split('#')[0].split('?')[0].split('app.html')[0];if(url.substr(url.length-1,1)=='/')url=url.substr(0,url.length-1)
return url},get_file_url:function(file_id){return repl('files/%(fn)s',{fn:file_id})}}
get_url_arg=wn.urllib.get_arg;get_url_dict=wn.urllib.get_dict;
/*
@ -724,7 +723,7 @@ $('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
href="http://erpnext.com" target="_blank"></a>')}
erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);}else{clearInterval(wn.updates.id);}}
wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{erpnext.toolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
wn.updates.id=setInterval(erpnext.update_messages,60000);}