<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/Helper/common.php");

$webhelper = new WebHelper();
$dbhelper = new dbHelper();
$sdihelper = new Sdihelper($dbhelper);

$LoginPkid = $webhelper->GetLoginPkid();
$LoginName = $webhelper->GetLoginName();

//LoginCheck
$PageCode = "050101";
$sno = "7"; //완공사례
//$title = "완공사례";
$title = "완공사례";
$PageUrl = "/gallery/completion_case01.php";
$PageName = "completion_case01";
$b_cate = "건축갤러리 상담신청"; //상담카테고리


//Parameter
$page = $webhelper->RequestFilter("page", 0, false);
$sch_b_show = $webhelper->RequestFilter("sch_b_show", 20, false);
$searchKey = $webhelper->RequestFilter("searchKey", -1, false);
$pkid = $webhelper->RequestFilter("pkid", 0, false);

$Parameter = "?page=$page&sch_b_show=$sch_b_show&searchKey=" . urlencode($searchKey);

//Parameter Check
if ($webhelper->isNull($page)) $page = 1;
if ($webhelper->isNull($sch_b_show)) $sch_b_show = "";
if ($webhelper->isNull($searchKey)) $searchKey = "";
if ($webhelper->isNull($pkid)) $pkid = 0;

$dbhelper->dbOpen();

//카테고리
$sql = "SELECT * FROM Web_board_set WHERE sno='$sno'";
$Cate = $dbhelper->RunSQLReturnOneRow($sql);
if($Cate["bs_cate"] != "")
	$CateArray=explode("|",$Cate["bs_cate"]);

if($pkid > 0)
{
	$sql = "select * from Web_board_data d left join Web_member m on d.mb_uid = m.mb_uid left join Web_board_set s on d.sno=s.sno where bno = $pkid ";
	$View = $dbhelper->RunSQLReturnOneRow($sql);
	$ViewCateArray = explode("|",$View["b_cate"]);
	$ViewEtc3Array = explode("|",$View["b_etc3"]);
	$sql = "select * from Web_board_file where bf_kind = 'board' and bno = ". $pkid ." order by bfno asc, bf_datetime desc";
	$ViewFileList = $dbhelper->RunSQLReturnRows($sql);
	$sql = "select * from Web_board_comment where bno = ". $pkid ." order by Bc_step , bc_step_reply";
	$ViewCommentList = $dbhelper->RunSQLReturnRows($sql);

	if ( $View['b_conn_url1'] ) { 
		$bno = $View['b_conn_url1'];
		$sql = "select *, (select bf_file from Web_board_file f where f.bno = d.bno and f.bf_kind = 'board' and bfno = 0 order by bf_datetime desc limit 1 ) bf_file from Web_board_data d left join Web_member m on d.mb_uid = m.mb_uid left join Web_board_set s on d.sno=s.sno where bno =  '$bno' ";
		$View1 = $dbhelper->RunSQLReturnOneRow($sql);
	}

	if ( $View['b_conn_url2'] ) { 
		$bno = $View['b_conn_url2'];
		$sql = "select *, (select bf_file from Web_board_file f where f.bno = d.bno and f.bf_kind = 'board' and bfno = 0 order by bf_datetime desc limit 1 ) bf_file from Web_board_data d left join Web_member m on d.mb_uid = m.mb_uid left join Web_board_set s on d.sno=s.sno where bno =  '$bno' ";
		$View2 = $dbhelper->RunSQLReturnOneRow($sql);
	}

	if ( $View['b_conn_url3'] ) { 
		$bno = $View['b_conn_url3'];
		$sql = "select *, (select bf_file from Web_board_file f where f.bno = d.bno and f.bf_kind = 'board' and bfno = 0 order by bf_datetime desc limit 1 ) bf_file from Web_board_data d left join Web_member m on d.mb_uid = m.mb_uid left join Web_board_set s on d.sno=s.sno where bno =  '$bno' ";
		$View3 = $dbhelper->RunSQLReturnOneRow($sql);
	}

	if ( $View['b_conn_url4'] ) { 
		$bno = $View['b_conn_url4'];
		$sql = "select *, (select bf_file from Web_board_file f where f.bno = d.bno and f.bf_kind = 'board' and bfno = 0 order by bf_datetime desc limit 1 ) bf_file from Web_board_data d left join Web_member m on d.mb_uid = m.mb_uid left join Web_board_set s on d.sno=s.sno where bno =  '$bno' ";
		$View4 = $dbhelper->RunSQLReturnOneRow($sql);
	}

	if ( $View['b_conn_url5'] ) { 
		$bno = $View['b_conn_url5'];
		$sql = "select *, (select bf_file from Web_board_file f where f.bno = d.bno and f.bf_kind = 'board' and bfno = 0 order by bf_datetime desc limit 1 ) bf_file from Web_board_data d left join Web_member m on d.mb_uid = m.mb_uid left join Web_board_set s on d.sno=s.sno where bno =  '$bno' ";
		$View5 = $dbhelper->RunSQLReturnOneRow($sql);
	}

}
$dbhelper->dbClose();

