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                                             hideLabels : true,
172                                             items : [
173                                                 {
174                                                     '|xns' : 'Roo.form',
175                                                     fieldLabel : 'Phone (Alt)',
176                                                     xtype : 'TextField',
177                                                     regex : /^[0-9 +-]+$/,
178                                                     width : 150,
179                                                     xns : Roo.form,
180                                                     name : 'cntct_phone1'
181                                                 }
182                                             ]
183
184                                         }
185                                     ]
186
187                                 },
188                                 {
189                                     '|xns' : 'Roo.form',
190                                     fieldLabel : 'Email',
191                                     vtype : 'email',
192                                     xtype : 'TextField',
193                                     width : 200,
194                                     xns : Roo.form,
195                                     name : 'cntct_email'
196                                 },
197                                 {
198                                     '|xns' : 'Roo.form',
199                                     xtype : 'FieldSet',
200                                     legend : "Address",
201                                     style : 'width:420px',
202                                     xns : Roo.form,
203                                     items : [
204                                         {
205                                             '|xns' : 'Roo.form',
206                                             fieldLabel : 'Line 1',
207                                             xtype : 'TextField',
208                                             allowBlank : false,
209                                             width : 300,
210                                             xns : Roo.form,
211                                             name : 'cntct_addr_id_addr_line1',
212                                             listeners : {
213                                                 keyup : function (_self, e)
214                                                    {
215                                                        _this.form.findField('addr_number').sync();
216                                                    }
217                                             }
218                                         },
219                                         {
220                                             '|xns' : 'Roo.form',
221                                             fieldLabel : 'Line 2',
222                                             xtype : 'TextField',
223                                             width : 300,
224                                             xns : Roo.form,
225                                             name : 'cntct_addr_id_addr_line2'
226                                         },
227                                         {
228                                             '|xns' : 'Roo.form',
229                                             fieldLabel : 'Line 3',
230                                             xtype : 'TextField',
231                                             width : 300,
232                                             xns : Roo.form,
233                                             name : 'cntct_addr_id_addr_line3'
234                                         },
235                                         {
236                                             store : {
237                                                 proxy : {
238                                                     '|xns' : 'Roo.data',
239                                                     url : baseURL + '/Roo/addr.php',
240                                                     xtype : 'HttpProxy',
241                                                     method : 'GET',
242                                                     xns : Roo.data
243                                                 },
244                                                 reader : {
245                                                     '|xns' : 'Roo.data',
246                                                     id : 'addr_state',
247                                                     root : 'data',
248                                                     xtype : 'JsonReader',
249                                                     fields : [ "addr_state"],
250                                                     xns : Roo.data,
251                                                     totalProperty : 'total'
252                                                 },
253                                                 '|xns' : 'Roo.data',
254                                                 xtype : 'Store',
255                                                 remoteSort : true,
256                                                 sortInfo : { direction : 'ASC', field: 'addr_state' },
257                                                 xns : Roo.data,
258                                                 listeners : {
259                                                         beforeload : function (_self, o){
260                                                                o.params = o.params || {};
261                                                                
262                                                               // o.params.state_country_id_country_name = _this.form.findField('addr_country').getValue();
263                                                                //if (!o.params.state_country_id_country_name.length) {
264                                                                //    Roo.MessageBox.alert("Select Country First");
265                                                            //        return false;
266                                                              //  }
267                                                              
268                                                               o.params._distinct = 'addr_state';
269                                                               o.params._columns = 'addr_state';
270                                                               o.params.limit = 999;
271                                                                // set more here
272                                                            }
273                                                 },
274                                                 items : [
275
276                                                 ]
277
278                                             },
279                                             '|xns' : 'Roo.form',
280                                             listWidth : 400,
281                                             triggerAction : 'all',
282                                             fieldLabel : 'State',
283                                             selectOnFocus : true,
284                                             displayField : 'addr_state',
285                                             emptyText : "State",
286                                             hiddenName : 'cntct_addr_id_addr_state',
287                                             minChars : 2,
288                                             valueField : 'addr_state',
289                                             xtype : 'ComboBox',
290                                             allowBlank : true,
291                                             typeAhead : true,
292                                             editable : true,
293                                             width : 200,
294                                             xns : Roo.form,
295                                             name : 'cntct_addr_id_addr_state',
296                                             qtip : "Select State",
297                                             queryParam : 'query[addr_state]',
298                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{addr_state}</b> </div>',
299                                             loadingText : "Searching...",
300                                             items : [
301
302                                             ]
303
304                                         },
305                                         {
306                                             '|xns' : 'Roo.form',
307                                             fieldLabel : 'City',
308                                             xtype : 'TextField',
309                                             width : 300,
310                                             xns : Roo.form,
311                                             name : 'cntct_addr_id_addr_city'
312                                         },
313                                         {
314                                             '|xns' : 'Roo.form',
315                                             fieldLabel : 'Zip code',
316                                             xtype : 'TextField',
317                                             width : 300,
318                                             xns : Roo.form,
319                                             name : 'cntct_addr_id_addr_postalcode'
320                                         },
321                                         {
322                                             store : {
323                                                 proxy : {
324                                                     '|xns' : 'Roo.data',
325                                                     url : baseURL + '/Roo/country.php',
326                                                     xtype : 'HttpProxy',
327                                                     method : 'GET',
328                                                     xns : Roo.data
329                                                 },
330                                                 reader : {
331                                                     '|xns' : 'Roo.data',
332                                                     id : 'country_id',
333                                                     root : 'data',
334                                                     xtype : 'JsonReader',
335                                                     fields : [{"name":"country_id","type":"int"},"county_name"],
336                                                     xns : Roo.data,
337                                                     totalProperty : 'total'
338                                                 },
339                                                 '|xns' : 'Roo.data',
340                                                 xtype : 'Store',
341                                                 remoteSort : true,
342                                                 sortInfo : { direction : 'ASC', field: 'country_name' },
343                                                 xns : Roo.data,
344                                                 listeners : {
345                                                         beforeload : function (_self, o){
346                                                                o.params = o.params || {};
347                                                                // set more here
348                                                                o.params.limit = 999;
349                                                            }
350                                                 },
351                                                 items : [
352
353                                                 ]
354
355                                             },
356                                             '|xns' : 'Roo.form',
357                                             listWidth : 400,
358                                             triggerAction : 'all',
359                                             fieldLabel : 'Country',
360                                             selectOnFocus : true,
361                                             displayField : 'country_name',
362                                             emptyText : "Country",
363                                             hiddenName : 'cntct_addr_id_addr_country',
364                                             minChars : 2,
365                                             valueField : 'country_name',
366                                             xtype : 'ComboBox',
367                                             allowBlank : true,
368                                             typeAhead : true,
369                                             editable : true,
370                                             width : 200,
371                                             xns : Roo.form,
372                                             name : 'cntct_addr_id_addr_country',
373                                             qtip : "Select Country",
374                                             queryParam : 'query[country_name]',
375                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{country_name}</b> </div>',
376                                             loadingText : "Searching...",
377                                             items : [
378
379                                             ]
380
381                                         }
382                                     ]
383
384                                 },
385                                 {
386                                     '|xns' : 'Roo.form',
387                                     legend : "Store Details (Delivery only)",
388                                     xtype : 'FieldSet',
389                                     xns : Roo.form,
390                                     items : [
391                                         {
392                                             '|xns' : 'Roo.form',
393                                             fieldLabel : 'Name',
394                                             xtype : 'TextField',
395                                             allowBlank : true,
396                                             readOnly : true,
397                                             width : 300,
398                                             xns : Roo.form,
399                                             name : 'vend_name'
400                                         },
401                                         {
402                                             '|xns' : 'Roo.form',
403                                             fieldLabel : 'Code',
404                                             xtype : 'TextField',
405                                             allowBlank : true,
406                                             readOnly : true,
407                                             width : 300,
408                                             xns : Roo.form,
409                                             name : 'vendaddr_code'
410                                         }
411                                     ]
412
413                                 },
414                                 {
415                                     '|xns' : 'Roo.form',
416                                     xtype : 'Hidden',
417                                     width : 100,
418                                     xns : Roo.form,
419                                     name : 'customer_id'
420                                 },
421                                 {
422                                     '|xns' : 'Roo.form',
423                                     xtype : 'Hidden',
424                                     width : 100,
425                                     xns : Roo.form,
426                                     name : 'cntct_addr_id'
427                                 },
428                                 {
429                                     '|xns' : 'Roo.form',
430                                     xtype : 'Hidden',
431                                     xns : Roo.form,
432                                     name : 'cntct_id'
433                                 }
434                             ]
435
436                         }
437                     ]
438
439                 }
440             ]
441
442         });
443     }
444 };