<div id="popup_bas" class="centering" style="width:1200px;margin-top: 1%;">
	<div class="detil" style="padding: 2px;background-color: white;">
		<?php //print_r($info_tanya_jawab); ?>
		<table style="font-size:14px;width:100%">
			<tr>
				<td></td>
				<td>
					<table id="tableDetilPerkara" style="font-size:14px;width:100%">
						<tr>
							<td colspan="2" class="header">Setting Berita Acara Sidang <?php 
							if ($arr_info_sidang['urutan'] ==1) {$lanjutan='Pertama';}else{$lanjutan='Lanjutan';};
								echo $lanjutan.' '.ucwords(strtolower($arr_info_sidang['agenda'])); ?></td>
						</tr>
						<col width="20%">
						<col width="80%">
						<tbody>
							<tr>
								<td colspan="2" class="divider">Pembuka</td>
							</tr>
							<tr>
								<td>No Perkara</td>
								<td><?php print_r($nomor_perkara); ?></td>
							</tr>
							<tr>
								<td>Tanggal Sidang</td>
								<td><?php echo $this->tanggalhelper->convertDayDate($arr_info_sidang['tanggal_sidang']); ?></td>
							</tr>
							<tr>
								<td>Majelis</td>
								<td><?php print_r($majelis_hakim_text); ?></td>
							</tr>
							<tr>
								<td>Panitera/Panitera Pengganti</td>
								<td><?php print_r($panitera_pengganti_text); ?></td>
							</tr>
							<tr>
								<td>Para Pihak</td>
								<td><?php print_r($para_pihak); ?></td>
							</tr>
							<tr>
								<td colspan="2" class="divider">Isi Konten</td>
							</tr>
							<tr>
								<td>Agenda</td>
								<td>
									<div class="cssTable">
										<table id='table_agenda'>
											<col width="5%">
											<col width="87%">
											<col width="8%">
											<tbody id='bd_table_agenda'>
											<tr>
												<td>
													No
												</td>
												<td>
													Agenda
												</td>
												<td> 
													Redaksi
												</td>
												<td>
													del
												</td>
											</tr>
											<?php 
											if ($info_bas!=''){
												$jenis_agenda_id=0;$i=1;
												foreach ($info_bas as $row) {
													echo "<tr>";
													echo "<td>";
													echo $i;
													echo "</td>";
													echo "<td>";
													echo $row->nama_agenda;
													echo "</td>";
													echo "<td hidden>";
													echo "<label class=''konten'>".$row->redaksi."</label>";
													echo '<input type="text" value="'.$row->jenis_agenda_id.'" name="agenda_id[]">
															<input type="text" value="'.$row->agenda_id.'" name="id[]">';
													if($row->isian!='tidak ada' && $row->isian!=null){
														$arr=explode("||||", $row->isian);
														echo '<textarea class="textarea" type="text" name="'.$arr[0].'" >'.$arr[1].'</textarea>';
													}
													if((strpos($row->type,'tanya_jawab') !== false)){
														echo "<table>";
														echo "<tr>";
														echo "	<td>";
														echo "		No";
														echo "	</td>";
														echo "	<td>";
														echo "		Sumber";
														echo "	</td>";
														echo "	<td>";
														echo "		Penanya";
														echo "	</td>";
														echo "	<td>";
														echo "		Pertanyaan";
														echo "	</td>";
														echo "	<td>";
														echo "		Jawaban";
														echo "	</td>";
														echo "	<td>";
														echo "		Keterangan";
														echo "	</td>";
														echo "</tr>";
														$x=1;
														foreach ($info_tanya_jawab as $val) {
															if ($val->jenis_agenda_id==$row->jenis_agenda_id){
																echo "<tr>";
																echo "	<td>";
																echo $x;
																echo "	</td>";
																echo "	<td>";
																if ($val->pihak_ke=='13'){
																	$nama='s'.$x;
																}elseif ($val->pihak_ke=='2'){
																	$nama='t'.$x;
																}
																echo "		<input name='pihak_ke__".$nama."' value='".$val->pihak_ke."'>";
																echo "		<input name='sumber_id__".$nama."' value='".$val->sumber_id."'>";
																echo "		<input name='urutan_sumber__".$nama."' value='".$val->urutan_sumber."'>";
																echo "	</td>";
																echo "	<td>";
																echo "		<input name='penanya_t__".$nama."' value='".$val->penanya_t."'>";
																echo "		<input name='urutan_penanya__".$nama."' value='".$val->urutan_penanya."'>";
																echo "	</td>";
																echo "	<td>";
																echo "		<input name='pertanyaan_t__".$nama."' value='".$val->pertanyaan_t."'>";
																echo "		<input name='urutan_pertanyaan__".$nama."' value='".$val->urutan_pertanyaan."'>";
																echo "	</td>";
																echo "	<td>";
																echo "		<input name='jawaban_t__".$nama."' value='".$val->jawaban_t."'>";
																echo "	</td>";
																echo "	<td>";
																echo "		<input name='kenal__".$nama."' value='".$val->kenal."'>";
																echo "		<input name='tanggapan_terdakwa__".$nama."' value='".$val->tanggapan_terdakwa."'>";
																echo "	</td>";
																echo "</tr>";
																$x++;
															}
														}
														echo "</table>";
													}
													echo "</td><td>[<a ahref='' class='delete_agenda'>hapus</a>]</td>";
													echo "</tr>";
													$i++;
												}
											}
											?>
											</tbody>
										</table>
										[<a href="#" onClick="tambah_agenda('<?php echo base_url('setting_bas/tambah_agenda/');?>')">Tambah</a>]
									</div>
								</td>
							</tr>
							<tr>
								<td colspan="2" class="divider">Penutup</td>
							</tr>
							<tr>
								<td>Penutup</td>
								<td>
									<span class="custom-dropdown custom-dropdown--emerald" style="width:200px">
										<select id="penutupan" name="penutupan" style="width:200px" class="custom-dropdown__select custom-dropdown__select--white">
											<?php if (!empty($list_penutupan)){
												foreach ($list_penutupan->result() as $row) {
													$selected=$row->id==$penutup_id?'selected':'';
													echo "<option value='".$row->id."' ".$selected.">".$row->preview."</option>";
												}
											}
											?>
										</select>
									</span>
								</td>
							</tr>
							<tr>
								<td colspan="2" class="buttongroup">
									<input type="button" id='print' value="Cetak" class="btn">
									<input type="button" id='clloss' value="Kembali" class="btn">
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</table>
	</div>
