<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

$g4[title] = "카테고리관리";

           //////////////////////////////////////////////////////////

          //페이지 구현
           $sql = " select count(*) as cnt from {$cart_table[cart_category]} ";
           $row = sql_fetch($sql);
           $total_count = $row[cnt];

           $rows =  45;
           $total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
           if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
           $from_record = ($page - 1) * $rows; // 시작 열을 구함
  



           $h_sql        = " select * from {$cart_table[cart_category]} order by wr_num,wr_reply, ne_8, wr_id desc limit $from_record, $rows ";
           $h_result     = sql_query($h_sql);
           $h_count      = mysql_num_rows($h_result);

           $write_pages = get_paging($h_result, $page, $total_page, "?url=category&page=");
          ////////////////////////////////////////////////////////////

//전체 체크박스 on
$is_checkbox = 1;

//전체폭
$width = "100%"; // 전체폭 890 에서 작업

//$cart_table[cart_category] = "g4_cart_category";

$colspan = 6;
if ($is_checkbox) $colspan++;

/////////////////////

?>

<table width=100% cellpadding=3 cellspacing=1>
<form name=fsearch method=get>
<tr>
    <td width=50% align=left><?=$listall?> (분류수 : <?=number_format($total_count)?>개)</td>
    <td width=50% align=right>
    </td>
</tr>
</form>
</table>


<table width="<?=$width?>" align=center cellpadding=0 cellspacing=0>
<tr>
  <td>
    <form name="fcart_list" method="post" style="margin:0px;">
    <input type = "hidden" name = "save" value = "true" />

    <table width="100%" cellspacing="0" cellpadding="0">
    <colgroup width=30>
    <colgroup width=''>
    <colgroup width=90>
    <colgroup width=60>
    <colgroup width=60>
    <colgroup width=50>
    <colgroup width=80>
    <tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
    <tr class='bgcol1 bold col1 ht center'>
                    <? if ($is_checkbox) { ?><td width=40><INPUT onclick="if (this.checked) all_checked(true); else all_checked(false);" type=checkbox></td><?}?>
					<td>카테고리명</td>
	                <td>분류코드</td>
					<td>출력스킨</td>
					<td>상품재고</td>
					<td>정렬순</td>
					<td>
					<? if ($is_admin == "super") {
						?><a href="javascript:add_cate('','','');"><img src='<?=$g4[admin_path]?>/img/icon_insert.gif' border=0 title='생성'></a><?}?>
                      </td>
	</tr>
    <tr><td colspan='<?=$colspan?>' class='line2'></td></tr>

    <!-- 목록 -->
    <?
    for($i=1;$i<count($list = sql_fetch_array($h_result));$i++) 
    {


        //$r_ca = "<span style='font-family:Tahoma;font-size:7pt;color:#ffffff;'>&nbsp;{$list[wr_reply]}</span>";
		//문자열의 길이반환
		$r_ca = strlen($list[wr_reply]);
		$r_ca = 10*$r_ca;

		


		?>
    <tr height="28" align="center">
                     <? if ($is_checkbox) { ?><td><input type=checkbox name=chk_wr_id[] value="<?=$list[wr_id]?>"></td><? } ?>
					<td style='padding-left:<?=$r_ca?>px;' align="left"><?=$list[wr_subject]?></td>
	                <td><?=$list[ne_1]?></td>	                
					<td><?=$list[ne_2]?></td>
					<td><?=$list[ne_3]?></td>
					<td><?=$list[ne_8]?></td>
					<td><a href="javascript:add_cate('<?=$list[ne_1]?>','<?=$list[wr_id]?>','p');"><img src='<?=$g4[admin_path]?>/img/icon_insert.gif' border=0 title='추가'></a> <a href="javascript:add_cate('<?=$list[ne_1]?>','','w');"><img src='<?=$g4[admin_path]?>/img/icon_modify.gif' border=0 title='수정'></a> <a href="javascript:add_del('<?=$list[wr_id]?>','<?=$list[wr_subject]?>','wr_id');"><img src='<?=$g4[admin_path]?>/img/icon_delete.gif' border=0 title='삭제'></a></td>
	</tr>
    <tr><td height="1" colspan=<?=$colspan?> bgcolor="#dadada"></td></tr>
	<?}?>

    <? if ($h_count == 0) { echo "<tr><td colspan='$colspan' height=100 align=center>카테고리가 존재하지 않습니다.</td></tr>"; } ?>
    <tr><td height="1" colspan=<?=$colspan?> bgcolor="#dadada"></td></tr>

    </table>
    </form>

	<!--------페이지--------->
	<br><br>
    <table width="100%" height="50" cellspacing="0" cellpadding="0">
    <tr><td align="center"><?=$write_pages?></td></tr>
    </table>
	<br>
	<!--------페이지--------->
	<br><br>
    <table width="100%" height="50" cellspacing="0" cellpadding="0">
    <tr><td>
        <? if ($is_checkbox) { ?>
            <a href="javascript:select_delete();">선택삭제</a>
        <? } ?>
	</td></tr>
    </table>
	<br>
	<!--------페이지--------->

  </td>
</tr>
</table>




<script language="javascript">




 function add_cate(se_01, se_02, se_03)
{ 
   url = g4_path+"/shop/add.php?se_01="+se_01+"&se_02="+se_02+"&se_03="+se_03;
        
   win_open(url, "winFormmail", "left=100, top=100, width=680, height=580, scrollbars=1");

}

 function add_del(se_01, se_02, se_03)
{ 
    var f = document.fcart_list;

    str = "삭제";
    if (!confirm(se_02+" 를 정말 "+str+" 하시겠습니까?\n\n한번 "+str+"한 자료는 복구할 수 없습니다"))
        return;

    f.action = g4_path+"/shop/delete_cate.php?wr_id="+se_01;
    f.submit();

}


// 선택한 게시물 삭제

 function all_checked(sw) {
  var f = document.fcart_list;

  for (var i=0; i<f.length; i++) {
  if (f.elements[i].name == "chk_wr_id[]")
      f.elements[i].checked = sw;
   }
}


function select_delete() {
    var f = document.fcart_list;

    str = "삭제";
    if (!check_confirm(str))
        return;

    if (!confirm("선택한 분류를 정말 "+str+" 하시겠습니까?\n\n한번 "+str+"한 자료는 복구할 수 없습니다"))
        return;

    f.action = g4_path+"/skin/cart/basic/delete_cate.php";
    f.submit();
}

function check_confirm(str) {
    var f = document.fcart_list;
    var chk_count = 0;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]" && f.elements[i].checked)
            chk_count++;
    }

    if (!chk_count) {
        alert(str + "할 게시물을 하나 이상 선택하세요.");
        return false;
    }
    return true;
}

</script>





