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"
208 text : "Magento Upload"
217 click : function (_self, e)
219 Pman.Dialog.Image.show(
221 _url : baseURL+'/Xtuple/Import/Magento',
226 Roo.MessageBox.alert("Notice", data);
227 _this.grid.footer.onClick('first');
233 text : "Magento Upload"
238 cls : 'x-btn-text-icon',
240 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
257 click : function (_self, e)
259 var from = _this.form.findField('_fromdate').getValue();
260 var to = _this.form.findField('_todate').getValue();
263 Roo.Msg.alert('Error', 'Please select a date range for the report');
269 filename : 'ARAging-' + to.format('Y-m-d'),
270 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
271 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
272 'param[2]': "useDocDate:number=1"
274 var cust_id = _this.form.findField('cohead_cust_id').getValue();
275 if (cust_id * 1 > 0) {
276 params['param[3]'] = 'cust_id:number=' + cust_id;
280 url : baseURL + '/Xtuple/Print',
284 Roo.MessageBox.alert("Notice", "Report will download shortly");
293 click : function (_self, e)
295 var from = _this.form.findField('_fromdate').getValue();
296 var to = _this.form.findField('_todate').getValue();
301 '_group' : 'arAging',
305 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
306 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
310 'useDocDate:text' : 'TRUE',
316 var cust_id = _this.form.findField('cohead_cust_id').getValue();
317 if (cust_id * 1 > 0) {
318 params['cust_id:number'] = cust_id;
321 new Pman.Download({
\r
322 url : baseURL + '/Roo/Metasql',
\r
326 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
336 click : function (_self, e)
338 var from = _this.form.findField('_fromdate').getValue();
339 var to = _this.form.findField('_todate').getValue();
344 '_group' : 'arAging',
350 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
351 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
354 'useDocDate:text' : 'TRUE',
359 var cust_id = _this.form.findField('cohead_cust_id').getValue();
360 if (cust_id * 1 > 0) {
361 params['cust_id:number'] = cust_id;
364 new Pman.Download({
\r
365 url : baseURL + '/Roo/Metasql',
\r
369 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
373 text : "Summary Excel"
381 text : "Customer History",
390 click : function (_self, e)
392 var cust_id = _this.form.findField('cohead_cust_id').getValue();
393 if (cust_id * 1 < 1) {
394 Roo.Msg.alert('Error', 'Please select a customer');
398 var from = _this.form.findField('_fromdate').getValue();
399 var to = _this.form.findField('_todate').getValue();
402 Roo.Msg.alert('Error', 'Please select a date range for the report');
407 template: 'customer_ar_history',
408 filename : 'customer_ar_history-' + to.format('Y-m-d'),
409 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
410 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
411 'param[2]': "cust_id:number=" + cust_id
415 url : baseURL + '/Xtuple/Print',
419 Roo.MessageBox.alert("Notice", "Report will download shortly");
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();
442 '_group' : 'customerHistory',
446 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
447 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
449 'cust_id:number' : cust_id,
455 new Pman.Download({
\r
456 url : baseURL + '/Roo/Metasql',
\r
460 Roo.MessageBox.alert("Notice", "Report will download shortly");
471 text : "Customer Statement",
480 click : function (_self, e)
482 var cust_id = _this.form.findField('cohead_cust_id').getValue();
483 if (cust_id * 1 < 1) {
484 Roo.Msg.alert('Error', 'Please select a customer');
488 var from = _this.form.findField('_fromdate').getValue();
489 var to = _this.form.findField('_todate').getValue();
494 template: 'customer_ar_statement',
495 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
496 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
497 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
498 'param[2]': "cust_id:number=" + cust_id
502 url : baseURL + '/Xtuple/Print',
506 Roo.MessageBox.alert("Notice", "Report will download shortly");
515 click : function (_self, e)
517 var cust_id = _this.form.findField('cohead_cust_id').getValue();
518 if (cust_id * 1 < 1) {
519 Roo.Msg.alert('Error', 'Please select a customer');
523 var from = _this.form.findField('_fromdate').getValue();
524 var to = _this.form.findField('_todate').getValue();
527 // Roo.Msg.alert('Error', 'Please select a date range for the report');
532 '_group' : 'customerStatement',
535 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
536 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
537 'cust_id:number' : cust_id,
543 new Pman.Download({
\r
544 url : baseURL + '/Roo/Metasql',
\r
548 Roo.MessageBox.alert("Notice", "Report will download shortly");
563 click : function (_self, e)
565 var sels = _this.grid.getSelectionModel().getSelections();
568 Roo.MessageBox.alert("Error", "Select an order");
572 for (var i =0; i < sels.length; i++) {
575 if(s.data.cohead_qtyuninvoiced * 1 > 0){
576 Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
580 if(s.data.aropen_unpaid * 1 > 0){
581 Roo.MessageBox.alert("Error", "Order has not been paid! - " + s.data.cohead_number);
584 ids.push(s.data.cohead_id);
587 new Pman.Download({
\r
588 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
590 cohead_id : ids.join(',')
595 Roo.MessageBox.alert("Notice", "Report will download shortly");
598 cls : 'x-btn-text-icon',
599 text : "Email to warehouse",
600 icon : Roo.rootURL + 'images/default/dd/email.gif'
608 var s = _this.grid.getSelectionModel().getSelected();
610 Roo.MessageBox.alert("Error", "Select an order to close");
614 if(s.data.cohead_status == 'C'){
615 Roo.MessageBox.alert("Error", "This order has been closed");
620 url: baseURL + '/Roo/cohead',
623 cohead_id : s.data.cohead_id,
629 Roo.MessageBox.alert("Notice", "DONE");
630 _this.grid.footer.onClick('first');
636 cls : 'x-btn-text-icon',
637 text : "Complete and Close",
638 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
650 // check if the login in user have more than 25 open orders..
651 // if yes, warning...
653 url : baseURL + '/Roo/cohead.php',
657 _count_order : 1 // make the search faster!
659 success : function(res) {
660 if(res.data[0].order_totals * 1 > 25){
661 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
666 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
667 _this.grid.footer.onClick('first');
671 cls : 'x-btn-text-icon',
673 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
681 var s = _this.grid.getSelectionModel().getSelected();
683 Roo.MessageBox.alert("Error", "Select an order to copy");
688 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
690 // get the id from the data, then
692 _this.grid.footer.onClick('first');
693 Pman.Tab.XtupleSales.grid.footer.onClick('first');
694 // get the id from the data, then start editing it..
696 _this.dialog.show(data, function() {
697 _this.grid.footer.onClick('refresh');
698 Pman.Tab.XtupleSales.grid.footer.onClick('first');
704 cls : 'x-btn-text-icon',
706 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
712 xtype: 'ColumnModel',
714 dataIndex : 'cohead_orderdate',
718 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
721 xtype: 'ColumnModel',
723 dataIndex : 'cohead_targetdate',
724 header : 'Target Delivery',
728 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
731 xtype: 'ColumnModel',
733 dataIndex : 'cohead_salesrep_id_salesrep_name',
734 header : 'Staff IC.',
737 renderer : function(v,x,r) {
739 if (r.data.cohead_display_salesrep_id) {
740 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
742 return String.format('{0}', v );
748 xtype: 'ColumnModel',
750 dataIndex : 'cohead_number',
754 renderer : function(v,x,r) {
757 // we want to show more detail about status..
758 // like payment status / delivery etc...
762 // S = shipped (or partial shipped)
763 // P = paid (or partial paid)
764 // online payment failed? >> on terms?
767 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
768 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
769 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
770 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
771 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
772 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
773 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
780 if (r.data.cohead_qtyunshipped > 0) {
782 tg += (r.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
785 tg += tags.stock_shipped;
788 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
789 // ?? partially invoiced??
792 if (r.data.cohead_qtyuninvoiced*1 < 1) {
793 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
800 if (r.data.cohead_status == 'C') {
801 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
803 if (r.data.cohead_status == 'X') {
804 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
806 return tg + ' ' + String.format('{0}', v);
810 xtype: 'ColumnModel',
812 dataIndex : 'cohead_cust_id_cust_number',
813 header : 'Customer#',
816 renderer : function(v) { return String.format('{0}', v); }
819 xtype: 'ColumnModel',
821 dataIndex : 'cohead_cust_id_cust_name',
825 renderer : function(v) { return String.format('{0}', v); }
828 xtype: 'ColumnModel',
830 dataIndex : 'cohead_custponumber',
831 header : 'Cust. PO#',
833 renderer : function(v) { return String.format('{0}', v); }
836 xtype: 'ColumnModel',
838 dataIndex : 'cohead_type',
841 renderer : function(v) { return String.format('{0}', v); }
844 xtype: 'ColumnModel',
846 dataIndex : 'cohead_src_locations',
849 renderer : function(v) { return String.format('{0}', v); }
852 xtype: 'ColumnModel',
854 dataIndex : 'cohead_shiptoaddress1',
857 renderer : function(v) { return String.format('{0}', v); }
860 xtype: 'ColumnModel',
862 dataIndex : 'cohead_terms_id_terms_descrip',
865 renderer : function(v) { return String.format('{0}', v); }
868 xtype: 'ColumnModel',
871 dataIndex : 'cohead_total',
874 renderer : function(v,x,r) {
875 var ret = String.format('{0} {1}',
876 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
879 if (parseInt(r.data.cohead_qtyordered) != 0 &&
880 parseInt(r.data.cohead_unshipped) == 0 &&
881 parseInt(r.data.cohead_qtyunshipped) == 0 &&
882 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
883 parseInt(r.data.cohead_unshipped) == 0 &&
884 parseInt(r.data.cohead_uninvoiced) == 0
889 return String.format('<b style="color:red" ' +
890 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
892 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
893 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
902 xtype: 'ContentPanel',
911 rendered : function (form)
918 style : 'margin:5px;',
924 select : function (combo, record, index)
926 _this.grid.footer.onClick('first');
928 render : function (_self)
930 _this.viewtypeSel = _self;
934 displayField : 'value',
936 emptyText : "View type",
938 forceSelection : true,
940 loadingText : "Searching...",
944 qtip : "Select Action",
945 queryParam : 'query[action]',
946 selectOnFocus : true,
947 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
948 triggerAction : 'all',
954 xtype: 'SimpleStore',
958 [ 'MYOPEN', 'My Open orders' ],
959 [ 'MYCLOSED', 'My Closed orders' ],
960 [ 'MYALL', 'My orders (all)' ],
961 [ 'MYVOID', 'My Voided orders' ],
962 [ 'OPEN', 'All Open orders' ],
963 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
964 [ 'NOTPAID', 'All Un-paid orders' ],
965 [ 'CLOSED', 'All Closed orders' ],
966 [ 'ALL', 'All orders' ],
967 [ 'VOID', 'Voided orders' ],
968 [ 'INCOMPLETE', 'Incomplete orders' ],
969 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
970 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
971 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
972 [ 'FIFOBUG', 'Problems with FIFO' ]
975 fields : [ 'key', 'value' ]
982 select : function (combo, record, index)
984 (function() { _this.grid.footer.onClick('first'); }).defer(100);
986 specialkey : function (_self, e)
988 //Roo.log(e.getKey());
989 if (e.getKey() == 13) {
990 (function() { _this.grid.footer.onClick('first'); }).defer(100);
992 _this.rsearch = true;
996 beforequery : function (combo, query, forceAll, cancel, e)
1000 _this.rsearch =false;
1007 displayField : 'cohead_number',
1009 emptyText : "Select Order",
1010 fieldLabel : 'Order #',
1011 forceSelection : false,
1013 loadingText : "Searching...",
1015 name : 'query[cohead_number]',
1017 qtip : "Select Order",
1018 queryParam : 'query[cohead_number]',
1019 selectOnFocus : true,
1020 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1021 triggerAction : 'all',
1023 valueField : 'cohead_number',
1029 beforeload : function (_self, o){
1030 o.params = o.params || {};
1031 o.params['_columns'] = 'cohead_number';
1036 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1041 url : baseURL + '/Roo/cohead.php'
1044 xtype: 'JsonReader',
1046 id : 'cohead_number',
1048 totalProperty : 'total',
1049 fields : ["cohead_number"]
1057 select : function (combo, record, index)
1059 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1063 displayField : 'cust_name',
1065 emptyText : "Select custinfo",
1066 fieldLabel : 'Customer',
1067 forceSelection : true,
1068 hiddenName : 'cohead_cust_id',
1070 loadingText : "Searching...",
1072 name : 'cohead_cust_id_cust_name',
1074 qtip : "Select custinfo",
1075 queryParam : 'query[cust_name]',
1076 selectOnFocus : true,
1077 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1078 triggerAction : 'all',
1080 valueField : 'cust_id',
1085 sortInfo : { direction : 'ASC', field: 'cust_name' },
1088 beforeload : function (_self, o){
1089 o.params = o.params || {};
1097 url : baseURL + '/Roo/custinfo.php'
1100 xtype: 'JsonReader',
1104 totalProperty : 'total',
1105 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1113 select : function (combo, date)
1115 _this.grid.footer.onClick('first');
1118 fieldLabel : 'From',
1127 select : function (combo, date)
1129 _this.grid.footer.onClick('first');
1152 click : function (_self, e)
1154 _this.grid.footer.onClick('first');
1158 icon : rootURL + '/Pman/templates/images/search.gif'
1164 click : function (_self, e)
1166 _this.form.reset('');
1169 _this.grid.footer.onClick('first');
1173 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1180 xtype: 'LayoutRegion',
1187 xtype: 'LayoutRegion',