<div id="_ic_wip_raw_material_wh" style="height:95%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="_ic_wip_raw_material_wh_bar" >   
		PERIODE: <select id="_ic_wip_raw_material_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="_ic_wip_raw_material_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_ic_wip_raw_material_wh_periode">Search</button> 
		<button type="button" id="xl_ic_wip_raw_material_wh_proses">PROSES DATA</button> 
		<button type="button" id="xl_ic_wip_raw_material_wh_delete">DEL</button> 
		<button type="button" id="xl_ic_wip_raw_material_wh_proses_data">DATA XLS</button> 
	</div>
	<div id="div_ic_wip_raw_material_wh_periode" ></div>
	<table id="tbl_ic_wip_raw_material"></table> <div id="ptbl_ic_wip_raw_material"></div> 
</div> 

<script type="text/javascript">
	$(document).ready(function(){
		setTimeout(function(){
				setGridHight($("#tbl_ic_wip_raw_material"),$("#_ic_wip_raw_material_wh"),$("#_ic_wip_raw_material_wh_bar")); 
			},10); 
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#tbl_ic_wip_raw_material"),$("#_ic_wip_raw_material_wh"),$("#_ic_wip_raw_material_wh_bar")); 
			},10); 
		});
		
		
		$("#search_ic_wip_raw_material_wh_periode").button().click(function(){
			
			var form_data = {
				periode:$("#_ic_wip_raw_material_wh_year_periode").val()+$("#_ic_wip_raw_material_wh_month_periode").val()
			};
			jQuery("#tbl_ic_wip_raw_material").jqGrid('setGridParam', { postData:form_data });
			$('#tbl_ic_wip_raw_material').trigger('reloadGrid');
			
			
			/*  var form_data = {
				filename:'_ic_wip_raw_material_wh.xls',
				
			 };
			 $.ajax({
				url: "<?php echo base_url().'inventory_control/ct_inventory_control/_ic_wip_raw_material_view_xls'; ?>",
				type: "POST",
				data: form_data,
				success:function(result){
					$("#div_ic_wip_raw_material_wh_periode").html(result);
				 }
				
			}); */
			
		});
		
		jQuery("#tbl_ic_wip_raw_material").jqGrid({
			url:'<?php echo base_url().'inventory_control/ct_inventory_control/tbl_inventory_control'; ?>',
			mtype : "post",
			postData:{'q':'1','jenis':'wip_raw_material'},
			datatype: "json",
			colNames:
			[
			'id_bs_pl', 
			'TGL',
			'AMOUNT'
			, 'PERIODE'
			, 'jenis'
			,'title'
		
			
			
			],
			colModel:[
				{name:'id_inventory_control',index:'id_inventory_control', width:60, hidden:true},
				{name:'tgl',index:'tgl', width:120},
				{name:'amount',index:'amount', width:150,hidden:false, align:'right', formatter:'number',summaryType:'sum'},
				{name:'periode',index:'periode', width:120,hidden:false},
				{name:'jenis',index:'jenis', width:120,hidden:true},
				{name:'title',index:'title', width:150,hidden:true}
				],
			rowNum:20,
			rowList:[20,50,100],
			pager: '#ptbl_ic_wip_raw_material',
			sortname: 'id_inventory_control',
			viewrecords: true,
			sortorder: "asc",
			width: '',
			height:300,
			jsonReader: { repeatitems : false },
			caption:"WIP RAW MATERIAL",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_ic_wip_raw_material").getDataIDs(); 
				var rowData = $("#tbl_ic_wip_raw_material").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_ic_wip_raw_material'));
				   
					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_ic_wip_raw_material").jqGrid('navGrid','#ptbl_ic_wip_raw_material',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_ic_wip_raw_material").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		$("#xl_ic_wip_raw_material_wh_proses").button().click(function(){
			var form_data = {
				bulan : $("#validasi_ap_wh_month_periode_b1").val(),
				tahun : $("#validasi_ap_wh_year_periode_b1").val(),
				tipe : 'wip_raw_material'
				
			}
			
			$("#frm_upload_inventory_control_ardlg").load('<?php echo base_url().'inventory_control/ct_inventory_control/view_inventory_control_upload'; ?>',  form_data, function() {
				$("#frm_upload_inventory_control_ardlg").dialog({
					modal:true,
					width : 740,
					height : 520,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frm_upload_inventory_control_ardlg').dialog("destroy"); 
					    $(".frm_upload_inventory_control_ardlg_cl").remove(); 
					    $("body").append('<div id="frm_upload_inventory_control_ardlg" title="IN FINISH GOOD" class="frm_upload_inventory_control_ardlg_cl"></div>'); 
						$('#tbl_ic_wip_raw_material').trigger('reloadGrid');
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			})
			
			
		});
		
		$("#xl_ic_wip_raw_material_wh_delete").button().click(function(){
			var id = jQuery("#tbl_ic_wip_raw_material").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_ic_wip_raw_material").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			var form_data = {
				id:ret.id_inventory_control,
				filename:ret.filename,
				tipe:ret.tipe
			
			};
			
			
			$("#dlg_ic_inventory_control_delete").dialog( "destroy" );
			$(".dlg_ic_inventory_control_deletecl").remove();
			$(".dlg_ic_inventory_control_deletecl").html('');
			$("body").append('<div id="dlg_ic_inventory_control_delete" title="Warning" class="dlg_ic_inventory_control_deletecl"><p>Apakah anda akan memproses data ini?!?</p></div>');
			$("#dlg_ic_inventory_control_delete").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'inventory_control/ct_inventory_control/proses_delete_inventory_control'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_ic_inventory_control_delete").dialog("close");
								$('#dlg_ic_inventory_control_delete').dialog("destroy"); 
								$(".dlg_ic_inventory_control_deletecl").remove(); 
								jQuery("#tbl_ic_wip_raw_material").trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlg_ic_inventory_control_delete").dialog("close");
								$('#dlg_ic_inventory_control_delete').dialog("destroy"); 
								$(".dlg_ic_inventory_control_deletecl").remove(); 
								jQuery("#tbl_ic_wip_raw_material").trigger('reloadGrid');

							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlg_ic_inventory_control_delete" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlg_ic_inventory_control_delete').dialog("destroy"); 
					$(".dlg_ic_inventory_control_deletecl").remove(); 
					$("body").append('<div id="dlg_ic_inventory_control_delete" title="Warning" class="dlg_ic_inventory_control_deletecl"><p>Apakah anda akan memproses data ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
		});
		
		
		$("#xl_ic_wip_raw_material_wh_proses_data").button().click(function(){
			
			//alert($("#_ic_wip_raw_material_wh_year_periode").val() + $("#_ic_wip_raw_material_wh_month_periode").val() );
			document.location.href = '<?php echo base_url().'inventory_control/ct_inventory_control/bs_excel_data'; ?>'+'?periode='+$("#_ic_wip_raw_material_wh_year_periode").val()+$("#_ic_wip_raw_material_wh_month_periode").val()
		
		});
	
	
	});
</script>
<div id="frm_upload_inventory_control_ardlg" title="IN FINISH GOOD" class="frm_upload_inventory_control_ardlg_cl"></div>	