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",
174 cls : 'x-btn-text-icon',
175 text : "Download Results",
176 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
188 click : function (_self, e)
190 Pman.Dialog.XtupleInvHistory.show({
196 text : "Quick Stock Check"
210 click : function (_self, e)
212 Pman.Dialog.Image.show(
214 _url : baseURL+'/Xtuple/Import/Magento',
219 Roo.MessageBox.alert("Notice", data);
220 _this.grid.footer.onClick('first');
226 text : "Magento Upload"
232 click : function (_self, e)
234 Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {
235 Pman.Dialog.Image.show({
237 _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)
239 Roo.MessageBox.alert('Success', data);
240 _this.grid.footer.onClick('first');
245 text : "Import HSBC csv file"
251 click : function (_self, e)
253 Pman.Dialog.Image.show(
255 _url : baseURL+'/Xtuple/Import/WayBill',
260 Roo.MessageBox.alert("Notice", data);
261 _this.grid.footer.onClick('first');
266 text : "Import Waybill Delivery"
274 cls : 'x-btn-text-icon',
276 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
293 click : function (_self, e)
295 var from = _this.form.findField('_fromdate').getValue();
296 var to = _this.form.findField('_todate').getValue();
299 Roo.Msg.alert('Error', 'Please select a date range for the report');
305 filename : 'ARAging-' + to.format('Y-m-d'),
306 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
307 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
308 'param[2]': "useDocDate:number=1"
310 var cust_id = _this.form.findField('cohead_cust_id').getValue();
311 if (cust_id * 1 > 0) {
312 params['param[3]'] = 'cust_id:number=' + cust_id;
316 url : baseURL + '/Xtuple/Print',
320 Roo.MessageBox.alert("Notice", "Report will download shortly");
329 click : function (_self, e)
331 var from = _this.form.findField('_fromdate').getValue();
332 var to = _this.form.findField('_todate').getValue();
337 '_group' : 'arAging',
341 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
342 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
346 'useDocDate:text' : 'TRUE',
352 var cust_id = _this.form.findField('cohead_cust_id').getValue();
353 if (cust_id * 1 > 0) {
354 params['cust_id:number'] = cust_id;
357 new Pman.Download({
\r
358 url : baseURL + '/Roo/Metasql',
\r
362 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
372 click : function (_self, e)
374 var from = _this.form.findField('_fromdate').getValue();
375 var to = _this.form.findField('_todate').getValue();
380 '_group' : 'arAging',
386 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
387 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
390 'useDocDate:text' : 'TRUE',
395 var cust_id = _this.form.findField('cohead_cust_id').getValue();
396 if (cust_id * 1 > 0) {
397 params['cust_id:number'] = cust_id;
400 new Pman.Download({
\r
401 url : baseURL + '/Roo/Metasql',
\r
405 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
409 text : "Summary Excel"
417 text : "Customer History",
426 click : function (_self, e)
428 var cust_id = _this.form.findField('cohead_cust_id').getValue();
429 if (cust_id * 1 < 1) {
430 Roo.Msg.alert('Error', 'Please select a customer');
434 var from = _this.form.findField('_fromdate').getValue();
435 var to = _this.form.findField('_todate').getValue();
438 Roo.Msg.alert('Error', 'Please select a date range for the report');
443 template: 'customer_ar_history',
444 filename : 'customer_ar_history-' + to.format('Y-m-d'),
445 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
446 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
447 'param[2]': "cust_id:number=" + cust_id
451 url : baseURL + '/Xtuple/Print',
455 Roo.MessageBox.alert("Notice", "Report will download shortly");
464 click : function (_self, e)
466 var cust_id = _this.form.findField('cohead_cust_id').getValue();
467 if (cust_id * 1 < 1) {
468 Roo.Msg.alert('Error', 'Please select a customer');
472 var from = _this.form.findField('_fromdate').getValue();
473 var to = _this.form.findField('_todate').getValue();
478 '_group' : 'customerHistory',
482 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
483 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
485 'cust_id:number' : cust_id,
491 new Pman.Download({
\r
492 url : baseURL + '/Roo/Metasql',
\r
496 Roo.MessageBox.alert("Notice", "Report will download shortly");
507 text : "Customer Statement",
516 click : function (_self, e)
518 var cust_id = _this.form.findField('cohead_cust_id').getValue();
519 if (cust_id * 1 < 1) {
520 Roo.Msg.alert('Error', 'Please select a customer');
524 var from = _this.form.findField('_fromdate').getValue();
525 var to = _this.form.findField('_todate').getValue();
530 template: 'customer_ar_statement',
531 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
532 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
533 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
534 'param[2]': "cust_id:number=" + cust_id
538 url : baseURL + '/Xtuple/Print',
542 Roo.MessageBox.alert("Notice", "Report will download shortly");
551 click : function (_self, e)
553 var cust_id = _this.form.findField('cohead_cust_id').getValue();
554 if (cust_id * 1 < 1) {
555 Roo.Msg.alert('Error', 'Please select a customer');
559 var from = _this.form.findField('_fromdate').getValue();
560 var to = _this.form.findField('_todate').getValue();
563 // Roo.Msg.alert('Error', 'Please select a date range for the report');
568 '_group' : 'customerStatement',
571 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
572 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
573 'cust_id:number' : cust_id,
579 new Pman.Download({
\r
580 url : baseURL + '/Roo/Metasql',
\r
584 Roo.MessageBox.alert("Notice", "Report will download shortly");
599 click : function (_self, e)
601 var sels = _this.grid.getSelectionModel().getSelections();
604 Roo.MessageBox.alert("Error", "Select an order");
608 for (var i =0; i < sels.length; i++) {
611 if(s.data.cohead_qtyuninvoiced * 1 > 0){
612 Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
616 if(s.data.aropen_unpaid * 1 > 0){
617 Roo.MessageBox.alert("Error", "Order has not been paid! - " + s.data.cohead_number);
620 ids.push(s.data.cohead_id);
623 new Pman.Download({
\r
624 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
626 cohead_id : ids.join(',')
631 Roo.MessageBox.alert("Notice", "Report will download shortly");
634 cls : 'x-btn-text-icon',
635 text : "Email to warehouse",
636 icon : Roo.rootURL + 'images/default/dd/email.gif'
644 var s = _this.grid.getSelectionModel().getSelected();
646 Roo.MessageBox.alert("Error", "Select an order to close");
650 if(s.data.cohead_status == 'C'){
651 Roo.MessageBox.alert("Error", "This order has been closed");
655 Roo.MessageBox.confirm("Confirm", "Are you sure?",
661 url: baseURL + '/Roo/cohead',
664 cohead_id : s.data.cohead_id,
670 Roo.MessageBox.alert("Notice", "DONE");
671 _this.grid.footer.onClick('first');
680 cls : 'x-btn-text-icon',
681 text : "Complete and Close",
682 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
692 url: baseURL + '/Roo/cohead',
700 Roo.MessageBox.alert("Notice", "DONE");
701 _this.grid.footer.onClick('first');
707 cls : 'x-btn-text-icon',
708 text : "Clear Unpaid Orders",
709 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
718 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID all the Sales Order and Purchase Order?",
725 url : baseURL + '/Xtuple/VoidSalesAndPurchaseOrders',
727 success : function() {
739 cls : 'x-btn-text-icon',
740 text : "Void all the Sales Order and Purchase Order",
741 icon : rootURL + '/Pman/templates/images/trash.gif'
753 // check if the login in user have more than 25 open orders..
754 // if yes, warning...
756 url : baseURL + '/Roo/cohead.php',
760 _count_order : 1 // make the search faster!
762 success : function(res) {
763 if(res.data[0].order_totals * 1 > 25){
764 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
769 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
770 _this.grid.footer.onClick('first');
774 cls : 'x-btn-text-icon',
776 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
784 var s = _this.grid.getSelectionModel().getSelected();
786 Roo.MessageBox.alert("Error", "Select an order to copy");
791 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
793 // get the id from the data, then
795 _this.grid.footer.onClick('first');
796 Pman.Tab.XtupleSales.grid.footer.onClick('first');
797 // get the id from the data, then start editing it..
799 _this.dialog.show(data, function() {
800 _this.grid.footer.onClick('refresh');
801 Pman.Tab.XtupleSales.grid.footer.onClick('first');
807 cls : 'x-btn-text-icon',
809 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
815 xtype: 'ColumnModel',
817 dataIndex : 'cohead_orderdate',
821 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
824 xtype: 'ColumnModel',
826 dataIndex : 'cohead_targetdate',
827 header : 'Target Delivery',
831 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
834 xtype: 'ColumnModel',
836 dataIndex : 'cohead_salesrep_id_salesrep_name',
837 header : 'Staff IC.',
840 renderer : function(v,x,r) {
842 if (r.data.cohead_display_salesrep_id) {
843 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
845 return String.format('{0}', v );
851 xtype: 'ColumnModel',
853 dataIndex : 'cohead_number',
857 renderer : function(v,x,r) {
860 // we want to show more detail about status..
861 // like payment status / delivery etc...
865 // S = shipped (or partial shipped)
866 // P = paid (or partial paid)
867 // online payment failed? >> on terms?
870 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
871 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
872 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
873 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
874 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
875 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
876 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
883 if (r.data.cohead_qtyunshipped > 0) {
885 tg += (r.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
888 tg += tags.stock_shipped;
891 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
892 // ?? partially invoiced??
895 if (r.data.cohead_qtyuninvoiced*1 < 1) {
896 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
903 if (r.data.cohead_status == 'C') {
904 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
906 if (r.data.cohead_status == 'X') {
907 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
909 return tg + ' ' + String.format('{0}', v);
913 xtype: 'ColumnModel',
915 dataIndex : 'cohead_cust_id_cust_number',
916 header : 'Customer#',
919 renderer : function(v) { return String.format('{0}', v); }
922 xtype: 'ColumnModel',
924 dataIndex : 'cohead_cust_id_cust_name',
928 renderer : function(v) { return String.format('{0}', v); }
931 xtype: 'ColumnModel',
933 dataIndex : 'cohead_custponumber',
934 header : 'Cust. PO#',
936 renderer : function(v) { return String.format('{0}', v); }
939 xtype: 'ColumnModel',
941 dataIndex : 'cohead_type',
944 renderer : function(v) { return String.format('{0}', v); }
947 xtype: 'ColumnModel',
949 dataIndex : 'cohead_src_locations',
952 renderer : function(v) { return String.format('{0}', v); }
955 xtype: 'ColumnModel',
957 dataIndex : 'cohead_shiptoaddress1',
960 renderer : function(v) { return String.format('{0}', v); }
963 xtype: 'ColumnModel',
965 dataIndex : 'cohead_terms_id_terms_descrip',
968 renderer : function(v) { return String.format('{0}', v); }
971 xtype: 'ColumnModel',
974 dataIndex : 'cohead_total',
977 renderer : function(v,x,r) {
978 var ret = String.format('{0} {1}',
979 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
982 if (parseInt(r.data.cohead_qtyordered) != 0 &&
983 parseInt(r.data.cohead_unshipped) == 0 &&
984 parseInt(r.data.cohead_qtyunshipped) == 0 &&
985 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
986 parseInt(r.data.cohead_unshipped) == 0 &&
987 parseInt(r.data.cohead_uninvoiced) == 0
992 return String.format('<b style="color:red" ' +
993 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
995 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
996 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
1005 xtype: 'ContentPanel',
1014 rendered : function (form)
1021 style : 'margin:5px;',
1027 select : function (combo, record, index)
1029 _this.grid.footer.onClick('first');
1031 render : function (_self)
1033 _this.viewtypeSel = _self;
1037 displayField : 'value',
1039 emptyText : "View type",
1040 fieldLabel : 'View',
1041 forceSelection : true,
1043 loadingText : "Searching...",
1047 qtip : "Select Action",
1048 queryParam : 'query[action]',
1049 selectOnFocus : true,
1050 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
1051 triggerAction : 'all',
1057 xtype: 'SimpleStore',
1061 [ 'MYOPEN', 'My Open orders' ],
1062 [ 'MYCLOSED', 'My Closed orders' ],
1063 [ 'MYALL', 'My orders (all)' ],
1064 [ 'MYVOID', 'My Voided orders' ],
1065 [ 'OPEN', 'All Open orders' ],
1066 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
1067 [ 'NOTPAID', 'All Un-paid orders' ],
1068 [ 'CLOSED', 'All Closed orders' ],
1069 [ 'ALL', 'All orders' ],
1070 [ 'VOID', 'Voided orders' ],
1071 [ 'INCOMPLETE', 'Incomplete orders' ],
1072 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
1073 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
1074 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
1075 [ 'FIFOBUG', 'Problems with FIFO' ]
1078 fields : [ 'key', 'value' ]
1085 select : function (combo, record, index)
1087 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1089 specialkey : function (_self, e)
1091 //Roo.log(e.getKey());
1092 if (e.getKey() == 13) {
1093 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1095 _this.rsearch = true;
1099 beforequery : function (combo, query, forceAll, cancel, e)
1102 if( _this.rsearch) {
1103 _this.rsearch =false;
1110 displayField : 'cohead_number',
1112 emptyText : "Select Order",
1113 fieldLabel : 'Order #',
1114 forceSelection : false,
1116 loadingText : "Searching...",
1118 name : 'query[cohead_number]',
1120 qtip : "Select Order",
1121 queryParam : 'query[cohead_number]',
1122 selectOnFocus : true,
1123 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1124 triggerAction : 'all',
1126 valueField : 'cohead_number',
1132 beforeload : function (_self, o){
1133 o.params = o.params || {};
1134 o.params['_columns'] = 'cohead_number';
1139 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1144 url : baseURL + '/Roo/cohead.php'
1147 xtype: 'JsonReader',
1149 id : 'cohead_number',
1151 totalProperty : 'total',
1152 fields : ["cohead_number"]
1160 select : function (combo, record, index)
1162 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1166 displayField : 'cust_name',
1168 emptyText : "Select custinfo",
1169 fieldLabel : 'Customer',
1170 forceSelection : true,
1171 hiddenName : 'cohead_cust_id',
1173 loadingText : "Searching...",
1175 name : 'cohead_cust_id_cust_name',
1177 qtip : "Select custinfo",
1178 queryParam : 'query[cust_name]',
1179 selectOnFocus : true,
1180 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1181 triggerAction : 'all',
1183 valueField : 'cust_id',
1188 sortInfo : { direction : 'ASC', field: 'cust_name' },
1191 beforeload : function (_self, o){
1192 o.params = o.params || {};
1200 url : baseURL + '/Roo/custinfo.php'
1203 xtype: 'JsonReader',
1207 totalProperty : 'total',
1208 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1216 select : function (combo, date)
1218 _this.grid.footer.onClick('first');
1221 fieldLabel : 'From',
1230 select : function (combo, date)
1232 _this.grid.footer.onClick('first');
1255 click : function (_self, e)
1257 _this.grid.footer.onClick('first');
1261 icon : rootURL + '/Pman/templates/images/search.gif'
1267 click : function (_self, e)
1269 _this.form.reset('');
1272 _this.grid.footer.onClick('first');
1276 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1283 xtype: 'LayoutRegion',
1290 xtype: 'LayoutRegion',