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">P</span>',
741 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
748 if (r.data.cohead_qtyunshipped > 0) {
750 tg += (rd.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
753 tg += tags.stock_shipped;
756 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
757 // ?? partially invoiced??
760 if (r.data.cohead_qtyuninvoiced*1 < 1) {
761 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
768 if (r.data.cohead_status == 'C') {
769 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
771 if (r.data.cohead_status == 'X') {
772 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
774 return tg + ' ' + String.format('{0}', v);
778 xtype: 'ColumnModel',
780 dataIndex : 'cohead_cust_id_cust_number',
781 header : 'Customer#',
784 renderer : function(v) { return String.format('{0}', v); }
787 xtype: 'ColumnModel',
789 dataIndex : 'cohead_cust_id_cust_name',
793 renderer : function(v) { return String.format('{0}', v); }
796 xtype: 'ColumnModel',
798 dataIndex : 'cohead_custponumber',
799 header : 'Cust. PO#',
801 renderer : function(v) { return String.format('{0}', v); }
804 xtype: 'ColumnModel',
806 dataIndex : 'cohead_type',
809 renderer : function(v) { return String.format('{0}', v); }
812 xtype: 'ColumnModel',
814 dataIndex : 'cohead_src_locations',
817 renderer : function(v) { return String.format('{0}', v); }
820 xtype: 'ColumnModel',
822 dataIndex : 'cohead_shiptoaddress1',
825 renderer : function(v) { return String.format('{0}', v); }
828 xtype: 'ColumnModel',
830 dataIndex : 'cohead_terms_id_terms_descrip',
833 renderer : function(v) { return String.format('{0}', v); }
836 xtype: 'ColumnModel',
839 dataIndex : 'cohead_total',
842 renderer : function(v,x,r) {
843 var ret = String.format('{0} {1}',
844 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
847 if (parseInt(r.data.cohead_qtyordered) != 0 &&
848 parseInt(r.data.cohead_unshipped) == 0 &&
849 parseInt(r.data.cohead_qtyunshipped) == 0 &&
850 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
851 parseInt(r.data.cohead_unshipped) == 0 &&
852 parseInt(r.data.cohead_uninvoiced) == 0
857 return String.format('<b style="color:red" ' +
858 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
860 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
861 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
870 xtype: 'ContentPanel',
879 rendered : function (form)
886 style : 'margin:5px;',
892 select : function (combo, record, index)
894 _this.grid.footer.onClick('first');
896 render : function (_self)
898 _this.viewtypeSel = _self;
902 displayField : 'value',
904 emptyText : "View type",
906 forceSelection : true,
908 loadingText : "Searching...",
912 qtip : "Select Action",
913 queryParam : 'query[action]',
914 selectOnFocus : true,
915 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
916 triggerAction : 'all',
922 xtype: 'SimpleStore',
926 [ 'MYOPEN', 'My Open orders' ],
927 [ 'MYCLOSED', 'My Closed orders' ],
928 [ 'MYALL', 'My orders (all)' ],
929 [ 'MYVOID', 'My Voided orders' ],
930 [ 'OPEN', 'All Open orders' ],
931 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
932 [ 'NOTPAID', 'All Un-paid orders' ],
933 [ 'CLOSED', 'All Closed orders' ],
934 [ 'ALL', 'All orders' ],
935 [ 'VOID', 'Voided orders' ],
936 [ 'INCOMPLETE', 'Incomplete orders' ],
937 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
938 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
939 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
940 [ 'FIFOBUG', 'Problems with FIFO' ]
943 fields : [ 'key', 'value' ]
950 select : function (combo, record, index)
952 (function() { _this.grid.footer.onClick('first'); }).defer(100);
954 specialkey : function (_self, e)
956 //Roo.log(e.getKey());
957 if (e.getKey() == 13) {
958 (function() { _this.grid.footer.onClick('first'); }).defer(100);
960 _this.rsearch = true;
964 beforequery : function (combo, query, forceAll, cancel, e)
968 _this.rsearch =false;
975 displayField : 'cohead_number',
977 emptyText : "Select Order",
978 fieldLabel : 'Order #',
979 forceSelection : false,
981 loadingText : "Searching...",
983 name : 'query[cohead_number]',
985 qtip : "Select Order",
986 queryParam : 'query[cohead_number]',
987 selectOnFocus : true,
988 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
989 triggerAction : 'all',
991 valueField : 'cohead_number',
997 beforeload : function (_self, o){
998 o.params = o.params || {};
999 o.params['_columns'] = 'cohead_number';
1004 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1009 url : baseURL + '/Roo/cohead.php'
1012 xtype: 'JsonReader',
1014 id : 'cohead_number',
1016 totalProperty : 'total',
1017 fields : ["cohead_number"]
1025 select : function (combo, record, index)
1027 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1031 displayField : 'cust_name',
1033 emptyText : "Select custinfo",
1034 fieldLabel : 'Customer',
1035 forceSelection : true,
1036 hiddenName : 'cohead_cust_id',
1038 loadingText : "Searching...",
1040 name : 'cohead_cust_id_cust_name',
1042 qtip : "Select custinfo",
1043 queryParam : 'query[cust_name]',
1044 selectOnFocus : true,
1045 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1046 triggerAction : 'all',
1048 valueField : 'cust_id',
1053 sortInfo : { direction : 'ASC', field: 'cust_name' },
1056 beforeload : function (_self, o){
1057 o.params = o.params || {};
1065 url : baseURL + '/Roo/custinfo.php'
1068 xtype: 'JsonReader',
1072 totalProperty : 'total',
1073 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1081 select : function (combo, date)
1083 _this.grid.footer.onClick('first');
1086 fieldLabel : 'From',
1095 select : function (combo, date)
1097 _this.grid.footer.onClick('first');
1120 click : function (_self, e)
1122 _this.grid.footer.onClick('first');
1126 icon : rootURL + '/Pman/templates/images/search.gif'
1132 click : function (_self, e)
1134 _this.form.reset('');
1137 _this.grid.footer.onClick('first');
1141 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1148 xtype: 'LayoutRegion',
1155 xtype: 'LayoutRegion',