<?php
	$able_modify = false;
?>
<style>
.option_popup{
  width:100%;
  max-width:1200px;
  margin:0 auto;
}
.option_popup > h2{
  font-weight: 700;
  font-size: 18px;
  line-height: 100%;
  letter-spacing: -0.02em;
  color: #222222;
}

.option_popup > h2 .astc--text{
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: #1E75FF;
}
.option_popup > h2 .astc--text.ty2{
  color: #909EB5;
}

.option_popup .options--list{
  width:100%;
  border-top:1px solid #888;
  margin-top:20px;
  padding-top:40px;
}
.option_popup .options--list > h2{
  font-weight: 500;
  font-size: 14px;
  line-height: 100%;
  letter-spacing: -0.02em;
  color: #111111;
}
.option_popup .options--list > ul{
  display: flex;
  align-items: center;
  margin-top:30px;
  margin-bottom:50px;
}
.option_popup .options--list > ul >li{
  width:calc(100% / 4);
}
input[type="checkbox"] + label{
  font-weight: 350;
  font-size: 14px;
  line-height: 100%;
  color: #333333;
  display: flex;
  align-items:center;
  cursor: pointer;
}

input[type="checkbox"] + label:before{
  content:'';
  display: block;
  width:16px;
  height:16px;
  background:url(/design/staff/assets/img/check_off.svg) no-repeat center;
  margin-right:12px;
}
input[type="checkbox"]:checked + label:before{
  background:url(/design/staff/assets/img/check_on.svg) no-repeat center;
}


.option_popup .pic--add--wrap{
  display: flex;
  align-items: center;
  justify-content:space-between;
  width:100%;
  border-top:1px solid #888;
  margin-top:20px;
  padding-top:40px;
}
.option_popup .pic--add--wrap.bd-0{
  border:0px;
  padding-top:0px;
}

.option_popup .pic--add--wrap .add--box{
  width: 224px;
  height: 224px;
  display: flex;
  align-items: center;
  justify-content:center;
  flex-direction: column;

  background: #FFFFFF;
  border: 1px solid #EEEEEE;
  box-shadow: 0px 5px 5px rgba(239, 240, 241, 0.5);
  border-radius: 20px;
}
.option_popup .pic--add--wrap .add--box .thumb{
  width: 80px;
  height: 80px;
  border-radius: 80px;
  background: #F7F7F9;
  position: relative;
}

.option_popup .pic--add--wrap.view--type .add--box .thumb{
  width:200px;
  height:140px;
  border-radius:0px;
  margin:0 auto;
  overflow:hidden;
  background: transparent!important;
}

.option_popup .pic--add--wrap.view--type .add--box .thumb img{
  position: absolute;
  top:50%;
  left:50%;
  transform: translate(-50%, -50%);
  max-height:140px;
  max-width:200px;
  object-fit: cover;
}

.option_popup .pic--add--wrap.view--type .add--box.car--dashboard{
  position: relative;
}
.option_popup .pic--add--wrap.view--type .add--box.car--dashboard .thumb{
  height:204px;
  width:204px;
  position:absolute;
  top:50%;
  left:50%;
  transform: translate(-50%, -50%);
}
.option_popup .pic--add--wrap.view--type .add--box.car--dashboard .thumb img{
  width:100%;
  height:100%;
  max-width:204px;
  max-height:204px;
}
.option_popup .pic--add--wrap.view--type .add--box.car--dashboard .desc{
  z-index: 2;
  position: absolute;
  bottom:20px;
}



.option_popup .pic--add--wrap .add--box .thumb .add--btn{
  width: 26px;
  height: 26px;
  border-radius:26px;
  border: 1px solid #EDEFF1;
  box-shadow: 0px 2px 2px #DDE1E8;
  background:#fff url(../img/add_ic.svg) no-repeat center;
  position: absolute;
  top:0px;
  right:0px;
  cursor: pointer;
}