if($ViewFileList != null && count($ViewFileList) > 0) {	
	$i = 0;
	foreach ($ViewFileList as $row){
		if ( $row["bf_file"] ) {
			$str = "";
			$tmp = $webhelper->GetImageExplode( $row["bf_file"] );
			$row['file'] = "/common/download.php?code=".$View['bs_code']."&pkid=".$View['bno'];
			//$str .= "add_file(\"<br /><p style='margin:5px 0 5px;'><input type='checkbox' title='' name='afile_del[]' value='$row[bfno]'><a href='$row[file]' title='첨부파일'>{$row[bf_source]}</a> (파일 삭제시 체크 박스를 클릭해 주세요.)</p>";				
			//$imgarr=array('gif','jpg','png','JPG','PNG','GIF','jpeg');				
			//$Thumb="/FileData/".$View['bs_code']."/simg/list_".$row['bf_file'];
			//if(in_array($tmp[1],$imgarr)) $str .="<br /><img src='".$Thumb."' />";				
			//$str .= "\");\n";

			//$str .= "<br /><p style='margin:5px 0 5px;'><input type='checkbox' class='check01' title='' name='afile_del[]' value='$row[bfno]'><a href='/Admin/common/download.php?code=$View[bs_code]&pkid=$row[bno]' //title='첨부파일'>{$row["bf_source"]}</a> (파일 삭제시 체크 박스를 클릭해 주세요.)</p>";				
			//$imgarr=array('gif','jpg','png','JPG','PNG','GIF','jpeg');				
			//$Thumb="/FileData/".$View['bs_code']."/simg/list_".$row['bf_file'];
			//if(in_array($tmp[1],$imgarr)) $str .="<br /><img src='".$Thumb."' />";		

			
			$str .= "<br /><p style='margin:5px 0 -10px;'><input type='checkbox' class='check01' title='' name='afile_del[]' value='$row[bfno]'><a href='$row[file]' title='첨부파일'>{$row["bf_source"]}</a> (파일 삭제시 체크 박스를 클릭해 주세요.)</p>";				
			$imgarr=array('gif','jpg','png','JPG','PNG','GIF','jpeg');				

			$Thumb="/FileData/".$View['bs_code']."/".$row['bf_file'];
			if ( $i == 0 )
				$Thumb2="/FileData/".$View['bs_code']."/simg/list_".$row['bf_file'];
			else if ( $i == 1 )
				$Thumb2="/FileData/".$View['bs_code']."/simg/view_".$row['bf_file'];
			else if ( $i == 2 )
				$Thumb2="/FileData/".$View['bs_code']."/simg/view_".$row['bf_file'];
			else if ( $i == 3 )
				$Thumb2="/FileData/".$View['bs_code']."/simg/view_".$row['bf_file'];
			else if ( $i == 4 )
				$Thumb2="/FileData/".$View['bs_code']."/simg/view_".$row['bf_file'];
			else if ( $i == 5 )
				$Thumb2="/FileData/".$View['bs_code']."/simg/view_".$row['bf_file'];
			else if ( $i == 22 )
				$Thumb2="/FileData/".$View['bs_code']."/simg/view_".$row['bf_file'];
			
			if(in_array($tmp[1],$imgarr)) $str2 = $str."<br /><img src='".$Thumb2."' width='100' />";
			if(in_array($tmp[1],$imgarr)) $str .="<br /><img src='".$Thumb."' width='100' />";
			
			//$View['afile'.$i] = $str;
			//$View['thumb_afile'.$i] = $str2;

			//$is_file = $str;
			if ( $row["bfno"] == 0 ) $is_thumb0 = $str; //썸네일
			if ( $row["bfno"] == 1 ) $is_thumb1 = $str; //메인썸네일
			if ( $row["bfno"] == 2 ) $is_thumb2 = $str; //메인베스트썸네일
			if ( $row["bfno"] == 3 ) $is_thumb3 = $str; //
			if ( $row["bfno"] == 4 ) $is_thumb4 = $str; //
			if ( $row["bfno"] == 5 ) $is_thumb5= $str; //
			if ( $row["bfno"] == 22 ) $is_thumb22 = $str; //

			if ( $row["bfno"] == 1 ) $MainImg = "/FileData/".$View['bs_code']."/".$row['bf_file']; //메인썸네일


		} else {
			$str .= "add_file('');\n";
		}
		$i++;
	}
}
else
{
	//$str .= "add_file('');\n";
}

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
<head>
	<title>윤성하우징</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="Description" content="">
	<meta name="Author" content="윤성하우징">
	<meta name="Keywords" content="윤성하우징">
	<meta property="og:type" content="website">
	<meta property="og:title" content="윤성하우징">
	<meta property="og:description" content="">
	<meta property="og:image" content="">
	<meta property="og:url" content="">
	<link rel="canonical" href="" />
	<link itemprop="url" href="" />
	<meta name="format-detection" content="telephone=no">
	<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.2, user-scalable=yes,target-densitydpi=device-dpi">
	<!-- FONT -->
	<link rel="preconnect" href="https://fonts.googleapis.com">
	<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
	<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@600;700&family=Roboto:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
	<!-- //FONT -->
	<link rel="stylesheet" type="text/css" href="/common/css/base.css" media="all">
	<script type="text/javascript" src="/common/js/jquery.js"></script>
	<script type="text/javascript" src="/common/js/jquery-ui.min.js"></script>
	
	<script type="text/javascript">

		function checkFrm()
		{

			var f = document.frm_write;

			var pattern_han = /([ㄱ-ㅎ|ㅏ-ㅣ|가-힣])/g; 
			var pattern_num = /([0-9])/g; 
			var pattern_email = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
			
			
			if(!$("#b_name").val()) {
				$("#b_name").focus();
				alert("이름을 입력해주세요.");		
				return;
			}

			if(!$("#b_etc10_2").val()) {
				$("#b_etc10_2").focus();
				alert("휴대폰을 입력해주세요.");		
				return;
			}	
			if(!pattern_num.test($("#b_etc10_2").val())) {
				$("#b_etc10_2").val("");
				$("#b_etc10_2").focus();
				alert("휴대폰번호는 숫자만 입력해주세요.");		
				return;
			}			
			if(!$("#b_etc10_3").val()) {
				$("#b_etc10_3").focus();
				alert("휴대폰을 입력해주세요.");		
				return;
			}
			if(!pattern_num.test($("#b_etc10_3").val())) {
				$("#b_etc10_3").val("");
				$("#b_etc10_3").focus();
				alert("휴대폰번호는 숫자만 입력해주세요.");		
				return;
			}			
			
			var tmp = '';
			$('input:checkbox[name=b_etc7_]:checked').each(function(i){
				if ( i == 0 )
					tmp = this.value;
				else
					tmp += ','+this.value;
			});
			f.b_etc7.value = tmp;		


			$("#b_etc10").val($("#b_etc10_1").val()+"-"+$("#b_etc10_2").val()+"-"+$("#b_etc10_3").val());
			
			if(f.b_content.value == "")
			{
				alert("문의내용을 입력하세요.");
				$("#b_content").focus();
				return;
			}


			if (!$("#terms_agree").prop("checked")){
				alert("개인정보취급방침 동의는 필수 선택사항 입니다.");
				$("#terms_agree").focus();
				return;
			}
			
			adn_btn_ok('103329','types4'); // ADN 전환체크

			$.ajax({
				url: '/common/application7.php',
				type: "GET",
				data: $("#frm_write").serialize(),
				contentType: "application/json; charset=utf-8",
				dataType: "json",
				async: false,
				success: function (res) {
					if(res == 1){
					    wider_conversion("완공사례상담");
						alert("문의 내용이 접수되었습니다.\n전문 하우징 매니저가 빠른 시간 내 연락드리겠습니다.\n감사합니다.");
					} else {
						alert("신청시 오류가 발생했습니다. 관리자에게 문의하시기 바랍니다.");
					}
					$("#b_name").val("");
					$("#b_etc10").val("");
					$("#b_etc10_2").val("");
					$("#b_etc10_3").val("");
					$("#b_content").val("");
					$("input:checkbox[id='terms_agree']").prop("checked", false);

				},
				error: function (res) {
					
				}
			});
		}

	</script>

