Fix #7123 - getting abra ready to test
[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                                         remoteSort : true,
108                                         sortInfo : { direction : 'ASC', field: 'vend_name' },
109                                         proxy : {
110                                             xtype: 'HttpProxy',
111                                             xns: Roo.data,
112                                             method : 'GET',
113                                             url : baseURL + '/Roo/Vendinfo.php'
114                                         },
115                                         reader : {
116                                             xtype: 'JsonReader',
117                                             xns: Roo.data,
118                                             id : 'vend_id',
119                                             root : 'data',
120                                             totalProperty : 'total',
121                                             fields : [
122                                                 {"name":"vend_id","type":"int"},
123                                                 {"name":"vend_name","type":"string"}
124                                             ]
125                                         }
126                                     }
127                                 },
128                                 {
129                                     xtype: 'ComboBox',
130                                     xns: Roo.form,
131                                     allowBlank : false,
132                                     displayField : 'curr_name',
133                                     editable : false,
134                                     emptyText : "Select Currency",
135                                     fieldLabel : 'Currency',
136                                     forceSelection : true,
137                                     hiddenName : 'pohead_curr_id',
138                                     listWidth : 400,
139                                     loadingText : "Searching...",
140                                     minChars : 2,
141                                     name : 'pohead_curr_id_curr_name',
142                                     pageSize : 20,
143                                     qtip : "Select Currency",
144                                     queryParam : 'query[curr_name]',
145                                     selectOnFocus : true,
146                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
147                                     triggerAction : 'all',
148                                     typeAhead : true,
149                                     valueField : 'curr_id',
150                                     width : 300,
151                                     store : {
152                                         xtype: 'Store',
153                                         xns: Roo.data,
154                                         listeners : {
155                                             beforeload : function (_self, o){
156                                                 o.params = o.params || {};
157                                             }
158                                         },
159                                         remoteSort : true,
160                                         sortInfo : { direction : 'ASC', field: 'curr_id' },
161                                         proxy : {
162                                             xtype: 'HttpProxy',
163                                             xns: Roo.data,
164                                             method : 'GET',
165                                             url : baseURL + '/Roo/curr_symbol.php'
166                                         },
167                                         reader : {
168                                             xtype: 'JsonReader',
169                                             xns: Roo.data,
170                                             id : 'curr_id',
171                                             root : 'data',
172                                             totalProperty : 'total',
173                                             fields : [
174                                                 {"name":"curr_id","type":"int"},
175                                                 {"name":"curr_name","type":"string"}
176                                             ]
177                                         }
178                                     }
179                                 }
180                             ]
181                         }
182                     ]
183                 }
184             ],
185             center : {
186                 xtype: 'LayoutRegion',
187                 xns: Roo
188             },
189             buttons : [
190                 {
191                     xtype: 'Button',
192                     xns: Roo,
193                     listeners : {
194                         click : function (_self, e)
195                         {
196                            _this.dialog.hide();
197                          
198                          }
199                     },
200                     text : "Cancel"
201                 },
202                 {
203                     xtype: 'Button',
204                     xns: Roo,
205                     listeners : {
206                         click : function (_self, e)
207                         {
208                             if (_this.form.findField('pohead_vend_id').getValue() < 1) {
209                                 Roo.MessageBox.alert("Error", "Select a vendor");
210                                 return;
211                             }
212                             var last = _this.vendor.lastData;
213                             
214                             var data = _this.form.getFieldValues();
215                             
216                             data.pohead_terms_id_terms_descrip = last.vend_terms_id_terms_descrip;
217                             data.pohead_terms_id = last.vend_terms_id;
218                             
219                             data.pohead_taxzone_id = last.vend_taxzone_id;
220                             data.pohead_taxzone_id_taxzone_descrip = last.vend_taxzone_id_taxzone_descrip;
221                             
222                             _this.dialog.hide();
223                             _this.callback(data);
224                         }
225                     },
226                     text : "OK"
227                 }
228             ]
229         });
230     }
231 };