 <div id="container_pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
<div class="pane-header ui-state-active" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_bar" >   
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_create">Create</button>  
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_sa">View SA</button>  
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_barang">View Barang</button> 
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_dokumen">View Dokumen</button> 
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_send_to_module">Send to Module</button> 
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_update_from_module">Sync from Module</button>
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_get_from_module">Get From Module</button> 
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_cancel">Cancel</button> 
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_finish">Finish</button> 
	<button type="button" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_map_supplier">Map Customer</button> 
</div>
<table id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl"></table> <div id="ppasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl"></div> 

<script type="text/javascript">
    
    $(document).ready(function(){
	
	$(window).bind('resize', function() {  
		setTimeout(function(){
			setGridHight($("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl"),$("#container_pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out"),$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_bar")); 
		},10); 
	}); 
		 
	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_create").button(); 
	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_sa").button(); 
	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_barang").button();  
 	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_dokumen").button();  
    $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_send_to_module").button();  
    $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_get_from_module").button();  
    $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_update_from_module").button();  
    $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_cancel").button();   
	$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_finish").button();   
    $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_map_supplier").button().hide();   

    jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_create").click(function(){  
		var $dialog = jQuery('<div \>')
		 .load('<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa'; ?>',{bc_prefix:'<?php echo $bc_prefix;  ?>'})
		 .dialog({
			modal:true,
			width : 970,
			height : 400,
				title :'CREATE FROM SA',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					"CREATE HEADER": function(){  
					
					 		
				 	 	var selRowIds;
							 selRowIds =  $("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list").jqGrid('getGridParam','selarrrow'); 
							if (selRowIds.length ==0){
								 alert("Harus memiliki minimal 1 SA, pilih SA");
								 exit;
							 } 
							var myArray = [];
							for (var i = 0; i < selRowIds.length; i++) 
							{
								var rowId = selRowIds[i];
								var idnya =  $('#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list').getCell(rowId, 'rID'); 
								myArray.push(idnya);
							} 
							var mark_id = jQuery('#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_cust_list').jqGrid('getGridParam','selrow');   
							if(!mark_id){ alert("Select Customer ");exit;}    
							var ret = jQuery("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_cust_list").jqGrid('getRowData',mark_id);    
							
							 
							var form_edit = {
									bc_prefix :'<?php echo $bc_prefix;  ?>',      
									cust_code  : ret.r1,
				 					lstsa  : myArray  
							}; 
							
							jQuery('.ui-dialog button:nth-child(2)').button('disable'); 
						
						 	$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/create_header_bc'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else {  
										alert(msg.stsno+msg.stsmsg); 
									}
								} 
							}).always(function() {
								jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
							});
							 
					} , 
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
					$("body").unblock(); 
				},
				resize: function( event, ui ) { 
					setTimeout(function(){
						setGridHight($("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list"),$("#container_pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list"),$("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list_bar")); 
						setGridHight($("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_cust_list"),$("#container_pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_cust_list"),$("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_cust_list_bar")); 
					},100); 
				}
			}); 
	}); 
	
  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_sa").click(function(){  
  
		var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
							if(!mark_id){ alert("Select Dokumen ");exit;}    
							var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
				 
		var field_data={bc_prefix:'<?php echo $bc_prefix;  ?>'
						,cust_code:ret.rc
						,id_header:ret.rID
						,status_module:ret.rt2
						,status:ret.r1
						,status_name:ret.r2
						,is_get:(ret.rg=='No')?'0':'1'
						};
		
		var $dialog = jQuery('<div \>')
		 .load('<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/view_sa'; ?>',field_data)
		 .dialog({
			modal:true,
			width : 600,
			height : 400,
				title :'LIST SA',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	}); 
	
  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_barang").click(function(){  
  
		var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
							if(!mark_id){ alert("Select Dokumen ");exit;}    
							var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
				 
		var field_data={bc_prefix:'<?php echo $bc_prefix;  ?>'
						,cust_code:ret.rc
						,id_header:ret.rID
						,is_get:(ret.rg=='No')?'0':'1'
						};
		
		var $dialog = jQuery('<div \>')
		 .load('<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/view_item'; ?>',field_data)
		 .dialog({
			modal:true,
			width : 900,
			height : 500,
				title :'LIST SA',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
				
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	}); 
	
	
  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_view_dokumen").click(function(){  
  
		var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
							if(!mark_id){ alert("Select Dokumen ");exit;}    
							var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
				 
		var field_data={bc_prefix:'<?php echo $bc_prefix;  ?>'
						,cust_code:ret.rc
						,id_header:ret.rID
						};
		
		var $dialog = jQuery('<div \>')
		 .load('<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/view_dokumen'; ?>',field_data)
		 .dialog({
			modal:true,
			width : 900,
			height : 500,
				title :'LIST SA',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
				
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	}); 
	
	
	  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_cancel").click(function(){  
			var $dialog =  $('<div />')
				.html(' <div class="ui-layout-content ui-widget-content-panel" style="margin-top:10px"> \
				<table class="tablefixed" > \
				<input type="hidden" id="doc_in_id23"> \
							<tr> \
							<td class="td100">Info Cancel</td> \
							  <td width="10"><div align="center">:</div></td> \
								<td colspan="3"><input name="txt_ciesa_bc_<?php echo $bc_prefix;  ?>_info_cancel" type="text" id="txt_ciesa_bc_<?php echo $bc_prefix;  ?>_info_cancel" style="width:100%;text-align:left;" /></td> \
							</tr> \
						</table> \
				</div>\
				<div class="pane-footer ui-state-default" />')
			 .dialog({
				modal:true,
				width : 500,
				height : 150,
				title :'CANCEL DOKUMENT <?php echo $bc_prefix;  ?>',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					"CANCEL DOCUMENT": function(){ 
							var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
						 	if(!mark_id){ alert("Pililh dokumen yang akan di cancel");exit;}    
								var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
						 	var form_edit = {      
									id_header  : ret.rID,
									status_info  : $('#txt_ciesa_bc_<?php echo $bc_prefix;  ?>_info_cancel').val()  
							}; 
							
							jQuery('.ui-dialog button:nth-child(2)').button('disable');  
							$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/cancel_document'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else { 
									alert(msg.stsno+msg.stsmsg);   
									}
								} 
							}).always(function() {
								jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
							});
							 
					} , 
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
				$("body").unblock(); 
				}
			}); 
	}); 
		 
	  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_send_to_module").click(function(){  
			var $dialog =  $('<div />')
				.html(' <div class="ui-layout-content ui-widget-content-panel" style="margin-top:10px"> \
				Data Akan di kirim ke module? \
				</div>\
				 <div class="pane-header ui-state-active" id="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_sa_tbl_sa_list_bar2" >TANDA TANGAN</div>\
				 <div class="ui-layout-content ui-widget-content-panel">\
			 	 <label class="lbfield55">NAME</label><label class="lbcolon">:</label><input id="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_tdd_name"name="pasi_ceisa_bc_out_tdd_name"  style="width:185px"   type="text" /><br \>\
				 <label class="lbfield55">JABATAN</label><label class="lbcolon">:</label><input id="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_tdd_jabatan"name="pasi_ceisa_bc_out_tdd_jabatan"   style="width:185px"  type="text" />\
				</div>\
				<div class="pane-footer ui-state-default" />')
			 .dialog({
				modal:true,
				width : 500,
				height : 250,
				title :'SEND DOCUMENT <?php echo $bc_prefix;  ?>',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					"SEND DOCUMENT": function(){ 
							var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
						 	if(!mark_id){ alert("Pililh dokumen yang akan di kirim ke module");exit;}    
								var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
						 	
							var form_edit = {      
									id_header  : ret.rID, 
					 				tdd_name  : $( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_tdd_name" ).val(), 
									tdd_jabatan  : $( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_tdd_jabatan" ).val(), 
							}; 
							
							jQuery('.ui-dialog button:nth-child(2)').button('disable'); 
		                    $.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/send_to_module'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else { 
									alert(msg.stsno+msg.stsmsg);   
									}
							} 
							}).always(function() {
								jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
							});
							 
					} , 
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
				 			$.ajax({    
									url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/load_setting_default'; ?>',
									type : 'POST',
										data : {bc_prefix:'<?php echo $bc_prefix;  ?>'},
										dataType: 'json',
										success: function(msg){
											if (msg.valid){
												$( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_tdd_name" ).val(msg.data['TDD_NAME']);
												$( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_tdd_jabatan" ).val(msg.data['TDD_JABATAN']); 
											}  
										} 
							});
					$("body").unblock(); 
				}
			}); 
	}); 
	
	  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_update_from_module").click(function(){  
			var $dialog =  $('<div />')
				.html(' <div class="ui-layout-content ui-widget-content-panel" style="margin-top:10px"> \
				Sync data from module? \
				<div class="pane-footer ui-state-default" />')
			 .dialog({
				modal:true,
				width : 500,
				height : 150,
				title :'SYNC DOCUMENT FROM MODULE <?php echo $bc_prefix;  ?>',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					"SYNC DOCUMENT": function(){ 
							var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
						 	if(!mark_id){ alert("Pililh dokumen yang akan di kirim ke module");exit;}    
								var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
						 	
							var form_edit = {      
									id_header  : ret.rID, 
				 			}; 
							
							jQuery('.ui-dialog button:nth-child(2)').button('disable'); 
							$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/update_from_module'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else { 
									alert(msg.stsno+msg.stsmsg);   
									}
								} 
							}).always(function() {
								jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
							});
							 
					} , 
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){ 
					$("body").unblock(); 
				}
			}); 
	}); 
	
	
	
	  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_get_from_module").click(function(){  
		var $dialog = jQuery('<div \>')
		 .load('<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/view_header_module_for_import'; ?>',{bc_prefix:'<?php echo $bc_prefix;  ?>'})
		 .dialog({
			modal:true,
			width : 970,
			height : 550,
				title :'IMPORT <?php echo $bc_prefix;  ?> FROM MODULE',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					"IMPORT DATA": function(){  
						var selRowIds;
						selRowIds =  $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_header_module_tbl").jqGrid('getGridParam','selarrrow');
						
						var myArray = [];
						for (var i = 0; i < selRowIds.length; i++) 
						{
							var rowId = selRowIds[i];
							var idnya =  $('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_header_module_tbl').getCell(rowId, 'rID'); 
							myArray.push(idnya);
						} 
						
						if (selRowIds.length ==0){
							alert("must have  minimum 1 item ");
							exit;
						}
					 
						var form_edit = {
								bc_prefix :'<?php echo $bc_prefix;  ?>',     
					 			replace_if_exists        	: $('#replace_if_exist<?php echo $bc_prefix;  ?>').is(':checked')==true?'1':'0',    
								lstsa  : myArray  
						}; 
						
						jQuery('.ui-dialog button:nth-child(2)').button('disable'); 
						$.ajax({    
						url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/import_data_from_module'; ?>',
						type : 'POST',
							data : form_edit,
							dataType: 'json',
							success: function(msg){
								if (msg.valid){
									alert(msg.stsmsg);  
									$dialog.dialog("close");  
									} else { 
									alert(msg.stsno+msg.stsmsg);  
									jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
								}
							} 
						}).always(function() {
								jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
						});
						 
					} , 
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	});  
	
	  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_map_supplier").click(function(){  
		var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
		if(!mark_id){ alert("Pililh dokumen");exit;}  
		var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
 		var $dialog = jQuery('<div \>')
		 .load('<?php echo base_url().'pasi_ceisa_master/ct_pasi_map_customer'; ?>',{bc_prefix:'<?php echo $bc_prefix;  ?>',source_npwp:ret.r11,source_name:ret.r12,source_address:ret.r14})
		 .dialog({
			modal:true,
			width : 970,
			height : 550,
				title :'MAPPING CUSTOMER',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					"MAPPING": function(){  
						var mark_id_cust = jQuery('#pasi_ceimap_cust_master_<?php echo $bc_prefix;  ?>map_cust_tbl').jqGrid('getGridParam','selrow');   
						if(!mark_id_cust){ alert("Pililh Customer");exit;}  
						var ret_cust = jQuery("#pasi_ceimap_cust_master_<?php echo $bc_prefix;  ?>map_cust_tbl").jqGrid('getRowData',mark_id_cust);    
 
						var form_edit = {
								id_header :ret.rID,     
								cust_code :ret_cust.r1
				 		}; 
						
						jQuery('.ui-dialog button:nth-child(2)').button('disable'); 
						$.ajax({    
						url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/update_mapping_customer'; ?>',
						type : 'POST',
							data : form_edit,
							dataType: 'json',
							success: function(msg){
								if (msg.valid){
									alert(msg.stsmsg);  
									$dialog.dialog("close");  
								} else { 
									alert(msg.stsno+msg.stsmsg);  
									jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
								}
							} 
						}).always(function() {
								jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
						});
						 
					} , 
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	}); 

	  jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_finish").click(function(){  
				var mark_id = jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').jqGrid('getGridParam','selrow');   
						 	if(!mark_id){ alert("Pililh dokumen yang update status finish");exit;}    
				
					var $dialog =  $('<div />')
				.html(' <div class="ui-layout-content ui-widget-content-panel" style="margin-top:10px"> \
				Finish dokumen? data akan masuk ke dalam laporan pengeluaran dokumen <br /><br />\
  						 <br />\
				<label class="lbfield75" for="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_compare">Compare Item</label><label class="lbcolon">:</label><input  name="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_compare" type="checkbox" id="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_compare"  value=\'Yes\' offval=\'No\'  /><label  for="pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_compare">(Compare SA Ceisa)</label><br \>\
				<label class="lbfield75">Surat Jalan No</label><label class="lbcolon">:</label><input id="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_surat_jalan_no"name="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_receive_no"  style="width:185px"   type="text" /><br \>\
				<label class="lbfield75">Surat Jalan Date</label><label class="lbcolon">:</label><input id="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_surat_jalan_date"name="pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_receive_date"   style="width:185px"  type="text" />\
				</div>')
			 .dialog({
				modal:true,
				width : 450,
				height : 200,
				title :'FINISH DOCUMENT BC <?php echo $bc_prefix;  ?>',
				buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					
					"FINISH": function(){ 
					
				 			var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
							var form_edit = {      
									id_header  : ret.rID,
									surat_jalan_no :  $( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_surat_jalan_no" ).val(),
									surat_jalan_date :	$.datepicker.formatDate('yymmdd', new Date($("#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_surat_jalan_date").datepicker( "getDate" ))),
									compare_data :$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_compare').is(':checked')==true?'1':'0',
							}; 
				
								 	
	
							jQuery('.ui-dialog button:nth-child(2)').button('disable'); 
							$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/finish_document'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else { 
										alert(msg.stsno+msg.stsmsg);   
									}
								} 
							}).always(function() {
								jQuery('.ui-dialog button:nth-child(2)').button('enable'); 
							});
							 
					} , 
				},
				close : function(){
					$dialog.dialog('destroy').remove();
					$('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl').trigger('reloadGrid');
				},
				open: function(){ 
					$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_compare").prop("checked", true);  
					$( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_surat_jalan_date" ).datepicker({
						dateFormat:'dd-mm-yy',
						changeMonth: true,
						changeYear: true,
						numberOfMonths: 1,
						onClose: function( selectedDate ) {
						}
					  });
					  var ret = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('getRowData',mark_id);    
					var form_edit = {      
									id_header  : ret.rID, 
							}; 
				 			$.ajax({    
									url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_out_from_sa/get_surat_jalan'; ?>',
									type : 'POST',
										data : form_edit,
										dataType: 'json',
										success: function(msg){
											if (msg.valid){
												$( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_surat_jalan_no" ).val(msg.data['SURAT_JALAN_NO']);
												$( "#pasi_ceisa_bc_out<?php echo $bc_prefix;  ?>_surat_jalan_date" ).val(msg.data['SURAT_JALAN_DATE']); 
											}  
										} 
							});
					$("body").unblock(); 
				}
			}); 
	}); 
	
	
	jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid({
			url:'<?php echo base_url().'pasi_ceisa_bc_out/ct_pasi_ceisa_bc_'.$bc_prefix_name.'/loaddata'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:[
			'tpb_out_header_ID_HEADER','tpb_out_header_h_status_status_tpb_out_id','Status','G','Nomor AJU','Nomor Daftar','Tanggal Daftar','Status','Status2'
			,'NPWP','KODE','NAMA','ALAMAT'
			,'Bruto','Harga Penyerahan','Barang','Kemasan','Kontainer'
			,'Info', 'Tanggal','Nama','Tanggal','Nama','Tanggal'
			,'Nama','RC'
			]
			,colModel:[
			{name:'rID',index:'rID', width:80, hidden:true , align :'right'}
			,{name:'r1',index:'r1', width:80, hidden:true, align :'right'}
			,{name:'r2',index:'r2', width:80, stype: 'select', search:true, searchoptions:{searchhidden: true, value: '-100:All;0:DRAFT;1:SEND TO MODULE;2:MAPPING;3:FINISH;-1:CANCEL'}}
 			,{name:'rg',index:'rg', width:40, editable: false, formatter:'checkbox',  align: "center",stype: "select", searchoptions: { value: "-100:All;1:Yes;0:No" }}
 			,{name:'r3',index:'r3', width:190, hidden:false, align :'left'}
			,{name:'r5',index:'r5', width:60, hidden:false, align :'left'}
			,{name:'r4',index:'r4', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_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:'rt',index:'rt', width:120, hidden:false, align :'left'}
			,{name:'rt2',index:'rt2', width:120, hidden:true, align :'left'}
		
			,{name:'r11',index:'r11', width:80, hidden:false, align :'left'}
			,{name:'rc',index:'rc', width:60, hidden:false, align :'left'}
			,{name:'r12',index:'r12', width:180, hidden:false, align :'left'}
			,{name:'r14',index:'r14', width:300, hidden:false, align :'left'}

			,{name:'r6',index:'r6', width:80, hidden:false, align :'right'}
			,{name:'r7',index:'r7', width:80, hidden:false, align :'right'}
			,{name:'r8',index:'r8', width:80, hidden:false, align :'right'}
			,{name:'r9',index:'r9', width:80, hidden:false, align :'right'}
			,{name:'r10',index:'r10', width:80, hidden:false, align :'right'}

			,{name:'r15',index:'r15', width:80, hidden:false, align :'left'}
			,{name:'r16',index:'r16', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_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:'r17',index:'r17', width:80, hidden:false, align :'left'}
			,{name:'r18',index:'r18', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_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:'r19',index:'r19', width:80, hidden:false, align :'left'}
			,{name:'r20',index:'r20', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_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:'r21',index:'r21', width:80, hidden:false, align :'left'}
			,{name:'r13',index:'r13', width:80, hidden:true, align :'left'}
		
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ppasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl',
			sortname: 'r1',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height: 100,
			//width: 950,
			//height:300,
			jsonReader: { repeatitems : false },
			caption:"Data BC <?php echo $bc_prefix;  ?>",
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
		    onSelectRow: function(rowid){ 
				var rowData = $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").getRowData(rowid); 
		 		if (rowData.rg == 'Yes' ){
					$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_map_supplier").show();
			     }
				else{
					$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_map_supplier").hide(); 
			   }
	 
  		 	 },
			gridComplete: function(){
				// var rowIDs = jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").getDataIDs(); 
				// var rowData = $("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").getRowData();
			
				// for (var i = 0; i < rowData.length; i++) 
				// {
				   // var trElement = jQuery("#"+ rowIDs[i],jQuery('#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_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_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('setGroupHeaders', 
            { useColSpanStyle: true, groupHeaders:[
			{startColumnName: 'r3', numberOfColumns: 4, titleText: '<em><center>Dokumen</center></em>'},
			{startColumnName: 'r6', numberOfColumns: 5, titleText: '<em><center>Jumlah</center></em>'}, 
 			{startColumnName: 'r11', numberOfColumns: 5, titleText: '<em><center>Penerima</center></em>'}, 
 			{startColumnName: 'r15', numberOfColumns: 3, titleText: '<em><center>Status</center></em>'}, 
 			{startColumnName: 'r18', numberOfColumns: 2, titleText: '<em><center>Modify</center></em>'}, 
 			{startColumnName: 'r20', numberOfColumns: 2, titleText: '<em><center>Create</center></em>'}, 
        ] });
			               
		jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('navGrid','#ppasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
	
	
		
	setTimeout(function(){
			setGridHight($("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_tbl"),$("#container_pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out"),$("#pasi_ceisa_bc_<?php echo $bc_prefix;  ?>_out_bar")); 
		},100); 
	});
		  	
</script>

	
	