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

Calc.calc_03.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">',
                  'Kredyt będziesz spłacał ',
                '</div>',
                '<div class="right">',
                  Calc.results.inne.czas+' ',
                '</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: 'numerRaty'
				  },{
		            name: 'kapitalowaObecny'
		          },{
		            name: 'odsetkowaObecny'
		          },{
		            name: 'calkowitaObecny'
		          }], data: []}),
			    columns: [
			      {header: 'Numer raty',  dataIndex:'numerRaty', width: 120},
		          {header: 'Część kapitałowa raty',  dataIndex:'kapitalowaObecny', width: 190},
		          {header: 'Część odsetkowa raty', dataIndex:'odsetkowaObecny', width: 190},
		          {header: 'Rata całkowita', dataIndex:'calkowitaObecny', width: 190}
		        ],
		     plugins:[{
			 	 init: function(grid){
			 	 	grid.store.on('load', function(){
			 	 		if(Calc.expandedGrids['grid1']!=[])	{
							//nagłówek grida
							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">Kolejna rata</td>',
								'<td style="width: 190px;" class="boder">Część kapitałowa raty</td>',
								'<td style="width: 190px;" class="boder">Część odsetkowa raty</td>',
								'<td style="width: 180px;  class="boder-right">Rata całkowita</td></tr>',
								'</thead></table></div>'
								].join(' '));
						}else{
							this.gridHeader.parentNode.removeChild(this.gridHeader);
						}
					});
				 }
			 }]
	},{
		xtype: 'elem.expand',
	    expandCmp: 'grid1'
	}]
	});
		Calc.calc_03.result.superclass.initComponent.apply(this, arguments);
		this.addEvents ( 'afterrender' );
	},
	afterRender: function(){
		Calc.calc_03.result.superclass.afterRender.call(this);
		this.fireEvent('afterrender', this);
	}

});

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

