Pman.js
[Pman.Core] / Pman.Dialog.CorePersonContact.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.CorePersonContact = {
8
9  _strings : {
10   '1c76cbfe21c6f44c1d1e59d54f3e4420' :"Company",
11   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
12   'c8972faa3b9e1c7250db23c57c85aa23' :"Edit / Create Contact Details",
13   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
14   'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
15   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
16   '9675747b5ab12d05f18518761e68a533' :"Select Companies",
17   'df814135652a5a308fea15bff37ea284' :"Office",
18   'c373dd4bd4ba0b5d3e0c7522c5629880' :"Select Office",
19   '49ee3087348e8d44e1feda1917443987' :"Name",
20   'bbbabdbe1b262f75d99d62880b953be1' :"Role",
21   'c9cc8cce247e49bae79f15173ce97354' :"Save",
22   '9810aa2b9f44401be4bf73188ef2b67d' :"Fax"
23  },
24
25  dialog : false,
26  callback:  false,
27
28  show : function(data, cb)
29  {
30   if (!this.dialog) {
31    this.create();
32   }
33
34   this.callback = cb;
35   this.data = data;
36   this.dialog.show(this.data._el);
37   if (this.form) {
38    this.form.reset();
39    this.form.setValues(data);
40    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
41   }
42
43  },
44
45  create : function()
46  {
47    var _this = this;
48    this.dialog = Roo.factory({
49     xtype : 'LayoutDialog',
50     closable : false,
51     collapsible : false,
52     height : 290,
53     resizable : false,
54     title : _this._strings['c8972faa3b9e1c7250db23c57c85aa23'] /* Edit / Create Contact Details */,
55     width : 450,
56     xns : Roo,
57     '|xns' : 'Roo',
58     center : {
59      xtype : 'LayoutRegion',
60      xns : Roo,
61      '|xns' : 'Roo'
62     },
63     buttons : [
64      {
65       xtype : 'Button',
66       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
67       listeners : {
68        click : function (_self, e)
69         {
70             _this.dialog.hide();
71         }
72       },
73       xns : Roo,
74       '|xns' : 'Roo'
75      },
76      {
77       xtype : 'Button',
78       text : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
79       listeners : {
80        click : function (_self, e)
81         {
82             // do some checks?
83              
84             
85             _this.dialog.el.mask("Saving");
86             _this.form.doAction("submit");
87         
88         }
89       },
90       xns : Roo,
91       '|xns' : 'Roo'
92      }
93     ],
94     items  : [
95      {
96       xtype : 'ContentPanel',
97       region : 'center',
98       xns : Roo,
99       '|xns' : 'Roo',
100       items  : [
101        {
102         xtype : 'Form',
103         method : 'POST',
104         style : 'margin:10px;',
105         url : baseURL + '/Roo/core_person',
106         listeners : {
107          actioncomplete : function(_self,action)
108           {
109               if (action.type == 'setdata') {
110                  //_this.dialog.el.mask("Loading");
111                  //this.load({ method: 'GET', params: { '_id' : _this.data.id }});
112                  return;
113               }
114               if (action.type == 'load') {
115                   _this.dialog.el.unmask();
116                   return;
117               }
118               if (action.type =='submit') {
119               
120                   _this.dialog.el.unmask();
121                   _this.dialog.hide();
122               
123                    if (_this.callback) {
124                       _this.callback.call(_this, _this.form.getValues());
125                    }
126                    _this.form.reset();
127                    return;
128               }
129           },
130          rendered : function (form)
131           {
132               _this.form= form;
133           }
134         },
135         xns : Roo.form,
136         '|xns' : 'Roo.form',
137         items  : [
138          {
139           xtype : 'ComboBox',
140           allowBlank : false,
141           displayField : 'code',
142           editable : false,
143           emptyText : _this._strings['9675747b5ab12d05f18518761e68a533'] /* Select Companies */,
144           fieldLabel : _this._strings['1c76cbfe21c6f44c1d1e59d54f3e4420'] /* Company */,
145           forceSelection : true,
146           hiddenName : 'company_id',
147           listWidth : 400,
148           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
149           minChars : 2,
150           name : 'company_id_code',
151           pageSize : 20,
152           qtip : _this._strings['9675747b5ab12d05f18518761e68a533'] /* Select Companies */,
153           queryParam : 'query[code]',
154           selectOnFocus : true,
155           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{code}</b> </div>',
156           triggerAction : 'all',
157           typeAhead : true,
158           valueField : 'id',
159           width : 300,
160           listeners : {
161            add : function (combo)
162             {
163             
164                 Pman.Dialog.Companies.show( {  id: 0 },  function(data) {
165                         _this.form.setValues({
166                                 company_id_name : data.name,
167                                 company_id : data.id
168                         });
169                 }); 
170             }
171           },
172           xns : Roo.form,
173           '|xns' : 'Roo.form',
174           store : {
175            xtype : 'Store',
176            remoteSort : true,
177            sortInfo : { direction : 'ASC', field: 'id' },
178            listeners : {
179             beforeload : function (_self, o){
180                  o.params = o.params || {};
181                  // set more here
182              }
183            },
184            xns : Roo.data,
185            '|xns' : 'Roo.data',
186            proxy : {
187             xtype : 'HttpProxy',
188             method : 'GET',
189             url : baseURL + '/Roo/core_company.php',
190             xns : Roo.data,
191             '|xns' : 'Roo.data'
192            },
193            reader : {
194             xtype : 'JsonReader',
195             fields : [{"name":"id","type":"int"},{"name":"code","type":"string"}],
196             id : 'id',
197             root : 'data',
198             totalProperty : 'total',
199             xns : Roo.data,
200             '|xns' : 'Roo.data'
201            }
202           }
203          },
204          {
205           xtype : 'ComboBox',
206           allowBlank : false,
207           displayField : 'name',
208           editable : false,
209           emptyText : _this._strings['c373dd4bd4ba0b5d3e0c7522c5629880'] /* Select Office */,
210           fieldLabel : _this._strings['df814135652a5a308fea15bff37ea284'] /* Office */,
211           forceSelection : true,
212           hiddenName : 'office_id',
213           listWidth : 400,
214           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
215           minChars : 2,
216           name : 'office_id_name',
217           pageSize : 20,
218           qtip : _this._strings['c373dd4bd4ba0b5d3e0c7522c5629880'] /* Select Office */,
219           queryParam : 'query[name]',
220           selectOnFocus : true,
221           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>',
222           triggerAction : 'all',
223           typeAhead : true,
224           valueField : 'id',
225           width : 300,
226           listeners : {
227            add : function (combo)
228             {
229                 var coid = _this.form.findField('company_id').getValue();
230                 if (!coid ) {
231                 
232                      Ext.MessageBox.alert("Error", "Select An Company First");
233                     return false;
234             
235                 }
236                 Pman.Dialog.Office.show(cfg, function(data) {
237                             _this.form.setValues({
238                                 office_id_name : data.name,
239                                 office_id : data.id
240                         });
241                     }); 
242                 
243                 
244             },
245            beforequery : function (combo, query, forceAll, cancel, e)
246             {
247                     var coid = _this.form.findField('company_id').getValue();
248                     if (coid < 1 ) {
249                         Ext.MessageBox.alert("Error", "Select An Company First");
250                         return false;
251                     }
252             }
253           },
254           xns : Roo.form,
255           '|xns' : 'Roo.form',
256           store : {
257            xtype : 'Store',
258            remoteSort : true,
259            sortInfo : { direction : 'ASC', field: 'id' },
260            listeners : {
261             beforeload : function (_self, o){
262                  o.params = o.params || {};
263                  var coid = _this.form.findField('company_id').getValue();
264                  o.params.company_id = coid;
265              }
266            },
267            xns : Roo.data,
268            '|xns' : 'Roo.data',
269            proxy : {
270             xtype : 'HttpProxy',
271             method : 'GET',
272             url : baseURL + '/Roo/Office.php',
273             xns : Roo.data,
274             '|xns' : 'Roo.data'
275            },
276            reader : {
277             xtype : 'JsonReader',
278             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
279             id : 'id',
280             root : 'data',
281             totalProperty : 'total',
282             xns : Roo.data,
283             '|xns' : 'Roo.data'
284            }
285           }
286          },
287          {
288           xtype : 'TextField',
289           allowBlank : true,
290           fieldLabel : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
291           name : 'name',
292           width : 300,
293           xns : Roo.form,
294           '|xns' : 'Roo.form'
295          },
296          {
297           xtype : 'TextField',
298           fieldLabel : _this._strings['bbbabdbe1b262f75d99d62880b953be1'] /* Role */,
299           name : 'role',
300           width : 200,
301           xns : Roo.form,
302           '|xns' : 'Roo.form'
303          },
304          {
305           xtype : 'TextField',
306           fieldLabel : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
307           name : 'phone',
308           width : 200,
309           xns : Roo.form,
310           '|xns' : 'Roo.form'
311          },
312          {
313           xtype : 'TextField',
314           fieldLabel : _this._strings['9810aa2b9f44401be4bf73188ef2b67d'] /* Fax */,
315           name : 'fax',
316           width : 200,
317           xns : Roo.form,
318           '|xns' : 'Roo.form'
319          },
320          {
321           xtype : 'TextField',
322           allowBlank : false,
323           fieldLabel : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
324           name : 'email',
325           width : 200,
326           xns : Roo.form,
327           '|xns' : 'Roo.form'
328          },
329          {
330           xtype : 'Hidden',
331           name : 'id',
332           xns : Roo.form,
333           '|xns' : 'Roo.form'
334          }
335         ]
336        }
337       ]
338      }
339     ]
340    });
341  }
342 };