sync
[Pman.Admin] / Pman.Tab.AdminOffice.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.AdminOffice = new Roo.XComponent({
8
9  _strings : {
10   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
11   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
12   '14820f8c54725a56438e99f6bd57dfa3' :"Displaying Office{0} - {1} of {2}",
13   '7dce122004969d56ae2e0245cb754d35' :"Edit",
14   '7407f706267593de473324b2c07ef2fc' :"Offices / Departments / Sub-Companies",
15   '217574e21514de41ec31aaf5ddadb2c3' :"No Office found",
16   'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
17   'a8fa7984f57a42bb41143f3d7665bd36' :"Name / Department / Sub Comp.",
18   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
19   'dd7bf230fde8d4836917806aff6a6b27' :"Address",
20   '9810aa2b9f44401be4bf73188ef2b67d' :"Fax"
21  },
22
23   part     :  ["Admin", "Office" ],
24   order    : '001-Pman.Tab.AdminOffice',
25   region   : 'center',
26   parent   : 'Pman.Tab.AdminCompanies',
27   name     : "Pman.Tab.AdminOffice",
28   disabled : false, 
29   permname : '', 
30   _tree : function(_data)
31   {
32    var _this = this;
33    var MODULE = this;
34    return {
35    xtype : 'GridPanel',
36    background : true,
37    fitContainer : true,
38    fitToframe : true,
39    region : 'south',
40    tableName : 'Office',
41    title : _this._strings['7407f706267593de473324b2c07ef2fc'] /* Offices / Departments / Sub-Companies */,
42    listeners : {
43     activate : function() {
44          _this.panel = this;
45          if (_this.grid) {
46              _this.grid.footer.onClick('first');
47          }
48      }
49    },
50    xns : Roo,
51    '|xns' : 'Roo',
52    grid : {
53     xtype : 'Grid',
54     autoExpandColumn : 'name',
55     loadMask : true,
56     listeners : {
57      render : function() 
58       {
59           _this.grid = this; 
60           _this.dialog =Pman.Dialog.Office;
61           if (_this.panel.active) {
62              this.footer.onClick('first');
63           } 
64       },
65      rowdblclick : function (_self, rowIndex, e)
66       {
67           if (!_this.dialog) { 
68               return; 
69           }
70           _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
71               _this.grid.footer.onClick('first');
72           }); 
73       }
74     },
75     xns : Roo.grid,
76     '|xns' : 'Roo.grid',
77     footer : {
78      xtype : 'PagingToolbar',
79      displayInfo : true,
80      displayMsg : _this._strings['14820f8c54725a56438e99f6bd57dfa3'] /* Displaying Office{0} - {1} of {2} */,
81      emptyMsg : _this._strings['217574e21514de41ec31aaf5ddadb2c3'] /* No Office found */,
82      pageSize : 25,
83      xns : Roo,
84      '|xns' : 'Roo'
85     },
86     toolbar : {
87      xtype : 'Toolbar',
88      xns : Roo,
89      '|xns' : 'Roo',
90      items  : [
91       {
92        xtype : 'Button',
93        cls : 'x-btn-text-icon',
94        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
95        text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
96        listeners : {
97         click : function()
98          {
99              if (!_this.dialog) {
100               return;
101              }
102              var sd = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected();
103              if (!sd) {
104                  Roo.MessageBox.alert("Error", "Select an company to add an office to");
105                  return;
106              }
107              var cdata = sd.data;
108              _this. dialog.show( { 
109                  id : 0 ,
110                  company_name : cdata.name,
111                  company_id : cdata.id,
112                  address : cdata.address,
113                  phone : cdata.tel,
114                  fax : cdata.fax,
115                  email  : cdata.email
116              } , function() {
117                  _this.grid.footer.onClick('first');
118             });
119          }
120        },
121        xns : Roo.Toolbar,
122        '|xns' : 'Roo.Toolbar'
123       },
124       {
125        xtype : 'Button',
126        cls : 'x-btn-text-icon',
127        icon : Roo.rootURL + 'images/default/tree/leaf.gif',
128        text : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
129        listeners : {
130         click : function()
131          {
132              var s = _this.grid.getSelectionModel().getSelections();
133              if (!s.length || (s.length > 1))  {
134                  Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
135                  return;
136              }
137              if (!_this.dialog) {
138                  return;
139              }
140              s[0].data.company_name = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected().data.name;
141              _this.dialog.show(s[0].data, function() {
142                  _this.grid.footer.onClick('first');
143              }); 
144              
145          }
146        },
147        xns : Roo.Toolbar,
148        '|xns' : 'Roo.Toolbar'
149       },
150       {
151        xtype : 'Button',
152        cls : 'x-btn-text-icon',
153        icon : rootURL + '/Pman/templates/images/trash.gif',
154        text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
155        listeners : {
156         click : function()
157          {
158               Pman.genericDelete(_this, 'Office'); 
159          }
160        },
161        xns : Roo.Toolbar,
162        '|xns' : 'Roo.Toolbar'
163       }
164      ]
165     },
166     dataSource : {
167      xtype : 'Store',
168      remoteSort : true,
169      sortInfo : { field : 'name', direction: 'ASC' },
170      listeners : {
171       beforeload : function (_self, o)
172        {
173            try {
174                var sm = Pman.Tab.AdminCompanies.grid.getSelectionModel();
175                sm = sm.getSelected();
176                if (!sm || !sm.data.id) {
177                    // mask??
178                    return false;
179                }
180                       
181                o.params.company_id = sm.data.id ;
182            } catch (e) {
183                return false;
184            }
185            
186            
187         }
188      },
189      xns : Roo.data,
190      '|xns' : 'Roo.data',
191      proxy : {
192       xtype : 'HttpProxy',
193       method : 'GET',
194       url : baseURL + '/Roo/core_office.php',
195       xns : Roo.data,
196       '|xns' : 'Roo.data'
197      },
198      reader : {
199       xtype : 'JsonReader',
200       fields : [
201           {
202               'name': 'id',
203               'type': 'int'
204           },
205           {
206               'name': 'company_id',
207               'type': 'int'
208           },
209           {
210               'name': 'name',
211               'type': 'string'
212           },
213           {
214               'name': 'address',
215               'type': 'string'
216           },
217           {
218               'name': 'phone',
219               'type': 'string'
220           },
221           {
222               'name': 'fax',
223               'type': 'string'
224           },
225           {
226               'name': 'email',
227               'type': 'string'
228           },
229           {
230               'name': 'role',
231               'type': 'string'
232           },
233           {
234               'name': 'company_id_code',
235               'type': 'string'
236           },
237           {
238               'name': 'company_id_name',
239               'type': 'string'
240           },
241           {
242               'name': 'company_id_remarks',
243               'type': 'string'
244           },
245           {
246               'name': 'company_id_owner_id',
247               'type': 'int'
248           },
249           {
250               'name': 'company_id_address',
251               'type': 'string'
252           },
253           {
254               'name': 'company_id_tel',
255               'type': 'string'
256           },
257           {
258               'name': 'company_id_fax',
259               'type': 'string'
260           },
261           {
262               'name': 'company_id_email',
263               'type': 'string'
264           },
265           {
266               'name': 'company_id_id',
267               'type': 'int'
268           },
269           {
270               'name': 'company_id_isOwner',
271               'type': 'int'
272           },
273           {
274               'name': 'company_id_logo_id',
275               'type': 'int'
276           },
277           {
278               'name': 'company_id_background_color',
279               'type': 'string'
280           },
281           {
282               'name': 'company_id_comptype',
283               'type': 'string'
284           },
285           {
286               'name': 'company_id_url',
287               'type': 'string'
288           },
289           {
290               'name': 'company_id_main_office_id',
291               'type': 'int'
292           },
293           {
294               'name': 'company_id_created_by',
295               'type': 'int'
296           },
297           {
298               'name': 'company_id_created_dt',
299               'type': 'date'
300           },
301           {
302               'name': 'company_id_updated_by',
303               'type': 'int'
304           },
305           {
306               'name': 'company_id_updated_dt',
307               'type': 'date'
308           },
309           {
310               'name': 'company_id_passwd',
311               'type': 'string'
312           },
313           {
314               'name': 'company_id_dispatch_port',
315               'type': 'string'
316           },
317           {
318               'name': 'company_id_province',
319               'type': 'string'
320           },
321           {
322               'name': 'company_id_country',
323               'type': 'string'
324           }
325       ],
326       id : 'id',
327       root : 'data',
328       totalProperty : 'total',
329       xns : Roo.data,
330       '|xns' : 'Roo.data'
331      }
332     },
333     colModel : [
334      {
335       xtype : 'ColumnModel',
336       dataIndex : 'name',
337       header : _this._strings['a8fa7984f57a42bb41143f3d7665bd36'] /* Name / Department / Sub Comp. */,
338       renderer : function(v) { return String.format('{0}', v); },
339       sortable : true,
340       width : 200,
341       xns : Roo.grid,
342       '|xns' : 'Roo.grid'
343      },
344      {
345       xtype : 'ColumnModel',
346       dataIndex : 'phone',
347       header : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
348       renderer : function(v) { return String.format('{0}', v); },
349       width : 100,
350       xns : Roo.grid,
351       '|xns' : 'Roo.grid'
352      },
353      {
354       xtype : 'ColumnModel',
355       dataIndex : 'fax',
356       header : _this._strings['9810aa2b9f44401be4bf73188ef2b67d'] /* Fax */,
357       renderer : function(v) { return String.format('{0}', v); },
358       width : 100,
359       xns : Roo.grid,
360       '|xns' : 'Roo.grid'
361      },
362      {
363       xtype : 'ColumnModel',
364       dataIndex : 'email',
365       header : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
366       renderer : function (v) {
367           return (v.length && v.indexOf('@') > 0 ) ? 
368               String.format('<a href="mailto:{0}">{0}</a>',v) : v;
369               
370       },
371       width : 200,
372       xns : Roo.grid,
373       '|xns' : 'Roo.grid'
374      },
375      {
376       xtype : 'ColumnModel',
377       dataIndex : 'address',
378       header : _this._strings['dd7bf230fde8d4836917806aff6a6b27'] /* Address */,
379       renderer : function(v) { return String.format('{0}', v); },
380       width : 300,
381       xns : Roo.grid,
382       '|xns' : 'Roo.grid'
383      }
384     ]
385    }
386   };  }
387 });