<?php
	include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
	include $_SERVER['DOCUMENT_ROOT'].'/common/dealer_chk.php';

?>
<!DOCTYPE html>
<HTML lang="ko">
<head>
<meta charset="utf-8">
<title>UPRO</title>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="/m/css/sumogallery.css">
<link rel="stylesheet" type="text/css" href="/m/css/common.css">
<link rel="stylesheet" type="text/css" href="/m/css/sub.css">
<script type="text/javascript" charset="utf-8" src="/m/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/m/js/jquery.panzoom.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/m/js/ui.js"></script>
<script type="text/javascript" src="<?=JS_PATH?>"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" type="text/css" media="all" />

</head>

<body>
<!-- s : header -->
<? include("../inc/inc_header.php"); ?>
<!-- // e : header -->

<!-- s : container -->
<section id="container">
	<section id="visual" class="visual_mypage">
		<h2>마이페이지</h2>
		<p>쉽고 간편한 내차팔기, 견적산출,<br>최종 매각까지 어떤 수수료도 요구하지 않습니다.</p>
	</section>

	<section id="content">
	    <? include("./inc_menu_dealer.php") ?>
 <?
	$s_cd_dealer = $_SESSION['s_cd_dealer'];
	$s_cd_dealer_p = $_SESSION['s_cd_dealer_p'];
	$s_ds_type = $_SESSION['s_ds_type'];

	if($s_ds_type == "D0"){	//딜러
		$sql1 = " cd_dealer_p = '$s_cd_dealer' ";
	}else{	//딜러-관리자
		$sql1 = " cd_dealer = '$s_cd_dealer' ";
	}

	$cd_sale = $_REQUEST["cd_sale"];

	$sql ="SELECT
						a.*
						, b.nm_model
						, c.nm_grade
						, d.nm_brand
						, e.nm_model_sub
						, getCode('car_master','ds_type',a.ds_type) as nm_type
						, getCode('car_master','ds_year',a.ds_year) as nm_year
						, getCode('car_master','ds_open',a.ds_open) as nm_open
						, getCode('car_master','ds_sales',a.ds_sales) as nm_sales
						, getCode('car_master','ds_transmission',a.ds_transmission) as nm_transmission
						, getCode('car_master','ds_oil',a.ds_oil) as nm_oil
						, getCode('car_master','ds_accident',a.ds_accident) as nm_accident
						, getCode('sale_master','ds_usertype',s.ds_usertype) as nm_usertype
						, getCode('member_master','ds_area',s.ds_area) as nm_area
						, getCode('member_master','ds_area',s.ds_area_user) as nm_area_user
						, getCode('sale_master','ds_status',s.ds_status) as nm_status
						, s.nm_name nm_name_sale
						, s.ds_status ds_status_sale
						, s.nm_hp nm_hp_sale
						, s.nm_email nm_email_sale
						, s.ds_area ds_area_sale
						, s.nm_price nm_price_sale
						, s.nm_price_final nm_price_final_sale
						, s.nm_recommend nm_recommend_sale
						, s.nm_cont_return nm_cont_return_sale
						, s.nm_cont_tender_error nm_cont_tender_error_sale
						, s.ds_status_contract ds_status_contract_sale
						, s.ds_status_contract_step1 ds_status_contract_step1_sale
						, s.ds_status_contract_step2 ds_status_contract_step2_sale
						, s.ds_status_contract_step3 ds_status_contract_step3_sale
						, s.ds_status_contract_step4 ds_status_contract_step4_sale
						, s.nm_contract_date nm_contract_date_sale
						, s.nm_contract_cont_final nm_contract_cont_final_sale
						, s.nm_contract_fail_reason nm_contract_fail_reason_sale
						, s.nm_file_chk1 nm_file_chk1_sale
						, s.nm_file_chk2 nm_file_chk2_sale
						, s.nm_file_chk3 nm_file_chk3_sale
						, s.nm_file_chk4 nm_file_chk4_sale
						, s.nm_file_chk5 nm_file_chk5_sale
						, s.nm_file_trading nm_file_trading_sale
						, s.nm_file_performance nm_file_performance_sale
						, s.nm_file_postscript nm_file_postscript_sale
						, (select min(nm_price) from tender_master where cd_sale = '$cd_sale' and cd_dealer_p = '$s_cd_dealer_p' and ds_status = 'Z0') nm_price_tender
						, f.cd_tender cd_tender
						, f.ds_lock_status ds_lock_status
						FROM sale_master s
							inner join car_master a on (s.cd_car = a.cd_car)
							left outer join car_model b on (a.cd_model = b.cd_model)
							left outer join car_grade c on (a.cd_grade = c.cd_grade)
							left outer join car_brand d on (a.cd_brand = d.cd_brand)
							left outer join car_model_sub e on (a.cd_model_sub = e.cd_model_sub)
							left outer join tender_master f on (s.cd_sale = f.cd_sale and f.ds_status = 'Z0' and f.ds_delind = 'N')
						WHERE s.cd_sale='$cd_sale' ";

	$col=mysql_fetch_array(mysql_query($sql));
	if (!empty($col[cd_car])){

		$cd_car = $col[cd_car];
		$cd_model = $col[cd_model];
		$cd_brand = $col[cd_brand];
		$ds_logo = $col[ds_logo];
		$cd_category = $col[cd_category];
		$cd_grade = $col[cd_grade];
		$ds_cate = $col[ds_cate];
		$ds_type = $col[ds_type];
		$ds_year = $col[ds_year];
		$nm_name = $col[nm_name];
		$nm_price = $col[nm_price];
		$nm_mileage = $col[nm_mileage];
		$ds_driving_system = $col[ds_driving_system];
		$ds_transmission = $col[ds_transmission];
		$nm_file_list = $col[nm_file_list];
		$nm_file_main = $col[nm_file_main];
		$nm_file_report = $col[nm_file_report];
		$nm_file_report_back = $col[nm_file_report_back];
		$nm_file_front = $col[nm_file_front];
		$nm_file_back = $col[nm_file_back];
		$nm_file_side1 = $col[nm_file_side1];
		$nm_file_side2 = $col[nm_file_side2];
		$nm_file_dashboard = $col[nm_file_dashboard];
		$ds_oil = $col[ds_oil];
		$nm_gearbox = $col[nm_gearbox];
		$nm_color = $col[nm_color];
		$nm_incolor = $col[nm_incolor];
		$ds_accident = $col[ds_accident];
		$nm_cont_accident  = $col[nm_cont_accident];
		$nm_regdate = $col[nm_regdate];
		$ds_sales = $col[ds_sales];
		$nm_btitle = $col[nm_btitle];
		$nm_stitle = $col[nm_stitle];
		$nm_ltitle = $col[nm_ltitle];
		$nm_cont = $col[nm_cont];
		$nm_guide = $col[nm_guide];
		$ds_open = $col[ds_open];
		$ds_status = $col[ds_status];
		$dt_insert = $col[dt_insert];
		$nm_insert = $col[nm_insert];
		$dt_update = $col[dt_update];
		$nm_update = $col[nm_update];
		$ds_delind = $col[ds_delind];
		$nm_number = $col[nm_number];
		$nm_cc = $col[nm_cc];
		$ds_trade = $col[ds_trade];
		$ds_main = $col[ds_main];
		$nm_regdate_yyyy = $col[nm_regdate_yyyy];
		$nm_regdate_mm = $col[nm_regdate_mm];
		$nm_regdate_dd = $col[nm_regdate_dd];

		$nm_brand = $col[nm_brand];
		$nm_model = $col[nm_model];
		$nm_model_sub = $col[nm_model_sub];
		$nm_grade = $col[nm_grade];

		$nm_year = $col[nm_year];
		$nm_type = $col[nm_type];
		$nm_open = $col[nm_open];
		$nm_sales = $col[nm_sales];
		$nm_transmission = $col[nm_transmission];
		$nm_oil = $col[nm_oil];
		$nm_usertype = $col[nm_usertype];
		$nm_accident = $col[nm_accident];
		$nm_area = $col[nm_area];
		$nm_area_user = $col[nm_area_user];
		$nm_name_sale = $col[nm_name_sale];
		$ds_status_sale = $col[ds_status_sale];
		$nm_hp_sale = $col[nm_hp_sale];
		$nm_email_sale = $col[nm_email_sale];
		$ds_area_sale = $col[ds_area_sale];
		$nm_price_sale = $col[nm_price_sale];
		$nm_price_final_sale = $col[nm_price_final_sale];
		$nm_recommend_sale = $col[nm_recommend_sale];
		$nm_cont_return_sale = $col[nm_cont_return_sale];
		$nm_cont_tender_error_sale = $col[nm_cont_tender_error_sale];
		$ds_status_contract_sale = $col[ds_status_contract_sale];
		$ds_status_contract_step1_sale = $col[ds_status_contract_step1_sale];
		$ds_status_contract_step2_sale = $col[ds_status_contract_step2_sale];
		$ds_status_contract_step3_sale = $col[ds_status_contract_step3_sale];
		$ds_status_contract_step4_sale = $col[ds_status_contract_step4_sale];
		$nm_contract_date_sale = $col[nm_contract_date_sale];
		$nm_contract_cont_final_sale = $col[nm_contract_cont_final_sale];
		$nm_contract_fail_reason_sale = $col[nm_contract_fail_reason_sale];
		$nm_file_chk1_sale = $col[nm_file_chk1_sale];
		$nm_file_chk2_sale = $col[nm_file_chk2_sale];
		$nm_file_chk3_sale = $col[nm_file_chk3_sale];
		$nm_file_chk4_sale = $col[nm_file_chk4_sale];
		$nm_file_chk5_sale = $col[nm_file_chk5_sale];
		$nm_file_trading_sale = $col[nm_file_trading_sale];
		$nm_file_performance_sale = $col[nm_file_performance_sale];
		$nm_file_postscript_sale = $col[nm_file_postscript_sale];
		$nm_price_tender = $col[nm_price_tender];

		//보험처리
		$nm_act_chgno = $col[nm_act_chgno];
		$nm_act_chgnm = $col[nm_act_chgnm];
		$nm_act_s1 = $col[nm_act_s1];
		$nm_act_s2 = $col[nm_act_s2];
		$nm_act_s3 = $col[nm_act_s3];
		$nm_act_s4 = $col[nm_act_s4];
		$nm_act_my = $col[nm_act_my];
		$nm_act_my_amt = $col[nm_act_my_amt];
		$nm_act_other = $col[nm_act_other];
		$nm_act_other_amt = $col[nm_act_other_amt];
		$nm_act_searchdt = $col[nm_act_searchdt];
		$nm_act_cnt = $col[nm_act_cnt];
		$nm_act_general_spec = $col[nm_act_general_spec];
		$nm_act_use_record = $col[nm_act_use_record];
		$nm_act_use_record_lend = $col[nm_act_use_record_lend];
		$nm_act_use_record_biz = $col[nm_act_use_record_biz];
		$nm_act_use_record_official = $col[nm_act_use_record_official];
		$nm_act_ins_loss = $col[nm_act_ins_loss];
		$nm_act_ins_wet = $col[nm_act_ins_wet];
		$nm_act_ins_robbery = $col[nm_act_ins_robbery];
		$nm_file_act = $col[nm_file_act];
		$nm_act_yn = $col[nm_act_yn];

		$ds_g1_01 = $col[ds_g1_01];
		$ds_g1_02 = $col[ds_g1_02];
		$ds_g1_03 = $col[ds_g1_03];
		$ds_g1_04 = $col[ds_g1_04];
		$ds_g1_05 = $col[ds_g1_05];
		$ds_g2_01 = $col[ds_g2_01];
		$ds_g2_02 = $col[ds_g2_02];
		$ds_g2_03 = $col[ds_g2_03];
		$ds_g2_04 = $col[ds_g2_04];
		$ds_g2_05 = $col[ds_g2_05];
		$ds_g3_01 = $col[ds_g3_01];
		$ds_g3_02 = $col[ds_g3_02];
		$ds_g3_03 = $col[ds_g3_03];
		$ds_g3_04 = $col[ds_g3_04];
		$ds_g3_05 = $col[ds_g3_05];
		$ds_g4_01 = $col[ds_g4_01];
		$ds_g4_02 = $col[ds_g4_02];
		$ds_g4_03 = $col[ds_g4_03];
		$ds_g4_04 = $col[ds_g4_04];
		$ds_g4_05 = $col[ds_g4_05];

		$ds_lock_status = $col[ds_lock_status];

/*
		$arr_nm_info1 = explode("-",$nm_info1);
		if(count($arr_nm_info1) == 3){
			$nm_info11 = $arr_nm_info1[0];
			$nm_info12 = $arr_nm_info1[1];
			$nm_info13 = $arr_nm_info1[2];
		}else{
			$nm_info11 = "";
			$nm_info12 = "";
			$nm_info13 = "";
		}

		$arr_nm_info3 = explode("@",$nm_info3);
		if(count($arr_nm_info3) == 2){
			$nm_info31 = $arr_nm_info3[0];
			$nm_info32 = $arr_nm_info3[1];
		}else{
			$nm_info31 = "";
			$nm_info32 = "";
		}
		$nm_info3 = $col[nm_info3];
*/

	}else{
			AlertBack("지정되지않은 요청입니다");
	}

	$sql ="SELECT *
		FROM car_history_master mst
		WHERE  cd_car='$cd_car' AND ds_delind='N' and ds_type = 'user'";
	$history_col=mysql_fetch_array(mysql_query($sql));

	$r000  		= $history_col["r000"];
	$r001  		= $history_col["r001"];
	$r002  		= $history_col["r002"];
	$r004  		= $history_col["r004"];
	$r005  		= $history_col["r005"];
	$r101  		= $history_col["r101"];
	$r102  		= $history_col["r102"];
	$r103  		= $history_col["r103"];
	$r104  		= $history_col["r104"];
	$r105  		= $history_col["r105"];
	$r106  		= $history_col["r106"];
	$r107  		= $history_col["r107"];
	$r108  		= $history_col["r108"];
	$r109  		= $history_col["r109"];
	$r401  		= $history_col["r401"];
	$r402  		= $history_col["r402"];
	$r403  		= $history_col["r403"];
	$r404  		= $history_col["r404"];
	$r405  		= $history_col["r405"];
	$r406_01  	= $history_col["r406_01"];
	$r407  		= $history_col["r407"];
	$r408_01  	= $history_col["r408_01"];
	$r409  		= $history_col["r409"];
	$r410_01  	= $history_col["r410_01"];
	$r201  		= $history_col["r201"];
	$r202  		= $history_col["r202"];
	$r203  		= $history_col["r203"];
	$r204  		= $history_col["r204"];
	$r205  		= $history_col["r205"];
	$r510  		= $history_col["r510"];
	$r511_01  	= $history_col["r511_01"];
	$r501  		= $history_col["r501"];
	$r502  		= $history_col["r502"];
	$r301  		= $history_col["r301"];
	$r302  		= $history_col["r302"];
	$r303  		= $history_col["r303"];
	$r601  		= $history_col["r601"];
	$r602  		= $history_col["r602"];

