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                                     timeout : 90000,
93                                     url : baseURL + '/Xtuple/Roo/Poitem.php'
94                                 },
95                                 reader : {
96                                     xtype: 'JsonReader',
97                                     xns: Roo.data,
98                                     id : 'poitem_id',
99                                     root : 'data',
100                                     totalProperty : 'total',
101                                     fields : [
102                                         {
103                                             'name': 'poitem_id',
104                                             'type': 'int'
105                                         }
106                                     ]
107                                 }
108                             },
109                             toolbar : {
110                                 xtype: 'Toolbar',
111                                 xns: Roo,
112                                 items : [
113                                     {
114                                         xtype: 'Button',
115                                         xns: Roo.Toolbar,
116                                         listeners : {
117                                             click : function()
118                                             {
119                                                 var status = _this.form.findField('pohead_status').getValue();
120                                                 
121                                                 if(status == 'C'){
122                                                     Roo.MessageBox.alert("Error", "This PO has been closed");
123                                                     return;
124                                                 }
125                                                 
126                                                 var ct  =    _this.grid.ds.getCount();
127                                                 
128                                                 var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;
129                                                 
130                                                 var dt = _this.form.findField('pohead_orderdate').getValue();
131                                                 
132                                                 var nr = _this.grid.ds.reader.newRow({
133                                                     poitem_id : 0,
134                                                     poitem_linenumber : last,
135                                                     item_number : '',
136                                                     item_descrip1 : '',
137                                                     poitem_duedate : dt,
138                                                     poitem_qty_ordered : 1,
139                                                     poitem_unitprice : 0
140                                                 });
141                                                 
142                                                 _this.grid.stopEditing();
143                                                 _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
144                                                 _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);
145                                             }
146                                         },
147                                         cls : 'x-btn-text-icon',
148                                         text : "Add",
149                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
150                                     },
151                                     {
152                                         xtype: 'Button',
153                                         xns: Roo.Toolbar,
154                                         listeners : {
155                                             click : function ()
156                                             {
157                                                 var status = _this.form.findField('pohead_status').getValue();
158                                                 
159                                                 if(status == 'C'){
160                                                     Roo.MessageBox.alert("Error", "This PO has been closed");
161                                                     return;
162                                                 }
163                                                 
164                                                 var cs = _this.grid.getSelectionModel().getSelectedCell();
165                                                 if (!cs) {
166                                                     Roo.MessageBox.alert("Error", "Select a cell");
167                                                     return;
168                                                 }
169                                                 _this.grid.stopEditing();
170                                                 var r = _this.grid.ds.getAt(cs[0]);
171                                                 
172                                                 if(r.data.poitem_qty_received * 1 > 0){
173                                                     Roo.MessageBox.alert("Error", "This item has been receipted");
174                                                     return;
175                                                 }
176                                                 
177                                                 
178                                                 _this.grid.ds.remove(r);
179                                                
180                                             }
181                                         },
182                                         cls : 'x-btn-text-icon',
183                                         text : "Remove",
184                                         icon : rootURL + '/Pman/templates/images/trash.gif'
185                                     }
186                                 ]
187                             },
188                             footer : {
189                                 xtype: 'PagingToolbar',
190                                 xns: Roo,
191                                 displayInfo : true,
192                                 emptyMsg : "No Item found",
193                                 pageSize : 100,
194                                 updateSummary : function() {
195                                 \r
196                                     var f = this;\r
197                                     new Pman.Request({\r
198                                         url : baseURL + '/Xtuple/Roo/Poitem',\r
199                                         method : 'GET',\r
200                                         params : {
201                                             _roo_office : _this.data.office ? _this.data.office : baseURL.split('/').pop().substr(0,2),\r
202                                             _totals : 1,\r
203                                             poitem_pohead_id : _this.form.findField('pohead_id').getValue()\r
204                                         },\r
205                                         success : function(d) {
206                                             Roo.log(d);\r
207                                             f.displayEl.update(String.format(\r
208                                                 "{0} items | Total : {1} {2}",\r
209                                                 d.data[0].count_item,\r
210                                                 _this.form.findField('pohead_curr_id').el.dom.value,\r
211                                                 d.data[0].totals\r
212                                             ));\r
213                                                 \r
214                                         }\r
215                                     });\r
216                                 
217                                 }
218                             },
219                             colModel : [
220                                 {
221                                     xtype: 'ColumnModel',
222                                     xns: Roo.grid,
223                                     align : 'right',
224                                     dataIndex : 'poitem_linenumber',
225                                     header : 'Line#',
226                                     width : 50,
227                                     renderer : function(v) { return String.format('{0}', v); }
228                                 },
229                                 {
230                                     xtype: 'ColumnModel',
231                                     xns: Roo.grid,
232                                     dataIndex : 'item_number',
233                                     header : 'Item code',
234                                     width : 100,
235                                     renderer : function(v) { return String.format('{0}', v); },
236                                     editor : {
237                                         xtype: 'GridEditor',
238                                         xns: Roo.grid,
239                                         field : {
240                                             xtype: 'ComboBox',
241                                             xns: Roo.form,
242                                             listeners : {
243                                                 beforeselect : function (combo, record, index)
244                                                 {
245                                                   var ar = _this.grid.activeEditor.record;
246                                                   
247                                                   (function() { 
248                                                       ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
249                                                       ar.set('poitem_itemsite_id', record.data.itemsite_id);
250                                                   }).defer(100);
251                                                   
252                                                 }
253                                             },
254                                             allowBlank : false,
255                                             displayField : 'itemsite_item_id_item_number',
256                                             editable : true,
257                                             emptyText : "Select item",
258                                             forceSelection : true,
259                                             hiddenName : 'itemsite_item_id_item_number',
260                                             listWidth : 400,
261                                             loadingText : "Searching...",
262                                             minChars : 2,
263                                             name : 'item_number',
264                                             pageSize : 20,
265                                             qtip : "Select item",
266                                             queryParam : 'query[number]',
267                                             selectOnFocus : true,
268                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> - {itemsite_item_id_item_descrip1} </div>',
269                                             triggerAction : 'all',
270                                             typeAhead : false,
271                                             valueField : 'item_number',
272                                             store : {
273                                                 xtype: 'Store',
274                                                 xns: Roo.data,
275                                                 listeners : {
276                                                     beforeload : function (_self, o){
277                                                         o.params = o.params || {}; 
278                                                         o.params.itemsite_posupply = 1;
279                                                     }
280                                                 },
281                                                 remoteSort : true,
282                                                 sortInfo : { direction : 'ASC', field: 'item_number' },
283                                                 proxy : {
284                                                     xtype: 'HttpProxy',
285                                                     xns: Roo.data,
286                                                     method : 'GET',
287                                                     url : baseURL + '/Roo/itemsite.php'
288                                                 },
289                                                 reader : {
290                                                     xtype: 'JsonReader',
291                                                     xns: Roo.data,
292                                                     id : 'itemsite_id',
293                                                     root : 'data',
294                                                     totalProperty : 'total',
295                                                     fields : [{"name":"item_id","type":"int"},"item_number"]
296                                                 }
297                                             }
298                                         }
299                                     }
300                                 },
301                                 {
302                                     xtype: 'ColumnModel',
303                                     xns: Roo.grid,
304                                     dataIndex : 'item_descrip1',
305                                     header : 'Item description',
306                                     width : 150,
307                                     renderer : function(v) { return String.format('{0}', v); }
308                                 },
309                                 {
310                                     xtype: 'ColumnModel',
311                                     xns: Roo.grid,
312                                     dataIndex : 'poitem_duedate',
313                                     header : 'Due date',
314                                     width : 100,
315                                     renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }
316                                 },
317                                 {
318                                     xtype: 'ColumnModel',
319                                     xns: Roo.grid,
320                                     align : 'right',
321                                     dataIndex : 'poitem_qty_ordered',
322                                     header : 'Ordered',
323                                     width : 75,
324                                     renderer : function(v) { return String.format('{0}', v); },
325                                     editor : {
326                                         xtype: 'GridEditor',
327                                         xns: Roo.grid,
328                                         field : {
329                                             xtype: 'NumberField',
330                                             xns: Roo.form,
331                                             allowDecimals : false,
332                                             decimalPrecision : 0,
333                                             minValue : 1,
334                                             style : 'text-align:right'
335                                         }
336                                     }
337                                 },
338                                 {
339                                     xtype: 'ColumnModel',
340                                     xns: Roo.grid,
341                                     align : 'right',
342                                     dataIndex : 'poitem_qty_received',
343                                     header : 'Received',
344                                     width : 75,
345                                     renderer : function(v,x,r) { 
346                                         return String.format(
347                                             r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style="color:red">{0}</span>':  '{0}',
348                                              v - r.data.poitem_qty_returned);
349                                     }
350                                 },
351                                 {
352                                     xtype: 'ColumnModel',
353                                     xns: Roo.grid,
354                                     align : 'right',
355                                     dataIndex : 'poitem_qty_vouchered',
356                                     header : 'Vouchered',
357                                     width : 65,
358                                     renderer : function(v,x,r) { 
359                                         return String.format(
360                                             r.data.poitem_qty_ordered != v ? '<span style="color:red">{0}</span>':  '{0}',
361                                              v);
362                                     }
363                                 },
364                                 {
365                                     xtype: 'ColumnModel',
366                                     xns: Roo.grid,
367                                     align : 'right',
368                                     dataIndex : 'poitem_unitprice',
369                                     header : 'Unit price',
370                                     width : 100,
371                                     renderer : function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); },
372                                     editor : {
373                                         xtype: 'GridEditor',
374                                         xns: Roo.grid,
375                                         field : {
376                                             xtype: 'NumberField',
377                                             xns: Roo.form,
378                                             allowBlank : false,
379                                             allowDecimals : false,
380                                             decimalPrecision : 0,
381                                             minValue : 1,
382                                             style : 'text-align:right'
383                                         }
384                                     }
385                                 }
386                             ]
387                         }
388                     }
389                 ],
390                 center : {
391                     xtype: 'LayoutRegion',
392                     xns: Roo,
393                     autoScroll : false,
394                     split : true
395                 }
396             }
397         };
398     }
399 });