<!-- eworks에서 모달 위에 띄우는 모달 창 결재 상세내역 -->
<div class="modal fade" id="eworks_viewmodal" tabindex="-1" role="dialog">
  <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-fullsm" role="document" >
    <div class="modal-content">
      <div class="modal-header" title="e결재 창">
        <h6 class="modal-title"> <ion-icon name="medkit-outline"> </ion-icon>  결재 </h6>
			<button type="button" class="btn btn-light-secondary close"   id="closeModaldetailBtn" >					
					<span class="d-none d-sm-block"><i class="bi bi-x"></i></span>
			</button>       
      </div>
      <div class="modal-body">
       <!-- 결재정보 -->
         <div class="row">		
		   <div class="col-sm-8">		
			</div>	
		   <div id="approvalTable" class="col-sm-4">								
			</div>
         </div>
		<div class="card">	   				
				<div class="card-body" id="eworks_viewcontents">						
				<div class="table-reponsive mb-2 ">
				<table class="table table-bordered">
				   <tbody>
				   
					 <tr class="align-items-center">
					   <td class="text-center" > 구분 </td>
							<td>
							<?php
								// eworks_item 목록 정의
								$eworksItems = [
									'일반',
									'연차',
									'품의서',
									'지출결의서',
									'원자재구매',
									'부자재구매',
									'일일지출내역서',
								];

								// 현재 선택된 값 (예: write_form.php 로딩 시)
								// $currentItem 에는 기존 데이터에서 불러온 $row['eworks_item'] 등을 할당합니다.
								$currentItem = $row['eworks_item'] ?? '일반';
								?>

								<select class="form-select" id="eworks_item" name="eworks_item" style="font-size:12px; height:30px;" onchange="eworksItemChanged(this)">
									<?php foreach ($eworksItems as $item): ?>
										<option value="<?= htmlspecialchars($item, ENT_QUOTES) ?>"
											<?= $item === $currentItem ? 'selected' : '' ?>>
											<?= htmlspecialchars($item) ?>
										</option>
									<?php endforeach; ?>
								</select>

							</td>
					  <td class="text-center" > 결제라인 </td>
					  <td>								
							<div class="d-flex justify-content-start">			
								<input type="text" class="form-control" id="e_line" name="e_line"  >                                                        		
								<input type="hidden"  id="e_line_id" name="e_line_id">
								<button type="button" class="form-control"  id="setLineBtn" onclick = "setLine();"  ><i class="bi bi-search"></i></button>
							</div>							  
					  </td>
					  <td class="text-center" > 작성일시 </td>
					   <td >
						  <input type="text" class="form-control" id="registdate"  name="registdate"  >                                                    
						  </td>
						<td class="text-center" > 작성자 </td>
						<td> 	
							<input type="text" class="form-control" id="author"  name="author" >                                                    
						</td>
					  </tr>
					  <tr class="align-items-center">
					  <td class="text-start" > 결제진행 </td>
					   <td colspan="3">
							 <input type="text" class="form-control text-start" readonly id="e_prograss"  name="e_prograss" >   
						</td>							  
						<td class="text-center" >참조 </td> 
						<td colspan="3">
							<div class="d-flex">			
								<input type="text" class="form-control" id="r_line" style="width:90%;" name="r_line"  >                                                        		
								<input type="hidden"  id="r_line_id" name="r_line_id">
								<button type="button" class="form-control" onclick="setRef();" style="width:8%;" ><i class="bi bi-search" ></i></button>	                                                  
							</div>							  
						</td>			
					  </tr>		
                      <tr class="align-items-center">				  
					  <td class="text-center" > 내용 </td>
					   <td  colspan="7">
							<div class="row d-flex justify-content-center " >
								<div id="htmlContainer">							  
									<textarea id="contents" class="form-control" name="contents" rows="10"><?= isset($contents) ? $contents : '' ?></textarea>
								</div>
							</div>
						</td>		
					  </tr>
						
				</tbody>
				</table>
				</div>					
					
					<div id="eworksBtn">																															 
							<?php  require_once($_SERVER['DOCUMENT_ROOT'] . '/eworks/eworksBtn.php'); ?>									
							
					</div>	
				</div>
			</div>
		</div>			
      <div class="modal-footer">
	    <span id="numdisplay"> </span>
        <button type="button"  class="btn btn-outline-dark btn-sm" id="closesecondModalBtn" > &times; 닫기</button>
      </div>
      </div>
    </div>
</div>
