<div id="tabkas_in_bc_out_c" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div id="tabkas_in_bc_out" style="height:95%;margin:0px; padding:0px;">
		<ul> 
			<li><a id="tab_kas_in_bc_out" href="#div_tab_kas_in_bc_out">DATA AR</a></li>
			<li><a id="tab_kas_in_bc_out_trx" href="#div_kas_in_bc_out_data_trx">INVOICE AR</a></li>
		</ul>
		<div id="div_tab_kas_in_bc_out" >
			<div class="pane-header ui-state-active" id="div_tab_kas_in_bc_out_bar" >  
				
				PERIODE: <select id="kas_in_bc_out_wh_month_periode" style="height:20px" >
						<option value="">-</option>
						<option value="01">JAN</option>
						<option value="02">FEB</option>
						<option value="03">MAR</option>
						<option value="04">APR</option>
						<option value="05">MEI</option>
						<option value="06">JUN</option>
						<option value="07">JUL</option>
						<option value="08">AGS</option>
						<option value="09">SEP</option>
						<option value="10">OKT</option>
						<option value="11">NOV</option>
						<option value="12">DES</option>
					</select>
					<select id="kas_in_bc_out_wh_year_periode" style="height:20px" >
						<?php   
							for($index=date('Y');$index > date('Y')-10;$index-=1) {	
						?>
							<option value="<?php echo $index;  ?>"><?php echo $index;  ?></option>
						
						<?php
							}
						?>
					</select>
					<button type="button" id="search_kas_in_bc_out_wh_periode">Search</button> 
					<button type="button" id="xl_kas_in_bc_out_wh_periode">Excel</button> 
				
				
			</div>
			<table id="tbl_kas_in_bc_out"></table> <div id="ptbl_kas_in_bc_out"></div>
		</div>
		<div id="div_kas_in_bc_out_data_trx" >
			<div class="pane-header ui-state-active" id="div_kas_in_bc_out_data_trx_bar" >    
				PERIODE: <select id="bulan_period_kas_in_bc_out_trx" style="height:15px" >
							<option value="">-</option>
							<option value="01">JAN</option>
							<option value="02">FEB</option>
							<option value="03">MAR</option>
							<option value="04">APR</option>
							<option value="05">MEI</option>
							<option value="06">JUN</option>
							<option value="07">JUL</option>
							<option value="08">AGS</option>
							<option value="09">SEP</option>
							<option value="10">OKT</option>
							<option value="11">NOV</option>
							<option value="12">DES</option>
						</select>
				<select id="tahun_period_kas_in_bc_out_trx" style="height:15px" >
					<?php   
						for($index=date('Y');$index > date('Y')-10;$index-=1) {	
					?>
						<option value="<?php echo $index;  ?>"><?php echo $index;  ?></option>
					
					<?php
						}
					?>
				</select>
				<button id="btn_kas_in_bc_out_trx_search" >Search</button> 
			</div>
			<table id="tbl_kas_in_bc_out_trx"></table> <div id="ptbl_kas_in_bc_out_trx"></div>
			
		</div>
	</div>
