Pman.Dialog.XtupleTerms.bjs
[Pman.Xtuple] / Pman.Dialog.XtupleTerms.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.XtupleTerms = {
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 : "Create / Edit Terms",
42             xtype : 'LayoutDialog',
43             width : 500,
44             xns : Roo,
45             closable : false,
46             resizable : false,
47             height : 550,
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/terms.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: { _id : _this.data.id}});
99                                                return;
100                                            }
101                                            
102                                            return;
103                                        }
104                                        if (action.type == 'load') {
105                                            return;
106                                        }
107                                        if (action.type =='submit') {
108                                        
109                                            _this.dialog.hide();
110                                        
111                                             if (_this.callback) {
112                                                _this.callback.call(_this, _this.form.getValues());
113                                             }
114                                             
115                                             _this.form.reset();
116                                             return;
117                                        }
118                                    },
119                                 rendered : function (form)
120                                    {
121                                        _this.form= form;
122                                    }
123                             },
124                             items : [
125                                 {
126                                     '|xns' : 'Roo.form',
127                                     legend : "Details",
128                                     style : 'width:420px',
129                                     xtype : 'FieldSet',
130                                     xns : Roo.form,
131                                     items : [
132                                         {
133                                             '|xns' : 'Roo.form',
134                                             fieldLabel : 'First Name',
135                                             xtype : 'TextField',
136                                             allowBlank : false,
137                                             width : 300,
138                                             xns : Roo.form,
139                                             name : 'cntct_first_name'
140                                         },
141                                         {
142                                             '|xns' : 'Roo.form',
143                                             fieldLabel : 'Last Name',
144                                             xtype : 'TextField',
145                                             width : 300,
146                                             xns : Roo.form,
147                                             name : 'cntct_last_name'
148                                         },
149                                         {
150                                             '|xns' : 'Roo.form',
151                                             fieldLabel : 'Phone',
152                                             xtype : 'TextField',
153                                             regex : /^[0-9 +-]+$/,
154                                             width : 300,
155                                             xns : Roo.form,
156                                             name : 'cntct_phone'
157                                         },
158                                         {
159                                             '|xns' : 'Roo.form',
160                                             fieldLabel : 'Alt',
161                                             xtype : 'TextField',
162                                             regex : /^[0-9 +-]+$/,
163                                             width : 300,
164                                             xns : Roo.form,
165                                             name : 'cntct_phone2'
166                                         },
167                                         {
168                                             '|xns' : 'Roo.form',
169                                             allowBlank : false,
170                                             fieldLabel : 'Email',
171                                             vtype : 'email',
172                                             xtype : 'TextField',
173                                             width : 300,
174                                             xns : Roo.form,
175                                             name : 'cntct_email'
176                                         },
177                                         {
178                                             '|xns' : 'Roo.form',
179                                             fieldLabel : 'Password',
180                                             xtype : 'TextField',
181                                             inputType : 'password',
182                                             width : 300,
183                                             xns : Roo.form,
184                                             name : 'password'
185                                         },
186                                         {
187                                             '|xns' : 'Roo.form',
188                                             fieldLabel : 'Confirm PW',
189                                             xtype : 'TextField',
190                                             inputType : 'password',
191                                             width : 300,
192                                             xns : Roo.form,
193                                             name : 'password2'
194                                         },
195                                         {
196                                             '|xns' : 'Roo.form',
197                                             checked : true,
198                                             fieldLabel : 'Active',
199                                             xtype : 'Checkbox',
200                                             valueOff : 0,
201                                             xns : Roo.form,
202                                             inputValue : true,
203                                             name : 'cntct_active'
204                                         }
205                                     ]
206
207                                 },
208                                 {
209                                     '|xns' : 'Roo.form',
210                                     fieldLabel : 'Code',
211                                     xtype : 'TextField',
212                                     allowBlank : false,
213                                     width : 300,
214                                     xns : Roo.form,
215                                     name : 'terms_code'
216                                 },
217                                 {
218                                     '|xns' : 'Roo.form',
219                                     fieldLabel : 'Description',
220                                     width : 300,
221                                     xtype : 'TextArea',
222                                     xns : Roo.form,
223                                     name : 'terms_descrip'
224                                 },
225                                 {
226                                     '|xns' : 'Roo.form',
227                                     fieldLabel : 'Due Days',
228                                     allowDecimals : true,
229                                     xtype : 'NumberField',
230                                     decimalPrecision : 0,
231                                     width : 300,
232                                     xns : Roo.form,
233                                     name : 'terms_duedays'
234                                 },
235                                 {
236                                     '|xns' : 'Roo.form',
237                                     fieldLabel : 'Discount Day',
238                                     xtype : 'NumberField',
239                                     allowDecimals : true,
240                                     decimalPrecision : 0,
241                                     width : 300,
242                                     xns : Roo.form,
243                                     name : 'terms_discdays'
244                                 },
245                                 {
246                                     '|xns' : 'Roo.form',
247                                     xtype : 'Hidden',
248                                     xns : Roo.form,
249                                     value : "D",
250                                     name : 'terms_type'
251                                 },
252                                 {
253                                     '|xns' : 'Roo.form',
254                                     xtype : 'Hidden',
255                                     xns : Roo.form,
256                                     name : 'terms_id'
257                                 }
258                             ]
259
260                         }
261                     ]
262
263                 }
264             ]
265
266         });
267     }
268 };