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"
223 text : "Magento Upload",
232 click : function (_self, e)
234 Pman.Dialog.Image.show(
236 _url : baseURL+'/Xtuple/Import/MagentoOld',
242 Roo.MessageBox.alert("Notice", data);
243 _this.grid.footer.onClick('first');
247 msg.push("Updated " + data.updated + " Products(s)");
250 msg.push("Added " + data.inserted + " Products(s)");
253 msg.push("Skipped " + data.skipped);
257 msg.push("No data changed");
259 Roo.MessageBox.alert("Notice", msg.join("\n")); */
265 text : "Upload Magento File (Old Format)"
271 click : function (_self, e)
273 Pman.Dialog.Image.show(
275 _url : baseURL+'/Xtuple/Import/Magento',
280 Roo.MessageBox.alert("Notice", data);
281 _this.grid.footer.onClick('first');
287 text : "Upload Magento File (New Format)"
295 cls : 'x-btn-text-icon',
297 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
314 click : function (_self, e)
316 var from = _this.form.findField('_fromdate').getValue();
317 var to = _this.form.findField('_todate').getValue();
320 Roo.Msg.alert('Error', 'Please select a date range for the report');
326 filename : 'ARAging-' + to.format('Y-m-d'),
327 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
328 'param[1]': "relDate:string='" + to.format('Y-m-d') + "'",
329 'param[2]': "useDocDate:number=1"
331 var cust_id = _this.form.findField('cohead_cust_id').getValue();
332 if (cust_id * 1 > 0) {
333 params['param[3]'] = 'cust_id:number=' + cust_id;
337 url : baseURL + '/Xtuple/Print',
341 Roo.MessageBox.alert("Notice", "Report will download shortly");
350 click : function (_self, e)
352 var from = _this.form.findField('_fromdate').getValue();
353 var to = _this.form.findField('_todate').getValue();
358 '_group' : 'arAging',
362 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
363 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
367 'useDocDate:text' : 'TRUE',
373 var cust_id = _this.form.findField('cohead_cust_id').getValue();
374 if (cust_id * 1 > 0) {
375 params['cust_id:number'] = cust_id;
378 new Pman.Download({
\r
379 url : baseURL + '/Roo/Metasql',
\r
383 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
393 click : function (_self, e)
395 var from = _this.form.findField('_fromdate').getValue();
396 var to = _this.form.findField('_todate').getValue();
401 '_group' : 'arAging',
407 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
408 'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
411 'useDocDate:text' : 'TRUE',
416 var cust_id = _this.form.findField('cohead_cust_id').getValue();
417 if (cust_id * 1 > 0) {
418 params['cust_id:number'] = cust_id;
421 new Pman.Download({
\r
422 url : baseURL + '/Roo/Metasql',
\r
426 Roo.MessageBox.alert("Notice", "Report will download shortly");
\r
430 text : "Summary Excel"
438 text : "Customer History",
447 click : function (_self, e)
449 var cust_id = _this.form.findField('cohead_cust_id').getValue();
450 if (cust_id * 1 < 1) {
451 Roo.Msg.alert('Error', 'Please select a customer');
455 var from = _this.form.findField('_fromdate').getValue();
456 var to = _this.form.findField('_todate').getValue();
459 Roo.Msg.alert('Error', 'Please select a date range for the report');
464 template: 'customer_ar_history',
465 filename : 'customer_ar_history-' + to.format('Y-m-d'),
466 'param[0]': "startDate:string='" + from.format('Y-m-d') + "'",
467 'param[1]': "endDate:string='" + to.format('Y-m-d') + "'",
468 'param[2]': "cust_id:number=" + cust_id
472 url : baseURL + '/Xtuple/Print',
476 Roo.MessageBox.alert("Notice", "Report will download shortly");
485 click : function (_self, e)
487 var cust_id = _this.form.findField('cohead_cust_id').getValue();
488 if (cust_id * 1 < 1) {
489 Roo.Msg.alert('Error', 'Please select a customer');
493 var from = _this.form.findField('_fromdate').getValue();
494 var to = _this.form.findField('_todate').getValue();
499 '_group' : 'customerHistory',
503 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
504 'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
506 'cust_id:number' : cust_id,
512 new Pman.Download({
\r
513 url : baseURL + '/Roo/Metasql',
\r
517 Roo.MessageBox.alert("Notice", "Report will download shortly");
528 text : "Customer Statement",
537 click : function (_self, e)
539 var cust_id = _this.form.findField('cohead_cust_id').getValue();
540 if (cust_id * 1 < 1) {
541 Roo.Msg.alert('Error', 'Please select a customer');
545 var from = _this.form.findField('_fromdate').getValue();
546 var to = _this.form.findField('_todate').getValue();
551 template: 'customer_ar_statement',
552 filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
553 'param[0]': "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
554 'param[1]': "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
555 'param[2]': "cust_id:number=" + cust_id
559 url : baseURL + '/Xtuple/Print',
563 Roo.MessageBox.alert("Notice", "Report will download shortly");
572 click : function (_self, e)
574 var cust_id = _this.form.findField('cohead_cust_id').getValue();
575 if (cust_id * 1 < 1) {
576 Roo.Msg.alert('Error', 'Please select a customer');
580 var from = _this.form.findField('_fromdate').getValue();
581 var to = _this.form.findField('_todate').getValue();
584 // Roo.Msg.alert('Error', 'Please select a date range for the report');
589 '_group' : 'customerStatement',
592 'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
593 'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
594 'cust_id:number' : cust_id,
600 new Pman.Download({
\r
601 url : baseURL + '/Roo/Metasql',
\r
605 Roo.MessageBox.alert("Notice", "Report will download shortly");
622 var s = _this.grid.getSelectionModel().getSelected();
624 Roo.MessageBox.alert("Error", "Select an order to close");
628 if(s.data.cohead_status == 'C'){
629 Roo.MessageBox.alert("Error", "This order has been closed");
634 url: baseURL + '/Roo/cohead',
637 cohead_id : s.data.cohead_id,
643 Roo.MessageBox.alert("Notice", "DONE");
644 _this.grid.footer.onClick('first');
650 cls : 'x-btn-text-icon',
651 text : "Complete and Close",
652 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
658 click : function (_self, e)
660 var s = _this.grid.getSelectionModel().getSelected();
662 Roo.MessageBox.alert("Error", "Select an order");
666 new Pman.Download({
\r
667 url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',
\r
669 cohead_id : s.data.cohead_id
674 Roo.MessageBox.alert("Notice", "Report will download shortly");
677 cls : 'x-btn-text-icon',
678 text : "Email to warehouse",
679 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
691 // check if the login in user have more than 25 open orders..
692 // if yes, warning...
694 url : baseURL + '/Roo/cohead.php',
698 _count_order : 1 // make the search faster!
700 success : function(res) {
701 if(res.data[0].order_totals * 1 > 25){
702 Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
707 Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
708 _this.grid.footer.onClick('first');
712 cls : 'x-btn-text-icon',
714 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
722 var s = _this.grid.getSelectionModel().getSelected();
724 Roo.MessageBox.alert("Error", "Select an order to copy");
729 Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
731 // get the id from the data, then
733 _this.grid.footer.onClick('first');
734 Pman.Tab.XtupleSales.grid.footer.onClick('first');
735 // get the id from the data, then start editing it..
737 _this.dialog.show(data, function() {
738 _this.grid.footer.onClick('refresh');
739 Pman.Tab.XtupleSales.grid.footer.onClick('first');
745 cls : 'x-btn-text-icon',
747 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
753 xtype: 'ColumnModel',
755 dataIndex : 'cohead_orderdate',
759 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
762 xtype: 'ColumnModel',
764 dataIndex : 'cohead_targetdate',
765 header : 'Target Delivery',
769 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
772 xtype: 'ColumnModel',
774 dataIndex : 'cohead_salesrep_id_salesrep_name',
775 header : 'Staff IC.',
778 renderer : function(v,x,r) {
780 if (r.data.cohead_display_salesrep_id) {
781 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
783 return String.format('{0}', v );
789 xtype: 'ColumnModel',
791 dataIndex : 'cohead_number',
795 renderer : function(v,x,r) {
797 if (r.data.cohead_status == 'C') {
798 return String.format('<i qtip="closed">{0}</i>', v);
800 if (r.data.cohead_status == 'X') {
801 return String.format('<s qtip="void">{0}</s>', v);
803 return String.format('{0}', v);
807 xtype: 'ColumnModel',
809 dataIndex : 'cohead_cust_id_cust_number',
810 header : 'Customer#',
813 renderer : function(v) { return String.format('{0}', v); }
816 xtype: 'ColumnModel',
818 dataIndex : 'cohead_cust_id_cust_name',
822 renderer : function(v) { return String.format('{0}', v); }
825 xtype: 'ColumnModel',
827 dataIndex : 'cohead_custponumber',
828 header : 'Cust. PO#',
830 renderer : function(v) { return String.format('{0}', v); }
833 xtype: 'ColumnModel',
835 dataIndex : 'cohead_type',
838 renderer : function(v) { return String.format('{0}', v); }
841 xtype: 'ColumnModel',
843 dataIndex : 'cohead_src_locations',
846 renderer : function(v) { return String.format('{0}', v); }
849 xtype: 'ColumnModel',
851 dataIndex : 'cohead_shiptoaddress1',
854 renderer : function(v) { return String.format('{0}', v); }
857 xtype: 'ColumnModel',
859 dataIndex : 'cohead_terms_id_terms_descrip',
862 renderer : function(v) { return String.format('{0}', v); }
865 xtype: 'ColumnModel',
868 dataIndex : 'cohead_total',
871 renderer : function(v,x,r) {
872 var ret = String.format('{0} {1}',
873 r.data.cohead_curr_id_curr_name, v ? parseFloat(v).toFixed(3) : '---'
876 if (parseInt(r.data.cohead_qtyordered) != 0 &&
877 parseInt(r.data.cohead_unshipped) == 0 &&
878 parseInt(r.data.cohead_qtyunshipped) == 0 &&
879 parseInt(r.data.cohead_qtyuninvoiced) == 0 &&
880 parseInt(r.data.cohead_unshipped) == 0 &&
881 parseInt(r.data.cohead_uninvoiced) == 0
886 return String.format('<b style="color:red" ' +
887 'qtip="Products: {3} ({4}) <BR/>Unshipped: {1} ({5})<BR>Uninvoiced: {2} ({6})">{0}</b>',
889 r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
890 r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
899 xtype: 'ContentPanel',
908 rendered : function (form)
915 style : 'margin:5px;',
921 select : function (combo, record, index)
923 _this.grid.footer.onClick('first');
925 render : function (_self)
927 _this.viewtypeSel = _self;
931 displayField : 'value',
933 emptyText : "View type",
935 forceSelection : true,
937 loadingText : "Searching...",
941 qtip : "Select Action",
942 queryParam : 'query[action]',
943 selectOnFocus : true,
944 tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
945 triggerAction : 'all',
951 xtype: 'SimpleStore',
955 [ 'MYOPEN', 'My Open orders' ],
956 [ 'MYCLOSED', 'My Closed orders' ],
957 [ 'MYALL', 'My orders (all)' ],
958 [ 'MYVOID', 'My Voided orders' ],
959 [ 'OPEN', 'All Open orders' ],
960 [ 'CLOSED', 'All Closed orders' ],
961 [ 'ALL', 'All orders' ],
962 [ 'VOID', 'Voided orders' ],
963 [ 'INCOMPLETE', 'Incomplete orders' ],
964 [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
965 // [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],
966 // [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
967 [ 'FIFOBUG', 'Problems with FIFO' ]
970 fields : [ 'key', 'value' ]
977 select : function (combo, record, index)
979 (function() { _this.grid.footer.onClick('first'); }).defer(100);
981 specialkey : function (_self, e)
983 //Roo.log(e.getKey());
984 if (e.getKey() == 13) {
985 (function() { _this.grid.footer.onClick('first'); }).defer(100);
987 _this.rsearch = true;
991 beforequery : function (combo, query, forceAll, cancel, e)
995 _this.rsearch =false;
1002 displayField : 'cohead_number',
1004 emptyText : "Select Order",
1005 fieldLabel : 'Order #',
1006 forceSelection : false,
1008 loadingText : "Searching...",
1010 name : 'query[cohead_number]',
1012 qtip : "Select Order",
1013 queryParam : 'query[cohead_number]',
1014 selectOnFocus : true,
1015 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
1016 triggerAction : 'all',
1018 valueField : 'cohead_number',
1024 beforeload : function (_self, o){
1025 o.params = o.params || {};
1026 o.params['_columns'] = 'cohead_number';
1031 sortInfo : { direction : 'ASC', field: 'cohead_number' },
1036 url : baseURL + '/Roo/cohead.php'
1039 xtype: 'JsonReader',
1041 id : 'cohead_number',
1043 totalProperty : 'total',
1044 fields : ["cohead_number"]
1052 select : function (combo, record, index)
1054 (function() { _this.grid.footer.onClick('first'); }).defer(100);
1058 displayField : 'cust_name',
1060 emptyText : "Select custinfo",
1061 fieldLabel : 'Customer',
1062 forceSelection : true,
1063 hiddenName : 'cohead_cust_id',
1065 loadingText : "Searching...",
1067 name : 'cohead_cust_id_cust_name',
1069 qtip : "Select custinfo",
1070 queryParam : 'query[cust_name]',
1071 selectOnFocus : true,
1072 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> ({cust_number})</div>',
1073 triggerAction : 'all',
1075 valueField : 'cust_id',
1080 sortInfo : { direction : 'ASC', field: 'cust_name' },
1083 beforeload : function (_self, o){
1084 o.params = o.params || {};
1092 url : baseURL + '/Roo/custinfo.php'
1095 xtype: 'JsonReader',
1099 totalProperty : 'total',
1100 fields : [{"name":"cust_id","type":"int"},"cust_name"]
1108 select : function (combo, date)
1110 _this.grid.footer.onClick('first');
1113 fieldLabel : 'From',
1122 select : function (combo, date)
1124 _this.grid.footer.onClick('first');
1147 click : function (_self, e)
1149 _this.grid.footer.onClick('first');
1153 icon : rootURL + '/Pman/templates/images/search.gif'
1159 click : function (_self, e)
1161 _this.form.reset('');
1164 _this.grid.footer.onClick('first');
1168 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
1175 xtype: 'LayoutRegion',
1182 xtype: 'LayoutRegion',