<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>    
  <style>
 	
 </style>
 
</head>
 <body> 
	<div>
	   <div id="laporanmutasiscr"style="height:50px; width: 790px;">
	    <p>G. LAPORAN PERTANGGUNGJAWABAN SISA DAN SCRAP<span style="padding-left:20px;"></p> 
	   	<p>KAWASAN BERIKAT<span style="padding-left:10px;"><input type="text" id="namaperush" size=40 value="PT. EDS MANUFACTURING INDONESIA"/> PERIODE : 
		<input type="text" id="tglawalscr" size=15 value='<?php echo $date_stock; ?>' readonly="readonly"/> S.D <input type="text" id="tglakhirscr" size=15 value='<?php echo date('d/m/Y'); ?>' readonly="readonly"/>  (2) 
		<span style="padding-left:10px;"><button id="printlaporanscr">Search</button><button id="printlaporanscrpdf">PDF</button><button id="printlaporanscrxls">EXCEL</button></span></p>
	    <div id="add_progress" align="center" style="display:none"><?php echo $loading_indicator; ?></div>
	   </div>
		<div id="divlapposisibrgdlmscr">
			<table id="grdlaporanmutasiscr"></table> <div id="pgrdlaporanmutasiscr"> </div>  
		</div>
		<div id="divprintlapposisiscrpdf">
		
			<iframe id="framelapposisibrgscr" src="" frameborder="0" width="100%" height="370">
			</iframe>
		</div>	
	</div>
	<?php
			$tgawal = explode("/", $date_stock);	
		    $tglawal =  $tgawal[1].'/'.$tgawal[0].'/'.$tgawal[2];
		
			$q = $this->db->query("
				select top 1 convert(varchar, date_stock_opname, 103) as date_stock_opname from dbo.tbl_stock_opname 
				where date_stock_opname < '$tglawal' and typebahan = 'SS'
				order by date_stock_opname desc
			");
			$result = $q->result_array();
			$xx=$date_stock;
			foreach ($result as $r){
				$xx=$r['date_stock_opname'];
			}
		//echo  $xx;
	?>
		
	<input type="hidden" id="tglstoscr" value="<?php echo $xx; ?>" />
	
<script type="text/javascript">	
	$(document).ready(function(){
	 	
	
		var currentDate = new Date(); 
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'dd/mm/yy'
		};
		
		$("#tglawalscr").datepicker(datesetopt);
		$("#tglakhirscr").datepicker(datesetopt); 
		
       
		$("#divprintlapposisiscrpdf").hide();	

		
		 $( "#printlaporanscr" ).button().click(function(){
		 
			$("#divprintlapposisiscrpdf").fadeOut();
			$("#divlapposisibrgdlmscr").fadeIn();
			var form_data = {
				'q':'1',
				'caritanggal':'ya',
				'tglawalscr':$("#tglawalscr").val(),
				'tglakhirscr':$("#tglakhirscr").val()
			};
			jQuery("#grdlaporanmutasiscr").jqGrid('setGridParam', { postData:form_data });
			$("#grdlaporanmutasiscr").trigger("reloadGrid");
			
			$("#grdlaporanmutasiscr").setLabel("saldoawal",'SALDO AWAL <br/>'+$("#tglawalscr").val());
			$("#grdlaporanmutasiscr").setLabel("saldoakhir",'SALDO AKHIR <br/>'+$("#tglakhirscr").val());	
			$("#grdlaporanmutasiscr").setLabel("stockopname",'STOCK OPNAME <br/>'+$("#tglstoscr").val());
		 
		 }); 
		
		
		$("#tglakhirscr").change(function() {
		  $("#grdlaporanmutasiscr").setLabel("saldoawal",'SALDO AWAL <br/>'+$("#tglawalscr").val());
		  $("#grdlaporanmutasiscr").setLabel("saldoakhir",'SALDO AKHIR <br/>'+$("#tglakhirscr").val());	
		  $("#grdlaporanmutasiscr").setLabel("stockopname",'STOCK OPNAME <br/>'+$("#tglstoscr").val());	
		}); 
		
		// $("#tglawalscr").change(function() {
			// $("#grdlaporanmutasiscr").setLabel("saldoawal",'SALDO AWAL <br/>'+$("#tglawalscr").val());
		 
		
		// })
		
		$("#printlaporanscrpdf").button().click(function(){
		
			$("#add_progress").show();
			$("#divprintlapposisiscrpdf").fadeIn();
			$("#divlapposisibrgdlmscr").fadeOut();
			$("#framelapposisibrgscr").attr("src", "<?php echo base_url().'reports/ct_reportcustoms/data_reportmutasiscr_jasper'; ?>"+'?tglawalscr='+$("#tglawalscr").val()+'&tglakhirscr='+$("#tglakhirscr").val()+'&format=pdf').load(function(){
			
				$("#add_progress").hide();
			
			});
				
		
		});
		
		
		jQuery("#grdlaporanmutasiscr").jqGrid({
		        
				url:'<?php echo base_url().'reports/ct_reportcustoms/data_reportmutasiscr'; ?>',
				datatype: "json",
				mtype: 'POST',
				postData:{'q':'1','caritanggal':'ya', 'tglawalscr':$("#tglawalscr").val(),'tglakhirscr':$("#tglakhirscr").val()},
				colNames:['No','KODE BARANG', 'NAMA BARANG','SAT','SALDO AWAL <br/>'+'<?php echo $date_stock; ?>','PEMASUKAN','PENGELUARAN','PENYESUAIAN (ADJUSTMENT)','SALDO AKHIR <br/>'+$("#tglakhirscr").val(),'STOCK OPNAME <br/>'+$("#tglstoscr").val(),'SELISIH','KETERANGAN' ],
				colModel:[
					{name:'no',index:'no', width:34},
					{name:'kodebarang',index:'kodebarang', width:63,  align:"left"},
					{name:'namabarang',index:'namabarang', width:101, align:"left"},
					{name:'satuan',index:'satuan', width:42, align:"left"},
					{name:'saldoawal',index:'saldoawal', width:123, align:"right"},
					{name:'pemasukan',index:'pemasukan', width:96, align:"right"},
					{name:'pengeluaran',index:'pengeluaran', width:96, align:"right"},
					{name:'penyesuaian',index:'penyesuaian', width:96, align:"right"},
					{name:'saldoakhir',index:'saldoakhir', width:96, align:"right"},
					{name:'stockopname',index:'stockopname', width:96, align:"right"},
					{name:'selisih',index:'selisih', width:96, align:"right"},
					{name:'keterangan',index:'keterangan', width:96},
					
				],  
				rowNum:10,
				rowList:[10,20,30],
				pager: '#pgrdlaporanmutasiscr',
				sortname: 'kodebarang',
				viewrecords: true,
				sortorder: "asc",
				width: 890,
				height:300,
				shrinkToFit: false,
				jsonReader: { repeatitems : false },
			    caption:"MUTASI SCRAP DAN SISA",
				loadComplete : function(){
					var form_data = {
					'tglawalbb':$("#tglawalscr").val(),
					'tglakhirbb':$("#tglakhirscr").val(),
					'typebahan':'SS'
					
					};
					$.ajax({
						url : '<?php echo base_url().'reports/ct_reportcustoms/tglstockopname'; ?>',
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							$("#tglstoscr").val(msg.desc);
							$("#grdlaporanmutasiscr").setLabel("stockopname",'STOCK OPNAME <br/>'+msg.desc);
					
						}
					});
				}
			//	rownumbers: true,
			
			}); 
			
			
			
			jQuery("#grdlaporanmutasiscr").jqGrid('navGrid','#pgrdlaporanmutasiscr',{edit:false,add:false,del:false,view:true});
			
			$("#printlaporanscrxls").button().click(function(){
		
		
			  document.location.href = '<?php echo base_url().'reports/ct_reportcustoms/printxlsmutasiscr'; ?>'+'?tglawalscr='+$("#tglawalscr").val()+'&tglakhirscr='+$("#tglakhirscr").val()
				
		
		    });			    
				    
		
	});
	</script>

</body>

</html> 
		