?>


		<ul class="success_confirm">
			<li>
				<p>차량정보 확인  <? if($ds_status_contract_step1_sale != "Y"){ ?><span class="no">미확인</span><? }else{ ?><span>확인</span><? } ?></p>
				<div class="confirm_cont">
					<table class="tbl_h">
						<colgroup>
							<col width="32%">
							<col width="*">
						</colgroup>
						<tr>
							<th>차량번호</th>
							<td><?=$nm_number?></td>
						</tr>
						<tr>
							<th>제조사</th>
							<td><?=$nm_brand?></td>
						</tr>
						<tr>
							<th>모델</th>
							<td><?=$nm_model?></td>
						</tr>
                        	<tr>
							<th>세부모델</th>
							<td><?=$nm_model_sub?></td>
						</tr>
                        	<tr>
							<th>등급</th>
							<td><?=$nm_grade?></td>
						</tr>
                        	<tr>
							<th>연식(최초등록일)</th>
							<td><?=$nm_regdate_yyyy."년 ".$nm_regdate_mm."월"?></td>
						</tr>
                        	<tr>
							<th>형식연도</th>
							<td><?=$nm_year?>년</td>
						</tr>
                        	<tr>
							<th>배기량</th>
							<td><?=$nm_cc?>cc</td>
						</tr>

						<tr>
							<th>변속기</th>
							<td><?=$nm_transmission?></td>
						</tr>
						<tr>
							<th>연료</th>
							<td><?=$nm_oil?></td>
						</tr>
						<tr>
							<th>색상</th>
							<td><?=$nm_color?></td>
						</tr>
						<tr>
							<th>주행거리</th>
							<td><?=$nm_mileage?>km</td>
						</tr>
				<!--		<tr>
							<th>추천인</th>
							<td>없음</td>
						</tr>-->
						<tr>
							<th>사고유무</th>
							<td>
							<?=$nm_accident?><?=($ds_accident == "A0") ? " - ".$nm_cont_accident : "" ?>
							</td>
						</tr>
						<tr>
							<th>옵션</th>
							<td><?=$nm_cont?></td>
						</tr>
						<tr>
							<!-- 판매 희망지역 추가 -->
							<th>판매희망지역</th>
							<td>
								<?=$nm_area_user?>
							</td>
							<!-- 판매 희망지역 추가 -->
						</tr>
						<tr>
							<th>필수사진</th>
							<td>
								<!-- <ul class="photo_list">
									<li>
										<img src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_front?>" onclick="viewPhoto('<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_front?>')">
										<span>차량전면</span>
									</li>
									<li>
										<img src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_back?>" onclick="viewPhoto('<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_back?>')">
										<span>차량후면</span>
									</li>
									<li>
										<img src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side1?>" onclick="viewPhoto('<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side1?>')">
										<span>운전석 측면</span>
									</li>
									<li>
										<img src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side2?>" onclick="viewPhoto('<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side2?>')">
										<span>조수석 측면</span>
									</li>
									<li>
										<img src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_dashboard?>" onclick="viewPhoto('<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_dashboard?>')">
										<span>계기판</span>
									</li>
								</ul> -->
                <ul class="photo_list">
                  <li>
                    <img data-sgallery="group1" data-full="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_front?>" data-thumb="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_front?>" src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_front?>" title="차량전면">
                    <span>차량전면</span>
                  </li>
                  <li>
                    <img data-sgallery="group1" data-full="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_back?>" data-thumb="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_back?>" src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_back?>" title="차량후면">
                    <span>차량후면</span>
                  </li>
                  <li>
                    <img data-sgallery="group1" data-full="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side1?>" data-thumb="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side1?>" src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side1?>" title="운전석 측면">
                    <span>운전석 측면</span>
                  </li>
                  <li>
                    <img data-sgallery="group1" data-full="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side2?>" data-thumb="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side2?>" src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_side2?>" title="조수석 측면">
                    <span>조수석 측면</span>
                  </li>
                  <li>
                    <img data-sgallery="group1" data-full="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_dashboard?>" data-thumb="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_dashboard?>" src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$nm_file_dashboard?>" title="계기판">
                    <span>계기판</span>
                  </li>
                </ul>
							</td>
						</tr>
						<tr>
							<th>추가사진</th>
							<td>

                <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>-->
                    <li><img data-sgallery="group2" data-full="<?=UPLOAD_PATH_CAR?><?=$imgs[cd_car]?>_detail/<?=$imgs[nm_file]?>" data-thumb="<?=UPLOAD_PATH_CAR?><?=$imgs[cd_car]?>_detail/<?=$imgs[nm_file]?>" src="<?=UPLOAD_PATH_CAR?><?=$imgs[cd_car]?>_detail/<?=$imgs[nm_file]?>"></li>
                  <?
                      }
                    }else{
                  ?>
                  <?
                    }
                  ?>


                  <!--	<li><img src="/admin/img/@img_car.jpg"></li>
                    <li><img src="/admin/img/@img_car.jpg"></li>
                    <li><img src="/admin/img/@img_car.jpg"></li>-->
                  </ul>
							</td>
						</tr>
					</table>

					<h3>사고이력정보</h3>

					<!-- 사고이력정보 수정 -->
					<?
						//차량 보험처리 이력 요약 정보
						include_once($_SERVER['DOCUMENT_ROOT'].'/common/inc/inc_car_history_m_summary.php');
					?>

					<!-- //사고이력정보 수정 -->

					<div class="btn_center">
						<a href="#" class="button color-black" onclick="openLayer('car'); return false;">사고이력 정보 조회보기</a>
					</div>

                    	<h3></h3>
					<table class="tbl_h">
						<colgroup>
							<col width="28%">
							<col width="*">
						</colgroup>
						<tr>
							<th>입찰 참여 금액</th>
							<td><?=$nm_price_tender?> 만원</td>
						</tr>
					</table>

