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");
152 _this.grid.ds.proxy.conn.method = 'POST';
159 text : "Download Mailing list subscribers"
165 click : function (_self, e)
168 if (!Pman.hasPerm('Xtuple.CustomerDownload','S')) {
169 Roo.MessageBox.alert("Error", "Permission Denied");
172 _this.grid.ds.proxy.conn.method = 'POST';
179 text : "Download Customers"
185 click : function (_self, e)
188 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
189 Roo.MessageBox.alert("Error", "Permission Denied");
193 var c = _this.country.getValue();
195 Roo.MessageBox.alert("Error", "Please select a country");
200 url : baseURL + '/Roo/custinfo',
205 'search[_country]' : c,
206 'search[with_address]' : 1
212 text : "Download Customers As Json"
218 click : function (_self, e)
221 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
222 Roo.MessageBox.alert("Error", "Permission Denied");
226 Pman.Dialog.Image.show(
228 _url : baseURL+'/Xtuple/Import/Customers'
232 _this.grid.footer.onClick('first');
233 Roo.MessageBox.alert("Notice", "DONE");
234 // Roo.MessageBox.alert("Notice", msg.join("\n"));
241 text : "Upload Customers"
247 click : function (_self, e)
250 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
251 Roo.MessageBox.alert("Error", "Permission Denied");
255 Pman.Dialog.Image.show(
257 _url : baseURL+'/Xtuple/Import/MyCustomers'
261 _this.grid.footer.onClick('first');
262 Roo.MessageBox.alert("Notice", "DONE");
263 // Roo.MessageBox.alert("Notice", msg.join("\n"));
270 text : "Upload Customers Json File"
276 click : function (_self, e)
279 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
280 Roo.MessageBox.alert("Error", "Permission Denied");
284 Pman.Dialog.Image.show(
286 _url : baseURL+'/Xtuple/Import/AUPostAccounts'
290 _this.grid.footer.onClick('first');
291 Roo.MessageBox.alert("Notice", data);
298 text : "Upload AU Post Accounts"
318 render : function (_self)
320 _this.searchBox = _self;
322 specialkey : function (_self, e)
324 _this.grid.footer.onClick('first');
332 click : function (_self, e)
334 _this.grid.footer.onClick('first');
338 icon : rootURL + '/Pman/templates/images/search.gif'
344 click : function (_self, e)
346 _this.searchBox.setValue('');
349 _this.grid.footer.onClick('first');
353 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
359 render : function (_self)
361 _this.officeCombo = _self;
363 select : function (combo, record, index)
366 _this.grid.footer.onClick('first');
370 displayField : 'office',
372 fieldLabel : 'Office',
373 hiddenName : 'office',
377 tpl : '<div class="x-grid-cell-text x-btn button"><b>{office}</b> </div>',
378 triggerAction : 'all',
379 valueField : 'office',
382 xtype: 'SimpleStore',
399 render : function (_self)
401 _this.country = _self;
403 select : function (combo, record, index)
405 _this.grid.footer.onClick('first');
410 displayField : 'addr_country',
412 emptyText : "Select Country",
413 fieldLabel : 'Country',
414 forceSelection : true,
415 hiddenName : 'addr_country',
417 loadingText : "Searching...",
419 name : 'addr_country',
421 qtip : "Select Country",
422 queryParam : 'query[addr_country]',
423 selectOnFocus : true,
424 tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_country}</b> </div>',
425 triggerAction : 'all',
427 valueField : 'addr_country',
433 beforeload : function (_self, o){
434 o.params = o.params || {};
435 o.params._distinct = 'addr_country';
436 o.params._columns ='addr_country';
440 sortInfo : { direction : 'ASC', field: 'addr_country' },
445 url : baseURL + '/Roo/Addr.php'
452 totalProperty : 'total',
453 fields : [{"name":"addr_id","type":"int"},{"name":"addr_country","type":"string"}]
461 toggle : function (_self, pressed)
463 _this.grid.footer.onClick('first');
465 render : function (_self)
467 _this.activeBtn = _self;
472 text : "Show / Hide Inactive"
477 text : "Has orders since"
483 render : function (_self)
485 _this.dateSearch = _self
487 select : function (combo, date)
489 _this.grid.footer.onClick('first');
491 specialkey : function (_self, e)
493 _this.grid.footer.onClick('first');
501 text : "No orders since"
507 render : function (_self)
509 _this.dateSearchNo = _self
511 select : function (combo, date)
513 _this.grid.footer.onClick('first');
515 specialkey : function (_self, e)
517 _this.grid.footer.onClick('first');
532 if (!_this.dialog) return;
533 _this.dialog.show( { id : 0 } , function() {
534 _this.grid.footer.onClick('first');
538 cls : 'x-btn-text-icon',
540 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
548 var s = _this.grid.getSelectionModel().getSelections();
549 if (!s.length || (s.length > 1)) {
550 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
553 if (!_this.dialog) return;
554 _this.dialog.show(s[0].data, function() {
555 _this.grid.footer.onClick('first');
560 cls : 'x-btn-text-icon',
562 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
568 xtype: 'ColumnModel',
570 dataIndex : 'cust_active',
573 renderer : function(v) { return String.format('{0}', v? 'Y' : 'N'); }
576 xtype: 'ColumnModel',
578 dataIndex : 'last_order',
579 header : 'Last Order',
581 renderer : function(v) {
585 var vv = Date.parseDate(v, 'Y-m-d');
586 return String.format('{0}', vv.format('d/M/Y') );
590 xtype: 'ColumnModel',
592 dataIndex : 'cust_taxzone_id_taxzone_descrip',
593 header : 'Tax Status',
596 renderer : function(v) { return String.format('{0}', v); }
599 xtype: 'ColumnModel',
601 dataIndex : 'cust_terms_id_terms_descrip',
605 renderer : function(v) { return String.format('{0}', v); }
608 xtype: 'ColumnModel',
610 dataIndex : 'cust_salesrep_id_salesrep_name',
611 header : 'Sales Rep',
614 renderer : function(v) { return String.format('{0}', v); }
617 xtype: 'ColumnModel',
619 dataIndex : 'ipshead_id_name',
620 header : 'Curr/Price List',
623 renderer : function(v,x,r) {
625 return String.format('{0}<br/><span style="color:red">No price list</span>',
626 r.data.cust_curr_id_curr_name );
629 return String.format('{0}<br/>{1}',
630 r.data.cust_curr_id_curr_name,
635 xtype: 'ColumnModel',
637 dataIndex : 'cust_number',
641 renderer : function(v) { return String.format('{0}', v); }
644 xtype: 'ColumnModel',
646 dataIndex : 'cust_name',
650 renderer : function(v,x,r) {
651 if (!r.data.cust_char_internalcompany.length) {
652 return String.format('{0}', v);
654 return String.format('<span style="color:red">[Internal company : {0}] {1}</span>',
655 r.data.cust_char_internalcompany, v);
659 xtype: 'ColumnModel',
661 dataIndex : 'cust_bill_info',
662 header : 'Billing Address',
665 renderer : function(v,x,r)
669 Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {
\r
670 if (!r.data['cntct_addr_' + k].length) {
\r
673 add.push(String.format("{0}", r.data['cntct_addr_' + k]));
\r
676 return add.join('<BR/>');
679 var v = v.split("\r\n").join("<br/>");
684 xtype: 'ColumnModel',
686 dataIndex : 'cust_ship_info',
687 header : 'Shipping Address',
690 renderer : function(v,x,r)
694 Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {
\r
695 if (!r.data['cntct_addr_' + k].length) {
\r
698 add.push(String.format("{0}", r.data['cntct_addr_' + k]));
\r
701 return add.join('<BR/>');
704 var v = v.split("\r\n").join("<br/>");
709 xtype: 'ColumnModel',
711 dataIndex : 'cust_cntct_id_cntct_first_name',
715 renderer : function(v,x,r)
717 return String.format(
720 'Email: <a href="mailto:{2}">{2}</a>',
722 r.data.cust_cntct_id_cntct_first_name,
723 r.data.cust_cntct_id_cntct_phone,
724 r.data.cust_cntct_id_cntct_email
729 xtype: 'ColumnModel',
731 dataIndex : 'cust_char_au_post_accno',
736 renderer : function(v,x,r)
738 return String.format('{0}', v);
742 xtype: 'ColumnModel',
744 dataIndex : 'cust_cntct_id_cntct_phone',
745 header : 'Contact Number',
749 renderer : function(v,x,r)
751 return String.format('{0}',v);
755 xtype: 'ColumnModel',
757 dataIndex : 'cust_cntct_id_cntct_email',
762 renderer : function(v,x,r)
764 return String.format('<a href="mailto:{0}">{0}</a>', v);
768 xtype: 'ColumnModel',
771 dataIndex : 'cntct_addr_city',
776 renderer : function(v) { return String.format('{0}', v ? v : ''); }
779 xtype: 'ColumnModel',
782 dataIndex : 'cntct_addr_state',
787 renderer : function(v) { return String.format('{0}', v ? v : ''); }
790 xtype: 'ColumnModel',
793 dataIndex : 'cntct_addr_country',
797 renderer : function(v) { return String.format('{0}', v ? v : ''); }
800 xtype: 'ColumnModel',
802 dataIndex : 'cust_curr_id_curr_name',
806 renderer : function(v) { return String.format('{0}', v); }
809 xtype: 'ColumnModel',
812 dataIndex : 'balance',
815 renderer : function(v,x,r) {
818 return String.format('{0}{1}', r.data.cust_curr_id_curr_symbol, Roo.util.Format.number(v,2));