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