Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleMiscellaneousCheck.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.XtupleMiscellaneousCheck = {
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             listeners : {
34                 show : function (_self)
35                 {
36                     this.layout.getRegion('center').showPanel(0);
37                 }
38             },
39             closable : false,
40             collapsible : false,
41             height : 350,
42             modal : true,
43             resizable : false,
44             title : "Create Miscellaneous Check",
45             width : 500,
46             items : [
47                 {
48                     xtype: 'ContentPanel',
49                     xns: Roo,
50                     region : 'center',
51                     items : [
52                         {
53                             xtype: 'Form',
54                             xns: Roo.form,
55                             listeners : {
56                                 actioncomplete : function(_self,action)
57                                 {
58                                     if (action.type == 'setdata') {
59                                        if(_this.data.checkhead_id){
60                                            _this.dialog.el.mask("Loading");
61                                            this.load({ method: 'GET', params: { '_id' : _this.data.checkhead_id }});
62                                            return;
63                                        }
64                                        return;
65                                     }
66                                     if (action.type == 'load') {
67                                         _this.dialog.el.unmask();
68                                         return;
69                                     }
70                                     if (action.type =='submit') {
71                                     
72                                         _this.dialog.el.unmask();
73                                         _this.dialog.hide();
74                                     
75                                          if (_this.callback) {
76                                             _this.callback.call(_this, _this.form.getValues());
77                                          }
78                                          _this.form.reset();
79                                          return;
80                                     }
81                                 },
82                                 rendered : function (form)
83                                 {
84                                     _this.form= form;
85                                 }
86                             },
87                             labelWidth : 150,
88                             method : 'POST',
89                             style : 'margin:10px;',
90                             url : baseURL + '/Roo/checkhead.php',
91                             items : [
92                                 {
93                                     xtype: 'TextField',
94                                     xns: Roo.form,
95                                     allowBlank : true,
96                                     fieldLabel : 'Customer',
97                                     name : 'cust_name',
98                                     readOnly : true,
99                                     width : 200
100                                 },
101                                 {
102                                     xtype: 'TextField',
103                                     xns: Roo.form,
104                                     allowBlank : true,
105                                     fieldLabel : 'Apply To Credit Memo',
106                                     name : 'cmhead_number',
107                                     readOnly : true,
108                                     width : 200
109                                 },
110                                 {
111                                     xtype: 'ComboBox',
112                                     xns: Roo.form,
113                                     allowBlank : false,
114                                     disabled : true,
115                                     displayField : 'curr_name',
116                                     editable : false,
117                                     emptyText : "Select Currency",
118                                     fieldLabel : 'Currency',
119                                     forceSelection : true,
120                                     hiddenName : 'checkhead_curr_id',
121                                     listWidth : 400,
122                                     loadingText : "Searching...",
123                                     minChars : 2,
124                                     name : 'checkhead_curr_id_curr_name',
125                                     pageSize : 20,
126                                     qtip : "Select Currency",
127                                     queryParam : 'query[curr_name]',
128                                     selectOnFocus : true,
129                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
130                                     triggerAction : 'all',
131                                     typeAhead : true,
132                                     valueField : 'curr_id',
133                                     width : 200,
134                                     store : {
135                                         xtype: 'Store',
136                                         xns: Roo.data,
137                                         listeners : {
138                                             beforeload : function (_self, o){
139                                                 o.params = o.params || {};
140                                                 // set more here
141                                                
142                                             }
143                                         },
144                                         remoteSort : true,
145                                         sortInfo : { direction : 'ASC', field: 'curr_symbol' },
146                                         proxy : {
147                                             xtype: 'HttpProxy',
148                                             xns: Roo.data,
149                                             method : 'GET',
150                                             url : baseURL + '/Roo/curr_symbol.php'
151                                         },
152                                         reader : {
153                                             xtype: 'JsonReader',
154                                             xns: Roo.data,
155                                             id : 'curr_id',
156                                             root : 'data',
157                                             totalProperty : 'total',
158                                             fields : [{"name":"curr_id","type":"int"},"curr_symbol"]
159                                         }
160                                     }
161                                 },
162                                 {
163                                     xtype: 'NumberField',
164                                     xns: Roo.form,
165                                     allowBlank : false,
166                                     allowDecimals : true,
167                                     decimalPrecision : 2,
168                                     fieldLabel : 'Amount',
169                                     name : 'checkhead_amount',
170                                     width : 200
171                                 },
172                                 {
173                                     xtype: 'ComboBox',
174                                     xns: Roo.form,
175                                     allowBlank : false,
176                                     displayField : 'bankaccnt_name',
177                                     editable : false,
178                                     emptyText : "Select Bank Accnt",
179                                     fieldLabel : 'Post to',
180                                     forceSelection : true,
181                                     hiddenName : 'checkhead_bankaccnt_id',
182                                     listWidth : 400,
183                                     loadingText : "Searching...",
184                                     minChars : 2,
185                                     name : 'checkhead_bankaccnt_id_name',
186                                     pageSize : 20,
187                                     qtip : "Select Bank Accnt",
188                                     queryParam : 'query[bankaccnt_name]',
189                                     selectOnFocus : true,
190                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{bankaccnt_name} - {bankaccnt_descrip}</b> </div>',
191                                     triggerAction : 'all',
192                                     typeAhead : true,
193                                     valueField : 'bankaccnt_id',
194                                     width : 200,
195                                     store : {
196                                         xtype: 'Store',
197                                         xns: Roo.data,
198                                         listeners : {
199                                             beforeload : function (_self, o){
200                                                 o.params = o.params || {};
201                                                 // set more here
202                                                
203                                             }
204                                         },
205                                         remoteSort : true,
206                                         sortInfo : { direction : 'DESC', field: 'bankaccnt_id' },
207                                         proxy : {
208                                             xtype: 'HttpProxy',
209                                             xns: Roo.data,
210                                             method : 'GET',
211                                             url : baseURL + '/Roo/bankaccnt.php'
212                                         },
213                                         reader : {
214                                             xtype: 'JsonReader',
215                                             xns: Roo.data,
216                                             id : 'bankaccnt_id',
217                                             root : 'data',
218                                             totalProperty : 'total',
219                                             fields : [{"name":"bankaccnt_id","type":"int"},"bankaccnt_name"]
220                                         }
221                                     }
222                                 },
223                                 {
224                                     xtype: 'DateField',
225                                     xns: Roo.form,
226                                     allowBlank : false,
227                                     fieldLabel : 'Date',
228                                     format : 'Y-m-d',
229                                     name : 'checkhead_checkdate',
230                                     width : 200
231                                 },
232                                 {
233                                     xtype: 'TextField',
234                                     xns: Roo.form,
235                                     allowBlank : true,
236                                     fieldLabel : 'Memo',
237                                     name : 'checkhead_for',
238                                     width : 200
239                                 },
240                                 {
241                                     xtype: 'TextArea',
242                                     xns: Roo.form,
243                                     allowBlank : true,
244                                     fieldLabel : 'Notes',
245                                     name : 'checkhead_notes',
246                                     width : 300
247                                 },
248                                 {
249                                     xtype: 'Hidden',
250                                     xns: Roo.form,
251                                     name : 'checkhead_id'
252                                 },
253                                 {
254                                     xtype: 'Hidden',
255                                     xns: Roo.form,
256                                     name : 'checkhead_recip_id'
257                                 },
258                                 {
259                                     xtype: 'Hidden',
260                                     xns: Roo.form,
261                                     name : 'checkhead_recip_type'
262                                 },
263                                 {
264                                     xtype: 'Hidden',
265                                     xns: Roo.form,
266                                     name : 'aropen_id'
267                                 },
268                                 {
269                                     xtype: 'Hidden',
270                                     xns: Roo.form,
271                                     name : 'checkhead_misc'
272                                 },
273                                 {
274                                     xtype: 'Hidden',
275                                     xns: Roo.form,
276                                     name : '_create_and_post'
277                                 },
278                                 {
279                                     xtype: 'Hidden',
280                                     xns: Roo.form,
281                                     name : 'remaining_total'
282                                 }
283                             ]
284                         }
285                     ]
286                 }
287             ],
288             center : {
289                 xtype: 'LayoutRegion',
290                 xns: Roo
291             },
292             buttons : [
293                 {
294                     xtype: 'Button',
295                     xns: Roo,
296                     listeners : {
297                         click : function (_self, e)
298                         {
299                             _this.dialog.hide();
300                         }
301                     },
302                     text : "Cancel"
303                 },
304                 {
305                     xtype: 'Button',
306                     xns: Roo,
307                     listeners : {
308                         click : function (_self, e)
309                         {
310                             // do some checks?
311                              
312                             
313                            // _this.dialog.el.mask("Saving");
314                            var a = _this.form.findField('checkhead_amount').getValue();
315                            var r = _this.form.findField('remaining_total').getValue();
316                            
317                            if(a - r > 0){
318                                 Roo.MessageBox.alert("Error", "You must enter an amount less than or equal to the credit memo! The amount remaining of this credit memo is " + r);
319                                 _this.form.findField('checkhead_amount').setValue(r);
320                                 return;
321                            }
322                            
323                            _this.form.doAction("submit");
324                         
325                         }
326                     },
327                     text : "Save"
328                 }
329             ]
330         });
331     }
332 };