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                     _this.img_upload_form.reset();
148                     if(_this.data.id * 1 > 0) {
149                         this.doAction('load',{ method: 'GET', params: { '_id' : _this.data.id }});
150                         _this.modal.setTitle('Modify Company');
151                         _this.onid.setValue(_this.data.id);
152                         
153                         if(_this.data.logo_id * 1 > 0) {
154                             _this.logo.el.dom.src = String.format('{0}/Images/Thumb/300/{1}/', baseURL, _this.data.logo_id); 
155                         }
156                     } else {
157                        _this.modal.setTitle('Add Company');
158                        _this.onid.setValue(''); 
159                        _this.logo.el.dom.src = ''; 
160                     }
161                     //_this.type.store.load({}); 
162             
163                     _this.ontable.setValue('core_company');
164             
165                     _this.imgtype.setValue('LOGO');
166                     return;
167                 }
168                
169                
170                 if (action.type == 'load') {
171                     _this.data = action.result.data;
172                     var meth = _this.data.comptype == 'OWNER' ? 'disable' : 'enable';
173                  
174                         
175                     if (_this.form.findField('comptype')) {
176                         _this.form.findField('comptype')[meth]();
177                     }
178                       
179                    // _this.loaded();
180                     return;
181                 }
182                 
183                 
184                 if (action.type == 'submit') { // only submitted here if we are 
185                     //_this.dialog.hide();
186                    
187                     if(_this.logo.getValue()!='') 
188                     {
189                         _this.img_upload_form.method = 'POST';
190                         _this.form.doAction("submit");
191                     }
192                    
193                     if (_this.callback) {
194                         _this.callback.call(this, action.result.data);
195                     }
196                     return; 
197                 }
198             },
199            actionfailed : function (_self, action)
200             {
201                 //Pman.standardActionFailed(_self,action);
202                             
203                  Roo.bootstrap.MessageBox.alert(action.result.errorMsg);
204             
205             },
206            render : function (_self)
207             {
208                 _this.form = _self; 
209             }
210           },
211           xns : Roo.bootstrap,
212           '|xns' : 'Roo.bootstrap',
213           items  : [
214            {
215             xtype : 'Input',
216             inputType : 'hidden',
217             name : 'id',
218             listeners : {
219              render : function (_self)
220               {
221                   _this.companyID = _self;
222               }
223             },
224             xns : Roo.bootstrap,
225             '|xns' : 'Roo.bootstrap'
226            },
227            {
228             xtype : 'ComboBox',
229             allowBlank : false,
230             alwaysQuery : true,
231             displayField : 'display_name',
232             editable : false,
233             fieldLabel : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
234             hiddenName : 'comptype',
235             labelAlign : 'left',
236             listWidth : 250,
237             loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
238             minChars : 2,
239             name : 'comptype_display_name',
240             queryParam : 'query[name]',
241             selectOnFocus : true,
242             triggerAction : 'all',
243             typeAhead : false,
244             valueField : 'name',
245             listeners : {
246              render : function (_self)
247               {
248                   _this.type = _self;
249                   _self.store.load({});
250               }
251             },
252             xns : Roo.bootstrap,
253             '|xns' : 'Roo.bootstrap',
254             store : {
255              xtype : 'Store',
256              remoteSort : true,
257              sortInfo : '{ direction : \'ASC\', field: \'id\' }',
258              listeners : {
259               beforeload : function (_self, options)
260                {
261                    options.params = options.params || {};
262                    // set more here
263                    //o.params['query[empty_etype]'] = 1;
264                    options.params.etype = 'COMPTYPE';
265                }
266              },
267              xns : Roo.data,
268              '|xns' : 'Roo.data',
269              proxy : {
270               xtype : 'HttpProxy',
271               method : 'GET',
272               url : baseURL + '/Roo/core_enum.php',
273               xns : Roo.data,
274               '|xns' : 'Roo.data'
275              },
276              reader : {
277               xtype : 'JsonReader',
278               id : 'id',
279               root : 'data',
280               totalProperty : 'total',
281               xns : Roo.data,
282               '|xns' : 'Roo.data'
283              }
284             }
285            },
286            {
287             xtype : 'Input',
288             fieldLabel : _this._strings['1c76cbfe21c6f44c1d1e59d54f3e4420'] /* Company */,
289             labelAlign : 'left',
290             name : 'name',
291             listeners : {
292              render : function (_self)
293               {
294                   _this.company = _self;
295               }
296             },
297             xns : Roo.bootstrap,
298             '|xns' : 'Roo.bootstrap'
299            },
300            {
301             xtype : 'Input',
302             fieldLabel : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
303             labelAlign : 'left',
304             name : 'tel',
305             listeners : {
306              render : function (_self)
307               {
308                   _this.tel = _self;
309               }
310             },
311             xns : Roo.bootstrap,
312             '|xns' : 'Roo.bootstrap'
313            },
314            {
315             xtype : 'Input',
316             fieldLabel : _this._strings['9810aa2b9f44401be4bf73188ef2b67d'] /* Fax */,
317             labelAlign : 'left',
318             name : 'fax',
319             listeners : {
320              render : function (_self)
321               {
322                   _this.fax = _self;
323               }
324             },
325             xns : Roo.bootstrap,
326             '|xns' : 'Roo.bootstrap'
327            },
328            {
329             xtype : 'Input',
330             fieldLabel : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
331             labelAlign : 'left',
332             name : 'email',
333             listeners : {
334              render : function (_self)
335               {
336                   _this.fax = _self;
337               }
338             },
339             xns : Roo.bootstrap,
340             '|xns' : 'Roo.bootstrap'
341            },
342            {
343             xtype : 'Input',
344             fieldLabel : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
345             labelAlign : 'left',
346             name : 'url',
347             listeners : {
348              render : function (_self)
349               {
350                   _this.url = _self;
351               }
352             },
353             xns : Roo.bootstrap,
354             '|xns' : 'Roo.bootstrap'
355            },
356            {
357             xtype : 'Input',
358             fieldLabel : _this._strings['dd7bf230fde8d4836917806aff6a6b27'] /* Address */,
359             labelAlign : 'left',
360             name : 'address',
361             listeners : {
362              render : function (_self)
363               {
364                   _this.address = _self;
365               }
366             },
367             xns : Roo.bootstrap,
368             '|xns' : 'Roo.bootstrap'
369            },
370            {
371             xtype : 'TextArea',
372             fieldLabel : _this._strings['231bc72756b5e6de492aaaa1577f61b1'] /* Remarks */,
373             labelAlign : 'left',
374             name : 'remarks',
375             listeners : {
376              render : function (_self)
377               {
378                   _this.remarks = _self;
379               }
380             },
381             xns : Roo.bootstrap,
382             '|xns' : 'Roo.bootstrap'
383            }
384           ]
385          }
386         ]
387        },
388        {
389         xtype : 'Column',
390         xs : 6,
391         xns : Roo.bootstrap,
392         '|xns' : 'Roo.bootstrap',
393         items  : [
394          {
395           xtype : 'Row',
396           xns : Roo.bootstrap,
397           '|xns' : 'Roo.bootstrap',
398           items  : [
399            {
400             xtype : 'Column',
401             xns : Roo.bootstrap,
402             '|xns' : 'Roo.bootstrap',
403             items  : [
404              {
405               xtype : 'Img',
406               imgResponsive : true,
407               style : 'text-align: center; margin-left: auto; margin-right: auto; ',
408               listeners : {
409                render : function (_self)
410                 {
411                     _this.logo = _self;
412                 }
413               },
414               xns : Roo.bootstrap,
415               '|xns' : 'Roo.bootstrap'
416              }
417             ]
418            }
419           ]
420          },
421          {
422           xtype : 'Row',
423           xns : Roo.bootstrap,
424           '|xns' : 'Roo.bootstrap',
425           items  : [
426            {
427             xtype : 'Column',
428             xns : Roo.bootstrap,
429             '|xns' : 'Roo.bootstrap',
430             items  : [
431              {
432               xtype : 'Form',
433               fileUpload : true,
434               method : 'POST',
435               style : 'margin:15px;',
436               url : baseURL + '/Roo/Images.php',
437               listeners : {
438                actioncomplete : function (_self, action)
439                 {
440                     if(action.type == 'setdata'){
441                         _self.reset(); 
442                         if(_this.data.id * 1 > 0) {
443                             _this.onid.setValue(_this.data.id);
444                             _this.ontable.setValue('coba_company');
445                         }        
446                         return;
447                     }
448                    
449                    if (action.type == 'submit') { // only submitted here if we are 
450                         if (_this.callback) {
451                             _this.callback.call(this, action.result.data);
452                             
453                             console.log(action.result.data);
454                         }
455                         return;
456                     }
457                 },
458                actionfailed : function (_self, action)
459                 {
460                 
461                 },
462                render : function (_self)
463                 {
464                     _this.img_upload_form = _self;
465                 }
466               },
467               xns : Roo.bootstrap,
468               '|xns' : 'Roo.bootstrap',
469               items  : [
470                {
471                 xtype : 'Input',
472                 allowBlank : false,
473                 fieldLabel : _this._strings['b999e07cf80ea5eca8e589cd8540a81e'] /* Select Logo */,
474                 forceFeedback : true,
475                 inputType : 'file',
476                 listeners : { 
477                        'change' : function(e) { 
478                             console.log(e);     
479                        }
480                 },
481                 name : 'imageUpload',
482                 listeners : {
483                  change : function (_self, newValue, oldValue)
484                   { 
485                       console.log(newValue);
486                   }
487                 },
488                 xns : Roo.bootstrap,
489                 '|xns' : 'Roo.bootstrap'
490                },
491                {
492                 xtype : 'Input',
493                 inputType : 'input',
494                 name : 'onid',
495                 listeners : {
496                  render : function (_self)
497                   {
498                       _this.onid = _self;
499                   }
500                 },
501                 xns : Roo.bootstrap,
502                 '|xns' : 'Roo.bootstrap'
503                },
504                {
505                 xtype : 'Input',
506                 inputType : 'input',
507                 name : 'ontable',
508                 listeners : {
509                  render : function (_self)
510                   {
511                       _this.ontable = _self;
512                   }
513                 },
514                 xns : Roo.bootstrap,
515                 '|xns' : 'Roo.bootstrap'
516                },
517                {
518                 xtype : 'Input',
519                 inputType : 'input',
520                 name : 'imgtype',
521                 listeners : {
522                  render : function (_self)
523                   {
524                       _this.imgtype = _self;
525                   }
526                 },
527                 xns : Roo.bootstrap,
528                 '|xns' : 'Roo.bootstrap'
529                }
530               ]
531              }
532             ]
533            }
534           ]
535          }
536         ]
537        }
538       ]
539      },
540      {
541       xtype : 'Row',
542       xns : Roo.bootstrap,
543       '|xns' : 'Roo.bootstrap',
544       items  : [
545        {
546         xtype : 'Column',
547         xns : Roo.bootstrap,
548         '|xns' : 'Roo.bootstrap'
549        }
550       ]
551      }
552     ]
553    }  );
554  }
555 });
556 Roo.apply(Pman.Dialog.BAdminCompany, Pman.Dialog.BAdminCompany.prototype);