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