diff --git a/build.json b/build.json index 6efbbc3095..70e00d69aa 100644 --- a/build.json +++ b/build.json @@ -23,4 +23,7 @@ "public/js/complete_setup.js": [ "erpnext/startup/js/complete_setup.js", ], + "public/js/gantt_task.js": [ + "erpnext/projects/gantt_task.js", + ] } \ No newline at end of file diff --git a/erpnext/home/page/attributions/attributions.html b/erpnext/home/page/attributions/attributions.html index f76c248dd9..63919d0a29 100644 --- a/erpnext/home/page/attributions/attributions.html +++ b/erpnext/home/page/attributions/attributions.html @@ -40,10 +40,9 @@
  • Ace - code editor
  • Slick Grid - report grid
  • jQPlot - graphs
  • +
  • JQuery.Gantt - Gantt Chart
  • JSON2 - JSON builder, parser
  • JSColor - color picker
  • -
  • sprintf - string formatting
  • -
  • historyjs - AJAX history
  • diff --git a/erpnext/projects/doctype/activity_type/__init__.py b/erpnext/projects/doctype/activity_type/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/projects/doctype/activity_type/activity_type.txt b/erpnext/projects/doctype/activity_type/activity_type.txt deleted file mode 100644 index 46ed91718f..0000000000 --- a/erpnext/projects/doctype/activity_type/activity_type.txt +++ /dev/null @@ -1,78 +0,0 @@ -# DocType, Activity Type -[ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:36:05', - 'docstatus': 0, - 'modified': '2012-03-27 14:36:05', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - 'autoname': u'field:activity_type', - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'in_dialog': 1, - 'module': u'Projects', - 'name': '__common__', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'version': 12 - }, - - # These values are common for all DocField - { - 'doctype': u'DocField', - 'fieldname': u'activity_type', - 'fieldtype': u'Data', - 'label': u'Activity Type', - 'name': '__common__', - 'parent': u'Activity Type', - 'parentfield': u'fields', - 'parenttype': u'DocType', - 'permlevel': 0, - 'reqd': 1 - }, - - # These values are common for all DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 1, - 'doctype': u'DocPerm', - 'name': '__common__', - 'parent': u'Activity Type', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'permlevel': 0, - 'read': 1, - 'submit': 0, - 'write': 1 - }, - - # DocType, Activity Type - { - 'doctype': 'DocType', - 'name': u'Activity Type' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'role': u'System Manager' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'role': u'Projects User' - }, - - # DocField - { - 'doctype': u'DocField' - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js index faa175fded..eca926190a 100644 --- a/erpnext/projects/doctype/project/project.js +++ b/erpnext/projects/doctype/project/project.js @@ -14,42 +14,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//-------------------------- Onload --------------------------- -cur_frm.cscript.onload = function(doc, cdt, cdn) { - if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'}); -} +// show tasks -//------------------- Get Contact Person based on customer selected --------------------------- -cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) { - if(doc.customer) - return 'SELECT `tabContact`.contact_name FROM `tabContact` WHERE (`tabContact`.is_customer = 1 AND `tabContact`.customer_name = "'+ doc.customer+'") AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50'; - else - msgprint("Please select Customer first") -} - -//-------------------------------- get query select Territory ------------------------------------------ -cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) { - return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; -} - -//------------------------ Customer and its primary contact Details ------------------------------------ -cur_frm.cscript.customer = function(doc, cdt, cdn) { - if(doc.customer) get_server_fields('get_customer_details', '','', doc, cdt, cdn, 1); -} - -//--------------------- Customer's Contact Person Details -------------------------------------------- -cur_frm.cscript.contact_person = function(doc, cdt, cdn) { - if(doc.contact_person) { - get_server_fields('get_contact_details','','',doc, cdt, cdn, 1); - } -} - -//--------- calculate gross profit -------------------------------- -cur_frm.cscript.project_value = function(doc, cdt, cdn){ - get_server_fields('get_gross_profit','','',doc, cdt, cdn, 1); -} - -//--------- calculate gross profit -------------------------------- -cur_frm.cscript.est_material_cost = function(doc, cdt, cdn){ - get_server_fields('get_gross_profit','','',doc, cdt, cdn, 1); -} +cur_frm.cscript.refresh = function(doc) { + if(!doc.__islocal) { + // refresh gantt chart + wn.require('erpnext/projects/gantt_task.js'); + if(!cur_frm.gantt_area) + cur_frm.gantt_area = $('
    ') + .appendTo(cur_frm.fields_dict.project_tasks.wrapper); + cur_frm.gantt_area.empty(); + erpnext.show_task_gantt(cur_frm.gantt_area, cur_frm.docname); + } +} \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.txt b/erpnext/projects/doctype/project/project.txt index 43cab3958e..1463f78d97 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-05-03 18:41:42', + 'creation': '2012-08-08 13:25:19', 'docstatus': 0, - 'modified': '2012-08-07 15:48:47', + 'modified': '2012-08-08 13:55:01', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -225,6 +225,8 @@ # DocField { + 'colour': u'White:FFF', + 'description': u'Milestones will be added as Events in the Calendar', 'doctype': u'DocField', 'fieldname': u'project_milestones', 'fieldtype': u'Table', @@ -237,6 +239,26 @@ 'search_index': 0 }, + # DocField + { + 'colour': u'White:FFF', + 'description': u'Tasks belonging to this Project.', + 'doctype': u'DocField', + 'fieldname': u'sb_tasks', + 'fieldtype': u'Section Break', + 'label': u'Tasks', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'project_tasks', + 'fieldtype': u'HTML', + 'label': u'Project Tasks', + 'permlevel': 0 + }, + # DocField { 'doctype': u'DocField', @@ -282,7 +304,7 @@ 'oldfieldname': u'project_value', 'oldfieldtype': u'Currency', 'permlevel': 0, - 'reqd': 1, + 'reqd': 0, 'search_index': 0, 'trigger': u'Client' }, @@ -322,7 +344,7 @@ 'oldfieldname': u'gross_margin_value', 'oldfieldtype': u'Currency', 'permlevel': 0, - 'reqd': 1, + 'reqd': 0, 'search_index': 0 }, @@ -336,7 +358,7 @@ 'oldfieldname': u'per_gross_margin', 'oldfieldtype': u'Currency', 'permlevel': 0, - 'reqd': 1, + 'reqd': 0, 'search_index': 0 }, diff --git a/erpnext/projects/doctype/project_activity/__init__.py b/erpnext/projects/doctype/project_activity/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/projects/doctype/project_activity/project_activity.js b/erpnext/projects/doctype/project_activity/project_activity.js deleted file mode 100644 index ad33e3cd7f..0000000000 --- a/erpnext/projects/doctype/project_activity/project_activity.js +++ /dev/null @@ -1,99 +0,0 @@ -// 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 . - -cur_frm.cscript.onload = function(doc, dt, dn) { - // created? - if(cur_frm.mylist) { - cur_frm.mylist.run(); - return; - } else { - - // create a new listing - var lst = new Listing('Activities Updates'); - - lst.colwidths = ['5%','30%','40%','25%']; - - // define options - var opts = {}; - - opts.head_main_style = {}; - opts.cell_style = { padding:'3px 2px', borderRight : '0px', borderBottom : '1px solid #AAA', verticalAlign: 'top'} - opts.head_style = { padding:'3px 2px', borderBottom : '1px solid #AAA'} - opts.alt_cell_style = {}; - opts.hide_print = 1; - opts.no_border = 1; - - opts.hide_export = 1; - opts.hide_print = 1; - opts.hide_rec_label = 1; - - lst.opts = opts; - - // query - lst.get_query = function() { - var doc = cur_frm.doc; - this.query = "select owner,creation,`update`, hours from `tabProject Activity Update` where parent = '"+doc.name+"'"; - this.query_max = "select count(*) from `tabProject Activity Update` where parent = '"+doc.name+"'"; - } - - lst.show_cell = function(cell,ri,ci,d){ - - // owner and date - if (ci==0){ - var d1 = $a(cell,'div'); - var img = $a(cell,'img','',{width:'40px'}); - img.src = wn.user_info(d[ri][0]).image; - var d2 = $a(cell,'div'); - d2.innerHTML = d[ri][0] + ' on: ' + date.str_to_user(d[ri][1]); - } - - // update - if(ci==1) { - cell.innerHTML = replace_newlines(d[ri][2]); - } - - // Hours - if (ci==2) { - cell.innerHTML = d[ri][3] + ' hrs'; - } - } - - lst.make(cur_frm.fields_dict['updates_html'].wrapper); - cur_frm.mylist = lst; - lst.run(); - } -} - -cur_frm.cscript.refresh = function(doc, dt, dn) { - - // show activities only after project is saved - - var fl = ['new_update','add','hours','updates_html']; - if(doc.__islocal) { - hide_field(fl);} - else { - unhide_field(fl); } -} - -cur_frm.cscript.add = function(doc, dt, dn) { - var callback = function(r,rt) { - - // refresh listing - cur_frm.mylist.run(); - - } - $c_obj(make_doclist(doc.doctype, doc.name),'add_update','',callback); -} diff --git a/erpnext/projects/doctype/project_activity/project_activity.py b/erpnext/projects/doctype/project_activity/project_activity.py deleted file mode 100644 index 950e7e83c0..0000000000 --- a/erpnext/projects/doctype/project_activity/project_activity.py +++ /dev/null @@ -1,48 +0,0 @@ -# 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 . - -# Please edit this list and import only required elements -import webnotes - -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add -from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, getchildren, make_autoname -from webnotes.model.doclist import getlist, copy_doclist -from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax -from webnotes import session, form, is_testing, msgprint, errprint - -set = webnotes.conn.set -sql = webnotes.conn.sql -get_value = webnotes.conn.get_value -in_transaction = webnotes.conn.in_transaction -convert_to_lists = webnotes.conn.convert_to_lists - -# ----------------------------------------------------------------------------------------- - - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d, dl - - def add_update(self): - d = Document('Project Activity Update') - d.parent = self.doc.name - d.update = self.doc.new_update - d.hours = self.doc.hours - d.save(1) - - self.doc.new_update = '' - self.doc.hours = '' \ No newline at end of file diff --git a/erpnext/projects/doctype/project_activity/project_activity.txt b/erpnext/projects/doctype/project_activity/project_activity.txt deleted file mode 100644 index 544716522c..0000000000 --- a/erpnext/projects/doctype/project_activity/project_activity.txt +++ /dev/null @@ -1,167 +0,0 @@ -# DocType, Project Activity -[ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:36:06', - 'docstatus': 0, - 'modified': '2012-03-27 14:36:06', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - 'autoname': u'Activity.######', - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'module': u'Projects', - 'name': '__common__', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'version': 15 - }, - - # These values are common for all DocField - { - 'doctype': u'DocField', - 'name': '__common__', - 'parent': u'Project Activity', - 'parentfield': u'fields', - 'parenttype': u'DocType', - 'permlevel': 0 - }, - - # These values are common for all DocPerm - { - 'create': 1, - 'doctype': u'DocPerm', - 'name': '__common__', - 'parent': u'Project Activity', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'permlevel': 0, - 'read': 1, - 'role': u'All', - 'write': 1 - }, - - # DocType, Project Activity - { - 'doctype': 'DocType', - 'name': u'Project Activity' - }, - - # DocPerm - { - 'doctype': u'DocPerm' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'project', - 'fieldtype': u'Link', - 'label': u'Project', - 'oldfieldname': u'project', - 'oldfieldtype': u'Link', - 'options': u'Project' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'activity_name', - 'fieldtype': u'Data', - 'label': u'Activity Name', - 'oldfieldname': u'activity_name', - 'oldfieldtype': u'Data', - 'print_hide': 1, - 'reqd': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'percent_complete', - 'fieldtype': u'Select', - 'label': u'Percent Complete', - 'oldfieldname': u'percent_complete', - 'oldfieldtype': u'Select', - 'options': u'0\n5\n10\n15\n20\n25\n30\n35\n40\n45\n50\n55\n60\n65\n70\n75\n80\n85\n90\n95\n100', - 'reqd': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'last_update', - 'fieldtype': u'Date', - 'hidden': 1, - 'label': u'Last Update', - 'oldfieldname': u'last_update', - 'oldfieldtype': u'Date', - 'print_hide': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'last_update_by', - 'fieldtype': u'Data', - 'hidden': 1, - 'label': u'Last Update By', - 'oldfieldname': u'last_update_by', - 'oldfieldtype': u'Data', - 'print_hide': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'updates', - 'fieldtype': u'Section Break', - 'label': u'Updates', - 'oldfieldtype': u'Section Break' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'updates_html', - 'fieldtype': u'HTML', - 'label': u'Updates HTML', - 'oldfieldtype': u'HTML' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'new_update', - 'fieldtype': u'Text', - 'label': u'New Update', - 'oldfieldname': u'new_update', - 'oldfieldtype': u'Text' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'hours', - 'fieldtype': u'Float', - 'label': u'Hours', - 'oldfieldname': u'hours', - 'oldfieldtype': u'Float' - }, - - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'add', - 'fieldtype': u'Button', - 'label': u'Add', - 'oldfieldtype': u'Button', - 'trigger': u'Client' - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/project_activity_update/__init__.py b/erpnext/projects/doctype/project_activity_update/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/projects/doctype/project_activity_update/project_activity_update.txt b/erpnext/projects/doctype/project_activity_update/project_activity_update.txt deleted file mode 100644 index 8155ccf069..0000000000 --- a/erpnext/projects/doctype/project_activity_update/project_activity_update.txt +++ /dev/null @@ -1,61 +0,0 @@ -# DocType, Project Activity Update -[ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:36:06', - 'docstatus': 0, - 'modified': '2012-03-27 14:36:06', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'istable': 1, - 'module': u'Projects', - 'name': '__common__', - 'section_style': u'Simple', - 'version': 1 - }, - - # These values are common for all DocField - { - 'doctype': u'DocField', - 'name': '__common__', - 'parent': u'Project Activity Update', - 'parentfield': u'fields', - 'parenttype': u'DocType', - 'permlevel': 0 - }, - - # DocType, Project Activity Update - { - 'doctype': 'DocType', - 'name': u'Project Activity Update' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'update', - 'fieldtype': u'Text', - 'label': u'Update', - 'oldfieldname': u'update', - 'oldfieldtype': u'Text' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'e.g. 0.5, 2.5 etc', - 'doctype': u'DocField', - 'fieldname': u'hours', - 'fieldtype': u'Float', - 'label': u'Hours', - 'oldfieldname': u'hours', - 'oldfieldtype': u'Float' - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/project_control/__init__.py b/erpnext/projects/doctype/project_control/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/projects/doctype/project_control/project_control.py b/erpnext/projects/doctype/project_control/project_control.py deleted file mode 100644 index 9928ffd35a..0000000000 --- a/erpnext/projects/doctype/project_control/project_control.py +++ /dev/null @@ -1,160 +0,0 @@ -# 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 . - -# Please edit this list and import only required elements -import webnotes - -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, set_default, str_esc_quote, user_format, validate_email_add, add_days -from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, getchildren, make_autoname -from webnotes.model.doclist import getlist, copy_doclist -from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax -from webnotes import session, form, is_testing, msgprint, errprint -from webnotes.utils.email_lib import sendmail -set = webnotes.conn.set -sql = webnotes.conn.sql -get_value = webnotes.conn.get_value -in_transaction = webnotes.conn.in_transaction -convert_to_lists = webnotes.conn.convert_to_lists - -# ----------------------------------------------------------------------------------------- - - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl - - def get_projects(self, arg): - # project list - pl=[] - status={} - if arg == 'Open': - pl = [p[0] for p in sql("select name from `tabProject` where status = 'Open' order by creation desc limit 20")] - for p1 in pl: - status[p1] = 'Open' - elif arg == 'Completed': - pl = [p[0] for p in sql("select name from `tabProject` where status = 'Completed' order by creation desc limit 20")] - for p2 in pl: - status[p2] = 'Completed' - elif arg == 'Cancelled': - pl = [p[0] for p in sql("select name from `tabProject` where status = 'Cancelled' order by creation desc limit 20")] - for p3 in pl: - status[p3] = 'Cancelled' - else: - #pl = [p[0] for p in sql("select name from `tabProject` order by creation desc limit 20")] - pl1 = sql("select name, status from `tabProject` order by creation desc limit 20", as_dict=1) - for p4 in pl1: - status[p4['name']] = p4['status'] - pl.append(p4['name']) - - # milestones in the next 7 days for active projects - ml = convert_to_lists(sql("select t1.milestone_date, t1.milestone, t1.parent from `tabProject Milestone` t1, tabProject t2 where t1.parent = t2.name and t2.status='Open' and DATEDIFF(t1.milestone_date, CURDATE()) BETWEEN 0 AND 7 ORDER BY t1.milestone_date ASC")) - - # percent of activity completed per project - comp = {} - n_tasks = {} - - for p in pl: - t1 = sql('select count(*) from tabTask where project=%s and docstatus!=2', p)[0][0] - n_tasks[p] = t1 or 0 - if t1: - t2 = sql('select count(*) from tabTask where project=%s and docstatus!=2 and status="Closed"', p)[0][0] - comp[p] = cint(flt(t2)*100/t1) - - return {'pl':pl, 'ml':ml, 'comp':comp, 'n_tasks':n_tasks, 'status':status} - - def get_resources(self): - ret = {} - - # resource list - rl = sql("select distinct allocated_to, assignee_email from tabTask") - - # get open & closed tickets - for r in rl: - if r[0]: - ret[r[1]] = {} - ret[r[1]]['id'] = r[0] - ret[r[1]]['Total'] = sql("select count(*) from tabTask where allocated_to=%s and docstatus!=2", r[0])[0][0] - ret[r[1]]['Closed'] = sql("select count(*) from tabTask where allocated_to=%s and status='Closed' and docstatus!=2", r[0])[0][0] - ret[r[1]]['percent'] = cint(flt(ret[r[1]]['Closed']) * 100 / ret[r[1]]['Total']) - - return ret - - # -------------------------------------------------------------- - # for Gantt Chart - - def get_init_data(self, arg=''): - pl = [p[0] for p in sql('select name from tabProject where docstatus != 2')] - rl = [p[0] for p in sql('select distinct allocated_to from tabTask where docstatus != 2 and ifnull(allocated_to,"") != ""')] - return {'pl':pl, 'rl':rl} - - def get_tasks(self, arg): - start_date, end_date, project, resource = arg.split('~~~') - - cl = '' - if project and project != 'All': - cl = " and ifnull(project,'') = '%s'" % project - - if resource and resource != 'All': - cl = " and ifnull(allocated_to,'') = '%s'" % resource - - tl = sql(""" - select subject, allocated_to, project, exp_start_date, exp_end_date, priority, status, name - from tabTask - where - ((exp_start_date between '%(st)s' and '%(end)s') or - (exp_end_date between '%(st)s' and '%(end)s') or - (exp_start_date < '%(st)s' and exp_end_date > '%(end)s')) %(cond)s order by exp_start_date limit 100""" % {'st': start_date, 'end': end_date, 'cond':cl}) - - return convert_to_lists(tl) - - def declare_proj_completed(self, arg): - chk = sql("select name from `tabTask` where project=%s and status='Open'", arg) - if chk: - chk_lst = [x[0] for x in chk] - msgprint("Task(s) "+','.join(chk_lst)+" has staus 'Open'. Please submit all tasks against this project before closing the project.") - return cstr('false') - else: - sql("update `tabProject` set status = 'Completed' where name = %s", arg) - return cstr('true') - - -def sent_reminder_task(): - task_list = sql(""" - select subject, allocated_to, project, exp_start_date, exp_end_date, - priority, status, name, senders_name, opening_date, review_date, description - from tabTask - where task_email_notify=1 - and sent_reminder=0 - and status='Open' - and exp_start_date is not null""",as_dict=1) - for i in task_list: - if date_diff(i['exp_start_date'],nowdate()) ==2: - msg2="""

    Two days to complete: %(name)s

    -

    This is a reminder for the task %(name)s has been assigned to you - by %(senders_name)s on %(opening_date)s

    -

    Subject: %(subject)s

    -

    Project: %(project)s

    -

    Expected Start Date: %(exp_start_date)s

    -

    Expected End Date: %(exp_end_date)s

    -

    Review Date: %(review_date)s

    -

    Details: %(description)s

    -

    If you have already completed this task, please update the system

    -

    Good Luck!

    -

    (This notification is autogenerated)

    """ % i - sendmail(i['allocated_to'], msg=msg2, subject='A task has been assigned') - sql("update `tabTask` set sent_reminder='1' where name='%(name)s' and allocated_to= '%(allocated_to)s'" % i) - diff --git a/erpnext/projects/doctype/project_control/project_control.txt b/erpnext/projects/doctype/project_control/project_control.txt deleted file mode 100644 index 76861cc573..0000000000 --- a/erpnext/projects/doctype/project_control/project_control.txt +++ /dev/null @@ -1,30 +0,0 @@ -# DocType, Project Control -[ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:36:06', - 'docstatus': 0, - 'modified': '2012-03-27 14:36:06', - 'modified_by': u'Administrator', - 'owner': u'harshada@webnotestech.com' - }, - - # These values are common for all DocType - { - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'issingle': 1, - 'module': u'Projects', - 'name': '__common__', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'version': 30 - }, - - # DocType, Project Control - { - 'doctype': 'DocType', - 'name': u'Project Control' - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/task/task.txt b/erpnext/projects/doctype/task/task.txt index 9c9f07debe..e5a5602d54 100644 --- a/erpnext/projects/doctype/task/task.txt +++ b/erpnext/projects/doctype/task/task.txt @@ -5,7 +5,7 @@ { 'creation': '2012-06-04 14:05:07', 'docstatus': 0, - 'modified': '2012-08-08 12:53:33', + 'modified': '2012-08-08 14:01:34', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -35,7 +35,8 @@ 'name': '__common__', 'parent': u'Task', 'parentfield': u'fields', - 'parenttype': u'DocType' + 'parenttype': u'DocType', + 'permlevel': 0 }, # These values are common for all DocPerm @@ -54,390 +55,6 @@ 'name': u'Task' }, - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'task_details', - 'fieldtype': u'Section Break', - 'label': u'Task Details', - 'oldfieldtype': u'Section Break', - 'permlevel': 0, - 'search_index': 0, - 'width': u'50%' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'subject', - 'fieldtype': u'Data', - 'in_filter': 1, - 'label': u'Subject', - 'oldfieldname': u'subject', - 'oldfieldtype': u'Data', - 'permlevel': 0, - 'reqd': 1 - }, - - # 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 - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'status', - 'fieldtype': u'Select', - 'label': u'Status', - 'no_copy': 1, - 'oldfieldname': u'status', - 'oldfieldtype': u'Select', - 'options': u'Open\nWorking\nPending Review\nClosed\nCancelled', - 'permlevel': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'priority', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Priority', - 'oldfieldname': u'priority', - 'oldfieldtype': u'Select', - 'options': u'Low\nMedium\nHigh\nUrgent', - 'permlevel': 0, - 'reqd': 0, - 'search_index': 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', - '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 - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'customer', - 'fieldtype': u'Link', - 'label': u'Customer', - 'oldfieldname': u'customer', - 'oldfieldtype': u'Link', - 'options': u'Customer', - 'permlevel': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'customer_name', - 'fieldtype': u'Data', - 'label': u'Customer Name', - 'oldfieldname': u'customer_name', - 'oldfieldtype': u'Data', - 'permlevel': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'column_break25', - 'fieldtype': u'Column Break', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'senders_contact_no', - 'fieldtype': u'Data', - 'label': u'Senders Contact No', - 'oldfieldname': u'senders_contact_no', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'senders_company', - 'fieldtype': u'Data', - 'label': u'Senders Company', - 'oldfieldname': u'senders_company', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'time_and_budget', - 'fieldtype': u'Section Break', - 'label': u'Time and Budget', - 'oldfieldtype': u'Section Break', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'expected', - 'fieldtype': u'Column Break', - 'label': u'Expected', - 'oldfieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'exp_total_hrs', - 'fieldtype': u'Data', - 'label': u'Total Hours (Expected)', - 'oldfieldname': u'exp_total_hrs', - 'oldfieldtype': u'Data', - 'permlevel': 0, - 'reqd': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'allocated_budget', - 'fieldtype': u'Currency', - 'label': u'Allocated Budget', - 'oldfieldname': u'allocated_budget', - 'oldfieldtype': u'Currency', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'actual', - 'fieldtype': u'Column Break', - 'label': u'Actual', - 'oldfieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'act_start_date', - 'fieldtype': u'Date', - 'label': u'Actual Start Date', - 'oldfieldname': u'act_start_date', - 'oldfieldtype': u'Date', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'act_end_date', - 'fieldtype': u'Date', - 'label': u'Actual End Date', - 'oldfieldname': u'act_end_date', - 'oldfieldtype': u'Date', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'act_total_hrs', - 'fieldtype': u'Data', - 'label': u'Total Hours (Actual)', - 'oldfieldname': u'act_total_hrs', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'actual_budget', - 'fieldtype': u'Currency', - 'label': u'Actual Budget', - '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 - }, - # DocPerm { 'amend': 1, @@ -473,5 +90,247 @@ 'doctype': u'DocPerm', 'permlevel': 1, 'role': u'Projects User' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'task_details', + 'fieldtype': u'Section Break', + 'label': u'Task Details', + 'oldfieldtype': u'Section Break', + 'search_index': 0, + 'width': u'50%' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'subject', + 'fieldtype': u'Data', + 'in_filter': 1, + 'label': u'Subject', + 'oldfieldname': u'subject', + 'oldfieldtype': u'Data', + 'reqd': 1 + }, + + # 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', + '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', + 'reqd': 0, + 'search_index': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'column_break0', + 'fieldtype': u'Column Break', + 'oldfieldtype': u'Column Break', + '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', + 'trigger': u'Client' + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'status', + 'fieldtype': u'Select', + 'label': u'Status', + 'no_copy': 1, + 'oldfieldname': u'status', + 'oldfieldtype': u'Select', + 'options': u'Open\nWorking\nPending Review\nClosed\nCancelled', + 'trigger': u'Client' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'priority', + 'fieldtype': u'Select', + 'in_filter': 1, + 'label': u'Priority', + 'oldfieldname': u'priority', + 'oldfieldtype': u'Select', + 'options': u'Low\nMedium\nHigh\nUrgent', + 'reqd': 0, + 'search_index': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'section_break0', + 'fieldtype': u'Section Break', + 'oldfieldtype': u'Section Break', + 'options': u'Simple' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'description', + 'fieldtype': u'Text Editor', + 'label': u'Details', + 'oldfieldname': u'description', + 'oldfieldtype': u'Text Editor', + 'reqd': 0, + 'width': u'300px' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'time_and_budget', + 'fieldtype': u'Section Break', + 'label': u'Time and Budget', + 'oldfieldtype': u'Section Break' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'expected', + 'fieldtype': u'Column Break', + 'label': u'Expected', + 'oldfieldtype': u'Column Break', + 'width': u'50%' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'exp_total_hrs', + 'fieldtype': u'Data', + 'label': u'Total Hours (Expected)', + 'oldfieldname': u'exp_total_hrs', + 'oldfieldtype': u'Data', + 'reqd': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'allocated_budget', + 'fieldtype': u'Currency', + 'label': u'Allocated Budget', + 'oldfieldname': u'allocated_budget', + 'oldfieldtype': u'Currency' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'actual', + 'fieldtype': u'Column Break', + 'label': u'Actual', + 'oldfieldtype': u'Column Break', + 'width': u'50%' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'act_start_date', + 'fieldtype': u'Date', + 'label': u'Actual Start Date', + 'oldfieldname': u'act_start_date', + 'oldfieldtype': u'Date' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'act_end_date', + 'fieldtype': u'Date', + 'label': u'Actual End Date', + 'oldfieldname': u'act_end_date', + 'oldfieldtype': u'Date' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'act_total_hrs', + 'fieldtype': u'Data', + 'label': u'Total Hours (Actual)', + 'oldfieldname': u'act_total_hrs', + 'oldfieldtype': u'Data' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'actual_budget', + 'fieldtype': u'Currency', + 'label': u'Actual Budget', + 'oldfieldname': u'actual_budget', + 'oldfieldtype': u'Currency' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'more_details', + 'fieldtype': u'Section Break', + 'label': u'More Details' + }, + + # 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' + }, + + # 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' } ] \ No newline at end of file diff --git a/erpnext/projects/gantt_task.js b/erpnext/projects/gantt_task.js new file mode 100644 index 0000000000..aa3adbb85f --- /dev/null +++ b/erpnext/projects/gantt_task.js @@ -0,0 +1,88 @@ +// 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 . + +// gantt chart for project tasks + +wn.require('js/lib/jQuery.Gantt/css/style.css'); +wn.require('js/lib/jQuery.Gantt/js/jquery.fn.gantt.min.js'); + +erpnext.show_task_gantt = function(parent, project) { + + $(parent).css('min-height', '300px').html('
    Loading...
    ') + + var get_source = function(r) { + var source = []; + // projects + $.each(r.message, function(i,v) { + source.push({ + name: v.project, + desc: v.subject, + values: [{ + label: v.subject, + desc: v.description || v.subject, + from: '/Date("'+v.exp_start_date+'")/', + to: '/Date("'+v.exp_end_date+'")/', + customClass: { + 'Open':'ganttRed', + 'Pending Review':'ganttOrange', + 'Working':'', + 'Completed':'ganttGreen', + 'Cancelled':'ganttGray' + }[v.status], + dataObj: v + }] + }) + }); + return source + } + wn.call({ + method: 'projects.page.projects.projects.get_tasks', + args: { + project: project || '' + }, + callback: function(r) { + $(parent).empty(); + if(!r.message.length) { + $(parent).html('
    No Tasks Yet.
    '); + } else { + var gantt_area = $('
    ').appendTo(parent); + gantt_area.gantt({ + source: get_source(r), + navigate: project ? "button" : "scroll", + scale: "weeks", + minScale: "weeks", + maxScale: "months", + onItemClick: function(data) { + wn.set_route('Form', 'Task', data.name); + }, + onAddClick: function(dt, rowId) { + newdoc('Task'); + } + }); + } + + $('').click(function() { + wn.model.with_doctype('Task', function() { + var new_name = LocalDB.create('Task'); + if(project) + locals.Task[new_name].project = project; + wn.set_route('Form', 'Task', new_name); + }); + }).appendTo(parent); + } + }) +} diff --git a/erpnext/projects/page/projects/projects.js b/erpnext/projects/page/projects/projects.js index f9af826911..e67959e7b4 100644 --- a/erpnext/projects/page/projects/projects.js +++ b/erpnext/projects/page/projects/projects.js @@ -16,56 +16,9 @@ pscript.onload_Projects = function(wrapper) { wn.ui.make_app_page({parent:wrapper, title:'Gantt Chart: All Tasks', single_column:true}); - - $(wrapper).find('.layout-main').html('
    Loading...
    ') - - - wn.require('js/lib/jQuery.Gantt/css/style.css'); - wn.require('js/lib/jQuery.Gantt/js/jquery.fn.gantt.min.js'); - - wn.call({ - method: 'projects.page.projects.projects.get_tasks', - callback: function(r) { - $(wrapper).find('.layout-main').empty(); - - var source = []; - // projects - $.each(r.message, function(i,v) { - source.push({ - name: v.project, - desc: v.subject, - values: [{ - label: v.subject, - desc: v.description || v.subject, - from: '/Date("'+v.exp_start_date+'")/', - to: '/Date("'+v.exp_end_date+'")/', - customClass: { - 'Open':'ganttRed', - 'Pending Review':'ganttOrange', - 'Working':'', - 'Completed':'ganttGreen', - 'Cancelled':'ganttGray' - }[v.status], - dataObj: v - }] - }) - }) - - var gantt_area = $('
    ').appendTo($(wrapper).find('.layout-main')); - gantt_area.gantt({ - source: source, - navigate: "scroll", - scale: "weeks", - minScale: "weeks", - maxScale: "months", - onItemClick: function(data) { - wn.set_route('Form', 'Task', data.name); - }, - onAddClick: function(dt, rowId) { - - } - }); - - } - }) + if(!erpnext.show_task_gantt) + wn.require('js/gantt_task.js'); + + var gantt_area = $('
    ').appendTo($(wrapper).find('.layout-main')); + erpnext.show_task_gantt(gantt_area); } \ No newline at end of file diff --git a/erpnext/projects/page/projects/projects.py b/erpnext/projects/page/projects/projects.py index 4774194cfc..b9ee190827 100644 --- a/erpnext/projects/page/projects/projects.py +++ b/erpnext/projects/page/projects/projects.py @@ -18,8 +18,11 @@ import webnotes @webnotes.whitelist() def get_tasks(): + cond = '' + if webnotes.form_dict.get('project'): + cond = ' and project="%s"' % webnotes.form_dict.get('project') return webnotes.conn.sql("""select name, project, subject, exp_start_date, exp_end_date, description, status 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 + and exp_end_date is not null %s""" % cond, as_dict=True) \ No newline at end of file diff --git a/public/js/all-app.js b/public/js/all-app.js index bd5af85762..6f2bf1ff0f 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1104,7 +1104,7 @@ Layout.prototype.show=function(){$ds(this.wrapper);} Layout.prototype.hide=function(){$dh(this.wrapper);} Layout.prototype.close_borders=function(){if(this.with_border){this.myrows[this.myrows.length-1].wrapper.style.borderBottom='1px solid #000';}} function LayoutRow(layout,parent){this.layout=layout;this.wrapper=$a(parent,'div','form-layout-row');this.main_head=$a(this.wrapper,'div');this.main_body=$a(this.wrapper,'div');if(layout.with_border){this.wrapper.style.border='1px solid #000';this.wrapper.style.borderBottom='0px';} -this.header=$a(this.main_body,'div','',{padding:(layout.with_border?'0px 8px':'0px')});this.body=$a(this.main_body,'div');this.table=$a(this.body,'table','',{width:'100%',borderCollapse:'collapse'});this.row=this.table.insertRow(0);this.mycells=[];} +this.header=$a(this.main_body,'div','',{padding:(layout.with_border?'0px 8px':'0px')});this.body=$a(this.main_body,'div');this.table=$a(this.body,'table','',{width:'100%',borderCollapse:'collapse',tableLayout:'fixed'});this.row=this.table.insertRow(0);this.mycells=[];} LayoutRow.prototype.hide=function(){$dh(this.wrapper);} LayoutRow.prototype.show=function(){$ds(this.wrapper);} LayoutRow.prototype.addCell=function(wid){var lc=new LayoutCell(this.layout,this,wid);this.mycells[this.mycells.length]=lc;return lc;} diff --git a/public/js/gantt_task.js b/public/js/gantt_task.js new file mode 100644 index 0000000000..11f2009f03 --- /dev/null +++ b/public/js/gantt_task.js @@ -0,0 +1,10 @@ + +/* + * erpnext/projects/gantt_task.js + */ +wn.require('js/lib/jQuery.Gantt/css/style.css');wn.require('js/lib/jQuery.Gantt/js/jquery.fn.gantt.min.js');erpnext.show_task_gantt=function(parent,project){$(parent).css('min-height','300px').html('
    Loading...
    ') +var get_source=function(r){var source=[];$.each(r.message,function(i,v){source.push({name:v.project,desc:v.subject,values:[{label:v.subject,desc:v.description||v.subject,from:'/Date("'+v.exp_start_date+'")/',to:'/Date("'+v.exp_end_date+'")/',customClass:{'Open':'ganttRed','Pending Review':'ganttOrange','Working':'','Completed':'ganttGreen','Cancelled':'ganttGray'}[v.status],dataObj:v}]})});return source} +wn.call({method:'projects.page.projects.projects.get_tasks',args:{project:project||''},callback:function(r){$(parent).empty();if(!r.message.length){$(parent).html('
    No Tasks Yet.
    ');}else{var gantt_area=$('
    ').appendTo(parent);gantt_area.gantt({source:get_source(r),navigate:project?"button":"scroll",scale:"weeks",minScale:"weeks",maxScale:"months",onItemClick:function(data){wn.set_route('Form','Task',data.name);},onAddClick:function(dt,rowId){newdoc('Task');}});} +$('').click(function(){wn.model.with_doctype('Task',function(){var new_name=LocalDB.create('Task');if(project) +locals.Task[new_name].project=project;wn.set_route('Form','Task',new_name);});}).appendTo(parent);}})} \ No newline at end of file