Pman.Dialog.XtupleTerms.bjs
[Pman.Xtuple] / Pman.Dialog.XtupleTerms.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.XtupleTerms = {
8
9     dialog : false,
10     callback:  false,
11
12     show : function(data, cb)
13     {
14         if (!this.dialog) {
15             this.create();
16         }
17
18         this.callback = cb;
19         this.data = data;
20         this.dialog.show(this.data._el);
21         if (this.form) {
22            this.form.reset();
23            this.form.setValues(data);
24            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
25         }
26
27     },
28
29     create : function()
30     {
31         var _this = this;
32         this.dialog = Roo.factory({
33             center : {
34                 '|xns' : 'Roo',
35                 xtype : 'LayoutRegion',
36                 xns : Roo
37             },
38             '|xns' : 'Roo',
39             modal : true,
40             collapsible : false,
41             title : "Create / Edit Terms",
42             xtype : 'LayoutDialog',
43             width : 500,
44             xns : Roo,
45             closable : false,
46             resizable : false,
47             height : 550,
48             buttons : [
49                  {
50                         '|xns' : 'Roo',
51                         text : "Cancel",
52                         xtype : 'Button',
53                         xns : Roo,
54                         listeners : {
55                                 click : function (_self, e)
56                                    {
57                                        _this.dialog.hide();
58                                    }
59                         }
60                     },
61 {
62                         '|xns' : 'Roo',
63                         text : "Save",
64                         xtype : 'Button',
65                         xns : Roo,
66                         listeners : {
67                                 click : function (_self, e)
68                                    {
69                                        // do some checks?
70                                         
71                                        
72                                     
73                                        _this.form.doAction("submit");
74                                    
75                                    }
76                         }
77                     }
78             ],
79             items : [
80                 {
81                     '|xns' : 'Roo',
82                     region : 'center',
83                     xtype : 'ContentPanel',
84                     xns : Roo,
85                     items : [
86                         {
87                             '|xns' : 'Roo.form',
88                             url : baseURL + '/Roo/cntct.php',
89                             method : 'POST',
90                             xtype : 'Form',
91                             style : 'margin:10px;',
92                             xns : Roo.form,
93                             listeners : {
94                                 actioncomplete : function(_self,action)
95                                    {
96                                        if (action.type == 'setdata') {
97                                            if (_this.data.id) { 
98                                                this.load({ method: 'GET', params: { _id : _this.data.id}});
99                                                return;
100                                            }
101                                            
102                                            return;
103                                        }
104                                        if (action.type == 'load') {
105                                            return;
106                                        }
107                                        if (action.type =='submit') {
108                                        
109                                            _this.dialog.hide();
110                                        
111                                             if (_this.callback) {
112                                                 _this.form.setValues(action.result.data);
113                                                _this.callback.call(_this, _this.form.getValues());
114                                             }
115                                             _this.form.reset();
116                                             return;
117                                        }
118                                    },
119                                 rendered : function (form)
120                                    {
121                                        _this.form= form;
122                                    }
123                             },
124                             items : [
125                                 {
126                                     '|xns' : 'Roo.form',
127                                     xtype : 'FieldSet',
128                                     legend : "Details",
129                                     style : 'width:420px',
130                                     xns : Roo.form,
131                                     items : [
132                                         {
133                                             '|xns' : 'Roo.form',
134                                             fieldLabel : 'First Name',
135                                             xtype : 'TextField',
136                                             allowBlank : false,
137                                             width : 300,
138                                             xns : Roo.form,
139                                             name : 'cntct_first_name'
140                                         },
141                                         {
142                                             '|xns' : 'Roo.form',
143                                             fieldLabel : 'Last Name',
144                                             xtype : 'TextField',
145                                             width : 300,
146                                             xns : Roo.form,
147                                             name : 'cntct_last_name'
148                                         },
149                                         {
150                                             '|xns' : 'Roo.form',
151                                             fieldLabel : 'Phone',
152                                             xtype : 'TextField',
153                                             regex : /^[0-9 +-]+$/,
154                                             width : 300,
155                                             xns : Roo.form,
156                                             name : 'cntct_phone'
157                                         },
158                                         {
159                                             '|xns' : 'Roo.form',
160                                             fieldLabel : 'Alt',
161                                             xtype : 'TextField',
162                                             regex : /^[0-9 +-]+$/,
163                                             width : 300,
164                                             xns : Roo.form,
165                                             name : 'cntct_phone2'
166                                         },
167                                         {
168                                             '|xns' : 'Roo.form',
169                                             allowBlank : false,
170                                             fieldLabel : 'Email',
171                                             vtype : 'email',
172                                             xtype : 'TextField',
173                                             width : 300,
174                                             xns : Roo.form,
175                                             name : 'cntct_email'
176                                         },
177                                         {
178                                             '|xns' : 'Roo.form',
179                                             fieldLabel : 'Password',
180                                             xtype : 'TextField',
181                                             inputType : 'password',
182                                             width : 300,
183                                             xns : Roo.form,
184                                             name : 'password'
185                                         },
186                                         {
187                                             '|xns' : 'Roo.form',
188                                             fieldLabel : 'Confirm PW',
189                                             xtype : 'TextField',
190                                             inputType : 'password',
191                                             width : 300,
192                                             xns : Roo.form,
193                                             name : 'password2'
194                                         },
195                                         {
196                                             '|xns' : 'Roo.form',
197                                             checked : true,
198                                             fieldLabel : 'Active',
199                                             xtype : 'Checkbox',
200                                             valueOff : 0,
201                                             xns : Roo.form,
202                                             inputValue : true,
203                                             name : 'cntct_active'
204                                         }
205                                     ]
206
207                                 },
208                                 {
209                                     '|xns' : 'Roo.form',
210                                     legend : "Address",
211                                     style : 'width:420px',
212                                     xtype : 'FieldSet',
213                                     xns : Roo.form,
214                                     items : [
215                                         {
216                                             '|xns' : 'Roo.form',
217                                             fieldLabel : 'Line 1',
218                                             xtype : 'TextField',
219                                             allowBlank : false,
220                                             width : 300,
221                                             xns : Roo.form,
222                                             name : 'cntct_addr_id_addr_line1'
223                                         },
224                                         {
225                                             '|xns' : 'Roo.form',
226                                             fieldLabel : 'Line 2',
227                                             xtype : 'TextField',
228                                             width : 300,
229                                             xns : Roo.form,
230                                             name : 'cntct_addr_id_addr_line2'
231                                         },
232                                         {
233                                             '|xns' : 'Roo.form',
234                                             fieldLabel : 'Line 3',
235                                             xtype : 'TextField',
236                                             width : 300,
237                                             xns : Roo.form,
238                                             name : 'cntct_addr_id_addr_line3'
239                                         },
240                                         {
241                                             store : {
242                                                 proxy : {
243                                                     '|xns' : 'Roo.data',
244                                                     url : baseURL + '/Roo/addr.php',
245                                                     method : 'GET',
246                                                     xtype : 'HttpProxy',
247                                                     xns : Roo.data
248                                                 },
249                                                 reader : {
250                                                     '|xns' : 'Roo.data',
251                                                     id : 'addr_state',
252                                                     root : 'data',
253                                                     xtype : 'JsonReader',
254                                                     fields : [ "addr_state"],
255                                                     xns : Roo.data,
256                                                     totalProperty : 'total'
257                                                 },
258                                                 '|xns' : 'Roo.data',
259                                                 xtype : 'Store',
260                                                 remoteSort : true,
261                                                 sortInfo : { direction : 'ASC', field: 'addr_state' },
262                                                 xns : Roo.data,
263                                                 listeners : {
264                                                         beforeload : function (_self, o){
265                                                                o.params = o.params || {};
266                                                                
267                                                               // o.params.state_country_id_country_name = _this.form.findField('addr_country').getValue();
268                                                                //if (!o.params.state_country_id_country_name.length) {
269                                                                //    Roo.MessageBox.alert("Select Country First");
270                                                            //        return false;
271                                                              //  }
272                                                              
273                                                               o.params._distinct = 'addr_state';
274                                                               o.params._columns = 'addr_state';
275                                                               o.params.limit = 999;
276                                                                // set more here
277                                                            }
278                                                 },
279                                                 items : [
280
281                                                 ]
282
283                                             },
284                                             '|xns' : 'Roo.form',
285                                             listWidth : 400,
286                                             triggerAction : 'all',
287                                             fieldLabel : 'State',
288                                             selectOnFocus : true,
289                                             displayField : 'addr_state',
290                                             emptyText : "State",
291                                             hiddenName : 'cntct_addr_id_addr_state',
292                                             minChars : 2,
293                                             valueField : 'addr_state',
294                                             xtype : 'ComboBox',
295                                             allowBlank : true,
296                                             typeAhead : true,
297                                             editable : true,
298                                             width : 300,
299                                             xns : Roo.form,
300                                             name : 'cntct_addr_id_addr_state',
301                                             qtip : "Select State",
302                                             queryParam : 'query[addr_state]',
303                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{addr_state}</b> </div>',
304                                             loadingText : "Searching...",
305                                             items : [
306
307                                             ]
308
309                                         },
310                                         {
311                                             '|xns' : 'Roo.form',
312                                             fieldLabel : 'City',
313                                             xtype : 'TextField',
314                                             width : 300,
315                                             xns : Roo.form,
316                                             name : 'cntct_addr_id_addr_city'
317                                         },
318                                         {
319                                             '|xns' : 'Roo.form',
320                                             fieldLabel : 'Zip code',
321                                             xtype : 'TextField',
322                                             width : 300,
323                                             xns : Roo.form,
324                                             name : 'cntct_addr_id_addr_postalcode'
325                                         },
326                                         {
327                                             store : {
328                                                 proxy : {
329                                                     '|xns' : 'Roo.data',
330                                                     url : baseURL + '/Roo/country.php',
331                                                     method : 'GET',
332                                                     xtype : 'HttpProxy',
333                                                     xns : Roo.data
334                                                 },
335                                                 reader : {
336                                                     '|xns' : 'Roo.data',
337                                                     id : 'country_id',
338                                                     root : 'data',
339                                                     xtype : 'JsonReader',
340                                                     fields : [{"name":"country_id","type":"int"},"county_name"],
341                                                     xns : Roo.data,
342                                                     totalProperty : 'total'
343                                                 },
344                                                 '|xns' : 'Roo.data',
345                                                 xtype : 'Store',
346                                                 remoteSort : true,
347                                                 sortInfo : { direction : 'ASC', field: 'country_name' },
348                                                 xns : Roo.data,
349                                                 listeners : {
350                                                         beforeload : function (_self, o){
351                                                                o.params = o.params || {};
352                                                                // set more here
353                                                                o.params.limit = 999;
354                                                            }
355                                                 },
356                                                 items : [
357
358                                                 ]
359
360                                             },
361                                             '|xns' : 'Roo.form',
362                                             listWidth : 400,
363                                             triggerAction : 'all',
364                                             fieldLabel : 'Country',
365                                             selectOnFocus : true,
366                                             displayField : 'country_name',
367                                             emptyText : "Country",
368                                             hiddenName : 'cntct_addr_id_addr_country',
369                                             minChars : 2,
370                                             valueField : 'country_name',
371                                             xtype : 'ComboBox',
372                                             allowBlank : true,
373                                             typeAhead : true,
374                                             editable : true,
375                                             width : 300,
376                                             xns : Roo.form,
377                                             name : 'cntct_addr_id_addr_country',
378                                             qtip : "Select Country",
379                                             queryParam : 'query[country_name]',
380                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{country_name}</b> </div>',
381                                             loadingText : "Searching...",
382                                             items : [
383
384                                             ]
385
386                                         }
387                                     ]
388
389                                 },
390                                 {
391                                     '|xns' : 'Roo.form',
392                                     xtype : 'Hidden',
393                                     value : "AGENT",
394                                     xns : Roo.form,
395                                     name : 'cntct_registrar_type'
396                                 },
397                                 {
398                                     '|xns' : 'Roo.form',
399                                     xtype : 'Hidden',
400                                     xns : Roo.form,
401                                     name : 'customer_id'
402                                 },
403                                 {
404                                     '|xns' : 'Roo.form',
405                                     xtype : 'Hidden',
406                                     xns : Roo.form,
407                                     name : 'cntct_addr_id'
408                                 },
409                                 {
410                                     '|xns' : 'Roo.form',
411                                     xtype : 'Hidden',
412                                     xns : Roo.form,
413                                     name : 'cntct_id'
414                                 }
415                             ]
416
417                         }
418                     ]
419
420                 }
421             ]
422
423         });
424     }
425 };