<div id="container_out_scrap_bc27_scrap_inv" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="out_scrap_bc27_scrap_inv_bar" >  
		<button id="btnoutscrapbc27">Item List</button>
		<button id="btninvcscrapbc27">Send to BC 2.7</button>
	</div>
	<table id="tbl_out_scrap_bc27_scrap"></table> <div id="ptbl_out_scrap_bc27_scrap"></div>
</div>
<script type="text/javascript">
    
    $(document).ready(function(){
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#tbl_out_scrap_bc27_scrap"),$("#container_out_scrap_bc27_scrap_inv"),$("#out_scrap_bc27_scrap_inv_bar")); 
			},10); 
		});
		$("#btnoutscrapbc27").button().click(function(){
			$("#frmitemlistbc27scrapdlg").load('<?php echo base_url().'pasi_inventory/ct_outgoing_scrap_27/view_outgoing_scrap27_itemlist'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmitemlistbc27scrapdlg").dialog({
					modal:true,
					width : 694,
					height : 499,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmitemlistbc27scrapdlg').dialog("destroy"); 
					    $(".frmitemlistbc27scrapdlg_cl").remove(); 
					    $("body").append('<div id="frmitemlistbc27scrapdlg" title="ITEM LIST" class="frmitemlistbc27scrapdlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		
        $("#btninvcscrapbc27").button().click(function(){

            $.ajax({
                url : "<?php echo base_url().'pasi_inventory/ct_outgoing_scrap_27/prosesdatabc27scrap'; ?>",
                type : 'POST',
                dataType: 'json',

                success: function(msg){

                    if (msg.sts == '00'){
                        alert(msg.desc);
						$('#tbl_out_scrap_bc27_scrap').trigger('reloadGrid');

                    } else { alert(msg.sts+msg.desc);  }


                }
            });
        });


		jQuery("#tbl_out_scrap_bc27_scrap").jqGrid({
			url:'<?php echo base_url().'pasi_inventory/ct_outgoing_scrap_27/loadData'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			
			
			colNames:['id', 'Nomor Pendaftaran','Tanggal Pendaftaran','Nomor. Pengajuan','Nomor Keluar','Tanggal Keluar','Kode Barang','Nama Barang','Jenis','Jumlah','Satuan','Total Harga','Nomor. Invoice','Create Date','Create By','Update Date','Update By','Status'],
			colModel:[
				{name:'id_invoice_scrap_27',index:'id_invoice_scrap_27', width:60, hidden:true},
				{name:'nodaf',index:'nodaf', width:100, hidden:false},
				{name:'tgl_daf',index:'tgl_daf', width:100, hidden:false},
				{name:'car',index:'car', width:100, hidden:false},
				{name:'out_no',index:'out_no', width:100,hidden:false},
				{name:'out_tgl',index:'out_tgl', width:100,hidden:false},
				{name:'kdbrg',index:'kdbrg', width:150,hidden:false},
				{name:'nama_barang',index:'nama_barang', width:150,hidden:false},
				{name:'jenis_barang',index:'jenis_barang', width:50,hidden:false},	
				{name:'jumlah',index:'jumlah', width:50,hidden:false},
				{name:'satuan',index:'satuan', width:150},
				{name:'total_harga',index:'total_harga', width:50, hidden:false},
				{name:'no_invoice',index:'no_invoice', width:50,hidden:false},
				{name:'create_date',index:'create_date', width:120,hidden:false},
				{name:'create_by',index:'create_by', width:100,hidden:false},
				{name:'update_date',index:'update_date', width:120,hidden:false},
				{name:'update_by',index:'update_by', width:100,hidden:false},
				{name:'Status',index:'Status', width:100,hidden:false},
				],
			rowNum:100,
			rowList:[100,200,300],
			pager: '#ptbl_out_scrap_bc27_scrap',
			sortname: 'id_invoice_scrap_27',
			viewrecords: true,
			sortorder: "asc",
			width: '',
			height:100,
			jsonReader: { repeatitems : false },
			caption:"Data Scrap BC 2.7",
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_out_scrap_bc27_scrap").getDataIDs(); 
				var rowData = $("#tbl_out_scrap_bc27_scrap").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_out_scrap_bc27_scrap'));
				   
					switch (rowData[i].Status) {
						case 'DATA PROCESSED':
						   trElement.css({"color":"red"});
						break;
						
						case 'UPLOAD':
						   trElement.css({"color":"green"});
						break;
						
					}
				}
			},
			
			
		})
			                
		jQuery("#tbl_out_scrap_bc27_scrap").jqGrid('navGrid','#ptbl_out_scrap_bc27_scrap',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_out_scrap_bc27_scrap").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
			setTimeout(function(){
				setGridHight($("#tbl_out_scrap_bc27_scrap"),$("#container_out_scrap_bc27_scrap_inv"),$("#out_scrap_bc27_scrap_inv_bar")); 
			},10); 

	});	  	
</script>
<div id="frmitemlistbc27scrapdlg" title="ITEM LIST" class="frmitemlistbc27scrapdlg_cl"></div>