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",
176 cls : 'x-btn-text-icon',
177 text : "Download Results",
178 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
190 click : function (_self, e)
192 Pman.Dialog.XtupleInvHistory.show({
198 text : "Quick Stock Check"
212 click : function (_self, e)
214 Pman.Dialog.Image.show(
216 _url : baseURL+'/Xtuple/Import/Magento',
221 Roo.MessageBox.alert("Notice", data);
222 _this.grid.footer.onClick('first');
228 text : "Magento Upload"
234 click : function (_self, e)
236 Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {
237 Pman.Dialog.Image.show({
239 _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)
241 Roo.MessageBox.alert('Success', data);
242 _this.grid.footer.onClick('first');
247 text : "Import HSBC csv file"
253 click : function (_self, e)
255 Pman.Dialog.Image.show(
257 _url : baseURL+'/Xtuple/Import/WayBill',
262 Roo.MessageBox.alert("Notice", data);
263 _this.grid.footer.onClick('first');
268 text : "Import Waybill Delivery"
276 cls : 'x-btn-text-icon',
278 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
295 click : function (_self, e)
297 var from = _this.form.findField('_fromdate').getValue();
298 var to = _this.form.findField('_todate').getValue();
301 Roo.Msg.alert('Error', 'Please select a date range for the report');
307 filename : 'ARAging-' + to.format('Y-m-d'),
308 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
309 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
310 'param[2]': "useDocDate:number=1"
312 var cust_id = _this.form.findField('cohead_cust_id').getValue();
313 if (cust_id * 1 > 0) {
314 params['param[3]'] = 'cust_id:number=' + cust_id;
318 url : baseURL + '/Xtuple/Print',
322 Roo.MessageBox.alert("Notice", "Report will download shortly");
331 click : function (_self, e)
333 var from = _this.form.findField('_fromdate').getValue();
334 var to = _this.form.findField('_todate').getValue();
339 '_group' : 'arAging',
343 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
344 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
348 'useDocDate:text' : 'TRUE',
354 var cust_id = _this.form.findField('cohead_cust_id').getValue();
355 if (cust_id * 1 > 0) {
356 params['cust_id:number'] = cust_id;
359 new Pman.Download({
\r
360 url : baseURL + '/Roo/Metasql',
\r
364 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
374 click : function (_self, e)
376 var from = _this.form.findField('_fromdate').getValue();
377 var to = _this.form.findField('_todate').getValue();
382 '_group' : 'arAging',
388 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
389 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
392 'useDocDate:text' : 'TRUE',
397 var cust_id = _this.form.findField('cohead_cust_id').getValue();
398 if (cust_id * 1 > 0) {
399 params['cust_id:number'] = cust_id;
402 new Pman.Download({
\r
403 url : baseURL + '/Roo/Metasql',
\r
407 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
411 text : "Summary Excel"
419 text : "Customer History",
428 click : function (_self, e)
430 var cust_id = _this.form.findField('cohead_cust_id').getValue();
431 if (cust_id * 1 < 1) {
432 Roo.Msg.alert('Error', 'Please select a customer');
436 var from = _this.form.findField('_fromdate').getValue();
437 var to = _this.form.findField('_todate').getValue();
440 Roo.Msg.alert('Error', 'Please select a date range for the report');
445 template: 'customer_ar_history',
446 filename : 'customer_ar_history-' + to.format('Y-m-d'),
447 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
448 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
449 'param[2]': "cust_id:number=" + cust_id
453 url : baseURL + '/Xtuple/Print',
457 Roo.MessageBox.alert("Notice", "Report will download shortly");
466 click : function (_self, e)
468 var cust_id = _this.form.findField('cohead_cust_id').getValue();
469 if (cust_id * 1 < 1) {
470 Roo.Msg.alert('Error', 'Please select a customer');
474 var from = _this.form.findField('_fromdate').getValue();
475 var to = _this.form.findField('_todate').getValue();
480 '_group' : 'customerHistory',
484 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
485 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
487 'cust_id:number' : cust_id,
493 new Pman.Download({
\r
494 url : baseURL + '/Roo/Metasql',
\r
498 Roo.MessageBox.alert("Notice", "Report will download shortly");
509 text : "Customer Statement",
518 click : function (_self, e)
520 var cust_id = _this.form.findField('cohead_cust_id').getValue();
521 if (cust_id * 1 < 1) {
522 Roo.Msg.alert('Error', 'Please select a customer');
526 var from = _this.form.findField('_fromdate').getValue();
527 var to = _this.form.findField('_todate').getValue();
532 template: 'customer_ar_statement',
533 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
534 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
535 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
536 'param[2]': "cust_id:number=" + cust_id
540 url : baseURL + '/Xtuple/Print',
544 Roo.MessageBox.alert("Notice", "Report will download shortly");
553 click : function (_self, e)
555 var cust_id = _this.form.findField('cohead_cust_id').getValue();
556 if (cust_id * 1 < 1) {
557 Roo.Msg.alert('Error', 'Please select a customer');
561 var from = _this.form.findField('_fromdate').getValue();
562 var to = _this.form.findField('_todate').getValue();
565 // Roo.Msg.alert('Error', 'Please select a date range for the report');
570 '_group' : 'customerStatement',
573 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
574 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
575 'cust_id:number' : cust_id,
581 new Pman.Download({
\r
582 url : baseURL + '/Roo/Metasql',
\r
586 Roo.MessageBox.alert("Notice", "Report will download shortly");
601 click : function (_self, e)
603 var sels = _this.grid.getSelectionModel().getSelections();
606 Roo.MessageBox.alert("Error", "Select an order");
610 for (var i =0; i < sels.length; i++) {
613 if(s.data.cohead_qtyuninvoiced * 1 > 0){
614 Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
618 if(s.data.aropen_unpaid * 1 > 0){
619 Roo.MessageBox.alert("Error", "Order has not been paid! - " + s.data.cohead_number);
622 ids.push(s.data.cohead_id);
625 new Pman.Download({
\r
626 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
628 cohead_id : ids.join(',')
633 Roo.MessageBox.alert("Notice", "Report will download shortly");
636 cls : 'x-btn-text-icon',
637 text : "Email to warehouse",
638 icon : Roo.rootURL + 'images/default/dd/email.gif'
646 var s = _this.grid.getSelectionModel().getSelected();
648 Roo.MessageBox.alert("Error", "Select an order to close");
652 if(s.data.cohead_status == 'C'){
653 Roo.MessageBox.alert("Error", "This order has been closed");
657 Roo.MessageBox.confirm("Confirm", "Are you sure?",
663 url: baseURL + '/Roo/cohead',
666 cohead_id : s.data.cohead_id,
672 Roo.MessageBox.alert("Notice", "DONE");
673 _this.grid.footer.onClick('first');
682 cls : 'x-btn-text-icon',
683 text : "Complete and Close",
684 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
694 url: baseURL + '/Roo/cohead',
702 Roo.MessageBox.alert("Notice", "DONE");
703 _this.grid.footer.onClick('first');
709 cls : 'x-btn-text-icon',
710 text : "Clear Unpaid Orders",
711 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
723 // check if the login in user have more than 25 open orders..
724 // if yes, warning...
726 url : baseURL + '/Roo/cohead.php',
730 _count_order : 1 // make the search faster!
732 success : function(res) {
733 if(res.data[0].order_totals * 1 > 25){
734 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
739 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
740 _this.grid.footer.onClick('first');
744 cls : 'x-btn-text-icon',
746 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
754 var s = _this.grid.getSelectionModel().getSelected();
756 Roo.MessageBox.alert("Error", "Select an order to copy");
761 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
763 // get the id from the data, then
765 _this.grid.footer.onClick('first');
766 Pman.Tab.XtupleSales.grid.footer.onClick('first');
767 // get the id from the data, then start editing it..
769 _this.dialog.show(data, function() {
770 _this.grid.footer.onClick('refresh');
771 Pman.Tab.XtupleSales.grid.footer.onClick('first');
777 cls : 'x-btn-text-icon',
779 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
785 xtype: 'ColumnModel',
787 dataIndex : 'cohead_orderdate',
791 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
794 xtype: 'ColumnModel',
796 dataIndex : 'cohead_targetdate',
797 header : 'Target Delivery',
801 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
804 xtype: 'ColumnModel',
806 dataIndex : 'cohead_salesrep_id_salesrep_name',
807 header : 'Staff IC.',
810 renderer : function(v,x,r) {
812 if (r.data.cohead_display_salesrep_id) {
813 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
815 return String.format('{0}', v );
821 xtype: 'ColumnModel',
823 dataIndex : 'cohead_number',
827 renderer : function(v,x,r) {
830 // we want to show more detail about status..
831 // like payment status / delivery etc...
835 // S = shipped (or partial shipped)
836 // P = paid (or partial paid)
837 // online payment failed? >> on terms?
840 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
841 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
842 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
843 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
844 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
845 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
846 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
853 if (r.data.cohead_qtyunshipped > 0) {
855 tg += (r.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
858 tg += tags.stock_shipped;
861 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
862 // ?? partially invoiced??
865 if (r.data.cohead_qtyuninvoiced*1 < 1) {
866 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
873 if (r.data.cohead_status == 'C') {
874 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
876 if (r.data.cohead_status == 'X') {
877 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
879 return tg + ' ' + String.format('{0}', v);
883 xtype: 'ColumnModel',
885 dataIndex : 'cohead_cust_id_cust_number',
886 header : 'Customer#',
889 renderer : function(v) { return String.format('{0}', v); }
892 xtype: 'ColumnModel',
894 dataIndex : 'cohead_cust_id_cust_name',
898 renderer : function(v) { return String.format('{0}', v); }
901 xtype: 'ColumnModel',
903 dataIndex : 'cohead_custponumber',
904 header : 'Cust. PO#',
906 renderer : function(v) { return String.format('{0}', v); }
909 xtype: 'ColumnModel',
911 dataIndex : 'cohead_type',
914 renderer : function(v) { return String.format('{0}', v); }
917 xtype: 'ColumnModel',
919 dataIndex : 'cohead_src_locations',
922 renderer : function(v) { return String.format('{0}', v); }
925 xtype: 'ColumnModel',
927 dataIndex : 'cohead_shiptoaddress1',
930 renderer : function(v) { return String.format('{0}', v); }
933 xtype: 'ColumnModel',
935 dataIndex : 'cohead_terms_id_terms_descrip',
938 renderer : function(v) { return String.format('{0}', v); }
941 xtype: 'ColumnModel',
943 dataIndex : 'cohead_ordercomments',
947 renderer : function(v) { return String.format('{0}', v); }
950 xtype: 'ColumnModel',
953 dataIndex : 'cohead_total',
956 renderer : function(v,x,r) {
957 var ret = String.format('{0} {1}',
958 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
961 if (parseInt(r.data.cohead_qtyordered) != 0 &&
962 parseInt(r.data.cohead_unshipped) == 0 &&
963 parseInt(r.data.cohead_qtyunshipped) == 0 &&
964 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
965 parseInt(r.data.cohead_unshipped) == 0 &&
966 parseInt(r.data.cohead_uninvoiced) == 0
971 return String.format('<b style="color:red" ' +
972 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
974 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
975 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
984 xtype: 'ContentPanel',
993 rendered : function (form)
1000 style : 'margin:5px;',
1006 select : function (combo, record, index)
1008 _this.grid.footer.onClick('first');
1010 render : function (_self)
1012 _this.viewtypeSel = _self;
1016 displayField : 'value',
1018 emptyText : "View type",
1019 fieldLabel : 'View',
1020 forceSelection : true,
1022 loadingText : "Searching...",
1026 qtip : "Select Action",
1027 queryParam : 'query[action]',
1028 selectOnFocus : true,
1029 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
1030 triggerAction : 'all',
1036 xtype: 'SimpleStore',
1040 [ 'MYOPEN', 'My Open orders' ],
1041 [ 'MYCLOSED', 'My Closed orders' ],
1042 [ 'MYALL', 'My orders (all)' ],
1043 [ 'MYVOID', 'My Voided orders' ],
1044 [ 'OPEN', 'All Open orders' ],
1045 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
1046 [ 'NOTPAID', 'All Un-paid orders' ],
1047 [ 'PAIDNOTSHIPPED', 'All paid / not shipped orders' ],
1048 [ 'CLOSED', 'All Closed orders' ],
1050 [ 'ALL', 'All orders' ],
1051 [ 'VOID', 'Voided orders' ],
1052 [ 'INCOMPLETE', 'Incomplete orders' ],
1053 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
1054 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
1055 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
1056 [ 'FIFOBUG', 'Problems with FIFO' ]
1059 fields : [ 'key', 'value' ]
1066 select : function (combo, record, index)
1068 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1070 specialkey : function (_self, e)
1072 //Roo.log(e.getKey());
1073 if (e.getKey() == 13) {
1074 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1076 _this.rsearch = true;
1080 beforequery : function (combo, query, forceAll, cancel, e)
1083 if( _this.rsearch) {
1084 _this.rsearch =false;
1091 displayField : 'cohead_number',
1093 emptyText : "Select Order",
1094 fieldLabel : 'Order #',
1095 forceSelection : false,
1097 loadingText : "Searching...",
1099 name : 'query[cohead_number]',
1101 qtip : "Select Order",
1102 queryParam : 'query[cohead_number]',
1103 selectOnFocus : true,
1104 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1105 triggerAction : 'all',
1107 valueField : 'cohead_number',
1113 beforeload : function (_self, o){
1114 o.params = o.params || {};
1115 o.params['_columns'] = 'cohead_number';
1120 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1125 url : baseURL + '/Roo/cohead.php'
1128 xtype: 'JsonReader',
1130 id : 'cohead_number',
1132 totalProperty : 'total',
1133 fields : ["cohead_number"]
1141 select : function (combo, record, index)
1143 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1147 displayField : 'cust_name',
1149 emptyText : "Select custinfo",
1150 fieldLabel : 'Customer',
1151 forceSelection : true,
1152 hiddenName : 'cohead_cust_id',
1154 loadingText : "Searching...",
1156 name : 'cohead_cust_id_cust_name',
1158 qtip : "Select custinfo",
1159 queryParam : 'query[cust_name]',
1160 selectOnFocus : true,
1161 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1162 triggerAction : 'all',
1164 valueField : 'cust_id',
1169 sortInfo : { direction : 'ASC', field: 'cust_name' },
1172 beforeload : function (_self, o){
1173 o.params = o.params || {};
1181 url : baseURL + '/Roo/custinfo.php'
1184 xtype: 'JsonReader',
1188 totalProperty : 'total',
1189 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1197 select : function (combo, date)
1199 _this.grid.footer.onClick('first');
1202 fieldLabel : 'From',
1211 select : function (combo, date)
1213 _this.grid.footer.onClick('first');
1236 click : function (_self, e)
1238 _this.grid.footer.onClick('first');
1242 icon : rootURL + '/Pman/templates/images/search.gif'
1248 click : function (_self, e)
1250 _this.form.reset('');
1253 _this.grid.footer.onClick('first');
1257 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1264 xtype: 'LayoutRegion',
1271 xtype: 'LayoutRegion',