Pman.Tab.XtuplePriceLists.bjs
[Pman.Xtuple] / Pman.Tab.XtuplePriceLists.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.Tab.XtuplePriceLists = new Roo.XComponent({
6     part     :  ["Xtuple","PriceLists"],
7     order    : '001-Pman.Tab.XtuplePriceLists',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleManage',
10     name     : "Pman.Tab.XtuplePriceLists",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             background : true,
21             fitContainer : true,
22             fitToFrame : true,
23             region : 'center',
24             title : "Price List",
25             layout : {
26                 xtype: 'BorderLayout',
27                 xns: Roo,
28                 items : [
29                     {
30                         xtype: 'GridPanel',
31                         xns: Roo,
32                         listeners : {
33                             activate : function() {
34                                 _this.panel = this;
35                                 if (_this.grid) {
36                                     _this.grid.footer.onClick('first');
37                                 }
38                             }
39                         },
40                         background : true,
41                         fitContainer : true,
42                         fitToframe : true,
43                         region : 'center',
44                         tableName : 'ipshead',
45                         title : "Price Lists",
46                         grid : {
47                             xtype: 'Grid',
48                             xns: Roo.grid,
49                             listeners : {
50                                 render : function() 
51                                 {
52                                     _this.grid = this; 
53                                     _this.dialog = Pman.Dialog.XtuplePriceList
54                                     if (_this.panel.active) {
55                                        this.footer.onClick('first');
56                                     }
57                                 },
58                                 rowdblclick : function (_self, rowIndex, e)
59                                 {
60                                     if (!_this.dialog) return;
61                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
62                                         _this.grid.footer.onClick('first');
63                                     }); 
64                                     
65                                 }
66                             },
67                             autoExpandColumn : 'ipshead_descrip',
68                             loadMask : true,
69                             sm : {
70                                 xtype: 'RowSelectionModel',
71                                 xns: Roo.grid,
72                                 listeners : {
73                                     selectionchange : function (_self)
74                                     {
75                                         _this.igrid.footer.onClick('first');
76                                     }
77                                 },
78                                 singleSelect : true
79                             },
80                             dataSource : {
81                                 xtype: 'Store',
82                                 xns: Roo.data,
83                                 remoteSort : true,
84                                 sortInfo : { field : 'ipshead_name', direction: 'ASC' },
85                                 proxy : {
86                                     xtype: 'HttpProxy',
87                                     xns: Roo.data,
88                                     method : 'GET',
89                                     url : baseURL + '/Roo/ipshead.php'
90                                 },
91                                 reader : {
92                                     xtype: 'JsonReader',
93                                     xns: Roo.data,
94                                     totalProperty : 'total',
95                                     root : 'data',
96                                     id : 'id',
97                                     fields : [
98                                         {
99                                             'name': 'ipshead_id',
100                                             'type': 'int'
101                                         },
102                                         {
103                                             'name': 'ipshead_name',
104                                             'type': 'string'
105                                         },
106                                         {
107                                             'name': 'ipshead_descrip',
108                                             'type': 'string'
109                                         },
110                                         {
111                                             'name': 'ipshead_effective',
112                                             'type': 'date',
113                                             'dateFormat': 'Y-m-d'
114                                         },
115                                         {
116                                             'name': 'ipshead_expires',
117                                             'type': 'date',
118                                             'dateFormat': 'Y-m-d'
119                                         },
120                                         {
121                                             'name': 'ipshead_curr_id',
122                                             'type': 'int'
123                                         },
124                                         {
125                                             'name': 'ipshead_updated',
126                                             'type': 'date',
127                                             'dateFormat': 'Y-m-d'
128                                         },
129                                         {
130                                             'name': 'ipshead_curr_id_curr_id',
131                                             'type': 'int'
132                                         },
133                                         {
134                                             'name': 'ipshead_curr_id_curr_base',
135                                             'type': 'int'
136                                         },
137                                         {
138                                             'name': 'ipshead_curr_id_curr_name',
139                                             'type': 'string'
140                                         },
141                                         {
142                                             'name': 'ipshead_curr_id_curr_symbol',
143                                             'type': 'string'
144                                         },
145                                         {
146                                             'name': 'ipshead_curr_id_curr_abbr',
147                                             'type': 'string'
148                                         }
149                                     ]
150                                 }
151                             },
152                             footer : {
153                                 xtype: 'PagingToolbar',
154                                 xns: Roo,
155                                 displayInfo : true,
156                                 displayMsg : "Displaying ipshead{0} - {1} of {2}",
157                                 emptyMsg : "No ipshead found",
158                                 pageSize : 25
159                             },
160                             toolbar : {
161                                 xtype: 'Toolbar',
162                                 xns: Roo,
163                                 items : [
164                                     {
165                                         xtype: 'Button',
166                                         xns: Roo.Toolbar,
167                                         listeners : {
168                                             click : function (_self, e)
169                                             {
170                                                new Pman.Download({
171                                                     method: 'GET',
172                                                     url : baseURL + '/Roo/Ipsiteminfo',
173                                                     params : {
174                                                         _pricegrid : 1
175                                                     }
176                                                });
177                                             }
178                                         },
179                                         text : "Download Price Matrix"
180                                     },
181                                     {
182                                         xtype: 'Button',
183                                         xns: Roo.Toolbar,
184                                         listeners : {
185                                             click : function (_self, e)
186                                             {
187                                                Pman.Dialog.Image.show(
188                                                    {
189                                                         _url : baseURL+'/Xtuple/Pricing'
190                                                     
191                                                    },
192                                                    function (data) {
193                                                         var msg = [];
194                                                         if (data.deleted) {
195                                                             msg.push("Deleted " + data.deleted + " Price(s)");
196                                                         }
197                                                         if (data.updated) {
198                                                             msg.push("Updated " + data.updated + " Price(s)");
199                                                         }            
200                                                         if (data.inserted) {
201                                                             msg.push("Added " + data.inserted + " Price(s)");
202                                                         }
203                                                         if (!msg.length) {
204                                                             msg.push("No data changed");
205                                                         }
206                                                         Roo.MessageBox.alert("Notice", msg.join("\n"));
207                                             
208                                                    }
209                                                );
210                                             }
211                                         },
212                                         text : "Upload Price Matrix"
213                                     },
214                                     {
215                                         xtype: 'Fill',
216                                         xns: Roo.Toolbar
217                                     },
218                                     {
219                                         xtype: 'Button',
220                                         xns: Roo.Toolbar,
221                                         text : "Add",
222                                         cls : 'x-btn-text-icon',
223                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
224                                         listeners : {
225                                             click : function()
226                                             {
227                                                 if (!_this.dialog) return;
228                                                 _this.dialog.show( { id : 0 } , function() {
229                                                     _this.grid.footer.onClick('first');
230                                                }); 
231                                             }
232                                         }
233                                     },
234                                     {
235                                         xtype: 'Button',
236                                         xns: Roo.Toolbar,
237                                         text : "Delete",
238                                         cls : 'x-btn-text-icon',
239                                         icon : rootURL + '/Pman/templates/images/trash.gif',
240                                         listeners : {
241                                             click : function()
242                                             {
243                                                  Pman.genericDelete(_this, 'ipshead'); 
244                                             }
245                                         }
246                                     }
247                                 ]
248                             },
249                             colModel : [
250                                 {
251                                     xtype: 'ColumnModel',
252                                     xns: Roo.grid,
253                                     dataIndex : 'ipshead_curr_id_curr_name',
254                                     header : 'Ipshead curr',
255                                     sortable : true,
256                                     width : 75,
257                                     renderer : function(v) { return String.format('{0}', v); }
258                                 },
259                                 {
260                                     xtype: 'ColumnModel',
261                                     xns: Roo.grid,
262                                     dataIndex : 'ipshead_name',
263                                     header : 'Ipshead name',
264                                     sortable : true,
265                                     width : 200,
266                                     renderer : function(v) { return String.format('{0}', v); }
267                                 },
268                                 {
269                                     xtype: 'ColumnModel',
270                                     xns: Roo.grid,
271                                     header : 'Ipshead descrip',
272                                     width : 200,
273                                     dataIndex : 'ipshead_descrip',
274                                     renderer : function(v) { return String.format('{0}', v); }
275                                 },
276                                 {
277                                     xtype: 'ColumnModel',
278                                     xns: Roo.grid,
279                                     header : 'Ipshead effective',
280                                     width : 75,
281                                     dataIndex : 'ipshead_effective',
282                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
283                                 },
284                                 {
285                                     xtype: 'ColumnModel',
286                                     xns: Roo.grid,
287                                     dataIndex : 'ipshead_expires',
288                                     header : 'Ipshead expires',
289                                     width : 75,
290                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
291                                 },
292                                 {
293                                     xtype: 'ColumnModel',
294                                     xns: Roo.grid,
295                                     header : 'Ipshead updated',
296                                     width : 75,
297                                     dataIndex : 'ipshead_updated',
298                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
299                                 }
300                             ]
301                         }
302                     },
303                     {
304                         xtype: 'GridPanel',
305                         xns: Roo,
306                         listeners : {
307                             activate : function() {
308                                 _this.ipanel = this;
309                                 if (_this.igrid) {
310                                    // _this.igrid.footer.onClick('first');
311                                 }
312                             }
313                         },
314                         background : true,
315                         fitContainer : true,
316                         fitToframe : true,
317                         region : 'east',
318                         tableName : 'item',
319                         title : "Products",
320                         grid : {
321                             xtype: 'EditorGrid',
322                             xns: Roo.grid,
323                             listeners : {
324                                 render : function() 
325                                 {
326                                     _this.igrid = this; 
327                                     //_this.dialog = Pman.Dialog.FILL_IN
328                                     if (_this.ipanel.active) {
329                                        //this.footer.onClick('first');
330                                     }
331                                 },
332                                 cellclick : function (_self, row, col, e)
333                                 {
334                                      var di = _this.grid.colModel.getDataIndex(col);
335                                      
336                                      var rec = _this.grid.ds.getAt(row);
337                                      
338                                      if(di == 'item_image_filename'){
339                                         if(!rec.data.item_image_id){
340                                             return;
341                                         }
342                                         var u = baseURL;
343                                         if(rec.data.item_image_from_hk){
344                                             u = u.split('/');
345                                             u.pop();
346                                             u = u.join('/') + '/hk.php';
347                                         }
348                                         Pman.download( {
349                                            url: u + '/Images/Download/' + rec.data.item_image_id  + '/' + rec.data.item_image_filename
350                                        });
351                                        return;
352                                      }
353                                      
354                                      if (di == 'item_active') {
355                                      
356                                         var nv = rec.data.item_active ? 0 : 1;
357                                         new Pman.Request({
358                                             mask : 'Saving',
359                                             url : baseURL + '/Roo/Item',
360                                             params : {
361                                                 item_id : rec.data.item_id,
362                                                 item_active : nv
363                                             },
364                                             success : function() {
365                                                 rec.set('item_active', nv);
366                                             }
367                                         });
368                                         return;
369                                         
370                                      
371                                      }
372                                      
373                                      if(di == 'itemsrc_active'){
374                                         if(!rec.data.itemsrc_active){
375                                             Roo.MessageBox.alert('Error','Please edit it on Xtuple tool');
376                                             return;
377                                         }
378                                         if(rec.data.itemsrc_active){
379                                             Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
380                                                 function (res) {
381                                                     if(res!='yes') {
382                                                         return;
383                                                     }
384                                                     rec.commit();
385                                             });
386                                         }
387                                     }
388                                      
389                                      _this.locgrid.footer.onClick('first');
390                                      
391                                      
392                                      
393                                      
394                                 },
395                                 afteredit : function (e)
396                                 {
397                                     
398                                     
399                                     Roo.log(e);
400                                     new Pman.Request({
401                                         url : baseURL +'/Roo/Charass',
402                                         params : {
403                                              charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
404                                              charass_value : e.value,
405                                              charass_target_type : 'I',
406                                              charass_default : 1,
407                                              charass_target_id : e.record.data.item_id
408                                          },
409                                          method : 'POST'
410                                      });
411                                     
412                                     
413                                     e.record.commit();
414                                     
415                                     
416                                     
417                                 },
418                                 rowdblclick : function (_self, rowIndex, e)
419                                 {
420                                     if (!_this.dialog) return;
421                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
422                                         _this.grid.footer.onClick('first');
423                                     }); 
424                                 }
425                             },
426                             autoExpandColumn : 'item_descrip1',
427                             clicksToEdit : 1,
428                             loadMask : true,
429                             dataSource : {
430                                 xtype: 'Store',
431                                 xns: Roo.data,
432                                 listeners : {
433                                     beforeload : function (_self, o)
434                                     {
435                                         o.params = o.params || {}
436                                         
437                                         var p = _this.grid.getSelectionModel().getSelected();
438                                         
439                                         if(!p || p.ipshead_id * 1 < 1){
440                                             this.removeAll();
441                                             return false;
442                                         }
443                                         
444                                         o.params.item_active = 1;
445                                     
446                                     },
447                                     update : function (_self, record, operation)
448                                     {
449                                         if(operation != 'commit'){
450                                             return;
451                                         }
452                                         
453                                         var nv  = record.data.itemsrc_active ? 0 : 1;
454                                         new Pman.Request({
455                                             mask : 'Saving',
456                                             url : baseURL + '/Roo/Itemsrc',
457                                             params : {
458                                                 _update_by_item : 1,
459                                                 item_id : record.data.item_id,
460                                                 itemsrc_active : nv
461                                             },
462                                             success : function(res) {
463                                                 record.set('itemsrc_active', nv);
464                                             }
465                                         });
466                                     }
467                                 },
468                                 remoteSort : true,
469                                 sortInfo : { field : 'item_number', direction: 'ASC' },
470                                 proxy : {
471                                     xtype: 'HttpProxy',
472                                     xns: Roo.data,
473                                     method : 'GET',
474                                     url : baseURL + '/Roo/item.php'
475                                 },
476                                 reader : {
477                                     xtype: 'JsonReader',
478                                     xns: Roo.data,
479                                     totalProperty : 'total',
480                                     root : 'data',
481                                     id : 'id',
482                                     fields : [
483                                         {
484                                             'name': 'item_id',
485                                             'type': 'int'
486                                         },
487                                         {
488                                             'name': 'item_number',
489                                             'type': 'string'
490                                         },
491                                         {
492                                             'name': 'item_descrip1',
493                                             'type': 'string'
494                                         },
495                                         {
496                                             'name': 'item_descrip2',
497                                             'type': 'string'
498                                         },
499                                         {
500                                             'name': 'item_classcode_id',
501                                             'type': 'int'
502                                         },
503                                         {
504                                             'name': 'item_picklist',
505                                             'type': 'int'
506                                         },
507                                         {
508                                             'name': 'item_comments',
509                                             'type': 'string'
510                                         },
511                                         {
512                                             'name': 'item_sold',
513                                             'type': 'int'
514                                         },
515                                         {
516                                             'name': 'item_fractional',
517                                             'type': 'int'
518                                         },
519                                         {
520                                             'name': 'item_active',
521                                             'type': 'int'
522                                         },
523                                         {
524                                             'name': 'item_type',
525                                             'type': 'string'
526                                         },
527                                         {
528                                             'name': 'item_prodweight',
529                                             'type': 'float'
530                                         },
531                                         {
532                                             'name': 'item_packweight',
533                                             'type': 'float'
534                                         },
535                                         {
536                                             'name': 'item_prodcat_id',
537                                             'type': 'int'
538                                         },
539                                         {
540                                             'name': 'item_exclusive',
541                                             'type': 'int'
542                                         },
543                                         {
544                                             'name': 'item_listprice',
545                                             'type': 'float'
546                                         },
547                                         {
548                                             'name': 'item_config',
549                                             'type': 'int'
550                                         },
551                                         {
552                                             'name': 'item_extdescrip',
553                                             'type': 'string'
554                                         },
555                                         {
556                                             'name': 'item_upccode',
557                                             'type': 'string'
558                                         },
559                                         {
560                                             'name': 'item_maxcost',
561                                             'type': 'float'
562                                         },
563                                         {
564                                             'name': 'item_inv_uom_id',
565                                             'type': 'int'
566                                         },
567                                         {
568                                             'name': 'item_price_uom_id',
569                                             'type': 'int'
570                                         },
571                                         {
572                                             'name': 'item_warrdays',
573                                             'type': 'int'
574                                         },
575                                         {
576                                             'name': 'item_freightclass_id',
577                                             'type': 'int'
578                                         },
579                                         {
580                                             'name': 'item_tax_recoverable',
581                                             'type': 'int'
582                                         },
583                                         {
584                                             'name': 'item_price_uom_id_uom_id',
585                                             'type': 'int'
586                                         },
587                                         {
588                                             'name': 'item_price_uom_id_uom_name',
589                                             'type': 'string'
590                                         },
591                                         {
592                                             'name': 'item_price_uom_id_uom_descrip',
593                                             'type': 'string'
594                                         },
595                                         {
596                                             'name': 'item_price_uom_id_uom_item_weight',
597                                             'type': 'int'
598                                         },
599                                         {
600                                             'name': 'item_inv_uom_id_uom_id',
601                                             'type': 'int'
602                                         },
603                                         {
604                                             'name': 'item_inv_uom_id_uom_name',
605                                             'type': 'string'
606                                         },
607                                         {
608                                             'name': 'item_inv_uom_id_uom_descrip',
609                                             'type': 'string'
610                                         },
611                                         {
612                                             'name': 'item_inv_uom_id_uom_item_weight',
613                                             'type': 'int'
614                                         },
615                                         {
616                                             'name': 'item_freightclass_id_freightclass_id',
617                                             'type': 'int'
618                                         },
619                                         {
620                                             'name': 'item_freightclass_id_freightclass_code',
621                                             'type': 'string'
622                                         },
623                                         {
624                                             'name': 'item_freightclass_id_freightclass_descrip',
625                                             'type': 'string'
626                                         },
627                                         {
628                                             'name': 'item_classcode_id_classcode_id',
629                                             'type': 'int'
630                                         },
631                                         {
632                                             'name': 'item_classcode_id_classcode_code',
633                                             'type': 'string'
634                                         },
635                                         {
636                                             'name': 'item_classcode_id_classcode_descrip',
637                                             'type': 'string'
638                                         },
639                                         {
640                                             'name': 'item_classcode_id_classcode_mfg',
641                                             'type': 'int'
642                                         },
643                                         {
644                                             'name': 'item_classcode_id_classcode_creator',
645                                             'type': 'string'
646                                         },
647                                         {
648                                             'name': 'item_classcode_id_classcode_created',
649                                             'type': 'date'
650                                         },
651                                         {
652                                             'name': 'item_classcode_id_classcode_modifier',
653                                             'type': 'string'
654                                         },
655                                         {
656                                             'name': 'item_classcode_id_classcode_modified',
657                                             'type': 'date'
658                                         },
659                                         {
660                                             'name': 'item_classcode_id_classcode_type',
661                                             'type': 'string'
662                                         }
663                                     ]
664                                 }
665                             },
666                             footer : {
667                                 xtype: 'PagingToolbar',
668                                 xns: Roo,
669                                 displayInfo : true,
670                                 displayMsg : "",
671                                 emptyMsg : "",
672                                 pageSize : 25
673                             },
674                             colModel : [
675                                 {
676                                     xtype: 'ColumnModel',
677                                     xns: Roo.grid,
678                                     dataIndex : 'item_number',
679                                     header : 'Number',
680                                     width : 100,
681                                     renderer : function(v) { return String.format('{0}', v); }
682                                 },
683                                 {
684                                     xtype: 'ColumnModel',
685                                     xns: Roo.grid,
686                                     align : 'right',
687                                     dataIndex : 'ipshead_price',
688                                     header : 'Price',
689                                     width : 75,
690                                     renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); }
691                                 }
692                             ]
693                         }
694                     }
695                 ],
696                 center : {
697                     xtype: 'LayoutRegion',
698                     xns: Roo
699                 },
700                 east : {
701                     xtype: 'LayoutRegion',
702                     xns: Roo,
703                     split : true,
704                     width : 500
705                 }
706             }
707         };
708     }
709 });