Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleSalesProductList.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.XtupleSalesProductList = {
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.grid.footer.onClick('first');
37                 }
38             },
39             closable : false,
40             collapsible : false,
41             height : 600,
42             modal : true,
43             resizable : false,
44             title : "Products List",
45             width : 1000,
46             items : [
47                 {
48                     xtype: 'GridPanel',
49                     xns: Roo,
50                     listeners : {
51                         activate : function() {
52                             _this.panel = this;
53                             
54                          //   if (_this.grid) {
55                          //       _this.grid.footer.onClick('first');
56                          //   }
57                         }
58                     },
59                     background : false,
60                     fitContainer : true,
61                     fitToframe : true,
62                     region : 'center',
63                     tableName : 'item',
64                     title : "Products List",
65                     grid : {
66                         xtype: 'Grid',
67                         xns: Roo.grid,
68                         listeners : {
69                             render : function() 
70                             {
71                                 _this.grid = this; 
72                               //  if (_this.panel.active) {
73                             //      this.footer.onClick('first');
74                               //  }
75                                 
76                             },
77                             rowdblclick : function (_self, rowIndex, e)
78                             {
79                                 _this.dialog.hide();
80                                 if(!_this.callback){
81                                     return;
82                                 }
83                                 var s = this.ds.getAt(rowIndex);
84                                 if (s.data.item_id * 1 < 1 ) {
85                                     return;
86                                 }
87                                 
88                                 _this.callback.call(_this,s.data);
89                             }
90                         },
91                         autoExpandColumn : 'item_descrip1',
92                         loadMask : true,
93                         sm : {
94                             xtype: 'RowSelectionModel',
95                             xns: Roo.grid,
96                             singleSelect : false
97                         },
98                         dataSource : {
99                             xtype: 'Store',
100                             xns: Roo.data,
101                             listeners : {
102                                 beforeload : function (_self, o)
103                                 {
104                                       o.params._with_prodcat = 1;
105                                       o.params._with_char = 1;
106                                       if (!_this.data.exclude_itemsrc_vendor) {
107                                       
108                                           o.params._with_itemsrc_active = 1;
109                                       }
110                                       o.params._with_last_purchase_price = 1;
111                                       o.params._with_itemsite = 1;
112                                       o.params._with_image = 1;
113                                 
114                                       if(typeof(_this.data.cohead_cust_id) != 'undefined'){
115                                         o.params.cohead_cust_id = _this.data.cohead_cust_id;
116                                       }
117                                       
118                                       if(typeof(_this.data.cohead_id) != 'undefined'){
119                                         o.params.cohead_id = _this.data.cohead_id;
120                                       }
121                                       
122                                       var s = _this.searchBox.getValue();
123                                       if (s.length) {
124                                             o.params['query[number_or_name]'] = s;
125                                        }
126                                        if (_this.data.exclude_itemsrc_vendor) {
127                                             o.params._exclude_itemsrc_vendor = _this.data.exclude_itemsrc_vendor;
128                                        } 
129                                         
130                                       _this.addSelected.show();
131                                       if (!_this.data.multi_select) {
132                                             _this.addSelected.hide();
133                                       }
134                                       
135                                 }
136                             },
137                             remoteSort : true,
138                             sortInfo : { field : 'item_number', direction: 'ASC' },
139                             proxy : {
140                                 xtype: 'HttpProxy',
141                                 xns: Roo.data,
142                                 method : 'GET',
143                                 url : baseURL + '/Roo/item.php'
144                             },
145                             reader : {
146                                 xtype: 'JsonReader',
147                                 xns: Roo.data,
148                                 id : 'item_id',
149                                 root : 'data',
150                                 totalProperty : 'total',
151                                 fields : [
152                                     {
153                                         'name': 'item_id',
154                                         'type': 'int'
155                                     },
156                                     {
157                                         'name': 'item_number',
158                                         'type': 'string'
159                                     },
160                                     {
161                                         'name': 'item_descrip1',
162                                         'type': 'string'
163                                     },
164                                     {
165                                         'name': 'item_descrip2',
166                                         'type': 'string'
167                                     },
168                                     {
169                                         'name': 'item_classcode_id',
170                                         'type': 'int'
171                                     },
172                                     {
173                                         'name': 'item_picklist',
174                                         'type': 'int'
175                                     },
176                                     {
177                                         'name': 'item_comments',
178                                         'type': 'string'
179                                     },
180                                     {
181                                         'name': 'item_sold',
182                                         'type': 'int'
183                                     },
184                                     {
185                                         'name': 'item_fractional',
186                                         'type': 'int'
187                                     },
188                                     {
189                                         'name': 'item_active',
190                                         'type': 'int'
191                                     },
192                                     {
193                                         'name': 'item_type',
194                                         'type': 'string'
195                                     },
196                                     {
197                                         'name': 'item_prodweight',
198                                         'type': 'float'
199                                     },
200                                     {
201                                         'name': 'item_packweight',
202                                         'type': 'float'
203                                     },
204                                     {
205                                         'name': 'item_prodcat_id',
206                                         'type': 'int'
207                                     },
208                                     {
209                                         'name': 'item_exclusive',
210                                         'type': 'int'
211                                     },
212                                     {
213                                         'name': 'item_listprice',
214                                         'type': 'float'
215                                     },
216                                     {
217                                         'name': 'item_config',
218                                         'type': 'int'
219                                     },
220                                     {
221                                         'name': 'item_extdescrip',
222                                         'type': 'string'
223                                     },
224                                     {
225                                         'name': 'item_upccode',
226                                         'type': 'string'
227                                     },
228                                     {
229                                         'name': 'item_maxcost',
230                                         'type': 'float'
231                                     },
232                                     {
233                                         'name': 'item_inv_uom_id',
234                                         'type': 'int'
235                                     },
236                                     {
237                                         'name': 'item_price_uom_id',
238                                         'type': 'int'
239                                     },
240                                     {
241                                         'name': 'item_warrdays',
242                                         'type': 'int'
243                                     },
244                                     {
245                                         'name': 'item_freightclass_id',
246                                         'type': 'int'
247                                     },
248                                     {
249                                         'name': 'item_tax_recoverable',
250                                         'type': 'int'
251                                     },
252                                     {
253                                         'name': 'item_price_uom_id_uom_id',
254                                         'type': 'int'
255                                     },
256                                     {
257                                         'name': 'item_price_uom_id_uom_name',
258                                         'type': 'string'
259                                     },
260                                     {
261                                         'name': 'item_price_uom_id_uom_descrip',
262                                         'type': 'string'
263                                     },
264                                     {
265                                         'name': 'item_price_uom_id_uom_item_weight',
266                                         'type': 'int'
267                                     },
268                                     {
269                                         'name': 'item_inv_uom_id_uom_id',
270                                         'type': 'int'
271                                     },
272                                     {
273                                         'name': 'item_inv_uom_id_uom_name',
274                                         'type': 'string'
275                                     },
276                                     {
277                                         'name': 'item_inv_uom_id_uom_descrip',
278                                         'type': 'string'
279                                     },
280                                     {
281                                         'name': 'item_inv_uom_id_uom_item_weight',
282                                         'type': 'int'
283                                     },
284                                     {
285                                         'name': 'item_freightclass_id_freightclass_id',
286                                         'type': 'int'
287                                     },
288                                     {
289                                         'name': 'item_freightclass_id_freightclass_code',
290                                         'type': 'string'
291                                     },
292                                     {
293                                         'name': 'item_freightclass_id_freightclass_descrip',
294                                         'type': 'string'
295                                     },
296                                     {
297                                         'name': 'item_classcode_id_classcode_id',
298                                         'type': 'int'
299                                     },
300                                     {
301                                         'name': 'item_classcode_id_classcode_code',
302                                         'type': 'string'
303                                     },
304                                     {
305                                         'name': 'item_classcode_id_classcode_descrip',
306                                         'type': 'string'
307                                     },
308                                     {
309                                         'name': 'item_classcode_id_classcode_mfg',
310                                         'type': 'int'
311                                     },
312                                     {
313                                         'name': 'item_classcode_id_classcode_creator',
314                                         'type': 'string'
315                                     },
316                                     {
317                                         'name': 'item_classcode_id_classcode_created',
318                                         'type': 'date'
319                                     },
320                                     {
321                                         'name': 'item_classcode_id_classcode_modifier',
322                                         'type': 'string'
323                                     },
324                                     {
325                                         'name': 'item_classcode_id_classcode_modified',
326                                         'type': 'date'
327                                     },
328                                     {
329                                         'name': 'item_classcode_id_classcode_type',
330                                         'type': 'string'
331                                     }
332                                 ]
333                             }
334                         },
335                         footer : {
336                             xtype: 'PagingToolbar',
337                             xns: Roo,
338                             displayInfo : true,
339                             displayMsg : "Double click to select the item",
340                             emptyMsg : "No item found",
341                             pageSize : 25
342                         },
343                         toolbar : {
344                             xtype: 'Toolbar',
345                             xns: Roo,
346                             items : [
347                                 {
348                                     xtype: 'TextField',
349                                     xns: Roo.form,
350                                     listeners : {
351                                         specialkey : function (_self, e)
352                                         {
353                                           _this.grid.footer.onClick('first');
354                                         },
355                                         render : function (_self)
356                                         {
357                                             _this.searchBox = _self;
358                                         }
359                                     }
360                                 },
361                                 {
362                                     xtype: 'Button',
363                                     xns: Roo.Toolbar,
364                                     listeners : {
365                                         click : function (_self, e)
366                                         {
367                                             _this.grid.footer.onClick('first');
368                                         }
369                                     },
370                                     cls : 'x-btn-icon',
371                                     icon : rootURL + '/Pman/templates/images/search.gif'
372                                 },
373                                 {
374                                     xtype: 'Button',
375                                     xns: Roo.Toolbar,
376                                     listeners : {
377                                         click : function (_self, e)
378                                         {
379                                             _this.searchBox.setValue('');\r
380                                             _this.status_type.setValue('');\r
381                                             _this.grid.footer.onClick('first');\r
382                                         }
383                                     },
384                                     cls : 'x-btn-icon',
385                                     icon : rootURL + '/Pman/templates/images/edit-clear.gif'
386                                 }
387                             ]
388                         },
389                         colModel : [
390                             {
391                                 xtype: 'ColumnModel',
392                                 xns: Roo.grid,
393                                 dataIndex : 'item_image_id',
394                                 header : 'Image',
395                                 width : 100,
396                                 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/50/{1}/{2}" height="50">', baseURL, v, r.data.item_image_filename); }
397                             },
398                             {
399                                 xtype: 'ColumnModel',
400                                 xns: Roo.grid,
401                                 dataIndex : 'item_char_brand',
402                                 header : 'Brand',
403                                 sortable : true,
404                                 width : 100,
405                                 renderer : function(v) { return String.format('{0}', v); }
406                             },
407                             {
408                                 xtype: 'ColumnModel',
409                                 xns: Roo.grid,
410                                 dataIndex : 'item_char_productgroup',
411                                 header : 'Product Group',
412                                 width : 100,
413                                 renderer : function(v) { return String.format('{0}', v); }
414                             },
415                             {
416                                 xtype: 'ColumnModel',
417                                 xns: Roo.grid,
418                                 dataIndex : 'item_number',
419                                 header : 'Number',
420                                 width : 75,
421                                 renderer : function(v) { return String.format('{0}', v); }
422                             },
423                             {
424                                 xtype: 'ColumnModel',
425                                 xns: Roo.grid,
426                                 dataIndex : 'item_descrip1',
427                                 header : 'Description',
428                                 width : 200,
429                                 renderer : function(v) { return String.format('{0}', v); }
430                             },
431                             {
432                                 xtype: 'ColumnModel',
433                                 xns: Roo.grid,
434                                 dataIndex : 'itemsrc_active',
435                                 header : 'Purchased',
436                                 width : 75,
437                                 renderer : function(v) {  
438                                     var state = v * 1 > 0 ?  '-checked' : '';
439                                 
440                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
441                                                 
442                                  }
443                             },
444                             {
445                                 xtype: 'ColumnModel',
446                                 xns: Roo.grid,
447                                 dataIndex : 'item_sold',
448                                 header : 'is Sold?',
449                                 width : 50,
450                                 renderer : function(v) {  
451                                     var state = v * 1 > 0 ?  '-checked' : '';
452                                 
453                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
454                                                 
455                                  }
456                             },
457                             {
458                                 xtype: 'ColumnModel',
459                                 xns: Roo.grid,
460                                 dataIndex : 'item_active',
461                                 header : 'is Active?',
462                                 width : 55,
463                                 renderer : function(v) {  
464                                     var state = v * 1 > 0 ?  '-checked' : '';
465                                 
466                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
467                                                 
468                                  }
469                             },
470                             {
471                                 xtype: 'ColumnModel',
472                                 xns: Roo.grid,
473                                 dataIndex : 'item_type',
474                                 header : 'Type',
475                                 width : 50,
476                                 renderer : function(v) { return String.format('{0}', v); }
477                             },
478                             {
479                                 xtype: 'ColumnModel',
480                                 xns: Roo.grid,
481                                 dataIndex : 'item_prodcat_id_prodcat_code',
482                                 header : 'Item prodcat',
483                                 width : 100,
484                                 renderer : function(v) { return String.format('{0}', v); }
485                             }
486                         ]
487                     }
488                 }
489             ],
490             center : {
491                 xtype: 'LayoutRegion',
492                 xns: Roo
493             },
494             buttons : [
495                 {
496                     xtype: 'Button',
497                     xns: Roo,
498                     listeners : {
499                         click : function (_self, e)
500                         {
501                         
502                             if(!_this.callback){
503                                  _this.dialog.hide();
504                                 return;
505                             }
506                             var sels = _this.grid.selModel.getSelections();
507                             if (!sels.length) {
508                                 Roo.MessageBox.alert("Error", "Select some items");
509                             }
510                               _this.dialog.hide();
511                             _this.callback.call(_this,sels);
512                         },
513                         render : function (_self)
514                         {
515                             _this.addSelected = _self;
516                         }
517                     },
518                     text : "Add Selected"
519                 },
520                 {
521                     xtype: 'Button',
522                     xns: Roo,
523                     listeners : {
524                         click : function (_self, e)
525                         {
526                             Pman.Dialog.XtupleItem.show({item_id : 0}, function(){
527                                 _this.grid.footer.onClick('first');
528                             });
529                         }
530                     },
531                     text : "Create New"
532                 },
533                 {
534                     xtype: 'Button',
535                     xns: Roo,
536                     listeners : {
537                         click : function (_self, e)
538                         {
539                             _this.dialog.hide();
540                         }
541                     },
542                     text : "Cancel"
543                 }
544             ]
545         });
546     }
547 };