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