Pman.Tab.CoreOAuthClient.bjs
[Pman.Core] / Pman.Tab.CoreOAuthClient.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.CoreOAuthClient = new Roo.XComponent({
6     part     :  ["Core","OAuthClient"],
7     order    : '001-Pman.Tab.CoreOAuthClient',
8     region   : 'center',
9     parent   : false,
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: 'NestedLayoutPanel',
19             xns: Roo,
20             region : 'center',
21             title : "Email Template",
22             layout : {
23                 xtype: 'BorderLayout',
24                 xns: Roo,
25                 items : [
26                     {
27                         xtype: 'GridPanel',
28                         xns: Roo,
29                         listeners : {
30                             activate : function() {
31                                 _this.panel = this;
32                                 
33                                 if (_this.grid) {
34                                     _this.grid.footer.onClick('first');
35                                 }
36                             }
37                         },
38                         background : true,
39                         fitContainer : true,
40                         fitToframe : true,
41                         region : 'center',
42                         tableName : 'core_oauth_clients',
43                         title : "Oauth2 Clients",
44                         grid : {
45                             xtype: 'EditorGrid',
46                             xns: Roo.grid,
47                             listeners : {
48                                 render : function() 
49                                 {
50                                     _this.grid = this; 
51                                     if (_this.panel.active) {
52                                        this.footer.onClick('first');
53                                     }
54                                 },
55                                 beforeedit : function (e)
56                                 {
57                                     var r = e.record.data.poitem_qty_received * 1;
58                                     
59                                     if(r > 0){
60                                         Roo.MessageBox.alert("Error", "This item has been receipted");
61                                         return false;
62                                     }
63                                     
64                                     var status = _this.form.findField('pohead_status').getValue();
65                                     
66                                     if(status == 'C'){
67                                         Roo.MessageBox.alert("Error", "This PO has been closed");
68                                         return false;
69                                     }
70                                     
71                                     
72                                 }
73                             },
74                             autoExpandColumn : 'redirect_uri',
75                             clicksToEdit : 1,
76                             loadMask : true,
77                             dataSource : {
78                                 xtype: 'Store',
79                                 xns: Roo.data,
80                                 listeners : {
81                                     beforeload : function (_self, o){
82                                         o.params = o.params || {};
83                                     
84                                     }
85                                 },
86                                 remoteSort : true,
87                                 sortInfo : { field : 'client_id', direction: 'ASC' },
88                                 proxy : {
89                                     xtype: 'HttpProxy',
90                                     xns: Roo.data,
91                                     method : 'GET',
92                                     url : baseURL + '/Roo/Core_oauth_clients'
93                                 },
94                                 reader : {
95                                     xtype: 'JsonReader',
96                                     xns: Roo.data,
97                                     id : 'id',
98                                     root : 'data',
99                                     totalProperty : 'total',
100                                     fields : [
101                                         {
102                                             'name': 'client_id',
103                                             'type': 'string'
104                                         },
105                                         {
106                                             'name': 'client_secret',
107                                             'type': 'string'
108                                         },
109                                         {
110                                             'name': 'redirect_uri',
111                                             'type': 'string'
112                                         }
113                                     ]
114                                 }
115                             },
116                             toolbar : {
117                                 xtype: 'Toolbar',
118                                 xns: Roo,
119                                 items : [
120                                     {
121                                         xtype: 'Button',
122                                         xns: Roo.Toolbar,
123                                         listeners : {
124                                             click : function()
125                                             {
126                                                 var status = _this.form.findField('pohead_status').getValue();
127                                                 
128                                                 if(status == 'C'){
129                                                     Roo.MessageBox.alert("Error", "This PO has been closed");
130                                                     return;
131                                                 }
132                                                 
133                                                 var ct  =    _this.grid.ds.getCount();
134                                                 
135                                                 var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;
136                                                 
137                                                 var dt = _this.form.findField('pohead_orderdate').getValue();
138                                                 
139                                                 var nr = _this.grid.ds.reader.newRow({
140                                                     poitem_id : 0,
141                                                     poitem_linenumber : last,
142                                                     item_number : '',
143                                                     item_descrip1 : '',
144                                                     poitem_duedate : dt,
145                                                     poitem_qty_ordered : 1,
146                                                     poitem_unitprice : 0
147                                                 });
148                                                 
149                                                 _this.grid.stopEditing();
150                                                 _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
151                                                 _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);
152                                             }
153                                         },
154                                         cls : 'x-btn-text-icon',
155                                         text : "Add",
156                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
157                                     },
158                                     {
159                                         xtype: 'Button',
160                                         xns: Roo.Toolbar,
161                                         listeners : {
162                                             click : function ()
163                                             {
164                                                 var status = _this.form.findField('pohead_status').getValue();
165                                                 
166                                                 if(status == 'C'){
167                                                     Roo.MessageBox.alert("Error", "This PO has been closed");
168                                                     return;
169                                                 }
170                                                 
171                                                 var cs = _this.grid.getSelectionModel().getSelectedCell();
172                                                 if (!cs) {
173                                                     Roo.MessageBox.alert("Error", "Select a cell");
174                                                     return;
175                                                 }
176                                                 _this.grid.stopEditing();
177                                                 var r = _this.grid.ds.getAt(cs[0]);
178                                                 
179                                                 if(r.data.poitem_qty_received * 1 > 0){
180                                                     Roo.MessageBox.alert("Error", "This item has been receipted");
181                                                     return;
182                                                 }
183                                                 
184                                                 
185                                                 _this.grid.ds.remove(r);
186                                                
187                                             }
188                                         },
189                                         cls : 'x-btn-text-icon',
190                                         text : "Remove",
191                                         icon : rootURL + '/Pman/templates/images/trash.gif'
192                                     }
193                                 ]
194                             },
195                             footer : {
196                                 xtype: 'PagingToolbar',
197                                 xns: Roo,
198                                 displayInfo : true,
199                                 emptyMsg : "No Clients found",
200                                 pageSize : 25
201                             },
202                             colModel : [
203                                 {
204                                     xtype: 'ColumnModel',
205                                     xns: Roo.grid,
206                                     align : 'right',
207                                     dataIndex : 'poitem_linenumber',
208                                     header : 'Line#',
209                                     width : 50,
210                                     renderer : function(v) { return String.format('{0}', v); }
211                                 },
212                                 {
213                                     xtype: 'ColumnModel',
214                                     xns: Roo.grid,
215                                     dataIndex : 'item_number',
216                                     header : 'Item code',
217                                     width : 100,
218                                     renderer : function(v) { return String.format('{0}', v); },
219                                     editor : {
220                                         xtype: 'GridEditor',
221                                         xns: Roo.grid,
222                                         field : {
223                                             xtype: 'ComboBox',
224                                             xns: Roo.form,
225                                             listeners : {
226                                                 beforeselect : function (combo, record, index)
227                                                 {
228                                                   var ar = _this.grid.activeEditor.record;
229                                                   
230                                                   (function() { 
231                                                       ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
232                                                       ar.set('poitem_itemsite_id', record.data.itemsite_id);
233                                                   }).defer(100);
234                                                   
235                                                 }
236                                             },
237                                             allowBlank : false,
238                                             displayField : 'itemsite_item_id_item_number',
239                                             editable : true,
240                                             emptyText : "Select item",
241                                             forceSelection : true,
242                                             hiddenName : 'itemsite_item_id_item_number',
243                                             listWidth : 400,
244                                             loadingText : "Searching...",
245                                             minChars : 2,
246                                             name : 'item_number',
247                                             pageSize : 20,
248                                             qtip : "Select item",
249                                             queryParam : 'query[number]',
250                                             selectOnFocus : true,
251                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> - {itemsite_item_id_item_descrip1} </div>',
252                                             triggerAction : 'all',
253                                             typeAhead : false,
254                                             valueField : 'item_number',
255                                             store : {
256                                                 xtype: 'Store',
257                                                 xns: Roo.data,
258                                                 listeners : {
259                                                     beforeload : function (_self, o){
260                                                         o.params = o.params || {}; 
261                                                         o.params.itemsite_posupply = 1;
262                                                     }
263                                                 },
264                                                 remoteSort : true,
265                                                 sortInfo : { direction : 'ASC', field: 'item_number' },
266                                                 proxy : {
267                                                     xtype: 'HttpProxy',
268                                                     xns: Roo.data,
269                                                     method : 'GET',
270                                                     url : baseURL + '/Roo/itemsite.php'
271                                                 },
272                                                 reader : {
273                                                     xtype: 'JsonReader',
274                                                     xns: Roo.data,
275                                                     id : 'itemsite_id',
276                                                     root : 'data',
277                                                     totalProperty : 'total',
278                                                     fields : [{"name":"item_id","type":"int"},"item_number"]
279                                                 }
280                                             }
281                                         }
282                                     }
283                                 },
284                                 {
285                                     xtype: 'ColumnModel',
286                                     xns: Roo.grid,
287                                     dataIndex : 'item_descrip1',
288                                     header : 'Item description',
289                                     width : 150,
290                                     renderer : function(v) { return String.format('{0}', v); }
291                                 },
292                                 {
293                                     xtype: 'ColumnModel',
294                                     xns: Roo.grid,
295                                     dataIndex : 'poitem_duedate',
296                                     header : 'Due date',
297                                     width : 100,
298                                     renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }
299                                 },
300                                 {
301                                     xtype: 'ColumnModel',
302                                     xns: Roo.grid,
303                                     align : 'right',
304                                     dataIndex : 'poitem_qty_ordered',
305                                     header : 'Ordered',
306                                     width : 75,
307                                     renderer : function(v) { return String.format('{0}', v); },
308                                     editor : {
309                                         xtype: 'GridEditor',
310                                         xns: Roo.grid,
311                                         field : {
312                                             xtype: 'NumberField',
313                                             xns: Roo.form,
314                                             allowDecimals : false,
315                                             decimalPrecision : 0,
316                                             minValue : 1,
317                                             style : 'text-align:right'
318                                         }
319                                     }
320                                 },
321                                 {
322                                     xtype: 'ColumnModel',
323                                     xns: Roo.grid,
324                                     align : 'right',
325                                     dataIndex : 'poitem_qty_received',
326                                     header : 'Received',
327                                     width : 75,
328                                     renderer : function(v,x,r) { 
329                                         return String.format(
330                                             r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style="color:red">{0}</span>':  '{0}',
331                                              v - r.data.poitem_qty_returned);
332                                     }
333                                 },
334                                 {
335                                     xtype: 'ColumnModel',
336                                     xns: Roo.grid,
337                                     align : 'right',
338                                     dataIndex : 'poitem_qty_vouchered',
339                                     header : 'Vouchered',
340                                     width : 65,
341                                     renderer : function(v,x,r) { 
342                                         return String.format(
343                                             r.data.poitem_qty_ordered != v ? '<span style="color:red">{0}</span>':  '{0}',
344                                              v);
345                                     }
346                                 },
347                                 {
348                                     xtype: 'ColumnModel',
349                                     xns: Roo.grid,
350                                     align : 'right',
351                                     dataIndex : 'poitem_unitprice',
352                                     header : 'Unit price',
353                                     width : 100,
354                                     renderer : function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); },
355                                     editor : {
356                                         xtype: 'GridEditor',
357                                         xns: Roo.grid,
358                                         field : {
359                                             xtype: 'NumberField',
360                                             xns: Roo.form,
361                                             allowBlank : false,
362                                             allowDecimals : false,
363                                             decimalPrecision : 0,
364                                             minValue : 1,
365                                             style : 'text-align:right'
366                                         }
367                                     }
368                                 }
369                             ]
370                         }
371                     }
372                 ],
373                 center : {
374                     xtype: 'LayoutRegion',
375                     xns: Roo,
376                     autoScroll : false,
377                     split : true
378                 }
379             }
380         };
381     }
382 });