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