1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleSalesHistory = new Roo.XComponent({
6 part : ["Xtuple","SalesHistory"],
7 order : '400-Pman.Tab.XtupleSalesHistory',
9 parent : 'Pman.Tab.XtupleSales',
10 name : "Pman.Tab.XtupleSalesHistory",
21 activate : function() {
24 _this.hgrid.footer.onClick('first');
33 title : "Sales History",
41 //_this.dialog = Pman.Dialog.FILL_IN
42 if (_this.hpanel.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), function() {
50 _this.grid.footer.onClick('first');
54 autoExpandColumn : 'item_descrip1',
60 beforeload : function (_self, o)
64 _group : 'salesHistory',
67 'credit:text' : 'credit',
68 'return:text' : 'return',
69 'includeFormatted:int' : 1,
70 'startDate:text' : _this.dateFrom.getValue(),
71 'endDate:text' : _this.dateTo.getValue()
75 if (_this.custSel.getValue()) {
76 o.params['cust_id:number'] = _this.custSel.getValue();
79 if (_this.countrySel.getValue()) {
80 o.params['addr_country:text'] = _this.countrySel.getValue();
83 if (_this.postalCodeSel.getValue()) {
84 o.params['addr_postalcode:text'] = _this.postalCodeSel.getValue();
87 if (_this.itemSel.getValue()) {
88 o.params['item_id:number'] = _this.itemSel.getValue();
91 if (_this.orderRep.getValue()) {
92 o.params['cohist_salesrep_id:number'] = _this.orderRep.getValue();
95 if (_this.custRep.getValue()) {
96 o.params['cust_salesrep_id:number'] = _this.custRep.getValue();
102 sortInfo : { field : 'cohist_shipvia', direction: 'ASC' },
107 url : baseURL + '/Roo/metasql.php'
112 totalProperty : 'total',
121 'name': 'cohist_cust_id',
125 'name': 'cohist_itemsite_id',
129 'name': 'cohist_shipdate',
131 'dateFormat': 'Y-m-d'
134 'name': 'cohist_shipvia',
138 'name': 'cohist_ordernumber',
142 'name': 'cohist_orderdate',
144 'dateFormat': 'Y-m-d'
147 'name': 'cohist_invcnumber',
151 'name': 'cohist_invcdate',
153 'dateFormat': 'Y-m-d'
156 'name': 'cohist_qtyshipped',
160 'name': 'cohist_unitprice',
164 'name': 'cohist_shipto_id',
168 'name': 'cohist_salesrep_id',
172 'name': 'cohist_duedate',
174 'dateFormat': 'Y-m-d'
177 'name': 'cohist_imported',
181 'name': 'cohist_billtoname',
185 'name': 'cohist_billtoaddress1',
189 'name': 'cohist_billtoaddress2',
193 'name': 'cohist_billtoaddress3',
197 'name': 'cohist_billtocity',
201 'name': 'cohist_billtostate',
205 'name': 'cohist_billtozip',
209 'name': 'cohist_shiptoname',
213 'name': 'cohist_shiptoaddress1',
217 'name': 'cohist_shiptoaddress2',
221 'name': 'cohist_shiptoaddress3',
225 'name': 'cohist_shiptocity',
229 'name': 'cohist_shiptostate',
233 'name': 'cohist_shiptozip',
237 'name': 'cohist_commission',
241 'name': 'cohist_commissionpaid',
245 'name': 'cohist_unitcost',
249 'name': 'cohist_misc_type',
253 'name': 'cohist_misc_descrip',
257 'name': 'cohist_misc_id',
261 'name': 'cohist_doctype',
265 'name': 'cohist_promisedate',
267 'dateFormat': 'Y-m-d'
270 'name': 'cohist_ponumber',
274 'name': 'cohist_curr_id',
278 'name': 'cohist_sequence',
282 'name': 'cohist_taxtype_id',
286 'name': 'cohist_taxzone_id',
290 'name': 'cohist_curr_id_curr_id',
294 'name': 'cohist_curr_id_curr_base',
298 'name': 'cohist_curr_id_curr_name',
302 'name': 'cohist_curr_id_curr_symbol',
306 'name': 'cohist_curr_id_curr_abbr',
310 'name': 'cohist_taxzone_id_taxzone_id',
314 'name': 'cohist_taxzone_id_taxzone_code',
318 'name': 'cohist_taxzone_id_taxzone_descrip',
322 'name': 'cohist_taxtype_id_taxtype_id',
326 'name': 'cohist_taxtype_id_taxtype_name',
330 'name': 'cohist_taxtype_id_taxtype_descrip',
334 'name': 'cohist_taxtype_id_taxtype_sys',
341 xtype: 'PagingToolbar',
344 displayMsg : "Displaying Sales History {0} - {1} of {2}",
345 emptyMsg : "No cohist found",
351 text : "<span class=\"sales-footer-text\"></span>"
363 render : function (_self)
365 _this.custSel = _self;
369 displayField : 'cust_name',
371 emptyText : "Select Customer",
372 fieldLabel : 'cust_name',
373 forceSelection : true,
374 hiddenName : 'cust_id',
376 loadingText : "Searching...",
380 qtip : "Select Customer",
381 queryParam : 'query[cust_name]',
382 selectOnFocus : true,
383 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
384 triggerAction : 'all',
386 valueField : 'cust_id',
392 beforeload : function (_self, o){
393 o.params = o.params || {};
398 sortInfo : { direction : 'ASC', field: 'cust_name' },
403 url : baseURL + '/Roo/custinfo.php'
410 totalProperty : 'total',
411 fields : [{"name":"cust_id","type":"int"},"cust_name"]
419 render : function (_self)
421 _this.countrySel = _self;
425 displayField : 'addr_country',
427 emptyText : "Select Country",
428 fieldLabel : 'addr_country',
429 forceSelection : true,
430 hiddenName : 'addr_country',
432 loadingText : "Searching...",
434 name : 'addr_country',
436 qtip : "Select Country",
437 queryParam : 'query[addr_country]',
438 selectOnFocus : true,
439 tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_country}</b> </div>',
440 triggerAction : 'all',
442 valueField : 'addr_country',
448 beforeload : function (_self, o){
449 o.params = o.params || {};
450 o.params._distinct = 'addr_country';
451 o.params._columns = 'addr_country';
452 o.params['!addr_country'] = '';
457 sortInfo : { direction : 'ASC', field: 'addr_country' },
462 url : baseURL + '/Roo/addr.php'
469 totalProperty : 'total',
470 fields : [{"name":"addr_country","type":"string"}]
478 render : function (_self)
480 _this.postalCodeSel = _self;
484 displayField : 'addr_postalcode',
486 emptyText : "Select Postal Code",
487 fieldLabel : 'addr_postalcode',
488 forceSelection : true,
489 hiddenName : 'addr_postalcode',
491 loadingText : "Searching...",
493 name : 'addr_postalcode',
495 qtip : "Select Postal Code",
496 queryParam : 'query[addr_postalcode]',
497 selectOnFocus : true,
498 tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_postalcode}</b> </div>',
499 triggerAction : 'all',
501 valueField : 'addr_postalcode',
507 beforeload : function (_self, o){
508 o.params = o.params || {};
509 o.params._distinct = 'addr_postalcode';
510 o.params._columns = 'addr_postalcode';
511 o.params['!addr_postalcode'] = '';
516 sortInfo : { direction : 'ASC', field: 'addr_postalcode' },
521 url : baseURL + '/Roo/addr.php'
526 id : 'addr_postalcode',
528 totalProperty : 'total',
529 fields : [{"name":"addr_postalcode","type":"string"}]
537 render : function (_self)
539 _this.itemSel = _self;
543 displayField : 'item_number',
545 emptyText : "Select Item Number",
546 fieldLabel : 'item_number',
547 forceSelection : true,
548 hiddenName : 'item_number',
550 loadingText : "Searching...",
552 name : 'item_number',
554 qtip : "Select Item Number",
555 queryParam : 'query[number_or_name]',
556 selectOnFocus : true,
557 tpl : '<div class="x-grid-cell-text x-btn button"><b>{item_number}</b> </div>',
558 triggerAction : 'all',
560 valueField : 'item_id',
566 beforeload : function (_self, o){
567 o.params = o.params || {};
572 sortInfo : { direction : 'ASC', field: 'item_number' },
577 url : baseURL + '/Roo/Item.php'
584 totalProperty : 'total',
585 fields : [{"name":"item_id","type":"int"},"item_number"]
593 render : function (_self)
595 _this.orderRep = _self;
599 displayField : 'salesrep_name',
601 emptyText : "Order Sales Rep",
602 fieldLabel : 'Order Sales Rep',
603 forceSelection : true,
604 hiddenName : 'salesrep_name',
606 loadingText : "Searching...",
608 name : 'salesrep_name',
610 qtip : "Select Order Sales Rep",
611 queryParam : 'query[name]',
612 selectOnFocus : true,
613 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
614 triggerAction : 'all',
616 valueField : 'salesrep_id',
622 beforeload : function (_self, o){
623 o.params = o.params || {};
624 o.params.salesrep_active = 1
628 sortInfo : { direction : 'ASC', field: 'salesrep_id' },
633 url : baseURL + '/Roo/Salesrep.php'
640 totalProperty : 'total',
641 fields : [{"name":"salesrep_id","type":"int"}]
649 render : function (_self)
651 _this.custRep = _self;
655 displayField : 'salesrep_name',
657 emptyText : "Customer Sales Rep",
658 fieldLabel : 'Customer Sales Rep',
659 forceSelection : true,
660 hiddenName : 'salesrep_name',
662 loadingText : "Searching...",
664 name : 'salesrep_name',
666 qtip : "Select Customer Sales Rep",
667 queryParam : 'query[name]',
668 selectOnFocus : true,
669 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
670 triggerAction : 'all',
672 valueField : 'salesrep_id',
678 beforeload : function (_self, o){
679 o.params = o.params || {};
680 o.params.salesrep_active = 1
684 sortInfo : { direction : 'ASC', field: 'salesrep_id' },
689 url : baseURL + '/Roo/Salesrep.php'
696 totalProperty : 'total',
697 fields : [{"name":"salesrep_id","type":"int"}]
710 render : function (_self)
712 _this.dateFrom = _self;
717 value : (function() {return (new Date()).add(Date.MONTH, -3); })()
728 render : function (_self)
730 _this.dateTo = _self;
735 value : (function() {return (new Date()) })()
741 click : function (_self, e)
743 _this.hgrid.footer.onClick('first');
764 click : function (_self, e)
766 var o = { params : {}};
767 Roo.apply(o.params, {
768 _group : 'salesHistory',
770 csvCols : '*', csvTitles : '*',
771 'credit:text' : 'credit',
772 'return:text' : 'return',
773 'includeFormatted:int' : 1,
774 'startDate:text' : _this.dateFrom.getValue(),
775 'endDate:text' : _this.dateTo.getValue(),
780 if (_this.custSel.getValue()) {
781 o.params['cust_id:number'] = _this.custSel.getValue();
784 if (_this.countrySel.getValue()) {
785 o.params['addr_country:text'] = _this.countrySel.getValue();
788 if (_this.postalCodeSel.getValue()) {
789 o.params['addr_postalcode:text'] = _this.postalCodeSel.getValue();
792 if (_this.itemSel.getValue()) {
793 o.params['item_id:number'] = _this.itemSel.getValue();
796 if (_this.orderRep.getValue()) {
797 o.params['cohist_salesrep_id:number'] = _this.orderRep.getValue();
800 if (_this.custRep.getValue()) {
801 o.params['cust_salesrep_id:number'] = _this.custRep.getValue();
806 url: baseURL + '/Roo/Metasql',
813 text : "Sales History"
819 click : function (_self, e)
821 var o = { params : {}};
822 Roo.apply(o.params, {
823 _group : 'salesHistory',
825 csvCols : '*', csvTitles : '*',
826 'credit:text' : 'credit',
827 'return:text' : 'return',
828 'includeFormatted:int' : 1,
829 'startDate:text' : _this.dateFrom.getValue(),
830 'endDate:text' : _this.dateTo.getValue(),
835 if (_this.custSel.getValue()) {
836 o.params['cust_id:number'] = _this.custSel.getValue();
839 if (_this.countrySel.getValue()) {
840 o.params['addr_country:text'] = _this.countrySel.getValue();
843 if (_this.postalCodeSel.getValue()) {
844 o.params['addr_postalcode:text'] = _this.postalCodeSel.getValue();
847 if (_this.itemSel.getValue()) {
848 o.params['item_id:number'] = _this.itemSel.getValue();
851 if (_this.orderRep.getValue()) {
852 o.params['cohist_salesrep_id:number'] = _this.orderRep.getValue();
855 if (_this.custRep.getValue()) {
856 o.params['cust_salesrep_id:number'] = _this.custRep.getValue();
861 url: baseURL + '/Roo/Metasql',
868 text : "Stockists Summary"
877 xtype: 'ColumnModel',
879 dataIndex : 'cust_id',
882 renderer : function(v) { return String.format('{0}', v); }
885 xtype: 'ColumnModel',
887 dataIndex : 'cust_name',
890 renderer : function(v) { return String.format('{0}', v); }
893 xtype: 'ColumnModel',
895 dataIndex : 'order_salesrep_name',
896 header : 'Order Sales Rep',
898 renderer : function(v) { return String.format('{0}', v); }
901 xtype: 'ColumnModel',
903 dataIndex : 'cust_salesrep_name',
904 header : 'Customer Sales Rep',
907 renderer : function(v) { return String.format('{0}', v); }
910 xtype: 'ColumnModel',
912 dataIndex : 'addr_country',
915 renderer : function(v) { return String.format('{0}', v); }
918 xtype: 'ColumnModel',
920 dataIndex : 'addr_city',
924 renderer : function(v) { return String.format('{0}', v); }
927 xtype: 'ColumnModel',
929 dataIndex : 'addr_state',
933 renderer : function(v) { return String.format('{0}', v); }
936 xtype: 'ColumnModel',
938 dataIndex : 'addr_postalcode',
939 header : 'Postal Code',
941 renderer : function(v) { return String.format('{0}', v); }
944 xtype: 'ColumnModel',
946 dataIndex : 'cohist_ordernumber',
949 renderer : function(v) { return String.format('{0}', v); }
952 xtype: 'ColumnModel',
954 dataIndex : 'cohead_orderdate',
955 header : 'Order date',
957 renderer : function(v) {
958 var d = Date.parseDate(v, 'Y-m-d');
959 return String.format('{0}', d ? d.format('d/M/Y') : '');
963 xtype: 'ColumnModel',
965 dataIndex : 'invmonth',
966 header : 'Invoice Month',
968 renderer : function(v) {
970 return String.format('{0}', v);
974 xtype: 'ColumnModel',
976 dataIndex : 'cohist_invcdate',
977 header : 'Invoice date',
979 renderer : function(v) {
980 var d = Date.parseDate(v, 'Y-m-d');
981 return String.format('{0}', d ? d.format('d/M/Y') : '');
985 xtype: 'ColumnModel',
987 dataIndex : 'cohist_invcnumber',
990 renderer : function(v) { return String.format('{0}', v); }
993 xtype: 'ColumnModel',
995 dataIndex : 'item_brand',
998 renderer : function(v) { return String.format('{0}', v ? v : ''); }
1001 xtype: 'ColumnModel',
1003 dataIndex : 'item_number',
1004 header : 'Item No.',
1006 renderer : function(v) { return String.format('{0}', v ? v : ''); }
1009 xtype: 'ColumnModel',
1011 dataIndex : 'item_descrip1',
1012 header : 'Description',
1014 renderer : function(v) { return String.format('{0}', v); }
1017 xtype: 'ColumnModel',
1020 dataIndex : 'cohist_qtyshipped',
1023 renderer : function(v) { return parseInt(v); }
1026 xtype: 'ColumnModel',
1028 dataIndex : 'currabbr',
1029 header : 'Currency',
1031 renderer : function(v) { return String.format('{0}', v.split(/\s+/)[0]); }
1034 xtype: 'ColumnModel',
1037 dataIndex : 'cohist_unitprice',
1038 header : 'Unit Price',
1040 renderer : function(v) { return Roo.util.Format.number( v, 2); }
1043 xtype: 'ColumnModel',
1046 dataIndex : 'extprice',
1047 header : 'Ext Cost',
1049 renderer : function(v) { return Roo.util.Format.number( v, 2); }
1052 xtype: 'ColumnModel',
1055 dataIndex : 'extpricebase',
1056 header : 'Ext Price (Base)',
1058 renderer : function(v) { return Roo.util.Format.number( v, 2); }
1061 xtype: 'ColumnModel',
1064 dataIndex : 'baseunitprice',
1065 header : 'Unit Price (Base)',
1068 renderer : function(v) { return Roo.util.Format.number( v, 2); }
1071 xtype: 'ColumnModel',
1074 dataIndex : 'basefifovalue',
1075 header : 'Fifo Cost',
1077 renderer : function(v) { return Roo.util.Format.number( v, 2); }