file upload should not be decoded

This commit is contained in:
Rushabh Mehta
2012-08-08 10:37:02 +05:30
15 changed files with 296 additions and 477 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
@@ -35,59 +35,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)

View File

@@ -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
}
]

View File

@@ -217,7 +217,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'

View File

@@ -0,0 +1,6 @@
.gantt {
-moz-box-sizing: border-box;
border: 14px solid #DDDDDD;
border-radius: 6px 6px 6px 6px;
margin: 20px auto;
}

View File

@@ -1 +0,0 @@
<div id="projects_div" class="layout_wrapper"></div>

View File

@@ -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('<div class="help-box">Loading...</div>')
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<this.tasks.length; i++) {
new GanttTask(this.grid, this.tasks[i], i)
}
}
// ==========================================================================
GanttGrid = function(chart, s_date, e_date) {
this.chart = chart;
this.s_date = s_date;
this.wrapper = $a(chart.grid_area, 'div');
this.start_date = date.str_to_obj(date.user_to_str(s_date));
this.end_date = date.str_to_obj(date.user_to_str(e_date));
this.n_days = date.get_diff(this.end_date, this.start_date) + 1;
this.g_width = 100 / this.n_days + '%';
this.make();
}
GanttGrid.prototype.make = function() {
this.body = make_table(this.wrapper, 1, 2, '100%', ['30%','70%']);
this.make_grid();
this.make_labels();
this.y_labels = $a($td(this.body, 0, 0), 'div', '', {marginTop:'2px', position:'relative'});
}
GanttGrid.prototype.make_grid = function() {
// grid -----------
var ht = this.chart.tasks.length * 40 + 'px';
this.grid = $a($td(this.body, 0, 1), 'div', '', {border:'2px solid #888', height: ht, position:'relative'});
this.grid_tab = make_table(this.grid, 1, this.n_days, '100%', [], {width:this.g_width, borderLeft:'1px solid #DDD', height: ht});
$y(this.grid_tab,{tableLayout:'fixed'});
this.task_area = $a(this.grid, 'div', '', {position:'absolute', height:ht, width: '100%', top:'0px'});
}
GanttGrid.prototype.make_labels = function() {
// labels ------------
this.x_labels = $a($td(this.body, 0, 1), 'div', '', {marginTop:'8px'});
this.x_lab_tab = make_table(this.x_labels, 1, this.n_days, '100%', [], {width:this.g_width, fontSize:'10px'});
$y(this.x_lab_tab,{tableLayout:'fixed'});
var d = this.start_date;
var today = new Date();
for(var i=0; i<this.n_days; i++) {
if(d.getDay()==0) {
$td(this.x_lab_tab,0,i).innerHTML = d.getDate() + '-' + month_list[d.getMonth()];
$y($td(this.grid_tab,0,i),{borderLeft:'1px solid RED'})
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+'")/'
}]
})
})
var gantt_area = $('<div class="gantt">').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 = '<div>';
if(d[0]) t += '<b>Task: </b>' + d[0];
if(d[5]) t += '<br><b>Priority: </b>' + d[5];
if(d[6]) t += '<br><b>Status: </b>' + d[6];
if(d[1]) t += '<br><b>Allocated To: </b>' + d[1];
if(d[2]) t += '<br><b>Project: </b>' + d[2];
if(d[3]) t += '<br><b>From: </b>' + date.str_to_user(d[3]);
if(d[4]) t += '<br><b>To: </b>' + date.str_to_user(d[4]);
t += '</div>';
msgprint(t)
})
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
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)

View File

@@ -1 +0,0 @@
Projects