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

//불러올 장바구니스킨경로
$cart_skin_path  =  "$g4[path]/skin/cart/basic";

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


$colspan = 7;

$r_colspan  =  9;

//전체 체크박스 on
$is_checkbox = 1;
if ($is_checkbox) $colspan++;

?>


<table width="<?=$width?>"  align=center cellpadding=0 cellspacing=0>
<tr>
  <td valign="top">
    <br>
    <form name="fcart_list" method="post" style="margin:0px;">
	<input type='hidden' name='order' value='<?=$order?>'>

    <!------내용------>
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr><td colspan="<?=$r_colspan?>" height="2" bgcolor="#b6d1d9"></td></tr>
	<tr><td colspan="<?=$r_colspan?>" height="2"></td></tr>
	<tr height="28" bgcolor="#d0e1eb" align="center">
                       <? if ($is_checkbox) { ?><td width=40><INPUT onclick="if (this.checked) all_checked(true); else all_checked(false);" type=checkbox></td><?}?>
					<td width="50">번호</td>
	                <td style='padding-left:30px;' colspan="2"><span class=title_middle style='color:#39424e;'><strong>샘풀이미지</strong></span></td>
					<td width="70"><span class=title_middle style='color:#39424e;'><strong>가 격</strong></span></td>
					<td width="90"><span class=title_middle style='color:#39424e;'><strong>수량/변경</strong></span></td>
					<td width="70"><span class=title_middle style='color:#39424e;'><strong>소 계</strong></span></td>
					<td width="60"><span class=title_middle style='color:#39424e;'><strong>상 태</strong></span></td>
					<td width="90"><span class=title_middle style='color:#39424e;'><strong>기 타</strong></span></td>	
	</tr>
    <?
		$i = 0;
    while ($row = sql_fetch_array($result)){

		$r_ca = strlen($row[wr_reply]);
		$r_ca = 10*$r_ca;
        $reply_img  = "";
		if($r_ca){
         $reply_img = "<img src='{$cart_skin_path}/img/icon_reply.gif' border=0 align=absmiddle>";
		}

		//이미지 출력
		$img_id     = sql_fetch(" select wr_id,ca_name from $m_table where wr_40 = '$row[wr_10]' ");
		$file_name  = sql_fetch(" select bf_file from g4_board_file where wr_id = '$img_id[wr_id]' and bf_no = 0 and bo_table= '$se_table' ");

		$image      = $file_name[bf_file];


		if (preg_match("/\.(gif|jpg|png)$/i", $image)){

			switch($img_id[ca_name]){
				case '가로형':
				    $image_w  =  150;
					$image_h  =  51;
				break;

				case '세로형':
				    $image_w  =  51;
					$image_h  =  151;
				break;

				case '포스터':
				    $image_w  =  151;
					$image_h  =  181;
				break;
			}



          //사진 테드리 사이즈
          $ph_width   = $image_w +2;
          $ph_height  = $image_h +2 ;

	      $thumb_width     =$image_w; 
	      $thumb_height    =$image_h; 

	      $image = urlencode($image); // 첫번째 파일이 이미지라면

		   if (preg_match("/\.(gif|jpg|png)$/i", $image)){

	 	     $thumbsource="$g4[path]/data/file/{$se_table}/" . $image;
		     $thumbimg2 = "<img src='{$thumbsource}' width='".$thumb_width."' height='".$thumb_height."' style='border:1  #c1c1c1 solid'>"; 
		   }
		}
		




		?>
	<tr><td colspan="<?=$r_colspan?>" height="5"></td></tr>
	<tr height="118" align="center">
	                   <? if ($is_checkbox) { ?><td><input type=checkbox name=chk_wr_id[] value="<?=$row[wr_id]?>"></td><? } ?>
	                   <td><?=($i+1)?></td>
	                <td width="120" ><?=$thumbimg2?></td>
	                <td style='padding-left:10px;'>
					    <table width="95%" border="1" cellspacing="0" bordercolor="#CCCCCC" bordercolordark="white" bordercolorlight="#CCCCCC">
						<tr height="22"><td style='padding-left:5px;width:80px;'>용    도</td>
						    <td style='padding-left:5px;'><?=$row[wr_5]?></td>
						</tr>
						<tr height="22"><td style='padding-left:5px;width:80px;'>사 이 즈</td>
						    <td style='padding-left:5px;'>가로&nbsp;<?=$row[wr_2]?>cm&nbsp;&times;&nbsp;세로&nbsp;<?=$row[wr_3]?>cm </td>
						</tr>
						<tr height="22"><td style='padding-left:5px;width:80px;'>마 무 리</td>
						    <td style='padding-left:5px;'><?=$row[wr_6]?></td>
						</tr>
						</table>
					
					</td>
					<td>
					<?
						$p_price = $row[wr_2]*$row[wr_3];
					    $p_price = $p_price*32;
					    echo number_format($p_price)." 원";


					?>					
					</td>
					<td>
					<input name=<?=$row[wr_id]?> style="width:30px;"  value="<?=$row[wr_1]?>"><br>
					<a href="javascript:qt_ch(<?=$row[wr_id]?>);"><img src='<?=$cart_skin_path?>/img/btn_ch.gif' border=0></a>

                    <a href="javascript:add_del('<?=$row[wr_id]?>','<?=$row[wr_subject]?>','wr_id');"><img src='<?=$cart_skin_path?>/img/btn_del.gif' border=0></a>

					
					</td>
					<td>
					<?
				    //echo $row[wr_4];
					$sum_price  = $p_price*$row[wr_1];
					echo number_format($sum_price)." 원";					
					?></td>
					<td>
					<?
                     switch($row[wr_1]){
						case '1':
							echo "진행중";
						break;

						default:
							echo '접수대기';
						break;


					}
				    ?>	
					</td>
					<td>
					<a href="javascript:add_write2('r','<?=$order?>','<?=$g4_cart_qna?>',<?=$row[wr_id]?>);">답변</a>
					<a href="javascript:add_write2('r','<?=$order?>','<?=$g4_cart_qna?>',<?=$row[wr_id]?>);">수정</a>
				
					</td>	
	</tr>
	<tr><td colspan="<?=$r_colspan?>" height="5"></td></tr>
	<tr><td colspan="<?=$r_colspan?>" height="2" bgcolor="#dddbdb"></td></tr>



	<!--------------------
	                   <? if ($is_checkbox) { ?><td><input type=checkbox name=chk_wr_id[] value="<?=$row[wr_id]?>"></td><? } ?>
	                   <td><?=($i+1)?></td>
	                   <td style='padding-left:<?=$r_ca?>px;' align="left"><?=$reply_img?><?=$row[wr_subject]?></td>
					   <td><?=$row[mb_id]?></td>
					   <td><?=$row[wr_name]?></td>
					   <td><?=substr($row[wr_datetime],2,14)?></td>
					   <td>RR</td>
					   <td><a href="javascript:add_write2('r','<?=$order?>','<?=$g4_cart_qna?>',<?=$row[wr_id]?>);">답변</a>
					   <a href="javascript:add_write2('r','<?=$order?>','<?=$g4_cart_qna?>',<?=$row[wr_id]?>);">수정</a>
					   <a href="javascript:add_del('<?=$row[wr_id]?>','<?=$row[wr_subject]?>','wr_id');">삭제</a>
					   
					   </td>
					   <td>dddddd</td>
	--------------------->

	
	<?
		$i++;
    }
    ?>
    <? if ($order_count == 0) { echo "<tr><td colspan='$colspan' height=100 align=center>질문이 존재하지 않습니다.</td></tr>"; } ?>
	</table>
    </form>
	<br>
    <!----//내용------>



	<!-----------글쓰기-------->
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr><td width="50%"><? if ($is_checkbox) { ?><a href="javascript:select_delete();">선택삭제</a><? } ?></td>
	     <td align="right"><a href="javascript:add_write('','<?=$order?>','<?=$g4_cart_qna?>','');">글쓰기</a></td>
	</tr>
	</table>
	<!-----------글쓰기-------->
	<br>
	<!-----------페이지-------->
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr><td align="center"><?=$write_pages?></td></tr>
	</table>
	<!-----------페이지-------->
  </td>
</tr>
</table>


<script language="javascript">

// 선택한 게시물 삭제

 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 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+"/skin/cart/basic/adm/delete_cate.php?wr_id="+se_01;
    f.submit();

}

function qt_ch(se_01) {
    var f = document.fcart_list;


    f.action = g4_path+"/skin/cart/basic/adm/qt_ch.php?wr_id="+se_01;
    f.submit();
}


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/adm/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;
}



 function add_write(se_01, se_02, se_03, se_04)
{ 
   url = g4_path+"/skin/cart/basic/adm/write.skin.php?se_01="+se_01+"&se_02="+se_02+"&se_03="+se_03+"&se_04="+se_04;
        
   win_open(url, "winFormmail", "left=100, top=100, width=560, height=350, scrollbars=1");

}

 function add_write2(se_01, se_02, se_03, se_04)
{ 
   url = g4_path+"/skin/cart/basic/adm/write.skin.php?se_01="+se_01+"&se_02="+se_02+"&se_03="+se_03+"&se_04="+se_04;
        
   win_open(url, "winFormmail", "left=100, top=100, width=560, height=450, scrollbars=1");

}

</script>

