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',
670 Roo.MessageBox.alert("Notice", "DONE");
671 _this.grid.footer.onClick('first');
677 cls : 'x-btn-text-icon',
678 text : "Clear Unpaid Orders",
679 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
691 // check if the login in user have more than 25 open orders..
692 // if yes, warning...
694 url : baseURL + '/Roo/cohead.php',
698 _count_order : 1 // make the search faster!
700 success : function(res) {
701 if(res.data[0].order_totals * 1 > 25){
702 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
707 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
708 _this.grid.footer.onClick('first');
712 cls : 'x-btn-text-icon',
714 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
722 var s = _this.grid.getSelectionModel().getSelected();
724 Roo.MessageBox.alert("Error", "Select an order to copy");
729 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
731 // get the id from the data, then
733 _this.grid.footer.onClick('first');
734 Pman.Tab.XtupleSales.grid.footer.onClick('first');
735 // get the id from the data, then start editing it..
737 _this.dialog.show(data, function() {
738 _this.grid.footer.onClick('refresh');
739 Pman.Tab.XtupleSales.grid.footer.onClick('first');
745 cls : 'x-btn-text-icon',
747 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
753 xtype: 'ColumnModel',
755 dataIndex : 'cohead_orderdate',
759 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
762 xtype: 'ColumnModel',
764 dataIndex : 'cohead_targetdate',
765 header : 'Target Delivery',
769 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
772 xtype: 'ColumnModel',
774 dataIndex : 'cohead_salesrep_id_salesrep_name',
775 header : 'Staff IC.',
778 renderer : function(v,x,r) {
780 if (r.data.cohead_display_salesrep_id) {
781 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
783 return String.format('{0}', v );
789 xtype: 'ColumnModel',
791 dataIndex : 'cohead_number',
795 renderer : function(v,x,r) {
798 // we want to show more detail about status..
799 // like payment status / delivery etc...
803 // S = shipped (or partial shipped)
804 // P = paid (or partial paid)
805 // online payment failed? >> on terms?
808 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
809 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
810 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
811 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
812 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
813 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
814 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
821 if (r.data.cohead_qtyunshipped > 0) {
823 tg += (r.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
826 tg += tags.stock_shipped;
829 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
830 // ?? partially invoiced??
833 if (r.data.cohead_qtyuninvoiced*1 < 1) {
834 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
841 if (r.data.cohead_status == 'C') {
842 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
844 if (r.data.cohead_status == 'X') {
845 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
847 return tg + ' ' + String.format('{0}', v);
851 xtype: 'ColumnModel',
853 dataIndex : 'cohead_cust_id_cust_number',
854 header : 'Customer#',
857 renderer : function(v) { return String.format('{0}', v); }
860 xtype: 'ColumnModel',
862 dataIndex : 'cohead_cust_id_cust_name',
866 renderer : function(v) { return String.format('{0}', v); }
869 xtype: 'ColumnModel',
871 dataIndex : 'cohead_custponumber',
872 header : 'Cust. PO#',
874 renderer : function(v) { return String.format('{0}', v); }
877 xtype: 'ColumnModel',
879 dataIndex : 'cohead_type',
882 renderer : function(v) { return String.format('{0}', v); }
885 xtype: 'ColumnModel',
887 dataIndex : 'cohead_src_locations',
890 renderer : function(v) { return String.format('{0}', v); }
893 xtype: 'ColumnModel',
895 dataIndex : 'cohead_shiptoaddress1',
898 renderer : function(v) { return String.format('{0}', v); }
901 xtype: 'ColumnModel',
903 dataIndex : 'cohead_terms_id_terms_descrip',
906 renderer : function(v) { return String.format('{0}', v); }
909 xtype: 'ColumnModel',
912 dataIndex : 'cohead_total',
915 renderer : function(v,x,r) {
916 var ret = String.format('{0} {1}',
917 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
920 if (parseInt(r.data.cohead_qtyordered) != 0 &&
921 parseInt(r.data.cohead_unshipped) == 0 &&
922 parseInt(r.data.cohead_qtyunshipped) == 0 &&
923 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
924 parseInt(r.data.cohead_unshipped) == 0 &&
925 parseInt(r.data.cohead_uninvoiced) == 0
930 return String.format('<b style="color:red" ' +
931 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
933 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
934 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
943 xtype: 'ContentPanel',
952 rendered : function (form)
959 style : 'margin:5px;',
965 select : function (combo, record, index)
967 _this.grid.footer.onClick('first');
969 render : function (_self)
971 _this.viewtypeSel = _self;
975 displayField : 'value',
977 emptyText : "View type",
979 forceSelection : true,
981 loadingText : "Searching...",
985 qtip : "Select Action",
986 queryParam : 'query[action]',
987 selectOnFocus : true,
988 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
989 triggerAction : 'all',
995 xtype: 'SimpleStore',
999 [ 'MYOPEN', 'My Open orders' ],
1000 [ 'MYCLOSED', 'My Closed orders' ],
1001 [ 'MYALL', 'My orders (all)' ],
1002 [ 'MYVOID', 'My Voided orders' ],
1003 [ 'OPEN', 'All Open orders' ],
1004 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
1005 [ 'NOTPAID', 'All Un-paid orders' ],
1006 [ 'CLOSED', 'All Closed orders' ],
1007 [ 'ALL', 'All orders' ],
1008 [ 'VOID', 'Voided orders' ],
1009 [ 'INCOMPLETE', 'Incomplete orders' ],
1010 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
1011 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
1012 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
1013 [ 'FIFOBUG', 'Problems with FIFO' ]
1016 fields : [ 'key', 'value' ]
1023 select : function (combo, record, index)
1025 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1027 specialkey : function (_self, e)
1029 //Roo.log(e.getKey());
1030 if (e.getKey() == 13) {
1031 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1033 _this.rsearch = true;
1037 beforequery : function (combo, query, forceAll, cancel, e)
1040 if( _this.rsearch) {
1041 _this.rsearch =false;
1048 displayField : 'cohead_number',
1050 emptyText : "Select Order",
1051 fieldLabel : 'Order #',
1052 forceSelection : false,
1054 loadingText : "Searching...",
1056 name : 'query[cohead_number]',
1058 qtip : "Select Order",
1059 queryParam : 'query[cohead_number]',
1060 selectOnFocus : true,
1061 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1062 triggerAction : 'all',
1064 valueField : 'cohead_number',
1070 beforeload : function (_self, o){
1071 o.params = o.params || {};
1072 o.params['_columns'] = 'cohead_number';
1077 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1082 url : baseURL + '/Roo/cohead.php'
1085 xtype: 'JsonReader',
1087 id : 'cohead_number',
1089 totalProperty : 'total',
1090 fields : ["cohead_number"]
1098 select : function (combo, record, index)
1100 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1104 displayField : 'cust_name',
1106 emptyText : "Select custinfo",
1107 fieldLabel : 'Customer',
1108 forceSelection : true,
1109 hiddenName : 'cohead_cust_id',
1111 loadingText : "Searching...",
1113 name : 'cohead_cust_id_cust_name',
1115 qtip : "Select custinfo",
1116 queryParam : 'query[cust_name]',
1117 selectOnFocus : true,
1118 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1119 triggerAction : 'all',
1121 valueField : 'cust_id',
1126 sortInfo : { direction : 'ASC', field: 'cust_name' },
1129 beforeload : function (_self, o){
1130 o.params = o.params || {};
1138 url : baseURL + '/Roo/custinfo.php'
1141 xtype: 'JsonReader',
1145 totalProperty : 'total',
1146 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1154 select : function (combo, date)
1156 _this.grid.footer.onClick('first');
1159 fieldLabel : 'From',
1168 select : function (combo, date)
1170 _this.grid.footer.onClick('first');
1193 click : function (_self, e)
1195 _this.grid.footer.onClick('first');
1199 icon : rootURL + '/Pman/templates/images/search.gif'
1205 click : function (_self, e)
1207 _this.form.reset('');
1210 _this.grid.footer.onClick('first');
1214 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1221 xtype: 'LayoutRegion',
1228 xtype: 'LayoutRegion',