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

Calc.calc_04.result = Ext.extend(Calc.result, {
	title: 'Kalkualtor korzyści z konsolidacji',
	//html: 'nanana',
	initComponent: function() {
		Ext.apply(this, {
		  header: true,
			//baseCls: 'calc-input',
		  items: [{
		  	xtype: 'panel',
		  	baseCls: 'res-grid-wrapper-mtx',
		  	items: [{

              xtype: 'grid',
		      disableSelection : true,
		    //draggable: false,
		      enableColumnHide: false,
		      hideHeaders: true,
		      enableColumnMove: false,
		      enableColumnResize: false,
		      enableDragDrop: false,
		      enableHdMenu: false,
		      footer: true,
		      stripeRows: true,
			  trackMouseOver: false,
		      width: 690,
		      autoHeight: true,
              //height: 184,
              header: true,
	          title: 'Obecne kredyty',
			  baseCls: 'calc-result-grid',
			  ds: new Ext.data.SimpleStore({fields: [{
		            name: 'typ'
		          },{
		            name: 'kwotaPozostala'
		          },{
		            name: 'oprocentowanie'
		          },{
		            name: 'ilMiesiecy'
		          },{
		            name: 'rata'
		          }], data: Calc.results.grid1}),
			    columns: [
		          {header: 'Typ kredytu',  dataIndex:'typ', width: 130},
		          {header: 'Kwota kredytu w pln pozostała do spłaty',  dataIndex:'kwotaPozostala', width: 140},
		          {header: 'Obecne oprocentowanie spłacanego kredytu', dataIndex:'oprocentowanie', width: 140},
		          {header: 'Ilośc miesięcy do końca spłaty', dataIndex:'ilMiesiecy', width: 139},
		          {header: 'Wysokość płaconej raty',  dataIndex:'rata', width: 138}
		        ],
		     plugins:[{
			 	 init: function(grid){
			 	 	grid.on('render', function(){
			 	 		//nagłówek grida
						var scroller = Ext.query('.x-grid3-scroller',grid.body.dom)[0];
						Ext.DomHelper.insertBefore(scroller, ['<div><table class="result-grid-header"><thead>',
							'<tr class="result-grid-lower-header">',
							  '<td style="width: 110px;" class="boder-left">Typ kredytu</td>',
							  '<td style="width: 155px;" class="boder">Kwota kredytu w pln pozostała do spłaty</td>',
							  '<td style="width: 155px;" class="boder">Obecne oprocentowanie spłacanego kredytu</td>',
							  '<td style="width: 135px;" class="boder">Ilośc miesięcy do końca spłaty</td>',
							  '<td style="width: 125px;" class="boder-right">Wysokość płaconej raty</td>',
							'</tr></thead></table></div>'
							].join(' '));

					});

				 }
			 }]
	      }]
		  },{
		  	xtype: 'panel',
		  	baseCls: 'res-grid-foot-wrapper-mtx',
		  	items: [{
			  	xtype: 'panel',
			  	border: false,
			  	style: 'margin: 0 0 2px 8px',
			  	html: [
					'<table class="result-grid-footer-gray" style="width: 690px;">',
					'<tr><td style="width: 90px;">SUMA:</td>',
					'<td style="width: 139px;">'+Calc.results.inne.kredyty+'</td>',
	  				'<td style="width: 139px;"></td><td style="width: 99px;"></td>',
					'<td style="width: 125px;">'+Calc.results.inne.raty+'</td></tr></table>'
				].join(' ')
		  	}]
		  },{
		  	xtype: 'panel',
		  	baseCls: 'res-grid-foot2-wrapper-mtx',
		  	items: [{
				xtype: 'grid',
				disableSelection : true,
				//draggable: false,
				enableColumnHide: false,
				hideHeaders: true,
				enableColumnMove: false,
				enableColumnResize: false,
				enableDragDrop: false,
				enableHdMenu: false,
				footer: true,
				stripeRows: true,
				style: 'margin-left: 8px',
				trackMouseOver: false,
				width: 690,
				height: 119,
				header: true,
				title: 'Kredyt konsolidacyjny',
				  baseCls: 'calc-result-grid',
				  ds: new Ext.data.SimpleStore({fields: [{
						name: 'kwota'
					  },{
						name: 'oprocentowanie'
					  },{
						name: 'ilMiesiecy'
					  },{
						name: 'rata'
					  }], data: Calc.results.grid2}),
					columns: [
					  {header: 'Kwota kredytu skonsolidowanego',  dataIndex: 'kwota', width: 144},
					  {header: 'Oprocentowanie kredytu skonsolidowanego',  dataIndex: 'oprocentowanie', width: 174},
					  {header: 'Ilość miesięcy do końca spłaty kredytu skonsolidowanego', dataIndex: 'ilMiesiecy', width: 174},
					  {header: 'Wysokość raty po konsolidacji',  dataIndex: 'rata', width: 195}
					],
				 plugins:[{
					 init: function(grid){
						grid.on('render', function(){
							//nagłówek grida
							var scroller = Ext.query('.x-grid3-scroller',grid.body.dom)[0];
							Ext.DomHelper.insertBefore(scroller, ['<div><table class="result-grid-header"><thead>',
								'<tr class="result-grid-lower-header">',
									'<td style="width: 150px;" class="boder-left">Kwota kredytu <br />skonsolidowanego</td>',
									'<td style="width: 160px;" class="boder">Oprocentowanie kredytu skonsolidowanego</td>',
									'<td style="width: 180px;" class="boder">Ilość miesięcy do końca spłaty <br/>kredytu skonsolidowanego</td>',
									'<td style="width: 150px;" class="boder-right">Wysokość raty po konsolidacji</td>',
								'</tr></thead></table></div>'
								].join(' '));

							Ext.DomHelper.append(grid.footer.dom, [
								'<table class="result-grid-footer">',
								'<tr><td style="width: 280px; text-align: left;">TWOJA MIESIĘCZNA RATA ZMNIEJSZY SIĘ O:</td>',
								'<td style="width: 350px;">'+Calc.results.inne.roznica_rat+'</td>',
								'</tr></table>'
							].join(' '));

							//this.header.hide();
						});

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

});

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


