<?


//****************파라미터정보***************************
If ($a_ad_cms == "Y") {
	$a_ad_cms_url = "ad_cms.php?a_num=".$a_num."&amp;".$page_info;
} Else {
	$a_ad_cms_url = "#";
}
//*******************************************************

//****************페이징정보*****************************
$v_pagesize		= $a_displaysu; //리스트 화면에 보여줄 갯수
$v_block		= 10;			//페이징 갯수
$length			= 30;			//내용 길이
//*******************************************************

//****************테이블 기본 환경설정*******************
$is_tablename = $a_tablename; //테이블명

$R_Fields = "b_num, b_type, b_id, b_name, b_pwd, b_subject, b_email, b_jumin, b_phone1, b_phone2, b_phone3, b_cate, b_catename, b_noticechk, b_content, b_ip, b_count, b_look, b_open, b_ref, b_step, b_level, b_regdate, b_chuchun, b_sbjclr, b_sdate, b_edate, b_temp1, b_temp2, b_temp3, b_temp4, b_temp5, b_temp6, b_temp7, b_temp8, b_file1, b_file2, b_file3, b_file4, b_file5,b_c_count"; //레코드필드

$pk_Field = "b_num";

$opt_where_str = ""; //기본조건이 있을때 사용..없으면 '' 처리

//$orderby_str = " ORDER BY "&pk_Field&" DESC "; //정렬
$orderby_str = " ORDER BY b_ref desc, b_step asc "; //정렬
//*******************************************************


//****************옵션 부분******************************
if (trim($p_keyword) != "" && $p_search != "") { //검색어가 있다면
	$search_str = " AND ". $v_search ." like '%". str_replace("'","''",$v_keyword)."%'";
}

If ($is_ad_cms != "Y") { //관리자가아닐때 실행할것들...

	if ($a_member == "Y") { //회원제 사용일때
		$search_str2 = " AND b_id = '".$_SESSION["ss_m_id"]."' ";

		if ($_SESSION["ss_m_id"] == "") {
			goMessage("로그인 후 사용하세요", "/content/07guide/02_01.php");
		}
	}
	$search_str5 =" AND  b_look = 'Y' ";
}


//if ($a_reply == "N" or ($a_reply == "Y" and $a_replyOpt == "2") ) { //답변기능을 사용하지 않을때.
	$search_str3 =" and  b_type = 'N' ";
//}




//기간설정 사용시..
if ($a_date_list == "Y") {
	
	If ($a_sdate !=  "" And $a_edate == "") {
		$search_str4 = " and left(b_regdate,10) >= '".$a_sdate."' ";
	} ElseIf ($a_sdate !=  "" And $a_edate != "") {
		$search_str4 = " and left(b_regdate,10) >= '".$a_sdate."' and left(b_regdate,10) <= '".$a_edate."'";
	}
}

//분류기능 사용시..
if ($a_cate == "Y" and  $v_cate != "") {
	$search_str6 = " AND  b_cate = ".$v_cate;
}
//*******************************************************

//****************전체 레코드 수 뽑기********************
$SQL_T = "select count(".$pk_Field.") as ".$pk_Field." from ".$is_tablename." where ".$pk_Field." <> '0'";
$SQL_T = $SQL_T.$search_str.$search_str2.$search_str3.$search_str4.$search_str5.$search_str6; //검색옵션
$mysql->ParseExec($SQL_T);
$mysql->FetchInto(&$row);

$recordcount = $row[$pk_Field];

$v_totalpage	= floor(($recordcount-1)/$v_pagesize)+1;		//'전체덩어리갯수

if($v_page == ""){
	$v_page = 1;
}elseif($v_page < 1){
	$v_page = 1;
}elseif($v_page > $v_totalpage){
	$v_page = $v_totalpage;
}
//*******************************************************


$strSQL = "select ".$R_Fields." from ".$is_tablename. " where ".$pk_Field." <> '0' ";
$strSQL = $strSQL . $search_str . $search_str2 . $search_str3 . $search_str4 . $search_str5.$search_str6; //검색옵션
$strSQL = $strSQL.$orderby_str." limit ".($v_pagesize * ($v_page-1)).",".$v_pagesize;
//echo $strSQL;
$mysql->ParseExec($strSQL);


?>



<?include("top.php"); //상단파일?>

