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