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