</head>

<body>
	<!-- wrap -->
	<div id="wrap" class="gallery_view">

		<?php include_once($_SERVER['DOCUMENT_ROOT'] . "/inc/gnb.php");  ?>

		<!-- side_quick -->
		<!-- <div class="side_quick">
			<h3><img src="/images/common/quick_logo.png" alt="윤성 YUNSUNG HOUSING" width="56"></h3>
			<ul class="menu_list">
				<li><div class="d_t"><a href="#" class="d_c">전시장<br />방문예약</a></div></li>
				<li><div class="d_t"><a href="#" class="d_c">가이드북<br />신청</a></div></li>
				<li><div class="d_t"><a href="#" class="d_c">A/S신청</a></div></li>
				<li><div class="d_t"><a href="#" class="d_c">건축 상담</a></div></li>
				<li><div class="d_t"><a href="tel:1566-0495" class="d_c">건축문의<br />1566-0495</a></div></li>
				<li><div class="d_t"><a href="javascript:scollTopStart();" class="d_c btn_top">TOP</a></div></li>
			</ul>
		</div> -->
		<!-- //side_quick -->

		<!-- container -->

		<div class="gallery_visual" style="background-image:url(<?=$MainImg?>)">
			<div class="text_wrap">
				<p class="text01" style="color:<?=$View['b_etc26']?>"><?=$View['b_etc21']?></p>
				<p class="text02" style="color:<?=$View['b_etc27']?>"><?=$View['b_etc22']?></p>
			</div>
		</div>


		<div id="container" class="gallery">

			<?php include_once($_SERVER['DOCUMENT_ROOT'] . "/gallery/_view.php"); ?>

		</div>
		<!-- //container -->

		<?php
			$title = "건축 갤러리 &gt; 완공사례";
			include_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
		?>

		<script type="text/javascript" src="/common/js/swiper.min.js"></script>
		<script type="text/javascript" src="/common/js/clipboard.min.js"></script>
		<script type="text/javascript" src="/common/js/common.js"></script>
		<script>
			$(function(){

				var clipboard = new ClipboardJS('.clipboard', {
					text: function() {
						return window.location.href;
					}
				});
				clipboard.on('success', function(e) {
					alert('주소가 복사되었습니다.\n원하는 곳에 붙여넣기(Ctrl+V)해주세요.');
				});

				galleryVisual();

				$('.btn_share').on('click', function(){
					event.preventDefault();
					if(!$(this).parents('.share_wrap').hasClass('on')){
						$(this).parents('.share_wrap').addClass('on');
					}else{
						$(this).parents('.share_wrap').removeClass('on');
					}
				})
			});


			$(window).on("resize",function () {

				galleryVisual();

			});


			function galleryVisual(){
				$('.gallery_visual').height(SH);
				$('.gallery').css('margin-top',SH);
			}

			/*var referenceHouse = new Swiper('#referenceHouse', {
				slidesPerView: 4,
				spaceBetween: 34,
				autoplay: {
					delay: 3700,
					disableOnInteraction: false,
				},
				pagination : false,
				navigation: {
				  nextEl: ".swiper-button-next",
				  prevEl: ".swiper-button-prev",
				},
				breakpoints: {
					1024: {
						slidesPerView: 3,
						spaceBetween: 20
					},
					768: {
						slidesPerView: 2,
						spaceBetween: 10
					},
					420: {
						slidesPerView: 1,
						spaceBetween: 0
					}
				}
			});*/
		</script>

	</body>
</html>


