
<div id="tabbahanpenolong_stockawal" style="height:430px">
	<ul>
		<li><a id="id_tab_proses_all_bc41" href="#divid_tab_proses_all_bc41">PROSES SELLING/REPAIR</a></li>
		<li><a id="id_tab_proses_all_bc41_scrap" href="#divid_tab_proses_all_bc41_scrap">PROSES SCRAP</a></li>
		
	</ul>
	
	<div id="divid_tab_proses_all_bc41" >
		<div class="pane-header ui-state-active" id="alatkantor_set_bar" >    
			<button id="btn_bahanpenolong_view_memo_exim_bc41">VIEW DATA</button>
			<button id="btn_bahanpenolong_proses_exim_memo_exim_bc41">PROSES DATA</button>
		</div>
		<table id="tbl_bahanpenolong_memo_exim_bc41"></table> <div id="ptbl_bahanpenolong_memo_exim_bc41"></div>

	</div>
	<div id="divid_tab_proses_all_bc41_scrap" >
		<div class="pane-header ui-state-active" id="alatkantor_set_bar" >    
			<button id="btn_bahanpenolong_view_memo_exim_bc41_scrap">VIEW DATA</button>
			<button id="btn_bahanpenolong_data_exim_memo_exim_bc41_scrap">DATA SCRAP</button>
			<button id="btn_bahanpenolong_proses_exim_memo_exim_bc41_scrap">PROSES DATA</button>
		</div>
		<table id="tbl_bahanpenolong_memo_exim_bc41_scrap"></table> <div id="ptbl_bahanpenolong_memo_exim_bc41_scrap"></div>

	</div>
	
	
</div>



