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

	$MENU_ACTV = '31';

	$list_url 		= "notice_list.php";
	$cd_board 		= "01";
	$ds_kind 		= (empty($_SESSION["s_ds_kind"]) ? $_REQUEST["ds_kind"]:$_SESSION["s_ds_kind"]);
	$s_cd_user 		= $_SESSION['s_cd_user'];
	$s_cd_dealer 	= $_SESSION['s_cd_dealer'];
	$searchword 	= $_REQUEST['searchword'];

	// if ( ($ds_kind == "A" && empty($s_cd_user))
	// 		|| ($ds_kind == "D" && empty($s_cd_dealer))
	// 	){
	// 	AlertRedirect("잘못된 요청입니다.","/index.php");
	// }

	if (empty($PageNo)) {$PageNo=1;}else{$PageNo=$PageNo;}
	$PageSize=10; //목록개수설정
	$pagestartpoint=($PageNo-1)*$PageSize;
	$add_sql = "where cd_board='$cd_board' and ds_delind='N'";
	$add_sql.= " and (ds_kind is null or ds_kind='' or ds_kind='$ds_kind') ";

	if($searchword != ""){
		if($searchtype=="" || $searchtype==null){
			$add_sql.= "	and (nm_title like '$searchword%' or nm_content like '$searchword%')";
		}else{
			$add_sql.= "	and $searchtype like '$searchword%'";
		}
	}

	$sql = "select count(*) from board_master $add_sql";

	$totalrows = @mysql_result(mysql_query($sql),0,0);
?>
<? include("../include/inc_header.php") ?>


<main class="pb123">
	<section>
		<div class="sub--top--visual cscenter">
			<div class="contents--inner">
				<h2>고객 센터</h2>
				<p>이차조아에 대해 궁금하신 점이 있다면 무엇이든 물어보세요.</p>
			</div>
		</div>
	</section>
	<?php include_once($_SERVER['DOCUMENT_ROOT']."/include/inc_nav.php");?>

	<section>
		<div class="notice--board--wrap">
			<form id="searchForm" name="searchForm" method="get">
			<div class="board--search--wrap d-flex align-items-center justify-content-between">

				<div class="result--count">총<span><?=number_format($totalrows)?></span>건</div>
				<div class="sch--wrappers">
					<input type="text" id="searchword" name="searchword" class="form-control" placeholder="검색어를 입력해주세요" value="<?=$searchword?>">
					<button type="button" class="btn sch--btn" id="btn_search"></button>
				</div>

			</div>
			</form>
			<table>
				<colgroup>
					<col style="width:100px;"/>
					<col width="*"/>
					<col style="width:135px;"/>
					<col style="width:0px;">
				</colgroup>
				<tbody>
			<?php
					if($totalrows>0) {
						$r = mysql_query("SELECT *
											FROM board_master
											$add_sql
										ORDER BY ds_top desc, no_famally ASC, no_order ASC
										LIMIT $pagestartpoint,$PageSize");
						$i=1;
						while($col = mysql_fetch_array($r)) {
							$date = strtotime ($col['dt_insert']);
							$view_date = strtotime ("-1 day",time());
							if($date >= $view_date) {
								$newicon = " <img src='".ADMIN_PATH."img/i_new.gif' style='margin-top:1px;' /> ";
							} else {
								$newicon = "";
							}

							if($col['no_step']>0){
								$padding = $col['no_step'] * 8;
								$step = "<span style=\"padding-left:".$padding."px\"/>";
							}

							$tmpNum =$totalrows-($PageSize*($PageNo-1));
							$no = ($tmpNum - $i)+1;

			?>
						<tr onclick="location.href='./notice_view.php?cd_board=<?=$cd_board?>&cd_seq=<?=$col['cd_seq']?>&PageNo=<?=$PageNo?>&PageSort=<?=$PageSort?>&PageSize=<?=$PageSort?>&searchtype=<?=$searchtype?>&searchword=<?=$searchword?>'">
							<td class="text-center">
								<div class="numb"><?=$no?></div>
							</td>
							<td>
								<div class="board--captions">
									<span class="lock--notice">공지</span>
									<?=text_cut($col['nm_title'],50)?>
								</div>
							</td>
							<td class="text-center">
								<div class="date--text"><?=$col['dt_insert']?></div>
							</td>
						</tr>

			<?php
							$i++;
						}
					}else{
			?>
						<tr>
							<td colspan="3">등록된 정보가 없습니다.</td>
						</tr>
			<?php
					}
			?>
				</tbody>
			</table>
			<div class="col-12 d-flex justify-content-center">
				<?php
					$url = "./$list_url?searchtype=$searchtype&searchword=$searchword&ds_status=$ds_status&ds_usertype=$ds_usertype&PageSort=$PageSort";
					ListPg($url ,$PageNo,$PageSize,10,$totalrows,$leftboard[1],$rootpath);
				?>
			</div>

		</div>
	</section>


</main>
<script>
function go_search() {
	$("#searchForm").submit();
}
$(function() {
	$("#btn_search").on("click", function() {
		go_search();
	});
})
</script>
<!-- s : footer -->
<? include("../include/inc_footer.php"); ?>
<!-- // e : footer -->
