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 Item found",
200                                 pageSize : 100,
201                                 updateSummary : function() {
202                                 \r
203                                     var f = this;\r
204                                     new Pman.Request({\r
205                                         url : baseURL + '/Xtuple/Roo/Poitem',\r
206                                         method : 'GET',\r
207                                         params : {
208                                             _roo_office : _this.data.office ? _this.data.office : baseURL.split('/').pop().substr(0,2),\r
209                                             _totals : 1,\r
210                                             poitem_pohead_id : _this.form.findField('pohead_id').getValue()\r
211                                         },\r
212                                         success : function(d) {
213                                             Roo.log(d);\r
214                                             f.displayEl.update(String.format(\r
215                                                 "{0} items | Total : {1} {2}",\r
216                                                 d.data[0].count_item,\r
217                                                 _this.form.findField('pohead_curr_id').el.dom.value,\r
218                                                 d.data[0].totals\r
219                                             ));\r
220                                                 \r
221                                         }\r
222                                     });\r
223                                 
224                                 }
225                             },
226                             colModel : [
227                                 {
228                                     xtype: 'ColumnModel',
229                                     xns: Roo.grid,
230                                     align : 'right',
231                                     dataIndex : 'poitem_linenumber',
232                                     header : 'Line#',
233                                     width : 50,
234                                     renderer : function(v) { return String.format('{0}', v); }
235                                 },
236                                 {
237                                     xtype: 'ColumnModel',
238                                     xns: Roo.grid,
239                                     dataIndex : 'item_number',
240                                     header : 'Item code',
241                                     width : 100,
242                                     renderer : function(v) { return String.format('{0}', v); },
243                                     editor : {
244                                         xtype: 'GridEditor',
245                                         xns: Roo.grid,
246                                         field : {
247                                             xtype: 'ComboBox',
248                                             xns: Roo.form,
249                                             listeners : {
250                                                 beforeselect : function (combo, record, index)
251                                                 {
252                                                   var ar = _this.grid.activeEditor.record;
253                                                   
254                                                   (function() { 
255                                                       ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
256                                                       ar.set('poitem_itemsite_id', record.data.itemsite_id);
257                                                   }).defer(100);
258                                                   
259                                                 }
260                                             },
261                                             allowBlank : false,
262                                             displayField : 'itemsite_item_id_item_number',
263                                             editable : true,
264                                             emptyText : "Select item",
265                                             forceSelection : true,
266                                             hiddenName : 'itemsite_item_id_item_number',
267                                             listWidth : 400,
268                                             loadingText : "Searching...",
269                                             minChars : 2,
270                                             name : 'item_number',
271                                             pageSize : 20,
272                                             qtip : "Select item",
273                                             queryParam : 'query[number]',
274                                             selectOnFocus : true,
275                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> - {itemsite_item_id_item_descrip1} </div>',
276                                             triggerAction : 'all',
277                                             typeAhead : false,
278                                             valueField : 'item_number',
279                                             store : {
280                                                 xtype: 'Store',
281                                                 xns: Roo.data,
282                                                 listeners : {
283                                                     beforeload : function (_self, o){
284                                                         o.params = o.params || {}; 
285                                                         o.params.itemsite_posupply = 1;
286                                                     }
287                                                 },
288                                                 remoteSort : true,
289                                                 sortInfo : { direction : 'ASC', field: 'item_number' },
290                                                 proxy : {
291                                                     xtype: 'HttpProxy',
292                                                     xns: Roo.data,
293                                                     method : 'GET',
294                                                     url : baseURL + '/Roo/itemsite.php'
295                                                 },
296                                                 reader : {
297                                                     xtype: 'JsonReader',
298                                                     xns: Roo.data,
299                                                     id : 'itemsite_id',
300                                                     root : 'data',
301                                                     totalProperty : 'total',
302                                                     fields : [{"name":"item_id","type":"int"},"item_number"]
303                                                 }
304                                             }
305                                         }
306                                     }
307                                 },
308                                 {
309                                     xtype: 'ColumnModel',
310                                     xns: Roo.grid,
311                                     dataIndex : 'item_descrip1',
312                                     header : 'Item description',
313                                     width : 150,
314                                     renderer : function(v) { return String.format('{0}', v); }
315                                 },
316                                 {
317                                     xtype: 'ColumnModel',
318                                     xns: Roo.grid,
319                                     dataIndex : 'poitem_duedate',
320                                     header : 'Due date',
321                                     width : 100,
322                                     renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }
323                                 },
324                                 {
325                                     xtype: 'ColumnModel',
326                                     xns: Roo.grid,
327                                     align : 'right',
328                                     dataIndex : 'poitem_qty_ordered',
329                                     header : 'Ordered',
330                                     width : 75,
331                                     renderer : function(v) { return String.format('{0}', v); },
332                                     editor : {
333                                         xtype: 'GridEditor',
334                                         xns: Roo.grid,
335                                         field : {
336                                             xtype: 'NumberField',
337                                             xns: Roo.form,
338                                             allowDecimals : false,
339                                             decimalPrecision : 0,
340                                             minValue : 1,
341                                             style : 'text-align:right'
342                                         }
343                                     }
344                                 },
345                                 {
346                                     xtype: 'ColumnModel',
347                                     xns: Roo.grid,
348                                     align : 'right',
349                                     dataIndex : 'poitem_qty_received',
350                                     header : 'Received',
351                                     width : 75,
352                                     renderer : function(v,x,r) { 
353                                         return String.format(
354                                             r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style="color:red">{0}</span>':  '{0}',
355                                              v - r.data.poitem_qty_returned);
356                                     }
357                                 },
358                                 {
359                                     xtype: 'ColumnModel',
360                                     xns: Roo.grid,
361                                     align : 'right',
362                                     dataIndex : 'poitem_qty_vouchered',
363                                     header : 'Vouchered',
364                                     width : 65,
365                                     renderer : function(v,x,r) { 
366                                         return String.format(
367                                             r.data.poitem_qty_ordered != v ? '<span style="color:red">{0}</span>':  '{0}',
368                                              v);
369                                     }
370                                 },
371                                 {
372                                     xtype: 'ColumnModel',
373                                     xns: Roo.grid,
374                                     align : 'right',
375                                     dataIndex : 'poitem_unitprice',
376                                     header : 'Unit price',
377                                     width : 100,
378                                     renderer : function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); },
379                                     editor : {
380                                         xtype: 'GridEditor',
381                                         xns: Roo.grid,
382                                         field : {
383                                             xtype: 'NumberField',
384                                             xns: Roo.form,
385                                             allowBlank : false,
386                                             allowDecimals : false,
387                                             decimalPrecision : 0,
388                                             minValue : 1,
389                                             style : 'text-align:right'
390                                         }
391                                     }
392                                 }
393                             ]
394                         }
395                     }
396                 ],
397                 center : {
398                     xtype: 'LayoutRegion',
399                     xns: Roo,
400                     autoScroll : false,
401                     split : true
402                 }
403             }
404         };
405     }
406 });