</div>
<script type="text/javascript">

function tambah_agenda(url){
	var no_urut = ($('#table_agenda tr').length);
	popup_tambah_agenda(url+'/'+no_urut+'/<?php echo $alur_perkara_id."/".$enc;?>');
}

function popup_tambah_agenda(url){
	$('#popup_form_3rd').remove();
    $('<div id="popup_form_3rd" class="popup"><div id="form_pop_3rd"></div></div>').appendTo( "body" );
    $('#form_pop_3rd').load(url);
    $("#form_pop_2nd").hide();
    $("body").css({ overflow: 'hidden' })
    $('#popup_form_3rd').fadeIn('slow');
}
$("#clloss").click(function() {
	$('#popup_form').fadeIn();
	$('#popup_form_2nd').fadeOut();
    $("body").css({overflow: 'hidden'});    
});
$('#print').click(function(){
	var tes=$('#table_agenda :input').serializeArray();
	var penutup = {penutup:$('#penutupan').val()};
	$('#form_cetak_post_bas').remove();
	<?php 
	if($this->session->userdata('jenis_pengadilan')==4){
	?>
		buka('POST', '<?php echo base_url("setting_bas_agama_c/cetak")?>/<?php echo $enc; ?>/<?php echo $arr_info_sidang["id"]; ?>', tes, penutup, '_blank');
	<?php
	}else{
	?>
		buka('POST', '<?php echo base_url("setting_bas_c/cetak")?>/<?php echo $enc; ?>/<?php echo $arr_info_sidang["id"]; ?>', tes, penutup, '_blank');
	<?php
	}
	?>
	$('#form_cetak_post_bas').remove();
});
$("#table_agenda").on('click','.delete_agenda',function(){
	$(this).parent().parent().remove();
});

buka = function(verb, url, data, penutup, target) {
  var form = document.createElement("form");
  form.id = "form_cetak_post_bas";
  form.action = url;
  form.method = verb;
  form.target = target || "_blank";
  if (data) {
    for (var key in data) {
      var input = document.createElement("textarea");
      input.name = key;
      input.value = typeof data[key] === "object" ? JSON.stringify(data[key]) : data[key];
      form.appendChild(input);
    }
  }
  if (penutup){
  	for (var key in penutup) {
      var input = document.createElement("textarea");
      input.name = key;
      input.value = typeof penutup[key] === "object" ? JSON.stringify(penutup[key]) : penutup[key];
      form.appendChild(input);
    }
  }
  form.style.display = 'none';
  document.body.appendChild(form);
  form.submit();
};
</script>