<script type="text/javascript">
    
	
    $(document).ready(function(){
		
		$("#tabbahanpenolong_stockawal").tabs();
		
		jQuery("#tbl_bahanpenolong_memo_exim_bc41").jqGrid({
			url:'<?php echo base_url().'settings/ct_barangbahanpenolong/data_bahanpenolong_memo_Allx'; ?>',
			mtype : "post",
			postData:{'q':'1', status_data:function(){ return 'PROSESEXIM' },fill:function(){ return 'EXIM' }, TIPEOUT:function(){ return 'NONSCRAP' } },
			datatype: "json",
			colNames:[
			'id_memo', 
			'nomor memo',
			'tgl_memo', 
			'npwp_pembeli', 'kode_pembeli','nama_pembeli','harga_penyerahan','tipe_out','id_ceisa_hdr', 'bc_no'
			, 'tgl_bc','car'
			,'ndpbm'
			,'bruto'
			,'kdval'
			,'status'
			, 'create_date','create_by','update_date','update_by',
			
			],
			colModel:[
				{name:'id_memo',index:'id_memo', width:60, hidden:true},
				{name:'nomor_memo',index:'nomor_memo', width:159},
				{name:'tgl_memo',index:'tgl_memo', width:90},
				{name:'npwp_pembeli',index:'npwp_pembeli', width:105, hidden:false},
				{name:'kode_pembeli',index:'kode_pembeli', width:105,hidden:false},
				{name:'nama_pembeli',index:'nama_pembeli', width:195,hidden:false},
				{name:'harga_penyerahan',index:'harga_penyerahan', width:105, hidden:false, align:"right"},
				{name:'tipe_out',index:'tipe_out', width:84,hidden:false},
				{name:'id_ceisa_hdr',index:'id_ceisa_hdr', width:105, hidden:true},
				{name:'bc_no',index:'bc_no', width:105},
				{name:'tgl_bc',index:'tgl_bc', width:105},
				{name:'car',index:'car', width:137},
				{name:'ndpbm',index:'ndpbm', width:105},
				{name:'bruto',index:'bruto', width:105},
				{name:'kdval',index:'kdval', width:105},
				{name:'status_data',index:'status_data', width:105, hidden:false},
				{name:'create_date',index:'create_date', width:84,hidden:false},
				{name:'create_by',index:'create_by', width:84,hidden:false},
				{name:'update_date',index:'update_date', width:84,hidden:false},
				{name:'update_by',index:'update_by', width:84,hidden:false},
				],
			rowNum:20,
			rowList:[20,50,100],
			pager: '#ptbl_bahanpenolong_memo_exim_bc41',
			sortname: 'id_memo',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:250,
			jsonReader: { repeatitems : false },
			caption:"Data Bahan Penolong",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_bahanpenolong_memo_exim_bc41").getDataIDs(); 
				var rowData = $("#tbl_bahanpenolong_memo_exim_bc41").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_bahanpenolong_memo_exim_bc41'));
				   
					switch (rowData[i].status_data) {
						
						case 'PROSESEXIM':
						   trElement.css({"color":"green"});
						break;
						case 'PROCESSEDBC':
						   trElement.css({"color":"red"});
						break;
						
					}
				}
			},
		}); 
			
                        
		jQuery("#tbl_bahanpenolong_memo_exim_bc41").jqGrid('navGrid','#ptbl_bahanpenolong_memo_exim_bc41',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_bahanpenolong_memo_exim_bc41").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		
		$("#btn_bahanpenolong_view_memo_exim_bc41").button().click(function(){
			var id = jQuery("#tbl_bahanpenolong_memo_exim_bc41").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_bahanpenolong_memo_exim_bc41").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data = {
				id_memo:ret.id_memo
				,command:'UPDATE'
			}
			
			$("#frm_create_memo_bahanpenolong").load('<?php echo base_url().'settings/ct_barangbahanpenolong/view_bahanpenolong_memo_update_view'; ?>', 
			form_data , function() {
				$("#frm_create_memo_bahanpenolong").dialog({
					modal:true,
					width : 900,
					height : 600,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frm_create_memo_bahanpenolong').dialog("destroy"); 
					    $(".frm_create_memo_bahanpenolong_cl").remove(); 
					    $("body").append('<div id="frm_create_memo_bahanpenolong" title="BAHAN PENOLONG MEMO" class="frm_create_memo_bahanpenolong_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
				
			
		});
		
		$("#btn_bahanpenolong_proses_exim_memo_exim_bc41").button().click(function(){
			var id = jQuery("#tbl_bahanpenolong_memo_exim_bc41").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_bahanpenolong_memo_exim_bc41").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			if (ret.status_data != 'PROSESEXIM'){
				alert("DATA SUDAH DIPROSES");		
				return false;	
			}
			
			var form_data = {
				id_memo:ret.id_memo
				,command:'UPDATE'
			}
			
			$("#dlg_bahanpenolong_memo_proses_bc").dialog( "destroy" );
			$(".dlg_bahanpenolong_memo_proses_bc_cl").remove();
			$("body").append('<div id="dlg_bahanpenolong_memo_proses_bc" title="Warning" class="dlg_bahanpenolong_memo_proses_bc_cl"><p>Apakah anda akan melakukan ' + ' PROSES BC ' + ' data memo ini?!?</p><br /></div>');
			$("#dlg_bahanpenolong_memo_proses_bc").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc41/proses_bahanpenolong_memo'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_bahanpenolong_memo_proses_bc").dialog("close");
								$('#dlg_bahanpenolong_memo_proses_bc').dialog("destroy"); 
								$(".dlg_bahanpenolong_memo_proses_bc_cl").remove(); 
								$('#tbl_bahanpenolong_memo_exim_bc41').trigger('reloadGrid');
								$('#tblbc41hdr').trigger('reloadGrid');
								$("body").append('<div id="dlg_bahanpenolong_memo_proses_bc" title="Warning" class="dlg_bahanpenolong_memo_proses_bc_cl"></div>');
			

							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlg_bahanpenolong_memo_proses_bc").dialog("close");
								$('#dlg_bahanpenolong_memo_proses_bc').dialog("destroy"); 
								$(".dlg_bahanpenolong_memo_proses_bc_cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlg_bahanpenolong_memo_proses_bc').dialog("destroy"); 
					$(".dlg_bahanpenolong_memo_proses_bc_cl").remove(); 
					$("body").append('<div id="dlg_bahanpenolong_memo_proses_bc" title="Warning" class="dlg_bahanpenolong_memo_proses_bc_cl"><p>Apakah anda akan melakukan insert part hs ini?!?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
			
		});
			
		
		jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid({
			url:'<?php echo base_url().'settings/ct_barangbahanpenolong/data_bahanpenolong_memo_Allx'; ?>',
			mtype : "post",
			postData:{'q':'1', status_data:function(){ return 'PROSESEXIM' },fill:function(){ return 'EXIM' }, TIPEOUT:function(){ return 'SCRAP' } },
			datatype: "json",
			colNames:[
			'id_memo', 
			'nomor memo',
			'tgl_memo', 
			'npwp_pembeli', 'kode_pembeli','nama_pembeli','harga_penyerahan','tipe_out','id_ceisa_hdr', 'bc_no'
			, 'tgl_bc','car'
			,'ndpbm'
			,'bruto'
			,'kdval'
			,'status'
			, 'create_date','create_by','update_date','update_by',
			
			],
			colModel:[
				{name:'id_memo',index:'id_memo', width:60, hidden:true},
				{name:'nomor_memo',index:'nomor_memo', width:159},
				{name:'tgl_memo',index:'tgl_memo', width:90},
				{name:'npwp_pembeli',index:'npwp_pembeli', width:105, hidden:false},
				{name:'kode_pembeli',index:'kode_pembeli', width:105,hidden:false},
				{name:'nama_pembeli',index:'nama_pembeli', width:195,hidden:false},
				{name:'harga_penyerahan',index:'harga_penyerahan', width:105, hidden:false, align:"right"},
				{name:'tipe_out',index:'tipe_out', width:84,hidden:false},
				{name:'id_ceisa_hdr',index:'id_ceisa_hdr', width:105, hidden:true},
				{name:'bc_no',index:'bc_no', width:105},
				{name:'tgl_bc',index:'tgl_bc', width:105},
				{name:'car',index:'car', width:137},
				{name:'ndpbm',index:'ndpbm', width:105},
				{name:'bruto',index:'bruto', width:105},
				{name:'kdval',index:'kdval', width:105},
				{name:'status_data',index:'status_data', width:105, hidden:false},
				{name:'create_date',index:'create_date', width:84,hidden:false},
				{name:'create_by',index:'create_by', width:84,hidden:false},
				{name:'update_date',index:'update_date', width:84,hidden:false},
				{name:'update_by',index:'update_by', width:84,hidden:false},
				],
			rowNum:20,
			rowList:[20,50,100],
			pager: '#ptbl_bahanpenolong_memo_exim_bc41_scrap',
			sortname: 'id_memo',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:250,
			jsonReader: { repeatitems : false },
			caption:"Data Bahan Penolong Scrap",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").getDataIDs(); 
				var rowData = $("#tbl_bahanpenolong_memo_exim_bc41_scrap").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_bahanpenolong_memo_exim_bc41_scrap'));
				   
					switch (rowData[i].status_data) {
						
						case 'PROSESEXIM':
						   trElement.css({"color":"green"});
						break;
						case 'PROCESSEDBC':
						   trElement.css({"color":"red"});
						break;
						
					}
				}
			},
		}); 
			
                        
		jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('navGrid','#ptbl_bahanpenolong_memo_exim_bc41_scrap',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		
		$("#btn_bahanpenolong_view_memo_exim_bc41_scrap").button().click(function(){
			var id = jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data = {
				id_memo:ret.id_memo
				,command:'UPDATE'
			}
			
			$("#frm_create_memo_bahanpenolong").load('<?php echo base_url().'settings/ct_barangbahanpenolong/view_bahanpenolong_memo_update_view'; ?>', 
			form_data , function() {
				$("#frm_create_memo_bahanpenolong").dialog({
					modal:true,
					width : 900,
					height : 600,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frm_create_memo_bahanpenolong').dialog("destroy"); 
					    $(".frm_create_memo_bahanpenolong_cl").remove(); 
					    $("body").append('<div id="frm_create_memo_bahanpenolong" title="BAHAN PENOLONG MEMO" class="frm_create_memo_bahanpenolong_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
				
			
		});
		
		$("#btn_bahanpenolong_proses_exim_memo_exim_bc41_scrap").button().click(function(){
			var id = jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			if (ret.status_data != 'PROSESEXIM'){
				alert("DATA SUDAH DIPROSES");		
				return false;	
			}
			
			var form_data = {
				id_memo:ret.id_memo
				,command:'UPDATE'
			}
			
			$("#dlg_bahanpenolong_memo_proses_bc_scrap").dialog( "destroy" );
			$(".dlg_bahanpenolong_memo_proses_bc_scrap_cl").remove();
			$("body").append('<div id="dlg_bahanpenolong_memo_proses_bc_scrap" title="Warning" class="dlg_bahanpenolong_memo_proses_bc_scrap_cl"><p>Apakah anda akan melakukan ' + ' PROSES BC ' + ' data memo ini?!?</p><br /></div>');
			$("#dlg_bahanpenolong_memo_proses_bc_scrap").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'exim/ct_bc41/proses_bahanpenolong_memo_scrap'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlg_bahanpenolong_memo_proses_bc_scrap").dialog("close");
								$('#dlg_bahanpenolong_memo_proses_bc_scrap').dialog("destroy"); 
								$(".dlg_bahanpenolong_memo_proses_bc_scrap_cl").remove(); 
								$('#tbl_bahanpenolong_memo_exim_bc41_scrap').trigger('reloadGrid');
								$('#tblbc41hdr').trigger('reloadGrid');
								$("body").append('<div id="dlg_bahanpenolong_memo_proses_bc_scrap" title="Warning" class="dlg_bahanpenolong_memo_proses_bc_scrap_cl"></div>');
			

							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlg_bahanpenolong_memo_proses_bc_scrap").dialog("close");
								$('#dlg_bahanpenolong_memo_proses_bc_scrap').dialog("destroy"); 
								$(".dlg_bahanpenolong_memo_proses_bc_scrap_cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlg_bahanpenolong_memo_proses_bc_scrap').dialog("destroy"); 
					$(".dlg_bahanpenolong_memo_proses_bc_scrap_cl").remove(); 
					$("body").append('<div id="dlg_bahanpenolong_memo_proses_bc_scrap" title="Warning" class="dlg_bahanpenolong_memo_proses_bc_scrap_cl"><p>Apakah anda akan melakukan insert part hs ini?!?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
			
		});
		$("#btn_bahanpenolong_data_exim_memo_exim_bc41_scrap").button().click(function(){
			var id = jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_bahanpenolong_memo_exim_bc41_scrap").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data = {
				id_memo:ret.id_memo
				,command:'UPDATE'
			}
			
			$("#frm_data_memo_bahanpenolong_bc41_scrap").load('<?php echo base_url().'exim/ct_bc41/view_bc41_memo_data_scrap'; ?>', 
			form_data , function() {
				$("#frm_data_memo_bahanpenolong_bc41_scrap").dialog({
					modal:true,
					width : 830,
					height : 460,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frm_data_memo_bahanpenolong_bc41_scrap').dialog("destroy"); 
					    $(".frm_data_memo_bahanpenolong_bc41_scrap_cl").remove(); 
					    $("body").append('<div id="frm_data_memo_bahanpenolong_bc41_scrap" title="BAHAN PENOLONG MEMO" class="frm_data_memo_bahanpenolong_bc41_scrap_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});	
		});
		
	});
		  	
</script>
<div id="frm_create_memo_bahanpenolong" title="BAHAN PENOLONG MEMO" class="frm_create_memo_bahanpenolong_cl"></div>
<div id="frm_data_memo_bahanpenolong_bc41_scrap" title="BAHAN PENOLONG MEMO" class="frm_data_memo_bahanpenolong_bc41_scrap_cl"></div>

	
	