Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleProdcat.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.XtupleProdcat = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             closable : false,
34             collapsible : false,
35             height : 400,
36             modal : true,
37             resizable : false,
38             title : "Edit / Create Product Category",
39             width : 450,
40             items : [
41                 {
42                     xtype: 'ContentPanel',
43                     xns: Roo,
44                     region : 'center',
45                     items : [
46                         {
47                             xtype: 'Form',
48                             xns: Roo.form,
49                             listeners : {
50                                 actioncomplete : function(_self,action)
51                                 {
52                                     if (action.type == 'setdata') {
53                                         if(_this.data.prodcat_id){
54                                             _this.dialog.el.mask("Loading");
55                                             this.load({ method: 'GET', params: { '_id' : _this.data.prodcat_id, '_with_salesaccnt' : 1 }}); 
56                                         }
57                                        
58                                        _this.form.findField('salesaccnt_sales_accnt_id_descrip').setValue('');
59                                        _this.form.findField('salesaccnt_credit_accnt_id_descrip').setValue('');
60                                        _this.form.findField('salesaccnt_cos_accnt_id_descrip').setValue('');
61                                        return;
62                                     }
63                                     if (action.type == 'load') {
64                                         _this.dialog.el.unmask();
65                                         return;
66                                     }
67                                     if (action.type =='submit') {
68                                     
69                                         _this.dialog.el.unmask();
70                                         _this.dialog.hide();
71                                     
72                                          if (_this.callback) {
73                                             _this.callback.call(_this, _this.form.getValues());
74                                          }
75                                          _this.form.reset();
76                                          return;
77                                     }
78                                 },
79                                 rendered : function (form)
80                                 {
81                                     _this.form= form;
82                                 }
83                             },
84                             labelWidth : 150,
85                             method : 'POST',
86                             style : 'margin:10px;',
87                             url : baseURL + '/Roo/Prodcat.php',
88                             items : [
89                                 {
90                                     xtype: 'FieldSet',
91                                     xns: Roo.form,
92                                     legend : "Product Category Detail",
93                                     style : 'width:380px',
94                                     items : [
95                                         {
96                                             xtype: 'TextField',
97                                             xns: Roo.form,
98                                             allowBlank : false,
99                                             fieldLabel : 'Category Code',
100                                             name : 'prodcat_code',
101                                             width : 200
102                                         },
103                                         {
104                                             xtype: 'TextField',
105                                             xns: Roo.form,
106                                             allowBlank : false,
107                                             fieldLabel : 'Category Description',
108                                             name : 'prodcat_descrip',
109                                             width : 200
110                                         }
111                                     ]
112                                 },
113                                 {
114                                     xtype: 'FieldSet',
115                                     xns: Roo.form,
116                                     legend : "Account Setting",
117                                     style : 'width:380px',
118                                     items : [
119                                         {
120                                             xtype: 'Row',
121                                             xns: Roo.form,
122                                             labelWidth : 150,
123                                             items : [
124                                                 {
125                                                     xtype: 'ComboBox',
126                                                     xns: Roo.form,
127                                                     listeners : {
128                                                         beforeselect : function (combo, record, index)
129                                                         {
130                                                             _this.form.findField('salesaccnt_sales_accnt_id_descrip').setValue(record.data.accnt_descrip);
131                                                         }
132                                                     },
133                                                     allowBlank : false,
134                                                     displayField : 'accnt_name',
135                                                     editable : true,
136                                                     emptyText : "Select Account",
137                                                     fieldLabel : 'Inventory Sales Account',
138                                                     forceSelection : true,
139                                                     hiddenName : 'salesaccnt_sales_accnt_id',
140                                                     listWidth : 400,
141                                                     loadingText : "Searching...",
142                                                     minChars : 2,
143                                                     name : 'salesaccnt_sales_accnt_id_name',
144                                                     pageSize : 20,
145                                                     qtip : "Select Account",
146                                                     queryParam : 'search[name]',
147                                                     selectOnFocus : true,
148                                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{accnt_name} ( {accnt_descrip} )</b> </div>',
149                                                     triggerAction : 'all',
150                                                     typeAhead : true,
151                                                     valueField : 'accnt_id',
152                                                     width : 200,
153                                                     store : {
154                                                         xtype: 'Store',
155                                                         xns: Roo.data,
156                                                         listeners : {
157                                                             beforeload : function (_self, o){
158                                                                 o.params = o.params || {};
159                                                                 // set more here
160                                                                 o.params.accnt_active = 1;
161                                                                 o.params.accnt_type = 'R';
162                                                             }
163                                                         },
164                                                         remoteSort : true,
165                                                         sortInfo : { direction : 'ASC', field: 'accnt_id' },
166                                                         proxy : {
167                                                             xtype: 'HttpProxy',
168                                                             xns: Roo.data,
169                                                             method : 'GET',
170                                                             url : baseURL + '/Roo/accnt.php'
171                                                         },
172                                                         reader : {
173                                                             xtype: 'JsonReader',
174                                                             xns: Roo.data,
175                                                             id : 'accnt_id',
176                                                             root : 'data',
177                                                             totalProperty : 'total',
178                                                             fields : [{"name":"accnt_id","type":"int"},{"name":"accnt_descrip","type":"string"}]
179                                                         }
180                                                     }
181                                                 }
182                                             ]
183                                         },
184                                         {
185                                             xtype: 'Row',
186                                             xns: Roo.form,
187                                             height : 30,
188                                             hideLabels : true,
189                                             style : 'margin-left:155px;',
190                                             items : [
191                                                 {
192                                                     xtype: 'DisplayField',
193                                                     xns: Roo.form,
194                                                     name : 'salesaccnt_sales_accnt_id_descrip',
195                                                     width : 200
196                                                 }
197                                             ]
198                                         },
199                                         {
200                                             xtype: 'Row',
201                                             xns: Roo.form,
202                                             labelWidth : 150,
203                                             items : [
204                                                 {
205                                                     xtype: 'ComboBox',
206                                                     xns: Roo.form,
207                                                     listeners : {
208                                                         beforeselect : function (combo, record, index)
209                                                         {
210                                                             _this.form.findField('salesaccnt_credit_accnt_id_descrip').setValue(record.data.accnt_descrip);
211                                                         }
212                                                     },
213                                                     allowBlank : false,
214                                                     displayField : 'accnt_name',
215                                                     editable : true,
216                                                     emptyText : "Select Account",
217                                                     fieldLabel : 'Credit Memo Account',
218                                                     forceSelection : true,
219                                                     hiddenName : 'salesaccnt_credit_accnt_id',
220                                                     listWidth : 400,
221                                                     loadingText : "Searching...",
222                                                     minChars : 2,
223                                                     name : 'salesaccnt_credit_accnt_id_name',
224                                                     pageSize : 20,
225                                                     qtip : "Select Account",
226                                                     queryParam : 'search[name]',
227                                                     selectOnFocus : true,
228                                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{accnt_name} ( {accnt_descrip} )</b> </div>',
229                                                     triggerAction : 'all',
230                                                     typeAhead : true,
231                                                     valueField : 'accnt_id',
232                                                     width : 200,
233                                                     store : {
234                                                         xtype: 'Store',
235                                                         xns: Roo.data,
236                                                         listeners : {
237                                                             beforeload : function (_self, o){
238                                                                 o.params = o.params || {};
239                                                                 // set more here
240                                                                 o.params.accnt_active = 1;
241                                                                 o.params.accnt_type = 'R';
242                                                             }
243                                                         },
244                                                         remoteSort : true,
245                                                         sortInfo : { direction : 'ASC', field: 'accnt_id' },
246                                                         proxy : {
247                                                             xtype: 'HttpProxy',
248                                                             xns: Roo.data,
249                                                             method : 'GET',
250                                                             url : baseURL + '/Roo/accnt.php'
251                                                         },
252                                                         reader : {
253                                                             xtype: 'JsonReader',
254                                                             xns: Roo.data,
255                                                             id : 'accnt_id',
256                                                             root : 'data',
257                                                             totalProperty : 'total',
258                                                             fields : [{"name":"accnt_id","type":"int"},{"name":"accnt_descrip","type":"string"}]
259                                                         }
260                                                     }
261                                                 }
262                                             ]
263                                         },
264                                         {
265                                             xtype: 'Row',
266                                             xns: Roo.form,
267                                             height : 30,
268                                             hideLabels : true,
269                                             style : 'margin-left:155px;',
270                                             items : [
271                                                 {
272                                                     xtype: 'DisplayField',
273                                                     xns: Roo.form,
274                                                     name : 'salesaccnt_credit_accnt_id_descrip',
275                                                     width : 200
276                                                 }
277                                             ]
278                                         },
279                                         {
280                                             xtype: 'Row',
281                                             xns: Roo.form,
282                                             labelWidth : 150,
283                                             items : [
284                                                 {
285                                                     xtype: 'ComboBox',
286                                                     xns: Roo.form,
287                                                     listeners : {
288                                                         beforeselect : function (combo, record, index)
289                                                         {
290                                                             _this.form.findField('salesaccnt_cos_accnt_id_descrip').setValue(record.data.accnt_descrip);
291                                                         }
292                                                     },
293                                                     allowBlank : false,
294                                                     displayField : 'accnt_name',
295                                                     editable : true,
296                                                     emptyText : "Select Account",
297                                                     fieldLabel : 'Cost of Sales Account',
298                                                     forceSelection : true,
299                                                     hiddenName : 'salesaccnt_cos_accnt_id',
300                                                     listWidth : 400,
301                                                     loadingText : "Searching...",
302                                                     minChars : 2,
303                                                     name : 'salesaccnt_cos_accnt_id_name',
304                                                     pageSize : 20,
305                                                     qtip : "Select Account",
306                                                     queryParam : 'search[name]',
307                                                     selectOnFocus : true,
308                                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{accnt_name} ( {accnt_descrip} )</b> </div>',
309                                                     triggerAction : 'all',
310                                                     typeAhead : true,
311                                                     valueField : 'accnt_id',
312                                                     width : 200,
313                                                     store : {
314                                                         xtype: 'Store',
315                                                         xns: Roo.data,
316                                                         listeners : {
317                                                             beforeload : function (_self, o){
318                                                                 o.params = o.params || {};
319                                                                 // set more here
320                                                                 o.params.accnt_active = 1;
321                                                                 o.params.accnt_type = 'E';
322                                                             }
323                                                         },
324                                                         remoteSort : true,
325                                                         sortInfo : { direction : 'ASC', field: 'accnt_id' },
326                                                         proxy : {
327                                                             xtype: 'HttpProxy',
328                                                             xns: Roo.data,
329                                                             method : 'GET',
330                                                             url : baseURL + '/Roo/accnt.php'
331                                                         },
332                                                         reader : {
333                                                             xtype: 'JsonReader',
334                                                             xns: Roo.data,
335                                                             id : 'accnt_id',
336                                                             root : 'data',
337                                                             totalProperty : 'total',
338                                                             fields : [{"name":"accnt_id","type":"int"},{"name":"accnt_descrip","type":"string"}]
339                                                         }
340                                                     }
341                                                 }
342                                             ]
343                                         },
344                                         {
345                                             xtype: 'Row',
346                                             xns: Roo.form,
347                                             height : 30,
348                                             hideLabels : true,
349                                             style : 'margin-left:155px;',
350                                             items : [
351                                                 {
352                                                     xtype: 'DisplayField',
353                                                     xns: Roo.form,
354                                                     name : 'salesaccnt_cos_accnt_id_descrip',
355                                                     width : 200
356                                                 }
357                                             ]
358                                         }
359                                     ]
360                                 },
361                                 {
362                                     xtype: 'Hidden',
363                                     xns: Roo.form,
364                                     name : 'prodcat_id'
365                                 },
366                                 {
367                                     xtype: 'Hidden',
368                                     xns: Roo.form,
369                                     name : 'salesaccnt_id'
370                                 }
371                             ]
372                         }
373                     ]
374                 }
375             ],
376             center : {
377                 xtype: 'LayoutRegion',
378                 xns: Roo
379             },
380             buttons : [
381                 {
382                     xtype: 'Button',
383                     xns: Roo,
384                     listeners : {
385                         click : function (_self, e)
386                         {
387                             _this.dialog.hide();
388                         }
389                     },
390                     text : "Cancel"
391                 },
392                 {
393                     xtype: 'Button',
394                     xns: Roo,
395                     listeners : {
396                         click : function (_self, e)
397                         {
398                             // do some checks?
399                              
400                             
401                            // _this.dialog.el.mask("Saving");
402                             _this.form.doAction("submit");
403                         
404                         }
405                     },
406                     text : "Save"
407                 }
408             ]
409         });
410     }
411 };