<? if($ds_status_contract_step1_sale != "Y" && $ds_status_contract_step1_sale != "N"){ ?>
	<?
		//차량 락이 걸려 있지 않아야 버튼이 노출
		if($ds_lock_status == 'Z0') {
	?>
					<div class="btn_center">
						<span class="fl"><a href="#" class="button" onclick="openLayer('estimate'); return false;">이상없는 견적입니다.</a></span>
						<span class="fr"><a href="#" class="button gray" onclick="openLayer('estimate2'); return false;">견적실수</a></span>
					</div>
    <? } ?>
<? } ?>



				</div>
			</li>
			<li>
				<p<? if($ds_status_contract_step1_sale != "Y"){ ?> noauth<? } ?>>고객통화 후 일정잡기 <? if($ds_status_contract_step2_sale != "Y"){ ?><span class="no">미확인</span><? }else{ ?><span>확인</span><? } ?></p>
				<div class="confirm_cont">

                <form id="frmFormStep2" name="frmFormStep2" method="post" action="dealer_proc.php" enctype="multipart/form-data">
<input type="hidden" id="mode" name="mode" value="ContractStep2">
<input type="hidden" id="cd_sale" name="cd_sale" value="<?=$cd_sale?>">

					<div class="schedule">
						<!-- calendar -->
						<div class="calendar">
							<input type="text" class="inp_txt" style="width:100%;text-align:center;" id="nm_contract_date" name="nm_contract_date" value="<?=$nm_contract_date_sale?>">
							<span class="btn_cal" id="btn_cal">&nbsp;달력보기</span>
						</div>
						<!-- // calendar -->
                        <div class="tel">
						<p class="name"><?=$nm_name_sale?><br><?=$nm_hp_sale?></p>

                        <? if($ds_status_contract_step2_sale != "Y"){ ?>
							<?
								//차량 락이 걸려 있지 않아야 버튼이 노출
								if($ds_lock_status == 'Z0') {
							?>
							<div class="btn_center">
								<a href="#" class="button" id="btn_contract_step2">확인</a>
							</div>
								<? } ?>
                            <? } ?>
