Pman.Dialog.BAdminCompany.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminCompany.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.Dialog');
6
7 Pman.Dialog.BAdminCompany= function() {}
8 Roo.apply(Pman.Dialog.BAdminCompany.prototype, {
9
10  _strings : {
11   '1c76cbfe21c6f44c1d1e59d54f3e4420' :"Company",
12   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
13   '231bc72756b5e6de492aaaa1577f61b1' :"Remarks",
14   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
15   'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
16   '66bc3ece76861852889e623217049d32' :"Edit Company Details",
17   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
18   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
19   'dd7bf230fde8d4836917806aff6a6b27' :"Address",
20   'c9cc8cce247e49bae79f15173ce97354' :"Save",
21   'e6b391a8d2c4d45902a23a8b6585703d' :"URL"
22  },
23  _named_strings : {
24   'tel_fieldLabel' : 'bcc254b55c4a1babdf1dcb82c207506b' /* Phone */ ,
25   'comptype_display_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
26   'name_fieldLabel' : '1c76cbfe21c6f44c1d1e59d54f3e4420' /* Company */ ,
27   'remarks_fieldLabel' : '231bc72756b5e6de492aaaa1577f61b1' /* Remarks */ ,
28   'url_fieldLabel' : 'e6b391a8d2c4d45902a23a8b6585703d' /* URL */ ,
29   'email_fieldLabel' : 'ce8ae9da5b7cd6c3df2929543a9af92d' /* Email */ ,
30   'address_fieldLabel' : 'dd7bf230fde8d4836917806aff6a6b27' /* Address */ ,
31   'comptype_display_name_fieldLabel' : 'a1fa27779242b4902f7ae3bdd5c6d508' /* Type */ 
32  },
33
34  dialog : false,
35  callback:  false,
36
37  show : function(data, cb)
38  {
39   if (!this.dialog) {
40    this.create();
41   }
42
43   this.callback = cb;
44   this.data = data;
45   this.dialog.show(this.data._el);
46   if (this.form) {
47    this.form.reset();
48    this.form.setValues(data);
49    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
50   }
51
52  },
53
54  create : function()
55  {
56   var _this = this;
57   this.dialog = Roo.factory({
58     xtype : 'Modal',
59     cls : 'enable-overflow padding-bottom-trim badmin-dialog-company',
60     size : 'lg',
61     title : _this._strings['66bc3ece76861852889e623217049d32'] /* Edit Company Details */,
62     listeners : {
63      render : function (_self)
64       {
65           _this.modal = _self;
66       }
67     },
68     xns : Roo.bootstrap,
69     '|xns' : 'Roo.bootstrap',
70     buttons : [
71      {
72       xtype : 'Button',
73       html : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
74       weight : 'default',
75       listeners : {
76        click : function (_self, e)
77         {
78             _this.dialog.hide();
79         }
80       },
81       xns : Roo.bootstrap,
82       '|xns' : 'Roo.bootstrap'
83      },
84      {
85       xtype : 'Button',
86       html : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
87       weight : 'primary',
88       listeners : {
89        click : function (_self, e)
90         {
91             if(!_this.form.isValid()){
92                 Roo.bootstrap.MessageBox.alert('Error', 'Please Correct all the errors in red');
93                 return;
94             }
95             
96             var myID = _this.form.findField('id').getValue();
97             var myName = _this.form.findField('name').getValue();
98             
99             console.log(myID + ' ' + myName);
100             
101             new Pman.Request({
102                 url : baseURL + '/Roo/Core_company.php',
103                 method : 'POST',
104                 params : {
105                   id : _this.form.findField('id').getValue() * 1,
106                   name : _this.form.findField('name').getValue(),
107                   _check_name : 1
108                 }, 
109                 success : function(res) {
110                    
111                     // Adding new record
112                     _this.form.doAction("submit");
113                 },
114                 failure : function(res) {
115                    _this.form.doAction("submit");
116                 }
117             });
118              
119             return;
120             
121         },
122        render : function (_self)
123         {
124             _this.btn_ok=this;
125         }
126       },
127       xns : Roo.bootstrap,
128       '|xns' : 'Roo.bootstrap'
129      }
130     ],
131     items  : [
132      {
133       xtype : 'Container',
134       style : 'width: 100%;',
135       xns : Roo.bootstrap,
136       '|xns' : 'Roo.bootstrap',
137       items  : [
138        {
139         xtype : 'Form',
140         url : baseURL + '/Roo/Core_company.php',
141         listeners : {
142          actioncomplete : function (_self, action)
143           {
144               if(action.type == 'setdata'){
145                   _self.reset(); 
146           
147                   if(_this.data.id * 1 > 0) {
148                       this.doAction('load',{ method: 'GET', params: { '_id' : _this.data.id }});
149                       _this.modal.setTitle('Edit Company Details');
150                       
151                   } else {
152                      _this.modal.setTitle('Create Company');
153                   }
154                   return;
155               }
156              
157              
158               if (action.type == 'load') {
159                   _this.data = action.result.data;
160                   
161                   if(_this.data.comptype == 'OWNER'){
162                       _this.form.findField('comptype').hide();
163                   }
164                   
165                   return;
166               }
167               
168               
169               if (action.type == 'submit') { // only submitted here if we are 
170                   //_this.dialog.hide();
171                   
172                   _this.dialog.hide();
173                   
174                    if (_this.callback) {
175                       _this.callback.call(this, action.result.data);
176                    }
177                   return; 
178               }
179           },
180          actionfailed : function (_self, action)
181           {
182               //Pman.standardActionFailed(_self,action);
183               
184               if (!this.isValid) {
185                   return;
186               }
187               
188               Roo.bootstrap.MessageBox.alert(action.result.errorMsg);
189           
190           },
191          render : function (_self)
192           {
193               _this.form = _self; 
194           }
195         },
196         xns : Roo.bootstrap,
197         '|xns' : 'Roo.bootstrap',
198         items  : [
199          {
200           xtype : 'Row',
201           xns : Roo.bootstrap,
202           '|xns' : 'Roo.bootstrap',
203           items  : [
204            {
205             xtype : 'Column',
206             md : 12,
207             xns : Roo.bootstrap,
208             '|xns' : 'Roo.bootstrap',
209             items  : [
210              {
211               xtype : 'ComboBox',
212               allowBlank : false,
213               alwaysQuery : true,
214               displayField : 'display_name',
215               editable : false,
216               fieldLabel : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
217               hiddenName : 'comptype',
218               indicatorpos : 'left',
219               loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
220               minChars : 2,
221               name : 'comptype_display_name',
222               queryParam : 'query[name]',
223               selectOnFocus : true,
224               triggerAction : 'all',
225               typeAhead : false,
226               valueField : 'name',
227               listeners : {
228                render : function (_self)
229                 {
230                     _this.type = _self;
231                     _self.store.load({});
232                 }
233               },
234               xns : Roo.bootstrap,
235               '|xns' : 'Roo.bootstrap',
236               store : {
237                xtype : 'Store',
238                remoteSort : true,
239                sortInfo : '{ direction : \'ASC\', field: \'id\' }',
240                listeners : {
241                 beforeload : function (_self, options)
242                  {
243                      options.params = options.params || {};
244                      // set more here
245                      //o.params['query[empty_etype]'] = 1;
246                      options.params.etype = 'COMPTYPE';
247                  }
248                },
249                xns : Roo.data,
250                '|xns' : 'Roo.data',
251                proxy : {
252                 xtype : 'HttpProxy',
253                 method : 'GET',
254                 url : baseURL + '/Roo/core_enum.php',
255                 xns : Roo.data,
256                 '|xns' : 'Roo.data'
257                },
258                reader : {
259                 xtype : 'JsonReader',
260                 id : 'id',
261                 root : 'data',
262                 totalProperty : 'total',
263                 xns : Roo.data,
264                 '|xns' : 'Roo.data'
265                }
266               }
267              }
268             ]
269            }
270           ]
271          },
272          {
273           xtype : 'Row',
274           xns : Roo.bootstrap,
275           '|xns' : 'Roo.bootstrap',
276           items  : [
277            {
278             xtype : 'Column',
279             md : 12,
280             xns : Roo.bootstrap,
281             '|xns' : 'Roo.bootstrap',
282             items  : [
283              {
284               xtype : 'Input',
285               fieldLabel : _this._strings['1c76cbfe21c6f44c1d1e59d54f3e4420'] /* Company */,
286               indicatorpos : 'left',
287               name : 'name',
288               listeners : {
289                render : function (_self)
290                 {
291                     _this.company = _self;
292                 }
293               },
294               xns : Roo.bootstrap,
295               '|xns' : 'Roo.bootstrap'
296              }
297             ]
298            }
299           ]
300          },
301          {
302           xtype : 'Row',
303           xns : Roo.bootstrap,
304           '|xns' : 'Roo.bootstrap',
305           items  : [
306            {
307             xtype : 'Column',
308             md : 12,
309             xns : Roo.bootstrap,
310             '|xns' : 'Roo.bootstrap',
311             items  : [
312              {
313               xtype : 'Input',
314               fieldLabel : _this._strings['dd7bf230fde8d4836917806aff6a6b27'] /* Address */,
315               indicatorpos : 'left',
316               name : 'address',
317               listeners : {
318                render : function (_self)
319                 {
320                     _this.address = _self;
321                 }
322               },
323               xns : Roo.bootstrap,
324               '|xns' : 'Roo.bootstrap'
325              }
326             ]
327            }
328           ]
329          },
330          {
331           xtype : 'Row',
332           xns : Roo.bootstrap,
333           '|xns' : 'Roo.bootstrap',
334           items  : [
335            {
336             xtype : 'Column',
337             md : 12,
338             xns : Roo.bootstrap,
339             '|xns' : 'Roo.bootstrap',
340             items  : [
341              {
342               xtype : 'Input',
343               fieldLabel : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
344               indicatorpos : 'left',
345               name : 'tel',
346               listeners : {
347                render : function (_self)
348                 {
349                     _this.tel = _self;
350                 }
351               },
352               xns : Roo.bootstrap,
353               '|xns' : 'Roo.bootstrap'
354              }
355             ]
356            }
357           ]
358          },
359          {
360           xtype : 'Row',
361           xns : Roo.bootstrap,
362           '|xns' : 'Roo.bootstrap',
363           items  : [
364            {
365             xtype : 'Column',
366             md : 12,
367             xns : Roo.bootstrap,
368             '|xns' : 'Roo.bootstrap',
369             items  : [
370              {
371               xtype : 'Input',
372               fieldLabel : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
373               indicatorpos : 'left',
374               name : 'email',
375               listeners : {
376                render : function (_self)
377                 {
378                     _this.fax = _self;
379                 }
380               },
381               xns : Roo.bootstrap,
382               '|xns' : 'Roo.bootstrap'
383              }
384             ]
385            }
386           ]
387          },
388          {
389           xtype : 'Row',
390           xns : Roo.bootstrap,
391           '|xns' : 'Roo.bootstrap',
392           items  : [
393            {
394             xtype : 'Column',
395             md : 12,
396             xns : Roo.bootstrap,
397             '|xns' : 'Roo.bootstrap',
398             items  : [
399              {
400               xtype : 'Input',
401               fieldLabel : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
402               indicatorpos : 'left',
403               name : 'url',
404               listeners : {
405                render : function (_self)
406                 {
407                     _this.url = _self;
408                 }
409               },
410               xns : Roo.bootstrap,
411               '|xns' : 'Roo.bootstrap'
412              }
413             ]
414            }
415           ]
416          },
417          {
418           xtype : 'Row',
419           cls : 'badmin-company-edit-remark',
420           xns : Roo.bootstrap,
421           '|xns' : 'Roo.bootstrap',
422           items  : [
423            {
424             xtype : 'Column',
425             md : 12,
426             xns : Roo.bootstrap,
427             '|xns' : 'Roo.bootstrap',
428             items  : [
429              {
430               xtype : 'TextArea',
431               fieldLabel : _this._strings['231bc72756b5e6de492aaaa1577f61b1'] /* Remarks */,
432               indicatorpos : 'left',
433               name : 'remarks',
434               listeners : {
435                render : function (_self)
436                 {
437                     _this.remarks = _self;
438                 }
439               },
440               xns : Roo.bootstrap,
441               '|xns' : 'Roo.bootstrap'
442              }
443             ]
444            }
445           ]
446          },
447          {
448           xtype : 'Input',
449           inputType : 'hidden',
450           name : 'id',
451           listeners : {
452            render : function (_self)
453             {
454                 _this.companyID = _self;
455             }
456           },
457           xns : Roo.bootstrap,
458           '|xns' : 'Roo.bootstrap'
459          }
460         ]
461        }
462       ]
463      }
464     ]
465    }  );
466  }
467 });
468 Roo.apply(Pman.Dialog.BAdminCompany, Pman.Dialog.BAdminCompany.prototype);