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                     remoteSort : true,
68                     sortInfo : { field : 'shiphead_notes', direction: 'ASC' },
69                     proxy : {
70                         xtype: 'HttpProxy',
71                         xns: Roo.data,
72                         method : 'GET',
73                         url : baseURL + '/Roo/shiphead.php'
74                     },
75                     reader : {
76                         xtype: 'JsonReader',
77                         xns: Roo.data,
78                         totalProperty : 'total',
79                         root : 'data',
80                         id : 'id',
81                         fields : [
82                             {
83                                 'name': 'shiphead_order_id',
84                                 'type': 'int'
85                             },
86                             {
87                                 'name': 'shiphead_number',
88                                 'type': 'string'
89                             },
90                             {
91                                 'name': 'shiphead_notes',
92                                 'type': 'string'
93                             },
94                             {
95                                 'name': 'shiphead_shipped',
96                                 'type': 'boolean'
97                             },
98                             {
99                                 'name': 'shiphead_shipdate',
100                                 'type': 'date'
101                             },
102                             {
103                                 'name': 'shiphead_sfstatus'
104                             }
105                         ]
106                     }
107                 },
108                 footer : {
109                     xtype: 'PagingToolbar',
110                     xns: Roo,
111                     pageSize : 25,
112                     displayInfo : true,
113                     displayMsg : "Displaying shiphead{0} - {1} of {2}",
114                     emptyMsg : "No shiphead found",
115                     items : [
116                         {
117                             xtype: 'Button',
118                             xns: Roo.Toolbar,
119                             listeners : {
120                                 click : function (_self, e)
121                                 {
122                                     new Pman.Download({
123                                         grid: _this.grid
124                                     });
125                                     Roo.MessageBox.alert("Notice", "Download should start soon");
126                                 }
127                             },
128                             text : "Download"
129                         }
130                     ]
131                 },
132                 toolbar : {
133                     xtype: 'Toolbar',
134                     xns: Roo,
135                     items : [
136                         {
137                             xtype: 'ComboBox',
138                             xns: Roo.form,
139                             allowBlank : false,
140                             editable : true,
141                             emptyText : "Select custinfo",
142                             forceSelection : true,
143                             listWidth : 400,
144                             loadingText : "Searching...",
145                             minChars : 2,
146                             pageSize : 20,
147                             qtip : "Select Customer",
148                             selectOnFocus : true,
149                             triggerAction : 'all',
150                             typeAhead : true,
151                             width : 300,
152                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
153                             queryParam : 'query[cust_name]',
154                             fieldLabel : 'cust_name',
155                             valueField : 'cust_id',
156                             displayField : 'cust_name',
157                             hiddenName : 'cust_id',
158                             name : 'cust_name',
159                             store : {
160                                 xtype: 'Store',
161                                 xns: Roo.data,
162                                 listeners : {
163                                     beforeload : function (_self, o){
164                                         o.params = o.params || {};
165                                         // set more here
166                                     }
167                                 },
168                                 remoteSort : true,
169                                 sortInfo : { direction : 'ASC', field: 'shiphead_shipdate' },
170                                 proxy : {
171                                     xtype: 'HttpProxy',
172                                     xns: Roo.data,
173                                     method : 'GET',
174                                     url : baseURL + '/Roo/custinfo.php'
175                                 },
176                                 reader : {
177                                     xtype: 'JsonReader',
178                                     xns: Roo.data,
179                                     id : 'cust_id',
180                                     root : 'data',
181                                     totalProperty : 'total',
182                                     fields : [{"name":"cust_id","type":"int"},"cust_name"]
183                                 }
184                             }
185                         }
186                     ]
187                 },
188                 colModel : [
189                     {
190                         xtype: 'ColumnModel',
191                         xns: Roo.grid,
192                         dataIndex : 'shiphead_order_id_cohead_number',
193                         header : 'Order#',
194                         sortable : true,
195                         width : 75,
196                         renderer : function(v) { return String.format('{0}', v); }
197                     },
198                     {
199                         xtype: 'ColumnModel',
200                         xns: Roo.grid,
201                         dataIndex : 'shiphead_custinfo_cust_name',
202                         header : 'Customer',
203                         width : 200,
204                         renderer : function(v) { return String.format('{0}', v); }
205                     },
206                     {
207                         xtype: 'ColumnModel',
208                         xns: Roo.grid,
209                         dataIndex : 'shiphead_number',
210                         header : 'Shipment#',
211                         sortable : true,
212                         width : 200,
213                         renderer : function(v) { return String.format('{0}', v); }
214                     },
215                     {
216                         xtype: 'ColumnModel',
217                         xns: Roo.grid,
218                         header : 'notes',
219                         width : 200,
220                         dataIndex : 'shiphead_notes',
221                         renderer : function(v) { return String.format('{0}', v); }
222                     },
223                     {
224                         xtype: 'ColumnModel',
225                         xns: Roo.grid,
226                         dataIndex : 'shiphead_shipped',
227                         header : 'shipped',
228                         width : 75,
229                         renderer : function(v,x,r) { 
230                         
231                         
232                         
233                           
234                             if (r.json.shiphead_shipdate.length) {
235                             
236                                 if (r.json.shiphead_shipped) {
237                                     return "Confirmed";
238                                 }
239                             
240                                  return 'Draft';
241                             }
242                              
243                             return 'VOID';
244                            
245                         
246                         }
247                     },
248                     {
249                         xtype: 'ColumnModel',
250                         xns: Roo.grid,
251                         dataIndex : 'shiphead_shipdate',
252                         header : 'shipdate',
253                         sortable : true,
254                         width : 75,
255                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
256                     }
257                 ]
258             }
259         };
260     }
261 });