</form>
						</div>
					</div>
				</div>
			</li>
			<li>
				<p<? if($ds_status_contract_step2_sale != "Y"){ ?> noauth<? } ?>>검차 결과 / 계약상황 입력하기  <? if($ds_status_contract_step3_sale != "Y"){ ?><span class="no">미확인</span><? }else{ ?><span>확인</span><? } ?></p>
				<div class="confirm_cont">


                <form id="frmFormStep3" name="frmFormStep3" method="post" action="dealer_proc.php" enctype="multipart/form-data">
<input type="hidden" id="mode" name="mode" value="ContractStep3">
<input type="hidden" id="cd_sale" name="cd_sale" value="<?=$cd_sale?>">

					<div class="deal_status">
						<h4>계약상황을 입력해주세요</h4>
						<p class="deal_check">
							<input type="radio" name="ds_status_contract" id="ds_status_contract" value="Z0"<? if($ds_status_contract_sale == "Z0"){ ?> checked="checked"<? } ?>><i></i><label for="deal_ok">거래완료</label>
							<input type="radio" name="ds_status_contract" id="ds_status_contract" value="B0"<? if($ds_status_contract_sale == "B0"){ ?> checked="checked"<? } ?>><i></i><label for="deal_dealy">거래연기</label>
							<input type="radio" name="ds_status_contract" id="ds_status_contract" value="C0"<? if($ds_status_contract_sale == "C0"){ ?> checked="checked"<? } ?>><i></i><label for="deal_fail">실패</label>
							<small>(※고객이 입력한 차량 내용과 차이가 있다면 검차결과 다른점을 입력해주세요.)</small>
						</p>
						<!-- 거래완료일 경우 -->
						<div class="deal_complete">
							<p class="my_price">내견적 : <strong><?=$nm_price_sale?></strong>만원 <span><input type="text" class="inp_txt" id="nm_price_final" name="nm_price_final" value="<?=$nm_price_final_sale?>"> 만원</span></p>
							<p><textarea cols="80" rows="8" placeholder="ex) 앞 휀다교환 1개-20만원, 앞범퍼 1판-7만원 20만원으로 최종조율, 다음주 수요일 인수예정" id="nm_contract_cont_final" name="nm_contract_cont_final"><?=$nm_contract_cont_final_sale?></textarea></p>
							<dl>
								<dt>검차사진(최대 5장, 선택)</dt>
								<dd>
									<div class="filebox">
										<label for="nm_file_chk1"<? if($nm_file_chk1_sale!=""){ ?> style="background-image:url('<?=UPLOAD_PATH?>dealer/contract_step/<?=$cd_sale?>_detail/<?=$nm_file_chk1_sale?>');background-size:cover;"<? } ?>>사진추가</label>
										<input class="upload-name" value="">
										<input type="file" name="nm_file_chk1" id="nm_file_chk1" class="upload-hidden" onchange="viewThumb(0,this)">
									</div>
								</dd>
								<dd>
									<div class="filebox">
										<label for="nm_file_chk2"<? if($nm_file_chk2_sale!=""){ ?> style="background-image:url('<?=UPLOAD_PATH?>dealer/contract_step/<?=$cd_sale?>_detail/<?=$nm_file_chk2_sale?>');background-size:cover;"<? } ?>>사진추가</label>
										<input class="upload-name" value="">
										<input type="file" name="nm_file_chk2" id="nm_file_chk2" class="upload-hidden" onchange="viewThumb(1,this)">
									</div>
								</dd>
								<dd>
									<div class="filebox">
										<label for="nm_file_chk3"<? if($nm_file_chk3_sale!=""){ ?> style="background-image:url('<?=UPLOAD_PATH?>dealer/contract_step/<?=$cd_sale?>_detail/<?=$nm_file_chk3_sale?>');background-size:cover;"<? } ?>>사진추가</label>
										<input class="upload-name" value="">
										<input type="file" name="nm_file_chk3" id="nm_file_chk3" class="upload-hidden" onchange="viewThumb(2,this)">
									</div>
								</dd>
								<dd>
									<div class="filebox">
										<label for="nm_file_chk4"<? if($nm_file_chk4_sale!=""){ ?> style="background-image:url('<?=UPLOAD_PATH?>dealer/contract_step/<?=$cd_sale?>_detail/<?=$nm_file_chk4_sale?>');background-size:cover;"<? } ?>>사진추가</label>
										<input class="upload-name" value="">
										<input type="file" name="nm_file_chk4" id="nm_file_chk4" class="upload-hidden" onchange="viewThumb(3,this)">
									</div>
								</dd>
								<dd>
									<div class="filebox">
										<label for="nm_file_chk5"<? if($nm_file_chk5_sale!=""){ ?> style="background-image:url('<?=UPLOAD_PATH?>dealer/contract_step/<?=$cd_sale?>_detail/<?=$nm_file_chk5_sale?>');background-size:cover;"<? } ?>>사진추가</label>
										<input class="upload-name" value="">
										<input type="file" name="nm_file_chk5" id="nm_file_chk5" class="upload-hidden" onchange="viewThumb(4,this)">
									</div>
								</dd>
							</dl>
						<!--	<div class="btn_center">
								<a href="#" class="button">확인</a>
							</div>-->
						</div>

						<!-- 거래연기 및 실패일 경우 -->
						<dl class="reason">
							<dt>거래 실패사유를 입력해주세요</dt>
							<dd><textarea cols="80" rows="8" id="nm_contract_fail_reason" name="nm_contract_fail_reason"><?=$nm_contract_fail_reason_sale?></textarea></dd>
						</dl>
					</div>
                    <? if($ds_status_contract_step3_sale != "Y"){ ?>
						<?
							//차량 락이 걸려 있지 않아야 버튼이 노출
							if($ds_lock_status == 'Z0') {
						?>
					<div class="btn_center">
						<a href="#" class="button" id="btn_contract_step3">확인</a>
					</div>
						<? } ?>
                    <? } ?>

