Sourced wnframework-modules from Google Code as erpnext
diff --git a/crm/page/__init__.py b/crm/page/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/__init__.py
diff --git a/crm/page/customers/__init__.py b/crm/page/customers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/customers/__init__.py
diff --git a/crm/page/customers/customers.comp.js b/crm/page/customers/customers.comp.js
new file mode 100644
index 0000000..b6e831c
--- /dev/null
+++ b/crm/page/customers/customers.comp.js
@@ -0,0 +1,3 @@
+
+pscript.onload_customers=function(){make_customer_tab($i('dcv_customers'));}
+function make_customer_tab(parent){pscript.dcv_customers=new wn.widgets.DocColumnView('Customers',parent,['Customer Group','Customer','Contact'],{'Customer Group':{show_fields:['name'],create_fields:['name'],search_fields:['name'],next_col:'Customer'},'Customer':{show_fields:['name','customer_name'],create_fields:['name','customer_name'],search_fields:['customer_name'],filter_by:['Customer Group','customer_group'],next_col:'Contact'},'Contact':{show_fields:['name','first_name','last_name'],create_fields:['name','first_name','last_name'],search_fields:['first_name','last_name'],conditions:['is_customer=1'],set_values:{'is_customer':1},filter_by:['Customer','customer']},})}
\ No newline at end of file
diff --git a/crm/page/customers/customers.html b/crm/page/customers/customers.html
new file mode 100644
index 0000000..9f3d19c
--- /dev/null
+++ b/crm/page/customers/customers.html
@@ -0,0 +1 @@
+<div id="dcv_customers"></div>
\ No newline at end of file
diff --git a/crm/page/customers/customers.js b/crm/page/customers/customers.js
new file mode 100644
index 0000000..7902e24
--- /dev/null
+++ b/crm/page/customers/customers.js
@@ -0,0 +1,34 @@
+//make tabs
+
+pscript.onload_customers = function() {
+	make_customer_tab($i('dcv_customers'));
+}
+
+function make_customer_tab(parent) {	
+	pscript.dcv_customers = new wn.widgets.DocColumnView('Customers', parent, 
+		['Customer Group', 'Customer', 'Contact'], {
+		'Customer Group': { 
+			show_fields : ['name'],
+			create_fields : ['name'],
+			search_fields : ['name'],
+			next_col: 'Customer'
+		},
+		'Customer': { 
+			show_fields : ['name', 'customer_name'],
+			create_fields : ['name', 'customer_name'],
+			search_fields : ['customer_name'],
+			filter_by : ['Customer Group', 'customer_group'],
+			next_col: 'Contact'
+		},
+		'Contact': { 
+			show_fields : ['name', 'first_name', 'last_name'],
+			create_fields : ['name','first_name', 'last_name'],
+			search_fields : ['first_name', 'last_name'],
+			conditions: ['is_customer=1'],
+			set_values: {'is_customer': 1 },
+			filter_by : ['Customer', 'customer']
+		},
+	})
+}
+
+
diff --git a/crm/page/customers/customers.txt b/crm/page/customers/customers.txt
new file mode 100644
index 0000000..7f44ab45
--- /dev/null
+++ b/crm/page/customers/customers.txt
@@ -0,0 +1,26 @@
+[
+	{
+		'content': None,
+		'creation': '2011-03-25 13:48:50',
+		'docstatus': 0,
+		'doctype': 'Page',
+		'icon': None,
+		'idx': None,
+		'menu_index': None,
+		'modified': '2011-03-25 13:48:50',
+		'modified_by': 'Administrator',
+		'module': 'CRM',
+		'name': 'customers',
+		'owner': 'Administrator',
+		'page_name': 'Customers',
+		'parent': None,
+		'parent_node': None,
+		'parentfield': None,
+		'parenttype': None,
+		'script': None,
+		'show_in_menu': None,
+		'standard': 'Yes',
+		'static_content': None,
+		'style': None
+	}
+]
\ No newline at end of file
diff --git a/crm/page/sales_browser/__init__.py b/crm/page/sales_browser/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/sales_browser/__init__.py
diff --git a/crm/page/sales_browser/sales_browser.html b/crm/page/sales_browser/sales_browser.html
new file mode 100644
index 0000000..1acb5ee
--- /dev/null
+++ b/crm/page/sales_browser/sales_browser.html
@@ -0,0 +1,4 @@
+<div class="layout_wrapper">
+<div id="tr_header"></div>
+<div id="tr_body" style="margin: 16px"></div>
+</div>
\ No newline at end of file
diff --git a/crm/page/sales_browser/sales_browser.js b/crm/page/sales_browser/sales_browser.js
new file mode 100644
index 0000000..a24c942
--- /dev/null
+++ b/crm/page/sales_browser/sales_browser.js
@@ -0,0 +1,421 @@
+pscript['onload_Sales Browser'] = function(){
+  var parent = $i('tr_body');
+  parent.innerHTML = 'Please select your chart: '
+  var sel = $a(parent,'select');
+  add_sel_options(sel, ['Territory', 'Customer Group', 'Item Group', 'Sales Person'], 'Territory');
+  var btn = $btn(parent, 'Go', function() { new SalesBrowser().set_val(sel_val(sel)) }, {marginTop:'8px'});
+}
+
+//================================= SalesBrowser Class ======================================
+SalesBrowser = function(){
+  
+  this.make_body = function(){
+  
+    $i('tr_header').innerHTML = '';
+    $i('tr_body').innerHTML = '';
+    //make header
+    var desc = this.sel;
+    var me = this;
+    var h = new PageHeader($i('tr_header'),desc);
+    h.add_button('New '+this.sel, function() { me.set_dialog(1); }, 0, 'ui-icon-plus', 1);
+    h.add_button('Refresh', function() { me.refresh_tree(); }, 0, 'ui-icon-refresh');
+
+    var div_body = $a($i('tr_body'),'div');
+    var tr_main_grid = make_table(div_body,1,2,'100%',['60%','40%'],{width: "100%", tableLayout: "fixed", borderCollapse: "collapse", border:"0px", padding:"4px 4px 4px 4px"});
+    
+    $y($td(tr_main_grid,0,0),{border: "1px solid #dddddd", padding: "8px", width: "60%"});   
+    this.tree_area = $a($td(tr_main_grid,0,0),'div');
+
+    $y($td(tr_main_grid,0,1),{border: "1px solid #DDD"});   
+    this.detail_area = $a($td(tr_main_grid,0,1),'div');
+    
+    this.make_tree_body(this.tree_area);  
+    this.refresh_tree();
+  }
+  
+  this.set_val = function(b){
+    var me = this;
+    me.sel = b;  
+    me.make_body();
+  }
+}
+
+//=================================================================================================================================
+SalesBrowser.prototype.make_tree_body = function(parent){
+
+  //this.tab2 =make_table(this.wrapper,1,2,'100%',['60%','40%']);
+  this.make_tree();
+  this.make_rgt_sect();
+  
+}
+
+//=================================================================================================================================
+SalesBrowser.prototype.make_rgt_sect=function(){
+  //var d = $a($td(this.tab2,0,1),'div','',{border:'1px solid #000'});
+
+  this.rgt_tab =make_table(this.detail_area,4,1,'','',{padding:"4px",spacing:"4px"});
+  this.dtl = $a($td(this.rgt_tab,0,0),'div');
+  this.btn = $a($td(this.rgt_tab,1,0),'div','span');
+  this.help = $a($td(this.rgt_tab,2,0),'div');
+  this.help.innerHTML = "Note: Explore and click on the tree node to see details."
+
+  this.set_btn();
+}
+//=================================================================================================================================
+SalesBrowser.prototype.set_btn = function(){
+  var me = this;
+  this.edit_btn = $btn(this.btn,'Edit',function(){ me.set_dialog(2); });
+
+  this.trash_btn = $btn(this.btn,'Trash',null);
+  this.trash_btn.onclick = function(){
+    var check = confirm("Are you sure you want to trash "+me.cur_node.rec.name+" node?");
+    
+    if(check){
+      var arg = [me.cur_node.rec.name, me.sel];
+      $c_obj('Sales Browser Control','trash_record',arg.join(','),function(r,rt){      me.refresh_tree();});
+
+    }
+  }
+}
+
+//=====================================================
+SalesBrowser.prototype.set_dialog = function(f){
+
+ 
+  if(this.sel == 'Territory')
+    new MakeDialog('Territory','territory',f,this);            //Territory Dialog
+  if(this.sel == 'Customer Group')
+    new MakeDialog('Customer Group','customer_group',f,this);  //Customer Group Dialog  
+  if(this.sel == 'Item Group')
+    new MakeDialog('Item Group','item_group',f,this);   //Item Group Dialog
+  if(this.sel == 'Sales Person')
+    new MakeDialog('Sales Person','sales_person',f,this);//Sales Person Dialog 
+  
+}
+//=====================================================Make Tree============================================================================
+SalesBrowser.prototype.make_tree = function() {
+  var me = this;
+
+  this.tree = new Tree(this.tree_area, '100%');
+  
+  //---------------------------------------------------------------------------------------------------------------------------------
+  // on click
+  this.tree.std_onclick = function(node) {
+      
+      me.cur_node = node;
+      if(node.rec.name =='All Customer Groups' || node.rec.name =='All Sales Persons' || node.rec.name =='All Item Groups' || node.rec.name =='All Territories'){
+        //$di(me.add_btn);
+
+        $dh(me.edit_btn);
+        $dh(me.trash_btn);
+      }
+      else{
+        //$di(me.add_btn);
+        //if(node.has_children == false)
+          //$dh(me.add_btn);
+
+        $di(me.edit_btn);
+        $di(me.trash_btn);
+
+      }
+      me.make_details();
+	  
+  }
+  //---------------------------------------------------------------------------------------------------------------------------------
+  // on expand
+  this.tree.std_onexp = function(node) {
+
+    if(node.expanded_once)return;
+    $di(node.loading_div);
+
+    var callback = function(r,rt) {
+
+      $dh(node.loading_div);
+      var n = me.tree.allnodes[r.message.parent];
+      var cl = r.message.cl;
+
+      for(var i=0;i<cl.length;i++) {
+        var imgsrc=null;
+        var has_children = true;
+
+        if(cl[i].is_group=='No') {
+          var imgsrc = 'images/icons/page.gif';
+          has_children = false;
+        }
+        var t = me.tree.addNode(n, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
+        t.rec = cl[i];
+        t.parent_account = r.message.parent;
+        t.has_children = has_children;
+      }
+
+    }
+    var arg = [node.rec.name, me.sel];
+    $c_obj('Sales Browser Control','get_record_list',arg.join(','),callback);
+  }
+  
+ 
+}
+
+//=================================================================================================================================
+SalesBrowser.prototype.make_details = function(){
+  var me = this;
+  var callback = function(r,rt){
+
+    me.dtl.innerHTML = "";
+    //me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse'})
+    
+    var h = $a(me.dtl,'h3','',{padding:'4px', margin:'0px',backgroundColor:'#EEEEEE',borderBottom:'1px solid #AAAAAA'});
+    $(h).html(r.message.name);
+    
+    var d = $a(me.dtl,'div');
+    me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse',padding:'4px'})
+    $td(me.dtl_tab,0,0).innerHTML="Parent";
+    if(r.message.parent != '')
+      $td(me.dtl_tab,0,1).innerHTML=": "+r.message.parent;
+    else
+      $td(me.dtl_tab,0,1).innerHTML=": ----";    
+    $td(me.dtl_tab,1,0).innerHTML="Has Child Node";
+    $td(me.dtl_tab,1,1).innerHTML=": "+r.message.is_group;
+   
+
+    me.open_doc = $a(me.dtl,'div','link_type',{paddingTop:'14px'});
+    me.open_doc.innerHTML = "Click here to open "+r.message.name;
+    
+    me.open_doc.onclick = function(){
+      loaddoc(me.sel,r.message.name );
+    }
+  }
+
+  var arg = [this.cur_node.rec.name, this.sel];
+  
+  $c_obj('Sales Browser Control','get_record',arg.join(','),callback);
+
+}
+//=================================================================================================================================
+SalesBrowser.prototype.refresh_tree=function(){
+
+  this.tree_area.innerHTML = '';
+  this.dtl.innerHTML = '';  
+  this.first_level_node();    //set root
+  //hide add, edit, trash buttons
+  //$dh(this.add_btn);
+  $dh(this.edit_btn);
+  $dh(this.trash_btn);
+  
+
+
+}
+
+//=============================== make first level node ================================================
+SalesBrowser.prototype.first_level_node = function(){
+
+  var me = this;
+  var callback = function(r,rt) {
+
+    var cl = r.message.cl;
+
+    for(var i=0;i<cl.length;i++) {
+      var imgsrc=null;
+      var has_children = true;
+
+      if(cl[i].is_group=='No') {
+        var imgsrc = 'images/icons/page.gif';
+        has_children = false;
+      }
+     me.tree_area.innerHTML = ''; 
+     if(me.tree) {
+
+        me.tree.innerHTML = '';
+        me.tree.body.innerHTML = '';
+        
+        me.make_tree();
+      }
+
+      var t = me.tree.addNode(null, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
+      t.rec ={};
+      t.rec.name = cl[i].name;
+      t.has_children = has_children;
+    }
+  }
+
+  $c_obj('Sales Browser Control','get_fl_node',this.sel,callback);
+
+}
+
+//========================================= Dialog Section ===================================================================
+//--------------------------------------------------------------------------------------------------------------------------------
+//========================================================================
+MakeDialog=function(label,field_name,n,cls_obj){
+
+  var new_head = 'Create A New '+label;
+
+  this.label = label;
+
+  this.lbl_rec = label+' Name';
+  this.field_name = field_name;
+  this.n = n;
+  this.cls_obj=cls_obj;
+  //-----------------------------------------------
+ 
+  this.main_dialog = new Dialog(400,300,new_head);      
+  this.set_dg_fields();
+  this.set_dg_values();
+  //-----------------------------------------------
+  this.new_main_dialog = this.main_dialog;
+  
+  this.new_main_dialog.show();
+
+}
+//=================================================================================================================================
+MakeDialog.prototype.set_dg_fields = function(){
+
+  var bd_lst = [];
+  bd_lst.push(['HTML','Heading'],['Data',this.lbl_rec],['Select','Parent'],['Select','Has Child Node']);
+  if(this.cls_obj.sel == 'Sales Person')
+    bd_lst.push(['HTML','','All nodes are allowed in transaction.']);
+  else
+    bd_lst.push(['HTML','','Only leaf nodes are allowed in transaction.']);
+  if(this.n==1)
+    bd_lst.push(['Button','Create']);
+  
+  if(this.n==2){
+    bd_lst.push(['Button','Update']);
+    this.set_edit_fields();
+  }  
+
+  this.main_dialog.make_body(bd_lst);
+  
+  //-----------------------------------------------
+}
+
+
+//==================================================================================================================================== 
+MakeDialog.prototype.set_edit_fields=function(){
+  var me = this;
+  var callback = function(r,rt){
+    
+    me.main_dialog.widgets[me.lbl_rec].value = r.message.name;
+    
+    add_sel_options(me.main_dialog.widgets['Parent'], r.message.parent_lst,r.message.parent);    
+    me.main_dialog.widgets['Has Child Node'].value = r.message.is_group;
+  }
+
+  var arg = [this.cls_obj.cur_node.rec.name, this.cls_obj.sel];
+  
+  $c_obj('Sales Browser Control','get_record',arg.join(','),callback);
+}
+//======================================= Validation - fields entered or not =================================================
+MakeDialog.prototype.validate = function(){
+
+  if(!this.main_dialog.widgets[this.lbl_rec].value) {
+      err_msg1 ='Please enter '+this.label +' Name' 
+      alert(err_msg1); 
+      return 1;
+    }
+    if(!this.main_dialog.widgets['Parent'].value){
+      alert('Please enter Parent Name' );
+      return 1;
+    }
+}
+//==================================================================================================================================== 
+MakeDialog.prototype.set_dg_values = function(){
+  if(this.n==1){
+    var me = this;
+    var callback = function(r,rt){
+      me.main_dialog.widgets[me.lbl_rec].disabled = 0;
+      me.main_dialog.widgets['Parent'].disabled = 0;
+
+      add_sel_options(me.main_dialog.widgets['Parent'],r.message);
+      //add_sel_options(this.main_dialog.widgets['Parent'], [this.cls_obj.cur_node.rec.name]);
+      me.btn_onclick('Create',me.cls_obj);
+    }
+  
+    $c_obj('Sales Browser Control','get_parent_lst',this.cls_obj.sel,callback);
+
+  }  
+  if(this.n == 2){
+    this.main_dialog.widgets[this.lbl_rec].disabled = 1;
+    this.main_dialog.widgets['Parent'].disabled = 0;
+    this.btn_onclick('Update');
+    this.old_value = sel_val(this.main_dialog.widgets['Parent']);
+  }
+
+  add_sel_options(this.main_dialog.widgets['Has Child Node'], ['Yes','No'], 'No');
+
+}
+
+//================================================================================================================================= 
+//-----------------------------------------Dialog button onclick event----------------------------------------------
+MakeDialog.prototype.btn_onclick=function(btn_name){
+  var me = this;
+  this.btn_name = btn_name;
+  this.main_dialog.widgets[this.btn_name].onclick = function() {
+  
+    var callback=function(r,rt){
+      if(r.message == 'true'){
+        me.main_dialog.hide();
+      }
+      else{
+        flag = me.validate();
+        if(flag == 1) return;
+           
+        //---------------------------------------------------------  
+
+        var arg2 = me.make_args();
+        
+        //create Sales Person -- server to Sales Browser Control
+        if(me.btn_name == "Create")
+          method_name = "add_node";
+        else 
+          method_name = "edit_node";       
+           
+        $c_obj('Sales Browser Control',method_name, docstring(arg2), function(r,rt) { 
+          me.main_dialog.widgets[me.lbl_rec].value='';
+          me.main_dialog.hide();
+          /*if(me.btn_name == "Create"){
+            me.cls_obj.cur_node.clear_child_nodes();
+            me.cls_obj.dtl.innerHTML = '';  
+            me.cls_obj.cur_node.expand();
+          }
+          else{
+            me.cls_obj.refresh_tree();   
+          }*/
+          me.cls_obj.refresh_tree(); 
+        });
+      }
+    }
+    var arg1 = {'node_title':me.cls_obj.sel,'is_group':sel_val(me.main_dialog.widgets['Has Child Node']),'lft':0,'rgt':0,'nm':me.main_dialog.widgets[me.lbl_rec].value,'parent_nm':sel_val(me.main_dialog.widgets['Parent']),'action':me.btn_name};
+    $c_obj('Sales Browser Control','mvalidate',docstring(arg1),callback);
+  }
+}
+//=================================================================================================================================
+
+MakeDialog.prototype.make_args = function(){
+  var args ={};   //args making
+  var nt = this.cls_obj.sel;
+  var nm = this.main_dialog.widgets[this.lbl_rec].value;
+  var pnm = sel_val(this.main_dialog.widgets['Parent']);
+  var grp = sel_val(this.main_dialog.widgets['Has Child Node']);
+
+  if(this.n==1)
+    var old_prt ='';
+  else if(this.n==2){
+    if(this.old_value == sel_val(this.main_dialog.widgets['Parent']))
+      var old_prt = '';
+    else
+      var old_prt = this.old_value;
+  }
+  
+  if(this.cls_obj.sel == 'Territory')
+    return {'node_title':nt,'territory_name':nm,'parent_territory':pnm,'is_group':grp,'old_parent':old_prt}
+
+  else if(this.cls_obj.sel == 'Customer Group')
+    return {'node_title':nt,'customer_group_name':nm,'parent_customer_group':pnm,'is_group':grp,'old_parent':old_prt}
+
+  else if(this.cls_obj.sel == 'Item Group')
+    return {'node_title':nt,'item_group_name':nm,'parent_item_group':pnm,'is_group':grp,'old_parent':old_prt}
+
+  else if(this.cls_obj.sel == 'Sales Person')
+    return {'node_title':nt,'sales_person_name':nm,'parent_sales_person':pnm,'is_group':grp,'old_parent':old_prt}
+
+}
\ No newline at end of file
diff --git a/crm/page/sales_browser/sales_browser.txt b/crm/page/sales_browser/sales_browser.txt
new file mode 100644
index 0000000..bdeb236
--- /dev/null
+++ b/crm/page/sales_browser/sales_browser.txt
@@ -0,0 +1 @@
+[{'creation': '2010-06-16 11:44:38', 'module': 'CRM', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Sales Browser', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Sales Browser', 'idx': None, 'static_content': None, 'modified': '2010-11-10 19:21:50', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'Administrator', 'name': 'PR000140', 'parent': 'Sales Browser', 'creation': '2010-06-16 12:08:31', 'modified': '2010-11-10 19:21:50', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'Administrator', 'name': 'PR000149', 'parent': 'Sales Browser', 'creation': '2010-07-14 15:57:09', 'modified': '2010-11-10 19:21:50', 'doctype': 'Page Role', 'idx': 2, 'parenttype': 'Page', 'role': 'Material Master Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/crm/page/sales_dashboard/__init__.py b/crm/page/sales_dashboard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/crm/page/sales_dashboard/__init__.py
diff --git a/crm/page/sales_dashboard/sales_dashboard.html b/crm/page/sales_dashboard/sales_dashboard.html
new file mode 100644
index 0000000..ec76d44
--- /dev/null
+++ b/crm/page/sales_dashboard/sales_dashboard.html
@@ -0,0 +1,6 @@
+<div class="layout_wrapper">
+<div id="pt_header"></div>
+<div id="pt_filters"></div>
+<p>&nbsp;</p>
+<div id="plot_test"></div>
+</div>
\ No newline at end of file
diff --git a/crm/page/sales_dashboard/sales_dashboard.js b/crm/page/sales_dashboard/sales_dashboard.js
new file mode 100644
index 0000000..cdb5c7c
--- /dev/null
+++ b/crm/page/sales_dashboard/sales_dashboard.js
@@ -0,0 +1,301 @@
+pscript['onload_Sales Dashboard'] = function() {
+  var h = new PageHeader('pt_header','Sales Dashboard');
+  
+  pscript.make_filters(); 
+  $dh(pscript.mnt_div);
+  $dh(pscript.mnt_div1);
+  //pscript.dx_axis = [];
+  
+  if($.jqplot) pscript.all_onchnge();
+  else
+    // import the library
+    $c_js('jquery/jquery.jqplot.min.js', pscript.all_onchnge);
+}
+//=======================================================================
+pscript.make_filters = function(){
+  this.tab = make_table('pt_filters', 2, 4, '800px', ['200px','200px','200px','200px'], {padding: '2px'});
+  pscript.fiscal_year();
+  pscript.report_type();
+  pscript.item_grp();
+  pscript.month_lst();
+}
+//=======================================================================
+
+pscript.fiscal_year=function(){
+  var me = this;
+  $td(this.tab,0,0).innerHTML = "Select Year";
+  this.sel_fy = $a($td(this.tab,1,0), 'select', null, {width:'120px'});
+  $c_obj('Plot Control', 'get_fiscal_year', '', function(r,rt){
+    if(r.message)  fy_lst = r.message;
+    else  fy_lst = [];
+    empty_select(me.sel_fy);
+    add_sel_options(me.sel_fy,fy_lst);
+    me.sel_fy.value = sys_defaults.fiscal_year;
+  });
+  
+}
+
+//=======================================================================
+
+pscript.report_type=function(){
+  $td(this.tab,0,1).innerHTML = "Select Report";
+  this.sel_rpt = $a($td(this.tab,1,1), 'select', null, {width:'120px'});
+  rpt_lst = ['Monthly','Weekly']; 
+  add_sel_options(this.sel_rpt,rpt_lst);
+}
+
+//=======================================================================
+
+pscript.item_grp=function(){
+  var me = this;
+  
+  $td(this.tab,0,2).innerHTML = "Select Item Group";
+  
+  this.sel_grp = $a($td(this.tab,1,2), 'select', null, {width:'120px'});
+  $c_obj('Plot Control', 'get_item_groups', '', function(r,rt){
+    
+    itg_lst = r.message;
+    itg_lst.push('All');
+    
+    empty_select(me.sel_grp);
+    add_sel_options(me.sel_grp, itg_lst.reverse());
+  });
+  
+}
+
+//=======================================================================
+
+pscript.month_lst=function(){
+  pscript.mnt_div1 = $a($td(this.tab,0,3));
+  pscript.mnt_div1.innerHTML = "Select Month";
+  pscript.mnt_div = $a($td(this.tab,1,3));
+  this.sel_mnt = $a(pscript.mnt_div, 'select', null, {width:'120px'});
+  mnt_lst = ['All','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; 
+  add_sel_options(this.sel_mnt,mnt_lst);
+}
+
+//=======================================================================
+pscript.all_onchnge = function(){
+  pscript.report_change();
+  pscript.fiscal_year_onchnage();
+  pscript.month_onchange();
+  pscript.item_grp_onchange();
+  pscript.monthly();
+}
+
+//=======================================================================
+pscript.report_change = function(){
+  var me = this;
+  this.sel_rpt.onchange = function(){
+    
+    $dh(pscript.mnt_div);
+    $dh(pscript.mnt_div1);
+    if(me.sel_rpt.value == 'Monthly'){
+      
+      pscript.monthly();
+    }
+    
+    else if(me.sel_rpt.value == 'Weekly'){
+      $ds(pscript.mnt_div); 
+      $ds(pscript.mnt_div1);
+      me.sel_mnt.value = 'All';
+      pscript.get_x_dates();
+
+    }
+    
+    else{
+      me.sel_mnt.value = 'All';
+      $i('plot_test').innerHTML = '';
+    }
+  }
+
+}
+//=======================================================================
+pscript.fiscal_year_onchnage = function(){
+  var me = this;
+  this.sel_fy.onchange = function(){ 
+
+    if(me.sel_rpt.value == 'Monthly'){
+      
+      me.sel_mnt.value = 'All';
+      $dh(pscript.mnt_div); 
+      $dh(pscript.mnt_div1);     
+      pscript.monthly();
+    }
+    else if(me.sel_rpt.value == 'Weekly' && me.sel_mnt.value){
+    
+      pscript.get_x_dates();
+      
+    }
+    
+    else{
+      me.sel_mnt.value = 'All';
+      me.sel_rpt.value == '';
+      $i('plot_test').innerHTML = '';
+      
+    }
+  }
+
+}
+//=======================================================================
+pscript.month_onchange = function(){
+  this.sel_mnt.onchange = function(){
+    pscript.get_x_dates();
+    
+  }
+}
+//=======================================================================
+
+pscript.item_grp_onchange=function(){
+  var me = this;
+  this.sel_grp.onchange = function(){
+  
+    if(me.sel_rpt.value == 'Monthly'){
+      
+      me.sel_mnt.value = 'All';
+      $dh(pscript.mnt_div); 
+      $dh(pscript.mnt_div1);     
+      pscript.monthly();
+    }
+    else if(me.sel_rpt.value == 'Weekly' && me.sel_mnt.value){
+    
+      pscript.get_x_dates();
+      
+    }
+    
+    else{
+      me.sel_mnt.value = 'All';
+      me.sel_rpt.value == '';
+      $i('plot_test').innerHTML = '';
+      
+    }
+  }
+    
+  }
+
+//=======================================================================
+
+pscript.get_x_dates=function(){
+  
+  if(this.sel_mnt.value !='All'){
+    
+    pscript.weekly();
+  }
+  else{ 
+    
+    $c_obj('Plot Control','yr_wk_dates',this.sel_fy.value,
+      function(r,rt){
+        
+        pscript.dx_axis = r.message[0];
+        
+        pscript.x_axis = r.message[1];
+        
+        pscript.yearly();
+      }
+    );
+    
+  }
+}
+
+//=======================================================================
+pscript.draw_graph1 = function(x_axis,line1,t) {
+  
+  t = t + " ("+sys_defaults.currency +")";
+  $i('plot_test').innerHTML = '';
+  // div plot_test contains the container div
+  $.jqplot('plot_test',  [line1],{
+    title:t,
+    axesDefaults: {
+      min:0  
+    },
+    
+    axes:{ 
+      xaxis:{ticks:x_axis}
+    }
+  });
+}
+//=======================================================================
+pscript.monthly = function(){
+  var callback = function(r,rt){
+    x_axis = r.message.x_axis;
+    msg_data = r.message.msg_data; 
+    
+    var line1 = [];
+    for(var i=0; i<x_axis.length;i++){
+      var f =0
+      for(var j=0; j<msg_data.length;j++){
+        if(msg_data[j] && x_axis[i]){
+          if(x_axis[i][1] == msg_data[j][1])
+          { 
+            line1.push([i+1,flt(msg_data[j][0])]);
+            f = 1
+          }
+          
+        }
+      }
+      if(f == 0){
+        line1.push([i+1,0]);
+      }
+    }
+    pscript.draw_graph1(x_axis,line1,'Monthly Sales');
+  }
+  var val2 = '';
+  if(this.sel_grp.value != 'All') val2 = this.sel_grp.value;
+  $c_obj('Plot Control','get_monthwise_amount',[this.sel_fy.value,val2],callback);
+}
+
+//=======================================================================
+
+pscript.weekly = function(){
+  
+  var callback = function(r,rt){
+    
+    x_axis =[[1,'Week1'],[2,'Week2'],[3,'Week3'],[4,'Week4'],[5,'Week5'],[6,'Week6']];
+    var line1 = [];
+    for(var i=0; i<x_axis.length;i++){
+      var f = 0;
+      for(var j=0; j<r.message.length;j++){
+        if(r.message[j]){
+          if(r.message[j][1] == x_axis[i][1]){ line1.push([i+1,flt(r.message[j][0])]); f=1;}}
+      }
+      if(f == 0){
+        line1.push([i+1,0]);
+      }
+    }
+    
+    pscript.draw_graph1(x_axis,line1,'Weekly Sales');
+  }
+  dict_mnt={'Jan':1,'Feb':2,'Mar':3,'Apr':4,'May':5,'Jun':6,'Jul':7,'Aug':8,'Sep':9,'Oct':10,'Nov':11,'Dec':12};
+  var val3 = '';
+  if(this.sel_grp.value != 'All') val3 = this.sel_grp.value;
+  $c_obj('Plot Control','get_weekwise_amount',[dict_mnt[this.sel_mnt.value],this.sel_fy.value,val3],callback);
+}
+
+//=======================================================================
+
+pscript.yearly = function(){
+  
+  var callback = function(r,rt){
+      
+    var line1 = [];
+    for(var i=0; i<pscript.x_axis.length;i++){
+      var f = 0
+      for(var j=0; j<r.message.length;j++){
+        if(r.message[j]){
+
+          if((r.message[j][1] == pscript.x_axis[i][1]) && (r.message[j][2] == pscript.x_axis[i][2])){ line1.push([pscript.x_axis[i][0],r.message[j][0]]); break; f =1;}
+      }
+      }
+      if(f == 0){
+        line1.push([pscript.x_axis[i][0],0]);
+      }
+    }
+    
+    pscript.draw_graph1(pscript.dx_axis,line1,'Year-Weekly Sales');
+  }
+  var val2 = '';
+  if(this.sel_grp.value != 'All') val2 = this.sel_grp.value;
+  
+  
+  $c_obj('Plot Control','get_year_weekwise_amount',[this.sel_fy.value,val2],callback);
+} 
\ No newline at end of file
diff --git a/crm/page/sales_dashboard/sales_dashboard.txt b/crm/page/sales_dashboard/sales_dashboard.txt
new file mode 100644
index 0000000..c08615a
--- /dev/null
+++ b/crm/page/sales_dashboard/sales_dashboard.txt
@@ -0,0 +1 @@
+[{'creation': '2010-05-21 13:56:25', 'module': 'CRM', 'doctype': 'Page', 'owner': 'harshada@webnotestech.com', 'style': None, 'modified_by': 'saumil@webnotestech.com', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Sales Dashboard', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Sales Dashboard', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000136', 'parent': 'Sales Dashboard', 'creation': '2010-05-21 13:56:25', 'modified': '2010-08-08 00:01:08', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Sales Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file