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