Pman.Dialog.XtupleQuickContact.bjs
[Pman.Xtuple] / Pman.Dialog.XtupleQuickContact.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.XtupleQuickContact = {
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 : "Quick enter Contact /  Address",
42             xtype : 'LayoutDialog',
43             width : 500,
44             xns : Roo,
45             closable : false,
46             resizable : false,
47             height : 480,
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                             xtype : 'Form',
90                             method : 'POST',
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: { 
99                                                    _id : _this.data._id , 
100                                                    _with_addr : 1
101                                                }});
102                                            }
103                                           return;
104                                        }
105                                        if (action.type == 'load') {
106                                            return;
107                                        }
108                                        if (action.type =='submit') {
109                                        
110                                            _this.dialog.hide();
111                                        
112                                             if (_this.callback) {
113                                                 _this.form.setValues(action.result.data);
114                                                _this.callback.call(_this, _this.form.getValues());
115                                             }
116                                             _this.form.reset();
117                                             return;
118                                        }
119                                    },
120                                 rendered : function (form)
121                                    {
122                                        _this.form= form;
123                                    }
124                             },
125                             items : [
126                                 {
127                                     '|xns' : 'Roo.form',
128                                     fieldLabel : 'First Name',
129                                     xtype : 'TextField',
130                                     allowBlank : false,
131                                     width : 300,
132                                     xns : Roo.form,
133                                     name : 'cntct_first_name'
134                                 },
135                                 {
136                                     '|xns' : 'Roo.form',
137                                     fieldLabel : 'Last Name',
138                                     xtype : 'TextField',
139                                     width : 300,
140                                     xns : Roo.form,
141                                     name : 'cntct_last_name'
142                                 },
143                                 {
144                                     '|xns' : 'Roo.form',
145                                     xtype : 'Row',
146                                     labelWidth : 120,
147                                     width : 500,
148                                     xns : Roo.form,
149                                     items : [
150                                         {
151                                             '|xns' : 'Roo.form',
152                                             xtype : 'Column',
153                                             xns : Roo.form,
154                                             items : [
155                                                 {
156                                                     '|xns' : 'Roo.form',
157                                                     fieldLabel : 'Phone',
158                                                     xtype : 'TextField',
159                                                     regex : /^[0-9 +-]+$/,
160                                                     width : 150,
161                                                     xns : Roo.form,
162                                                     name : 'cntct_phone'
163                                                 }
164                                             ]
165
166                                         },
167                                         {
168                                             '|xns' : 'Roo.form',
169                                             xtype : 'Column',
170                                             xns : Roo.form,
171                                             items : [
172                                                 {
173                                                     '|xns' : 'Roo.form',
174                                                     fieldLabel : 'Phone (Alt)',
175                                                     xtype : 'TextField',
176                                                     regex : /^[0-9 +-]+$/,
177                                                     width : 150,
178                                                     xns : Roo.form,
179                                                     name : 'cntct_phone1'
180                                                 }
181                                             ]
182
183                                         }
184                                     ]
185
186                                 },
187                                 {
188                                     '|xns' : 'Roo.form',
189                                     fieldLabel : 'Email',
190                                     vtype : 'email',
191                                     xtype : 'TextField',
192                                     width : 200,
193                                     xns : Roo.form,
194                                     name : 'cntct_email'
195                                 },
196                                 {
197                                     '|xns' : 'Roo.form',
198                                     xtype : 'FieldSet',
199                                     legend : "Address",
200                                     style : 'width:420px',
201                                     xns : Roo.form,
202                                     items : [
203                                         {
204                                             '|xns' : 'Roo.form',
205                                             fieldLabel : 'Line 1',
206                                             xtype : 'TextField',
207                                             allowBlank : false,
208                                             width : 300,
209                                             xns : Roo.form,
210                                             name : 'cntct_addr_id_addr_line1',
211                                             listeners : {
212                                                 keyup : function (_self, e)
213                                                    {
214                                                        _this.form.findField('addr_number').sync();
215                                                    }
216                                             }
217                                         },
218                                         {
219                                             '|xns' : 'Roo.form',
220                                             fieldLabel : 'Line 2',
221                                             xtype : 'TextField',
222                                             width : 300,
223                                             xns : Roo.form,
224                                             name : 'cntct_addr_id_addr_line2'
225                                         },
226                                         {
227                                             '|xns' : 'Roo.form',
228                                             fieldLabel : 'Line 3',
229                                             xtype : 'TextField',
230                                             width : 300,
231                                             xns : Roo.form,
232                                             name : 'cntct_addr_id_addr_line3'
233                                         },
234                                         {
235                                             store : {
236                                                 proxy : {
237                                                     '|xns' : 'Roo.data',
238                                                     url : baseURL + '/Roo/addr.php',
239                                                     xtype : 'HttpProxy',
240                                                     method : 'GET',
241                                                     xns : Roo.data
242                                                 },
243                                                 reader : {
244                                                     '|xns' : 'Roo.data',
245                                                     id : 'addr_state',
246                                                     root : 'data',
247                                                     xtype : 'JsonReader',
248                                                     fields : [ "addr_state"],
249                                                     xns : Roo.data,
250                                                     totalProperty : 'total'
251                                                 },
252                                                 '|xns' : 'Roo.data',
253                                                 xtype : 'Store',
254                                                 remoteSort : true,
255                                                 sortInfo : { direction : 'ASC', field: 'addr_state' },
256                                                 xns : Roo.data,
257                                                 listeners : {
258                                                         beforeload : function (_self, o){
259                                                                o.params = o.params || {};
260                                                                
261                                                               // o.params.state_country_id_country_name = _this.form.findField('addr_country').getValue();
262                                                                //if (!o.params.state_country_id_country_name.length) {
263                                                                //    Roo.MessageBox.alert("Select Country First");
264                                                            //        return false;
265                                                              //  }
266                                                              
267                                                               o.params._distinct = 'addr_state';
268                                                               o.params._columns = 'addr_state';
269                                                               o.params.limit = 999;
270                                                                // set more here
271                                                            }
272                                                 },
273                                                 items : [
274
275                                                 ]
276
277                                             },
278                                             '|xns' : 'Roo.form',
279                                             listWidth : 400,
280                                             triggerAction : 'all',
281                                             fieldLabel : 'State',
282                                             selectOnFocus : true,
283                                             displayField : 'addr_state',
284                                             emptyText : "State",
285                                             hiddenName : 'cntct_addr_id_addr_state',
286                                             minChars : 2,
287                                             valueField : 'addr_state',
288                                             xtype : 'ComboBox',
289                                             allowBlank : true,
290                                             typeAhead : true,
291                                             editable : true,
292                                             width : 200,
293                                             xns : Roo.form,
294                                             name : 'cntct_addr_id_addr_state',
295                                             qtip : "Select State",
296                                             queryParam : 'query[addr_state]',
297                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{addr_state}</b> </div>',
298                                             loadingText : "Searching...",
299                                             items : [
300
301                                             ]
302
303                                         },
304                                         {
305                                             '|xns' : 'Roo.form',
306                                             fieldLabel : 'City',
307                                             xtype : 'TextField',
308                                             width : 300,
309                                             xns : Roo.form,
310                                             name : 'cntct_addr_id_addr_city'
311                                         },
312                                         {
313                                             '|xns' : 'Roo.form',
314                                             fieldLabel : 'Zip code',
315                                             xtype : 'TextField',
316                                             width : 300,
317                                             xns : Roo.form,
318                                             name : 'cntct_addr_id_addr_postalcode'
319                                         },
320                                         {
321                                             store : {
322                                                 proxy : {
323                                                     '|xns' : 'Roo.data',
324                                                     url : baseURL + '/Roo/country.php',
325                                                     xtype : 'HttpProxy',
326                                                     method : 'GET',
327                                                     xns : Roo.data
328                                                 },
329                                                 reader : {
330                                                     '|xns' : 'Roo.data',
331                                                     id : 'country_id',
332                                                     root : 'data',
333                                                     xtype : 'JsonReader',
334                                                     fields : [{"name":"country_id","type":"int"},"county_name"],
335                                                     xns : Roo.data,
336                                                     totalProperty : 'total'
337                                                 },
338                                                 '|xns' : 'Roo.data',
339                                                 xtype : 'Store',
340                                                 remoteSort : true,
341                                                 sortInfo : { direction : 'ASC', field: 'country_name' },
342                                                 xns : Roo.data,
343                                                 listeners : {
344                                                         beforeload : function (_self, o){
345                                                                o.params = o.params || {};
346                                                                // set more here
347                                                                o.params.limit = 999;
348                                                            }
349                                                 },
350                                                 items : [
351
352                                                 ]
353
354                                             },
355                                             '|xns' : 'Roo.form',
356                                             listWidth : 400,
357                                             triggerAction : 'all',
358                                             fieldLabel : 'Country',
359                                             selectOnFocus : true,
360                                             displayField : 'country_name',
361                                             emptyText : "Country",
362                                             hiddenName : 'cntct_addr_id_addr_country',
363                                             minChars : 2,
364                                             valueField : 'country_name',
365                                             xtype : 'ComboBox',
366                                             allowBlank : true,
367                                             typeAhead : true,
368                                             editable : true,
369                                             width : 200,
370                                             xns : Roo.form,
371                                             name : 'cntct_addr_id_addr_country',
372                                             qtip : "Select Country",
373                                             queryParam : 'query[country_name]',
374                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{country_name}</b> </div>',
375                                             loadingText : "Searching...",
376                                             items : [
377
378                                             ]
379
380                                         }
381                                     ]
382
383                                 },
384                                 {
385                                     '|xns' : 'Roo.form',
386                                     legend : "Store Details (Delivery only)",
387                                     xtype : 'FieldSet',
388                                     xns : Roo.form,
389                                     items : [
390                                         {
391                                             '|xns' : 'Roo.form',
392                                             fieldLabel : 'Name',
393                                             xtype : 'TextField',
394                                             allowBlank : true,
395                                             readOnly : true,
396                                             width : 300,
397                                             xns : Roo.form,
398                                             name : 'vend_name'
399                                         },
400                                         {
401                                             '|xns' : 'Roo.form',
402                                             fieldLabel : 'Code',
403                                             xtype : 'TextField',
404                                             allowBlank : true,
405                                             readOnly : true,
406                                             width : 300,
407                                             xns : Roo.form,
408                                             name : 'vendaddr_code'
409                                         }
410                                     ]
411
412                                 },
413                                 {
414                                     '|xns' : 'Roo.form',
415                                     xtype : 'Hidden',
416                                     width : 100,
417                                     xns : Roo.form,
418                                     name : 'customer_id'
419                                 },
420                                 {
421                                     '|xns' : 'Roo.form',
422                                     xtype : 'Hidden',
423                                     width : 100,
424                                     xns : Roo.form,
425                                     name : 'cntct_addr_id'
426                                 },
427                                 {
428                                     '|xns' : 'Roo.form',
429                                     xtype : 'Hidden',
430                                     xns : Roo.form,
431                                     name : 'cntct_id'
432                                 }
433                             ]
434
435                         }
436                     ]
437
438                 }
439             ]
440
441         });
442     }
443 };