Pman.Tab.XtupleSalesShipment.bjs
[Pman.Xtuple] / Pman.Tab.XtupleSalesShipment.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.XtupleSalesShipment = new Roo.XComponent({
6     part     :  ["Xtuple","SalesShipment"],
7     order    : '100-Pman.Tab.XtupleSalesShipment',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleSales',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             title : "Fullfillments",
21             fitToframe : true,
22             fitContainer : true,
23             tableName : 'shiphead',
24             background : true,
25             region : 'center',
26             listeners : {
27                 activate : function() {
28                     _this.panel = this;
29                     if (_this.grid) {
30                         _this.grid.footer.onClick('first');
31                     }
32                 }
33             },
34             grid : {
35                 xtype: 'Grid',
36                 xns: Roo.grid,
37                 listeners : {
38                     render : function() 
39                     {
40                         _this.grid = this; 
41                         try { 
42                             _this.dialog = Pman.Dialog.XtupleSalesOrder;
43                         } catch(e) {}
44                         if (_this.panel.active) {
45                            this.footer.onClick('first');
46                         }
47                     },
48                     rowdblclick : function (_self, rowIndex, e)
49                     {
50                          if (!_this.dialog) return;
51                          
52                          var d =  this.getDataSource().getAt(rowIndex).data;
53                         _this.dialog.show( {
54                             cohead_id : d.shiphead_order_id
55                         
56                         }, function() {
57                             _this.grid.footer.onClick('refresh');
58                             Pman.Tab.XtupleSales.grid.footer.onClick('first');
59                         }); 
60                     }
61                 },
62                 autoExpandColumn : 'shiphead_notes',
63                 loadMask : true,
64                 dataSource : {
65                     xtype: 'Store',
66                     xns: Roo.data,
67                     listeners : {
68                         beforeload : function (_self, options)
69                         {
70                             options.params._status =  _this.status.getValue();
71                             var cust = _this.custSel.getValue();
72                             if (cust *1) {
73                             
74                             
75                             }
76                         }
77                     },
78                     remoteSort : true,
79                     sortInfo : { field : 'shiphead_notes', direction: 'ASC' },
80                     proxy : {
81                         xtype: 'HttpProxy',
82                         xns: Roo.data,
83                         method : 'GET',
84                         url : baseURL + '/Roo/shiphead.php'
85                     },
86                     reader : {
87                         xtype: 'JsonReader',
88                         xns: Roo.data,
89                         totalProperty : 'total',
90                         root : 'data',
91                         id : 'id',
92                         fields : [
93                             {
94                                 'name': 'shiphead_order_id',
95                                 'type': 'int'
96                             },
97                             {
98                                 'name': 'shiphead_number',
99                                 'type': 'string'
100                             },
101                             {
102                                 'name': 'shiphead_notes',
103                                 'type': 'string'
104                             },
105                             {
106                                 'name': 'shiphead_shipped',
107                                 'type': 'boolean'
108                             },
109                             {
110                                 'name': 'shiphead_shipdate',
111                                 'type': 'date'
112                             },
113                             {
114                                 'name': 'shiphead_sfstatus'
115                             }
116                         ]
117                     }
118                 },
119                 footer : {
120                     xtype: 'PagingToolbar',
121                     xns: Roo,
122                     pageSize : 25,
123                     displayInfo : true,
124                     displayMsg : "Displaying shiphead{0} - {1} of {2}",
125                     emptyMsg : "No shiphead found",
126                     items : [
127                         {
128                             xtype: 'Button',
129                             xns: Roo.Toolbar,
130                             listeners : {
131                                 click : function (_self, e)
132                                 {
133                                     new Pman.Download({
134                                         grid: _this.grid
135                                     });
136                                     Roo.MessageBox.alert("Notice", "Download should start soon");
137                                 }
138                             },
139                             text : "Download"
140                         }
141                     ]
142                 },
143                 toolbar : {
144                     xtype: 'Toolbar',
145                     xns: Roo,
146                     items : [
147                         {
148                             xtype: 'ComboBox',
149                             xns: Roo.form,
150                             listeners : {
151                                 select : function (combo, record, index)
152                                 {
153                                  (function() {   _this.grid.footer.onClick('first'); }).defer(100);
154                                 },
155                                 render : function (_self)
156                                 {
157                                 
158                                 }
159                             },
160                             allowBlank : false,
161                             displayField : 'cust_name',
162                             editable : true,
163                             emptyText : "Select custinfo",
164                             fieldLabel : 'cust_name',
165                             forceSelection : true,
166                             hiddenName : 'cust_id',
167                             listWidth : 400,
168                             loadingText : "Searching...",
169                             minChars : 2,
170                             name : 'cust_name',
171                             pageSize : 20,
172                             qtip : "Select Customer",
173                             queryParam : 'query[cust_name]',
174                             selectOnFocus : true,
175                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
176                             triggerAction : 'all',
177                             typeAhead : true,
178                             valueField : 'cust_id',
179                             width : 300,
180                             store : {
181                                 xtype: 'Store',
182                                 xns: Roo.data,
183                                 listeners : {
184                                     beforeload : function (_self, o){
185                                         o.params = o.params || {};
186                                         // set more here
187                                     }
188                                 },
189                                 remoteSort : true,
190                                 sortInfo : { direction : 'ASC', field: 'shiphead_shipdate' },
191                                 proxy : {
192                                     xtype: 'HttpProxy',
193                                     xns: Roo.data,
194                                     method : 'GET',
195                                     url : baseURL + '/Roo/custinfo.php'
196                                 },
197                                 reader : {
198                                     xtype: 'JsonReader',
199                                     xns: Roo.data,
200                                     id : 'cust_id',
201                                     root : 'data',
202                                     totalProperty : 'total',
203                                     fields : [{"name":"cust_id","type":"int"},"cust_name"]
204                                 }
205                             }
206                         },
207                         {
208                             xtype: 'ComboBox',
209                             xns: Roo.form,
210                             listeners : {
211                                 render : function (_self)
212                                 {
213                                   _this.status = _self;
214                                 },
215                                 beforeselect : function (combo, record, index)
216                                 {
217                                  (function() {   _this.grid.footer.onClick('first'); }).defer(100);
218                                 }
219                             },
220                             allowBlank : false,
221                             displayField : 'fname',
222                             editable : false,
223                             fieldLabel : 'Status',
224                             hiddenName : 'status',
225                             listWidth : 200,
226                             mode : 'local',
227                             name : 'status',
228                             triggerAction : 'all',
229                             value : "A",
230                             valueField : 'ftype',
231                             width : 100,
232                             store : {
233                                 xtype: 'SimpleStore',
234                                 xns: Roo.data,
235                                 data : [ 
236                                     [ 'S', "Shipped"],
237                                     [ 'R' , "Reserved"],
238                                     [ 'V' , "Void Only"],    
239                                     [ 'A', "All"] 
240                                 ],
241                                 fields : [  'ftype', 'fname']
242                             }
243                         }
244                     ]
245                 },
246                 colModel : [
247                     {
248                         xtype: 'ColumnModel',
249                         xns: Roo.grid,
250                         dataIndex : 'shiphead_order_id_cohead_number',
251                         header : 'Order#',
252                         sortable : true,
253                         width : 75,
254                         renderer : function(v) { return String.format('{0}', v); }
255                     },
256                     {
257                         xtype: 'ColumnModel',
258                         xns: Roo.grid,
259                         dataIndex : 'shiphead_custinfo_cust_name',
260                         header : 'Customer',
261                         width : 200,
262                         renderer : function(v) { return String.format('{0}', v); }
263                     },
264                     {
265                         xtype: 'ColumnModel',
266                         xns: Roo.grid,
267                         dataIndex : 'shiphead_number',
268                         header : 'Shipment#',
269                         sortable : true,
270                         width : 200,
271                         renderer : function(v) { return String.format('{0}', v); }
272                     },
273                     {
274                         xtype: 'ColumnModel',
275                         xns: Roo.grid,
276                         header : 'notes',
277                         width : 200,
278                         dataIndex : 'shiphead_notes',
279                         renderer : function(v) { return String.format('{0}', v); }
280                     },
281                     {
282                         xtype: 'ColumnModel',
283                         xns: Roo.grid,
284                         dataIndex : 'shiphead_shipped',
285                         header : 'shipped',
286                         width : 75,
287                         renderer : function(v,x,r) { 
288                         
289                         
290                         
291                           
292                             if (r.json.shiphead_shipdate.length) {
293                             
294                                 if (r.json.shiphead_shipped) {
295                                     return "Confirmed";
296                                 }
297                             
298                                  return 'Draft';
299                             }
300                              
301                             return 'VOID';
302                            
303                         
304                         }
305                     },
306                     {
307                         xtype: 'ColumnModel',
308                         xns: Roo.grid,
309                         dataIndex : 'shiphead_shipdate',
310                         header : 'shipdate',
311                         sortable : true,
312                         width : 75,
313                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
314                     }
315                 ]
316             }
317         };
318     }
319 });