<div id="container_pasi_ceisa_in_gudang" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
<div class="pane-header ui-state-active" id="pasi_ceisa_gudang_in_bar" >   
	 
	<button type="button" id="pasi_ceisa_gudang_in_received">APPROVAL</button>  
	<button type="button" id="pasi_ceisa_gudang_in_item">VIEW BARANG</button>  
</div>
<table id="pasi_ceisa_gudang_in_tbl"></table> <div id="ppasi_ceisa_gudang_in_tbl"></div> 

<script type="text/javascript">
    
    $(document).ready(function(){
	
	$(window).bind('resize', function() {  
		setTimeout(function(){
			setGridHight($("#pasi_ceisa_gudang_in_tbl"),$("#container_pasi_ceisa_in_gudang"),$("#pasi_ceisa_gudang_in_bar")); 
		},10); 
	}); 
		 
 
	$("#pasi_ceisa_gudang_in_received").button(); 
	$("#pasi_ceisa_gudang_in_item").button(); 

	jQuery("#pasi_ceisa_gudang_in_received").click(function(){  
 
 var mark_id = jQuery('#pasi_ceisa_gudang_in_tbl').jqGrid('getGridParam','selrow');   
					  if(!mark_id){ alert("Select Dokumen ");exit;}    
					  var ret = jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('getRowData',mark_id);    
		   
  var field_data={parmeter:'parameter'
	  			  ,bc_prefix:'in'
				  ,no_invoice:ret.r2
				  ,id_header:ret.rID
				  ,NOMOR_PENERIMAAN:ret.r11
				  ,TANGGAL_PENERIMAAN:ret.r12
				  ,NOMOR_SURATJALAN:ret.r13
				  ,TANGGAL_SURATJALAN:ret.r14,
				  NOMOR_DAFTAR:ret.r16,
					TANGGAL_DAFTAR: ret.r17,
					NOMOR_AJU:ret.r18,
					TYPE_BC:ret.r19			
				  };
  
  var $dialog = jQuery('<div \>')
   .load('<?php echo base_url().'pasi_ceisa_gudang_in/ct_gudang_in_load/view_gudang_in_received'; ?>',field_data)
   .dialog({
	  modal:true,
	  width : 650,
	  height : 550,
		  title :'LIST BARANG MASUK',
		  buttons: {
			  "CLOSE": function(){
				  $dialog.dialog("close");   
			  } ,
		  
		  },
		  close : function(){
			  $dialog.dialog('destroy').remove();
			  $('#pasi_ceisa_gudang_in_tbl').trigger('reloadGrid');
		  },
		  open: function(){
			  $("body").unblock(); 
		  }
	  }); 
		
	}); 

	var datePick = function (el) {
			$(el).datepicker({
				changeYear: true,
				changeMonth: true,
				showButtonPanel: true,
				onSelect: function () {
					
					if (this.id.substr(0, 3) === "gs_") {
                // in case of searching toolbar
					setTimeout(function(){
					jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						// refresh the filter in case of
						// searching dialog
						$(this).trigger('change');
					}
				}    
			});
		};

	jQuery("#pasi_ceisa_gudang_in_item").click(function(){   
  
  var mark_id = jQuery('#pasi_ceisa_gudang_in_tbl').jqGrid('getGridParam','selrow');   
					  if(!mark_id){ alert("Select Dokumen ");exit;}    
					  var ret = jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('getRowData',mark_id);    
		   
  var field_data={parmeter:'parameter'
	  			  ,bc_prefix:'in'
				  ,no_invoice:ret.r2
				  ,id_header:ret.rID
				  ,NOMOR_PENERIMAAN:ret.r11
				  ,TANGGAL_PENERIMAAN:ret.r12
				  ,NOMOR_SURATJALAN:ret.r13
				  ,TANGGAL_SURATJALAN:ret.r14,
				  NOMOR_DAFTAR:ret.r16,
					TANGGAL_DAFTAR: ret.r17,
					NOMOR_AJU:ret.r18,
					TYPE_BC:ret.r19			
				  };
  
  var $dialog = jQuery('<div \>')
   .load('<?php echo base_url().'pasi_ceisa_gudang_in/ct_gudang_in_load/view_gudang_in_item'; ?>',field_data)
   .dialog({
	  modal:true,
	  width : 950,
	  height : 550,
		  title :'LIST BARANG MASUK',
		  buttons: {
			  "CLOSE": function(){
				  $dialog.dialog("close");   
			  } ,
		  
		  },
		  close : function(){
			  $dialog.dialog('destroy').remove();
			  $('#pasi_ceisa_gudang_in_tbl').trigger('reloadGrid');
		  },
		  open: function(){
			  $("body").unblock(); 
		  }
	  }); 
}); 


//--------------------LOAD DATA

    jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid({
        url:'<?php echo base_url().'pasi_ceisa_gudang_in/ct_gudang_in_data/loaddata_gudang_in'; ?>',
			mtype : "post",
			postData:{'q':'1'},  
			datatype: "json",
			colNames:[
			'beli_ID_HEADER','STATUS','Nomor Ked','G','Nomor Dokumen','Tanggal Dokumen','Kode Supplier'
			,'Nama Supplier','Nama','Tanggal','NOMOR','TANGGAL','NOMOR','TANGGAL','x','x','x','x']

			,colModel:[
			{name:'rID',index:'rID', width:80, hidden:true , align :'right'}
			,{name:'r15',index:'r15', width:100, hidden:false, align :'left'}
			,{name:'r1',index:'r1', width:150, hidden:false, align :'left'} // no faktur      stype: 'select', search:true, searchoptions:{searchhidden: true, value: '-100:All;0:DRAFT;1:SEND TO MODULE;2:MAPPING;3:FINISH;-1:CANCEL'}}
 			,{name:'r10',index:'r10', width:40, editable: false, formatter:'checkbox',  align: "center",stype: "select", searchoptions: { value: "-100:All;1:Yes;0:No" }}
 	
     		,{name:'r2',index:'r2', width:190, hidden:false, align :'left'}  // no dokumen
			,{name:'r3',index:'r3', width:190, hidden:false, align :'left'}  // tanggal dokumen
			,{name:'r4',index:'r4', width:200, hidden:false, align :'left'}  // kode supp , searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_ceisa_gudang_in_tbl")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}	
			,{name:'r5',index:'r5', width:390, hidden:false, align :'left'}  // nama supp
            ,{name:'r6',index:'r6', width:100, hidden:false, align :'left'}
			,{name:'r7',index:'r7', width:100, hidden:false, align :'left'}
			,{name:'r11',index:'r11', width:100, hidden:false, align :'left'}	
			,{name:'r12',index:'r12', width:100, hidden:false, align :'left'}
			,{name:'r13',index:'r13', width:100, hidden:false, align :'left'}
			,{name:'r14',index:'r14', width:100, hidden:false, align :'left'}
			,{name:'r16',index:'r16', width:100, hidden:true, align :'left'}
			,{name:'r17',index:'r17', width:100, hidden:true, align :'left'}
			,{name:'r18',index:'r18', width:100, hidden:true, align :'left'}
			,{name:'r19',index:'r19', width:100, hidden:true, align :'left'}		
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ppasi_ceisa_gudang_in_tbl',
			sortname: 'r1',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height: 100,
			//width: 950,
			//height:300,
			jsonReader: { repeatitems : false },
			caption:"DATA BARANG MASUK GUDANG",
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
		    onSelectRow: function(rowid){ 
				var rowData = $("#pasi_ceisa_gudang_in_tbl").getRowData(rowid); 
	/*	 		if (rowData.rg == 'Yes' ){
					$("#pasi_ceisa_beli_map_supplier").show();
				}
				else{
					$("#pasi_ceisa_beli_map_supplier").hide();
			   } */
	 
  		 	 },
			gridComplete: function(){
				var rowIDs = jQuery("#pasi_ceisa_gudang_in_tbl").getDataIDs(); 
				var rowData = $("#pasi_ceisa_gudang_in_tbl").getRowData();
			    
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#pasi_ceisa_gudang_in_tbl'));
				   
				/*	switch (rowData[i].status_2) {
						case 'DATA PROCESSED':
						   trElement.css({"color":"green"});
						break;
						
						case 'SENT TO INVENTORY CANCELED':
						   trElement.css({"color":"green"});
						break;
						
						case 'DATA SENT TO INVENTORY':
						   trElement.css({"color":"purple"});
						break;
						case 'DATA PROCESSED INVENTORY':
						   trElement.css({"color":"blue"});
						break;
						case 'APPROVED INVENTORY':
						   trElement.css({"color":"red"});
						break;
					}*/
				}
			}, 
		}); 
		
		jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('setGroupHeaders', 
            { useColSpanStyle: true, groupHeaders:[
			{startColumnName: 'r2', numberOfColumns: 2, titleText: '<em><center>Dokumen</center></em>'},
 			{startColumnName: 'r4', numberOfColumns: 2, titleText: '<em><center>Supplier</center></em>'}, 
 			{startColumnName: 'r6', numberOfColumns: 2, titleText: '<em><center>Create</center></em>'}, 
 			{startColumnName: 'r11', numberOfColumns: 2, titleText: '<em><center>Pemerimaan</center></em>'}, 
 			{startColumnName: 'r13', numberOfColumns: 2, titleText: '<em><center>Surat Jalan</center></em>'}, 

        ] });
		
		jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('navGrid','#ppasi_ceisa_gudang_in_tbl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#pasi_ceisa_gudang_in_tbl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
	
	
		
	setTimeout(function(){
			setGridHight($("#pasi_ceisa_gudang_in_tbl"),$("#container_pasi_ceisa_in_gudang"),$("#pasi_ceisa_gudang_in_bar")); 
		},100); 


 
		

    });



</script>

<div id="formreceive_dlg" title="PENERIMAAN GUDANG" class="formreceive_dlg_cl"></div>
	