1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleCustomer = new Roo.XComponent({
6 part : ["Xtuple","Customer"],
7 order : '700-Pman.Tab.XtupleCustomer',
9 parent : 'Pman.Tab.XtupleSales',
10 name : "unnamed module",
21 activate : function() {
24 _this.grid.footer.onClick('first');
32 tableName : 'custinfo',
41 _this.dialog = Pman.Dialog.XtupleCustomer;
42 if (_this.panel.active) {
43 this.footer.onClick('first');
46 rowdblclick : function (_self, rowIndex, e)
48 if (!_this.dialog) return;
49 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
50 _this.grid.footer.onClick('refresh');
54 autoExpandColumn : 'cust_name',
60 beforeload : function (_self, o)
62 if (!_this.officeCombo) {
66 o.params = o.params || {};
67 o.params['search[cust_name]'] = _this.searchBox.getValue();
68 if (!_this.activeBtn.pressed) {
69 o.params.cust_active = 1;
71 var dt = _this.dateSearch.getValue();
73 o.params['search[orders_since]'] = dt.format('Y-m-d');
75 dt = _this.dateSearchNo.getValue();
77 o.params['search[no_orders_since]'] = dt.format('Y-m-d');
80 o.params['search[with_orders_since]'] = 1; //
81 o.params['search[with_balance]'] = 1;
82 o.params['search[with_address]'] = 1;
83 o.params['_with_char'] = 1;
84 o.params['_with_group_data'] = 1;
85 o.params['search[_country]'] = _this.country.getValue();
86 o.params._get = 1; // for download
88 o.params['cust_char_internalcompany'] = _this.officeCombo.getValue();
92 sortInfo : { field : 'cust_name', direction: 'ASC' },
97 url : baseURL + '/Roo/custinfo.php'
102 totalProperty : 'total',
107 'name': 'cust_active',
111 'name': 'cust_custtype_id_custtype_descrip',
115 'name': 'cust_salesrep_id_salesrep_name',
126 xtype: 'PagingToolbar',
130 displayMsg : "Displaying custinfo{0} - {1} of {2}",
131 emptyMsg : "No custinfo found",
136 text : "Upload/Download",
145 click : function (_self, e)
148 if (!Pman.hasPerm('Xtuple.CustomerDownload','S')) {
149 Roo.MessageBox.alert("Error", "Permission Denied");
154 '_group' : 'customer',
155 '_name' : 'subscribers',
163 url : baseURL + '/Roo/Metasql',
169 url : baseURL + '/Roo/custinfo',
177 Roo.MessageBox.alert("Notice", "Report will download shortly");
181 text : "Download Mailing list subscribers"
187 click : function (_self, e)
190 if (!Pman.hasPerm('Xtuple.CustomerDownload','S')) {
191 Roo.MessageBox.alert("Error", "Permission Denied");
194 _this.grid.ds.proxy.conn.method = 'POST';
201 text : "Download Customers"
207 click : function (_self, e)
210 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
211 Roo.MessageBox.alert("Error", "Permission Denied");
215 var c = _this.country.getValue();
217 Roo.MessageBox.alert("Error", "Please select a country");
222 url : baseURL + '/Roo/custinfo',
227 'search[_country]' : c,
228 'search[with_address]' : 1
234 text : "Download Customers As Json"
240 click : function (_self, e)
243 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
244 Roo.MessageBox.alert("Error", "Permission Denied");
248 Pman.Dialog.Image.show(
250 _url : baseURL+'/Xtuple/Import/Customers'
254 _this.grid.footer.onClick('first');
255 Roo.MessageBox.alert("Notice", "DONE");
256 // Roo.MessageBox.alert("Notice", msg.join("\n"));
263 text : "Upload Customers"
269 click : function (_self, e)
272 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
273 Roo.MessageBox.alert("Error", "Permission Denied");
277 Pman.Dialog.Image.show(
279 _url : baseURL+'/Xtuple/Import/MyCustomers'
283 _this.grid.footer.onClick('first');
284 Roo.MessageBox.alert("Notice", "DONE");
285 // Roo.MessageBox.alert("Notice", msg.join("\n"));
292 text : "Upload Customers Json File"
298 click : function (_self, e)
301 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
302 Roo.MessageBox.alert("Error", "Permission Denied");
306 Pman.Dialog.Image.show(
308 _url : baseURL+'/Xtuple/Import/AUPostAccounts'
312 _this.grid.footer.onClick('first');
313 Roo.MessageBox.alert("Notice", data);
320 text : "Upload AU Post Accounts"
340 render : function (_self)
342 _this.searchBox = _self;
344 specialkey : function (_self, e)
346 _this.grid.footer.onClick('first');
354 click : function (_self, e)
356 _this.grid.footer.onClick('first');
360 icon : rootURL + '/Pman/templates/images/search.gif'
366 click : function (_self, e)
368 _this.searchBox.setValue('');
371 _this.grid.footer.onClick('first');
375 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
381 render : function (_self)
383 _this.officeCombo = _self;
385 select : function (combo, record, index)
388 _this.grid.footer.onClick('first');
392 displayField : 'office',
394 fieldLabel : 'Office',
395 hiddenName : 'office',
399 tpl : '<div class="x-grid-cell-text x-btn button"><b>{office}</b> </div>',
400 triggerAction : 'all',
401 valueField : 'office',
404 xtype: 'SimpleStore',
421 render : function (_self)
423 _this.country = _self;
425 select : function (combo, record, index)
427 _this.grid.footer.onClick('first');
432 displayField : 'addr_country',
434 emptyText : "Select Country",
435 fieldLabel : 'Country',
436 forceSelection : true,
437 hiddenName : 'addr_country',
439 loadingText : "Searching...",
441 name : 'addr_country',
443 qtip : "Select Country",
444 queryParam : 'query[addr_country]',
445 selectOnFocus : true,
446 tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_country}</b> </div>',
447 triggerAction : 'all',
449 valueField : 'addr_country',
455 beforeload : function (_self, o){
456 o.params = o.params || {};
457 o.params._distinct = 'addr_country';
458 o.params._columns ='addr_country';
462 sortInfo : { direction : 'ASC', field: 'addr_country' },
467 url : baseURL + '/Roo/Addr.php'
474 totalProperty : 'total',
475 fields : [{"name":"addr_id","type":"int"},{"name":"addr_country","type":"string"}]
483 toggle : function (_self, pressed)
485 _this.grid.footer.onClick('first');
487 render : function (_self)
489 _this.activeBtn = _self;
494 text : "Show / Hide Inactive"
499 text : "Has orders since"
505 render : function (_self)
507 _this.dateSearch = _self
509 select : function (combo, date)
511 _this.grid.footer.onClick('first');
513 specialkey : function (_self, e)
515 _this.grid.footer.onClick('first');
523 text : "No orders since"
529 render : function (_self)
531 _this.dateSearchNo = _self
533 select : function (combo, date)
535 _this.grid.footer.onClick('first');
537 specialkey : function (_self, e)
539 _this.grid.footer.onClick('first');
554 if (!_this.dialog) return;
555 _this.dialog.show( { id : 0 } , function() {
556 _this.grid.footer.onClick('first');
560 cls : 'x-btn-text-icon',
562 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
570 var s = _this.grid.getSelectionModel().getSelections();
571 if (!s.length || (s.length > 1)) {
572 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
575 if (!_this.dialog) return;
576 _this.dialog.show(s[0].data, function() {
577 _this.grid.footer.onClick('first');
582 cls : 'x-btn-text-icon',
584 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
590 xtype: 'ColumnModel',
592 dataIndex : 'cust_active',
595 renderer : function(v) { return String.format('{0}', v? 'Y' : 'N'); }
598 xtype: 'ColumnModel',
600 dataIndex : 'last_order',
601 header : 'Last Order',
603 renderer : function(v) {
607 var vv = Date.parseDate(v, 'Y-m-d');
608 return String.format('{0}', vv.format('d/M/Y') );
612 xtype: 'ColumnModel',
614 dataIndex : 'cust_taxzone_id_taxzone_descrip',
615 header : 'Tax Status',
618 renderer : function(v) { return String.format('{0}', v); }
621 xtype: 'ColumnModel',
623 dataIndex : 'cust_terms_id_terms_descrip',
627 renderer : function(v) { return String.format('{0}', v); }
630 xtype: 'ColumnModel',
632 dataIndex : 'cust_salesrep_id_salesrep_name',
633 header : 'Sales Rep',
636 renderer : function(v) { return String.format('{0}', v); }
639 xtype: 'ColumnModel',
641 dataIndex : 'ipshead_id_name',
642 header : 'Curr/Price List',
645 renderer : function(v,x,r) {
647 return String.format('{0}<br/><span style="color:red">No price list</span>',
648 r.data.cust_curr_id_curr_name );
651 return String.format('{0}<br/>{1}',
652 r.data.cust_curr_id_curr_name,
657 xtype: 'ColumnModel',
659 dataIndex : 'cust_number',
663 renderer : function(v) { return String.format('{0}', v); }
666 xtype: 'ColumnModel',
668 dataIndex : 'cust_name',
672 renderer : function(v,x,r) {
673 if (!r.data.cust_char_internalcompany.length) {
674 return String.format('{0}', v);
676 return String.format('<span style="color:red">[Internal company : {0}] {1}</span>',
677 r.data.cust_char_internalcompany, v);
681 xtype: 'ColumnModel',
683 dataIndex : 'cust_bill_info',
684 header : 'Billing Address',
687 renderer : function(v,x,r)
691 Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {
\r
692 if (!r.data['cntct_addr_' + k].length) {
\r
695 add.push(String.format("{0}", r.data['cntct_addr_' + k]));
\r
698 return add.join('<BR/>');
701 var v = v.split("\r\n").join("<br/>");
706 xtype: 'ColumnModel',
708 dataIndex : 'cust_ship_info',
709 header : 'Shipping Address',
712 renderer : function(v,x,r)
716 Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {
\r
717 if (!r.data['cntct_addr_' + k].length) {
\r
720 add.push(String.format("{0}", r.data['cntct_addr_' + k]));
\r
723 return add.join('<BR/>');
726 var v = v.split("\r\n").join("<br/>");
731 xtype: 'ColumnModel',
733 dataIndex : 'cust_cntct_id_cntct_first_name',
737 renderer : function(v,x,r)
739 return String.format(
742 'Email: <a href="mailto:{2}">{2}</a>',
744 r.data.cust_cntct_id_cntct_first_name,
745 r.data.cust_cntct_id_cntct_phone,
746 r.data.cust_cntct_id_cntct_email
751 xtype: 'ColumnModel',
753 dataIndex : 'cust_char_au_post_accno',
758 renderer : function(v,x,r)
760 return String.format('{0}', v);
764 xtype: 'ColumnModel',
766 dataIndex : 'cust_cntct_id_cntct_phone',
767 header : 'Contact Number',
771 renderer : function(v,x,r)
773 return String.format('{0}',v);
777 xtype: 'ColumnModel',
779 dataIndex : 'cust_cntct_id_cntct_email',
784 renderer : function(v,x,r)
786 return String.format('<a href="mailto:{0}">{0}</a>', v);
790 xtype: 'ColumnModel',
793 dataIndex : 'cntct_addr_city',
798 renderer : function(v) { return String.format('{0}', v ? v : ''); }
801 xtype: 'ColumnModel',
804 dataIndex : 'cntct_addr_state',
809 renderer : function(v) { return String.format('{0}', v ? v : ''); }
812 xtype: 'ColumnModel',
815 dataIndex : 'cntct_addr_country',
819 renderer : function(v) { return String.format('{0}', v ? v : ''); }
822 xtype: 'ColumnModel',
824 dataIndex : 'cust_curr_id_curr_name',
828 renderer : function(v) { return String.format('{0}', v); }
831 xtype: 'ColumnModel',
834 dataIndex : 'balance',
837 renderer : function(v,x,r) {
840 return String.format('{0}{1}', r.data.cust_curr_id_curr_symbol, Roo.util.Format.number(v,2));