</form>
				</div>
			</li>
			<li>
				<p<? if($ds_status_contract_step3_sale != "Y"){ ?> noauth<? } ?>>거래마무리 관리 <? if($ds_status_contract_step4_sale != "Y"){ ?><span class="no">미확인</span><? }else{ ?><span>확인</span><? } ?></p>
				<div class="confirm_cont">
					<form id="frmFormStep4" name="frmFormStep4" method="post" action="dealer_proc.php" enctype="multipart/form-data">
					<input type="hidden" id="mode" name="mode" value="ContractStep4">
					<input type="hidden" id="cd_sale" name="cd_sale" value="<?=$cd_sale?>">
					<dl class="deal_attach">
						<dt>상사이전등록증 등록(48시간 이내 등록해주세요)</dt>
						<dd>
							<div class="filebox">
								<label for="nm_file_trading">찾아보기</label>
								<input class="upload-name" value="">
								<input type="file" name="nm_file_trading" id="nm_file_trading" class="upload-hidden">
							</div>
						</dd>
						<dt>성능지 등록 (5일 이전것으로 등록해주세요)</dt>
						<dd>
							<div class="filebox">
								<label for="nm_file_performance">찾아보기</label>
								<input class="upload-name" value="">
								<input type="file" name="nm_file_performance" id="nm_file_performance" class="upload-hidden">
							</div>
						</dd>
						<dt>거래 후기 사진을 올려주세요(선택)</dt>
						<dd>
							<div class="filebox">
								<label  for="nm_file_postscript">찾아보기</label>
								<input class="upload-name" value="">
								<input type="file" name="nm_file_postscript" id="nm_file_postscript" class="upload-hidden">
							</div>
						</dd>
					</dl>
                    <? if($ds_status_contract_step4_sale != "Y"){ ?>
						<?
							//차량 락이 걸려 있지 않아야 버튼이 노출
							if($ds_lock_status == 'Z0') {
						?>
					<div class="btn_center">
						<a href="#" class="button" id="btn_contract_step4">등록</a>
					</div>
						<? } ?>
                    <? } ?>
					</form>
				</div>
			</li>
		</ul>






					<!-- layer popup -->
					<div class="layer_popup car_popup">
						<h3>중고차 보험처리 이력정보 보고서</h3>
						<p class="close">레이어팝업닫기</p>
						<!-- 사고이력정보 수정 -->
						<div class="scr_cont">
							<?
								//차량 보험처리 이력 전체 정보
								include_once($_SERVER['DOCUMENT_ROOT'].'/common/inc/inc_car_history_m.php');
							?>
						</div>
					</div>
					<!-- // layer popup -->

					<!-- layer popup2 -->
					<div class="layer_popup estimate_popup">
						<div class="popup_wrap">
							<p class="msg">견적에 이상이 없습니다.</p>
							<div class="btn_center">
								<a href="#" class="button" id="btn_contract_step1">이상없음</a>
								<a href="#" class="button gray" onclick="closeLayer('estimate'); return false;">아니요</a>
							</div>
						</div>
					</div>
					<!-- // layer popup2 -->


					<!-- layer popup3 -->
					<div class="layer_popup estimate2_popup">
                    <form id="frmFormStepError" name="frmFormStepError" method="post" action="dealer_proc.php" enctype="multipart/form-data">
