Pman.Dialog.XtuplePurchaseOrderNew.bjs
[Pman.Xtuple] / Pman.Dialog.XtuplePurchaseOrderNew.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.XtuplePurchaseOrderNew = {
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.form.findField('pohead_vend_id').focus();
37                 }
38             },
39             closable : false,
40             height : 180,
41             modal : true,
42             resizable : false,
43             title : "Pick Vendor",
44             width : 500,
45             items : [
46                 {
47                     xtype: 'ContentPanel',
48                     xns: Roo,
49                     region : 'center',
50                     items : [
51                         {
52                             xtype: 'Form',
53                             xns: Roo.form,
54                             listeners : {
55                                 rendered : function (form)
56                                 {
57                                   _this.form = form;
58                                 }
59                             },
60                             items : [
61                                 {
62                                     xtype: 'ComboBox',
63                                     xns: Roo.form,
64                                     listeners : {
65                                         select : function (combo, record, index)
66                                         {
67                                            
68                                            Roo.log(record);
69                                             _this.form.setValues({
70                                                 pohead_curr_id : record.data.vend_curr_id,
71                                                 pohead_curr_id_curr_name : record.data.vend_curr_id_curr_name
72                                             
73                                             });
74                                         },
75                                         render : function (_self)
76                                         {
77                                             _this.vendor = _self;
78                                         }
79                                     },
80                                     allowBlank : false,
81                                     displayField : 'vend_name',
82                                     editable : true,
83                                     fieldLabel : 'Select Vendor',
84                                     forceSelection : true,
85                                     hiddenName : 'pohead_vend_id',
86                                     listWidth : 400,
87                                     loadingText : "Searching...",
88                                     minChars : 2,
89                                     name : 'pohead_vend_id_vend_name',
90                                     pageSize : 20,
91                                     qtip : "Select a vendor",
92                                     queryParam : 'query[vend_name]',
93                                     selectOnFocus : true,
94                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{vend_name}</b></div>',
95                                     triggerAction : 'all',
96                                     typeAhead : true,
97                                     valueField : 'vend_id',
98                                     width : 300,
99                                     store : {
100                                         xtype: 'Store',
101                                         xns: Roo.data,
102                                         listeners : {
103                                             beforeload : function (_self, o){
104                                                 o.params = o.params || {};
105                                                 
106                                             }
107                                         },
108                                         remoteSort : true,
109                                         sortInfo : { direction : 'ASC', field: 'vend_name' },
110                                         proxy : {
111                                             xtype: 'HttpProxy',
112                                             xns: Roo.data,
113                                             method : 'GET',
114                                             url : baseURL + '/Roo/Vendinfo.php'
115                                         },
116                                         reader : {
117                                             xtype: 'JsonReader',
118                                             xns: Roo.data,
119                                             id : 'vend_id',
120                                             root : 'data',
121                                             totalProperty : 'total',
122                                             fields : [
123                                                 {"name":"vend_id","type":"int"},
124                                                 {"name":"vend_name","type":"string"}
125                                             ]
126                                         }
127                                     }
128                                 },
129                                 {
130                                     xtype: 'ComboBox',
131                                     xns: Roo.form,
132                                     allowBlank : false,
133                                     displayField : 'curr_name',
134                                     editable : false,
135                                     emptyText : "Select Currency",
136                                     fieldLabel : 'Currency',
137                                     forceSelection : true,
138                                     hiddenName : 'pohead_curr_id',
139                                     listWidth : 400,
140                                     loadingText : "Searching...",
141                                     minChars : 2,
142                                     name : 'pohead_curr_id_curr_name',
143                                     pageSize : 20,
144                                     qtip : "Select Currency",
145                                     queryParam : 'query[curr_name]',
146                                     selectOnFocus : true,
147                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
148                                     triggerAction : 'all',
149                                     typeAhead : true,
150                                     valueField : 'curr_id',
151                                     width : 300,
152                                     store : {
153                                         xtype: 'Store',
154                                         xns: Roo.data,
155                                         listeners : {
156                                             beforeload : function (_self, o){
157                                                 o.params = o.params || {};
158                                             }
159                                         },
160                                         remoteSort : true,
161                                         sortInfo : { direction : 'ASC', field: 'curr_id' },
162                                         proxy : {
163                                             xtype: 'HttpProxy',
164                                             xns: Roo.data,
165                                             method : 'GET',
166                                             url : baseURL + '/Roo/curr_symbol.php'
167                                         },
168                                         reader : {
169                                             xtype: 'JsonReader',
170                                             xns: Roo.data,
171                                             id : 'curr_id',
172                                             root : 'data',
173                                             totalProperty : 'total',
174                                             fields : [
175                                                 {"name":"curr_id","type":"int"},
176                                                 {"name":"curr_name","type":"string"}
177                                             ]
178                                         }
179                                     }
180                                 }
181                             ]
182                         }
183                     ]
184                 }
185             ],
186             center : {
187                 xtype: 'LayoutRegion',
188                 xns: Roo
189             },
190             buttons : [
191                 {
192                     xtype: 'Button',
193                     xns: Roo,
194                     listeners : {
195                         click : function (_self, e)
196                         {
197                            _this.dialog.hide();
198                          
199                          }
200                     },
201                     text : "Cancel"
202                 },
203                 {
204                     xtype: 'Button',
205                     xns: Roo,
206                     listeners : {
207                         click : function (_self, e)
208                         {
209                             if (_this.form.findField('pohead_vend_id').getValue() < 1) {
210                                 Roo.MessageBox.alert("Error", "Select a vendor");
211                                 return;
212                             }
213                             var last = _this.vendor.lastData;
214                             
215                             var data = _this.form.getFieldValues();
216                             
217                             data.pohead_terms_id_terms_descrip = last.vend_terms_id_terms_descrip
218                             data.pohead_terms_id = last.vend_terms_id
219                             
220                             data.pohead_taxzone_id = last.vend_taxzone_id;
221                             data.pohead_taxzone_id_taxzone_descrip = last.vend_taxzone_id_taxzone_descrip;
222                             
223                             _this.dialog.hide();
224                             _this.callback(data);
225                         }
226                     },
227                     text : "OK"
228                 }
229             ]
230         });
231     }
232 };