<?php
require_once 'path.php';// root 폴더를 기준으로 상대적인 경로 자동 구하기
require_once $g['path_root'].'sessionChk.php';
require_once $g['path_config'].'dbconnect.php';
require_once $g['path_class'].'dbDataClass.php';
require_once $g['path_class'].'bbsClass.php';
$b = new bbsClass();
$d = new DBDataClass();
$link_url = "contacts.php"; // 현재 실행중인 파일명 가져오기
$page = isset($_GET['page'])? trim($_GET['page']):1;//페이지 변수 설정
$rowsPage = 10; // 한 화면에 표시되는 게시글 수
$curPage = isset($_GET['p']) ? $_GET['p'] : 1;
$m = isset($_GET['m']) ? $_GET['m'] :'list';
$flddata ="uid,cat1,cat2,mobileNO,officeNO";// 화면에 출력할 칼럼 발췌
$where = isset($_GET['where']) ? $_GET['where']: '';
$keyword = isset($_GET['keyword']) ? $_GET['keyword']: '';
$xorderby= isset($xorderby) ? $xorderby : 'cat1 ASC, cat2 ASC'; // 없는 칼럼인지 꼭 체크하라.
$sqlque = 'display=1';
if ($cat1) $sqlque .= ' and cat1='.$cat1;
if ($cat2) $sqlque .= ' and cat2='.$cat2;
if($where && $keyword) {
if($where == 'telNO') {
$sqlque .= " and (mobileNO LIKE '%".$keyword."%' OR officeNO LIKE '%".$keyword."%') ";
}
}
//echo $sqlque.'<br/>';
$g['url_link']=($m?'m='.$m.'&':'').($where?'where='.$where.'&':'').($keyword?'keyword='.urlencode(stripslashes($keyword)).'&':'');
$g['bbs_reset'] = $link_url.'?'.($m?'m='.$m.'&':'');
$table ='members'; // 테이블
$rows= $d->getDbArray($table,$sqlque,$flddata,$xorderby,$rowsPage,$curPage);
$NUM = $d->getDbRows($table,$sqlque); // 전체 게시글수
$TPG = $b->getTotalPage($NUM,$rowsPage);
$i = 0;
?>
<div class="table-responsive text-nowrap">
<div class="float-left info">
<?php if( $keyword ):?><strong>"<?php echo $keyword?>"</strong> 검색결과 : <?php endif?>
<?php echo number_format($NUM)?>개 (<?php echo $curPage;?>/<?php echo $TPG;?>페이지)
</div>
<table id="ListTable" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
<thead align='center'>
<tr>
<th scope="col">No</th>
<th scope="col">구분1</th>
<th scope="col">구분2</th>
<th scope="col">휴대폰번호</th>
<th scope="col">사무실번호</th>
</tr>
</thead>
<tbody>
<?php foreach($rows as $R):?>
<?php
$CA1= $d->getDbData('cate','id="'.$R['cat1'].'" and parent_id=0','name');
$CA2= $d->getDbData('cate','id="'.$R['cat2'].'" and parent_id="'.$R['cat1'].'"','name');
$no = $NUM - (($curPage - 1) * $rowsPage) - $i;
$i++;
?>
<tr id="<?php echo $R['uid']; ?>">
<td><?php echo $no;?></td>
<td><?php echo $CA1['name'];?></td>
<td><?php echo $CA2['name'];?></td>
<td><a href="tel:<?php echo $R['mobileNO'];?>"><i class="fas fa-phone"></i></a></td>
<td><a href="tel:<?php echo $R['officeNO'];?>"><i class="fas fa-phone"></i></a></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div class='form-group'>
<form name="Form" class="form-inline" action="<?php echo $link_url;?>">
<input type="hidden" name="m" value="<?php echo $m;?>" />
<input type="hidden" name="cat1" value="<?php echo $cat1;?>" />
<input type="hidden" name="cat2" value="<?php echo $cat2;?>" />
<input type="hidden" name="orderby" value="<?php echo $xorderby;?>" />
<div class="input-group mb-3">
<select name="where" class="browser-default custom-select">
<option value="telNO">전화번호</option>
</select>
</div>
<div class="input-group mb-3">
<input type="text" name="keyword" class="form-control" id="SearchKeyword">
<div class="input-group-append">
<button class="btn btn-md" type="button" id="Search">검색</button>
<button class="btn btn-md" type="button" id="Home">Home</button>
</div>
</div>
</form>
</div>
<?php $b->PageLinkView($link_url,$NUM,$rowsPage,$curPage,$g['url_link']);?>
</div>