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");
201 '_group' : 'customer',
202 '_name' : 'subscribers',
210 url : baseURL + '/Roo/Metasql',
214 Roo.MessageBox.alert("Notice", "Report will download shortly");
217 text : "Download Customers As Json"
223 click : function (_self, e)
226 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
227 Roo.MessageBox.alert("Error", "Permission Denied");
231 Pman.Dialog.Image.show(
233 _url : baseURL+'/Xtuple/Import/Customers'
237 _this.grid.footer.onClick('first');
238 Roo.MessageBox.alert("Notice", "DONE");
239 // Roo.MessageBox.alert("Notice", msg.join("\n"));
246 text : "Upload Customers"
252 click : function (_self, e)
255 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
256 Roo.MessageBox.alert("Error", "Permission Denied");
260 Pman.Dialog.Image.show(
262 _url : baseURL+'/Xtuple/Import/MyCustomers'
266 _this.grid.footer.onClick('first');
267 Roo.MessageBox.alert("Notice", "DONE");
268 // Roo.MessageBox.alert("Notice", msg.join("\n"));
275 text : "Upload Customers Json File"
281 click : function (_self, e)
284 if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
285 Roo.MessageBox.alert("Error", "Permission Denied");
289 Pman.Dialog.Image.show(
291 _url : baseURL+'/Xtuple/Import/AUPostAccounts'
295 _this.grid.footer.onClick('first');
296 Roo.MessageBox.alert("Notice", data);
303 text : "Upload AU Post Accounts"
323 render : function (_self)
325 _this.searchBox = _self;
327 specialkey : function (_self, e)
329 _this.grid.footer.onClick('first');
337 click : function (_self, e)
339 _this.grid.footer.onClick('first');
343 icon : rootURL + '/Pman/templates/images/search.gif'
349 click : function (_self, e)
351 _this.searchBox.setValue('');
354 _this.grid.footer.onClick('first');
358 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
364 render : function (_self)
366 _this.officeCombo = _self;
368 select : function (combo, record, index)
371 _this.grid.footer.onClick('first');
375 displayField : 'office',
377 fieldLabel : 'Office',
378 hiddenName : 'office',
382 tpl : '<div class="x-grid-cell-text x-btn button"><b>{office}</b> </div>',
383 triggerAction : 'all',
384 valueField : 'office',
387 xtype: 'SimpleStore',
404 render : function (_self)
406 _this.country = _self;
408 select : function (combo, record, index)
410 _this.grid.footer.onClick('first');
415 displayField : 'addr_country',
417 emptyText : "Select Country",
418 fieldLabel : 'Country',
419 forceSelection : true,
420 hiddenName : 'addr_country',
422 loadingText : "Searching...",
424 name : 'addr_country',
426 qtip : "Select Country",
427 queryParam : 'query[addr_country]',
428 selectOnFocus : true,
429 tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_country}</b> </div>',
430 triggerAction : 'all',
432 valueField : 'addr_country',
438 beforeload : function (_self, o){
439 o.params = o.params || {};
440 o.params._distinct = 'addr_country';
441 o.params._columns ='addr_country';
445 sortInfo : { direction : 'ASC', field: 'addr_country' },
450 url : baseURL + '/Roo/Addr.php'
457 totalProperty : 'total',
458 fields : [{"name":"addr_id","type":"int"},{"name":"addr_country","type":"string"}]
466 toggle : function (_self, pressed)
468 _this.grid.footer.onClick('first');
470 render : function (_self)
472 _this.activeBtn = _self;
477 text : "Show / Hide Inactive"
482 text : "Has orders since"
488 render : function (_self)
490 _this.dateSearch = _self
492 select : function (combo, date)
494 _this.grid.footer.onClick('first');
496 specialkey : function (_self, e)
498 _this.grid.footer.onClick('first');
506 text : "No orders since"
512 render : function (_self)
514 _this.dateSearchNo = _self
516 select : function (combo, date)
518 _this.grid.footer.onClick('first');
520 specialkey : function (_self, e)
522 _this.grid.footer.onClick('first');
537 if (!_this.dialog) return;
538 _this.dialog.show( { id : 0 } , function() {
539 _this.grid.footer.onClick('first');
543 cls : 'x-btn-text-icon',
545 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
553 var s = _this.grid.getSelectionModel().getSelections();
554 if (!s.length || (s.length > 1)) {
555 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
558 if (!_this.dialog) return;
559 _this.dialog.show(s[0].data, function() {
560 _this.grid.footer.onClick('first');
565 cls : 'x-btn-text-icon',
567 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
573 xtype: 'ColumnModel',
575 dataIndex : 'cust_active',
578 renderer : function(v) { return String.format('{0}', v? 'Y' : 'N'); }
581 xtype: 'ColumnModel',
583 dataIndex : 'last_order',
584 header : 'Last Order',
586 renderer : function(v) {
590 var vv = Date.parseDate(v, 'Y-m-d');
591 return String.format('{0}', vv.format('d/M/Y') );
595 xtype: 'ColumnModel',
597 dataIndex : 'cust_taxzone_id_taxzone_descrip',
598 header : 'Tax Status',
601 renderer : function(v) { return String.format('{0}', v); }
604 xtype: 'ColumnModel',
606 dataIndex : 'cust_terms_id_terms_descrip',
610 renderer : function(v) { return String.format('{0}', v); }
613 xtype: 'ColumnModel',
615 dataIndex : 'cust_salesrep_id_salesrep_name',
616 header : 'Sales Rep',
619 renderer : function(v) { return String.format('{0}', v); }
622 xtype: 'ColumnModel',
624 dataIndex : 'ipshead_id_name',
625 header : 'Curr/Price List',
628 renderer : function(v,x,r) {
630 return String.format('{0}<br/><span style="color:red">No price list</span>',
631 r.data.cust_curr_id_curr_name );
634 return String.format('{0}<br/>{1}',
635 r.data.cust_curr_id_curr_name,
640 xtype: 'ColumnModel',
642 dataIndex : 'cust_number',
646 renderer : function(v) { return String.format('{0}', v); }
649 xtype: 'ColumnModel',
651 dataIndex : 'cust_name',
655 renderer : function(v,x,r) {
656 if (!r.data.cust_char_internalcompany.length) {
657 return String.format('{0}', v);
659 return String.format('<span style="color:red">[Internal company : {0}] {1}</span>',
660 r.data.cust_char_internalcompany, v);
664 xtype: 'ColumnModel',
666 dataIndex : 'cust_bill_info',
667 header : 'Billing Address',
670 renderer : function(v,x,r)
674 Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {
\r
675 if (!r.data['cntct_addr_' + k].length) {
\r
678 add.push(String.format("{0}", r.data['cntct_addr_' + k]));
\r
681 return add.join('<BR/>');
684 var v = v.split("\r\n").join("<br/>");
689 xtype: 'ColumnModel',
691 dataIndex : 'cust_ship_info',
692 header : 'Shipping Address',
695 renderer : function(v,x,r)
699 Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {
\r
700 if (!r.data['cntct_addr_' + k].length) {
\r
703 add.push(String.format("{0}", r.data['cntct_addr_' + k]));
\r
706 return add.join('<BR/>');
709 var v = v.split("\r\n").join("<br/>");
714 xtype: 'ColumnModel',
716 dataIndex : 'cust_cntct_id_cntct_first_name',
720 renderer : function(v,x,r)
722 return String.format(
725 'Email: <a href="mailto:{2}">{2}</a>',
727 r.data.cust_cntct_id_cntct_first_name,
728 r.data.cust_cntct_id_cntct_phone,
729 r.data.cust_cntct_id_cntct_email
734 xtype: 'ColumnModel',
736 dataIndex : 'cust_char_au_post_accno',
741 renderer : function(v,x,r)
743 return String.format('{0}', v);
747 xtype: 'ColumnModel',
749 dataIndex : 'cust_cntct_id_cntct_phone',
750 header : 'Contact Number',
754 renderer : function(v,x,r)
756 return String.format('{0}',v);
760 xtype: 'ColumnModel',
762 dataIndex : 'cust_cntct_id_cntct_email',
767 renderer : function(v,x,r)
769 return String.format('<a href="mailto:{0}">{0}</a>', v);
773 xtype: 'ColumnModel',
776 dataIndex : 'cntct_addr_city',
781 renderer : function(v) { return String.format('{0}', v ? v : ''); }
784 xtype: 'ColumnModel',
787 dataIndex : 'cntct_addr_state',
792 renderer : function(v) { return String.format('{0}', v ? v : ''); }
795 xtype: 'ColumnModel',
798 dataIndex : 'cntct_addr_country',
802 renderer : function(v) { return String.format('{0}', v ? v : ''); }
805 xtype: 'ColumnModel',
807 dataIndex : 'cust_curr_id_curr_name',
811 renderer : function(v) { return String.format('{0}', v); }
814 xtype: 'ColumnModel',
817 dataIndex : 'balance',
820 renderer : function(v,x,r) {
823 return String.format('{0}{1}', r.data.cust_curr_id_curr_symbol, Roo.util.Format.number(v,2));