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_shipdate', direction: 'DESC' },
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                                     _this.custSel = _self;
158                                 }
159                             },
160                             allowBlank : false,
161                             displayField : 'cust_name',
162                             editable : true,
163                             emptyText : "Select custinfo",
164                             fieldLabel : 'cust_name',
165                             forceSelection : false,
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 : "S",
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                 toolbar : {
247                     xtype: 'Toolbar',
248                     xns: Roo,
249                     items : [
250                         {
251                             xtype: 'ComboBox',
252                             xns: Roo.form,
253                             listeners : {
254                                 select : function (combo, record, index)
255                                 {
256                                  (function() {   _this.grid.footer.onClick('first'); }).defer(100);
257                                 },
258                                 render : function (_self)
259                                 {
260                                     _this.custSel = _self;
261                                 }
262                             },
263                             allowBlank : false,
264                             displayField : 'cust_name',
265                             editable : true,
266                             emptyText : "Select custinfo",
267                             fieldLabel : 'cust_name',
268                             forceSelection : false,
269                             hiddenName : 'cust_id',
270                             listWidth : 400,
271                             loadingText : "Searching...",
272                             minChars : 2,
273                             name : 'cust_name',
274                             pageSize : 20,
275                             qtip : "Select Customer",
276                             queryParam : 'query[cust_name]',
277                             selectOnFocus : true,
278                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
279                             triggerAction : 'all',
280                             typeAhead : true,
281                             valueField : 'cust_id',
282                             width : 300,
283                             store : {
284                                 xtype: 'Store',
285                                 xns: Roo.data,
286                                 listeners : {
287                                     beforeload : function (_self, o){
288                                         o.params = o.params || {};
289                                         // set more here
290                                     }
291                                 },
292                                 remoteSort : true,
293                                 sortInfo : { direction : 'ASC', field: 'shiphead_shipdate' },
294                                 proxy : {
295                                     xtype: 'HttpProxy',
296                                     xns: Roo.data,
297                                     method : 'GET',
298                                     url : baseURL + '/Roo/custinfo.php'
299                                 },
300                                 reader : {
301                                     xtype: 'JsonReader',
302                                     xns: Roo.data,
303                                     id : 'cust_id',
304                                     root : 'data',
305                                     totalProperty : 'total',
306                                     fields : [{"name":"cust_id","type":"int"},"cust_name"]
307                                 }
308                             }
309                         },
310                         {
311                             xtype: 'ComboBox',
312                             xns: Roo.form,
313                             listeners : {
314                                 render : function (_self)
315                                 {
316                                   _this.status = _self;
317                                 },
318                                 beforeselect : function (combo, record, index)
319                                 {
320                                  (function() {   _this.grid.footer.onClick('first'); }).defer(100);
321                                 }
322                             },
323                             allowBlank : false,
324                             displayField : 'fname',
325                             editable : false,
326                             fieldLabel : 'Status',
327                             hiddenName : 'status',
328                             listWidth : 200,
329                             mode : 'local',
330                             name : 'status',
331                             triggerAction : 'all',
332                             value : "S",
333                             valueField : 'ftype',
334                             width : 100,
335                             store : {
336                                 xtype: 'SimpleStore',
337                                 xns: Roo.data,
338                                 data : [ 
339                                     [ 'S', "Shipped"],
340                                     [ 'R' , "Reserved"],
341                                     [ 'V' , "Void Only"],    
342                                     [ 'A', "All"] 
343                                 ],
344                                 fields : [  'ftype', 'fname']
345                             }
346                         }
347                     ]
348                 },
349                 colModel : [
350                     {
351                         xtype: 'ColumnModel',
352                         xns: Roo.grid,
353                         dataIndex : 'shiphead_order_id_cohead_number',
354                         header : 'Order#',
355                         sortable : true,
356                         width : 75,
357                         renderer : function(v) { return String.format('{0}', v); }
358                     },
359                     {
360                         xtype: 'ColumnModel',
361                         xns: Roo.grid,
362                         dataIndex : 'shiphead_custinfo_cust_name',
363                         header : 'Customer',
364                         width : 200,
365                         renderer : function(v) { return String.format('{0}', v); }
366                     },
367                     {
368                         xtype: 'ColumnModel',
369                         xns: Roo.grid,
370                         dataIndex : 'shiphead_number',
371                         header : 'Shipment#',
372                         sortable : true,
373                         width : 200,
374                         renderer : function(v) { return String.format('{0}', v); }
375                     },
376                     {
377                         xtype: 'ColumnModel',
378                         xns: Roo.grid,
379                         header : 'notes',
380                         width : 200,
381                         dataIndex : 'shiphead_notes',
382                         renderer : function(v) { return String.format('{0}', v); }
383                     },
384                     {
385                         xtype: 'ColumnModel',
386                         xns: Roo.grid,
387                         dataIndex : 'shiphead_delivery_note',
388                         header : 'Delivery Note#',
389                         width : 200,
390                         renderer : function(v) { return String.format('{0}', v); }
391                     },
392                     {
393                         xtype: 'ColumnModel',
394                         xns: Roo.grid,
395                         dataIndex : 'shiphead_shipped',
396                         header : 'shipped',
397                         width : 75,
398                         renderer : function(v,x,r) { 
399                         
400                         
401                         
402                           
403                             if (r.json.shiphead_shipdate.length) {
404                             
405                                 if (r.json.shiphead_shipped) {
406                                     return "Confirmed";
407                                 }
408                             
409                                  return 'Draft';
410                             }
411                              
412                             return 'VOID';
413                            
414                         
415                         }
416                     },
417                     {
418                         xtype: 'ColumnModel',
419                         xns: Roo.grid,
420                         dataIndex : 'shiphead_shipdate',
421                         header : 'shipdate',
422                         sortable : true,
423                         width : 75,
424                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
425                     }
426                 ]
427             }
428         };
429     }
430 });