<div id="container_alatkantor_set" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="alatkantor_set_bar" >    

	<button id="btn_upload_alatkantor">UPLOAD MASTER</button>
	<button id="btn_alatkantor_update_data">UPDATE MASTER</button>
	<!-- <button id="btn_alatkantor_stockawal">Saldo Awal</button> 
	<button id="btn_alatkantor_data_in">DATA IN</button>
	<button id="btn_alatkantor_data_out">DATA OUT</button>
	<button id="btn_alatkantor_stock_opname">STOCK OPNAME</button>
	<button id="btn_alatkantor_mutasi">MUTASI</button> -->
	
</div>
<table id="tbl_alatkantor"></table> <div id="ptbl_alatkantor"></div>
</div>
<script type="text/javascript">
    
	
    $(document).ready(function(){
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#tbl_alatkantor"),$("#container_alatkantor_set"),$("#alatkantor_set_bar")); 
			},10); 
		});
		$("#btn_upload_alatkantor").button().click(function(){
			$("#frmuploadalatkantordlg").load('<?php echo base_url().'settings/ct_barangmesin/view_uploadalatkantor'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmuploadalatkantordlg").dialog({
					modal:true,
					width : 850,
					height : 499,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmuploadalatkantordlg').dialog("destroy"); 
					    $(".frmuploadalatkantordlg_cl").remove(); 
					    $("body").append('<div id="frmuploadalatkantordlg" title="UPLOAD ALAT KANTOR" class="frmuploadalatkantordlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
		
		});
		/* 
		$("#btn_alatkantor_stockawal").button().click(function(){
			$("#frmstokawalalatkantordlg").load('<?php echo base_url().'settings/ct_barangmesin/view_alatkantor_stockawal'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmstokawalalatkantordlg").dialog({
					modal:true,
					width : 900,
					height : 499,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmstokawalalatkantordlg').dialog("destroy"); 
					    $(".frmstokawalalatkantordlg_cl").remove(); 
					    $("body").append('<div id="frmstokawalalatkantordlg" title="STOCK AWAL" class="frmstokawalalatkantordlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
		});
		 */
		jQuery("#tbl_alatkantor").jqGrid({
			url:'<?php echo base_url().'settings/ct_barangmesin/loadData'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['id_alat_kantor', 'part no','part name', 'part name customs', 'hs code','bm','cek price', 'part no2', 'kodebarang','Saldo Awal','uom','aktif'],
			colModel:[
				{name:'id_alat_kantor',index:'id_alat_kantor', width:60, hidden:true},
				{name:'part_no',index:'part_no', width:179},
				{name:'part_name',index:'part_name', width:186},
				{name:'part_name_customs',index:'part_name_customs', width:185, hidden:false},
				{name:'hs_code',index:'hs_code', width:84,hidden:false},
				{name:'bm',index:'bm', width:39, hidden:false, align:"right"},
				{name:'cek_price',index:'cek_price', width:72, align:"right"},
				{name:'part_no2',index:'part_no2', width:147},
				{name:'kode_barang',index:'kode_barang', width:147},
				{name:'saldo_awal',index:'saldo_awal', width:107},
				{name:'uom',index:'uom', width:84},
				{name:'aktif',index:'aktif', width:84,hidden:false},
				],
			rowNum:15,
			rowList:[15,25,35,50,100],
			pager: '#ptbl_alatkantor',
			sortname: 'id_alat_kantor',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:300,
			jsonReader: { repeatitems : false },
			caption:"Data Alat Kantor",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_alatkantor").getDataIDs(); 
				var rowData = $("#tbl_alatkantor").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_alatkantor'));
				   
					switch (rowData[i].aktif) {
						
						case 'nonaktif':
						   trElement.css({"color":"red"});
						break;
						
						
					}
				}
			},
		}); 
			
                        
		jQuery("#tbl_alatkantor").jqGrid('navGrid','#ptbl_alatkantor',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_alatkantor").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
			setTimeout(function(){
				setGridHight($("#tbl_alatkantor"),$("#container_alatkantor_set"),$("#alatkantor_set_bar")); 
			},100); 
			
		/* 	
		$("#btn_alatkantor_data_in").button().click(function(){
			$("#frmdata_inalatkantordlg").load('<?php echo base_url().'settings/ct_barangmesin/view_alatkantor_data_in'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmdata_inalatkantordlg").dialog({
					modal:true,
					width : 1000,
					height : 599,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmdata_inalatkantordlg').dialog("destroy"); 
					    $(".frmdata_inalatkantordlg_cl").remove(); 
					    $("body").append('<div id="frmdata_inalatkantordlg" title="DATA PEMASUKAN" class="frmdata_inalatkantordlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		 */
		 /* 
		$("#btn_alatkantor_data_out").button().click(function(){
			$("#frmdata_outalatkantordlg").load('<?php echo base_url().'settings/ct_barangmesin/view_alatkantor_data_out'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmdata_outalatkantordlg").dialog({
					modal:true,
					width : 1000,
					height : 599,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmdata_outalatkantordlg').dialog("destroy"); 
					    $(".frmdata_outalatkantordlg_cl").remove(); 
					    $("body").append('<div id="frmdata_outalatkantordlg" title="DATA PENGELUARAN" class="frmdata_outalatkantordlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		
		 */	
		
		
		$("#btn_alatkantor_update_data").button().click(function(){
			var id = jQuery("#tbl_alatkantor").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_alatkantor").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data={
				idx:ret.id_alat_kantor,
				part_no:ret.part_no,
				part_name:ret.part_name,
				part_name_customs:ret.part_name_customs,
				hs_code:ret.hs_code,
				bm:ret.bm,
				cek_price:ret.cek_price,
				part_no2:ret.part_no2,
				kode_barang:ret.kode_barang,
				saldo_awal:ret.saldo_awal,
				uom:ret.uom
				
			};	
			
			$("#frm_ak_pdate_dlg").load('<?php echo base_url().'settings/ct_barangmesin/view_alatkantor_update'; ?>',  form_data, function() {
				$("#frm_ak_pdate_dlg").dialog({
					modal:true,
					width : 400,
					height : 400,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frm_ak_pdate_dlg').dialog("destroy"); 
					    $(".frm_ak_pdate_dlg_cl").remove(); 
					    $("body").append('<div id="frm_ak_pdate_dlg" title="Part Alat Kantor" class="frm_ak_pdate_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
			
		});
		
		 /* 
		$("#btn_alatkantor_stock_opname").button().click(function(){
			$("#frmdata_sto_alatkantor_ct_dlg").load('<?php echo base_url().'settings/ct_barangmesin/view_alatkantor_stockopname'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmdata_sto_alatkantor_ct_dlg").dialog({
					modal:true,
					width : 1000,
					height : 599,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmdata_sto_alatkantor_ct_dlg').dialog("destroy"); 
					    $(".frmdata_sto_alatkantor_ct_dlg_cl").remove(); 
					    $("body").append('<div id="frmdata_sto_alatkantor_ct_dlg" title="DATA STO BAHAN PENOLONG" class="frmdata_sto_alatkantor_ct_dlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});			
					
			
		});
		 */
		/*  
		$("#btn_alatkantor_mutasi").button().click(function(){
			
			
			$("#frmdata_mts_alatkantor_ct_dlg").load('<?php echo base_url().'settings/ct_barangmesin/view_alatkantor_mutasi'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmdata_mts_alatkantor_ct_dlg").dialog({
					modal:true,
					width : 1000,
					height : 599,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmdata_mts_alatkantor_ct_dlg').dialog("destroy"); 
					    $(".frmdata_mts_alatkantor_ct_dlg_cl").remove(); 
					    $("body").append('<div id="frmdata_mts_alatkantor_ct_dlg" title="DATA MUTASI BAHAN PENOLONG" class="frmdata_mts_alatkantor_ct_dlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});			
			
			
		});
		
		
		 */
		
	});
		  	
</script>
<div id="frmuploadalatkantordlg" title="UPLOAD ALAT KANTOR" class="frmuploadalatkantordlg_cl"></div>
<div id="frmstokawalalatkantordlg" title="STOCK AWAL" class="frmstokawalalatkantordlg_cl"></div>
<div id="frmdata_inalatkantordlg" title="DATA PEMASUKAN" class="frmdata_inalatkantordlg_cl"></div>
<div id="frm_ak_pdate_dlg" title="Part Alat Kantor" class="frm_ak_pdate_dlg_cl"></div>
<div id="frmdata_outalatkantordlg" title="DATA PENGELUARAN" class="frmdata_outalatkantordlg_cl"></div>
<div id="frmdata_outalatkantor_ct_dlg" title="DATA PENGELUARAN CT01" class="frmdata_outalatkantor_ct_dlg_cl"></div>
<div id="frmdata_sto_alatkantor_ct_dlg" title="DATA STO ALAT KANTOR" class="frmdata_sto_alatkantor_ct_dlg_cl"></div>
<div id="frmdata_mts_alatkantor_ct_dlg" title="DATA MUTASI ALAT KANTOR" class="frmdata_mts_alatkantor_ct_dlg_cl"></div>

	
	