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