Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleAddress.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.XtupleAddress = {
8
9  _strings : {
10   '59716c97497eb9694541f7c3d37b1a4d' :"Country",
11   '3c1df4260ce594cb5594696461087f2f' :"Select Country",
12   '0dbd2559b7f2c43a6e5f0a649c4b172a' :"Edit Address",
13   '46a2a41cc6e552044816a2d04634545d' :"State",
14   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
15   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
16   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
17   'c9cc8cce247e49bae79f15173ce97354' :"Save",
18   'be2933038f93e25262400220080c111f' :"Select State"
19  },
20
21  dialog : false,
22  callback:  false,
23
24  show : function(data, cb)
25  {
26   if (!this.dialog) {
27    this.create();
28   }
29
30   this.callback = cb;
31   this.data = data;
32   this.dialog.show(this.data._el);
33   if (this.form) {
34    this.form.reset();
35    this.form.setValues(data);
36    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
37   }
38
39  },
40
41  create : function()
42  {
43    var _this = this;
44    this.dialog = Roo.factory({
45     center : {
46      '|xns' : 'Roo',
47      xns : Roo,
48      xtype : 'LayoutRegion'
49     },
50     '|xns' : 'Roo',
51     builderCfg : '{\"cols\":[{\"table\":\"addr\",\"column\":\"addr_id\",\"columnshort\":\"addr_id\",\"ctype\":\"int4\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\",\"display\":\"addr_id\"},{\"table\":\"addr\",\"column\":\"addr_active\",\"columnshort\":\"addr_active\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_line1\",\"columnshort\":\"addr_line1\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_line2\",\"columnshort\":\"addr_line2\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_line3\",\"columnshort\":\"addr_line3\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_city\",\"columnshort\":\"addr_city\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_state\",\"columnshort\":\"addr_state\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_postalcode\",\"columnshort\":\"addr_postalcode\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_country\",\"columnshort\":\"addr_country\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_notes\",\"columnshort\":\"addr_notes\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"addr\",\"column\":\"addr_number\",\"columnshort\":\"addr_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"addr_id\"],\"table\":\"addr\",\"xtype\":\"LayoutDialog\",\"|xns\":\"Roo\"}',
52     closable : false,
53     collapsible : false,
54     height : 400,
55     modal : true,
56     resizable : false,
57     title : _this._strings['0dbd2559b7f2c43a6e5f0a649c4b172a'],
58     width : 500,
59     xns : Roo,
60     xtype : 'LayoutDialog',
61     buttons : [
62       {
63        '|xns' : 'Roo',
64        text : _this._strings['ea4788705e6873b424c65e91c2846b19'],
65        xns : Roo,
66        xtype : 'Button',
67        listeners : {
68         click : function (_self, e)
69          {
70              _this.dialog.hide();
71          }
72        }
73       },
74 {
75        '|xns' : 'Roo',
76        text : _this._strings['c9cc8cce247e49bae79f15173ce97354'],
77        xns : Roo,
78        xtype : 'Button',
79        listeners : {
80         click : function (_self, e)
81          {
82              // do some checks?
83               
84              
85           
86              _this.form.doAction('submit');
87          
88          }
89        }
90       }
91     ],
92     items : [
93      {
94       toolbar : {
95        '|xns' : 'Roo',
96        xns : Roo,
97        xtype : 'Toolbar',
98        items : [
99         {
100          '|xns' : 'Roo.Toolbar',
101          xns : Roo.Toolbar,
102          xtype : 'Fill'
103         },
104         {
105          '|xns' : 'Roo.Toolbar',
106          cls : 'x-btn-text-icon',
107          icon : rootURL + '/Pman/templates/images/trash.gif',
108          text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'],
109          xns : Roo.Toolbar,
110          xtype : 'Button',
111          listeners : {
112           click : function()
113            {
114                var id = _this.form.findField('addr_id').getValue() *1;
115                if (!id) {
116                    Roo.MessageBox.alert("Error", "You can not delete this, you have not created it yet");
117                    return;
118                }
119                
120                
121                Roo.MessageBox.confirm("Confirm", "You will only be able to delete this if it is not referenced anywhere<BR>"+
122                        ", are you sure you want to try that?",
123                        function (res) {
124                            if(res!='yes') {
125                                return;
126                            
127                            }
128                            new Pman.Request({
129                                method: 'POST',
130                                url: baseURL+ '/Roo/addr',
131                                params : {
132                                    _delete : id
133                                },
134                                success : function() {
135                                    _this.callback({ addr_id : 0, addr_line1 : '' });
136                                    _this.dialog.hide();
137                                }
138                            });
139                    });
140                    
141                
142                
143            }
144          }
145         }
146        ]
147
148       },
149       '|xns' : 'Roo',
150       region : 'center',
151       xns : Roo,
152       xtype : 'ContentPanel',
153       items : [
154        {
155         '|xns' : 'Roo.form',
156         method : 'POST',
157         style : 'margin:10px;',
158         url : baseURL + '/Roo/addr.php',
159         xns : Roo.form,
160         xtype : 'Form',
161         listeners : {
162          actioncomplete : function(_self,action)
163           {
164               if (action.type == 'setdata') {
165                   if (_this.data.addr_id) { 
166                       this.load({ method: 'GET', params: { '_id' : _this.data.addr_id }});
167                   }
168                  return;
169               }
170               if (action.type == 'load') {
171                   return;
172               }
173               if (action.type =='submit') {
174               
175                   _this.dialog.hide();
176               
177                    if (_this.callback) {
178                        _this.form.setValues(action.result.data);
179                       _this.callback.call(_this, _this.form.getValues());
180                    }
181                    _this.form.reset();
182                    return;
183               }
184           },
185          rendered : function (form)
186           {
187               _this.form= form;
188           }
189         },
190         items : [
191          {
192           '|xns' : 'Roo.form',
193           allowBlank : false,
194           fieldLabel : 'Line 1',
195           name : 'addr_line1',
196           width : 300,
197           xns : Roo.form,
198           xtype : 'TextField',
199           listeners : {
200            keyup : function (_self, e)
201             {
202                 _this.form.findField('addr_number').sync();
203             }
204           }
205          },
206          {
207           '|xns' : 'Roo.form',
208           fieldLabel : 'Line 2',
209           name : 'addr_line2',
210           width : 300,
211           xns : Roo.form,
212           xtype : 'TextField'
213          },
214          {
215           '|xns' : 'Roo.form',
216           fieldLabel : 'Line 3',
217           name : 'addr_line3',
218           width : 300,
219           xns : Roo.form,
220           xtype : 'TextField'
221          },
222          {
223           '|xns' : 'Roo.form',
224           fieldLabel : 'City',
225           name : 'addr_city',
226           width : 300,
227           xns : Roo.form,
228           xtype : 'TextField'
229          },
230          {
231           store : {
232            proxy : {
233             '|xns' : 'Roo.data',
234             method : 'GET',
235             url : baseURL + '/Roo/addr.php',
236             xns : Roo.data,
237             xtype : 'HttpProxy'
238            },
239            reader : {
240             '|xns' : 'Roo.data',
241             fields : [ 'addr_state' ],
242             id : 'addr_state',
243             root : 'data',
244             totalProperty : 'total',
245             xns : Roo.data,
246             xtype : 'JsonReader'
247            },
248            '|xns' : 'Roo.data',
249            remoteSort : true,
250            sortInfo : { direction : 'ASC', field: 'addr_state' },
251            xns : Roo.data,
252            xtype : 'Store',
253            listeners : {
254             beforeload : function (_self, o){
255                  o.params = o.params || {};
256                  
257                 // o.params.state_country_id_country_name = _this.form.findField('addr_country').getValue();
258                  //if (!o.params.state_country_id_country_name.length) {
259                  //    Roo.MessageBox.alert("Select Country First");
260              //        return false;
261                //  }
262                
263                 o.params._distinct = 'addr_state';
264                 o.params._columns = 'addr_state';
265                 o.params.limit = 999;
266                  // set more here
267              }
268            },
269            items : [
270
271            ]
272
273           },
274           '|xns' : 'Roo.form',
275           allowBlank : true,
276           displayField : 'addr_state',
277           editable : true,
278           emptyText : _this._strings['46a2a41cc6e552044816a2d04634545d'],
279           fieldLabel : 'State',
280           listWidth : 400,
281           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'],
282           minChars : 2,
283           name : 'addr_state',
284           qtip : _this._strings['be2933038f93e25262400220080c111f'],
285           queryParam : 'query[addr_state]',
286           selectOnFocus : true,
287           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{addr_state}</b></div>',
288           triggerAction : 'all',
289           typeAhead : false,
290           valueField : 'addr_state',
291           width : 200,
292           xns : Roo.form,
293           xtype : 'ComboBox',
294           items : [
295
296           ]
297
298          },
299          {
300           store : {
301            proxy : {
302             '|xns' : 'Roo.data',
303             method : 'GET',
304             url : baseURL + '/Roo/country.php',
305             xns : Roo.data,
306             xtype : 'HttpProxy'
307            },
308            reader : {
309             '|xns' : 'Roo.data',
310             fields : [{'name':'country_id','type':'int'},'county_name'],
311             id : 'country_id',
312             root : 'data',
313             totalProperty : 'total',
314             xns : Roo.data,
315             xtype : 'JsonReader'
316            },
317            '|xns' : 'Roo.data',
318            remoteSort : true,
319            sortInfo : { direction : 'ASC', field: 'country_name' },
320            xns : Roo.data,
321            xtype : 'Store',
322            listeners : {
323             beforeload : function (_self, o){
324                  o.params = o.params || {};
325                  // set more here
326                  o.params.limit = 999;
327              }
328            },
329            items : [
330
331            ]
332
333           },
334           '|xns' : 'Roo.form',
335           allowBlank : true,
336           displayField : 'country_name',
337           editable : true,
338           emptyText : _this._strings['59716c97497eb9694541f7c3d37b1a4d'],
339           fieldLabel : 'Country',
340           listWidth : 400,
341           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'],
342           minChars : 2,
343           name : 'addr_country',
344           qtip : _this._strings['3c1df4260ce594cb5594696461087f2f'],
345           queryParam : 'query[country_name]',
346           selectOnFocus : true,
347           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{country_name}</b> </div>',
348           triggerAction : 'all',
349           typeAhead : false,
350           valueField : 'country_name',
351           width : 200,
352           xns : Roo.form,
353           xtype : 'ComboBox',
354           items : [
355
356           ]
357
358          },
359          {
360           '|xns' : 'Roo.form',
361           fieldLabel : 'postalcode',
362           name : 'addr_postalcode',
363           width : 150,
364           xns : Roo.form,
365           xtype : 'TextField'
366          },
367          {
368           '|xns' : 'Roo.form',
369           fieldLabel : 'Unique#',
370           name : 'addr_number',
371           sync : function() {
372               if (_this.form.findField('addr_id') * 1 > 0 ) {
373                   return;
374               }
375               this.setValue('C' + _this.form.findField('customer_id').getValue() + '-' + 
376                   _this.form.findField('addr_line1').getValue()
377               );
378                   
379           },
380           width : 150,
381           xns : Roo.form,
382           xtype : 'TextField'
383          },
384          {
385           '|xns' : 'Roo.form',
386           fieldLabel : 'notes',
387           name : 'addr_notes',
388           width : 300,
389           xns : Roo.form,
390           xtype : 'TextArea'
391          },
392          {
393           '|xns' : 'Roo.form',
394           name : 'customer_id',
395           width : 100,
396           xns : Roo.form,
397           xtype : 'Hidden'
398          },
399          {
400           '|xns' : 'Roo.form',
401           name : 'addr_id',
402           width : 100,
403           xns : Roo.form,
404           xtype : 'Hidden'
405          }
406         ]
407
408        }
409       ]
410
411      }
412     ]
413
414    });
415  }
416 };