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",
175 cls : 'x-btn-text-icon',
176 text : "Download Results",
177 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
189 click : function (_self, e)
191 Pman.Dialog.XtupleInvHistory.show({
197 text : "Quick Stock Check"
211 click : function (_self, e)
213 Pman.Dialog.Image.show(
215 _url : baseURL+'/Xtuple/Import/Magento',
220 Roo.MessageBox.alert("Notice", data);
221 _this.grid.footer.onClick('first');
227 text : "Magento Upload"
233 click : function (_self, e)
235 Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {
236 Pman.Dialog.Image.show({
238 _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)
240 Roo.MessageBox.alert('Success', data);
241 _this.grid.footer.onClick('first');
246 text : "Import HSBC csv file"
252 click : function (_self, e)
254 Pman.Dialog.Image.show(
256 _url : baseURL+'/Xtuple/Import/WayBill',
261 Roo.MessageBox.alert("Notice", data);
262 _this.grid.footer.onClick('first');
267 text : "Import Waybill Delivery"
275 cls : 'x-btn-text-icon',
277 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
294 click : function (_self, e)
296 var from = _this.form.findField('_fromdate').getValue();
297 var to = _this.form.findField('_todate').getValue();
300 Roo.Msg.alert('Error', 'Please select a date range for the report');
306 filename : 'ARAging-' + to.format('Y-m-d'),
307 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
308 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
309 'param[2]': "useDocDate:number=1"
311 var cust_id = _this.form.findField('cohead_cust_id').getValue();
312 if (cust_id * 1 > 0) {
313 params['param[3]'] = 'cust_id:number=' + cust_id;
317 url : baseURL + '/Xtuple/Print',
321 Roo.MessageBox.alert("Notice", "Report will download shortly");
330 click : function (_self, e)
332 var from = _this.form.findField('_fromdate').getValue();
333 var to = _this.form.findField('_todate').getValue();
338 '_group' : 'arAging',
342 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
343 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
347 'useDocDate:text' : 'TRUE',
353 var cust_id = _this.form.findField('cohead_cust_id').getValue();
354 if (cust_id * 1 > 0) {
355 params['cust_id:number'] = cust_id;
358 new Pman.Download({
\r
359 url : baseURL + '/Roo/Metasql',
\r
363 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
373 click : function (_self, e)
375 var from = _this.form.findField('_fromdate').getValue();
376 var to = _this.form.findField('_todate').getValue();
381 '_group' : 'arAging',
387 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
388 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
391 'useDocDate:text' : 'TRUE',
396 var cust_id = _this.form.findField('cohead_cust_id').getValue();
397 if (cust_id * 1 > 0) {
398 params['cust_id:number'] = cust_id;
401 new Pman.Download({
\r
402 url : baseURL + '/Roo/Metasql',
\r
406 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
410 text : "Summary Excel"
418 text : "Customer History",
427 click : function (_self, e)
429 var cust_id = _this.form.findField('cohead_cust_id').getValue();
430 if (cust_id * 1 < 1) {
431 Roo.Msg.alert('Error', 'Please select a customer');
435 var from = _this.form.findField('_fromdate').getValue();
436 var to = _this.form.findField('_todate').getValue();
439 Roo.Msg.alert('Error', 'Please select a date range for the report');
444 template: 'customer_ar_history',
445 filename : 'customer_ar_history-' + to.format('Y-m-d'),
446 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
447 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
448 'param[2]': "cust_id:number=" + cust_id
452 url : baseURL + '/Xtuple/Print',
456 Roo.MessageBox.alert("Notice", "Report will download shortly");
465 click : function (_self, e)
467 var cust_id = _this.form.findField('cohead_cust_id').getValue();
468 if (cust_id * 1 < 1) {
469 Roo.Msg.alert('Error', 'Please select a customer');
473 var from = _this.form.findField('_fromdate').getValue();
474 var to = _this.form.findField('_todate').getValue();
479 '_group' : 'customerHistory',
483 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
484 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
486 'cust_id:number' : cust_id,
492 new Pman.Download({
\r
493 url : baseURL + '/Roo/Metasql',
\r
497 Roo.MessageBox.alert("Notice", "Report will download shortly");
508 text : "Customer Statement",
517 click : function (_self, e)
519 var cust_id = _this.form.findField('cohead_cust_id').getValue();
520 if (cust_id * 1 < 1) {
521 Roo.Msg.alert('Error', 'Please select a customer');
525 var from = _this.form.findField('_fromdate').getValue();
526 var to = _this.form.findField('_todate').getValue();
531 template: 'customer_ar_statement',
532 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
533 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
534 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
535 'param[2]': "cust_id:number=" + cust_id
539 url : baseURL + '/Xtuple/Print',
543 Roo.MessageBox.alert("Notice", "Report will download shortly");
552 click : function (_self, e)
554 var cust_id = _this.form.findField('cohead_cust_id').getValue();
555 if (cust_id * 1 < 1) {
556 Roo.Msg.alert('Error', 'Please select a customer');
560 var from = _this.form.findField('_fromdate').getValue();
561 var to = _this.form.findField('_todate').getValue();
564 // Roo.Msg.alert('Error', 'Please select a date range for the report');
569 '_group' : 'customerStatement',
572 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
573 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
574 'cust_id:number' : cust_id,
580 new Pman.Download({
\r
581 url : baseURL + '/Roo/Metasql',
\r
585 Roo.MessageBox.alert("Notice", "Report will download shortly");
600 click : function (_self, e)
602 var sels = _this.grid.getSelectionModel().getSelections();
605 Roo.MessageBox.alert("Error", "Select an order");
609 for (var i =0; i < sels.length; i++) {
612 if(s.data.cohead_qtyuninvoiced * 1 > 0){
613 Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
617 if(s.data.aropen_unpaid * 1 > 0){
618 Roo.MessageBox.alert("Error", "Order has not been paid! - " + s.data.cohead_number);
621 ids.push(s.data.cohead_id);
624 new Pman.Download({
\r
625 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
627 cohead_id : ids.join(',')
632 Roo.MessageBox.alert("Notice", "Report will download shortly");
635 cls : 'x-btn-text-icon',
636 text : "Email to warehouse",
637 icon : Roo.rootURL + 'images/default/dd/email.gif'
645 var s = _this.grid.getSelectionModel().getSelected();
647 Roo.MessageBox.alert("Error", "Select an order to close");
651 if(s.data.cohead_status == 'C'){
652 Roo.MessageBox.alert("Error", "This order has been closed");
656 Roo.MessageBox.confirm("Confirm", "Are you sure?",
662 url: baseURL + '/Roo/cohead',
665 cohead_id : s.data.cohead_id,
671 Roo.MessageBox.alert("Notice", "DONE");
672 _this.grid.footer.onClick('first');
681 cls : 'x-btn-text-icon',
682 text : "Complete and Close",
683 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
693 url: baseURL + '/Roo/cohead',
701 Roo.MessageBox.alert("Notice", "DONE");
702 _this.grid.footer.onClick('first');
708 cls : 'x-btn-text-icon',
709 text : "Clear Unpaid Orders",
710 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
726 // check if the login in user have more than 25 open orders..
727 // if yes, warning...
729 url : baseURL + '/Roo/cohead.php',
733 _count_order : 1 // make the search faster!
735 success : function(res) {
736 if(res.data[0].order_totals * 1 > 25){
737 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
742 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
743 _this.grid.footer.onClick('first');
747 cls : 'x-btn-text-icon',
749 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
757 var s = _this.grid.getSelectionModel().getSelected();
759 Roo.MessageBox.alert("Error", "Select an order to copy");
764 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
766 // get the id from the data, then
768 _this.grid.footer.onClick('first');
769 Pman.Tab.XtupleSales.grid.footer.onClick('first');
770 // get the id from the data, then start editing it..
772 _this.dialog.show(data, function() {
773 _this.grid.footer.onClick('refresh');
774 Pman.Tab.XtupleSales.grid.footer.onClick('first');
780 cls : 'x-btn-text-icon',
782 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
788 xtype: 'ColumnModel',
790 dataIndex : 'cohead_orderdate',
794 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
797 xtype: 'ColumnModel',
799 dataIndex : 'cohead_targetdate',
800 header : 'Target Delivery',
804 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
807 xtype: 'ColumnModel',
809 dataIndex : 'cohead_salesrep_id_salesrep_name',
810 header : 'Staff IC.',
813 renderer : function(v,x,r) {
815 if (r.data.cohead_display_salesrep_id) {
816 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
818 return String.format('{0}', v );
824 xtype: 'ColumnModel',
826 dataIndex : 'cohead_number',
830 renderer : function(v,x,r) {
833 // we want to show more detail about status..
834 // like payment status / delivery etc...
838 // S = shipped (or partial shipped)
839 // P = paid (or partial paid)
840 // online payment failed? >> on terms?
843 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
844 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
845 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
846 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
847 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
848 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
849 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
856 if (r.data.cohead_qtyunshipped > 0) {
858 tg += (r.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
861 tg += tags.stock_shipped;
864 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
865 // ?? partially invoiced??
868 if (r.data.cohead_qtyuninvoiced*1 < 1) {
869 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
876 if (r.data.cohead_status == 'C') {
877 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
879 if (r.data.cohead_status == 'X') {
880 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
882 return tg + ' ' + String.format('{0}', v);
886 xtype: 'ColumnModel',
888 dataIndex : 'cohead_cust_id_cust_number',
889 header : 'Customer#',
892 renderer : function(v) { return String.format('{0}', v); }
895 xtype: 'ColumnModel',
897 dataIndex : 'cohead_cust_id_cust_name',
901 renderer : function(v) { return String.format('{0}', v); }
904 xtype: 'ColumnModel',
906 dataIndex : 'cohead_custponumber',
907 header : 'Cust. PO#',
909 renderer : function(v) { return String.format('{0}', v); }
912 xtype: 'ColumnModel',
914 dataIndex : 'cohead_type',
917 renderer : function(v) { return String.format('{0}', v); }
920 xtype: 'ColumnModel',
922 dataIndex : 'cohead_src_locations',
925 renderer : function(v) { return String.format('{0}', v); }
928 xtype: 'ColumnModel',
930 dataIndex : 'cohead_shiptoaddress1',
933 renderer : function(v) { return String.format('{0}', v); }
936 xtype: 'ColumnModel',
938 dataIndex : 'cohead_terms_id_terms_descrip',
941 renderer : function(v) { return String.format('{0}', v); }
944 xtype: 'ColumnModel',
947 dataIndex : 'cohead_total',
950 renderer : function(v,x,r) {
951 var ret = String.format('{0} {1}',
952 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
955 if (parseInt(r.data.cohead_qtyordered) != 0 &&
956 parseInt(r.data.cohead_unshipped) == 0 &&
957 parseInt(r.data.cohead_qtyunshipped) == 0 &&
958 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
959 parseInt(r.data.cohead_unshipped) == 0 &&
960 parseInt(r.data.cohead_uninvoiced) == 0
965 return String.format('<b style="color:red" ' +
966 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
968 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
969 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
978 xtype: 'ContentPanel',
987 rendered : function (form)
994 style : 'margin:5px;',
1000 select : function (combo, record, index)
1002 _this.grid.footer.onClick('first');
1004 render : function (_self)
1006 _this.viewtypeSel = _self;
1010 displayField : 'value',
1012 emptyText : "View type",
1013 fieldLabel : 'View',
1014 forceSelection : true,
1016 loadingText : "Searching...",
1020 qtip : "Select Action",
1021 queryParam : 'query[action]',
1022 selectOnFocus : true,
1023 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
1024 triggerAction : 'all',
1030 xtype: 'SimpleStore',
1034 [ 'MYOPEN', 'My Open orders' ],
1035 [ 'MYCLOSED', 'My Closed orders' ],
1036 [ 'MYALL', 'My orders (all)' ],
1037 [ 'MYVOID', 'My Voided orders' ],
1038 [ 'OPEN', 'All Open orders' ],
1039 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
1040 [ 'NOTPAID', 'All Un-paid orders' ],
1041 [ 'CLOSED', 'All Closed orders' ],
1042 [ 'ALL', 'All orders' ],
1043 [ 'VOID', 'Voided orders' ],
1044 [ 'INCOMPLETE', 'Incomplete orders' ],
1045 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
1046 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
1047 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
1048 [ 'FIFOBUG', 'Problems with FIFO' ]
1051 fields : [ 'key', 'value' ]
1058 select : function (combo, record, index)
1060 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1062 specialkey : function (_self, e)
1064 //Roo.log(e.getKey());
1065 if (e.getKey() == 13) {
1066 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1068 _this.rsearch = true;
1072 beforequery : function (combo, query, forceAll, cancel, e)
1075 if( _this.rsearch) {
1076 _this.rsearch =false;
1083 displayField : 'cohead_number',
1085 emptyText : "Select Order",
1086 fieldLabel : 'Order #',
1087 forceSelection : false,
1089 loadingText : "Searching...",
1091 name : 'query[cohead_number]',
1093 qtip : "Select Order",
1094 queryParam : 'query[cohead_number]',
1095 selectOnFocus : true,
1096 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1097 triggerAction : 'all',
1099 valueField : 'cohead_number',
1105 beforeload : function (_self, o){
1106 o.params = o.params || {};
1107 o.params['_columns'] = 'cohead_number';
1112 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1117 url : baseURL + '/Roo/cohead.php'
1120 xtype: 'JsonReader',
1122 id : 'cohead_number',
1124 totalProperty : 'total',
1125 fields : ["cohead_number"]
1133 select : function (combo, record, index)
1135 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1139 displayField : 'cust_name',
1141 emptyText : "Select custinfo",
1142 fieldLabel : 'Customer',
1143 forceSelection : true,
1144 hiddenName : 'cohead_cust_id',
1146 loadingText : "Searching...",
1148 name : 'cohead_cust_id_cust_name',
1150 qtip : "Select custinfo",
1151 queryParam : 'query[cust_name]',
1152 selectOnFocus : true,
1153 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1154 triggerAction : 'all',
1156 valueField : 'cust_id',
1161 sortInfo : { direction : 'ASC', field: 'cust_name' },
1164 beforeload : function (_self, o){
1165 o.params = o.params || {};
1173 url : baseURL + '/Roo/custinfo.php'
1176 xtype: 'JsonReader',
1180 totalProperty : 'total',
1181 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1189 select : function (combo, date)
1191 _this.grid.footer.onClick('first');
1194 fieldLabel : 'From',
1203 select : function (combo, date)
1205 _this.grid.footer.onClick('first');
1228 click : function (_self, e)
1230 _this.grid.footer.onClick('first');
1234 icon : rootURL + '/Pman/templates/images/search.gif'
1240 click : function (_self, e)
1242 _this.form.reset('');
1245 _this.grid.footer.onClick('first');
1249 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1256 xtype: 'LayoutRegion',
1263 xtype: 'LayoutRegion',