<input type="hidden" id="mode" name="mode" value="ContractStepError">
<input type="hidden" id="cd_sale" name="cd_sale" value="<?=$cd_sale?>">
						<div class="popup_wrap">
							<dl>
								<dt><em>견적실수</em>에 대한 사유를 적어주세요</dt>
								<dd>
									<textarea cols="70" rows="8" id="nm_cont_tender_error" name="nm_cont_tender_error"><?=$nm_cont_tender_error_sale?></textarea>
									<p><em>관리자 확인 후 패널티 적용이 있을 수 있습니다.</em>다시 한번 더 확인 부탁 드립니다.</p>
								</dd>
							</dl>
							<div class="btn_center">
								<a href="#" class="button" id="btn_contract_step_error">확인</a>
							</div>
						</div>
                        </form>
						<div class="close">레이어팝업 닫기</div>
					</div>
					<!-- // layer popup3 -->



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

		<script language="javascript" type="text/javascript">
      $('.photo_list li').on('click',function(){

        $(".SumoGallery").find('.Sbody img').panzoom({
          minScale: 0.7,
          maxScale: 3,
          exponential: true,
          // 기본적으로 패닝 끔
          disablePan: true
        }).on("panzoomzoom", function(e, panzoom, scale, opts) {
          // 확대/축소 동작시 패닝 켬
          panzoom.options.disablePan = false;
        }).on("panzoomend", function(e, panzoom, matrix, changed) {
          // 제스처가 끝난 시점에
          // 1. scale이 1보다 작음
          // 2. 변화가 없었고 더블 탭으로 판명
          // 1 혹은 2번을 만족하면 리셋한다. (scale을 1로, pan을 제자리로)
          if (panzoom.scale <= 1 || (!changed && +new Date() - prevTapTime < 300)) {
            panzoom.reset();
            panzoom.options.disablePan = true;
          }
          prevTapTime = +new Date();
        }).on("panzoomend", function(e, panzoom, matrix, changed) {
          var rect = panzoom.$elem.find("img").get(0).getBoundingClientRect();
          var diffW = Math.max(rect.width - $root.width(), 0);
          var diffH = Math.max(rect.height - $root.height(), 0);
          var maxX = diffW / 2;
          var minX = -maxX;
          var maxY = diffH / 2;
          var minY = -maxY;
          var x = parseFloat(matrix[4]);
          var y = parseFloat(matrix[5]);

          // 확대된 상태에서 패닝시 이미지가 뷰포트를 벗어나지 못하게 한다.
          if (panzoom.scale > 1) {
            x = Math.max(minX, Math.min(x, maxX));
            y = Math.max(minY, Math.min(y, maxY));
            panzoom.pan(x, y, {
              animate: true,
              silent: true
            });
          }
        })
      })
			function viewPhoto(arg1){
				$("#photoBig").attr("src", arg1);
				openLayer('photo'); return false;
			}
		</script>
	</section>