.option_popup .pic--add--wrap .add--box .thumb.car--01{ background:#f7f7f9 url(/design/staff/assets/img/car_pic01.svg) no-repeat center;}
.option_popup .pic--add--wrap .add--box .thumb.car--02{ background:#f7f7f9 url(/design/staff/assets/img/car_pic02.svg) no-repeat center;}
.option_popup .pic--add--wrap .add--box .thumb.car--03{ background:#f7f7f9 url(/design/staff/assets/img/car_pic03.svg) no-repeat center;}
.option_popup .pic--add--wrap .add--box .thumb.car--04{ background:#f7f7f9 url(/design/staff/assets/img/car_pic04.svg) no-repeat center;}
.option_popup .pic--add--wrap .add--box .thumb.car--05{ background:#f7f7f9 url(/design/staff/assets/img/car_pic05.svg) no-repeat center;}


.option_popup .pic--add--wrap .add--box .desc{
  font-weight: 350;
  font-size: 15px;
  line-height: 100%;
  text-align: center;
  letter-spacing: -0.02em;
  color: #000000;
  margin-top:10px;
}


.option_popup .pic--add--wrap.view--type .add--box .desc{
  background: #F3F5F8;
  border-radius: 50px;
  height:35px;
  display:inline-flex;
  align-items: center;
  padding:0 20px;

  font-weight: 350;
  font-size: 13px;
  text-align: center;
  letter-spacing: -0.02em;
  color: #000000;
}

.option_popup .pic--add--wrap .addition--box .thumb{
  background:#f7f7f9 url(../img/pic_ic.svg) no-repeat center;
}

.option_popup .pic--add--wrap .addition--box .add--btn{
  font-weight: 500;
  font-size: 12px;
  text-align: center;
  letter-spacing: -0.03em;
  color: #1E75FF;

  width: 100px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(30, 117, 255, 0.3);
  border-radius: 50px;
  cursor: pointer;
}
</style>
	<div class="area_title">
		<h3><em>▶</em> 소유주 정보</h3>
	</div>
	<div class="tbl_wrap">
		<table class="tbl_list2">
			<colgroup>
				<col width="12%">
				<col width="*">
			</colgroup>
			<tr>
				<th>소유주명</th>
				<td><?=$nm_name?></td>
			</tr>
			<tr>
				<th>차량번호</th>
				<td><?=$nm_number?></td>
			</tr>
			<tr>
				<th>판매자 연락처</th>
				<td><?=$nm_hp_sale?></td>
			</tr>
		</table>
	</div>

	<div class="area_title">
		<h3><em>▶</em> 차량 정보</h3>
	</div>
	<div class="tbl_wrap">
		<table class="tbl_list2">
			<colgroup>
				<col width="12%">
				<col width="38%">
				<col width="12%">
				<col width="38%">
			</colgroup>
			<tr>
				<th>제조사</th>
				<td><?=$nm_brand?></td>
				<th>모델</th>
				<td><?=$nm_model?></td>
			</tr>
			<tr>
				<th>연식(최초등록일)</th>
				<td><?=$nm_regdate_yyyy."년 ".$nm_regdate_mm."월"?></td>
				<th>형식연도</th>
				<td><?=$nm_year?>년</td>
			</tr>
			<tr>
				<th>배기량</th>
				<td><?=$nm_cc?>cc</td>
				<th>연료</th>
				<td><?=$ds_oil?></td>
			</tr>
			<tr>
				<th>색상</th>
				<td><?=$nm_color?></td>
				<th>주행거리</th>
			<?php
				if($able_modify) {
			?>
				<td>
					<input type='text' class="inp_txt" style="width:60px;" id='modify_nm_mileage' name='modify_nm_mileage' value='<?=$nm_mileage?>' /> km
					<!-- <a href="#" class="rnd_btn ty2 blue" onclick="changeNmMileage('<?=$cd_car?>', '<?=$cd_sale?>');return false;">수정</a> -->
				</td>
			<?php
				}else {
			?>
				<td><?=$nm_mileage?>km</td>
			<?php
				}
			?>
			</tr>
			<tr>
				<th>사고유무</th>
				<td>
			<?php
				if($able_modify) {
			?>
					<span class="select2" style="margin-right:5px;width:35%;">
						<select name="modify_ds_accident" id="modify_ds_accident" style='font: inherit;'></select>
					</span>
					<input name='nm_cont_accident' type='text' class="inp_txt" id='modify_nm_cont_accident'  value='<?=$nm_cont_accident?>' style="width:570px" />
			<?php
				}else{
			?>
					<?=$nm_accident?>&nbsp;<?=$nm_cont_accident?>
			<?php
				}
			?>
				</td>
				<th>판매지역</th>
				<td>
			<?php
				if($able_modify) {
			?>
				<span class="select2" style="margin-right:5px;width:35%;">
					<select name="modify_ds_area" id="modify_ds_area" style='font: inherit;'></select>
				</span>

			<?php
				}
				else {
			?>
				<?=$nm_area?>
			<?php
				}
			?>
				</td>
			</tr>
			<tr>
				<th>사업자 유,무 </th>
				<td>
			<?php
				if($able_modify) {
			?>
					<span class="select2" style="margin-right:5px;width:35%;">
						<select name="modify_ds_accident" id="modify_ds_accident" style='font: inherit;'></select>
					</span>
					<input name='nm_cont_accident' type='text' class="inp_txt" id='modify_nm_cont_accident'  value='<?=$nm_cont_accident?>' style="width:570px" />
			<?php
				}else{
			?>
					<?=$nm_accident?>&nbsp;<?=$nm_cont_accident?>
			<?php
				}
			?>
				</td>
				<th>추가옵션 및 특이사항</th>
				<td>
			<?php
				if($able_modify) {
			?>
				<span class="select2" style="margin-right:5px;width:35%;">
					<select name="nm_cont_pac" id="modify_ds_area" style='font: inherit;'></select>
				</span>

			<?php
				}
				else {
			?>
				<?=$nm_cont_pac?>
			<?php
				}
			?>
				</td>
			</tr>
			<tr>
				<th>희망 AAP SA </th>
				<td>
			<?php
				if($able_modify) {
			?>
					<span class="select2" style="margin-right:5px;width:35%;">
						<select name="modify_ds_accident" id="modify_ds_accident" style='font: inherit;'></select>
					</span>
					<input name='nm_cont_accident' type='text' class="inp_txt" id='modify_nm_cont_accident'  value='<?=$nm_cont_accident?>' style="width:570px" />
			<?php
				}else{
			?>
					<?=$aap_nm_name?> <button type="button" class="rnd_btn ty2 ty_s2 gray" style="margin-left:5px;" id="btn_aap_select">선택하기</button>
			<?php
				}
			?>
				</td>
				<th>판매시기</th>
				<td>
			<?php
				if($able_modify) {
			?>
				<span class="select2" style="margin-right:5px;width:35%;">
					<select name="nm_cont_pac" id="modify_ds_area" style='font: inherit;'></select>
				</span>

			<?php
				}
				else {
			?>
				<?=$ds_sale_period?>
			<?php
				}
			?>
				</td>
			</tr>
			
			<tr>
				<th>옵션정보</th>
				<td>
				<?php
					if(!empty($nm_cont_detail)) {
						$options = explode(",", $nm_cont_detail);
						if(!empty($options[0])) {
							$option_col=mysql_fetch_array(mysql_query("select getCode('car_master','ds_car_option_detail','$options[0]') as nm_name "));
						}
					}
				?>
				<?=$option_col['nm_name']?>  <button class="rnd_btn ty2 ty_s2 gray" style="margin-left:5px;" onclick="openLayer('option');">자세히보기</button>
				</td>
				<th>반려사유</th>
				<td><?=$nm_cont_return?></td>
			</tr>
			<tr>
				<th>관리자 코멘트</th>
				<td colspan="3">
			<?
				if($able_modify) {
			?>
				<textarea name="modify_nm_guide" id="modify_nm_guide"><?=$nm_guide?></textarea>
			<?}
				else {
			?>
				<?=$nm_guide?>
			<?
				}
			?>

				</td>
			</tr>

		</table>


		<!-- layer popup3 -->
		<div class="layer_popup photo_popup">
			<img src="/img/sell/ic_car_photo1.png" id="photoBig" style="width:500px;">
			<div class="close" onclick="closeLayer('photo');">레이어팝업 닫기</div>
		</div>
		<!-- // layer popup3 -->

		<!-- layer popup4 -->
		<div class="layer_popup option_popup">
			<h2>옵션정보</h2>
			<div class="options--list">
				<? include_once("../../common/inc/inc_car_option.php")?>
			</div>
			<div class="close" onclick="closeLayer('option');"></div>
		</div>
		<!-- // layer popup4 -->

	</div>

<?php
	$car_history_sql = "SELECT * FROM car_history_master WHERE cd_car_history = '$cd_car_history' AND ds_delind = 'N' AND ds_type = 'user' LIMIT 1 ";
	$car_history_res = mysql_query($car_history_sql);
	$car_history_col = mysql_fetch_array($car_history_res);
?>
	<div class="area_title">
		<h3><em>▶</em> 사고정보 이력</h3>
		<span class="select ty2" style='width:120px;'>
			<button type="button" class="rnd_btn ty3 blue" style="width:120px; height:29px;" id="btn_accident_view">사고정보 이력보기</button>
		</span>
	</div>
	<div class="tbl_wrap">
		<table class="tbl_list2">
			<colgroup>
				<col width="12%">
				<col width="*">
			</colgroup>
			<tr>
				<th>차량번호 변경</th>
				<td><?=number_format($car_history_col['r201'])?> 회</td>
			</tr>
			<tr>
				<th>소유주 변경</th>
				<td><?=number_format($car_history_col['r204'])?> 회</td>
			</tr>
			<tr>
				<th>자동차 보험 특수사고</th>
				<td>전손 : <?=number_format($car_history_col['405'])?>회 / 침수전(분)손 : <?=number_format($car_history_col['407'])?>회 / 도난 <?=number_format($car_history_col['r409'])?>회</td>
			</tr>
			<tr>
				<th>보험사고 (내차피해)</th>
				<td><?=number_format($car_history_col['r401'])?> 회 (<?=number_format($car_history_col['r402'])?> 원)</td>
			</tr>
			<tr>
				<th>보험사고 (타차가해)</th>
				<td><?=number_format($car_history_col['r403'])?> 회 (<?=number_format($car_history_col['r404'])?> 원)</td>
			</tr>

		</table>
	</div>

	<div class="area_title">
		<h3><em>▶</em> 차량 사진(필수사진)</h3>
	</div>
	<div class="tbl_wrap">
		<ul class="photo_list">
			<li>
				<?=getCarBasicThumbImage($cd_car, $nm_file_front, '차량전면', true, 'car_basic')?>
				<span>차량전면</span>
			</li>
			<li>
				<?=getCarBasicThumbImage($cd_car, $nm_file_back, '차량후면', true, 'car_basic')?>
				<span>차량후면</span>
			</li>
			<li>
				<?=getCarBasicThumbImage($cd_car, $nm_file_side1, '운전석 측면', true, 'car_basic')?>
				<span>운전석 측면</span>
			</li>
			<li>
				<?=getCarBasicThumbImage($cd_car, $nm_file_side2, '조수석 측면', true, 'car_basic')?>
				<span>조수석 측면</span>

			</li>
			<li>
				<?=getCarBasicThumbImage($cd_car, $nm_file_dashboard, '계기판', true, 'car_basic')?>
				<span>계기판</span>
			</li>
		</ul>

	</div>
	<div class="area_title">
		<h3><em>▶</em> 차량 사진(추가사진)</h3>
	</div>
	<div class="tbl_wrap">
		<ul class="photo_list">
		<?php
			if(!empty($cd_car)) {
				$sql = "SELECT *
							FROM car_file
								WHERE cd_car = '$cd_car'
									AND ds_delind='N'
							ORDER BY no_sort ASC, cd_car ASC ";

				// echo $sql;
				$r = mysqli_query($connect, $sql);
				$i=1;
				while($imgs = mysqli_fetch_assoc($r)) {
					// $car_additional_img = UPLOAD_PATH_CAR.$imgs['cd_car']."_detail/".$imgs['nm_file'];
		?>
			<li>
				<?=getCarAddtionalImage($cd_car, $imgs['nm_file'], '추가사진'.$i, true, 'car_additional')?>
			</li>
		<?php
					$i++;
				}
			}
		?>
		</ul>
		<!-- <ul class="photo_list">
		<?
			if(!empty($col['cd_car'])){
				$r = mysql_query("SELECT * FROM car_file WHERE cd_car = '$cd_car' and ds_type='' and ds_delind='N' Order by no_sort asc ,  cd_car ASC ");
				$i=1;
				while($imgs = mysql_fetch_array($r)) {
		?>
			<li><img src="<?=UPLOAD_PATH_CAR?><?=$imgs['cd_car']?>_detail/<?=$imgs['nm_file']?>" onclick="viewPhoto('<?=UPLOAD_PATH_CAR?><?=$imgs[cd_car]?>_detail/<?=$imgs['nm_file']?>')"></li>
		<?
				}
			}else{
		?>
		<?
			}
		?>
		</ul> -->
	</div>

	<div class="btn_right" style='padding-bottom:20px;'>
		<a href="#" class="rnd_btn ty1 blue" onclick="changeCarInfo('<?=$cd_car?>', '<?=$cd_sale?>');return false;">차량 정보 수정</a>
	</div>



<script laguage="javascript" type="text/javascript">

	function viewPhoto(arg1){

		$("#photoBig").attr("src", arg1);

		openLayer('photo'); return false;

	}

	function changeNmMileage(arg_cd_car, arg_cd_sale){

		$.post("proc.php", { mode:"changeMileage", cd_car: arg_cd_car, cd_sale: arg_cd_sale, nm_mileage: nm_mileage_val },function(data) {
			if(data=="Y"){
				alert("정상적으로 처리되었습니다.");
				return;
			}else if(data=="W") {
				alert("입찰대기, 입찰중 매물만 주행거리 수정이 가능합니다. ");
				return;
			}else if(data=="F") {
				alert("지정되지않은 요청입니다");
				return;
			}else{
				alert("정상적으로 처리되지 않았습니다.");
				return;
			}
		});

	}

	function changeCarInfo(arg_cd_car, arg_cd_sale) {
		var fieldlist = [["modify_cd_grade","등급"],["modify_ds_area","판매지역"],["modify_ds_accident","사고유무"],["modify_nm_mileage","주행거리"]] ;
		//,["modify_nm_guide","담당자코멘트"]

		if (!fnCheckForm(fieldlist)){
			return false;
		}

		var c = confirm("처리하시겠습니까?");
		if(c){
			var cd_grade = $("#modify_cd_grade").val();
			var ds_area = $("#modify_ds_area").val();
			var ds_accident = $("#modify_ds_accident").val();
			var nm_mileage_val = $("#modify_nm_mileage").val();
			var nm_guide_val = $("#modify_nm_guide").val();
			var nm_cont_accident = $("#modify_nm_cont_accident").val();


			$.post("proc.php", { mode:"changeCarInfo", cd_car: arg_cd_car, cd_sale: arg_cd_sale, cd_grade: cd_grade, ds_area: ds_area, ds_accident: ds_accident, nm_mileage: nm_mileage_val, nm_guide: nm_guide_val, nm_cont_accident : nm_cont_accident },function(data) {
				if(data=="Y"){
					alert("정상적으로 처리되었습니다.");
					return;
				}else if(data=="W") {
					alert("입찰대기, 입찰중 매물만 주행거리 수정이 가능합니다. ");
					return;
				}else if(data=="F") {
					alert("지정되지않은 요청입니다");
					return;
				}else{
					alert("정상적으로 처리되지 않았습니다.");
					return;
				}
			});
		}else{
			return false;
		}
	}

	$(function() {
		setCodeSelectJqTransForm("listGradeByModelSub","modify_cd_grade","car_grade","cd_grade",'<?=$cd_grade?>','선택하세요','<?=$cd_model_sub?>');
		setCodeSelectJqTransForm("listcode","modify_ds_accident", "car_master","ds_accident","<?=$ds_accident?>","선택하세요","");
		setCodeSelectJqTransForm("listcode","modify_ds_area", "member_master","ds_area","<?=$ds_area_sale?>","선택하세요","");


		//차량이력정보 보기 팝업
		$("#btn_accident_view").on("click", function() {
			viewPopup('history');
		});
	});

</script>
