<div class="container-fluid" > 	
<div class="row mb-2" >	   
        <div class="card"  style="padding:2;" >
            <div class="card-body text-center"  style="padding:2;" >         				
			<div id="output-list">
			<div class="d-flex justify-content-start align-items-center">				
					<table class="table table-bordered w-100">
                        <tbody>						
                            <tr>
                                <td class="text-end fw-bold" style="width:50px;">								
									출고 
                                <td style="width:130px;">
									<input type="date" id="outdate" name="outdate" class="form-control"  value="<?=$outdate?>"  >
								</td>
                                <td class="text-end fw-bold" style="width:50px;"> 접수 </td>
                                  <td style="width:130px;">
									<input type="date" id="indate" name="indate" class="form-control" value="<?=$indate?>"  > 																	
								</td>
                                <td class="text-end fw-bold" style="width:90px;"> 발주 작성 </td>
                                  <td style="width:130px;">
									<input type="date" id="orderdate" name="orderdate" class="form-control" value="<?=$orderdate?>"  > 																	
								</td>
								<td class="text-end fw-bold" style="width:80px;"> 제품코드 </td>
								<td class="text-center" style="width:130px;"> 
									<!-- 제품모델(KSS01 등) 선택 -->
									<?php  selectModel('prodCode', $prodCode);  ?>										
								</td>								
								<td class="text-end fw-bold" style="width:250px;">	
									<div class="d-flex justify-content-end align-items-center">									
										<?php if ($mode === '' || $mode === 'insert' || $mode === 'copy' || $mode === 'modify'): ?>
										<label for="createAutoCode" class="text-primary fw-bold" > 로트번호 자동생성 </label> &nbsp;	
											<input type="checkbox" id="createAutoCode" name="createAutoCode" >
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;										
										<?php endif; ?>
										 로트번호 	
										</div>
								</td>
                                <td class="text-center" style="width:150px;"> 
									<input type="text" id="lotNum" name="lotNum" class="form-control text-start" value="<?=$lotNum?>" autocomplete="off" >															
								</td>
                                <td class="text-end fw-bold" style="width:80px;"> 인증번호 </td>
                                <td class="text-center" style="width:250px;"> 
									<input type="text" id="warrantyNum" name="warrantyNum" class="form-control text-start" value="<?=$warrantyNum?>"  autocomplete="off" >																	
								</td>                               
							</tr>								
                        </tbody>
                    </table>                    
				</div>						  
			     <div class="row">				
			     <div class="col-sm-8">				
					<div class="d-flex justify-content-start align-items-center">				
					<table class="table table-bordered table-sm ">
                        <tbody>						
                            <tr>                               
                                <td class="text-center fw-bold w50px" > 진행 </td>
                                <td style="width:250px;">
								 <?php
									$aryreg=array();
									 switch ($regist_state) {
										case   "등록"           : $aryreg[0] = "checked" ; break;
										case   "수정"           : $aryreg[1] = "checked" ; break;
										case   "접수"           : $aryreg[2] = "checked" ; break;
										case   "완료"           : $aryreg[3] = "checked" ; break;
										default: break;
									}		 											 
								?>
									&nbsp;   등록       <input  type="radio" <?=$aryreg[0]?> name="regist_state" value="등록">
									&nbsp;   수정       <input  type="radio" <?=$aryreg[1]?> name="regist_state" value="수정">
									&nbsp;   접수       <input  type="radio" <?=$aryreg[2]?> name="regist_state" value="접수">
									&nbsp;   완료       <input  type="radio" <?=$aryreg[3]?> name="regist_state" value="완료">	  								
								</td>
                                <td class="text-center fw-bold" style="width:50px;"> 회사 </td>
								<td style="width:150px;">
									<?php
									if ($root == null) {
										$root = "주일";
									}
									?>
									<label>
										주일 <input type="radio" name="root" id="root" value="주일" <?= $root == "주일" ? 'checked' : '' ?>>
									</label>
									&nbsp;
									<label>
										경동 <input type="radio" name="root" id="root" value="경동" <?= $root == "경동" ? 'checked' : '' ?>>
									</label>
								</td>                                
								<td >
									<?php									
									$steelChecked = ($steel == "1") ? 'checked' : '' ;           // 절곡체크가 steel 임.
									$motorChecked = ($motor == "1") ? 'checked' : '';           // 모터가 들어가는지 체크
									$warrantyChecked = ($warranty == "인정") ? 'checked' : '';	// 인정제품인지 체크				
									$slatChecked = ($slatcheck == "1") ? 'checked' : '';        // 주자재(스크린,철재) 체크
									$partsChecked = ($partscheck == "1") ? 'checked' : '';      // 부자재 체크
									?>
									<div class="d-flex align-items-center justify-content-center">
									<h6>
									<label for="warranty">																			
										<input type="checkbox" id="warranty" data-readonly="true" name="warranty" value="인정" <?= $warrantyChecked ?> onchange="toggleOtherCheckboxes(this)"> 
										<span class="badge bg-primary-subtle border border-primary-subtle text-primary-emphasis rounded-pill me-1"> 인정 </span>
									</label>
									<label for="slatcheck">									
										<input type="checkbox" id="slatcheck" data-readonly="true" name="slatcheck" value="1" <?= $slatChecked ?>> 
										<span class="badge bg-info-subtle border border-info-subtle text-info-emphasis rounded-pill me-1"> 주자재(스크린,철재) </span>
									</label>									
									<label for="motor">									
										<input type="checkbox" id="motor" data-readonly="true" name="motor" value="1" <?= $motorChecked ?>> 
										<span class="badge bg-success-subtle border border-success-subtle text-success-emphasis rounded-pill me-1"> 모터 </span>
									</label>
									<label for="steel">											
										<input type="checkbox" data-readonly="true" id="steel" name="steel" value="1" <?= $steelChecked ?>> 
										<span class="badge bg-secondary-subtle border border-secondary-subtle text-secondary-emphasis rounded-pill me-1"> 절곡 </span>
									</label>
									<label for="partscheck">									
										<input type="checkbox" id="partscheck" data-readonly="true" name="partscheck" value="1" <?= $partsChecked ?>>  
										<span class="badge bg-danger-subtle border border-danger-subtle text-danger-emphasis rounded-pill me-1"> 부자재 </span>
									</label>
									</h6>
									</div>
									
									<script>
									function toggleOtherCheckboxes(warrantyCheckbox) {
										// 나머지 4개 체크박스 ID들
										const otherCheckboxes = ['slatcheck', 'motor', 'steel', 'partscheck'];
										
										// 인정 체크박스가 체크되었는지 확인
										const isChecked = warrantyCheckbox.checked;
										
										// 나머지 체크박스들을 모두 동일한 상태로 설정
										otherCheckboxes.forEach(function(checkboxId) {
											const checkbox = document.getElementById(checkboxId);
											if (checkbox) {
												checkbox.checked = isChecked;
											}
										});
									}
									</script>
								</td>
                                <td class="text-center fw-bold" style="width:50px;"> 담당 </td>
								<td style="width:80px;">
									<input type="text"  id="orderman" name="orderman" value="<?=$orderman?>" class="form-control" placeholder="담당자" > 
								</td>   
							</tr>								
                        </tbody>
                    </table>                    
				</div>
				<div class="d-flex align-items-center ">
					<table class="table table-bordered ">
						<tbody>						
							<tr>
								<td class="text-end" style="width:80px;">발주처</td>
								<td style="width:350px;"> 
									<div class="d-flex align-items-center justify-content-center"> 
										<input type="text" id="secondord" name="secondord" value="<?=$secondord?>" class="form-control text-start w-80"  autocomplete="off"   onkeydown="if(event.keyCode == 13) { phonebookBtn('secondord'); }"> &nbsp;
										<button type="button" id="searchsecondord" class="btn btn-primary  searchsecondord  btn-sm"  onclick="phonebookBtn('secondord');" > <i class="bi bi-search"></i> </button> 	 	 
										<!-- <button type="button" class="btn btn-dark-outline btn-sm restrictbtn" onclick="phonebookBtn('secondord');"> <ion-icon name="settings-outline"></ion-icon> </button> -->
									</div>
								</td> 
								<td class="text-end" >담당자</td>
								<td style="width:100px;"> 
									<input type="text" id="secondordman" name="secondordman" class="form-control  text-start"  autocomplete="off"  value="<?=$secondordman?>"  onkeydown="if(event.keyCode == 13) { phonebookBtn('secondordman'); }">				  									  
								</td>
								<td class="text-end" > <i class="bi bi-telephone-forward-fill"></i> 연락처 </td>
								<td style="width:130px;"> 
									<input type="text" id="secondordmantel" name="secondordmantel" value="<?=$secondordmantel?>"  autocomplete="off"  class="form-control  text-start" style="width:140px;"  onkeydown="if(event.keyCode == 13) { phonebookBtn('secondordmantel'); }">									
								</td>	
                               <td class="text-end" > 발주처 Code </td>
								<td style="width:80px;">
									<input type="text"  id="secondordnum" name="secondordnum" value="<?=$secondordnum?>" class="form-control" placeholder="발주처code" > 
								</td>                              															
                               <td class="text-end" > 견적 Code </td>
								<td style="width:80px;">
									<input type="text"  id="estimate_num" name="estimate_num" value="<?=$estimate_num?>" class="form-control" placeholder="견적code" > 
								</td>                              															
							</tr>								
						</tbody>
					</table>
				</div>
				</div>
					<div class="col-sm-4">						
						<div class="d-flex align-items-center ">						
							<table class="table table-bordered table-sm" style="border: 2px solid brown;">
								<tbody>						
									<tr>
									<td colspan="5" class="text-center">											
										<div class="d-flex align-items-center justify-content-center"> 
											<span  class="badge bg-danger " data-bs-toggle="tooltip" data-bs-placement="bottom" title=" 인정검사 요청이 오면 접수일자를 입력합니다." > 인정검사 </span> 
											<span  class="mx-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="같은 현장별 그룹화 작업, 그룹코드" > 그룹명 </span> 											
											<input type="text" id="ACIgroupName" name="ACIgroupName"  value="<?=$ACIgroupName?>" class="form-control  text-start w220px mx-1"  placeholder="품질관리서명 "  onkeydown="if(event.keyCode == 13) { acigroupBtn(); }"  autocomplete="off" > 								
											
											 <button type="button" id="fetch_loadgroupBtn" class="btn btn-primary  fetch_loadgroupBtn btn-sm"  onclick="acigroupBtn(); return false;" > <i class="bi bi-search"></i> </button> 	 	 
											<span  class="mx-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="품질관리서번호" > 품질관리서<br>번호 </span> 											
											<input type="text" id="ACIgroupCode" name="ACIgroupCode"  value="<?=$ACIgroupCode?>" class="form-control  text-start w120px mx-1"  placeholder="그룹코드"> 
									 
										</div>
									</td>																			
									</tr>				
									<tr>										
										<td style="width:80px;"> 접수 </td> 										
										<td style="width:80px;"> 요청 </td> 										
										<td style="width:80px;"> 완료 </td> 										
										<td style="width:80px;"> 제외 </td> 										
										<td style="width:100px;"> 메모 </td> 										
									</tr>				
									<tr>
									<td>
										<input
											type="date"
											id="ACIregDate"
											name="ACIregDate"
											class="form-control w60"
											autocomplete="off"
											value="<?= $ACIregDate !== '0000-00-00' ? $ACIregDate : '' ?>"
										>
										</td>
										<td>
										<input
											type="date"
											id="ACIaskDate"
											name="ACIaskDate"
											class="form-control w60"
											autocomplete="off"
											readonly
											value="<?= $ACIaskDate !== '0000-00-00' ? $ACIaskDate : '' ?>"
										>
										</td>
										<td>
										<input
											type="date"
											id="ACIdoneDate"
											name="ACIdoneDate"
											class="form-control"
											autocomplete="off"
											readonly
											value="<?= $ACIdoneDate !== '0000-00-00' ? $ACIdoneDate : '' ?>"
										>
										</td>									
										<td> 
											<input type="checkbox" id="ACIcheck" name="ACIcheck" style="width:25px;" value="1" <?= $ACIcheck == '1' ? 'checked' : '' ?> >
										</td>										
										<td> 
											<input type="text" id="ACImemo" name="ACImemo" class="form-control "  autocomplete="off"  value="<?=$ACImemo?>" >				  									  
										</td>										
									</tr>								
								</tbody>
							</table>						
					</div>
				  </div>  <!-- end of com-sm -->						
				</div>  <!-- end of row -->						
				
				
                <div class="d-flex justify-content-start align-items-center">					
				    <table class="table table-bordered table-sm ">
                        <tbody>						                            
                            <tr>
                                <td class="text-end" style="width:80px;"> 현 장 명 </td>
                                <td  style="width:400px;">	
									<div class="d-flex p-1 mb-1  justify-content-start align-items-center ">
										<input type="text" id="outworkplace" name="outworkplace"  value="<?=$outworkplace?>" class="form-control searchplace text-start w-90 me-1"  placeholder="주일은 현장명 경동은 업체명"> 
										 <button type="button" id="searchplace" class="btn btn-primary  searchplace  fetch_outworkplaceBtn btn-sm"> <i class="bi bi-search"></i> </button> 	 	 
											 </div> <span class="text-danger"> (주일공사는 현장명 검색 후 선택해야 출고가 연계됨) </span>									
								</td>								
                                <td class="text-center"  style="width:50px;"> 									
										<span class="text-dark fw-bold"> 공사 <br> 번호 </span>										 
								</td>								
                                <td class="text-center"  style="width:60px;"> 									
									<input type="text" id="con_num" name="con_num" value="<?=$con_num?>" class="form-control " placeholder="주일공사">
								</td>								
                                <td class="text-end" style="width:40px;"> 배송<br>방식 </td>
                                <td style="width:400px;" class="text-start"  >									 
									<?php
									if ($delivery == null) {
										$delivery = "상차(선불)";
									}

									$deliveryOptions = [
										"상차(선불)" => "checked", 
										"상차(착불)" => "", 
										"경동화물(선불)" => "", 
										"경동화물(착불)" => "", 
										"경동택배(선불)" => "", 
										"경동택배(착불)" => "", 
										"직접배차" => "", 
										"직접수령" => "", 
										"대신화물(선불)" => "", 
										"대신화물(착불)" => "", 
										"대신택배(선불)" => "", 
										"대신택배(착불)" => ""
									];

									if (array_key_exists($delivery, $deliveryOptions)) {
										$deliveryOptions[$delivery] = "checked";
									}
									?>
									
										&nbsp; 상차(선불) <input type="radio" <?= $deliveryOptions["상차(선불)"] ?> name="delivery" value="상차(선불)">
										&nbsp; 상차(착불) <input type="radio" <?= $deliveryOptions["상차(착불)"] ?> name="delivery" value="상차(착불)"> 
										&nbsp; 직접배차 <input type="radio" <?= $deliveryOptions["직접배차"] ?> name="delivery" value="직접배차">
										&nbsp; 직접수령 <input type="radio" <?= $deliveryOptions["직접수령"] ?> name="delivery" value="직접수령">
                                        <br>
										&nbsp; 경동화물(선불) <input type="radio" <?= $deliveryOptions["경동화물(선불)"] ?> name="delivery" value="경동화물(선불)">
										&nbsp; 경동화물(착불) <input type="radio" <?= $deliveryOptions["경동화물(착불)"] ?> name="delivery" value="경동화물(착불)">
										&nbsp; 경동택배(선불) <input type="radio" <?= $deliveryOptions["경동택배(선불)"] ?> name="delivery" value="경동택배(선불)">
										&nbsp; 경동택배(착불) <input type="radio" <?= $deliveryOptions["경동택배(착불)"] ?> name="delivery" value="경동택배(착불)">
                                        <br>
                                        &nbsp; 대신화물(선불) <input type="radio" <?= $deliveryOptions["대신화물(선불)"] ?> name="delivery" value="대신화물(선불)">
										&nbsp; 대신화물(착불) <input type="radio" <?= $deliveryOptions["대신화물(착불)"] ?> name="delivery" value="대신화물(착불)">
										&nbsp; 대신택배(선불) <input type="radio" <?= $deliveryOptions["대신택배(선불)"] ?> name="delivery" value="대신택배(선불)">
										&nbsp; 대신택배(착불) <input type="radio" <?= $deliveryOptions["대신택배(착불)"] ?> name="delivery" value="대신택배(착불)">									
								</td>	
                                <td style="width:400px;">
                                    <table class="table table-bordered table-sm text-end"  <?php echo $authority !== 'ACCOUNT' ? 'hidden' : ''; ?>>
                                        <thead >
                                            <tr>
                                                <td colspan="3" class="text-end"> 
													<button type='button' id='viewEstimateDetail' class='btn btn-success btn-sm mx-2 p-0'> <i class='bi bi-card-heading'></i> 인정제품 거래명세 </button>
													<button type="button" id="openUAaccountModal" class="btn btn-primary btn-sm mx-2 p-0"> <i class='bi bi-card-heading'></i> 비인정 거래명세 </button>
                                                    (VAT포함)
                                                </td>
                                            </tr>
                                            <tr>
                                                <th class="text-center">인정제품 금액</th>                                
                                                <th class="text-center">비인정제품 금액</th>
                                                <th class="text-center">총 금액</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>        
                                                <td>
                                                    <input type="text" id="estimateTotal" name="estimateTotal" class="form-control text-end" readonly 
                                                        value="<?= isset($estimateTotal) && $estimateTotal != 0 ? number_format($estimateTotal) : $estimateTotal ?>">
                                                </td>
                                                <td>
                                                    <input type="text" id="ET_unapproved" name="ET_unapproved" class="form-control text-end" readonly 
                                                        value="<?= isset($ET_unapproved) && $ET_unapproved != 0 ? number_format($ET_unapproved) : $ET_unapproved ?>">
                                                </td>
                                                <td>
                                                    <input type="text" id="ET_total" name="ET_total" class="form-control text-end" readonly 
                                                        value="<?= isset($ET_total) && $ET_total != 0 ? number_format($ET_total) : $ET_total ?>">
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>                            
                                </td>
                            </tr>
						</tbody>
					</table>
				</div>				
                <div class="d-flex mb-1 justify-content-center align-items-center">					
				    <table class="table table-bordered">
                        <tbody>						                            
                            <tr>
                                <td class="text-end" style="width:110px;"> 수신(반장/업체)  </td>
                                <td style="width:250px;">	
									<div class="d-flex p-1 mb-1  justify-content-start align-items-center ">
										<input type="text" id="receiver"  name="receiver" value="<?=$receiver?>" autocomplete="off" class="form-control w-90 me-1 text-start" placeholder="(작업반장/업체)"  > 
										<button type="button" class="btn btn-primary btn-sm fetch_receiverBtn" > <i class="bi bi-search"></i> </button> 	 	 									
									</div>
								</td>
											
                                <td class="text-end" style="width:100px;"> 수신처주소  </td>
                                <td style="width:400px;">										
										<input type="text" id="outputplace" name="outputplace" value="<?=$outputplace?>" autocomplete="off" class="form-control text-start " placeholder="현장주소 또는 납품처 주소 or 화물 영업소" > 									
								</td>
                                <td class="text-end w130px" >									
										<span class="text-dark fw-bold ms-2 me-2" > 수신처 연락처 </span>										
								</td>
                                <td class="text-start" >
									<input type="text" id="phone" name="phone" value="<?=$phone?>"   class="form-control text-start w150px" autocomplete="off"  placeholder="반장 or 업체"> 									
								</td>									
							</tr>						
						</tbody>
					</table>
				</div>
                <div class="d-flex mb-1 justify-content-center align-items-center">					
				    <table class="table table-bordered">
                        <tbody>						                            
                            <tr>
								<td class="text-end w40px"  > 비고 </td>
                                <td style="width:420px;" >	
									<div class="d-flex p-1 mb-1  justify-content-start align-items-center ">
										<textarea rows="3" id="comment" name="comment" class="form-control fs-6 text-dark "  style="height:64px;"  placeholder="내부 메시지를 남겨주세요." ><?=$comment?></textarea>
									</div>
								</td>		
								<td class="text-end fw-bold  text-danger w50px"> 수정<br>기록 </td>
                                <td style="width:420px;" >	
									<div class="d-flex p-1 mb-1  justify-content-start align-items-center ">
										<textarea rows="3" id="updatecomment" name="updatecomment"  style="height:64px;" class="form-control fs-6 text-danger " placeholder="수정사항 기록" ><?=$updatecomment?></textarea>
									</div> 
								</td>	
								<td class="text-end text-primary w80px"> 발주서,<br>출고증 등<br> 표시문구 </td>
                                <td style="width:420px;" >	
									<div class="d-flex p-1 mb-1  justify-content-start align-items-center ">
										<textarea rows="3" id="displayText" name="displayText" style="height:64px;" class="form-control fs-6 text-primary " placeholder="발주서 출고증 등 표시문구" ><?=$displayText?></textarea>
									</div> 
								</td>	
								<td class="text-start">   
									<h6> <span class="badge bg-secondary mb-1"><i class="bi bi-paperclip"></i> 첨부파일</span></h6> <br>																			
										<div class="d-flex  justify-content-start">  
											<!-- 파일 선택 -->
											<input type="file" id="upfile" name="upfile[]" multiple style="display:none;">
											<button class="btn btn-dark btn-sm me-4" type="button" onclick="document.getElementById('upfile').click();">
												<i class="bi bi-image"></i> </button>

											<!-- 드롭 영역 -->
											<div id="dropArea" style="border: 1px dashed #ccc; padding: 8px; width:320px; text-align: center;">
												파일 drop 영역
											</div>
											</div>
											<div class="d-flex mt-1 justify-content-start">  
											<!-- 파일 목록 표시 -->
												<div id="displayFile"></div>
											</div>																															
								</td>								
							</tr>													                           
                        </tbody>
                    </table>
                </div>
				
				</div>
        </div>
	 	     	 
	  </div> 
   </div>  
</div>  
	