</section>





<form id="frmFormStep1" name="frmFormStep1" method="post" action="dealer_proc.php">
<input type="hidden" id="mode" name="mode" value="ContractStep1">
<input type="hidden" id="cd_sale" name="cd_sale" value="<?=$cd_sale?>">
<input type="hidden" id="ds_status_contract_step1" name="ds_status_contract_step1" value="Y">
</form>

<script language="javascript" type="text/javascript">
	$("#nm_contract_date").datepicker({ dateFormat: 'yy-mm-dd' });

	function viewThumb(seq, arg){
/*
$('#img_select').change(function(){
setImageFromFile(this, '#preview');
});

function setImageFromFile(input, expression) {
    if (input.files && input.files[0])
    {
        var reader = new FileReader();

            reader.onload = function (e) {
                $(expression).attr('src', e.target.result);
           }
           reader.readAsDataURL(input.files[0]);
     }
}
[출처] jquery로 input file로 이미지 선택 시 바로 보이게 하기|작성자 내꺼는내꺼

.deal_complete dd .filebox label
*/
		if (arg.files && arg.files[0])
		{
			var reader = new FileReader();

			reader.onload = function (e) {
				$(".deal_complete dd .filebox label:eq("+seq+")").css("background","url('"+e.target.result+"')");
			}
			reader.readAsDataURL(arg.files[0]);
		}
	}

	$(document).ready(function() {

		$("#btn_cal").bind("click",function(){
			$("#nm_contract_date").datepicker('show');
		});

		$("#btn_contract_step1").bind("click",function(){
			var fieldlist = [["ds_status_contract_step1","확인여부"]]
			if (!fnCheckForm(fieldlist)){
				return false;
			}

			var c = confirm("처리하시겠습니까?");
			if(c){
				$("#frmFormStep1").submit();
			}else{
				return false;
			}
		});

		$("#btn_contract_step2").bind("click",function(){
			var fieldlist = [["nm_contract_date","일정 만남일"]]
			if (!fnCheckForm(fieldlist)){
				return false;
			}

			var c = confirm("처리하시겠습니까?");
			if(c){
				$("#frmFormStep2").submit();
			}else{
				return false;
			}
		});

		$("#btn_contract_step3").bind("click",function(){
//			alert($('input[name="ds_status_contract"]:checked').val());
			var fieldlist = [["ds_status_contract","계약 상황"]]
			if (!fnCheckForm(fieldlist)){
				return false;
			}

			//fnCheckForm에 radio를 체크 못하는 거 같아 수동으로 한번더 체크
			var checked_val = $('input[name="ds_status_contract"]:checked').val();
			if ($.trim(checked_val) == ""){
				alert("계약상황을 확인하세요");
				$('input[name="ds_status_contract"]:eq(0)').focus();
				return false;
			}

			if ($('input[name="ds_status_contract"]:checked').val() == "Z0"){
				fieldlist = [["nm_price_final","최종가격"]]
				if (!fnCheckForm(fieldlist)){
					return false;
				}
			}

			if ($('input[name="ds_status_contract"]:checked').val() == "C0"){
				fieldlist = [["nm_contract_fail_reason","거래 실패 사유"]]
				if (!fnCheckForm(fieldlist)){
					return false;
				}
			}

			var c = confirm("처리하시겠습니까?");
			if(c){
				$("#frmFormStep3").submit();
			}else{
				return false;
			}
		});

		$("#btn_contract_step4").bind("click",function(){
			var fieldlist = [["nm_file_trading","상사이전등록증"],["nm_file_performance","성능지"]]
			if (!fnCheckForm(fieldlist)){
				return false;
			}

			var c = confirm("처리하시겠습니까?");
			if(c){
				$("#frmFormStep4").submit();
			}else{
				return false;
			}
		});

		$("#btn_contract_step_error").bind("click",function(){
			var fieldlist = [["nm_cont_tender_error","견적 실수 사유"]]
			if (!fnCheckForm(fieldlist)){
				return false;
			}

			var c = confirm("처리하시겠습니까?");
			if(c){
				$("#frmFormStepError").submit();
			}else{
				return false;
			}
		});

	});

</script>

<!-- e : container -->

<!-- s : footer -->
<? include("../inc/inc_footer.html"); ?>
<!-- // e : footer -->
<script type="text/javascript" charset="utf-8" src="/m/js/jquery.sumogallery.js"></script>
</body>
</html>
<?
mysql_close($connect);
?>
