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"
209 click : function (_self, e)
211 Pman.Dialog.Image.show(
213 _url : baseURL+'/Xtuple/Import/Magento',
218 Roo.MessageBox.alert("Notice", data);
219 _this.grid.footer.onClick('first');
225 text : "Magento Upload"
237 cls : 'x-btn-text-icon',
239 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
256 click : function (_self, e)
258 var from = _this.form.findField('_fromdate').getValue();
259 var to = _this.form.findField('_todate').getValue();
262 Roo.Msg.alert('Error', 'Please select a date range for the report');
268 filename : 'ARAging-' + to.format('Y-m-d'),
269 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
270 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
271 'param[2]': "useDocDate:number=1"
273 var cust_id = _this.form.findField('cohead_cust_id').getValue();
274 if (cust_id * 1 > 0) {
275 params['param[3]'] = 'cust_id:number=' + cust_id;
279 url : baseURL + '/Xtuple/Print',
283 Roo.MessageBox.alert("Notice", "Report will download shortly");
292 click : function (_self, e)
294 var from = _this.form.findField('_fromdate').getValue();
295 var to = _this.form.findField('_todate').getValue();
300 '_group' : 'arAging',
304 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
305 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
309 'useDocDate:text' : 'TRUE',
315 var cust_id = _this.form.findField('cohead_cust_id').getValue();
316 if (cust_id * 1 > 0) {
317 params['cust_id:number'] = cust_id;
320 new Pman.Download({
\r
321 url : baseURL + '/Roo/Metasql',
\r
325 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
335 click : function (_self, e)
337 var from = _this.form.findField('_fromdate').getValue();
338 var to = _this.form.findField('_todate').getValue();
343 '_group' : 'arAging',
349 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
350 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
353 'useDocDate:text' : 'TRUE',
358 var cust_id = _this.form.findField('cohead_cust_id').getValue();
359 if (cust_id * 1 > 0) {
360 params['cust_id:number'] = cust_id;
363 new Pman.Download({
\r
364 url : baseURL + '/Roo/Metasql',
\r
368 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
372 text : "Summary Excel"
380 text : "Customer History",
389 click : function (_self, e)
391 var cust_id = _this.form.findField('cohead_cust_id').getValue();
392 if (cust_id * 1 < 1) {
393 Roo.Msg.alert('Error', 'Please select a customer');
397 var from = _this.form.findField('_fromdate').getValue();
398 var to = _this.form.findField('_todate').getValue();
401 Roo.Msg.alert('Error', 'Please select a date range for the report');
406 template: 'customer_ar_history',
407 filename : 'customer_ar_history-' + to.format('Y-m-d'),
408 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
409 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
410 'param[2]': "cust_id:number=" + cust_id
414 url : baseURL + '/Xtuple/Print',
418 Roo.MessageBox.alert("Notice", "Report will download shortly");
427 click : function (_self, e)
429 var cust_id = _this.form.findField('cohead_cust_id').getValue();
430 if (cust_id * 1 < 1) {
431 Roo.Msg.alert('Error', 'Please select a customer');
435 var from = _this.form.findField('_fromdate').getValue();
436 var to = _this.form.findField('_todate').getValue();
441 '_group' : 'customerHistory',
445 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
446 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
448 'cust_id:number' : cust_id,
454 new Pman.Download({
\r
455 url : baseURL + '/Roo/Metasql',
\r
459 Roo.MessageBox.alert("Notice", "Report will download shortly");
470 text : "Customer Statement",
479 click : function (_self, e)
481 var cust_id = _this.form.findField('cohead_cust_id').getValue();
482 if (cust_id * 1 < 1) {
483 Roo.Msg.alert('Error', 'Please select a customer');
487 var from = _this.form.findField('_fromdate').getValue();
488 var to = _this.form.findField('_todate').getValue();
493 template: 'customer_ar_statement',
494 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
495 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
496 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
497 'param[2]': "cust_id:number=" + cust_id
501 url : baseURL + '/Xtuple/Print',
505 Roo.MessageBox.alert("Notice", "Report will download shortly");
514 click : function (_self, e)
516 var cust_id = _this.form.findField('cohead_cust_id').getValue();
517 if (cust_id * 1 < 1) {
518 Roo.Msg.alert('Error', 'Please select a customer');
522 var from = _this.form.findField('_fromdate').getValue();
523 var to = _this.form.findField('_todate').getValue();
526 // Roo.Msg.alert('Error', 'Please select a date range for the report');
531 '_group' : 'customerStatement',
534 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
535 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
536 'cust_id:number' : cust_id,
542 new Pman.Download({
\r
543 url : baseURL + '/Roo/Metasql',
\r
547 Roo.MessageBox.alert("Notice", "Report will download shortly");
562 click : function (_self, e)
564 var sels = _this.grid.getSelectionModel().getSelections();
567 Roo.MessageBox.alert("Error", "Select an order");
571 for (var i =0; i < sels.length; i++) {
574 if(s.data.cohead_qtyuninvoiced * 1 > 0){
575 Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
579 if(s.data.aropen_unpaid * 1 > 0){
580 Roo.MessageBox.alert("Error", "Order has not been paid! - " + s.data.cohead_number);
583 ids.push(s.data.cohead_id);
586 new Pman.Download({
\r
587 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
589 cohead_id : ids.join(',')
594 Roo.MessageBox.alert("Notice", "Report will download shortly");
597 cls : 'x-btn-text-icon',
598 text : "Email to warehouse",
599 icon : Roo.rootURL + 'images/default/dd/email.gif'
607 var s = _this.grid.getSelectionModel().getSelected();
609 Roo.MessageBox.alert("Error", "Select an order to close");
613 if(s.data.cohead_status == 'C'){
614 Roo.MessageBox.alert("Error", "This order has been closed");
619 url: baseURL + '/Roo/cohead',
622 cohead_id : s.data.cohead_id,
628 Roo.MessageBox.alert("Notice", "DONE");
629 _this.grid.footer.onClick('first');
635 cls : 'x-btn-text-icon',
636 text : "Complete and Close",
637 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
649 // check if the login in user have more than 25 open orders..
650 // if yes, warning...
652 url : baseURL + '/Roo/cohead.php',
656 _count_order : 1 // make the search faster!
658 success : function(res) {
659 if(res.data[0].order_totals * 1 > 25){
660 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
665 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
666 _this.grid.footer.onClick('first');
670 cls : 'x-btn-text-icon',
672 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
680 var s = _this.grid.getSelectionModel().getSelected();
682 Roo.MessageBox.alert("Error", "Select an order to copy");
687 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
689 // get the id from the data, then
691 _this.grid.footer.onClick('first');
692 Pman.Tab.XtupleSales.grid.footer.onClick('first');
693 // get the id from the data, then start editing it..
695 _this.dialog.show(data, function() {
696 _this.grid.footer.onClick('refresh');
697 Pman.Tab.XtupleSales.grid.footer.onClick('first');
703 cls : 'x-btn-text-icon',
705 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
711 xtype: 'ColumnModel',
713 dataIndex : 'cohead_orderdate',
717 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
720 xtype: 'ColumnModel',
722 dataIndex : 'cohead_targetdate',
723 header : 'Target Delivery',
727 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
730 xtype: 'ColumnModel',
732 dataIndex : 'cohead_salesrep_id_salesrep_name',
733 header : 'Staff IC.',
736 renderer : function(v,x,r) {
738 if (r.data.cohead_display_salesrep_id) {
739 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
741 return String.format('{0}', v );
747 xtype: 'ColumnModel',
749 dataIndex : 'cohead_number',
753 renderer : function(v,x,r) {
756 // we want to show more detail about status..
757 // like payment status / delivery etc...
761 // S = shipped (or partial shipped)
762 // P = paid (or partial paid)
763 // online payment failed? >> on terms?
766 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
767 invoiced_not : '<span class="dragon-so-complete-not" qtip="Not Invoiced">I</span>',
768 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',
769 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
770 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
771 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
772 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
779 if (r.data.cohead_qtyunshipped > 0) {
781 tg += (r.data.shipitem_qty*1 > 0) ? tags.stock_reserved :tags.stock_not;
784 tg += tags.stock_shipped;
787 tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
788 // ?? partially invoiced??
791 if (r.data.cohead_qtyuninvoiced*1 < 1) {
792 tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
799 if (r.data.cohead_status == 'C') {
800 return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v);
802 if (r.data.cohead_status == 'X') {
803 return tg + ' ' + String.format('<s qtip="void">{0}</s>', v) ;
805 return tg + ' ' + String.format('{0}', v);
809 xtype: 'ColumnModel',
811 dataIndex : 'cohead_cust_id_cust_number',
812 header : 'Customer#',
815 renderer : function(v) { return String.format('{0}', v); }
818 xtype: 'ColumnModel',
820 dataIndex : 'cohead_cust_id_cust_name',
824 renderer : function(v) { return String.format('{0}', v); }
827 xtype: 'ColumnModel',
829 dataIndex : 'cohead_custponumber',
830 header : 'Cust. PO#',
832 renderer : function(v) { return String.format('{0}', v); }
835 xtype: 'ColumnModel',
837 dataIndex : 'cohead_type',
840 renderer : function(v) { return String.format('{0}', v); }
843 xtype: 'ColumnModel',
845 dataIndex : 'cohead_src_locations',
848 renderer : function(v) { return String.format('{0}', v); }
851 xtype: 'ColumnModel',
853 dataIndex : 'cohead_shiptoaddress1',
856 renderer : function(v) { return String.format('{0}', v); }
859 xtype: 'ColumnModel',
861 dataIndex : 'cohead_terms_id_terms_descrip',
864 renderer : function(v) { return String.format('{0}', v); }
867 xtype: 'ColumnModel',
870 dataIndex : 'cohead_total',
873 renderer : function(v,x,r) {
874 var ret = String.format('{0} {1}',
875 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
878 if (parseInt(r.data.cohead_qtyordered) != 0 &&
879 parseInt(r.data.cohead_unshipped) == 0 &&
880 parseInt(r.data.cohead_qtyunshipped) == 0 &&
881 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
882 parseInt(r.data.cohead_unshipped) == 0 &&
883 parseInt(r.data.cohead_uninvoiced) == 0
888 return String.format('<b style="color:red" ' +
889 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
891 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
892 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
901 xtype: 'ContentPanel',
910 rendered : function (form)
917 style : 'margin:5px;',
923 select : function (combo, record, index)
925 _this.grid.footer.onClick('first');
927 render : function (_self)
929 _this.viewtypeSel = _self;
933 displayField : 'value',
935 emptyText : "View type",
937 forceSelection : true,
939 loadingText : "Searching...",
943 qtip : "Select Action",
944 queryParam : 'query[action]',
945 selectOnFocus : true,
946 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
947 triggerAction : 'all',
953 xtype: 'SimpleStore',
957 [ 'MYOPEN', 'My Open orders' ],
958 [ 'MYCLOSED', 'My Closed orders' ],
959 [ 'MYALL', 'My orders (all)' ],
960 [ 'MYVOID', 'My Voided orders' ],
961 [ 'OPEN', 'All Open orders' ],
962 [ 'NOTSHIPPED', 'All Un-shipped orders' ],
963 [ 'NOTPAID', 'All Un-paid orders' ],
964 [ 'CLOSED', 'All Closed orders' ],
965 [ 'ALL', 'All orders' ],
966 [ 'VOID', 'Voided orders' ],
967 [ 'INCOMPLETE', 'Incomplete orders' ],
968 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
969 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
970 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
971 [ 'FIFOBUG', 'Problems with FIFO' ]
974 fields : [ 'key', 'value' ]
981 select : function (combo, record, index)
983 (function() { _this.grid.footer.onClick('first'); }).defer(100);
985 specialkey : function (_self, e)
987 //Roo.log(e.getKey());
988 if (e.getKey() == 13) {
989 (function() { _this.grid.footer.onClick('first'); }).defer(100);
991 _this.rsearch = true;
995 beforequery : function (combo, query, forceAll, cancel, e)
999 _this.rsearch =false;
1006 displayField : 'cohead_number',
1008 emptyText : "Select Order",
1009 fieldLabel : 'Order #',
1010 forceSelection : false,
1012 loadingText : "Searching...",
1014 name : 'query[cohead_number]',
1016 qtip : "Select Order",
1017 queryParam : 'query[cohead_number]',
1018 selectOnFocus : true,
1019 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1020 triggerAction : 'all',
1022 valueField : 'cohead_number',
1028 beforeload : function (_self, o){
1029 o.params = o.params || {};
1030 o.params['_columns'] = 'cohead_number';
1035 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1040 url : baseURL + '/Roo/cohead.php'
1043 xtype: 'JsonReader',
1045 id : 'cohead_number',
1047 totalProperty : 'total',
1048 fields : ["cohead_number"]
1056 select : function (combo, record, index)
1058 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1062 displayField : 'cust_name',
1064 emptyText : "Select custinfo",
1065 fieldLabel : 'Customer',
1066 forceSelection : true,
1067 hiddenName : 'cohead_cust_id',
1069 loadingText : "Searching...",
1071 name : 'cohead_cust_id_cust_name',
1073 qtip : "Select custinfo",
1074 queryParam : 'query[cust_name]',
1075 selectOnFocus : true,
1076 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1077 triggerAction : 'all',
1079 valueField : 'cust_id',
1084 sortInfo : { direction : 'ASC', field: 'cust_name' },
1087 beforeload : function (_self, o){
1088 o.params = o.params || {};
1096 url : baseURL + '/Roo/custinfo.php'
1099 xtype: 'JsonReader',
1103 totalProperty : 'total',
1104 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1112 select : function (combo, date)
1114 _this.grid.footer.onClick('first');
1117 fieldLabel : 'From',
1126 select : function (combo, date)
1128 _this.grid.footer.onClick('first');
1151 click : function (_self, e)
1153 _this.grid.footer.onClick('first');
1157 icon : rootURL + '/Pman/templates/images/search.gif'
1163 click : function (_self, e)
1165 _this.form.reset('');
1168 _this.grid.footer.onClick('first');
1172 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1179 xtype: 'LayoutRegion',
1186 xtype: 'LayoutRegion',