1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleSalesOrder = new Roo.XComponent({
6 part : ["Xtuple","SalesOrder"],
7 order : '001-Pman.Tab.XtupleSalesOrder',
9 parent : 'Pman.Tab.XtupleSales',
10 name : "unnamed module",
18 xtype: 'NestedLayoutPanel',
21 activate : function (_self)
23 this.setTitle('Sales Orders (' + Pman.Login.authUser.dbname +')');
27 title : "Sales Orders",
29 xtype: 'BorderLayout',
36 activate : function() {
39 _this.grid.footer.onClick('first');
57 _this.dialog = Pman.Dialog.XtupleSalesOrder;
59 if (_this.panel.active) {
60 this.footer.onClick('first');
63 rowdblclick : function (_self, rowIndex, e)
65 if (!_this.dialog) return;
66 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
67 _this.grid.footer.onClick('refresh');
68 Pman.Tab.XtupleSales.grid.footer.onClick('first');
72 autoExpandColumn : 'cohead_cust_id_cust_name',
78 beforeload : function (_self, options)
82 vl = _this.form.getFieldValues();
90 if (!(new String(vl[x])).length) {
93 options.params[x] = vl[x];
97 if (options.params['query[cohead_number]'].length) {
98 options.params.viewtype = 'REALALL';
104 sortInfo : { field : 'cohead_orderdate', direction: 'DESC' },
110 url : baseURL + '/Roo/cohead.php'
115 totalProperty : 'total',
120 'name': 'cohead_number',
124 'name': 'cohead_cust_id_cust_name',
128 'name': 'cohead_custponumber',
132 'name': 'cohead_type'
135 'name': 'cohead_orderdate',
139 'name': 'cohead_shipto_id_shipto_name',
143 'name': 'cohead_terms_id_terms_descrip',
147 'name': 'cohead_curr_id_curr_name',
154 xtype: 'PagingToolbar',
158 displayMsg : "Displaying cohead{0} - {1} of {2}",
159 emptyMsg : "No cohead found",
173 cls : 'x-btn-text-icon',
174 text : "Download Results",
175 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
187 click : function (_self, e)
189 Pman.Dialog.XtupleInvHistory.show({
195 text : "Quick Stock Check"
209 click : function (_self, e)
211 Pman.Dialog.Image.show(
213 _url : baseURL+'/Xtuple/Import/Magento',
218 Roo.MessageBox.alert("Notice", data);
219 _this.grid.footer.onClick('first');
225 text : "Magento Upload"
231 click : function (_self, e)
233 Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {
234 Pman.Dialog.Image.show({
236 _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)
238 Roo.MessageBox.alert('Success', data);
239 _this.grid.footer.onClick('first');
244 text : "Import HSBC csv file"
252 cls : 'x-btn-text-icon',
254 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
271 click : function (_self, e)
273 var from = _this.form.findField('_fromdate').getValue();
274 var to = _this.form.findField('_todate').getValue();
277 Roo.Msg.alert('Error', 'Please select a date range for the report');
283 filename : 'ARAging-' + to.format('Y-m-d'),
284 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
285 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
286 'param[2]': "useDocDate:number=1"
288 var cust_id = _this.form.findField('cohead_cust_id').getValue();
289 if (cust_id * 1 > 0) {
290 params['param[3]'] = 'cust_id:number=' + cust_id;
294 url : baseURL + '/Xtuple/Print',
298 Roo.MessageBox.alert("Notice", "Report will download shortly");
307 click : function (_self, e)
309 var from = _this.form.findField('_fromdate').getValue();
310 var to = _this.form.findField('_todate').getValue();
315 '_group' : 'arAging',
319 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
320 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
324 'useDocDate:text' : 'TRUE',
330 var cust_id = _this.form.findField('cohead_cust_id').getValue();
331 if (cust_id * 1 > 0) {
332 params['cust_id:number'] = cust_id;
335 new Pman.Download({
\r
336 url : baseURL + '/Roo/Metasql',
\r
340 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
350 click : function (_self, e)
352 var from = _this.form.findField('_fromdate').getValue();
353 var to = _this.form.findField('_todate').getValue();
358 '_group' : 'arAging',
364 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
365 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
368 'useDocDate:text' : 'TRUE',
373 var cust_id = _this.form.findField('cohead_cust_id').getValue();
374 if (cust_id * 1 > 0) {
375 params['cust_id:number'] = cust_id;
378 new Pman.Download({
\r
379 url : baseURL + '/Roo/Metasql',
\r
383 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
387 text : "Summary Excel"
395 text : "Customer History",
404 click : function (_self, e)
406 var cust_id = _this.form.findField('cohead_cust_id').getValue();
407 if (cust_id * 1 < 1) {
408 Roo.Msg.alert('Error', 'Please select a customer');
412 var from = _this.form.findField('_fromdate').getValue();
413 var to = _this.form.findField('_todate').getValue();
416 Roo.Msg.alert('Error', 'Please select a date range for the report');
421 template: 'customer_ar_history',
422 filename : 'customer_ar_history-' + to.format('Y-m-d'),
423 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
424 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
425 'param[2]': "cust_id:number=" + cust_id
429 url : baseURL + '/Xtuple/Print',
433 Roo.MessageBox.alert("Notice", "Report will download shortly");
442 click : function (_self, e)
444 var cust_id = _this.form.findField('cohead_cust_id').getValue();
445 if (cust_id * 1 < 1) {
446 Roo.Msg.alert('Error', 'Please select a customer');
450 var from = _this.form.findField('_fromdate').getValue();
451 var to = _this.form.findField('_todate').getValue();
456 '_group' : 'customerHistory',
460 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
461 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
463 'cust_id:number' : cust_id,
469 new Pman.Download({
\r
470 url : baseURL + '/Roo/Metasql',
\r
474 Roo.MessageBox.alert("Notice", "Report will download shortly");
485 text : "Customer Statement",
494 click : function (_self, e)
496 var cust_id = _this.form.findField('cohead_cust_id').getValue();
497 if (cust_id * 1 < 1) {
498 Roo.Msg.alert('Error', 'Please select a customer');
502 var from = _this.form.findField('_fromdate').getValue();
503 var to = _this.form.findField('_todate').getValue();
508 template: 'customer_ar_statement',
509 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
510 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
511 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
512 'param[2]': "cust_id:number=" + cust_id
516 url : baseURL + '/Xtuple/Print',
520 Roo.MessageBox.alert("Notice", "Report will download shortly");
529 click : function (_self, e)
531 var cust_id = _this.form.findField('cohead_cust_id').getValue();
532 if (cust_id * 1 < 1) {
533 Roo.Msg.alert('Error', 'Please select a customer');
537 var from = _this.form.findField('_fromdate').getValue();
538 var to = _this.form.findField('_todate').getValue();
541 // Roo.Msg.alert('Error', 'Please select a date range for the report');
546 '_group' : 'customerStatement',
549 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
550 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
551 'cust_id:number' : cust_id,
557 new Pman.Download({
\r
558 url : baseURL + '/Roo/Metasql',
\r
562 Roo.MessageBox.alert("Notice", "Report will download shortly");
577 click : function (_self, e)
579 var sels = _this.grid.getSelectionModel().getSelections();
582 Roo.MessageBox.alert("Error", "Select an order");
586 for (var i =0; i < sels.length; i++) {
589 if(s.data.cohead_qtyuninvoiced * 1 > 0){
590 Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
594 if(s.data.aropen_unpaid * 1 > 0){
595 Roo.MessageBox.alert("Error", "Order has not been paid! - " + s.data.cohead_number);
598 ids.push(s.data.cohead_id);
601 new Pman.Download({
\r
602 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
604 cohead_id : ids.join(',')
609 Roo.MessageBox.alert("Notice", "Report will download shortly");
612 cls : 'x-btn-text-icon',
613 text : "Email to warehouse",
614 icon : Roo.rootURL + 'images/default/dd/email.gif'
622 var s = _this.grid.getSelectionModel().getSelected();
624 Roo.MessageBox.alert("Error", "Select an order to close");
628 if(s.data.cohead_status == 'C'){
629 Roo.MessageBox.alert("Error", "This order has been closed");
634 url: baseURL + '/Roo/cohead',
637 cohead_id : s.data.cohead_id,
643 Roo.MessageBox.alert("Notice", "DONE");
644 _this.grid.footer.onClick('first');
650 cls : 'x-btn-text-icon',
651 text : "Complete and Close",
652 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
662 url: baseURL + '/Roo/cohead',
665 cohead_id : s.data.cohead_id,
671 Roo.MessageBox.alert("Notice", "DONE");
672 _this.grid.footer.onClick('first');
678 cls : 'x-btn-text-icon',
679 text : "Clear Unpaid Orders",
680 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
692 // check if the login in user have more than 25 open orders..
693 // if yes, warning...
695 url : baseURL + '/Roo/cohead.php',
699 _count_order : 1 // make the search faster!
701 success : function(res) {
702 if(res.data[0].order_totals * 1 > 25){
703 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
708 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
709 _this.grid.footer.onClick('first');
713 cls : 'x-btn-text-icon',
715 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
723 var s = _this.grid.getSelectionModel().getSelected();
725 Roo.MessageBox.alert("Error", "Select an order to copy");
730 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
732 // get the id from the data, then
734 _this.grid.footer.onClick('first');
735 Pman.Tab.XtupleSales.grid.footer.onClick('first');
736 // get the id from the data, then start editing it..
738 _this.dialog.show(data, function() {
739 _this.grid.footer.onClick('refresh');
740 Pman.Tab.XtupleSales.grid.footer.onClick('first');
746 cls : 'x-btn-text-icon',
748 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
754 xtype: 'ColumnModel',
756 dataIndex : 'cohead_orderdate',
760 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
763 xtype: 'ColumnModel',
765 dataIndex : 'cohead_targetdate',
766 header : 'Target Delivery',
770 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
773 xtype: 'ColumnModel',
775 dataIndex : 'cohead_salesrep_id_salesrep_name',
776 header : 'Staff IC.',
779 renderer : function(v,x,r) {
781 if (r.data.cohead_display_salesrep_id) {
782 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
784 return String.format('{0}', v );
790 xtype: 'ColumnModel',
792 dataIndex : 'cohead_number',
796 renderer : function(v,x,r) {
799 // we want to show more detail about status..
800 // like payment status / delivery etc...
804 // S = shipped (or partial shipped)
805 // P = paid (or partial paid)
806 // online payment failed? >> on terms?
809 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
810 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
811 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
812 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
813 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
814 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
815 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
822 if (r.data.cohead_qtyunshipped > 0) {
824 tg += (r.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
827 tg += tags.stock_shipped;
830 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
831 // ?? partially invoiced??
834 if (r.data.cohead_qtyuninvoiced*1 < 1) {
835 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
842 if (r.data.cohead_status == 'C') {
843 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
845 if (r.data.cohead_status == 'X') {
846 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
848 return tg + ' ' + String.format('{0}', v);
852 xtype: 'ColumnModel',
854 dataIndex : 'cohead_cust_id_cust_number',
855 header : 'Customer#',
858 renderer : function(v) { return String.format('{0}', v); }
861 xtype: 'ColumnModel',
863 dataIndex : 'cohead_cust_id_cust_name',
867 renderer : function(v) { return String.format('{0}', v); }
870 xtype: 'ColumnModel',
872 dataIndex : 'cohead_custponumber',
873 header : 'Cust. PO#',
875 renderer : function(v) { return String.format('{0}', v); }
878 xtype: 'ColumnModel',
880 dataIndex : 'cohead_type',
883 renderer : function(v) { return String.format('{0}', v); }
886 xtype: 'ColumnModel',
888 dataIndex : 'cohead_src_locations',
891 renderer : function(v) { return String.format('{0}', v); }
894 xtype: 'ColumnModel',
896 dataIndex : 'cohead_shiptoaddress1',
899 renderer : function(v) { return String.format('{0}', v); }
902 xtype: 'ColumnModel',
904 dataIndex : 'cohead_terms_id_terms_descrip',
907 renderer : function(v) { return String.format('{0}', v); }
910 xtype: 'ColumnModel',
913 dataIndex : 'cohead_total',
916 renderer : function(v,x,r) {
917 var ret = String.format('{0} {1}',
918 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
921 if (parseInt(r.data.cohead_qtyordered) != 0 &&
922 parseInt(r.data.cohead_unshipped) == 0 &&
923 parseInt(r.data.cohead_qtyunshipped) == 0 &&
924 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
925 parseInt(r.data.cohead_unshipped) == 0 &&
926 parseInt(r.data.cohead_uninvoiced) == 0
931 return String.format('<b style="color:red" ' +
932 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
934 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
935 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
944 xtype: 'ContentPanel',
953 rendered : function (form)
960 style : 'margin:5px;',
966 select : function (combo, record, index)
968 _this.grid.footer.onClick('first');
970 render : function (_self)
972 _this.viewtypeSel = _self;
976 displayField : 'value',
978 emptyText : "View type",
980 forceSelection : true,
982 loadingText : "Searching...",
986 qtip : "Select Action",
987 queryParam : 'query[action]',
988 selectOnFocus : true,
989 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
990 triggerAction : 'all',
996 xtype: 'SimpleStore',
1000 [ 'MYOPEN', 'My Open orders' ],
1001 [ 'MYCLOSED', 'My Closed orders' ],
1002 [ 'MYALL', 'My orders (all)' ],
1003 [ 'MYVOID', 'My Voided orders' ],
1004 [ 'OPEN', 'All Open orders' ],
1005 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
1006 [ 'NOTPAID', 'All Un-paid orders' ],
1007 [ 'CLOSED', 'All Closed orders' ],
1008 [ 'ALL', 'All orders' ],
1009 [ 'VOID', 'Voided orders' ],
1010 [ 'INCOMPLETE', 'Incomplete orders' ],
1011 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
1012 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
1013 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
1014 [ 'FIFOBUG', 'Problems with FIFO' ]
1017 fields : [ 'key', 'value' ]
1024 select : function (combo, record, index)
1026 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1028 specialkey : function (_self, e)
1030 //Roo.log(e.getKey());
1031 if (e.getKey() == 13) {
1032 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1034 _this.rsearch = true;
1038 beforequery : function (combo, query, forceAll, cancel, e)
1041 if( _this.rsearch) {
1042 _this.rsearch =false;
1049 displayField : 'cohead_number',
1051 emptyText : "Select Order",
1052 fieldLabel : 'Order #',
1053 forceSelection : false,
1055 loadingText : "Searching...",
1057 name : 'query[cohead_number]',
1059 qtip : "Select Order",
1060 queryParam : 'query[cohead_number]',
1061 selectOnFocus : true,
1062 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1063 triggerAction : 'all',
1065 valueField : 'cohead_number',
1071 beforeload : function (_self, o){
1072 o.params = o.params || {};
1073 o.params['_columns'] = 'cohead_number';
1078 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1083 url : baseURL + '/Roo/cohead.php'
1086 xtype: 'JsonReader',
1088 id : 'cohead_number',
1090 totalProperty : 'total',
1091 fields : ["cohead_number"]
1099 select : function (combo, record, index)
1101 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1105 displayField : 'cust_name',
1107 emptyText : "Select custinfo",
1108 fieldLabel : 'Customer',
1109 forceSelection : true,
1110 hiddenName : 'cohead_cust_id',
1112 loadingText : "Searching...",
1114 name : 'cohead_cust_id_cust_name',
1116 qtip : "Select custinfo",
1117 queryParam : 'query[cust_name]',
1118 selectOnFocus : true,
1119 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1120 triggerAction : 'all',
1122 valueField : 'cust_id',
1127 sortInfo : { direction : 'ASC', field: 'cust_name' },
1130 beforeload : function (_self, o){
1131 o.params = o.params || {};
1139 url : baseURL + '/Roo/custinfo.php'
1142 xtype: 'JsonReader',
1146 totalProperty : 'total',
1147 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1155 select : function (combo, date)
1157 _this.grid.footer.onClick('first');
1160 fieldLabel : 'From',
1169 select : function (combo, date)
1171 _this.grid.footer.onClick('first');
1194 click : function (_self, e)
1196 _this.grid.footer.onClick('first');
1200 icon : rootURL + '/Pman/templates/images/search.gif'
1206 click : function (_self, e)
1208 _this.form.reset('');
1211 _this.grid.footer.onClick('first');
1215 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1222 xtype: 'LayoutRegion',
1229 xtype: 'LayoutRegion',