From c7dbe293c3926741cd8f9e4d9dda9e204920e18e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 12:12:55 +0530 Subject: [PATCH 01/15] updates to kb: unanswered questions show in desktop, questions query moved to server-side --- erpnext/home/page/desktop/desktop.js | 1 + erpnext/startup/startup.js | 1 + erpnext/startup/startup.py | 25 ++++++------- erpnext/utilities/page/kb_common/kb_common.js | 13 +++++++ .../utilities/page/questions/questions.css | 4 ++ erpnext/utilities/page/questions/questions.js | 32 +++++++--------- erpnext/utilities/page/questions/questions.py | 37 ++++++++++++------- public/js/all-app.js | 2 +- public/js/all-web.js | 2 +- public/js/kb_common.js | 4 +- 10 files changed, 73 insertions(+), 48 deletions(-) diff --git a/erpnext/home/page/desktop/desktop.js b/erpnext/home/page/desktop/desktop.js index 0db20fb0c6..9ba5253e41 100644 --- a/erpnext/home/page/desktop/desktop.js +++ b/erpnext/home/page/desktop/desktop.js @@ -126,6 +126,7 @@ erpnext.desktop.show_pending_notifications = function() { add_circle('todo', 'things_todo', 'Things To Do'); add_circle('calendar', 'todays_events', 'Todays Events'); add_circle('project', 'open_tasks', 'Open Tasks'); + add_circle('kb', 'unanswered_questions', 'Unanswered Questions'); erpnext.update_messages(); diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index 9ea3c8959a..60104645b0 100644 --- a/erpnext/startup/startup.js +++ b/erpnext/startup/startup.js @@ -136,6 +136,7 @@ erpnext.update_messages = function(reset) { 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); + show_in_circle('unanswered_questions', r.message.unanswered_questions); } else { clearInterval(wn.updates.id); diff --git a/erpnext/startup/startup.py b/erpnext/startup/startup.py index f21f2519fe..0ae31141fe 100644 --- a/erpnext/startup/startup.py +++ b/erpnext/startup/startup.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals import webnotes def get_unread_messages(): @@ -11,9 +12,7 @@ def get_unread_messages(): """, webnotes.user.name, as_list=1) def get_open_support_tickets(): - """ - Returns a count of open support tickets - """ + """Returns a count of open support tickets""" from webnotes.utils import cint open_support_tickets = webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabSupport Ticket` @@ -21,18 +20,14 @@ def get_open_support_tickets(): return open_support_tickets and cint(open_support_tickets[0][0]) or 0 def get_open_tasks(): - """ - Returns a count of 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 - """ + """Returns a count of incomplete todos""" from webnotes.utils import cint incomplete_todos = webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabToDo` @@ -41,9 +36,7 @@ def get_things_todo(): return incomplete_todos and cint(incomplete_todos[0][0]) or 0 def get_todays_events(): - """ - Returns a count of todays events in calendar - """ + """Returns a count of todays events in calendar""" from webnotes.utils import nowdate, cint todays_events = webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabEvent` @@ -53,6 +46,11 @@ def get_todays_events(): webnotes.session.get('user'), nowdate())) return todays_events and cint(todays_events[0][0]) or 0 +def get_unanswered_questions(): + return len(filter(lambda d: d[0]==0, + webnotes.conn.sql("""select (select count(*) from tabAnswer + where tabAnswer.question = tabQuestion.name) as answers from tabQuestion"""))) + @webnotes.whitelist() def get_global_status_messages(arg=None): return { @@ -60,5 +58,6 @@ 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() + 'open_tasks': get_open_tasks(), + 'unanswered_questions': get_unanswered_questions() } diff --git a/erpnext/utilities/page/kb_common/kb_common.js b/erpnext/utilities/page/kb_common/kb_common.js index d77a938e0e..a135612d7e 100644 --- a/erpnext/utilities/page/kb_common/kb_common.js +++ b/erpnext/utilities/page/kb_common/kb_common.js @@ -25,6 +25,7 @@ KBItemToolbar = function(args, kb) { this.wrapper = $a(this.parent, 'div', '', {}); this.line1 = $a(this.wrapper, 'div', '', {color: '#888', fontSize:'11px', margin:'7px 0px'}); this.make_timestamp(); + this.make_answers(); if(this.with_tags) this.make_tags(); this.setup_del(); @@ -43,6 +44,18 @@ KBItemToolbar = function(args, kb) { } } + this.make_answers = function() { + if(this.doctype=='Question') { + if(this.det.answers==0) { + this.line1.innerHTML += ' | no answers'; + } else if(this.det.answers==1) { + this.line1.innerHTML += ' | 1 answer'; + } else { + this.line1.innerHTML += ' | '+this.det.answers+' answers'; + } + } + } + this.make_tags = function() { this.line1.innerHTML += ' | ' this.tags_area = $a(this.line1, 'span', 'kb-tags') diff --git a/erpnext/utilities/page/questions/questions.css b/erpnext/utilities/page/questions/questions.css index 52e8a38f2e..779da5505e 100644 --- a/erpnext/utilities/page/questions/questions.css +++ b/erpnext/utilities/page/questions/questions.css @@ -14,6 +14,10 @@ div.kb-search-wrapper textarea { .kb-questions { } +.un-answered { + color: #f33; +} + .kb-question-details { margin: 11px 0px 11px 29px; } diff --git a/erpnext/utilities/page/questions/questions.js b/erpnext/utilities/page/questions/questions.js index 048ed54bb6..22a70d8f41 100644 --- a/erpnext/utilities/page/questions/questions.js +++ b/erpnext/utilities/page/questions/questions.js @@ -115,24 +115,16 @@ function KnowledgeBase(w) { no_results_message: 'No questions found. Ask a new question!', appframe: wn.pages.questions.appframe, as_dict: 1, - get_query: function() { - - // filter by search string - var v = me.search.value==$(me.search).attr('default_text') ? '' : me.search.value; - cond = v ? (' and t1.question like "%'+v+'%"') : ''; - - // filter by tags - if(me.tag_filter_dict) { - for(f in me.tag_filter_dict) { - cond += ' and t1.`_user_tags` like "%' + f + '%"' - } + method: 'utilities.page.questions.questions.get_questions', + get_args: function() { + var args = {}; + if(me.search.value) { + args.search_text = me.search.value; } - return repl('select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags, ' - +'t1._users_voted, t2.first_name, t2.last_name ' - +'from tabQuestion t1, tabProfile t2 ' - +'where t1.docstatus!=2 ' - +'and t1.owner = t2.name' - +'%(cond)s order by t1.modified desc', {user:user, cond: cond}) + if(me.tag_filter_dict) { + args.tag_filters = keys(me.tag_filter_dict); + } + return args }, render_row: function(parent, data, listing) { new KBQuestion(parent, data, me); @@ -196,7 +188,11 @@ KBQuestion = function(parent, det, kb) { this.make = function() { this.wrapper = $a(parent, 'div', 'kb-question-wrapper'); - this.q_area = $a($a(this.wrapper, 'div'), 'h3', 'kb-questions link_type', {display:'inline', textDecoration:'none'}, det.question); + this.q_area = $a($a(this.wrapper, 'div'), 'h3', + 'kb-questions link_type', {display:'inline', textDecoration:'none'}, det.question); + if(det.answers==0) { + $(this.q_area).addClass('un-answered') + } this.q_area.onclick = function() { var q = this; diff --git a/erpnext/utilities/page/questions/questions.py b/erpnext/utilities/page/questions/questions.py index 52b80fe280..bd9efc7385 100644 --- a/erpnext/utilities/page/questions/questions.py +++ b/erpnext/utilities/page/questions/questions.py @@ -19,6 +19,29 @@ import webnotes from webnotes.utils import load_json, cint, cstr import json +@webnotes.whitelist() +def get_questions(): + """get list of questions""" + import json + conds = '' + + if 'search_text' in webnotes.form_dict: + conds = ' and t1.question like "%'+ webnotes.form_dict['search_text'] + '%"' + + if 'tag_filters' in webnotes.form_dict: + tag_filters = json.loads(webnotes.form_dict['tag_filters']) + for t in tag_filters: + conds += ' and t1._user_tags like "%'+ t +'%"' + + return webnotes.conn.sql("""select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags, + t2.first_name, t2.last_name, (select count(*) from tabAnswer where + tabAnswer.question = t1.name) as answers + from tabQuestion t1, tabProfile t2 + where t1.docstatus!=2 + and t1.owner = t2.name + %(conds)s + order by t1.modified desc""" % {"conds":conds}, as_dict=1) + # add a new question @webnotes.whitelist() def add_question(arg): @@ -39,20 +62,6 @@ def add_question(arg): 'txt': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question, 'notify': 1 })) - -@webnotes.whitelist() -def vote(arg): - args = load_json(arg) - - res = webnotes.conn.sql("select points, _users_voted from `tab%s` where name=%s" % (args['dt'], '%s'), args['dn'])[0] - p = cint(res[0]) - p = args['vote']=='up' and p+1 or p-1 - - # update - webnotes.conn.sql("update `tab%s` set points=%s, _users_voted=%s where name=%s" % (args['dt'], '%s', '%s', '%s'), \ - (p, cstr(res[1]) + ',' + webnotes.user.name, args['dn'])) - - return p @webnotes.whitelist() def delete(arg): diff --git a/public/js/all-app.js b/public/js/all-app.js index 3c50ed2ebd..6d6c820aa4 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -2258,7 +2258,7 @@ $('body').append('')} 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);show_in_circle('open_tasks',r.message.open_tasks);}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);show_in_circle('unanswered_questions',r.message.unanswered_questions);}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);} diff --git a/public/js/all-web.js b/public/js/all-web.js index c52a51ad3f..44860f4a37 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -726,7 +726,7 @@ $('body').append('')} 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);show_in_circle('open_tasks',r.message.open_tasks);}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);show_in_circle('unanswered_questions',r.message.unanswered_questions);}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);} diff --git a/public/js/kb_common.js b/public/js/kb_common.js index e61b5ef91b..d478cac368 100644 --- a/public/js/kb_common.js +++ b/public/js/kb_common.js @@ -2,10 +2,12 @@ /* * erpnext/utilities/page/kb_common/kb_common.js */ -KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=function(){this.wrapper=$a(this.parent,'div','',{});this.line1=$a(this.wrapper,'div','',{color:'#888',fontSize:'11px',margin:'7px 0px'});this.make_timestamp();if(this.with_tags) +KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=function(){this.wrapper=$a(this.parent,'div','',{});this.line1=$a(this.wrapper,'div','',{color:'#888',fontSize:'11px',margin:'7px 0px'});this.make_timestamp();this.make_answers();if(this.with_tags) this.make_tags();this.setup_del();} this.make_timestamp=function(){this.line1.innerHTML=repl('By %(name)s | %(when)s',{name:wn.utils.full_name(this.det.first_name,this.det.last_name),when:wn.datetime.comment_when(this.det.modified)});if(has_common(user_roles,['Administrator','System Manager'])){this.line1.innerHTML+=' | delete';}} +this.make_answers=function(){if(this.doctype=='Question') +this.line1.innerHTML+=' | '+this.det.answers+' answers'} this.make_tags=function(){this.line1.innerHTML+=' | ' this.tags_area=$a(this.line1,'span','kb-tags') this.tags=new TagList(this.tags_area,this.det._user_tags&&(this.det._user_tags.split(',')),this.doctype,this.det.name,0,kb.set_tag_filter)} From e6ecb0600159c2c1204aa167f1d52f6767d0a99c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 12:48:41 +0530 Subject: [PATCH 02/15] added markdown reference page --- .../page/markdown_reference/__init__.py | 0 .../markdown_reference/markdown_reference.css | 0 .../markdown_reference.html | 150 ++++++++++++++++++ .../markdown_reference/markdown_reference.js | 1 + .../markdown_reference/markdown_reference.py | 1 + .../markdown_reference/markdown_reference.txt | 28 ++++ 6 files changed, 180 insertions(+) create mode 100644 erpnext/utilities/page/markdown_reference/__init__.py create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.css create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.html create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.js create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.py create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.txt diff --git a/erpnext/utilities/page/markdown_reference/__init__.py b/erpnext/utilities/page/markdown_reference/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.css b/erpnext/utilities/page/markdown_reference/markdown_reference.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.html b/erpnext/utilities/page/markdown_reference/markdown_reference.html new file mode 100644 index 0000000000..5af414f275 --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.html @@ -0,0 +1,150 @@ +
+
+
+ Markdown Reference + × +
+
+
+
+

Phrase Emphasis

+
*italic*   **bold**
+_italic_   __bold__
+
+ +

Links

+ +

Inline:

+ +
An [example](http://url.com/ "Title")
+
+ +

Reference-style labels (titles are optional):

+ +
An [example][id]. Then, anywhere
+else in the doc, define the link:
+
+   [id]: http://example.com/  "Title"
+
+ +

Images

+ +

Inline (titles are optional):

+ +
![alt text](/path/img.jpg "Title")
+
+ +

Reference-style:

+ +
![alt text][id]
+
+    [id]: /url/to/img.jpg "Title"
+
+ +

Headers

+ +

Setext-style:

+ +
Header 1
+========
+
+Header 2
+--------
+
+
+ +

atx-style (closing #'s are optional):

+ +
# Header 1 #
+
+
+
+ +

Lists

+ +

Ordered, without paragraphs:

+ +
1.  Foo
+2.  Bar
+
+ +

Unordered, with paragraphs:

+ +
*   A list item.
+
+    With multiple paragraphs.
+
+*   Bar
+
+ +

You can nest them:

+ +
*   Abacus
+    * ass
+*   Bastard
+    1.  bitch
+    2.  bupkis
+        * BELITTLER
+    3. burper
+*   Cunning
+
+ +

Blockquotes

+ +
> Email-style angle brackets
+
+> are used for blockquotes.
+
+> > And, they can be nested.
+
+> >
+> * You can quote a list.
+> * Etc.
+
+ +

Code Spans

+ +
`<code>` spans are delimited
+by backticks.
+
+You can include literal backticks
+like `` `this` ``.
+
+ +

Preformatted Code Blocks

+ +

Indent every line of a code block by at least 4 spaces or 1 tab, and use a colon at the end of the preceding paragraph.

+ +
This is a normal paragraph:
+
+    This is a preformatted
+    code block.
+
+Preceded by a space, the colon
+disappears. :
+
+    This is a preformatted
+    code block.
+
+ +

Horizontal Rules

+ +

Three or more dashes or asterisks:

+ +
---
+
+* * *
+
+- - - -
+
+ +

Manual Line Breaks

+ +

End a line with two or more spaces:

+ +
Roses are red,
+Violets are blue.
+
+
+
+
\ No newline at end of file diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.js b/erpnext/utilities/page/markdown_reference/markdown_reference.js new file mode 100644 index 0000000000..8e8fbac2c9 --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.js @@ -0,0 +1 @@ +wn.pages['markdown-reference'].onload = function(wrapper) { } \ No newline at end of file diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.py b/erpnext/utilities/page/markdown_reference/markdown_reference.py new file mode 100644 index 0000000000..f807eb0a4d --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.py @@ -0,0 +1 @@ +import webnotes \ No newline at end of file diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.txt b/erpnext/utilities/page/markdown_reference/markdown_reference.txt new file mode 100644 index 0000000000..304f2e3de9 --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.txt @@ -0,0 +1,28 @@ +# Page, markdown-reference +[ + + # These values are common in all dictionaries + { + 'creation': '2012-08-07 12:35:30', + 'docstatus': 0, + 'modified': '2012-08-07 12:35:30', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Page + { + 'doctype': 'Page', + 'module': u'Utilities', + 'name': '__common__', + 'page_name': u'Markdown Reference', + 'standard': u'Yes', + 'title': u'Markdown Reference' + }, + + # Page, markdown-reference + { + 'doctype': 'Page', + 'name': u'markdown-reference' + } +] \ No newline at end of file From 6252c13ec850b564f9fcec3060b9fa88b440b263 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 12:53:49 +0530 Subject: [PATCH 03/15] added code style and mardown in todo --- erpnext/utilities/page/kb_common/kb_common.js | 2 +- erpnext/utilities/page/questions/questions.py | 2 +- erpnext/utilities/page/todo/todo.js | 6 ++++-- erpnext/utilities/page/todo/todo.py | 1 + public/css/all-app.css | 20 ++++++++++++++++++- public/css/all-web.css | 20 ++++++++++++++++++- public/js/all-app.js | 2 +- public/js/kb_common.js | 3 +-- 8 files changed, 47 insertions(+), 9 deletions(-) diff --git a/erpnext/utilities/page/kb_common/kb_common.js b/erpnext/utilities/page/kb_common/kb_common.js index a135612d7e..9d6b7e8e0b 100644 --- a/erpnext/utilities/page/kb_common/kb_common.js +++ b/erpnext/utilities/page/kb_common/kb_common.js @@ -93,7 +93,7 @@ EditableText = function(args) {
\ [edit]\ \ - \ \ Cancel\ diff --git a/erpnext/utilities/page/questions/questions.py b/erpnext/utilities/page/questions/questions.py index bd9efc7385..7420d5f8c9 100644 --- a/erpnext/utilities/page/questions/questions.py +++ b/erpnext/utilities/page/questions/questions.py @@ -49,7 +49,7 @@ def add_question(arg): from webnotes.model.doc import Document d = Document('Question') - d.question = args['question'].title() + d.question = args['question'] d.points = 1 d.save(1) diff --git a/erpnext/utilities/page/todo/todo.js b/erpnext/utilities/page/todo/todo.js index 786e757e29..1ab8982778 100644 --- a/erpnext/utilities/page/todo/todo.js +++ b/erpnext/utilities/page/todo/todo.js @@ -89,7 +89,7 @@ erpnext.todo.ToDoItem = Class.extend({ } if(!todo.description) todo.description = ''; - todo.desc = todo.description.replace(/\n/g, "
"); + todo.desc = wn.markdown(todo.description); $(parent_list).append(repl('\
\ @@ -145,7 +145,9 @@ erpnext.todo.make_dialog = function(det) { title: 'To Do', fields: [ {fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, - {fieldtype:'Text', fieldname:'description', label:'Description', reqd:1}, + {fieldtype:'Text', fieldname:'description', label:'Description', + reqd:1, description:'Use markdown to \ + format content'}, {fieldtype:'Check', fieldname:'checked', label:'Completed'}, {fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')}, {fieldtype:'Button', fieldname:'save', label:'Save'} diff --git a/erpnext/utilities/page/todo/todo.py b/erpnext/utilities/page/todo/todo.py index 1b54478eca..05c695d248 100644 --- a/erpnext/utilities/page/todo/todo.py +++ b/erpnext/utilities/page/todo/todo.py @@ -28,6 +28,7 @@ def get(arg=None): @webnotes.whitelist() def edit(arg=None): + import markdown2 args = webnotes.form_dict d = Document('ToDo', args.get('name') or None) diff --git a/public/css/all-app.css b/public/css/all-app.css index ecdbe652f9..f120a8bd73 100644 --- a/public/css/all-app.css +++ b/public/css/all-app.css @@ -1969,7 +1969,25 @@ span, div, td, input, textarea, button, select { } -pre { margin: 0px; padding: 0px; } +pre { + background-color: #F5F5F5; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px 4px 4px 4px; + display: block; + font-size: 12.025px; + line-height: 18px; + margin: 0 0 15px; + padding: 8.5px; + white-space: pre-wrap; + word-wrap: break-word; +} + +code, pre { + border-radius: 3px 3px 3px 3px; + color: #333333; + font-family: Menlo,Monaco,Consolas,"Courier New",monospace; + font-size: 12px; +} button { margin: 2px; margin-left: 0px; } diff --git a/public/css/all-web.css b/public/css/all-web.css index 332471b01b..b27a7dac47 100644 --- a/public/css/all-web.css +++ b/public/css/all-web.css @@ -1830,7 +1830,25 @@ span, div, td, input, textarea, button, select { } -pre { margin: 0px; padding: 0px; } +pre { + background-color: #F5F5F5; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px 4px 4px 4px; + display: block; + font-size: 12.025px; + line-height: 18px; + margin: 0 0 15px; + padding: 8.5px; + white-space: pre-wrap; + word-wrap: break-word; +} + +code, pre { + border-radius: 3px 3px 3px 3px; + color: #333333; + font-family: Menlo,Monaco,Consolas,"Courier New",monospace; + font-size: 12px; +} button { margin: 2px; margin-left: 0px; } diff --git a/public/js/all-app.js b/public/js/all-app.js index 6d6c820aa4..0620d3b0d6 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1895,7 +1895,7 @@ if(cur_frm.editable&&cur_frm.doc.docstatus>0){if(this.df.allow_on_submit&&cur_fr if(this.df['default'].toLowerCase()=='no add rows'){this.grid.can_add_rows=false;}} if(st=='Write'){this.grid.show();}else if(st=='Read'){this.grid.show();}else{this.grid.hide();} this.grid.refresh();} -_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"js/lib/tiny_mce_33/custom_content.css",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} +_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"js/lib/tiny_mce_33/custom_content.css?q=1",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} this.input.onchange=function(){me.set(me.editor.getContent());me.run_trigger();} this.get_value=function(){return me.editor.getContent();}}else{wn.require('js/lib/ace/ace.js');$(this.input_area).css('border','1px solid #aaa');this.pre=$a(this.input_area,'pre','',{position:'relative',height:'400px',width:'100%'});this.input={};this.myid=wn.dom.set_unique_id(this.pre);this.editor=ace.edit(this.myid);if(me.df.options=='Markdown'||me.df.options=='HTML'){wn.require('js/lib/ace/mode-html.js');var HTMLMode=require("ace/mode/html").Mode;me.editor.getSession().setMode(new HTMLMode());} else if(me.df.options=='Javascript'){wn.require('js/lib/ace/mode-javascript.js');var JavascriptMode=require("ace/mode/javascript").Mode;me.editor.getSession().setMode(new JavascriptMode());} diff --git a/public/js/kb_common.js b/public/js/kb_common.js index d478cac368..bbd57f10e6 100644 --- a/public/js/kb_common.js +++ b/public/js/kb_common.js @@ -6,8 +6,7 @@ KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=functi this.make_tags();this.setup_del();} this.make_timestamp=function(){this.line1.innerHTML=repl('By %(name)s | %(when)s',{name:wn.utils.full_name(this.det.first_name,this.det.last_name),when:wn.datetime.comment_when(this.det.modified)});if(has_common(user_roles,['Administrator','System Manager'])){this.line1.innerHTML+=' | delete';}} -this.make_answers=function(){if(this.doctype=='Question') -this.line1.innerHTML+=' | '+this.det.answers+' answers'} +this.make_answers=function(){if(this.doctype=='Question'){if(this.det.answers==0){this.line1.innerHTML+=' | no answers';}else if(this.det.answers==1){this.line1.innerHTML+=' | 1 answer';}else{this.line1.innerHTML+=' | '+this.det.answers+' answers';}}} this.make_tags=function(){this.line1.innerHTML+=' | ' this.tags_area=$a(this.line1,'span','kb-tags') this.tags=new TagList(this.tags_area,this.det._user_tags&&(this.det._user_tags.split(',')),this.doctype,this.det.name,0,kb.set_tag_filter)} From e30d5f833e87e8f115636cf40cd8d94824695910 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:05:42 +0530 Subject: [PATCH 04/15] New Report: Supplier Quotations --- .../Supplier Quotations.txt | 26 +++++++++++++++++++ erpnext/patches/august_2012/__init__.py | 0 .../august_2012/report_supplier_quotations.py | 3 +++ erpnext/patches/patch_list.py | 4 +++ 4 files changed, 33 insertions(+) create mode 100644 erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt create mode 100644 erpnext/patches/august_2012/__init__.py create mode 100644 erpnext/patches/august_2012/report_supplier_quotations.py diff --git a/erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt b/erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt new file mode 100644 index 0000000000..860a432810 --- /dev/null +++ b/erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt @@ -0,0 +1,26 @@ +# Report, Supplier Quotations +[ + + # These values are common in all dictionaries + { + 'creation': '2012-08-07 14:52:42', + 'docstatus': 0, + 'modified': '2012-08-07 14:57:57', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Report + { + 'doctype': 'Report', + 'json': u'{"filters":[["Supplier Quotation","supplier","like","%%"],["Supplier Quotation Item","item_code","like","%%"]],"columns":[["name","Supplier Quotation"],["supplier","Supplier Quotation"],["item_code","Supplier Quotation Item"],["description","Supplier Quotation Item"],["qty","Supplier Quotation Item"],["currency","Supplier Quotation"],["import_rate","Supplier Quotation Item"],["import_amount","Supplier Quotation Item"]],"sort_by":"modified","sort_order":"desc","sort_by_next":"name","sort_order_next":"desc"}', + 'name': '__common__', + 'ref_doctype': u'Supplier Quotation' + }, + + # Report, Supplier Quotations + { + 'doctype': 'Report', + 'name': u'Supplier Quotations' + } +] \ No newline at end of file diff --git a/erpnext/patches/august_2012/__init__.py b/erpnext/patches/august_2012/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/august_2012/report_supplier_quotations.py b/erpnext/patches/august_2012/report_supplier_quotations.py new file mode 100644 index 0000000000..bb0347910b --- /dev/null +++ b/erpnext/patches/august_2012/report_supplier_quotations.py @@ -0,0 +1,3 @@ +def execute(): + from webnotes.modules import reload_doc + reload_doc("buying", "Report", "Supplier Quotations") \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index f512bfc0e3..83da5c3fa3 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -517,4 +517,8 @@ patch_list = [ 'patch_module': 'patches.july_2012', 'patch_file': 'supplier_quotation', }, + { + 'patch_module': 'patches.august_2012', + 'patch_file': 'report_supplier_quotations', + }, ] \ No newline at end of file From 883285f5036d5812f7808a97bcd2cdeab456cb49 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:13:48 +0530 Subject: [PATCH 05/15] fix in supplier quotations patch --- erpnext/patches/august_2012/report_supplier_quotations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches/august_2012/report_supplier_quotations.py b/erpnext/patches/august_2012/report_supplier_quotations.py index bb0347910b..c0e6b3cf54 100644 --- a/erpnext/patches/august_2012/report_supplier_quotations.py +++ b/erpnext/patches/august_2012/report_supplier_quotations.py @@ -1,3 +1,3 @@ def execute(): from webnotes.modules import reload_doc - reload_doc("buying", "Report", "Supplier Quotations") \ No newline at end of file + reload_doc("Buying", "Report", "Supplier Quotations") \ No newline at end of file From df196c12a9306444e7fd3b601a20f019b191b387 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 16:35:27 +0530 Subject: [PATCH 06/15] projects: milestones have events, tasks have events with better description --- erpnext/projects/doctype/project/project.py | 135 +++++---- erpnext/projects/doctype/project/project.txt | 276 +++++++++---------- erpnext/projects/doctype/task/task.py | 2 +- 3 files changed, 203 insertions(+), 210 deletions(-) diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index b6fb9a8aac..3db66f050d 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -8,11 +8,11 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # Please edit this list and import only required elements import webnotes @@ -34,59 +34,78 @@ convert_to_lists = webnotes.conn.convert_to_lists class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - - # Get Customer Details along with its primary contact details - # ============================================================== - def get_customer_details(self): - details =sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1) - if details: - ret = { - 'customer_address' : details and details[0]['address'] or '', - 'territory' : details and details[0]['territory'] or '', - 'customer_group' : details and details[0]['customer_group'] or '', - 'customer_name' : details and details[0]['customer_name'] or '' - } - #get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details) - contact_det = sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1) - ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or '' - ret['contact_no'] = contact_det and contact_det[0]['phone'] or '' - ret['email_id'] = contact_det and contact_det[0]['email_id'] or '' - return ret - else: - msgprint("Customer : %s does not exist in system." % (self.doc.customer)) - raise Exception - - # Get customer's contact person details - # ============================================================== - def get_contact_details(self): - contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s' and docstatus != 2" %(self.doc,contact_person,self.doc.customer), as_dict=1) - if contact: - ret = { - 'contact_no' : contact and contact[0]['contact_no'] or '', - 'email_id' : contact and contact[0]['email_id'] or '' - } - return ret - else: - msgprint("Contact Person : %s does not exist in the system." % (self.doc,contact_person)) - raise Exception - - #calculate gross profit - #============================================= - def get_gross_profit(self): - pft, per_pft =0, 0 - pft = flt(self.doc.project_value) - flt(self.doc.est_material_cost) - #if pft > 0: - per_pft = (flt(pft) / flt(self.doc.project_value)) * 100 - ret = {'gross_margin_value': pft, 'per_gross_margin': per_pft} - return ret - - # validate - #================================================ - def validate(self): - if self.doc.project_start_date and self.doc.completion_date: - if getdate(self.doc.completion_date) < getdate(self.doc.project_start_date): - msgprint("Expected Completion Date can not be less than Project Start Date") - raise Exception + def __init__(self, doc, doclist=[]): + self.doc = doc + self.doclist = doclist + + # Get Customer Details along with its primary contact details + # ============================================================== + def get_customer_details(self): + details =sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1) + if details: + ret = { + 'customer_address' : details and details[0]['address'] or '', + 'territory' : details and details[0]['territory'] or '', + 'customer_group' : details and details[0]['customer_group'] or '', + 'customer_name' : details and details[0]['customer_name'] or '' + } + #get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details) + contact_det = sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1) + ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or '' + ret['contact_no'] = contact_det and contact_det[0]['phone'] or '' + ret['email_id'] = contact_det and contact_det[0]['email_id'] or '' + return ret + else: + msgprint("Customer : %s does not exist in system." % (self.doc.customer)) + raise Exception + + # Get customer's contact person details + # ============================================================== + def get_contact_details(self): + contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s' and docstatus != 2" %(self.doc,contact_person,self.doc.customer), as_dict=1) + if contact: + ret = { + 'contact_no' : contact and contact[0]['contact_no'] or '', + 'email_id' : contact and contact[0]['email_id'] or '' + } + return ret + else: + msgprint("Contact Person : %s does not exist in the system." % (self.doc,contact_person)) + raise Exception + + #calculate gross profit + #============================================= + def get_gross_profit(self): + pft, per_pft =0, 0 + pft = flt(self.doc.project_value) - flt(self.doc.est_material_cost) + #if pft > 0: + per_pft = (flt(pft) / flt(self.doc.project_value)) * 100 + ret = {'gross_margin_value': pft, 'per_gross_margin': per_pft} + return ret + + # validate + #================================================ + def validate(self): + if self.doc.project_start_date and self.doc.completion_date: + if getdate(self.doc.completion_date) < getdate(self.doc.project_start_date): + msgprint("Expected Completion Date can not be less than Project Start Date") + raise Exception + + def on_update(self): + # update milestones + webnotes.conn.sql("""delete from tabEvent where ref_type='Project' and ref_name=%s""", + self.doc.name) + for d in self.doclist: + if d.doctype=='Project Milestone' and d.docstatus!=2: + self.add_calendar_event(d.milestone, d.milestone_date) + + def add_calendar_event(self, milestone, date): + """ Add calendar event for task in calendar of Allocated person""" + event = Document('Event') + event.description = milestone + ' for ' + self.doc.name + event.event_date = date + event.event_hour = '10:00' + event.event_type = 'Public' + event.ref_type = 'Project' + event.ref_name = self.doc.name + event.save(1) \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.txt b/erpnext/projects/doctype/project/project.txt index 527201e17d..43cab3958e 100644 --- a/erpnext/projects/doctype/project/project.txt +++ b/erpnext/projects/doctype/project/project.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-03-27 14:36:05', + 'creation': '2012-05-03 18:41:42', 'docstatus': 0, - 'modified': '2012-03-27 14:36:05', + 'modified': '2012-08-07 15:48:47', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -29,7 +29,7 @@ 'show_in_menu': 0, 'subject': u' ', 'tag_fields': u'status', - 'version': 33 + 'version': 1 }, # These values are common for all DocField @@ -43,12 +43,17 @@ # These values are common for all DocPerm { + 'cancel': 1, + 'create': 1, 'doctype': u'DocPerm', 'name': '__common__', 'parent': u'Project', 'parentfield': u'permissions', 'parenttype': u'DocType', - 'read': 1 + 'permlevel': 0, + 'read': 1, + 'role': u'Projects User', + 'write': 1 }, # DocType, Project @@ -59,33 +64,7 @@ # DocPerm { - 'amend': 0, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'All', - 'submit': 0, - 'write': 1 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Projects User', - 'submit': 0, - 'write': 1 - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'All' + 'doctype': u'DocPerm' }, # DocField @@ -100,6 +79,15 @@ 'permlevel': 0 }, + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'cb_project_status', + 'fieldtype': u'Column Break', + 'label': u'Status', + 'permlevel': 0 + }, + # DocField { 'description': u'Project will get saved and will be searchable with project name given', @@ -163,71 +151,10 @@ # DocField { 'doctype': u'DocField', - 'fieldname': u'project_value', - 'fieldtype': u'Currency', - 'label': u'Project Value', - 'no_copy': 0, - 'oldfieldname': u'project_value', - 'oldfieldtype': u'Currency', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'gross_margin_value', - 'fieldtype': u'Currency', - 'label': u'Gross Margin Value', - 'no_copy': 0, - 'oldfieldname': u'gross_margin_value', - 'oldfieldtype': u'Currency', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'per_gross_margin', - 'fieldtype': u'Currency', - 'label': u'Gross Margin %', - 'no_copy': 0, - 'oldfieldname': u'per_gross_margin', - 'oldfieldtype': u'Currency', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'est_material_cost', - 'fieldtype': u'Currency', - 'label': u'Estimated Material Cost', - 'no_copy': 0, - 'oldfieldname': u'est_material_cost', - 'oldfieldtype': u'Currency', - 'permlevel': 0, - 'search_index': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'project_type', - 'fieldtype': u'Data', - 'label': u'Project Type', - 'no_copy': 0, - 'oldfieldname': u'project_type', - 'oldfieldtype': u'Data', - 'permlevel': 0, - 'search_index': 0 + 'fieldname': u'cb_project_dates', + 'fieldtype': u'Column Break', + 'label': u'Dates', + 'permlevel': 0 }, # DocField @@ -273,51 +200,41 @@ # DocField { 'doctype': u'DocField', - 'fieldname': u'amended_from', - 'fieldtype': u'Data', - 'hidden': 1, - 'label': u'Amended From', - 'no_copy': 1, - 'oldfieldname': u'amended_from', + 'fieldname': u'project_type', + 'fieldtype': u'Select', + 'label': u'Project Type', + 'no_copy': 0, + 'oldfieldname': u'project_type', 'oldfieldtype': u'Data', - 'permlevel': 1, - 'print_hide': 0, + 'options': u'Internal\nExternal\nOther', + 'permlevel': 0, 'search_index': 0 }, # DocField { + 'colour': u'White:FFF', + 'description': u'Important dates and commitments in your project life cycle', 'doctype': u'DocField', - 'fieldname': u'amemdment_date', - 'fieldtype': u'Date', - 'hidden': 1, - 'label': u'Amemdment Date', - 'no_copy': 1, - 'oldfieldname': u'amemdment_date', - 'oldfieldtype': u'Date', - 'permlevel': 1, - 'search_index': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'project_details', + 'fieldname': u'sb_milestones', 'fieldtype': u'Section Break', - 'label': u'Project Details', + 'label': u'Milestones', 'oldfieldtype': u'Section Break', - 'options': u'Simple', 'permlevel': 0 }, # DocField { 'doctype': u'DocField', - 'fieldname': u'column_break0', - 'fieldtype': u'Column Break', - 'oldfieldtype': u'Column Break', + 'fieldname': u'project_milestones', + 'fieldtype': u'Table', + 'label': u'Project Milestones', + 'no_copy': 0, + 'oldfieldname': u'project_milestones', + 'oldfieldtype': u'Table', + 'options': u'Project Milestone', 'permlevel': 0, - 'width': u'50%' + 'search_index': 0 }, # DocField @@ -325,6 +242,7 @@ 'doctype': u'DocField', 'fieldname': u'section_break0', 'fieldtype': u'Section Break', + 'label': u'Project Details', 'oldfieldtype': u'Section Break', 'options': u'Simple', 'permlevel': 0 @@ -343,6 +261,85 @@ 'search_index': 0 }, + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'project_details', + 'fieldtype': u'Section Break', + 'label': u'Project Costing', + 'oldfieldtype': u'Section Break', + 'options': u'Simple', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'project_value', + 'fieldtype': u'Currency', + 'label': u'Project Value', + 'no_copy': 0, + 'oldfieldname': u'project_value', + 'oldfieldtype': u'Currency', + 'permlevel': 0, + 'reqd': 1, + 'search_index': 0, + 'trigger': u'Client' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'est_material_cost', + 'fieldtype': u'Currency', + 'label': u'Estimated Material Cost', + 'no_copy': 0, + 'oldfieldname': u'est_material_cost', + 'oldfieldtype': u'Currency', + 'permlevel': 0, + 'search_index': 0, + 'trigger': u'Client' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'column_break0', + 'fieldtype': u'Column Break', + 'label': u'Margin', + 'oldfieldtype': u'Column Break', + 'permlevel': 0, + 'width': u'50%' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'gross_margin_value', + 'fieldtype': u'Currency', + 'label': u'Gross Margin Value', + 'no_copy': 0, + 'oldfieldname': u'gross_margin_value', + 'oldfieldtype': u'Currency', + 'permlevel': 0, + 'reqd': 1, + 'search_index': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'per_gross_margin', + 'fieldtype': u'Currency', + 'label': u'Gross Margin %', + 'no_copy': 0, + 'oldfieldname': u'per_gross_margin', + 'oldfieldtype': u'Currency', + 'permlevel': 0, + 'reqd': 1, + 'search_index': 0 + }, + # DocField { 'doctype': u'DocField', @@ -474,32 +471,6 @@ 'search_index': 0 }, - # DocField - { - 'colour': u'White:FFF', - 'description': u'Important dates and commitments in your project life cycle', - 'doctype': u'DocField', - 'fieldname': u'milestones', - 'fieldtype': u'Section Break', - 'label': u'Milestones', - 'oldfieldtype': u'Section Break', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'project_milestones', - 'fieldtype': u'Table', - 'label': u'Project Milestones', - 'no_copy': 0, - 'oldfieldname': u'project_milestones', - 'oldfieldtype': u'Table', - 'options': u'Project Milestone', - 'permlevel': 0, - 'search_index': 0 - }, - # DocField { 'doctype': u'DocField', @@ -517,12 +488,15 @@ # DocField { + 'colour': u'White:FFF', 'doctype': u'DocField', 'fieldname': u'file_list', 'fieldtype': u'Small Text', + 'hidden': 1, 'label': u'File List', 'no_copy': 1, 'permlevel': 0, + 'print_hide': 1, 'search_index': 0 } ] \ No newline at end of file diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index bfd98db127..7f023ca41f 100644 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -216,7 +216,7 @@ class DocType: """ Add calendar event for task in calendar of Allocated person""" event = Document('Event') event.owner = self.doc.allocated_to - event.description = self.doc.name + event.description = self.doc.subject event.event_date = self.doc.exp_start_date and self.doc.exp_start_date or '' event.event_hour = self.doc.event_hour and self.doc.event_hour or '10:00' event.event_type = 'Private' From c2ef064ebb7b702a7bb1f8128dd643635733c238 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 16:36:10 +0530 Subject: [PATCH 07/15] todo page background bugfix --- erpnext/utilities/page/todo/todo.css | 2 +- erpnext/utilities/page/todo/todo.html | 2 +- erpnext/utilities/page/todo/todo.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/utilities/page/todo/todo.css b/erpnext/utilities/page/todo/todo.css index 7c7dcaf23d..9fe595587a 100644 --- a/erpnext/utilities/page/todo/todo.css +++ b/erpnext/utilities/page/todo/todo.css @@ -49,7 +49,7 @@ padding-right: 15px; } -.layout-main { +.todo-layout { background-color: #FFFDC9; min-height: 300px; } \ No newline at end of file diff --git a/erpnext/utilities/page/todo/todo.html b/erpnext/utilities/page/todo/todo.html index 88dcbf3759..37b07a8bcd 100644 --- a/erpnext/utilities/page/todo/todo.html +++ b/erpnext/utilities/page/todo/todo.html @@ -1,6 +1,6 @@
-
+

My List


diff --git a/erpnext/utilities/page/todo/todo.js b/erpnext/utilities/page/todo/todo.js index 1ab8982778..89c1ed8024 100644 --- a/erpnext/utilities/page/todo/todo.js +++ b/erpnext/utilities/page/todo/todo.js @@ -144,10 +144,10 @@ erpnext.todo.make_dialog = function(det) { width: 480, title: 'To Do', fields: [ - {fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, {fieldtype:'Text', fieldname:'description', label:'Description', reqd:1, description:'Use markdown to \ format content'}, + {fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, {fieldtype:'Check', fieldname:'checked', label:'Completed'}, {fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')}, {fieldtype:'Button', fieldname:'save', label:'Save'} From 586c6f3cbe5a6664576113331407b0193dc84fc3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 16:36:40 +0530 Subject: [PATCH 08/15] calendar: links to ref document --- erpnext/utilities/page/calendar/calendar.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/utilities/page/calendar/calendar.js b/erpnext/utilities/page/calendar/calendar.js index 9aa5df87dc..3d3519b402 100644 --- a/erpnext/utilities/page/calendar/calendar.js +++ b/erpnext/utilities/page/calendar/calendar.js @@ -83,6 +83,7 @@ Calendar.prototype.show_event = function(ev, cal_ev) { d.make_body([ ['HTML','Heading'] ,['Text','Description'] + ,['HTML', 'Ref Link'] ,['Check', 'Public Event'] ,['Check', 'Cancel Event'] ,['HTML', 'Event Link'] @@ -111,12 +112,17 @@ Calendar.prototype.show_event = function(ev, cal_ev) { this.widgets['Public Event'].checked = true; this.widgets['Event Link'].innerHTML = ''; + this.widgets['Ref Link'].innerHTML = ''; - // link - var div = $a(this.widgets['Event Link'], 'div', 'link_type', {margin:'4px 0px'}); - div.onclick = function() { me.event_dialog.hide(); loaddoc('Event', me.event_dialog.ev.name); } - div.innerHTML = 'View Event details, add or edit participants'; - + if(this.ev.ref_type) { + $(repl('Reference: %(ref_type)s: %(ref_name)s', this.ev)) + .appendTo(this.widgets['Ref Link']) + } + + $(repl('More Options', this.ev)) + .appendTo(this.widgets['Event Link']) } // event save From 02aab69427c4070291fc7eb1cc8120f8b1e54555 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 16:44:36 +0530 Subject: [PATCH 09/15] merge --- public/js/all-app.js | 13 ++++++------- public/js/kb_common.js | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/public/js/all-app.js b/public/js/all-app.js index 0620d3b0d6..bd5af85762 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1790,10 +1790,9 @@ this.cleanup_refresh(this);} _f.Frm.prototype.cleanup_refresh=function(){var me=this;if(me.fields_dict['amended_from']){if(me.doc.amended_from){unhide_field('amended_from');unhide_field('amendment_date');}else{hide_field('amended_from');hide_field('amendment_date');}} if(me.fields_dict['trash_reason']){if(me.doc.trash_reason&&me.doc.docstatus==2){unhide_field('trash_reason');}else{hide_field('trash_reason');}} if(me.meta.autoname&&me.meta.autoname.substr(0,6)=='field:'&&!me.doc.__islocal){var fn=me.meta.autoname.substr(6);set_field_permlevel(fn,1);}} -_f.Frm.prototype.refresh_dependency=function(){var me=this;var doc=locals[this.doctype][this.docname];var dep_dict={};var has_dep=false;for(fkey in me.fields){var f=me.fields[fkey];f.dependencies_clear=true;var guardian=f.df.depends_on;if(guardian){if(!dep_dict[guardian]) -dep_dict[guardian]=[];dep_dict[guardian][dep_dict[guardian].length]=f;has_dep=true;}} +_f.Frm.prototype.refresh_dependency=function(){var me=this;var doc=locals[this.doctype][this.docname];var has_dep=false;for(fkey in me.fields){var f=me.fields[fkey];f.dependencies_clear=true;if(f.df.depends_on){has_dep=true;}} if(!has_dep)return;for(var i=me.fields.length-1;i>=0;i--){var f=me.fields[i];f.guardian_has_value=true;if(f.df.depends_on){var v=doc[f.df.depends_on];if(f.df.depends_on.substr(0,5)=='eval:'){f.guardian_has_value=eval(f.df.depends_on.substr(5));}else if(f.df.depends_on.substr(0,3)=='fn:'){f.guardian_has_value=me.runclientscript(f.df.depends_on.substr(3),me.doctype,me.docname);}else{if(v||(v==0&&!v.substr)){}else{f.guardian_has_value=false;}} -if(f.guardian_has_value){if(f.grid)f.grid.show();else $ds(f.wrapper);}else{if(f.grid)f.grid.hide();else $dh(f.wrapper);}}}} +if(f.guardian_has_value){f.df.hidden=false;f.refresh()}else{f.df.hidden=true;f.refresh()}}}} _f.Frm.prototype.setnewdoc=function(docname){if(this.opendocs[docname]){this.docname=docname;return;} Meta.make_local_dt(this.doctype,docname);this.docname=docname;var me=this;var viewname=docname;if(this.meta.issingle)viewname=this.doctype;this.runclientscript('onload',this.doctype,this.docname);this.is_editable[docname]=1;if(this.meta.read_only_onload)this.is_editable[docname]=0;this.opendocs[docname]=true;} _f.Frm.prototype.edit_doc=function(){this.is_editable[this.docname]=true;this.refresh();} @@ -1852,13 +1851,13 @@ cur_frm.comments.list.dt=cur_frm.doctype;cur_frm.comments.list.dn=cur_frm.docnam * lib/js/legacy/widgets/form/form_fields.js */ _f.ColumnBreak=function(){this.set_input=function(){};} -_f.ColumnBreak.prototype.make_body=function(){if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){return;} +_f.ColumnBreak.prototype.make_body=function(){if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])){return;} this.cell=this.frm.layout.addcell(this.df.width);$y(this.cell.wrapper,{padding:'8px'});_f.cur_col_break_width=this.df.width;var fn=this.df.fieldname?this.df.fieldname:this.df.label;if(this.df&&this.df.label){this.label=$a(this.cell.wrapper,'div','','',this.df.label);}} _f.ColumnBreak.prototype.refresh=function(layout){if(!this.cell)return;if(this.set_hidden!=this.df.hidden){if(this.df.hidden) this.cell.hide();else this.cell.show();this.set_hidden=this.df.hidden;}} _f.SectionBreak=function(){this.fields=[];this.set_input=function(){};this.make_row=function(){this.row=this.df.label?this.frm.layout.addrow():this.frm.layout.addsubrow();}} -_f.SectionBreak.prototype.make_body=function(){var me=this;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){return;} +_f.SectionBreak.prototype.make_body=function(){var me=this;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])){return;} this.make_row();if(this.df.label){if(!this.df.description) this.df.description='';$(this.row.main_head).html(repl('
\

%(label)s

\ @@ -1875,7 +1874,7 @@ _f.SectionBreak.prototype.has_data=function(){var me=this;for(var i in me.fields if(f.df.reqd&&!v){return true;} if(f.df.fieldtype=='Table'){if(f.grid.get_children().length||f.df.reqd){return true;}}} return false;} -_f.SectionBreak.prototype.refresh=function(from_form){if(this.df.hidden){if(this.row)this.row.hide();}else{if(this.collapsible){}}} +_f.SectionBreak.prototype.refresh=function(from_form){if(this.df.hidden){if(this.row)this.row.hide();}else{if(this.row)this.row.show();}} _f.ImageField=function(){this.images={};} _f.ImageField.prototype=new Field();_f.ImageField.prototype.onmake=function(){this.no_img=$a(this.wrapper,'div','no_img');this.no_img.innerHTML="No Image";$dh(this.no_img);} _f.ImageField.prototype.get_image_src=function(doc){if(doc.file_list){file=doc.file_list.split(',');extn=file[0].split('.');extn=extn[extn.length-1].toLowerCase();var img_extn_list=['gif','jpg','bmp','jpeg','jp2','cgm','ief','jpm','jpx','png','tiff','jpe','tif'];if(in_list(img_extn_list,extn)){var src=wn.request.url+"?cmd=downloadfile&file_id="+file[1];}}else{var src="";} @@ -1895,7 +1894,7 @@ if(cur_frm.editable&&cur_frm.doc.docstatus>0){if(this.df.allow_on_submit&&cur_fr if(this.df['default'].toLowerCase()=='no add rows'){this.grid.can_add_rows=false;}} if(st=='Write'){this.grid.show();}else if(st=='Read'){this.grid.show();}else{this.grid.hide();} this.grid.refresh();} -_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"js/lib/tiny_mce_33/custom_content.css?q=1",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} +_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table,advimage",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect,|,image",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"js/lib/tiny_mce_33/custom_content.css?q=1",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} this.input.onchange=function(){me.set(me.editor.getContent());me.run_trigger();} this.get_value=function(){return me.editor.getContent();}}else{wn.require('js/lib/ace/ace.js');$(this.input_area).css('border','1px solid #aaa');this.pre=$a(this.input_area,'pre','',{position:'relative',height:'400px',width:'100%'});this.input={};this.myid=wn.dom.set_unique_id(this.pre);this.editor=ace.edit(this.myid);if(me.df.options=='Markdown'||me.df.options=='HTML'){wn.require('js/lib/ace/mode-html.js');var HTMLMode=require("ace/mode/html").Mode;me.editor.getSession().setMode(new HTMLMode());} else if(me.df.options=='Javascript'){wn.require('js/lib/ace/mode-javascript.js');var JavascriptMode=require("ace/mode/javascript").Mode;me.editor.getSession().setMode(new JavascriptMode());} diff --git a/public/js/kb_common.js b/public/js/kb_common.js index bbd57f10e6..97ad5deb8e 100644 --- a/public/js/kb_common.js +++ b/public/js/kb_common.js @@ -16,7 +16,7 @@ EditableText=function(args){$.extend(this,args);var me=this;me.$w=$(repl('
\ [edit]\ \ - \ \ Cancel\ From bc26218889ea16d3a178f242b975de2d03c43e06 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 8 Aug 2012 10:02:55 +0530 Subject: [PATCH 10/15] added jQuery.Gantt --- erpnext/projects/page/projects/projects.css | 6 + erpnext/projects/page/projects/projects.html | 1 - erpnext/projects/page/projects/projects.js | 290 +++--------------- erpnext/projects/page/projects/projects.py | 25 ++ .../page/projects/projects_static.html | 1 - 5 files changed, 72 insertions(+), 251 deletions(-) create mode 100644 erpnext/projects/page/projects/projects.css create mode 100644 erpnext/projects/page/projects/projects.py delete mode 100644 erpnext/projects/page/projects/projects_static.html diff --git a/erpnext/projects/page/projects/projects.css b/erpnext/projects/page/projects/projects.css new file mode 100644 index 0000000000..2fc9c27d14 --- /dev/null +++ b/erpnext/projects/page/projects/projects.css @@ -0,0 +1,6 @@ +.gantt { + -moz-box-sizing: border-box; + border: 14px solid #DDDDDD; + border-radius: 6px 6px 6px 6px; + margin: 20px auto; +} \ No newline at end of file diff --git a/erpnext/projects/page/projects/projects.html b/erpnext/projects/page/projects/projects.html index c09eebae0c..e69de29bb2 100644 --- a/erpnext/projects/page/projects/projects.html +++ b/erpnext/projects/page/projects/projects.html @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/erpnext/projects/page/projects/projects.js b/erpnext/projects/page/projects/projects.js index 9fec3c9bb6..7dc9358677 100644 --- a/erpnext/projects/page/projects/projects.js +++ b/erpnext/projects/page/projects/projects.js @@ -22,258 +22,50 @@ pscript.queries_bg_dict = { 'Pending Review':'YELLOW' } -pscript.onload_Projects = function() { - var d = $i('projects_div'); +pscript.onload_Projects = function(wrapper) { + wn.ui.make_app_page({parent:wrapper, title:'Gantt Chart: All Tasks', single_column:true}); - new PageHeader(d, 'Gantt Chart'); - new GanttChart($a(d, 'div', '', { margin:'16px'})); -} - - -// Gantt Chart -// ========================================================================== - -GanttChart = function(parent) { - this.wrapper = $a(parent, 'div'); - //this.head = new PageHeader(this.wrapper, 'Gantt Chart'); - - this.toolbar_area = $a(this.wrapper, 'div','',{padding:'16px', border:'1px solid #AAF', }); $bg(this.toolbar_area, '#EEF'); $br(this.toolbar_area, '3px'); - this.toolbar_tab = make_table(this.toolbar_area, 1, 4, '100%', ['25%', '25%','25%', '25%']); - this.grid_area = $a(this.wrapper, 'div', '', {margin: '16px 0px'}); - this.no_task_message = $a(this.wrapper, 'div', 'help_box', - {textAign:'center', fontSize:'14px'}, 'Select your criteria and click on "Make" to show the Gantt Chart') - - this.get_init_data(); - //this.make_grid(); -} - -GanttChart.prototype.get_init_data = function() { - var me = this; - var callback = function(r,rt) { - me.pl = r.message.pl.sort(); - me.rl = r.message.rl.sort(); - - me.make_toolbar(); - } - $c_obj('Project Control','get_init_data','', callback); -} - -GanttChart.prototype.make_filter = function(label, idx) { - var w = $a($td(this.toolbar_tab,0,idx), 'div','',{marginBottom:'8px'}); - var l = $a(w, 'div','',{fontSize:'11px'}); l.innerHTML = label; - return w; -} - -GanttChart.prototype.make_select = function(label, options,idx) { - var w = this.make_filter(label,idx); - var s = $a(w, 'select','',{width:'100px'}); add_sel_options(s, add_lists(['All'],options)); - return s; -} - -GanttChart.prototype.make_date = function(label,idx) { - var w = this.make_filter(label,idx); - var i = $a(w, 'input'); - - var user_fmt = wn.boot.sysdefaults.date_format; - if(!this.user_fmt)this.user_fmt = 'dd-mm-yy'; - - $(i).datepicker({ - dateFormat: user_fmt.replace('yyyy','yy'), - altFormat:'yy-mm-dd', - changeYear: true - }); + $(wrapper).find('.layout-main').html('
Loading...
') - return i; -} - -GanttChart.prototype.make_toolbar = function() { - - // resource / project - this.r_sel = this.make_select('Resource', this.rl, 0); - this.p_sel = this.make_select('Project', this.pl, 1); - // start / end - this.s_date = this.make_date('Start Date', 2); this.s_date.value = date.str_to_user(date.month_start()); - this.e_date = this.make_date('End Date', 3); this.e_date.value = date.str_to_user(date.month_end()); + wn.require('js/lib/jQuery.Gantt/css/style.css'); + wn.require('js/lib/jQuery.Gantt/js/jquery.fn.gantt.min.js'); - // button - var me = this; - $btn(this.toolbar_area, 'Make', function() { me.refresh(); }, null, 'green', 1); - this.print_btn = $btn(this.toolbar_area, 'Print', function() { me.print(); }, {display:'none'},null); -} - -GanttChart.prototype.print = function() { - $(this.grid_area).printElement(); -} - -GanttChart.prototype.get_data = function() { - var me = this; - var callback = function(r, rt) { - me.tasks = r.message; - if(me.tasks.length) { - $dh(me.no_task_message); - $ds(me.grid_area); - me.show_tasks(); - $di(me.print_btn); - } else { - // nothign to show - $dh(me.grid_area); - $ds(me.no_task_message); - $dh(me.print_btn); - me.no_task_message.innerHTML = 'Nothing allocated for the above criteria' - } - } - $c_obj('Project Control','get_tasks', - [date.user_to_str(this.s_date.value), - date.user_to_str(this.e_date.value), - sel_val(this.p_sel), - sel_val(this.r_sel)].join('~~~') - , callback) -} - -GanttChart.prototype.make_grid = function() { - // clear earlier chart - this.grid_area.innerHTML = ''; - this.grid = new GanttGrid(this, this.s_date.value, this.e_date.value); -} - -GanttChart.prototype.refresh = function() { - this.get_data(); -} - -GanttChart.prototype.show_tasks = function() { - this.make_grid(); - for(var i=0; i').appendTo($(wrapper).find('.layout-main')); + gantt_area.gantt({ + source: source, + navigate: "scroll", + scale: "weeks", + minScale: "weeks", + maxScale: "months", + onItemClick: function(data) { + alert("Item clicked - show some details"); + }, + onAddClick: function(dt, rowId) { + //alert("Empty space clicked - add an item!"); + } + }); + } - 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.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.get_x = function(dt) { - var d = date.str_to_obj(dt); // convert to obj - return flt(date.get_diff(d, this.start_date)+1) / flt(date.get_diff(this.end_date, this.start_date)+1) * 100; -} - -// ========================================================================== - -GanttTask = function(grid, data, idx) { - // start_date, end_date, name, status - this.start_date = data[3]; - this.end_date = data[4]; - - // label - this.label = $a(grid.y_labels, 'div', '', {'top':(idx*40) + 'px', overflow:'hidden', position:'absolute', 'width':'100%', height: '40px'}); - var l1 = $a($a(this.label, 'div'), 'span', 'link_type'); l1.innerHTML = data[0]; l1.dn = data[7]; l1.onclick = function() { loaddoc('Task', this.dn) }; - var l2 = $a(this.label, 'div', '', {fontSize:'10px'}); l2.innerHTML = data[1]; - - // bar - var col = pscript.queries_bg_dict[data[5]]; - if(data[6]!='Open') col = pscript.queries_bg_dict[data[6]]; - if(!col) col = 'BLUE'; - - this.body = $a(grid.task_area, 'div','',{backgroundColor:col, height:'12px', position:'absolute'}); - - //bar info - this.body_info = $a(this.body, 'div','',{backgroundColor:'#CCC', position:'absolute', zIndex:20}); - - var x1 = grid.get_x(this.start_date); - var x2 = grid.get_x(this.end_date); - - if(x1<=0)x1=0; - else x1 -=100/flt(date.get_diff(grid.end_date, grid.start_date)+1); - if(x2>=100)x2=100; -// else x2+=100/flt(date.get_diff(grid.end_date, grid.start_date)+1); - - $y(this.body, { - top: idx * 40 + 14 + 'px', - left: x1 + '%', - width: (x2-x1) + '%', - zIndex: 1, - cursor:'pointer' }) - - // divider - if(idx) { - var d1 = $a(grid.task_area, 'div','',{borderBottom: '1px solid #AAA', position:'absolute', width:'100%', top:(idx*40) + 'px'}); - var d2 = $a(grid.y_labels, 'div','',{borderBottom: '1px solid #AAA', position:'absolute', width:'100%', top:(idx*40) + 'px'}); - } - - this.make_tooltip(data); -} - -GanttTask.prototype.make_tooltip = function(d) { - $(this.body).click(function() { - var t = '
'; - if(d[0]) t += 'Task: ' + d[0]; - if(d[5]) t += '
Priority: ' + d[5]; - if(d[6]) t += '
Status: ' + d[6]; - if(d[1]) t += '
Allocated To: ' + d[1]; - if(d[2]) t += '
Project: ' + d[2]; - if(d[3]) t += '
From: ' + date.str_to_user(d[3]); - if(d[4]) t += '
To: ' + date.str_to_user(d[4]); - t += '
'; - - msgprint(t) - }) - -} - - - - +} \ No newline at end of file diff --git a/erpnext/projects/page/projects/projects.py b/erpnext/projects/page/projects/projects.py new file mode 100644 index 0000000000..8f170def25 --- /dev/null +++ b/erpnext/projects/page/projects/projects.py @@ -0,0 +1,25 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import webnotes + +@webnotes.whitelist() +def get_tasks(): + return webnotes.conn.sql("""select name, project, subject, exp_start_date, exp_end_date, + description from tabTask where + project is not null + and exp_start_date is not null + and exp_end_date is not null""", as_dict=True) \ No newline at end of file diff --git a/erpnext/projects/page/projects/projects_static.html b/erpnext/projects/page/projects/projects_static.html deleted file mode 100644 index 05775457ba..0000000000 --- a/erpnext/projects/page/projects/projects_static.html +++ /dev/null @@ -1 +0,0 @@ -Projects \ No newline at end of file From bf8cac53c72df7afefb0f5a14febbd74b72c922b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 8 Aug 2012 10:05:51 +0530 Subject: [PATCH 11/15] pre, code style fix --- .../utilities/page/markdown_reference/markdown_reference.html | 2 +- public/css/all-app.css | 4 ++-- public/css/all-web.css | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.html b/erpnext/utilities/page/markdown_reference/markdown_reference.html index 5af414f275..cdf646cad3 100644 --- a/erpnext/utilities/page/markdown_reference/markdown_reference.html +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.html @@ -6,7 +6,7 @@
-
+

Phrase Emphasis

*italic*   **bold**
 _italic_   __bold__
diff --git a/public/css/all-app.css b/public/css/all-app.css
index f120a8bd73..19b550c707 100644
--- a/public/css/all-app.css
+++ b/public/css/all-app.css
@@ -1969,7 +1969,7 @@ span, div, td, input, textarea, button, select {
 }
 
 
-pre {
+.markdwon pre {
     background-color: #F5F5F5;
     border: 1px solid rgba(0, 0, 0, 0.15);
     border-radius: 4px 4px 4px 4px;
@@ -1982,7 +1982,7 @@ pre {
     word-wrap: break-word;
 }
 
-code, pre {
+.markdown code, .markdown pre {
     border-radius: 3px 3px 3px 3px;
     color: #333333;
     font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
diff --git a/public/css/all-web.css b/public/css/all-web.css
index b27a7dac47..8673c1f1f6 100644
--- a/public/css/all-web.css
+++ b/public/css/all-web.css
@@ -1830,7 +1830,7 @@ span, div, td, input, textarea, button, select {
 }
 
 
-pre {
+.markdwon pre {
     background-color: #F5F5F5;
     border: 1px solid rgba(0, 0, 0, 0.15);
     border-radius: 4px 4px 4px 4px;
@@ -1843,7 +1843,7 @@ pre {
     word-wrap: break-word;
 }
 
-code, pre {
+.markdown code, .markdown pre {
     border-radius: 3px 3px 3px 3px;
     color: #333333;
     font-family: Menlo,Monaco,Consolas,"Courier New",monospace;

From 7dbef2549a602b61072e17bcaebe204a477333b9 Mon Sep 17 00:00:00 2001
From: Rushabh Mehta 
Date: Wed, 8 Aug 2012 10:06:43 +0530
Subject: [PATCH 12/15] pre, code style fix

---
 public/css/all-app.css | 2 +-
 public/css/all-web.css | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/public/css/all-app.css b/public/css/all-app.css
index 19b550c707..dcc21384f7 100644
--- a/public/css/all-app.css
+++ b/public/css/all-app.css
@@ -1969,7 +1969,7 @@ span, div, td, input, textarea, button, select {
 }
 
 
-.markdwon pre {
+.markdown pre {
     background-color: #F5F5F5;
     border: 1px solid rgba(0, 0, 0, 0.15);
     border-radius: 4px 4px 4px 4px;
diff --git a/public/css/all-web.css b/public/css/all-web.css
index 8673c1f1f6..971d32f636 100644
--- a/public/css/all-web.css
+++ b/public/css/all-web.css
@@ -1830,7 +1830,7 @@ span, div, td, input, textarea, button, select {
 }
 
 
-.markdwon pre {
+.markdown pre {
     background-color: #F5F5F5;
     border: 1px solid rgba(0, 0, 0, 0.15);
     border-radius: 4px 4px 4px 4px;

From 11a5ba64ddd8d2ee56c1542ebe5218c6da901dfe Mon Sep 17 00:00:00 2001
From: Anand Doshi 
Date: Thu, 9 Aug 2012 11:30:21 +0530
Subject: [PATCH 13/15] fixed bug in depends_on: hidden property of a docfield
 should have value as 0 or 1

---
 public/js/all-app.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/public/js/all-app.js b/public/js/all-app.js
index bd5af85762..3c35b8344b 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -1792,7 +1792,7 @@ if(me.fields_dict['trash_reason']){if(me.doc.trash_reason&&me.doc.docstatus==2){
 if(me.meta.autoname&&me.meta.autoname.substr(0,6)=='field:'&&!me.doc.__islocal){var fn=me.meta.autoname.substr(6);set_field_permlevel(fn,1);}}
 _f.Frm.prototype.refresh_dependency=function(){var me=this;var doc=locals[this.doctype][this.docname];var has_dep=false;for(fkey in me.fields){var f=me.fields[fkey];f.dependencies_clear=true;if(f.df.depends_on){has_dep=true;}}
 if(!has_dep)return;for(var i=me.fields.length-1;i>=0;i--){var f=me.fields[i];f.guardian_has_value=true;if(f.df.depends_on){var v=doc[f.df.depends_on];if(f.df.depends_on.substr(0,5)=='eval:'){f.guardian_has_value=eval(f.df.depends_on.substr(5));}else if(f.df.depends_on.substr(0,3)=='fn:'){f.guardian_has_value=me.runclientscript(f.df.depends_on.substr(3),me.doctype,me.docname);}else{if(v||(v==0&&!v.substr)){}else{f.guardian_has_value=false;}}
-if(f.guardian_has_value){f.df.hidden=false;f.refresh()}else{f.df.hidden=true;f.refresh()}}}}
+if(f.guardian_has_value){f.df.hidden=0;f.refresh()}else{f.df.hidden=1;f.refresh()}}}}
 _f.Frm.prototype.setnewdoc=function(docname){if(this.opendocs[docname]){this.docname=docname;return;}
 Meta.make_local_dt(this.doctype,docname);this.docname=docname;var me=this;var viewname=docname;if(this.meta.issingle)viewname=this.doctype;this.runclientscript('onload',this.doctype,this.docname);this.is_editable[docname]=1;if(this.meta.read_only_onload)this.is_editable[docname]=0;this.opendocs[docname]=true;}
 _f.Frm.prototype.edit_doc=function(){this.is_editable[this.docname]=true;this.refresh();}

From c4df355edc9cb41cd56201650180cc9b1168e0bd Mon Sep 17 00:00:00 2001
From: Anand Doshi 
Date: Thu, 9 Aug 2012 11:33:56 +0530
Subject: [PATCH 14/15] removed msgprint in get_pos_details of sales invoice

---
 erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 6a7fb0186e..ec327c7e1b 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -209,7 +209,6 @@ class DocType(TransactionBase):
 			if ret['warehouse']:
 				actual_qty = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], ret['warehouse']))
 				ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
-			msgprint(ret)
 		return ret
 
 	def get_barcode_details(self, barcode):

From c6cf4a2630481ecb02d0f19be4403d56463e362b Mon Sep 17 00:00:00 2001
From: Anand Doshi 
Date: Thu, 9 Aug 2012 12:16:03 +0530
Subject: [PATCH 15/15] do not display mouse as a clickable pointer when
 hovering on description in todo list

---
 erpnext/utilities/page/todo/todo.css | 1 -
 1 file changed, 1 deletion(-)

diff --git a/erpnext/utilities/page/todo/todo.css b/erpnext/utilities/page/todo/todo.css
index 9fe595587a..499d8913b7 100644
--- a/erpnext/utilities/page/todo/todo.css
+++ b/erpnext/utilities/page/todo/todo.css
@@ -28,7 +28,6 @@
 }
 
 .todoitem .description {
-	cursor: pointer;
 	padding: 3px 0px;
 	display: inline-block;
 	width: 80%;