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