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