<!-- 리스트 -->
<div id="board" style="width:<?=$a_width?>;">


	<div class="board_total">
		<div class="board_total_left">
			<?if($a_ad_cms == "Y"){?>
			
				<?if($_SESSION["ss_m_id"] == ""){?>
				<a href="manager.php?a_num=<?=$a_num?>"><img src="/content/board/nninc_simple/img/key.gif" alt="" /></a> 
				<?}else{?>
				<a href="logout.php?a_num=<?=$a_num?>"><img src="/content/board/nninc_simple/img/unkey.gif" alt="" /></a> 
				<?}?>
			
			
				전체 <strong><?=$recordcount?></strong>개 (페이지 <strong class="board_orange"><?=$v_page?></strong>/<?=$v_totalpage?>)

			<?}else{?>
			<img src="/content/board/nninc_simple/img/total_ic.gif" alt="" /> 전체 <strong><?=$recordcount?></strong>개 (페이지 <strong class="board_orange"><?=$v_page?></strong>/<?=$v_totalpage?>)
			<?}?>
		</div>
		<div class="board_total_right">
			<?include("code.php"); //분류?>
		</div>
	</div>
	

	<?if($is_ad_cms == "Y"){?>
	<form id= "frm_list" action=""  method='post'>
	<div>
		<input type="hidden" name="status" />
		<input type="hidden" name="a_num" value="<?=$a_num?>" />

		<input type="hidden" id="chk_all" name="chk_all" /><!-- 전체체크 사용하려구.. -->
		
	</div>
	<?}?>
	<div>
		<input type="hidden" name="status" />
		<input type="hidden" name="a_num" value="<?=$a_num?>" />

		<input type="hidden" id="chk_all" name="chk_all" /><!-- 전체체크 사용하려구.. -->
		
	</div>


	<!-- 리스트 테이블 -->
	<div class="table_blist">

			<table cellspacing="0" >
			<caption><?=str_replace( " | ", "",$tit_name);?></caption>
				<colgroup>
				<?If ($is_ad_cms == "Y") { //관리권한이 있을때만 보인다?>
				<col width="50" />
				<?}?>
				<col width="60" />

				<?If ($a_lt_b == "Y") { ?>
				<col width="90" />
				<?}?>

				<col width="" />

				<?If ($a_type == "Y") { ?>
				<col width="90" />
				<?}?>

				<?If ($a_lt_a == "Y") { ?>
				<col width="70" />
				<?}?>
				
				
				<col width="80" />

				<col width="70" />

				<?If ($a_lt_c == "Y") { ?>
				<col width="50" />
				<?}?>
				</colgroup>
			<thead>
				<tr>
					<?If ($is_ad_cms == "Y") { //관리권한이 있을때만 보인다?>
					<th scope="col">선택</th>
					<?}?>
					<th scope="col">번호</th>
					<?If ($a_lt_b == "Y") { ?>
					<th scope="col">등록일</th>
					<?}?>

					<th scope="col">제목</th>

					<?If ($a_type == "Y") { ?>
					<th scope="col">공개여부</th>
					<?}?>
					<?If ($a_lt_a == "Y") { ?>
					<th scope="col">글쓴이</th>
					<?}?>
					
					<th scope="col">처리기한</th>

					<th scope="col" class="th_none">처리상황</th>
					
					<?If ($a_lt_c == "Y") { ?>
					<th scope="col" class="th_none">조회</th>
					<?}?>
				</tr>
			</thead>
			<tbody>
				
				<?
				If ($v_totalpage > 0) {        //------ 내용이 있으면 리스트 출력

					if($v_page == 1){
						$num = $recordcount;
					}else{
						$num = $recordcount - (($v_page -1) * $v_pagesize);
					}

					while($mysql->FetchInto(&$rs)) {

						//필드갯수만큼 ($Query_Fields).가지고온다..

						$R_Fields	= str_replace(" ", "", $R_Fields);
						$R_Fields_arr	= explode(",",$R_Fields);

						for($i=0;$i <= count($R_Fields_arr)-1;$i++){
							eval("\$".$R_Fields_arr[$i]."	= \$rs[".$R_Fields_arr[$i]."];");
								}

						

						//첨부파일표시
						if($a_upload == "Y" and $a_lt_e == "Y"){

							If ( $b_file1 != "" Or $b_file2 != "" Or $b_file3 != "" Or $b_file4 != "" Or $b_file5 != "") {
								$file_str = "<img src='/content/board/nninc_qna/img/icon_file.gif' alt='첨부파일' />";
							} Else {
								$file_str = "";
							}
						}
						
						
						//답변표시
						If ($b_type == "R") {

							$b_type_str = ""; //초기화
							
							For ($xx=1;$xx <= $b_level;$xx++) {

								if($xx != 1){$b_type_str = $b_type_str."&nbsp;&nbsp;&nbsp;";}
							}
							$b_type_str = $b_type_str."<img src='/content/board/nninc_qna/img/reply_ic.gif' width='40' height='16' alt='' />";

						} Else {
							$b_type_str = "";
						}

						
						//공개/비공개
						If ($a_type == "Y") {//사용하면

							if($b_open == "N"){//비공개이면
								
								$b_open_str = "<span style='color:#1775C4;font-weight:bold;font-size:0.9em'>비공개</span>";

								$b_name		= "***";
							}else{//공개이면
								$b_open_str = "<span style='color:#F66E00;font-weight:bold;font-size:0.9em'>공개</span>";
							}

						} Else {
							$b_open_str = "";
						}

						

						//사용/중지
						If ($b_look == "Y") {
							$tr_clr = "FFFFFF";
						} ElseIf ($b_look == "N") {
							$tr_clr = "#FFEFD2";
						}
						
						//댓글사용시
						If ($a_command == "Y") {
							if ($b_c_count != "0"){
								$a_command_str = "(".$b_c_count.")";
							} Else {
							$a_command_str = "";
							}
						} Else {
							$a_command_str = "";
						}

						if($b_temp6 != ""){
							$b_temp6_str = str_replace("-", ".", substr($b_temp6,0,10));
						}

						if($b_temp7 == ""){
							$b_temp7 = "접수";
						}

				?>
				<tr>
					<?If ($is_ad_cms == "Y") { //관리권한이 있을때만 보인다?>
					<td><input type="checkbox" name="chk[]" value="<?=$b_num?>" title="해당 게시글 선택"  /></td>
					<?}?>
					<td><?=$num?></td>

					<?If ($a_lt_b == "Y") { ?>
					<td><?=str_replace("-", ".", substr($b_regdate,0,10))?></td>
					<?}?>

					<td class="title">
							<?=$b_type_str?>
							<?if($b_type=="N"){ echo "<span class='category_color'>".$b_cate_str[$b_cate]."</span>";}?>
							<a href="view.php?a_num=<?=$a_num?>&amp;b_num=<?=$b_num?>&amp;<?=$page_info?>"><?=$b_subject?></a>
							<span class="reply_count"><?=$a_command_str?></span>
							<?=get_newimg2(substr($b_regdate,0,10), $a_new)?>
							<?=$file_str?>
					</td>

					<?If ($a_type == "Y") { ?>
					<td><?=$b_open_str?></td>
					<?}?>

					<?If ($a_lt_a == "Y") { ?>
					<td><?=$b_name?></td>
					<?}?>
					
					<td><?=$b_temp6_str?></td>

					<td><span style="font-weight:bold;font-size:0.9em;"><?=$b_temp7?></span></td>
					
					
					<?If ($a_lt_c == "Y") { ?>
					<td><?=$b_count?></td>
					<?}?>
				</tr>
				<?
					$num = $num - 1;
		
					}

				}
				else {
				?>
				<tr>
					<td class="center" colspan="10">등록된 내용이 없습니다.</td>
				</tr>
				<?
				}
				?>

			</tbody>
			</table>

	</div>
	<!-- //리스트 테이블 -->
	
	<?if($is_ad_cms == "Y"){?>
	</form>
	<? } ?>


	<!-- 버튼 -->
	<div class="board_button">
		<?If ($is_ad_cms == "Y") { //관리권한이 있을때만 보인다?>
		<div class="fl">
			<ul>
			<li class="pl"><img src="/manager/img/line01.gif" width="36" height="21" alt="" /></li>
			<li class="pt"><div class="board_bt01"><a href="javascript:checkAll();" ><span>전체 선택/해제</span></a></div><div class="board_bt01"><a href="javascript:delete2();" ><span>선택 게시글삭제</span></a></div></li>
			</ul>
		</div>
		<?}?>
		<div class="fr">
			<span class="bt"><a href="list.php?a_num=<?=$a_num?>" ><img src="/content/board/nninc_qna/img/list_bt.gif" width="62" height="23" alt="목록" /></a></span>
			<?if($is_write == "Y"){?>
			<span class="bt"><a href="write.php?a_num=<?=$a_num?>" ><img src="/content/board/nninc_qna/img/write_bt.gif" width="62" height="23" alt="쓰기" /></a></span>
			<?}?>
		</div>

	</div>
	<!-- //버튼 -->

	<!-- 페이징 -->
	<div class="board_paginate">
		<?page2("list.php?a_num=".$a_num)?>
	</div>
	<!-- //페이징 -->

	<!-- 게시물 검색 -->
	<div class="board_search">
		<form id="frm_sch" action="list.php?a_num=<?=$a_num?>"  method="post">
			<fieldset>
			<legend>게시물 검색</legend>
			<ul>
			<li class="board_search_start"></li>
			<li><img src="/content/board/nninc_qna/img/search_ic.gif" width="21" height="25" alt="" /></li>
			<li><select id="p_search" name="p_search" title="검색형태 선택" >
				<option value="b_subject" <?if ($v_search == "b_subject") { echo("selected='selected'"); } ?>>제목</option>
				<option value="b_content" <?if ($v_search == "b_content") { echo("selected='selected'"); } ?>>내용</option>
			</select></li>
			<li><input type="text" size="25" title="검색어를 입력하세요" id="p_keyword" name="p_keyword" class="board_input" value="<?=$v_keyword?>"  /></li>
			<li><input type="image" src="/content/board/nninc_qna/img/search_bt.gif" id="search_bt" name="search_bt" class="search_bt" alt="검색" /></li>
			<li class="board_search_end"></li>
			</ul>
			</fieldset>
		</form>
	</div>
	<!-- //게시물 검색 -->


</div>
<!-- //리스트 -->

<?include("bottom.php"); //하단파일?>

