SimpleExcel.php
[Pman.Core] / Pman.Dialog.CoreCompanies.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.CoreCompanies = {
8
9  _strings : {
10   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
11   '231bc72756b5e6de492aaaa1577f61b1' :"Remarks",
12   'b33457e7e1cd5dbf1db34a0c60fcb75f' :"Company ID (for filing Ref.)",
13   '023a5dfa857c4aa0156e6685231a1dbd' :"Select Type",
14   '8535bcc0f05358a583bb432bbadf7e0d' :"Select type",
15   '733640ec0c9367df1b4d85eb286ed9ae' :"Enter code",
16   '8c04eb09879a05470fae436ba76e3bb9' :"Enter Url",
17   '4ef6052d74436756f08e95fd63949653' :"Enter Company Name",
18   'c54b90756cfbeff9217293b567cb2eb0' :"Enter remarks",
19   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
20   'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
21   'cf3a5d25d39613ad5bbc2f5eb0f9b675' :"Enter Fax Number",
22   '9f86c00615b1a210935ac28ff8ebbb22' :"Enter Email Address",
23   'e7b47c58815acf1d3afa59a84b5db7fb' :"Company Name",
24   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
25   '32c4e9483403d60115b21519178e5384' :"Enter Address",
26   'b9c49611cfda3259a2b837b39489e650' :"Add Image",
27   '72b9d3d2e231f1de7a2bd70737f644aa' :"Add / Edit Organization",
28   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
29   '02a3a357710cc2a5dfdfb74ed012fb59' :"Url",
30   'dd7bf230fde8d4836917806aff6a6b27' :"Address",
31   'c9cc8cce247e49bae79f15173ce97354' :"Save",
32   'bc3a4c40d007b8d610a16312970e5cb3' :"Enter Phone Number",
33   '9810aa2b9f44401be4bf73188ef2b67d' :"Fax",
34   '35cb9e66ff801a819684ee0fbeabaeeb' :"Background Colour",
35   'bc87ef2144ae15ef4f78211e73948051' :"Logo Image"
36  },
37  _named_strings : {
38   'name_qtip' : '4ef6052d74436756f08e95fd63949653' /* Enter Company Name */ ,
39   'tel_fieldLabel' : 'bcc254b55c4a1babdf1dcb82c207506b' /* Phone */ ,
40   'address_qtip' : '32c4e9483403d60115b21519178e5384' /* Enter Address */ ,
41   'background_color_fieldLabel' : '35cb9e66ff801a819684ee0fbeabaeeb' /* Background Colour */ ,
42   'comptype_id_display_name_emptyText' : '023a5dfa857c4aa0156e6685231a1dbd' /* Select Type */ ,
43   'comptype_id_display_name_fieldLabel' : 'a1fa27779242b4902f7ae3bdd5c6d508' /* Type */ ,
44   'comptype_id_display_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
45   'code_fieldLabel' : 'b33457e7e1cd5dbf1db34a0c60fcb75f' /* Company ID (for filing Ref.) */ ,
46   'fax_fieldLabel' : '9810aa2b9f44401be4bf73188ef2b67d' /* Fax */ ,
47   'name_fieldLabel' : 'e7b47c58815acf1d3afa59a84b5db7fb' /* Company Name */ ,
48   'fax_qtip' : 'cf3a5d25d39613ad5bbc2f5eb0f9b675' /* Enter Fax Number */ ,
49   'url_qtip' : '8c04eb09879a05470fae436ba76e3bb9' /* Enter Url */ ,
50   'remarks_fieldLabel' : '231bc72756b5e6de492aaaa1577f61b1' /* Remarks */ ,
51   'code_qtip' : '733640ec0c9367df1b4d85eb286ed9ae' /* Enter code */ ,
52   'tel_qtip' : 'bc3a4c40d007b8d610a16312970e5cb3' /* Enter Phone Number */ ,
53   'email_qtip' : '9f86c00615b1a210935ac28ff8ebbb22' /* Enter Email Address */ ,
54   'url_fieldLabel' : '02a3a357710cc2a5dfdfb74ed012fb59' /* Url */ ,
55   'remarks_qtip' : 'c54b90756cfbeff9217293b567cb2eb0' /* Enter remarks */ ,
56   'comptype_id_display_name_qtip' : '8535bcc0f05358a583bb432bbadf7e0d' /* Select type */ ,
57   'email_fieldLabel' : 'ce8ae9da5b7cd6c3df2929543a9af92d' /* Email */ ,
58   'address_fieldLabel' : 'dd7bf230fde8d4836917806aff6a6b27' /* Address */ ,
59   'logo_id_fieldLabel' : 'bc87ef2144ae15ef4f78211e73948051' /* Logo Image */ 
60  },
61
62  dialog : false,
63  callback:  false,
64
65  show : function(data, cb)
66  {
67   if (!this.dialog) {
68    this.create();
69   }
70
71   this.callback = cb;
72   this.data = data;
73   this.dialog.show(this.data._el);
74   if (this.form) {
75    this.form.reset();
76    this.form.setValues(data);
77    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
78   }
79
80  },
81
82  create : function()
83  {
84    var _this = this;
85    this.dialog = Roo.factory({
86     xtype : 'LayoutDialog',
87     autoCreate : true,
88     closable : false,
89     collapsible : false,
90     draggable : false,
91     height : 400,
92     modal : true,
93     shadow : true,
94     title : _this._strings['72b9d3d2e231f1de7a2bd70737f644aa'] /* Add / Edit Organization */,
95     width : 750,
96     xns : Roo,
97     '|xns' : 'Roo',
98     center : {
99      xtype : 'LayoutRegion',
100      alwaysShowTabs : false,
101      autoScroll : false,
102      closeOnTab : true,
103      hideTabs : true,
104      titlebar : false,
105      xns : Roo,
106      '|xns' : 'Roo'
107     },
108     buttons : [
109      {
110       xtype : 'Button',
111       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
112       listeners : {
113        click : function (_self, e)
114         {
115             _this.dialog.hide();
116         }
117       },
118       xns : Roo,
119       '|xns' : 'Roo'
120      },
121      {
122       xtype : 'Button',
123       text : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
124       listeners : {
125        click : function (_self, e)
126         {
127             if(!_this.form.isValid()){
128                 Roo.MessageBox.alert('Error', 'Please Correct all the errors in red');
129                 return;
130             }
131             
132             new Pman.Request({
133                 url : baseURL + '/Roo/Core_company.php',
134                 method : 'POST',
135                 params : {
136                   id : _this.form.findField('id').getValue() * 1,
137                   name : _this.form.findField('name').getValue(),
138                   _check_name : 1
139                 }, 
140                 success : function(res) {
141                     _this.dialog.el.mask("Saving");
142                     _this.form.doAction("submit");
143                 },
144                 failure : function(res) {
145                     Roo.MessageBox.confirm(
146                         "Confirm", 
147                         "The company name has been used. Save it anyway?", 
148                         function(res) {
149                             if(res != 'yes') {
150                                 return;
151                             }
152                             
153                             _this.dialog.el.mask("Saving");
154                             _this.form.doAction("submit");
155                         }
156                     );
157                 }
158             });
159             
160             return;
161             
162         }
163       },
164       xns : Roo,
165       '|xns' : 'Roo'
166      }
167     ],
168     items  : [
169      {
170       xtype : 'ContentPanel',
171       autoCreate : true,
172       fitToFrame : true,
173       region : 'center',
174       xns : Roo,
175       '|xns' : 'Roo',
176       items  : [
177        {
178         xtype : 'Form',
179         fileUpload : true,
180         labelWidth : 160,
181         url : baseURL + '/Roo/core_company.php',
182         listeners : {
183          actioncomplete : function(f, act) {
184               _this.dialog.el.unmask();
185               //console.log('load completed'); 
186               // error messages?????
187               if(act.type == 'setdata'){
188                   this.load({ method: 'GET', params: { '_id' : _this.data.id }});
189                   return;
190               }
191              
192               if (act.type == 'load') {
193                   _this.data = act.result.data;
194                   var meth = _this.data.comptype == 'OWNER' ? 'disable' : 'enable';
195                
196                       
197                   if (_this.form.findField('comptype')) {
198                       _this.form.findField('comptype')[meth]();
199                   }
200                    
201                  // _this.loaded();
202                   return;
203               }
204               
205               
206               if (act.type == 'submit') { // only submitted here if we are 
207                   _this.dialog.hide();
208                  
209                   if (_this.callback) {
210                       _this.callback.call(this, act.result.data);
211                   }
212                   return; 
213               }
214               // unmask?? 
215           },
216          actionfailed : function(f, act) {
217               _this.dialog.el.unmask();
218               // error msg???
219               Pman.standardActionFailed(f,act);
220                         
221           },
222          rendered : function (form)
223           {
224               _this.form = form;
225           }
226         },
227         xns : Roo.form,
228         '|xns' : 'Roo.form',
229         items  : [
230          {
231           xtype : 'Column',
232           width : 500,
233           xns : Roo.form,
234           '|xns' : 'Roo.form',
235           items  : [
236            {
237             xtype : 'TextField',
238             allowBlank : true,
239             fieldLabel : _this._strings['b33457e7e1cd5dbf1db34a0c60fcb75f'] /* Company ID (for filing Ref.) */,
240             name : 'code',
241             qtip : _this._strings['733640ec0c9367df1b4d85eb286ed9ae'] /* Enter code */,
242             width : 100,
243             xns : Roo.form,
244             '|xns' : 'Roo.form'
245            },
246            {
247             xtype : 'ComboBox',
248             allowBlank : false,
249             alwaysQuery : true,
250             displayField : 'display_name',
251             emptyText : _this._strings['023a5dfa857c4aa0156e6685231a1dbd'] /* Select Type */,
252             fieldLabel : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
253             forceSelection : true,
254             hiddenName : 'comptype_id',
255             listWidth : 250,
256             loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
257             minChars : 2,
258             name : 'comptype_id_display_name',
259             pageSize : 20,
260             qtip : _this._strings['8535bcc0f05358a583bb432bbadf7e0d'] /* Select type */,
261             queryParam : 'query[name]',
262             selectOnFocus : true,
263             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> : {display_name}</div>',
264             triggerAction : 'all',
265             typeAhead : false,
266             valueField : 'id',
267             width : 200,
268             listeners : {
269              render : function (_self)
270               {
271                   _this.etypeCombo = _self;
272               }
273             },
274             xns : Roo.form,
275             '|xns' : 'Roo.form',
276             store : {
277              xtype : 'Store',
278              remoteSort : true,
279              sortInfo : { direction : 'ASC', field: 'id' },
280              listeners : {
281               beforeload : function (_self, o){
282                    o.params = o.params || {};
283                    // set more here
284                    //o.params['query[empty_etype]'] = 1;
285                    o.params.etype = 'COMPTYPE';
286                }
287              },
288              xns : Roo.data,
289              '|xns' : 'Roo.data',
290              proxy : {
291               xtype : 'HttpProxy',
292               method : 'GET',
293               url : baseURL + '/Roo/core_enum.php',
294               xns : Roo.data,
295               '|xns' : 'Roo.data'
296              },
297              reader : {
298               xtype : 'JsonReader',
299               fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
300               id : 'id',
301               root : 'data',
302               totalProperty : 'total',
303               xns : Roo.data,
304               '|xns' : 'Roo.data'
305              }
306             }
307            },
308            {
309             xtype : 'TextField',
310             allowBlank : false,
311             fieldLabel : _this._strings['e7b47c58815acf1d3afa59a84b5db7fb'] /* Company Name */,
312             name : 'name',
313             qtip : _this._strings['4ef6052d74436756f08e95fd63949653'] /* Enter Company Name */,
314             width : 300,
315             xns : Roo.form,
316             '|xns' : 'Roo.form'
317            },
318            {
319             xtype : 'TextField',
320             allowBlank : true,
321             fieldLabel : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
322             name : 'tel',
323             qtip : _this._strings['bc3a4c40d007b8d610a16312970e5cb3'] /* Enter Phone Number */,
324             width : 300,
325             xns : Roo.form,
326             '|xns' : 'Roo.form'
327            },
328            {
329             xtype : 'TextField',
330             allowBlank : true,
331             fieldLabel : _this._strings['9810aa2b9f44401be4bf73188ef2b67d'] /* Fax */,
332             name : 'fax',
333             qtip : _this._strings['cf3a5d25d39613ad5bbc2f5eb0f9b675'] /* Enter Fax Number */,
334             width : 300,
335             xns : Roo.form,
336             '|xns' : 'Roo.form'
337            },
338            {
339             xtype : 'TextField',
340             allowBlank : true,
341             fieldLabel : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
342             name : 'email',
343             qtip : _this._strings['9f86c00615b1a210935ac28ff8ebbb22'] /* Enter Email Address */,
344             width : 300,
345             xns : Roo.form,
346             '|xns' : 'Roo.form'
347            },
348            {
349             xtype : 'TextField',
350             allowBlank : true,
351             fieldLabel : _this._strings['02a3a357710cc2a5dfdfb74ed012fb59'] /* Url */,
352             name : 'url',
353             qtip : _this._strings['8c04eb09879a05470fae436ba76e3bb9'] /* Enter Url */,
354             width : 300,
355             xns : Roo.form,
356             '|xns' : 'Roo.form'
357            },
358            {
359             xtype : 'TextField',
360             allowBlank : true,
361             fieldLabel : _this._strings['dd7bf230fde8d4836917806aff6a6b27'] /* Address */,
362             name : 'address',
363             qtip : _this._strings['32c4e9483403d60115b21519178e5384'] /* Enter Address */,
364             width : 300,
365             xns : Roo.form,
366             '|xns' : 'Roo.form'
367            },
368            {
369             xtype : 'TextArea',
370             allowBlank : true,
371             fieldLabel : _this._strings['231bc72756b5e6de492aaaa1577f61b1'] /* Remarks */,
372             height : 120,
373             name : 'remarks',
374             qtip : _this._strings['c54b90756cfbeff9217293b567cb2eb0'] /* Enter remarks */,
375             width : 300,
376             xns : Roo.form,
377             '|xns' : 'Roo.form'
378            }
379           ]
380          },
381          {
382           xtype : 'Column',
383           labelAlign : 'top',
384           width : 200,
385           xns : Roo.form,
386           '|xns' : 'Roo.form',
387           items  : [
388            {
389             xtype : 'ColorField',
390             fieldLabel : _this._strings['35cb9e66ff801a819684ee0fbeabaeeb'] /* Background Colour */,
391             name : 'background_color',
392             xns : Roo.form,
393             '|xns' : 'Roo.form'
394            },
395            {
396             xtype : 'DisplayField',
397             fieldLabel : _this._strings['bc87ef2144ae15ef4f78211e73948051'] /* Logo Image */,
398             height : 170,
399             icon : 'rootURL + \'images/default/dd/drop-add.gif\'',
400             name : 'logo_id',
401             style : 'border: 1px solid #ccc;',
402             valueRenderer : function(v) {
403                 //var vp = v ? v : 'Companies:' + _this.data.id + ':-LOGO';
404                 if (!v) {
405                     return "No Image Available" + '<BR/>';
406                 }
407                 return String.format('<a target="_new" href="{1}"><img src="{0}" width="150"></a>', 
408                         baseURL + '/Images/Thumb/150x150/' + v + '/logo.jpg',
409                         baseURL + '/Images/'+v+'/logo.jpg'           // fixme - put escaped company name..
410                 );
411             },
412             width : 170,
413             xns : Roo.form,
414             '|xns' : 'Roo.form'
415            },
416            {
417             xtype : 'Button',
418             text : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
419             listeners : {
420              click : function (_self, e)
421               {
422                   var _t = _this.form.findField('logo_id');
423                                        
424                   Pman.Dialog.Image.show({
425                       onid :_this.data.id,
426                       ontable : 'core_company',
427                       imgtype : 'LOGO'
428                   }, function(data) {
429                       if  (data) {
430                           _t.setValue(data.id);
431                       }
432                       
433                   });
434               }
435             },
436             xns : Roo,
437             '|xns' : 'Roo'
438            }
439           ]
440          },
441          {
442           xtype : 'Hidden',
443           name : 'id',
444           xns : Roo.form,
445           '|xns' : 'Roo.form'
446          }
447         ]
448        }
449       ]
450      }
451     ]
452    });
453  }
454 };