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