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