Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleLanded.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.XtupleLanded = new Roo.XComponent({
6     part     :  ["Xtuple","Landed"],
7     order    : '100-Pman.Tab.XtupleLanded',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtuplePurchases',
10     name     : "Pman.Tab.XtupleLanded",
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             region : 'center',
22             title : "Landed Costs",
23             layout : {
24                 xtype: 'BorderLayout',
25                 xns: Roo,
26                 items : [
27                     {
28                         xtype: 'GridPanel',
29                         xns: Roo,
30                         listeners : {
31                             activate : function() {
32                                 _this.panel = this;
33                                 if (_this.grid) {
34                                     _this.grid.footer.onClick('first');
35                                 }
36                             }
37                         },
38                         background : true,
39                         fitContainer : true,
40                         fitToframe : true,
41                         region : 'center',
42                         tableName : 'vohead',
43                         title : "vohead",
44                         grid : {
45                             xtype: 'Grid',
46                             xns: Roo.grid,
47                             listeners : {
48                                 render : function() 
49                                 {
50                                     _this.grid = this; 
51                                     //_this.dialog = Pman.Dialog.FILL_IN
52                                     if (_this.panel.active) {
53                                        this.footer.onClick('first');
54                                     }
55                                 },
56                                 rowdblclick : function (_self, rowIndex, e)
57                                 {
58                                     if (!_this.dialog) return;
59                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
60                                         _this.grid.footer.onClick('first');
61                                     }); 
62                                 }
63                             },
64                             autoExpandColumn : 'vohead_reference',
65                             loadMask : true,
66                             dataSource : {
67                                 xtype: 'Store',
68                                 xns: Roo.data,
69                                 listeners : {
70                                     beforeload : function (_self, options)
71                                     {
72                                         options.params._landed = 1;
73                                         if (!_this.vsearch) {
74                                             return false;
75                                         }
76                                         options.params._landed_status = _this.status.getValue();    
77                                      
78                                     
79                                         options.params._search = _this.vsearch.getValue();
80                                     },
81                                     load : function (_self, records, options)
82                                     {
83                                     _this.rgrid.footer.onClick('refresh');
84                                     }
85                                 },
86                                 remoteSort : true,
87                                 sortInfo : { field : 'vohead_gldistdate', direction: 'DESC' },
88                                 proxy : {
89                                     xtype: 'HttpProxy',
90                                     xns: Roo.data,
91                                     method : 'GET',
92                                     url : baseURL + '/Roo/vohead.php'
93                                 },
94                                 reader : {
95                                     xtype: 'JsonReader',
96                                     xns: Roo.data,
97                                     totalProperty : 'total',
98                                     root : 'data',
99                                     id : 'id',
100                                     fields : [
101                                         {
102                                             'name': 'vohead_id',
103                                             'type': 'int'
104                                         },
105                                         {
106                                             'name': 'vohead_number',
107                                             'type': 'string'
108                                         },
109                                         {
110                                             'name': 'vohead_pohead_id',
111                                             'type': 'int'
112                                         },
113                                         {
114                                             'name': 'vohead_posted',
115                                             'type': 'int'
116                                         },
117                                         {
118                                             'name': 'vohead_duedate',
119                                             'type': 'date',
120                                             'dateFormat': 'Y-m-d'
121                                         },
122                                         {
123                                             'name': 'vohead_invcnumber',
124                                             'type': 'string'
125                                         },
126                                         {
127                                             'name': 'vohead_amount',
128                                             'type': 'float'
129                                         },
130                                         {
131                                             'name': 'vohead_docdate',
132                                             'type': 'date',
133                                             'dateFormat': 'Y-m-d'
134                                         },
135                                         {
136                                             'name': 'vohead_1099',
137                                             'type': 'int'
138                                         },
139                                         {
140                                             'name': 'vohead_distdate',
141                                             'type': 'date',
142                                             'dateFormat': 'Y-m-d'
143                                         },
144                                         {
145                                             'name': 'vohead_reference',
146                                             'type': 'string'
147                                         },
148                                         {
149                                             'name': 'vohead_terms_id',
150                                             'type': 'int'
151                                         },
152                                         {
153                                             'name': 'vohead_vend_id',
154                                             'type': 'int'
155                                         },
156                                         {
157                                             'name': 'vohead_curr_id',
158                                             'type': 'int'
159                                         },
160                                         {
161                                             'name': 'vohead_adjtaxtype_id',
162                                             'type': 'int'
163                                         },
164                                         {
165                                             'name': 'vohead_freighttaxtype_id',
166                                             'type': 'int'
167                                         },
168                                         {
169                                             'name': 'vohead_gldistdate',
170                                             'type': 'date',
171                                             'dateFormat': 'Y-m-d'
172                                         },
173                                         {
174                                             'name': 'vohead_misc',
175                                             'type': 'int'
176                                         },
177                                         {
178                                             'name': 'vohead_taxzone_id',
179                                             'type': 'int'
180                                         },
181                                         {
182                                             'name': 'vohead_taxtype_id',
183                                             'type': 'int'
184                                         },
185                                         {
186                                             'name': 'vohead_notes',
187                                             'type': 'string'
188                                         }
189                                     ]
190                                 }
191                             },
192                             sm : {
193                                 xtype: 'RowSelectionModel',
194                                 xns: Roo.grid,
195                                 listeners : {
196                                     afterselectionchange : function (_self)
197                                     {
198                                         _this.rsearch.setValue('');
199                                         _this.rgrid.footer.onClick('first');
200                                     }
201                                 },
202                                 singleSelect : true
203                             },
204                             footer : {
205                                 xtype: 'PagingToolbar',
206                                 xns: Roo,
207                                 pageSize : 25,
208                                 displayInfo : true,
209                                 displayMsg : "Displaying vohead{0} - {1} of {2}",
210                                 emptyMsg : "No vohead found"
211                             },
212                             toolbar : {
213                                 xtype: 'Toolbar',
214                                 xns: Roo,
215                                 items : [
216                                     {
217                                         xtype: 'ComboBox',
218                                         xns: Roo.form,
219                                         listeners : {
220                                             render : function (_self)
221                                             {
222                                               _this.status = _self;
223                                             },
224                                             select : function (combo, record, index)
225                                             {
226                                                 Roo.log('select');
227                                                 _this.grid.footer.onClick('first');
228                                             }
229                                         },
230                                         allowBlank : false,
231                                         displayField : 'fname',
232                                         editable : false,
233                                         fieldLabel : 'Status',
234                                         hiddenName : 'cm_status',
235                                         listWidth : 200,
236                                         mode : 'local',
237                                         name : 'cm_status_name',
238                                         triggerAction : 'all',
239                                         value : "NOTASSIGN",
240                                         valueField : 'ftype',
241                                         width : 150,
242                                         store : {
243                                             xtype: 'SimpleStore',
244                                             xns: Roo.data,
245                                             data : [ 
246                                                 [ 'NOTASSIGN', "Not Assigned"],
247                                                 [ 'ASSIGNED' , "Assigned"]
248                                             ],
249                                             fields : [  'ftype', 'fname']
250                                         }
251                                     },
252                                     {
253                                         xtype: 'TextField',
254                                         xns: Roo.form,
255                                         listeners : {
256                                             render : function (_self)
257                                             {
258                                                 _this.vsearch = _self;
259                                             },
260                                             specialkey : function (_self, e)
261                                             {
262                                             _this.grid.footer.onClick('first');
263                                             }
264                                         }
265                                     },
266                                     {
267                                         xtype: 'Button',
268                                         xns: Roo.Toolbar,
269                                         listeners : {
270                                             click : function (_self, e)
271                                             {
272                                             _this.grid.footer.onClick('first');
273                                             }
274                                         },
275                                         cls : 'x-btn-icon',
276                                         icon : rootURL + '/Pman/templates/images/search.gif'
277                                     }
278                                 ]
279                             },
280                             colModel : [
281                                 {
282                                     xtype: 'ColumnModel',
283                                     xns: Roo.grid,
284                                     dataIndex : 'vohead_gldistdate',
285                                     header : 'Date',
286                                     width : 75,
287                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
288                                 },
289                                 {
290                                     xtype: 'ColumnModel',
291                                     xns: Roo.grid,
292                                     dataIndex : 'vohead_number',
293                                     header : 'no#',
294                                     width : 100,
295                                     renderer : function(v,x,r) { 
296                                         return String.format('{0} / {1}', v,r.data.vohead_invcnumber); 
297                                     }
298                                 },
299                                 {
300                                     xtype: 'ColumnModel',
301                                     xns: Roo.grid,
302                                     dataIndex : 'vohead_reference',
303                                     header : 'Ref#',
304                                     width : 120,
305                                     renderer : function(v) { return String.format('{0}', v); }
306                                 },
307                                 {
308                                     xtype: 'ColumnModel',
309                                     xns: Roo.grid,
310                                     dataIndex : 'vohead_vend_id_vend_name',
311                                     header : 'Vohead vend',
312                                     width : 150,
313                                     renderer : function(v) { return String.format('{0}', v); }
314                                 },
315                                 {
316                                     xtype: 'ColumnModel',
317                                     xns: Roo.grid,
318                                     align : 'right',
319                                     dataIndex : 'vohead_total',
320                                     header : 'Amount',
321                                     width : 100,
322                                     renderer : function(v,x,r) { 
323                                       
324                                         
325                                         return String.format('{0} {1}', r.data.vohead_curr_id_curr_symbol,v); 
326                                     }
327                                 },
328                                 {
329                                     xtype: 'ColumnModel',
330                                     xns: Roo.grid,
331                                     align : 'right',
332                                     dataIndex : 'assigned',
333                                     header : 'Assigned',
334                                     width : 100,
335                                     renderer : function(v,x,r) { 
336                                         return v ? String.format('${0}',  v) : ''; 
337                                     }
338                                 }
339                             ]
340                         }
341                     },
342                     {
343                         xtype: 'GridPanel',
344                         xns: Roo,
345                         listeners : {
346                             activate : function() {
347                                 _this.rpanel = this;
348                                 //if (_this.rgrid) {
349                                   //  _this.rgrid.footer.onClick('first');
350                                 //}
351                             }
352                         },
353                         background : true,
354                         fitContainer : true,
355                         fitToframe : true,
356                         region : 'east',
357                         tableName : 'recvgrp',
358                         title : "recvgrp",
359                         grid : {
360                             xtype: 'Grid',
361                             xns: Roo.grid,
362                             listeners : {
363                                 render : function() 
364                                 {
365                                     _this.rgrid = this; 
366                                     //_this.dialog = Pman.Dialog.FILL_IN
367                                     //if (_this.panel.active) {
368                                    //    this.footer.onClick('first');
369                                     //}
370                                 },
371                                 rowdblclick : function (_self, rowIndex, e)
372                                 {
373                                     if (!_this.dialog) return;
374                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
375                                         _this.grid.footer.onClick('first');
376                                     }); 
377                                 }
378                             },
379                             autoExpandColumn : 'recvgrp_number',
380                             loadMask : true,
381                             dataSource : {
382                                 xtype: 'Store',
383                                 xns: Roo.data,
384                                 listeners : {
385                                     beforeload : function (_self, o)
386                                     {
387                                         var sel = _this.grid.selModel.getSelected();
388                                         if (!sel) {
389                                             this.removeAll();
390                                             return false;
391                                         }
392                                         o.params =  o.params || {};
393                                         o.params._landed_vohead = sel.data.vohead_id;
394                                         o.params._search = _this.rsearch.getValue();
395                                         
396                                         
397                                     }
398                                 },
399                                 remoteSort : true,
400                                 sortInfo : { field : 'recvgrp_date', direction: 'ASC' },
401                                 proxy : {
402                                     xtype: 'HttpProxy',
403                                     xns: Roo.data,
404                                     method : 'GET',
405                                     url : baseURL + '/Roo/recvgrp.php'
406                                 },
407                                 reader : {
408                                     xtype: 'JsonReader',
409                                     xns: Roo.data,
410                                     totalProperty : 'total',
411                                     root : 'data',
412                                     id : 'id',
413                                     fields : [
414                                         {
415                                             'name': 'recvgrp_id',
416                                             'type': 'int'
417                                         },
418                                         {
419                                             'name': 'recvgrp_number',
420                                             'type': 'string'
421                                         }
422                                     ]
423                                 }
424                             },
425                             footer : {
426                                 xtype: 'PagingToolbar',
427                                 xns: Roo,
428                                 pageSize : 25,
429                                 displayInfo : true,
430                                 displayMsg : "Displaying recvgrp{0} - {1} of {2}",
431                                 emptyMsg : "No recvgrp found"
432                             },
433                             toolbar : {
434                                 xtype: 'Toolbar',
435                                 xns: Roo,
436                                 items : [
437                                     {
438                                         xtype: 'TextField',
439                                         xns: Roo.form,
440                                         listeners : {
441                                             render : function (_self)
442                                             {
443                                                 _this.rsearch = _self;
444                                             },
445                                             specialkey : function (_self, e)
446                                             {
447                                             _this.rgrid.footer.onClick('first');
448                                             }
449                                         }
450                                     },
451                                     {
452                                         xtype: 'Button',
453                                         xns: Roo.Toolbar,
454                                         listeners : {
455                                             click : function (_self, e)
456                                             {
457                                             _this.rgrid.footer.onClick('first');
458                                             }
459                                         },
460                                         cls : 'x-btn-icon',
461                                         icon : rootURL + '/Pman/templates/images/search.gif'
462                                     },
463                                     {
464                                         xtype: 'Fill',
465                                         xns: Roo.Toolbar
466                                     },
467                                     {
468                                         xtype: 'Button',
469                                         xns: Roo.Toolbar,
470                                         listeners : {
471                                             click : function (_self, e)
472                                             {
473                                                 var recv = _this.rgrid.selModel.getSelected();
474                                                 var vo = _this.grid.selModel.getSelected();
475                                                 if (!vo || !recv) {
476                                                     return;
477                                                 }
478                                                 new Pman.Request({
479                                                     mask : 'saving',
480                                                     method  : 'POST',
481                                                     url : baseURL + '/Roo/Recvgrpland',
482                                                     params : {
483                                                         recvgrpland_vohead_id : vo.data.vohead_id,
484                                                         recvgrpland_recvgrp_id : recv.data.recvgrp_id, 
485                                                         recvgrpland_cost : vo.data.vohead_total,
486                                                         recvgrpland_curr_id : vo.data.vohead_curr_id
487                                                     },
488                                                     success : function () {
489                                                         _this.grid.footer.onClick('refresh');
490                                                     }
491                                                 });
492                                                         
493                                                 
494                                                 
495                                             }
496                                         },
497                                         text : "Assign All"
498                                     },
499                                     {
500                                         xtype: 'Button',
501                                         xns: Roo.Toolbar,
502                                         listeners : {
503                                             click : function (_self, e)
504                                             {
505                                                 var recv = _this.rgrid.selModel.getSelected();
506                                                 var vo = _this.grid.selModel.getSelected();
507                                                 if (!vo || !recv) {
508                                                     return;
509                                                 }
510                                                 
511                                                 var avail = ((1*vo.data.vohead_total) - (1*vo.data.assigned)).toFixed(2);
512                                                 
513                                                 Roo.MessageBox.prompt("How much to assign?",
514                                                     "The total available to assign is " + vo.data.vohead_curr_id_curr_symbol +
515                                                          ' ' + Roo.util.Format.number(avail,2),
516                                                     function (b, n) {
517                                                         if (b != 'ok') {
518                                                             return;
519                                                         }
520                                                         n = n*1;
521                                                         if (isNaN(n)) {
522                                                             Roo.MessageBox.alert("Error", "did not get a number");
523                                                             return;
524                                                         }
525                                             
526                                                         //vo.data.vohead_total
527                                                         if (n*1 > avail) {
528                                                             Roo.MessageBox.alert("Error", "you assigned to much, try again");
529                                                             return;
530                                                         }
531                                                         
532                                                         
533                                                         new Pman.Request({
534                                                             mask : 'saving',
535                                                             method  : 'POST',
536                                                             url : baseURL + '/Roo/Recvgrpland',
537                                                             params : {
538                                                                 recvgrpland_vohead_id : vo.data.vohead_id,
539                                                                 recvgrpland_recvgrp_id : recv.data.recvgrp_id, 
540                                                                 recvgrpland_cost : n,
541                                                                 recvgrpland_curr_id : vo.data.vohead_curr_id
542                                                             },
543                                                             success : function () {
544                                                                 _this.grid.footer.onClick('refresh');
545                                                             }
546                                                         });
547                                                     }
548                                                 );
549                                                 
550                                                 
551                                             }
552                                         },
553                                         text : "Assign Some"
554                                     },
555                                     {
556                                         xtype: 'Button',
557                                         xns: Roo.Toolbar,
558                                         listeners : {
559                                             click : function (_self, e)
560                                             {
561                                                 var recv = _this.rgrid.selModel.getSelected();
562                                                 var vo = _this.grid.selModel.getSelected();
563                                                 if (!vo || !recv) {
564                                                     return;
565                                                 }
566                                                var av = recv.data.assigned_landed * 1;
567                                                 if (!av) {
568                                                     return;
569                                                 }
570                                                 
571                                                 new Pman.Request({
572                                                     mask : 'saving',
573                                                     method  : 'POST',
574                                                     url : baseURL + '/Roo/Recvgrpland',
575                                                     params : {
576                                                         _void : 1,
577                                                         recvgrpland_vohead_id : vo.data.vohead_id,
578                                                         recvgrpland_recvgrp_id : recv.data.recvgrp_id
579                                                     },
580                                                     success : function () {
581                                                         _this.grid.footer.onClick('refresh');
582                                                     }
583                                                 });
584                                                         
585                                                 
586                                                 
587                                             }
588                                         },
589                                         text : "Remove Assign"
590                                     }
591                                 ]
592                             },
593                             colModel : [
594                                 {
595                                     xtype: 'ColumnModel',
596                                     xns: Roo.grid,
597                                     dataIndex : 'recvgrp_date',
598                                     header : 'Date',
599                                     width : 50,
600                                     renderer : function(v) { return String.format('{0}', v.format('d/M/Y')); }
601                                 },
602                                 {
603                                     xtype: 'ColumnModel',
604                                     xns: Roo.grid,
605                                     dataIndex : 'recvgrp_pohead_id_pohead_number',
606                                     header : 'Po#',
607                                     width : 75,
608                                     renderer : function(v) { return String.format('{0}', v); }
609                                 },
610                                 {
611                                     xtype: 'ColumnModel',
612                                     xns: Roo.grid,
613                                     dataIndex : 'recvgrp_number',
614                                     header : 'ref#',
615                                     width : 100,
616                                     renderer : function(v) { return String.format('{0}', v); }
617                                 },
618                                 {
619                                     xtype: 'ColumnModel',
620                                     xns: Roo.grid,
621                                     dataIndex : 'vend_name',
622                                     header : 'Vendor',
623                                     width : 75,
624                                     renderer : function(v) { return String.format('{0}', v); }
625                                 },
626                                 {
627                                     xtype: 'ColumnModel',
628                                     xns: Roo.grid,
629                                     dataIndex : 'recvgrp_location_id_location_descrip',
630                                     header : 'loc',
631                                     width : 75,
632                                     renderer : function(v) { return String.format('{0}', v); }
633                                 },
634                                 {
635                                     xtype: 'ColumnModel',
636                                     xns: Roo.grid,
637                                     align : 'right',
638                                     dataIndex : 'recv_qty',
639                                     header : 'Qty',
640                                     width : 75,
641                                     renderer : function(v) { 
642                                         if (v*1 <= 0.0) {
643                                             return '';
644                                         }
645                                         return Roo.util.Format.number(v, 2); 
646                                     }
647                                 },
648                                 {
649                                     xtype: 'ColumnModel',
650                                     xns: Roo.grid,
651                                     align : 'right',
652                                     dataIndex : 'recvgrp_landed_cost',
653                                     header : 'Old landed',
654                                     hidden : true,
655                                     width : 75,
656                                     renderer : function(v) { 
657                                         if (v*1 <= 0.0) {
658                                             return '';
659                                         }
660                                         return Roo.util.Format.number(v, 2); 
661                                     }
662                                 },
663                                 {
664                                     xtype: 'ColumnModel',
665                                     xns: Roo.grid,
666                                     align : 'right',
667                                     dataIndex : 'assigned_landed',
668                                     header : 'Assigned Value',
669                                     width : 75,
670                                     renderer : function(v,x,r) { 
671                                         if (v*1 <= 0.0) {
672                                         
673                                             if (r.data.total_landed_cost*1 > 0) {
674                                                 return '<span style="color:#ccc">' + 
675                                                  String.format('{0}', r.data.base_curr_symbol) + 
676                                                  Roo.util.Format.number(r.data.total_landed_cost, 2) + '</span>';
677                                             }
678                                         
679                                             return '';
680                                         }
681                                         return  String.format('{0}', r.data.base_curr_symbol) +  Roo.util.Format.number(v, 2); 
682                                     }
683                                 }
684                             ]
685                         }
686                     }
687                 ],
688                 center : {
689                     xtype: 'LayoutRegion',
690                     xns: Roo
691                 },
692                 east : {
693                     xtype: 'LayoutRegion',
694                     xns: Roo,
695                     split : true,
696                     width : 500
697                 }
698             }
699         };
700     }
701 });