////////////////////////////////////////////////////////////////////////////////////////////////////////
// Calc.calc_12.result
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Klasa reprezentuje sekcję wyników obliczeniowych
////////////////////////////////////////////////////////////////////////////////////////////////////////
Ext.ns('Calc.calc_12.result');

Calc.calc_12.result = Ext.extend(Calc.result, {
	title: 'Podsumowanie',
	initComponent: function() {
		Ext.apply(this, {
		  items: [{
	        xtype: 'panel',
	        cls: 'resultPanel',
	        border: false,
	        html: ['<div class="looseData">',
	                '<div class="left">',
	                  'Miesięczna kwota wypłacanej renty<br />',
	                  'Wartość uzbieranej emerytury na koniec okresu',
	                '</div>',
	                '<div class="right">',
	                  Calc.results.inne.renta+'<span class="label"> zł</span><br />',
	                  Calc.results.inne.oszczednosci+'<span class="label"> zł</span>',
	                '</div>',
	               '</div>'
	          ].join(' ')
	      },{
        xtype: 'elem.flashContent'
      },{
        xtype: 'grid',
		    disableSelection : true,
		    id: 'grid1',
		    autoHeight: true,
		    //draggable: false,
		    enableColumnHide: false,
		    hideHeaders: true,
		    enableColumnMove: false,
		    enableColumnResize: false,
		    enableDragDrop: false,
		    enableHdMenu: false,
		    footer: false,
		    stripeRows: true,
		    style: 'margin-left: 8px',
			  trackMouseOver: false,
		    width: 690,
	      header: true,
	      //title: 'Tabela',
			  baseCls: 'calc-result-grid',
			  ds: new Ext.data.SimpleStore({fields: [{
			  		name: 'miesiac'
				  },{
		            name: 'emerytura'
		          },{
		            name: 'zyskBiezacy'
		          },{
		            name: 'rataWyplaty'
		          }], data: []}),
			    columns: [
			      {header: 'Kolejny miesiąc wypłaty renty',  dataIndex:'miesiac', width: 117},
		          {header: 'Całkowita wysokość emerytury',  dataIndex:'emerytura', width: 190},
		          {header: 'Jaki zysk wypracuje kapitał pozostały do wypłaty', dataIndex:'zyskBiezacy', width: 190},
		          {header: 'Wysokość wypłacanej raty', dataIndex:'rataWyplaty', width: 190}
		        ],
		     plugins:[{
			 	 init: function(grid){
			 	 	grid.store.on('load', function(){

            //doklej nagłówek grida
            if(Calc.expandedGrids['grid1']!=[])	{
							var scroller = Ext.query('.x-grid3-scroller',grid.body.dom)[0];
							this.gridHeader = Ext.DomHelper.insertBefore(scroller, ['<div><table class="result-grid-header"><thead>',
								'<tr class="result-grid-lower-header">',
								'<td style="width: 120px;" class="boder-left">Kolejny miesiąc<br />wypłaty renty</td>',
								'<td style="width: 190px;" class="boder">Całkowita wysokość emerytury</td>',
								'<td style="width: 190px;" class="boder">Jaki zysk wypracuje kapitał pozostały do wypłaty</td>',
								'<td style="width: 180px;" class="boder-right">Wysokość wypłacanej raty</td></tr>',
								'</thead></table></div>'
								].join(' '));
						}else{
							this.gridHeader.parentNode.removeChild(this.gridHeader);
						}

						var expander = grid.ownerCt.findByType('elem.expand')[0];
						if(Calc.gridState == 'expand') expander.changeText('Zwiń tabelę');
						else if(Calc.gridState == 'collapse') expander.changeText('Pokaż pełne zestawienie');
					});
				 }
			 }]
      },{
          xtype: 'elem.expand',
	      expandCmp: 'grid1'
      }]

		});
		Calc.calc_12.result.superclass.initComponent.apply(this, arguments);
		this.addEvents ( 'afterrender' );
	},
	afterRender: function(){
		Calc.calc_12.result.superclass.afterRender.call(this);
		this.fireEvent('afterrender', this);
	}

});

Ext.reg('calc_12.result', Calc.calc_12.result);

