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