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"
201 click : function (_self, e)
203 Pman.Dialog.Image.show(
205 _url : baseURL+'/Xtuple/Import/Magento',
210 Roo.MessageBox.alert("Notice", data);
211 _this.grid.footer.onClick('first');
217 text : "Magento Upload"
222 cls : 'x-btn-text-icon',
224 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
241 click : function (_self, e)
243 var from = _this.form.findField('_fromdate').getValue();
244 var to = _this.form.findField('_todate').getValue();
247 Roo.Msg.alert('Error', 'Please select a date range for the report');
253 filename : 'ARAging-' + to.format('Y-m-d'),
254 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
255 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
256 'param[2]': "useDocDate:number=1"
258 var cust_id = _this.form.findField('cohead_cust_id').getValue();
259 if (cust_id * 1 > 0) {
260 params['param[3]'] = 'cust_id:number=' + cust_id;
264 url : baseURL + '/Xtuple/Print',
268 Roo.MessageBox.alert("Notice", "Report will download shortly");
277 click : function (_self, e)
279 var from = _this.form.findField('_fromdate').getValue();
280 var to = _this.form.findField('_todate').getValue();
285 '_group' : 'arAging',
289 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
290 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
294 'useDocDate:text' : 'TRUE',
300 var cust_id = _this.form.findField('cohead_cust_id').getValue();
301 if (cust_id * 1 > 0) {
302 params['cust_id:number'] = cust_id;
305 new Pman.Download({
\r
306 url : baseURL + '/Roo/Metasql',
\r
310 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
320 click : function (_self, e)
322 var from = _this.form.findField('_fromdate').getValue();
323 var to = _this.form.findField('_todate').getValue();
328 '_group' : 'arAging',
334 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
335 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
338 'useDocDate:text' : 'TRUE',
343 var cust_id = _this.form.findField('cohead_cust_id').getValue();
344 if (cust_id * 1 > 0) {
345 params['cust_id:number'] = cust_id;
348 new Pman.Download({
\r
349 url : baseURL + '/Roo/Metasql',
\r
353 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
357 text : "Summary Excel"
365 text : "Customer History",
374 click : function (_self, e)
376 var cust_id = _this.form.findField('cohead_cust_id').getValue();
377 if (cust_id * 1 < 1) {
378 Roo.Msg.alert('Error', 'Please select a customer');
382 var from = _this.form.findField('_fromdate').getValue();
383 var to = _this.form.findField('_todate').getValue();
386 Roo.Msg.alert('Error', 'Please select a date range for the report');
391 template: 'customer_ar_history',
392 filename : 'customer_ar_history-' + to.format('Y-m-d'),
393 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
394 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
395 'param[2]': "cust_id:number=" + cust_id
399 url : baseURL + '/Xtuple/Print',
403 Roo.MessageBox.alert("Notice", "Report will download shortly");
412 click : function (_self, e)
414 var cust_id = _this.form.findField('cohead_cust_id').getValue();
415 if (cust_id * 1 < 1) {
416 Roo.Msg.alert('Error', 'Please select a customer');
420 var from = _this.form.findField('_fromdate').getValue();
421 var to = _this.form.findField('_todate').getValue();
426 '_group' : 'customerHistory',
430 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
431 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
433 'cust_id:number' : cust_id,
439 new Pman.Download({
\r
440 url : baseURL + '/Roo/Metasql',
\r
444 Roo.MessageBox.alert("Notice", "Report will download shortly");
455 text : "Customer Statement",
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 template: 'customer_ar_statement',
479 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
480 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
481 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
482 'param[2]': "cust_id:number=" + cust_id
486 url : baseURL + '/Xtuple/Print',
490 Roo.MessageBox.alert("Notice", "Report will download shortly");
499 click : function (_self, e)
501 var cust_id = _this.form.findField('cohead_cust_id').getValue();
502 if (cust_id * 1 < 1) {
503 Roo.Msg.alert('Error', 'Please select a customer');
507 var from = _this.form.findField('_fromdate').getValue();
508 var to = _this.form.findField('_todate').getValue();
511 // Roo.Msg.alert('Error', 'Please select a date range for the report');
516 '_group' : 'customerStatement',
519 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
520 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
521 'cust_id:number' : cust_id,
527 new Pman.Download({
\r
528 url : baseURL + '/Roo/Metasql',
\r
532 Roo.MessageBox.alert("Notice", "Report will download shortly");
547 click : function (_self, e)
549 var s = _this.grid.getSelectionModel().getSelected();
551 Roo.MessageBox.alert("Error", "Select an order");
555 new Pman.Download({
\r
556 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
558 cohead_id : s.data.cohead_id
563 Roo.MessageBox.alert("Notice", "Report will download shortly");
566 cls : 'x-btn-text-icon',
567 text : "Email to warehouse",
568 icon : Roo.rootURL + 'images/default/dd/email.gif'
576 var s = _this.grid.getSelectionModel().getSelected();
578 Roo.MessageBox.alert("Error", "Select an order to close");
582 if(s.data.cohead_status == 'C'){
583 Roo.MessageBox.alert("Error", "This order has been closed");
588 url: baseURL + '/Roo/cohead',
591 cohead_id : s.data.cohead_id,
597 Roo.MessageBox.alert("Notice", "DONE");
598 _this.grid.footer.onClick('first');
604 cls : 'x-btn-text-icon',
605 text : "Complete and Close",
606 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
618 // check if the login in user have more than 25 open orders..
619 // if yes, warning...
621 url : baseURL + '/Roo/cohead.php',
625 _count_order : 1 // make the search faster!
627 success : function(res) {
628 if(res.data[0].order_totals * 1 > 25){
629 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
634 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
635 _this.grid.footer.onClick('first');
639 cls : 'x-btn-text-icon',
641 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
649 var s = _this.grid.getSelectionModel().getSelected();
651 Roo.MessageBox.alert("Error", "Select an order to copy");
656 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
658 // get the id from the data, then
660 _this.grid.footer.onClick('first');
661 Pman.Tab.XtupleSales.grid.footer.onClick('first');
662 // get the id from the data, then start editing it..
664 _this.dialog.show(data, function() {
665 _this.grid.footer.onClick('refresh');
666 Pman.Tab.XtupleSales.grid.footer.onClick('first');
672 cls : 'x-btn-text-icon',
674 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
680 xtype: 'ColumnModel',
682 dataIndex : 'cohead_orderdate',
686 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
689 xtype: 'ColumnModel',
691 dataIndex : 'cohead_targetdate',
692 header : 'Target Delivery',
696 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
699 xtype: 'ColumnModel',
701 dataIndex : 'cohead_salesrep_id_salesrep_name',
702 header : 'Staff IC.',
705 renderer : function(v,x,r) {
707 if (r.data.cohead_display_salesrep_id) {
708 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
710 return String.format('{0}', v );
716 xtype: 'ColumnModel',
718 dataIndex : 'cohead_number',
722 renderer : function(v,x,r) {
725 // we want to show more detail about status..
726 // like payment status / delivery etc...
730 // S = shipped (or partial shipped)
731 // P = paid (or partial paid)
732 // online payment failed? >> on terms?
735 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
736 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
737 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
738 stock_reserved : '<span class="dragon-so-complete-not" qtip="Stock Reserved / Not shipped">R</span>',
739 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
740 paid : '<span class="dragon-so-complete" qtip="Paid">$</span>',
741 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">$</span>'
746 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
747 // ?? partially invoiced??
750 tg += (r.data.cohead_qtyunshipped > 0) ? tags.stock_not : tags.stock_shipped;
754 if (r.data.cohead_status == 'C') {
755 return String.format('<i qtip="closed">{0}</i>', v) + tg
757 if (r.data.cohead_status == 'X') {
758 return String.format('<s qtip="void">{0}</s>', v) + tg ;
760 return String.format('{0}', v) + tg ;
764 xtype: 'ColumnModel',
766 dataIndex : 'cohead_cust_id_cust_number',
767 header : 'Customer#',
770 renderer : function(v) { return String.format('{0}', v); }
773 xtype: 'ColumnModel',
775 dataIndex : 'cohead_cust_id_cust_name',
779 renderer : function(v) { return String.format('{0}', v); }
782 xtype: 'ColumnModel',
784 dataIndex : 'cohead_custponumber',
785 header : 'Cust. PO#',
787 renderer : function(v) { return String.format('{0}', v); }
790 xtype: 'ColumnModel',
792 dataIndex : 'cohead_type',
795 renderer : function(v) { return String.format('{0}', v); }
798 xtype: 'ColumnModel',
800 dataIndex : 'cohead_src_locations',
803 renderer : function(v) { return String.format('{0}', v); }
806 xtype: 'ColumnModel',
808 dataIndex : 'cohead_shiptoaddress1',
811 renderer : function(v) { return String.format('{0}', v); }
814 xtype: 'ColumnModel',
816 dataIndex : 'cohead_terms_id_terms_descrip',
819 renderer : function(v) { return String.format('{0}', v); }
822 xtype: 'ColumnModel',
825 dataIndex : 'cohead_total',
828 renderer : function(v,x,r) {
829 var ret = String.format('{0} {1}',
830 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
833 if (parseInt(r.data.cohead_qtyordered) != 0 &&
834 parseInt(r.data.cohead_unshipped) == 0 &&
835 parseInt(r.data.cohead_qtyunshipped) == 0 &&
836 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
837 parseInt(r.data.cohead_unshipped) == 0 &&
838 parseInt(r.data.cohead_uninvoiced) == 0
843 return String.format('<b style="color:red" ' +
844 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
846 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
847 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
856 xtype: 'ContentPanel',
865 rendered : function (form)
872 style : 'margin:5px;',
878 select : function (combo, record, index)
880 _this.grid.footer.onClick('first');
882 render : function (_self)
884 _this.viewtypeSel = _self;
888 displayField : 'value',
890 emptyText : "View type",
892 forceSelection : true,
894 loadingText : "Searching...",
898 qtip : "Select Action",
899 queryParam : 'query[action]',
900 selectOnFocus : true,
901 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
902 triggerAction : 'all',
908 xtype: 'SimpleStore',
912 [ 'MYOPEN', 'My Open orders' ],
913 [ 'MYCLOSED', 'My Closed orders' ],
914 [ 'MYALL', 'My orders (all)' ],
915 [ 'MYVOID', 'My Voided orders' ],
916 [ 'OPEN', 'All Open orders' ],
917 [ 'CLOSED', 'All Closed orders' ],
918 [ 'ALL', 'All orders' ],
919 [ 'VOID', 'Voided orders' ],
920 [ 'INCOMPLETE', 'Incomplete orders' ],
921 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
922 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
923 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
924 [ 'FIFOBUG', 'Problems with FIFO' ]
927 fields : [ 'key', 'value' ]
934 select : function (combo, record, index)
936 (function() { _this.grid.footer.onClick('first'); }).defer(100);
938 specialkey : function (_self, e)
940 //Roo.log(e.getKey());
941 if (e.getKey() == 13) {
942 (function() { _this.grid.footer.onClick('first'); }).defer(100);
944 _this.rsearch = true;
948 beforequery : function (combo, query, forceAll, cancel, e)
952 _this.rsearch =false;
959 displayField : 'cohead_number',
961 emptyText : "Select Order",
962 fieldLabel : 'Order #',
963 forceSelection : false,
965 loadingText : "Searching...",
967 name : 'query[cohead_number]',
969 qtip : "Select Order",
970 queryParam : 'query[cohead_number]',
971 selectOnFocus : true,
972 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
973 triggerAction : 'all',
975 valueField : 'cohead_number',
981 beforeload : function (_self, o){
982 o.params = o.params || {};
983 o.params['_columns'] = 'cohead_number';
988 sortInfo : { direction : 'ASC', field: 'cohead_number' },
993 url : baseURL + '/Roo/cohead.php'
998 id : 'cohead_number',
1000 totalProperty : 'total',
1001 fields : ["cohead_number"]
1009 select : function (combo, record, index)
1011 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1015 displayField : 'cust_name',
1017 emptyText : "Select custinfo",
1018 fieldLabel : 'Customer',
1019 forceSelection : true,
1020 hiddenName : 'cohead_cust_id',
1022 loadingText : "Searching...",
1024 name : 'cohead_cust_id_cust_name',
1026 qtip : "Select custinfo",
1027 queryParam : 'query[cust_name]',
1028 selectOnFocus : true,
1029 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1030 triggerAction : 'all',
1032 valueField : 'cust_id',
1037 sortInfo : { direction : 'ASC', field: 'cust_name' },
1040 beforeload : function (_self, o){
1041 o.params = o.params || {};
1049 url : baseURL + '/Roo/custinfo.php'
1052 xtype: 'JsonReader',
1056 totalProperty : 'total',
1057 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1065 select : function (combo, date)
1067 _this.grid.footer.onClick('first');
1070 fieldLabel : 'From',
1079 select : function (combo, date)
1081 _this.grid.footer.onClick('first');
1104 click : function (_self, e)
1106 _this.grid.footer.onClick('first');
1110 icon : rootURL + '/Pman/templates/images/search.gif'
1116 click : function (_self, e)
1118 _this.form.reset('');
1121 _this.grid.footer.onClick('first');
1125 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1132 xtype: 'LayoutRegion',
1139 xtype: 'LayoutRegion',