</div>
<script type="text/javascript">
    
    $(document).ready(function(){ 
		var tabkas_in_bc_out_active_tab=0;
		setTimeout(function(){
			setGridHight($("#tbl_kas_in_bc_out"),$("#tabkas_in_bc_out"),$("#div_tab_kas_in_bc_out_bar"),$("#tabkas_in_bc_out .ui-tabs-nav").height()+30); 
		},20); 
		$("#tabkas_in_bc_out" ).tabs({                                                                  
            select:function(event,ui){    
			
				tabkas_in_bc_out_active_tab=ui.index;   
				
		 		if (tabkas_in_bc_out_active_tab==0){
					setTimeout(function(){
						setGridHight($("#tbl_kas_in_bc_out"),$("#tabkas_in_bc_out"),$("#div_tab_kas_in_bc_out_bar"),$("#tabkas_in_bc_out .ui-tabs-nav").height()+30); 
					},20); 
				}else if (tabkas_in_bc_out_active_tab==1){
					setTimeout(function(){
						setGridHight($("#tbl_kas_in_bc_out_trx"),$("#tabkas_in_bc_out"),$("#div_kas_in_bc_out_data_trx_bar"),$("#tabkas_in_bc_out .ui-tabs-nav").height()+30); 
					},20); 
				}
			}                                                                          
         });   		
			 
			 
		$(window).bind('resize', function() {  
				if (tabkas_in_bc_out_active_tab==0){
					setTimeout(function(){
						setGridHight($("#tbl_kas_in_bc_out"),$("#tabkas_in_bc_out"),$("#div_tab_kas_in_bc_out_bar"),$("#tabkas_in_bc_out .ui-tabs-nav").height()+30); 
					},100); 
				}else if (tabkas_in_bc_out_active_tab==1){
					setTimeout(function(){
						setGridHight($("#tbl_kas_in_bc_out_trx"),$("#tabkas_in_bc_out"),$("#div_kas_in_bc_out_data_trx_bar"),$("#tabkas_in_bc_out .ui-tabs-nav").height()+30); 
					},100); 
				}
		});
		
		
		jQuery("#tbl_kas_in_bc_out").jqGrid({
			url:'<?php echo base_url().'accounting_report/ct_accounting_report/data_acc_ar'; ?>',
			mtype : "post",
			postData:{'q':'1','awal':'1'},
			datatype: "json",
			colNames:
			[
			'id_apar',
			'DataType',
			'INVNO',
			'INVDATE',
			'GL_ACC',
			'PERIOD',
			'SAP_SOURCE',
			'JOURNAL_ID',
			'JOURNAL_DATE',
			'JOURNAL_DESC',
			'POSTING_KEY',
			'CURR',
			'DEBIT',
			'CREDIT',
			'BALANCE',
			'DEBIT_USD',
			'CREDIT_USD',
			'BALANCE_USD',
			'IMPORT_DATE',
			'EXTRACT_DATE'
			
			],
			colModel:[
				{name:'id_apar',index:'id_apar', width:60, hidden:true},
				{name:'DataType',index:'DataType', width:60},
				{name:'INVNO',index:'INVNO', width:160},
				{name:'INVDATE',index:'INVDATE', width:100, hidden:false},
				{name:'GL_ACC',index:'GL_ACC', width:100,hidden:false},
				{name:'PERIOD',index:'PERIOD', width:120,hidden:false},
				{name:'SAP_SOURCE',index:'SAP_SOURCE', width:100,hidden:false},
				{name:'JOURNAL_ID',index:'JOURNAL_ID', width:150,hidden:false},
				{name:'JOURNAL_DATE',index:'JOURNAL_DATE', width:150,hidden:false},
				{name:'JOURNAL_DESC',index:'JOURNAL_DESC', width:210,hidden:false},
				{name:'POSTING_KEY',index:'POSTING_KEY', width:84,hidden:false},
				{name:'CURR',index:'CURR', width:84,hidden:false},
				{name:'DEBIT',index:'DEBIT', width:84,hidden:false, align:'right', formatter:'number', summaryType:'sum'},
				{name:'CREDIT',index:'CREDIT', width:84,hidden:false, align:'right', formatter:'number', summaryType:'sum'},
				{name:'BALANCE',index:'BALANCE', width:84,hidden:false, align:'right', formatter:'number', summaryType:'sum'},
				{name:'DEBIT_USD',index:'DEBIT_USD', width:84,hidden:false, align:'right', formatter:'number', summaryType:'sum'},
				{name:'CREDIT_USD',index:'CREDIT_USD', width:84,hidden:false, align:'right', formatter:'number', summaryType:'sum'},
				{name:'BALANCE_USD',index:'BALANCE_USD', width:84,hidden:false, align:'right', formatter:'number', summaryType:'sum'},
				{name:'IMPORT_DATE',index:'IMPORT_DATE', width:120,hidden:false},
				{name:'EXTRACT_DATE',index:'EXTRACT_DATE', width:120,hidden:false}
				
				],
			rowNum:20,
			rowList:[20,50,100],
			pager: '#ptbl_kas_in_bc_out',
			sortname: 'JOURNAL_DATE',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:300,
			jsonReader: { repeatitems : false },
			caption:"DATA KAS OUT",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_kas_in_bc_out").getDataIDs(); 
				var rowData = $("#tbl_kas_in_bc_out").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_kas_in_bc_out'));
				   
					switch (rowData[i].status_data) {
						
						case 'PROSESEXIM':
						   trElement.css({"color":"green"});
						break;
						case 'PROCESSEDBC':
						   trElement.css({"color":"blue"});
						break;
						
						
					}
				}
			},
			footerrow: true, // set a footer row
			userDataOnFooter: true,
		}); 
			
                        
		jQuery("#tbl_kas_in_bc_out").jqGrid('navGrid','#ptbl_kas_in_bc_out',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_kas_in_bc_out").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		
		jQuery("#tbl_kas_in_bc_out_trx").jqGrid({
			url:'<?php echo base_url().'accounting_report/ct_accounting_report/data_v_acc_ar_inv'; ?>',
			mtype : "post",
			postData:{'q':'1','awal':'1'},
			datatype: "json",
			colNames:
			[
			
			'INVNO',
			'INVDATE',
			'GL_ACC',
			'PERIOD',
			'DEBIT',
			'CREDIT',
			'BALANCE',
			'DEBIT_USD',
			'CREDIT_USD',
			'BALANCE_USD',
			
			'CAR',
			'NODAFT',
			'TGDAFT',
			'typedok',
			'sts'
			],
			colModel:[
				
				{name:'INVNO',index:'INVNO', width:160},
				{name:'INVDATE',index:'INVDATE', width:100, hidden:false},
				{name:'GL_ACC',index:'GL_ACC', width:100,hidden:false},
				{name:'PERIOD',index:'PERIOD', width:120,hidden:false},
				{name:'DEBIT',index:'DEBIT', width:184,hidden:false, align:'right', formatter:'number'},
				{name:'CREDIT',index:'CREDIT', width:184,hidden:false, align:'right', formatter:'number'},
				{name:'BALANCE',index:'BALANCE', width:184,hidden:false, align:'right', formatter:'number'},
				{name:'DEBIT_USD',index:'DEBIT_USD', width:184,hidden:false, align:'right', formatter:'number'},
				{name:'CREDIT_USD',index:'CREDIT_USD', width:184,hidden:false, align:'right', formatter:'number'},
				{name:'BALANCE_USD',index:'BALANCE_USD', width:184,hidden:false, align:'right', formatter:'number'},
				
				{name:'CAR',index:'CAR', width:200,hidden:false},
				{name:'NODAFT',index:'NODAFT', width:120,hidden:false},
				{name:'TGDAFT',index:'TGDAFT', width:120,hidden:false},
				{name:'typedok',index:'typedok', width:120,hidden:false},
				{name:'sts',index:'sts', width:120,hidden:true},
				
				
				],
			rowNum:20,
			rowList:[20,50,100],
			pager: '#ptbl_kas_in_bc_out_trx',
			sortname: 'INVDATE',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:300,
			jsonReader: { repeatitems : false },
			caption:"DATA KAS OUT",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_kas_in_bc_out_trx").getDataIDs(); 
				var rowData = $("#tbl_kas_in_bc_out_trx").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_kas_in_bc_out_trx'));
				   
					switch (rowData[i].sts) {
						
						case 'NON BC':
						   trElement.css({"color":"blue"});
						break;
						case 'BC':
						   trElement.css({"color":"black"});
						break;
						
						
					}
				}
			},
		}); 
			
                        
		jQuery("#tbl_kas_in_bc_out_trx").jqGrid('navGrid','#ptbl_kas_in_bc_out_trx',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_kas_in_bc_out_trx").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		
		
		
		
		$("#search_kas_in_bc_out_wh_periode").button().click(function(){
			var form_data = {
				periode:$("#kas_in_bc_out_wh_year_periode").val()+$("#kas_in_bc_out_wh_month_periode").val()
				, 'awal':'2'
			};
			jQuery("#tbl_kas_in_bc_out").jqGrid('setGridParam', { postData:form_data });
			$('#tbl_kas_in_bc_out').trigger('reloadGrid');
			
			
		});
		
		
		$("#btn_kas_in_bc_out_trx_search").button().click(function(){
			var form_data = {
				periode:$("#tahun_period_kas_in_bc_out_trx").val()+$("#bulan_period_kas_in_bc_out_trx").val()
				, 'awal':'2'
			};
			jQuery("#tbl_kas_in_bc_out_trx").jqGrid('setGridParam', { postData:form_data });
			$('#tbl_kas_in_bc_out_trx').trigger('reloadGrid');			
			
		});
		
		$("#xl_kas_in_bc_out_wh_periode").button().click(function(){
			
			document.location.href = '<?php echo base_url().'accounting_report/ct_accounting_report/kas_in_bc_out_excel'; ?>'+'?periode='+$("#kas_in_bc_out_wh_year_periode").val()+$("#kas_in_bc_out_wh_month_periode").val()
			
		});
		
	});
		  	
</script>

