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