diff --git a/css/all-app.css b/css/all-app.css index f30d1cfaca2..4ed2d5771aa 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -1732,6 +1732,7 @@ div.stat-bar { font-weight: 400; src: local('Open Sans'), local('OpenSans'), url('../lib/css/fonts/opensans.woff') format('woff'); } + @font-face { font-family: 'Lato'; font-style: normal; @@ -1739,6 +1740,12 @@ div.stat-bar { src: local('Lato Regular'), local('Lato-Regular'), url('../lib/css/fonts/lato.woff') format('woff'); } +@font-face { + font-family: 'Cabin'; + font-style: normal; + font-weight: 400; + src: local('Cabin Regular'), local('Cabin-Regular'), url('../lib/css/fonts/cabin.woff') format('woff'); +} /* diff --git a/css/all-web.css b/css/all-web.css index ad1304ba1f3..bdd2ad584f5 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -1627,6 +1627,7 @@ button.btn.small, input[type="submit"].btn.small { font-weight: 400; src: local('Open Sans'), local('OpenSans'), url('../lib/css/fonts/opensans.woff') format('woff'); } + @font-face { font-family: 'Lato'; font-style: normal; @@ -1634,6 +1635,12 @@ button.btn.small, input[type="submit"].btn.small { src: local('Lato Regular'), local('Lato-Regular'), url('../lib/css/fonts/lato.woff') format('woff'); } +@font-face { + font-family: 'Cabin'; + font-style: normal; + font-weight: 400; + src: local('Cabin Regular'), local('Cabin-Regular'), url('../lib/css/fonts/cabin.woff') format('woff'); +} /* diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index a8550d5b7ea..7e77068f68d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -17,7 +17,7 @@ cur_frm.cscript.tname = "Purchase Invoice Item"; cur_frm.cscript.fname = "entries"; cur_frm.cscript.other_fname = "purchase_tax_details"; -wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js'); +wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js'); wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js'); // On Load diff --git a/erpnext/buying/doctype/purchase_taxes_and_charges_master/__init__.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/__init__.py similarity index 100% rename from erpnext/buying/doctype/purchase_taxes_and_charges_master/__init__.py rename to erpnext/accounts/doctype/purchase_taxes_and_charges_master/__init__.py diff --git a/erpnext/buying/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js similarity index 100% rename from erpnext/buying/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js rename to erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js diff --git a/erpnext/buying/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py similarity index 100% rename from erpnext/buying/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py rename to erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py diff --git a/erpnext/buying/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt similarity index 98% rename from erpnext/buying/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt rename to erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt index 4c07ca14ca4..1ecac405f3e 100644 --- a/erpnext/buying/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt @@ -19,7 +19,7 @@ 'default_print_format': u'Standard', 'doctype': 'DocType', 'document_type': u'Master', - 'module': u'Buying', + 'module': u'Accounts', 'name': '__common__', 'section_style': u'Simple', 'server_code_error': u' ', diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 68cdf1f747b..8091aeeada7 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -23,7 +23,7 @@ cur_frm.cscript.sales_team_fname = "sales_team"; cur_frm.pformat.print_heading = 'Invoice'; wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); -wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); diff --git a/erpnext/home/page/event_updates/__init__.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/__init__.py similarity index 100% rename from erpnext/home/page/event_updates/__init__.py rename to erpnext/accounts/doctype/sales_taxes_and_charges_master/__init__.py diff --git a/erpnext/setup/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js similarity index 100% rename from erpnext/setup/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js rename to erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js diff --git a/erpnext/setup/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py similarity index 100% rename from erpnext/setup/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py rename to erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py diff --git a/erpnext/setup/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt similarity index 99% rename from erpnext/setup/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt rename to erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt index 2ab0541ba02..655269c26ef 100644 --- a/erpnext/setup/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt @@ -19,7 +19,7 @@ 'default_print_format': u'Standard', 'doctype': 'DocType', 'document_type': u'Master', - 'module': u'Setup', + 'module': u'Accounts', 'name': '__common__', 'section_style': u'Tabbed', 'server_code_error': u' ', @@ -192,4 +192,4 @@ 'options': u'Sales Taxes and Charges', 'permlevel': 0 } -] \ No newline at end of file +] diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 15057924172..82abd6bc3cd 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -18,7 +18,7 @@ cur_frm.cscript.tname = "Purchase Order Item"; cur_frm.cscript.fname = "po_details"; cur_frm.cscript.other_fname = "purchase_tax_details"; -wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js'); +wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js'); wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js'); wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); diff --git a/erpnext/home/page/event_updates/.DS_Store b/erpnext/home/page/event_updates/.DS_Store deleted file mode 100644 index 5008ddfcf53..00000000000 Binary files a/erpnext/home/page/event_updates/.DS_Store and /dev/null differ diff --git a/erpnext/home/page/event_updates/event_updates.css b/erpnext/home/page/event_updates/event_updates.css deleted file mode 100644 index a88fed48b16..00000000000 --- a/erpnext/home/page/event_updates/event_updates.css +++ /dev/null @@ -1,62 +0,0 @@ -div.home-status { - margin: 7px; - padding: 5px; - color: #666; -} - -span.home-status-link { - cursor: pointer; - text-decoration: underline; -} - -span.home-status-unread { - padding: 2px 3px; - font-size: 11px; - color: #FFF; - background-color: RED; -} - -div.setup-wizard { - display: none; - margin: 13px 0px; - background-color: #FED; - padding: 13px; -} - -div.setup-wizard .header { - font-size: 12px; - font-weight: bold; - color: #322; - margin-bottom: 7px; -} - - -div.setup-wizard .percent-outer { - height: 17px; - background-color: #FFF; - border: 2px solid #322; -} - -div.setup-wizard .percent-inner { - height: 17px; - background-color: GREEN; -} - -div.setup-wizard .suggestion { - margin: 7px 0px; - color: #322; -} - -div.setup-wizard .prev-next { - height: 13px; -} - -div.setup-wizard .prev-next span { - display: none; - float: right; - margin-left: 13px; - color: #877; - font-size: 11px; -} - - diff --git a/erpnext/home/page/event_updates/event_updates.html b/erpnext/home/page/event_updates/event_updates.html deleted file mode 100644 index 41ae9a56c2b..00000000000 --- a/erpnext/home/page/event_updates/event_updates.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/erpnext/home/page/event_updates/event_updates.js b/erpnext/home/page/event_updates/event_updates.js deleted file mode 100644 index 797d8e95c9d..00000000000 --- a/erpnext/home/page/event_updates/event_updates.js +++ /dev/null @@ -1,671 +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 . - -pscript['onload_Event Updates'] = function() { - if(user=='Guest') { - loadpage('Login Page'); - return; - } - - pscript.home_make_body(); - pscript.home_make_status(); - pscript.home_set_banner(); - pscript.home_make_widgets(); -} - -// ================================== - -pscript.home_make_body = function() { - var wrapper = wn.pages['Event Updates']; - - // body - $(wrapper).addClass('layout-wrapper').addClass('layout-wrapper-background') - - wrapper.body = $a(wrapper, 'div', 'layout-main-section'); - wrapper.head = $a(wrapper.body, 'div'); - wrapper.side_section =$a(wrapper, 'div', 'layout-side-section'); - $a(wrapper, 'div', '', {clear:'both'}); - - wrapper.banner_area = $a(wrapper.head, 'div'); - - wrapper.setup_wizard_area = $a(wrapper.body, 'div', 'setup-wizard'); -} - -// ================================== - -pscript.home_set_banner = function(wrapper) { - var wrapper = wn.pages['Event Updates']; - var cp = wn.control_panel; - - // banner - if(cp.client_name) { - var banner = $a(wrapper.banner_area, 'div', '', {paddingBottom:'4px'}) - banner.innerHTML = cp.client_name; - } -} - -// Widgets -// ================================== - -pscript.home_make_widgets = function() { - var wrapper = wn.pages['Event Updates']; - var cell = wrapper.side_section; - - // sidebar - sidebar = new wn.widgets.PageSidebar(cell, { - sections:[ - { - title: 'Calendar', - display: function() { return !has_common(user_roles, ['Guest','Customer','Vendor'])}, - render: function(wrapper) { - new HomeCalendar(new HomeWidget(wrapper, 'Calendar', 'Event'), wrapper); - } - }, - - { - title: 'To Do', - display: function() { return !has_common(user_roles, ['Guest','Customer','Vendor'])}, - render: function(wrapper) { - new HomeToDo(new HomeWidget(wrapper, 'To Do', 'Item')); - } - }, - - { - title: 'Online Users', - display: function() { return !has_common(user_roles, ['Guest','Customer','Vendor'])}, - render: function(wrapper) { - pscript.online_users_obj = new OnlineUsers(wrapper); - } - } - ] - }); - - new FeedList(wrapper.body); -} - -OnlineUsers = function(wrapper) { - var me = this; - this.wrapper = wrapper; - - this.my_company_link = function() { - $a($a(wrapper, 'div', '', {marginBottom:'7px'}), 'span', 'link_type', - {color:'#777', 'color:hover':'#FFF', fontSize:'11px'}, - 'See all users', function() {loadpage('My Company'); }); - } - - this.render = function(online_users) { - me.my_company_link(); - - if(online_users.length) { - var max = online_users.length; max = (max > 10 ? 10 : max) - me.wrapper.innerHTML = ""; - for(var i=0; i '; - $a($td(tab, 0, 1), 'span', 'social', {}, replace_newlines(det.description)); - - if(det.ref_type && det.ref_name && det.ref_name != 'None') { - var span=$a($a($td(tab, 0, 1),'div'),'span','link_type'); - span.innerHTML = det.ref_name; span.dt = det.ref_type; - span.onclick = function() { loaddoc(this.dt, this.innerHTML); } - } -} - -HomeCalendar.prototype.clear_dialog = function() { - this.set_dialog_values({event_date:get_today(), event_hour:'8:00', description:''}); -} - -HomeCalendar.prototype.set_dialog_values = function(det) { - var d = this.widget.dialog; - d.set_values(det); - d.det = det; -} - -HomeCalendar.prototype.save = function(btn) { - var d = this.widget.dialog; - var me = this; - var det = d.get_values(); - - if(!det) { - btn.done_working(); - return; - } - - det.name = d.det.name; - det.owner = user; - if(!det.event_type) - det.event_type = 'Private'; - - var callback = function(r,rt) { - btn.done_working(); - me.widget.dialog.hide(); - me.widget.refresh(); - } - $c_obj('Home Control','edit_event',JSON.stringify(det),callback); -} - -// Todo -// =========================== - -HomeToDo = function(widget) { - this.widget = widget; - - // methods - this.widget.get_list_method = 'get_todo_list'; - this.widget.delete_method = 'remove_todo_item'; - this.widget.no_items_message = 'Nothing to do?'; - this.widget.get_item_id = function(det) { return det.name; } - - this.widget.decorator = this; - - this.widget.dialog_fields = [ - {fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, - {fieldtype:'Text', fieldname:'description', label:'Description', 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'} - ]; - - this.widget.refresh(); -} - -HomeToDo.prototype.render_item = function(item, det) { - - // priority tag - var tab = make_table($td(item.tab, 0, 0), 1, 2, '100%', ['48px', null], {padding:'2px'}); - $y(tab, {tableLayout:'fixed'}); - - var span = $a($td(tab, 0, 0), 'span', '', {padding:'2px',color:'#FFF',fontSize:'10px' - , backgroundColor:(det.priority=='Low' ? '#888' : - (det.priority=='High' ? '#EDA857' : '#687FD3'))}); - - $(span).css('-moz-border-radius','3px').css('-webkit-border-radius','3px'); - span.innerHTML = det.priority; - - // text - var span = $a($td(tab, 0, 1), 'div', 'social', {lineHeight:'1.5em'}, - replace_newlines(det.description)); - if(det.checked) $y(span,{textDecoration:'line-through'}); - - // reference link - if(det.reference_name) { - $a($td(tab, 0, 1), 'div', 'social', '', - repl('%(reference_name)s', - det)) - } - - // if expired & open, then in red - if(!det.checked && dateutil.str_to_obj(det.date) < new Date()) { - $y(span,{color:'RED'}); - $a($td(tab, 0, 1), 'div', '', {fontSize:'10px', color:'#666'}, - dateutil.str_to_user(det.date) + ' (Overdue)'); - } else { - $a($td(tab, 0, 1), 'div', '', {fontSize:'10px', color:'#666'}, - dateutil.str_to_user(det.date)); - } -} - -HomeToDo.prototype.clear_dialog = function() { - this.set_dialog_values(['','',get_today(),'Medium',0]); -} - -HomeToDo.prototype.set_dialog_values = function(det) { - var d = this.widget.dialog; - d.set_values({ - date: det.date, - priority: det.priority, - description: det.description, - checked: det.checked - }); - d.det = det; -} - -HomeToDo.prototype.save = function(btn) { - var d = this.widget.dialog; - var me = this; - - var det = d.get_values() - if(!det) { - btn.done_working(); - return; - } - - det.name = d.det.name; - var callback = function(r,rt) { - btn.done_working(); - me.widget.dialog.hide(); - me.widget.refresh(); - } - $c_obj('Home Control','add_todo_item',JSON.stringify(det),callback); -} - -// Feed -// ================================== - - -FeedList = function(parent) { - // settings - this.auto_feed_off = cint(sys_defaults.auto_feed_off); - - this.wrapper = $a(parent, 'div'); - this.make_head(); - this.make_list(); - this.list.run(); -} - -FeedList.prototype.make_head = function() { - var me = this; - this.head = $a(this.wrapper, 'div', '', {marginBottom:'8px'}); - - // head - - $a(this.head,'h1','', {display:'inline'}, 'Home'); - - // refresh - $a(this.head,'span','link_type', - {marginLeft:'7px', fontSize:'11px'}, 'refresh', - function() { me.run(); } - ); - - if(has_common(user_roles, ['System Manager','Accounts Manager'])) { - $btn(this.head, 'Dashboard', function() {loadpage('dashboard'); }, {marginLeft:'7px'}, 'cupid-blue') - - } -} - -FeedList.prototype.run = function() { - this.prev_date = null; - this.list.run(); -} - -FeedList.prototype.make_list = function() { - var me = this; - this.list_area = $a(this.wrapper,'div') - - this.list = new wn.ui.Listing({ - parent: this.list_area, - query: repl('select \ - distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.modified_by, \ - if(ifnull(t1.full_name,"")="", t1.owner, t1.full_name) as full_name, \ - t1.modified, t1.color \ - from tabFeed t1, tabUserRole t3, tabDocPerm t4 \ - where t1.doc_type = t4.parent \ - and t3.parent = "%(user)s" \ - and t4.role = t3.role \ - and ifnull(t4.`read`,0) = 1 \ - order by t1.modified desc', {user:user}), - no_result_message: 'Nothing to show yet. Your feed will be updated as you start your activities', - render_row: function(parent, data) { - me.render_feed(parent, data) - }, - onrun: function() { - $(me.wrapper).fadeIn(); - if(me.after_run) me.after_run(); - }, - hide_refresh: true - }); -} - -FeedList.prototype.render_feed = function(parent, data) { - new FeedItem(parent, data, this); -} - -// Item -// ------------------------------- - -FeedItem = function(cell, det, feedlist) { - var me = this; - - this.det = det; this.feedlist = feedlist; - this.wrapper = $a(cell,'div','',{paddingBottom:'4px'}); - this.head = $a(this.wrapper,'div'); - - this.tab = make_table(this.wrapper, 1, 2, '100%', [(100/7)+'%', (600/7)+'%']); - $y(this.tab,{tableLayout:'fixed'}) - - $y($td(this.tab,0,0),{textAlign:'right',paddingRight:'4px'}); - - // text - this.text_area = $a($td(this.tab,0,1), 'div'); - this.render_references(this.text_area, det); - this.render_tag(det); - - // add day separator - this.add_day_sep(det); -} - -// Day separator -// ------------------------------------------------- - -FeedItem.prototype.add_day_sep = function(det) { - var me = this; - var prev_date = det.modified.split(' ')[0]; - - var make_div = function() { - var div = $a(me.head, 'div', '', - {borderBottom:'1px solid #888', margin:'8px 0px', padding:'2px 0px', color:'#888', fontSize:'11px'}); - div.innerHTML = comment_when(det.modified, 1); - - // today? - if(prev_date==get_today()) { - div.innerHTML = ''; - span = $a(div, 'span', '', {padding:'2px', color:'#000', fontWeight:'bold'}); - span.innerHTML = 'Today'; - } - } - - if(this.feedlist.prev_date && this.feedlist.prev_date != prev_date) { make_div(); } - if(!this.feedlist.prev_date) { make_div(); } - this.feedlist.prev_date = prev_date; -} - -// Tag -// ------------------------------------------------- - -FeedItem.prototype.render_tag = function(det) { - // type is the name - tag = $a($td(this.tab,0,0), 'div', '', - {color:'#FFF', padding:'3px', textAlign:'right', fontSize:'11px', - whiteSpace:'nowrap', overflow:'hidden', cursor:'pointer'}); - $br(tag,'3px'); - $y(tag, {backgroundColor:(det.color || '#273')}); - - // tag label - tag.innerHTML = det.feed_type || get_doctype_label(det.doc_type); - - // not comment / label - if(!det.feed_type) { - tag.dt = det.doc_type; - tag.onclick = function() { loaddocbrowser(this.dt); } - } -} - -FeedItem.prototype.render_references = function(div, det) { - // name - div.tab = make_table(div, 1, 2, '100%', [null, '15%']) - var dt = det.doc_type; var dn = det.doc_name - - // link - if(det.feed_type=='Login') { - // nothing - no link - } else { - var allow = in_list(profile.can_read, dt); - var span = $a($td(div.tab,0,0), 'span', (allow ? 'link_type': ''), null, - det.doc_name); - span.dt = dt; span.dn = dn; - if(allow) span.onclick = function() { loaddoc(this.dt, this.dn); } - } - - // subject - if(det.subject) { - $a($td(div.tab,0,0), 'span', '', {marginLeft:'7px', color:'#444'}, det.subject); - } - - // by - $y($td(div.tab,0,1), {fontSize:'11px'}).innerHTML = - (strip(det.full_name) ? det.full_name : det.modified_by); -} - -pscript.home_make_status = function() { - var wrapper = wn.pages['Event Updates']; - - // get values - $c_page('home', 'event_updates', 'get_status_details', user, - function(r,rt) { - //wn.container.wntoolbar.set_new_comments(r.message.unread_messages); - - // render online users - pscript.online_users_obj.render(r.message.online_users); - pscript.online_users = r.message.online_users; - - // complete registration - if(in_list(user_roles,'System Manager')) { - wn.require("erpnext/home/page/event_updates/complete_registration.js"); - pscript.complete_registration(r.message.registration_complete, r.message.profile); - } - - // setup wizard - if(r.message.setup_status) { - new SetupWizard(r.message.setup_status) - } - } - ); -} - -SetupWizard = function(status) { - var me = this; - $.extend(this, { - make: function(status) { - me.status = status; - me.wrapper = wn.pages['Event Updates'].setup_wizard_area; - $ds(me.wrapper); - me.make_percent(status.percent); - me.make_suggestion(status.ret); - }, - make_percent: function(percent) { - $a(me.wrapper, 'div', 'header', {}, 'Your setup is '+percent+'% complete'); - var o = $a(me.wrapper, 'div', 'percent-outer'); - $a(o, 'div', 'percent-inner', {width:percent + '%'}); - }, - make_suggestion: function(ret) { - me.suggest_area = $a(me.wrapper, 'div', 'suggestion'); - if(me.status.ret.length>1) { - me.prev_next = $a(me.wrapper, 'div', 'prev-next'); - - // next - me.next = $a(me.prev_next, 'span', 'link_type', null, 'Next Suggestion', - function() { me.show_suggestion(me.cur_sugg+1) }); - - // prev - me.prev = $a(me.prev_next, 'span', 'link_type', null, 'Previous Suggestion', - function() { me.show_suggestion(me.cur_sugg-1) }); - - } - if(me.status.ret.length) { - me.show_suggestion(0); - } else { - me.suggest_area.innerHTML = 'Congratulations: '.bold() + 'You are now on your track... Good luck'; - } - }, - show_suggestion: function(idx) { - me.cur_sugg = idx; - me.suggest_area.innerHTML = 'What you can do next: '.bold() + me.status.ret[idx]; - - // show hide prev, next - if(me.status.ret.length>1) { - $dh(me.prev); $dh(me.next); - if(idx>0) $ds(me.prev); - if(idx. - -import webnotes -from webnotes.utils import cint - -@webnotes.whitelist() -def get_online_users(arg=None): - # get users - return webnotes.conn.sql("""SELECT DISTINCT t1.user, t2.first_name, t2.last_name - from tabSessions t1, tabProfile t2 - where t1.user = t2.name - and t1.user not in ('Guest','Administrator') - and TIMESTAMPDIFF(HOUR,t1.lastupdate,NOW()) <= 1""", as_list=1) or [] - -def get_unread_messages(): - "returns unread (docstatus-0 messages for a user)" - return webnotes.conn.sql("""\ - SELECT name, comment - FROM `tabComment` - WHERE comment_doctype IN ('My Company', 'Message') - AND comment_docname = %s - AND ifnull(docstatus,0)=0 - """, webnotes.user.name, as_list=1) - -def get_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` - WHERE status = 'Open'""") - return open_support_tickets and cint(open_support_tickets[0][0]) or 0 - -def get_things_todo(): - """ - Returns a count of incomplete todos - """ - from webnotes.utils import cint - incomplete_todos = webnotes.conn.sql("""\ - SELECT COUNT(*) FROM `tabToDo` - WHERE IFNULL(checked, 0) = 0 - AND owner = %s""", webnotes.session.get('user')) - return incomplete_todos and cint(incomplete_todos[0][0]) or 0 - -def get_todays_events(): - """ - Returns a count of todays events in calendar - """ - from webnotes.utils import nowdate, cint - todays_events = webnotes.conn.sql("""\ - SELECT COUNT(*) FROM `tabEvent` - WHERE owner = %s - AND event_type != 'Cancel' - AND event_date = %s""", ( - webnotes.session.get('user'), nowdate())) - return todays_events and cint(todays_events[0][0]) or 0 - -@webnotes.whitelist() -def get_global_status_messages(arg=None): - return { - 'unread_messages': get_unread_messages(), - 'open_support_tickets': get_open_support_tickets(), - 'things_todo': get_things_todo(), - 'todays_events': get_todays_events(), - } - -@webnotes.whitelist() -def get_status_details(arg=None): - """get toolbar items""" - from webnotes.utils import cint, date_diff, nowdate, get_defaults - - online = get_online_users() - - # system messages - ret = { - 'user_count': len(online) or 0, - #'unread_messages': get_unread_messages(), - #'open_support_tickets': get_open_support_tickets(), - 'online_users': online or [], - 'setup_status': get_setup_status(), - 'registration_complete': cint(get_defaults('registration_complete')) and 'Yes' or 'No', - 'profile': webnotes.conn.sql("""\ - SELECT first_name, last_name FROM `tabProfile` - WHERE name=%s AND docstatus<2""", webnotes.user.name, as_dict=1) - } - return ret - -def get_setup_status(arg=None): - """ - Returns the setup status of the current account - """ - if cint(webnotes.conn.get_global('setup_done')): - return '' - - percent = 20 - ret = [] - - def is_header_set(): - header = webnotes.conn.get_value('Control Panel', None, 'client_name') or '' - - if header.startswith('
'\ - +(webnotes.conn.get_value('Control Panel', None, 'company_name') or '')): - return False - - elif 'Banner Comes Here' in header: - return False - - else: - return True - - if not is_header_set(): - ret.append('Upload your company banner') - else: - percent += 20 - - def check_type(doctype, ret, percent): - if not webnotes.conn.sql("select count(*) from tab%s" % doctype)[0][0]: - ret.append(''' - - Create a new %(dt)s - or - - Import from a spreadsheet''' % {'dt':doctype}) - else: - percent += 20 - return ret, percent - - ret, percent = check_type('Item', ret, percent) - ret, percent = check_type('Customer', ret, percent) - ret, percent = check_type('Supplier', ret, percent) - - if percent==100: - webnotes.conn.set_global('setup_done', '1') - return '' - - return {'ret': ret, 'percent': percent} - diff --git a/erpnext/home/page/event_updates/event_updates.txt b/erpnext/home/page/event_updates/event_updates.txt deleted file mode 100644 index 21d93500339..00000000000 --- a/erpnext/home/page/event_updates/event_updates.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Page, Event Updates -[ - - # These values are common in all dictionaries - { - 'creation': '2010-12-14 10:23:23', - 'docstatus': 0, - 'modified': '2010-12-27 10:58:56', - 'modified_by': 'Administrator', - 'owner': 'Administrator' - }, - - # These values are common for all Page - { - 'doctype': 'Page', - 'module': 'Home', - 'name': '__common__', - 'page_name': 'Event Updates', - 'standard': 'Yes' - }, - - # Page, Event Updates - { - 'doctype': 'Page', - 'name': 'Event Updates' - } -] \ No newline at end of file diff --git a/erpnext/home/page/event_updates/event_updates_static.html b/erpnext/home/page/event_updates/event_updates_static.html deleted file mode 100644 index 682f1b2c5e3..00000000000 --- a/erpnext/home/page/event_updates/event_updates_static.html +++ /dev/null @@ -1 +0,0 @@ -Event Updates \ No newline at end of file diff --git a/erpnext/home/page/my_company/__init__.py b/erpnext/home/page/my_company/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/erpnext/home/page/my_company/my_company.css b/erpnext/home/page/my_company/my_company.css deleted file mode 100644 index d2d9a668f42..00000000000 --- a/erpnext/home/page/my_company/my_company.css +++ /dev/null @@ -1,82 +0,0 @@ -/* item */ - -div.my-company-member-item-selected { - background-color: #BBC; -} - - - -/* profile */ -.my-company-name-head { - font-size: 14px; - font-weight: bold; - margin-bottom: 7px; -} - -.my-company-email { - margin-bottom: 7px; - color: #888; -} - -.my-company-online-status { - font-weight: bold; - margin-left: 7px; -} - -.my-company-status { - margin-bottom: 7px; - color: #888; - font-style: italics; -} - -.my-company-bio { - margin-bottom: 7px; -} - -.my-company-toolbar { - margin: 7px 0px; -} - -/* conversation */ - -.my-company-input-wrapper { - color: #555; - padding: 13px; -} - -.my-company-input-wrapper td { - vertical-align: bottom; -} - -.my-company-input-wrapper textarea { - height: 3em; - font-size: 14px; - width: 100%; - margin: 7px 0px 3px 0px; -} - -.my-company-input-wrapper button { - margin: 0px; -} - -.my-company-conversation { - border-top: 1px solid #DDD; -} -.my-company-comment-wrapper { - padding: 7px; - border-bottom: 1px solid #DDD; -} - -.my-company-timestamp { - color: #888; - font-size: 11px; - margin: 3px; -} - -.my-company-conversation-head { - padding: 3px; - background-color: #DEDEDE; - color: #555; - font-size: 14px; - text-align: center; -} \ No newline at end of file diff --git a/erpnext/home/page/my_company/my_company.html b/erpnext/home/page/my_company/my_company.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/erpnext/home/page/my_company/my_company.js b/erpnext/home/page/my_company/my_company.js deleted file mode 100644 index f6425630647..00000000000 --- a/erpnext/home/page/my_company/my_company.js +++ /dev/null @@ -1,760 +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 . - -pscript['onload_My Company'] = function() { - var wrapper = wn.pages['My Company']; - - // body - wrapper.className = 'layout_wrapper'; - wrapper.head = new PageHeader(wrapper, 'People'); - wrapper.body = $a(wrapper, 'div', '', {marginRight:'11px', marginTop:'11px'}); - - wrapper.message = $a(wrapper.body, 'div'); - wrapper.tab = make_table(wrapper.body, 1, 2, '100%', ['25%','75%']); - - $y(wrapper.tab, {tableLayout:'fixed'}) - - pscript.myc_make_toolbar(wrapper); - pscript.myc_make_list(wrapper); - - if(pscript.is_erpnext_saas) { - pscript.myc_show_erpnext_message(); - } -} - -pscript.myc_make_toolbar = function(wrapper) { - if(has_common(user_roles, ['System Manager', 'Administrator'])) { - wrapper.head.add_button('Add User', pscript.myc_add_user) - } -} - -// -// Only for erpnext product - show max users allowed -// -pscript.myc_show_erpnext_message = function() { - var callback = function(r, rt) { - if(r.exc) {msgprint(r.exc); return;} - $a(wrapper.message, 'div', 'help_box', '', 'You have ' + r.message.enabled - + ' users enabled out of ' + r.message.max_user - + '. Go to Account Settings to increase the number of users'); - } - $c_page('home', 'my_company', 'get_max_users', '', callback) -} - -// -// Add user dialog and server call -// -pscript.myc_add_user = function() { - var fields = [{ - fieldtype: 'Data', - fieldname: 'user', - reqd: 1, - label: 'Email Id of the user to add' - }, - { - fieldtype: 'Data', - fieldname: 'first_name', - reqd: 1, - label: 'First Name' - }, - { - fieldtype: 'Data', - fieldname: 'last_name', - label: 'Last Name' - }, - { - fieldtype: 'Data', - fieldname: 'password', - reqd: 1, - label: 'Password' - }, - { - fieldtype: 'Button', - label: 'Add', - fieldname: 'add' - }]; - - fields.push(); - - var d = new wn.widgets.Dialog({ - title: 'Add User', - width: 400, - fields: fields - }); - d.make(); - d.fields_dict.add.input.onclick = function() { - v = d.get_values(); - if(v) { - d.fields_dict.add.input.set_working(); - $c_page('home', 'my_company', 'add_user', v, function(r,rt) { - if(r.exc) { msgprint(r.exc); return; } - else { - d.hide(); - pscript.myc_refresh(); - } - }) - } - } - d.show(); -} - -pscript.myc_refresh = function() { - wn.pages['My Company'].member_list.lst.run(); -} - -pscript.myc_make_list= function(wrapper) { - wrapper.member_list = new MemberList(wrapper) -} - -pscript.get_fullname=function(uid) { - if(uid=='Administrator') return uid; - return wn.pages['My Company'].member_list.member_items[uid].fullname; -} - - - -//============================================= - -MemberList = function(parent) { - var me = this; - this.profiles = {}; - this.member_items = {}; - this.role_objects = {}; - this.cur_profile = null; - - this.list_wrapper = $a($td(parent.tab,0,0), 'div', '', {marginLeft:'11px'}); - var cell = $td(parent.tab,0,1); - $y(cell, { border: '1px solid #aaa' }); - cell.className = 'layout_wrapper'; - this.profile_wrapper = $a(cell, 'div'); - - this.no_user_selected = $a(this.profile_wrapper, 'div', 'help_box', null, 'Please select a user to view profile'); - - this.make_search(); - if(pscript.online_users) { - this.make_list(); - } else { - $c_page('home', 'event_updates', 'get_online_users', '', function(r,rt) { - pscript.online_users = r.message; - me.make_list(); - }) - } -} - -// ---------------------- - -MemberList.prototype.make_search = function() { - var me = this; - this.search_area = $a(this.list_wrapper, 'div', '', {textAlign:'center', padding:'8px'}); - this.search_inp = $a(this.search_area, 'input', '', {fontSize:'14px', width:'80%'}); - this.search_inp.set_empty = function() { - this.value = 'Search'; $fg(this,'#888'); - } - this.search_inp.onfocus = function() { - $fg(this,'#000'); - if(this.value=='Search')this.value = ''; - } - this.search_inp.onchange = function() { - if(!this.value) this.set_empty(); - } - this.search_inp.set_empty(); -} - -// ---------------------- - -MemberList.prototype.make_list = function() { - var me = this; - this.lst_area = $a(this.list_wrapper, 'div'); - - this.lst = new wn.ui.Listing({ - parent: this.lst_area, - as_dict: 1, - get_query: function() { - var c1 = ''; - if(me.search_inp.value && me.search_inp.value != 'Search') { - var c1 = repl(' AND (first_name LIKE "%(txt)s" OR last_name LIKE "%(txt)s" OR name LIKE "%(txt)s")', {txt:'%' + me.search_inp.value + '%'}); - } - - return repl("SELECT name, \ - ifnull(concat_ws(' ', first_name, last_name),'') as full_name, \ - gender, file_list, enabled \ - FROM tabProfile \ - WHERE docstatus != 2 \ - AND name not in ('Guest','Administrator') %(cond)s \ - ORDER BY name asc",{cond:c1}); - }, - render_row: function(parent, data) { - me.member_items[data.name] = new MemberItem(parent, data, me); - } - }); - this.lst.run(); -} - - -/* -Create / show profile -*/ -MemberList.prototype.show_profile = function(uid, member_item) { - $dh(this.no_user_selected); - - // if not exists, create - if(!this.profiles[uid]) { - if(!member_item) member_item = this.member_items[uid]; - this.profiles[uid] = new MemberProfile(this.profile_wrapper, uid, member_item); - } - - // hide current - if(this.cur_profile) - this.cur_profile.hide(); - - // show this - this.profiles[uid].show(); - this.cur_profile = this.profiles[uid]; -} - - -// Member Item -// List item of all profiles -// on the left hand sidebar of the page - -MemberItem = function(parent, det, mlist) { - var me = this; - this.det = det; - this.wrapper = $a(parent, 'div'); - this.enabled = det.enabled; - - this.tab = make_table(this.wrapper, 1,2,'100%', ['20%', '70%'], {padding:'4px', overflow:'hidden'}); - $y(this.tab, {tableLayout:'fixed', borderCollapse:'collapse'}) - - this.is_online = function() { - for(var i=0;iYour Password', - description: "Your password is required to update the concerned user's password", - fieldtype: 'Password', - fieldname: 'sys_admin_pwd', - reqd: 1 - }, - - { - label: 'Continue', - fieldtype: 'Button', - fieldname: 'continue' - } - ] - }); - - pass_d.fields_dict.continue.input.onclick = function() { - btn.pwd_dialog.hide(); - args.sys_admin_pwd = btn.pwd_dialog.get_values().sys_admin_pwd; - btn.set_working(); - me.update_security(args); - btn.done_working(); - } - - pass_d.show(); - btn.pwd_dialog = pass_d; - btn.done_working(); - } else { - btn.done_working(); - me.update_security(args); - } - }; - sd.show(); - } - - this.update_security = function(args) { - $c_page('home', 'my_company', 'update_security', JSON.stringify(args), function(r,rt) { - if(r.exc) { - msgprint(r.exc); - return; - } - me.sec_dialog.hide(); - $.extend(me.profile, me.sec_dialog.get_values()); - }); - } - - // delete user - // create a confirm dialog and call server method - this.delete_user = function() { - var cp = wn.control_panel; - - var d = new Dialog(400,200,'Delete User'); - d.make_body([ - ['HTML','','Do you really want to remove '+this.uid+' from system?'],['Button','Delete'] - ]); - d.onshow = function() { - this.clear_inputs(); - } - - d.widgets['Delete'].onclick = function() { - this.set_working(); - - var callback = function(r,rt) { - d.hide(); - if(r.exc) { - msgprint(r.exc); - return; - } - pscript.myc_refresh() - msgprint("User Deleted Successfully"); - } - $c_page('home', 'my_company', 'delete_user', {'user': me.uid}, callback); - } - d.show(); - } - - // set enabled - this.set_enable_button = function() { - var me = this; - var act = this.profile.enabled ? 'Disable' : 'Enable'; - - if(this.status_button) { - this.status_button.innerHTML = act; - } else { - // make the button - this.status_button = $btn(this.toolbar_area, act, function() { - var callback = function(r,rt) { - locals['Profile'][me.profile.name].enabled = cint(r.message); - me.status_button.done_working(); - me.refresh_enable_disable(); - } - this.set_working(); - $c_page('home','my_company', this.innerHTML.toLowerCase()+'_profile',me.profile.name, callback); - }, null, null, 1); - } - if(this.uid==user) $dh(this.status_button); else $di(this.status_button); - } - - // render the details of the user from Profile - this.render = function() { - this.profile = locals['Profile'][uid]; - scroll(0, 0); - - // name - if(cstr(this.profile.first_name) || cstr(this.profile.last_name)) { - this.fullname = cstr(this.profile.first_name) + ' ' + cstr(this.profile.last_name); - } else { - this.fullname = this.profile.name; - } - this.name_area.innerHTML = this.fullname; - - // email - this.email_area.innerHTML = this.profile.name; - - // online / offline - this.online_status_area.innerHTML = (this.member_item.is_online() ? '(Online)' : '(Offline)') - if(this.member_item.is_online()) { - $y(this.online_status_area, {color:'green'}); - } - - // refresh enable / disabled - this.refresh_enable_disable(); - - // designation - this.bio_area.innerHTML = this.profile.designation ? ('Designation: ' + cstr(this.profile.designation) + '
') : ''; - this.bio_area.innerHTML += this.profile.bio ? this.profile.bio : 'No bio'; - - new MemberConversation(this.wrapper, this.profile.name, this.fullname); - } - - // refresh enable / disable - this.refresh_enable_disable = function() { - this.profile = locals['Profile'][this.uid] - - if(!this.profile.enabled) { - $fg(this.name_area,'#999'); - } else { - $fg(this.name_area,'#000'); - } - - this.member_item.enabled = this.profile.enabled; - this.member_item.refresh_name_link(); - - this.status_span.innerHTML = this.profile.enabled ? 'Enabled' : 'Disabled'; - - // set styles and buttons - if(has_common(['Administrator','System Manager'],user_roles)) { - this.set_enable_button(); - } - } - - // Load user profile (if not loaded) - this.load = function() { - if(locals['Profile'] && locals['Profile'][uid]) { - this.render(); - return; - } - var callback = function(r,rt) { - $dh(me.member_item.working_img); - $ds(me.wrapper); - me.loading = 0; - me.render(); - } - $ds(this.member_item.working_img); - $dh(this.wrapper); - this.loading = 1; - $c('webnotes.widgets.form.load.getdoc', {'name':this.uid, 'doctype':'Profile', 'user':user}, callback); // onload - } - - // show / hide - this.show = function() { - if(!this.loading)$ds(this.wrapper); - - // select profile - this.member_item.select(); - } - this.hide = function() { - $dh(this.wrapper); - - // select profile - this.member_item.deselect(); - } - - this.make_message_list = function() { - - } - - this.make(); - this.load(); -} - - - - -// Member conversation -// Between the current user and the displayed profile -// or if same, then the conversation with all other -// profiles -MemberConversation = function(parent, uid, fullname) { - var me = this; - this.wrapper = $a(parent, 'div', 'my-company-conversation'); - this.fullname = fullname; - this.make = function() { - if(user!=uid) { - this.make_input(); - } - this.make_list(); - - // set all messages - // as "read" (docstatus = 0) - if(user==uid) { - $c_page('home', 'my_company', 'set_read_all_messages', '', function(r,rt) { }); - } - } - - this.make_input = function() { - this.input_wrapper = $a(this.wrapper, 'div', 'my-company-input-wrapper'); - var tab = make_table(this.input_wrapper, 1, 2, '100%', ['64%','36%'], {padding: '3px'}) - this.input = $a($td(tab,0,0), 'textarea'); - - // button - var div = $a(this.input_wrapper, 'div'); - this.post = $btn(div, 'Post'.bold(), function() { me.post_message(); }, {margin:'0px 13px 0px 3px'}) - this.post.disabled = true; - - this.input.onkeyup = this.input.onchange = function() { - if(this.value) { - me.post.disabled = false; - } else { - me.post.disabled = true; - } - } - - // notification check - this.notify_check = $a_input(div, 'checkbox', null); - $a(div, 'span', '', {marginLeft:'3px'}, 'Notify ' + fullname + ' by email') - } - - this.post_message = function() { - if(me.input.value==$(me.input).attr('default_text')) { - msgprint('Please write a message first!'); return; - } - this.post.set_working(); - $c_page('home', 'my_company', 'post_comment', { - uid: uid, - comment: $(me.input).val(), - notify: me.notify_check.checked ? 1 : 0 - }, function(r,rt) { - $(me.input).val("").blur(); - me.post.done_working(); - if(r.exc) { msgprint(r.exc); return; } - me.notify_check.checked = false; - me.refresh(); - }) - } - - this.make_list = function() { - this.lst_area = $a(this.wrapper, 'div', 'my-company-conversation', {padding:'7px 13px'}); - - if(user==uid) { - this.my_messages_box = $a(this.lst_area, 'div', 'my-company-conversation-head', {marginBottom:'7px'}, 'Messages by everyone to me
To send a message, click on the user on the left') - } - - this.lst = new wn.ui.Listing({ - parent: this.lst_area, - as_dict: 1, - no_result_message: (user==uid - ? 'No messages by anyone yet' - : 'No messages yet. To start a conversation post a new message'), - - get_query: function() { - if(uid==user) { - return repl("SELECT comment, owner, comment_docname, creation, docstatus " + - "FROM `tabComment` "+ - "WHERE comment_doctype='My Company' " + - "AND comment_docname='%(user)s' " + - "ORDER BY creation DESC ", {user:user}); - - } else { - return repl("SELECT comment, owner, comment_docname, creation, docstatus " + - "FROM `tabComment` "+ - "WHERE comment_doctype='My Company' " + - "AND ((owner='%(user)s' AND comment_docname='%(uid)s') " + - "OR (owner='%(uid)s' AND comment_docname='%(user)s')) " + - "ORDER BY creation DESC ", {uid:uid, user:user}); - - } - }, - render_row: function(parent, data) { - new MemberCoversationComment(parent, data, me); - }, - - }) - this.refresh(); - } - - this.refresh = function() { - me.lst.run() - } - - this.make(); -} - -MemberCoversationComment = function(cell, det, conv) { - var me = this; - this.det = det; - this.wrapper = $a(cell, 'div', 'my-company-comment-wrapper'); - this.comment = $a(this.wrapper, 'div', 'my-company-comment'); - - this.user = $a(this.comment, 'span', 'link_type', {fontWeight:'bold'}, pscript.get_fullname(det.owner)); - this.user.onclick = function() { - wn.pages['My Company'].member_list.show_profile(me.det.owner); - } - - var st = (!det.docstatus ? {fontWeight: 'bold'} : null); - this.msg = $a(this.comment, 'span', 'social', st, ': ' + det.comment); - - if(det.full_name==user) { - $y(this.wrapper, {backgroundColor: '#D9D9F3'}); - } - this.timestamp = $a(this.wrapper, 'div', 'my-company-timestamp', '', comment_when(det.creation)); -} - - - - - - - diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py deleted file mode 100644 index 5e3ba9484ce..00000000000 --- a/erpnext/home/page/my_company/my_company.py +++ /dev/null @@ -1,218 +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 . - -import webnotes - -from webnotes.utils import cint, load_json, cstr -from webnotes.model.doc import Document - -try: import json -except: import simplejson as json - -@webnotes.whitelist() -def get_account_settings_url(arg=''): - import server_tools.gateway_utils - return server_tools.gateway_utils.get_account_settings_url() - -@webnotes.whitelist() -def get_max_users(arg=''): - from server_tools.gateway_utils import get_max_users_gateway - return { - 'max_users': get_max_users_gateway(), - 'enabled': cint(webnotes.conn.sql("select count(*) from tabProfile where ifnull(enabled,0)=1 and name not in ('Administrator', 'Guest')")[0][0]) - } - -@webnotes.whitelist() -def enable_profile(arg=''): - webnotes.conn.sql("update tabProfile set enabled=1 where name=%s", arg) - return 1 - -@webnotes.whitelist() -def disable_profile(arg=''): - if arg=='Administrator': - return 'Cannot disable Administrator' - - webnotes.conn.sql("update tabProfile set enabled=0 where name=%s", arg) - webnotes.login_manager.logout(user=arg) - return 0 - -@webnotes.whitelist() -def delete_user(args): - args = json.loads(args) - webnotes.conn.sql("update tabProfile set enabled=0, docstatus=2 where name=%s", args['user']) - # erpnext-saas - import webnotes.defs - from webnotes.utils import cint - if hasattr(webnotes.defs, 'sync_with_gateway') and \ - cint(webnotes.defs.sync_with_gateway) or 0: - from server_tools.gateway_utils import remove_user_gateway - remove_user_gateway(args['user']) - - webnotes.login_manager.logout(user=args['user']) - - -@webnotes.whitelist() -def add_user(args): - args = json.loads(args) - # erpnext-saas - import webnotes.defs - from webnotes.utils import cint - if hasattr(webnotes.defs, 'sync_with_gateway') and \ - cint(webnotes.defs.sync_with_gateway) or 0: - from server_tools.gateway_utils import add_user_gateway - add_user_gateway(args) - - add_profile(args) - -@webnotes.whitelist() -def add_profile(args): - from webnotes.utils import validate_email_add, now - email = args['user'] - - sql = webnotes.conn.sql - - if not email: - email = webnotes.form_dict.get('user') - if not validate_email_add(email): - raise Exception - return 'Invalid Email Id' - - if sql("select name from tabProfile where name = %s", email): - # exists, enable it - sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email) - webnotes.msgprint('Profile exists, enabled it with new password') - else: - # does not exist, create it! - pr = Document('Profile') - pr.name = email - pr.email = email - pr.first_name = args.get('first_name') - pr.last_name = args.get('last_name') - pr.enabled = 1 - pr.user_type = 'System User' - pr.save(1) - - if args.get('password'): - sql(""" - UPDATE tabProfile - SET password = PASSWORD(%s), modified = %s - WHERE name = %s""", (args.get('password'), now, email)) - - send_welcome_mail(email, args) - -@webnotes.whitelist() -def send_welcome_mail(email, args): - """send welcome mail to user with password and login url""" - pr = Document('Profile', email) - from webnotes.utils.email_lib import sendmail_md - args.update({ - 'company': webnotes.conn.get_default('company'), - 'password': args.get('password'), - 'account_url': webnotes.conn.get_default('account_url') - }) - if not args.get('last_name'): args['last_name'] = '' - sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args, from_defs=1) - -# -# post comment -# -@webnotes.whitelist() -def post_comment(arg): - arg = load_json(arg) - - from webnotes.model.doc import Document - d = Document('Comment') - d.comment_doctype = 'My Company' - d.comment_docname = arg['uid'] # to - d.owner = webnotes.user.name - d.comment = arg['comment'] - d.save(1) - - if cint(arg.get('notify')): - fn = webnotes.conn.sql('select first_name, last_name from tabProfile where name=%s', webnotes.user.name)[0] - if fn[0] or f[1]: - fn = cstr(fn[0]) + (fn[0] and ' ' or '') + cstr(fn[1]) - else: - fn = webnotes.user.name - - message = '''A new comment has been posted on your page by %s: - - Comment: %s - - To answer, please login to your erpnext account! - - https://signin.erpnext.com - ''' % (fn, arg['comment']) - - from webnotes.model.code import get_obj - note = get_obj('Notification Control') - email_msg = note.prepare_message({ - 'type': 'New Comment', - 'message': message - }) - - sender = webnotes.user.name!='Administrator' and webnotes.user.name or 'support+admin_post@erpnext.com' - - from webnotes.utils.email_lib import sendmail - sendmail([arg['uid']], sender, email_msg, fn + ' has posted a new comment') - -# -# update read messages -# -@webnotes.whitelist() -def set_read_all_messages(arg=''): - webnotes.conn.sql("""UPDATE `tabComment` - SET docstatus = 1 - WHERE comment_doctype = 'My Company' - AND comment_docname = %s - """, webnotes.user.name) - -@webnotes.whitelist() -def update_security(args=''): - import json - args = json.loads(args) - webnotes.conn.set_value('Profile', args['user'], 'restrict_ip', args.get('restrict_ip')) - webnotes.conn.set_value('Profile', args['user'], 'login_after', args.get('login_after')) - webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before')) - - if 'new_password' in args: - import webnotes.defs - from webnotes.utils import cint - if hasattr(webnotes.defs, 'sync_with_gateway') and \ - cint(webnotes.defs.sync_with_gateway) or 0: - import server_tools.gateway_utils - res = server_tools.gateway_utils.change_password('', args['new_password'], args['user'], args['sys_admin_pwd']) - if 'Traceback' not in res['message']: - webnotes.msgprint(res['message']) - webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user'])) - else: webnotes.msgprint('Settings Updated') - -welcome_txt = """ -## %(company)s - -Dear %(first_name)s %(last_name)s - -Welcome! - -A new account has been created for you, here are your details: - -login-id: %(user)s -password: %(password)s - -To login to your new ERPNext account, please go to: - -%(account_url)s -""" diff --git a/erpnext/home/page/my_company/my_company.txt b/erpnext/home/page/my_company/my_company.txt deleted file mode 100644 index 31833155816..00000000000 --- a/erpnext/home/page/my_company/my_company.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Page, My Company -[ - - # These values are common in all dictionaries - { - 'creation': '2010-12-14 10:23:19', - 'docstatus': 0, - 'modified': '2010-12-27 17:44:15', - 'modified_by': 'Administrator', - 'owner': 'Administrator' - }, - - # These values are common for all Page - { - 'doctype': 'Page', - 'module': 'Home', - 'name': '__common__', - 'page_name': 'My Company', - 'show_in_menu': 1, - 'standard': 'Yes' - }, - - # These values are common for all Page Role - { - 'doctype': 'Page Role', - 'name': '__common__', - 'parent': 'My Company', - 'parentfield': 'roles', - 'parenttype': 'Page' - }, - - # Page, My Company - { - 'doctype': 'Page', - 'name': 'My Company' - }, - - # Page Role - { - 'doctype': 'Page Role', - 'idx': 1, - 'role': 'Administrator' - }, - - # Page Role - { - 'doctype': 'Page Role', - 'idx': 2, - 'role': 'All' - } -] \ No newline at end of file diff --git a/erpnext/knowledge_base/page/questions/questions.py b/erpnext/knowledge_base/page/questions/questions.py index 1b90fc701df..52b80fe2803 100644 --- a/erpnext/knowledge_base/page/questions/questions.py +++ b/erpnext/knowledge_base/page/questions/questions.py @@ -17,6 +17,7 @@ import webnotes from webnotes.utils import load_json, cint, cstr +import json # add a new question @webnotes.whitelist() @@ -30,14 +31,14 @@ def add_question(arg): d.save(1) if args['suggest']: - from home.page.my_company.my_company import post_comment + from utilities.page.messages import messages for s in args['suggest']: if s: - post_comment({ - 'uid': s, - 'comment': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question, + messages.post(json.dumps({ + 'contact': s, + 'txt': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question, 'notify': 1 - }) + })) @webnotes.whitelist() def vote(arg): @@ -60,4 +61,4 @@ def delete(arg): """ args = load_json(arg) from webnotes.model import delete_doc - delete_doc(args['dt'], args['dn']) \ No newline at end of file + delete_doc(args['dt'], args['dn']) diff --git a/erpnext/patches/jan_mar_2012/rename_dt.py b/erpnext/patches/jan_mar_2012/rename_dt.py index 01e6bafd082..a258f73ec5b 100644 --- a/erpnext/patches/jan_mar_2012/rename_dt.py +++ b/erpnext/patches/jan_mar_2012/rename_dt.py @@ -14,9 +14,7 @@ def execute1(): replace_labels_with_fieldnames() def execute(): - # delete dt, mapper - delete_dt_and_mapper() - + #--------------------------------------------------- # doctype renaming rendt = get_dt_to_be_renamed() @@ -45,9 +43,52 @@ def execute(): #--------------------------------------------------- # Reload mapper from file for d in ren_mapper: - mod = '_'.join(webnotes.conn.sql("select module from `tabDocType Mapper` where name = %s", ren_mapper[d])[0][0].lower().split()) + mod = '_'.join(webnotes.conn.sql("select module from `tabDocType Mapper` where name = %s", + ren_mapper[d])[0][0].lower().split()) reload_doc(mod, 'DocType Mapper', ren_mapper[d]) + + delete_search_criteria() + + # reload custom search criteria + #for d in webnotes.conn.sql("""select name, module from + # `tabSearch Criteria` where ifnull(standard, 'No') = 'Yes' and ifnull(disabled, 0) = 0"""): + # + for path, folders, files in os.walk(webnotes.defs.modules_path): + if not path.endswith('search_criteria'): continue + module = path.split(os.sep)[-2] + for sc in folders: + try: + reload_doc(module, 'search_criteria', sc) + print module, sc + except Exception, e: + print "did not reload: " + str(d) + webnotes.conn.sql("""DELETE FROM `tabPrint Format` + WHERE name IN ('Delivery Note Format', 'Purchase Order Format', + 'Quotation Format', 'Receivable Voucher Format', 'Sales Order', + 'SalesInvoiceModern_test', 'SalesInvoiceStdNew', + 'Service Order Format', 'Service Quotation Format')""") + + # reload custom print format + for d in webnotes.conn.sql("""select name, module from `tabPrint Format` + where ifnull(standard, 'No') = 'Yes'"""): + try: + reload_doc(d[1], 'Print Format', d[0]) + except Exception, e: + print "did not reload: " + str(d) + + # Reload GL Mapper + for d in webnotes.conn.sql("select name from `tabGL Mapper`"): + reload_doc('accounts', 'GL Mapper', d[0]) + + #gl entry, stock ledger entry, + + + + # T0-do-list + # gl mapper name + +def delete_search_criteria(): webnotes.conn.sql("""DELETE FROM `tabSearch Criteria` WHERE name IN ('', 'bills-to_be_paid', 'bills-to_be_submitted', 'cenvat_credit_-_input_or_capital_goods', @@ -84,74 +125,18 @@ def execute(): 'projectwise_pending_qty_and_costs_as_per_purchase_cost', 'custom_test', 'custom_test1', 'delivery_notes', 'delivery_note_disabled', 'lead', 'lead_interested', 'lead_report', 'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order', - 'sales_order1', 'sales_agentwise_commission', 'test_report', 'territory_wise_sales_-_target_vs_actual_')""") + 'sales_order1', 'sales_agentwise_commission', 'test_report', + 'territory_wise_sales_-_target_vs_actual_')""") webnotes.conn.sql(""" DELETE FROM `tabSearch Criteria` WHERE name IN ('monthly_transaction_summary', 'trend_analyzer', 'yearly_transaction_summary', 'invoices-overdue', 'lead-to_follow_up', 'opportunity-to_follow_up', 'serial_no-amc_expiring_this_month', - 'serial_no-warranty_expiring_this_month', ) + 'serial_no-warranty_expiring_this_month') AND IFNULL(standard, 'No') = 'Yes' """) - # reload custom search criteria - for d in webnotes.conn.sql("""select name, module from - `tabSearch Criteria` where ifnull(standard, 'No') = 'Yes' and ifnull(disabled, 0) = 0"""): - try: - reload_doc(d[1], 'search_criteria', d[0].replace('-', '_')) - print d - except Exception, e: - print "did not reload: " + str(d) - - webnotes.conn.sql("""DELETE FROM `tabPrint Format` - WHERE name IN ('Delivery Note Format', 'Purchase Order Format', - 'Quotation Format', 'Receivable Voucher Format', 'Sales Order', - 'SalesInvoiceModern_test', 'SalesInvoiceStdNew', - 'Service Order Format', 'Service Quotation Format')""") - - # reload custom print format - for d in webnotes.conn.sql("""select name, module from `tabPrint Format` - where ifnull(standard, 'No') = 'Yes'"""): - try: - reload_doc(d[1], 'Print Format', d[0]) - except Exception, e: - print "did not reload: " + str(d) - - # Reload GL Mapper - for d in webnotes.conn.sql("select name from `tabGL Mapper`"): - reload_doc('accounts', 'GL Mapper', d[0]) - - #gl entry, stock ledger entry, - - - - # T0-do-list - # gl mapper name - - - -def delete_dt_and_mapper(): - del_mapper = ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan'] - for d in del_mapper: - delete_doc('DocType Mapper', d) - - del_dt = ['Widget Control', 'Update Delivery Date Detail', 'Update Delivery Date', - 'Tag Detail', 'Supplier rating', 'Stylesheet', 'Question Tag', - 'PRO PP Detail', 'PRO Detail', 'PPW Detail', 'PF Detail', - 'Personalize', 'Patch Util', 'Page Template', 'Module Def Role', - 'Module Def Item', 'File Group', 'File Browser Control', 'File', - 'Educational Qualifications', 'Earn Deduction Detail', - 'DocType Property Setter', 'Contact Detail', 'BOM Report Detail', - 'BOM Replace Utility Detail', 'BOM Replace Utility', - 'Absent Days Detail', 'Activity Dashboard Control', 'Raw Materials Supplied', - 'Setup Wizard Control', 'Company Group', 'Lease Agreement', 'Lease Installment'] # docformat - - for d in del_dt: - delete_doc('DocType', d) - - - def rename_in_db(ren_data, data_type, is_doctype): for d in ren_data: print colored('Renaming... ' + d + ' --> '+ ren_data[d], 'yellow') @@ -166,7 +151,7 @@ def rename_in_db(ren_data, data_type, is_doctype): def update_dt_in_records(rendt): for d in rendt: # Feed, property setter, search criteria, gl mapper, form 16A, naming series options, doclayer - dodtype is not mentioed in options - dt_list = webnotes.conn.sql("select t1.parent, t1.fieldname from tabDocField t1, tabDocType t2 where t1.parent = t2.name and t1.fieldname in ('dt', 'doctype', 'doc_type', 'dt_type') and ifnull(t1.options, '') = '' and ifnull(t2.issingle, 0) = 0") + dt_list = webnotes.conn.sql("select t1.parent, t1.fieldname from tabDocField t1, tabDocType t2 where t1.parent = t2.name and t1.fieldname in ('dt', 'doctype', 'doc_type', 'dt_type') and ifnull(t1.options, '') = '' and ifnull(t2.issingle, 0) = 0 and t1.parent in ('Custom Field', 'Custom Script')") for dt in dt_list: webnotes.conn.sql("update `tab%s` set %s = replace(%s, '%s', '%s') where %s = '%s'" % (dt[0], dt[1], dt[1], d, rendt[d], dt[1], d)) diff --git a/erpnext/patches/jan_mar_2012/sync_ref_db.py b/erpnext/patches/jan_mar_2012/sync_ref_db.py index efc831db9e5..2997d9ccb60 100644 --- a/erpnext/patches/jan_mar_2012/sync_ref_db.py +++ b/erpnext/patches/jan_mar_2012/sync_ref_db.py @@ -1,15 +1,49 @@ -def execute(): - import webnotes - sql = webnotes.conn.sql - from webnotes.model import delete_doc +import webnotes +sql = webnotes.conn.sql +from webnotes.model import delete_doc +def execute(): del_rec = { - 'DocType' : ['Update Series', 'File', 'File Browser Control', 'File Group', 'Tag Detail', 'DocType Property Setter', 'Company Group'], - 'Page' : ['File Browser'] + 'DocType' : ['Update Series', 'File', 'File Browser Control', 'File Group', + 'Tag Detail', 'DocType Property Setter', 'Company Group', 'Widget Control', + 'Update Delivery Date Detail', 'Update Delivery Date', + 'Tag Detail', 'Supplier rating', 'Stylesheet', 'Question Tag', + 'PRO PP Detail', 'PRO Detail', 'PPW Detail', 'PF Detail', + 'Personalize', 'Patch Util', 'Page Template', 'Module Def Role', + 'Module Def Item', 'File Group', 'File Browser Control', 'File', + 'Educational Qualifications', 'Earn Deduction Detail', + 'DocType Property Setter', 'Contact Detail', 'BOM Report Detail', + 'BOM Replace Utility Detail', 'BOM Replace Utility', + 'Absent Days Detail', 'Activity Dashboard Control', 'Raw Materials Supplied', + 'Setup Wizard Control', 'Company Group', 'Lease Agreement', 'Lease Installment', + 'Terms and Conditions', 'Time Sheet', 'Time Sheet Detail', 'Naming Series Options'], + 'Page' : ['File Browser'], + 'DocType Mapper': ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan'] } for d in del_rec: for r in del_rec[d]: + if d=='DocType': + sql("delete from tabFeed where doc_type=%s", r) delete_doc(d, r) sql("delete from tabDocField where label='Repair Purchase Request' and parent = 'Purchase Request'") + + drop_tables() + + +def drop_tables(): + webnotes.conn.commit() + from webnotes.model.db_schema import remove_all_foreign_keys + remove_all_foreign_keys() + count = 0 + tab_list = sql("SHOW TABLES") + for tab in tab_list: + if tab[0].startswith('_') or tab[0] in ('tabSingles', 'tabSessions', 'tabSeries'): continue + res = sql("SELECT COUNT(*) FROM `tabDocType` WHERE name = %s", tab[0][3:]) + if not res[0][0]: + count += 1 + print tab[0] + sql("DROP TABLE `%s`" % tab[0]) + print count + webnotes.conn.begin() diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index a589a32ffb8..563052f77b3 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -22,7 +22,7 @@ cur_frm.cscript.sales_team_fname = "sales_team"; // ===================================================================================== wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); -wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js index fd043af011b..2a6e5a3d121 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.js +++ b/erpnext/selling/doctype/sales_common/sales_common.js @@ -18,7 +18,7 @@ // ------ // cur_frm.cscript.tname - Details table name // cur_frm.cscript.fname - Details fieldname -// cur_frm.cscript.other_fname - wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); fieldname +// cur_frm.cscript.other_fname - wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); fieldname // cur_frm.cscript.sales_team_fname - Sales Team fieldname // ============== Load Default Taxes =================== diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 1fe5fe1496b..24e69a2ee03 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -23,7 +23,7 @@ cur_frm.cscript.sales_team_fname = "sales_team"; wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); -wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); diff --git a/erpnext/setup/doctype/sales_taxes_and_charges_master/__init__.py b/erpnext/setup/doctype/sales_taxes_and_charges_master/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index 27befaf7218..5d7e663d422 100644 --- a/erpnext/startup/startup.js +++ b/erpnext/startup/startup.js @@ -114,34 +114,38 @@ var update_messages = function(reset) { if(inList(['Guest'], user) || !wn.session_alive) { return; } if(!reset) { - $c_page('home', 'event_updates', 'get_global_status_messages', null, - function(r,rt) { - if(!r.exc) { - // This function is defined in toolbar.js - wn.container.wntoolbar.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); - } + var set_messages = function(r) { + if(!r.exc) { + // This function is defined in toolbar.js + wn.container.wntoolbar.set_new_comments(r.message.unread_messages); + + var show_in_circle = function(parent_id, msg) { + var parent = $('#'+parent_id); + if(parent) { + if(msg) { + parent.find('span:first').text(msg); + parent.toggle(true); + } else { + parent.toggle(false); } } - - show_in_circle('unread_messages', r.message.unread_messages.length); - show_in_circle('open_support_tickets', r.message.open_support_tickets); - show_in_circle('things_todo', r.message.things_todo); - show_in_circle('todays_events', r.message.todays_events); - - } else { - clearInterval(wn.updates.id); } + + show_in_circle('unread_messages', r.message.unread_messages.length); + show_in_circle('open_support_tickets', r.message.open_support_tickets); + show_in_circle('things_todo', r.message.things_todo); + show_in_circle('todays_events', r.message.todays_events); + + } else { + clearInterval(wn.updates.id); } - ); + } + + wn.call({ + method: 'startup.startup.get_global_status_messages', + callback: set_messages + }); + } else { wn.container.wntoolbar.set_new_comments(0); $('#unread_messages').toggle(false); diff --git a/erpnext/startup/startup.py b/erpnext/startup/startup.py new file mode 100644 index 00000000000..8bc13f8678d --- /dev/null +++ b/erpnext/startup/startup.py @@ -0,0 +1,54 @@ +import webnotes + +def get_unread_messages(): + "returns unread (docstatus-0 messages for a user)" + return webnotes.conn.sql("""\ + SELECT name, comment + FROM `tabComment` + WHERE comment_doctype IN ('My Company', 'Message') + AND comment_docname = %s + AND ifnull(docstatus,0)=0 + """, webnotes.user.name, as_list=1) + +def get_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` + WHERE status = 'Open'""") + return open_support_tickets and cint(open_support_tickets[0][0]) or 0 + +def get_things_todo(): + """ + Returns a count of incomplete todos + """ + from webnotes.utils import cint + incomplete_todos = webnotes.conn.sql("""\ + SELECT COUNT(*) FROM `tabToDo` + WHERE IFNULL(checked, 0) = 0 + AND owner = %s""", webnotes.session.get('user')) + return incomplete_todos and cint(incomplete_todos[0][0]) or 0 + +def get_todays_events(): + """ + Returns a count of todays events in calendar + """ + from webnotes.utils import nowdate, cint + todays_events = webnotes.conn.sql("""\ + SELECT COUNT(*) FROM `tabEvent` + WHERE owner = %s + AND event_type != 'Cancel' + AND event_date = %s""", ( + webnotes.session.get('user'), nowdate())) + return todays_events and cint(todays_events[0][0]) or 0 + +@webnotes.whitelist() +def get_global_status_messages(arg=None): + return { + 'unread_messages': get_unread_messages(), + 'open_support_tickets': get_open_support_tickets(), + 'things_todo': get_things_todo(), + 'todays_events': get_todays_events(), + } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index d9368bd9b44..8e158979e62 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -21,7 +21,7 @@ cur_frm.cscript.other_fname = "other_charges"; cur_frm.cscript.sales_team_fname = "sales_team"; wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); -wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index abeac49ea8c..7e81b888389 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -18,7 +18,7 @@ cur_frm.cscript.tname = "Purchase Receipt Item"; cur_frm.cscript.fname = "purchase_receipt_details"; cur_frm.cscript.other_fname = "purchase_tax_details"; -wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js'); +wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js'); wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js'); wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); diff --git a/erpnext/utilities/page/messages/messages.py b/erpnext/utilities/page/messages/messages.py index 3a27bca2575..212a2686b09 100644 --- a/erpnext/utilities/page/messages/messages.py +++ b/erpnext/utilities/page/messages/messages.py @@ -68,9 +68,41 @@ def post(arg=None): d.comment_docname = arg['contact'] d.comment_doctype = 'Message' d.save() + + import webnotes.utils + if webnotes.utils.cint(arg.get('notify')): + notify(arg) @webnotes.whitelist() def delete(arg=None): webnotes.conn.sql("""delete from `tabComment` where name=%s""", webnotes.form_dict['name']); + +def notify(arg=None): + from webnotes.utils import cstr + fn = webnotes.conn.sql('select first_name, last_name from tabProfile where name=%s', webnotes.user.name)[0] + if fn[0] or f[1]: + fn = cstr(fn[0]) + (fn[0] and ' ' or '') + cstr(fn[1]) + else: + fn = webnotes.user.name + + message = '''A new comment has been posted on your page by %s: + Comment: %s + + To answer, please login to your erpnext account! + + https://signin.erpnext.com + ''' % (fn, arg['txt']) + + from webnotes.model.code import get_obj + note = get_obj('Notification Control') + email_msg = note.prepare_message({ + 'type': 'New Comment', + 'message': message + }) + + sender = webnotes.user.name!='Administrator' and webnotes.user.name or 'support+admin_post@erpnext.com' + + from webnotes.utils.email_lib import sendmail + sendmail([arg['contact']], sender, email_msg, fn + ' has posted a new comment') diff --git a/js/all-app.js b/js/all-app.js index 78ff3e18f29..75a130b7f9c 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -2228,8 +2228,9 @@ else if(nm=='Accounts Browser') pscript.make_chart(chart_type);} loadpage(nm,call_back);} var update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;} -if(!reset){$c_page('home','event_updates','get_global_status_messages',null,function(r,rt){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} -show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}});}else{wn.container.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}} +if(!reset){var set_messages=function(r){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} +show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}} +wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{wn.container.wntoolbar.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(update_messages,60000);} erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))} diff --git a/js/all-web.js b/js/all-web.js index a25d3e8dafc..58b748db01a 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -1256,8 +1256,9 @@ else if(nm=='Accounts Browser') pscript.make_chart(chart_type);} loadpage(nm,call_back);} var update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;} -if(!reset){$c_page('home','event_updates','get_global_status_messages',null,function(r,rt){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} -show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}});}else{wn.container.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}} +if(!reset){var set_messages=function(r){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} +show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}} +wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{wn.container.wntoolbar.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(update_messages,60000);} erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))} @@ -1289,4 +1290,4 @@ item.route=item.url||item.custom_page;$parent_li.find('.dropdown-menu').append(r erpnext.com
\ ',wn.boot.website_settings));this.make_items();},make_items:function(){var items=wn.boot.website_menus for(var i=0;i%(label)s',item))}}}});$(document).bind('startup',function(){erpnext.footer=new erpnext.Footer();erpnext.navbar.navbar=new erpnext.navbar.Navbar();}) + data-label="%(label)s">%(label)s',item))}}}});$(document).bind('startup',function(){erpnext.footer=new erpnext.Footer();erpnext.navbar.navbar=new erpnext.navbar.Navbar();}) \ No newline at end of file diff --git a/version.num b/version.num index 3591ec6784c..b6f9e0e3aea 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -1492 +1495 \ No newline at end of file diff --git a/wnf.py b/wnf.py index ad450cda417..94450d8e745 100755 --- a/wnf.py +++ b/wnf.py @@ -242,11 +242,11 @@ def run(): elif options.sync_all is not None: import webnotes.model.sync - webnotes.model.sync.sync_all() + webnotes.model.sync.sync_all(options.force or 0) elif options.sync is not None: import webnotes.model.sync - webnotes.model.sync.sync(options.sync[0], options.sync[1]) + webnotes.model.sync.sync(options.sync[0], options.sync[1], options.force or 0) # print messages if webnotes.message_log: