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

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

// 테마에 orderinquiry.sub.php 있으면 include
if(defined('G5_THEME_SHOP_PATH')) {
    $theme_inquiry_file = G5_THEME_SHOP_PATH.'/rcpcinquiry.sub.php';
    if(is_file($theme_inquiry_file)) {
        include_once($theme_inquiry_file);
        unset($theme_inquiry_file);
        return;
    }
}
?>

<!-- 렌탈PC 이용내역 목록 시작 { -->
<?php if (!$limit) { ?>총 <?php echo $cnt; ?> 건<?php } ?>

<?php $member_mb_id_esc = oi_sql(isset($member['mb_id']) ? $member['mb_id'] : ''); ?>

<div class="tbl_head03 tbl_wrap">
    <table>
    <thead>
    <tr>
        <th scope="col"><input type='checkbox' name='animal' value='selectall' onclick='selectAll(this)'/></th>
		<th scope="col">품번</th>
        <th scope="col">서버위치</th>
        <th>PC별명</th>
        <th>PC메모</th>
        <th>PC사양</th>
        <th scope="col">렌탈이용시작일</th>
        <th scope="col">렌탈이용만료일</th>
        <th scope="col">렌탈잔여일수</th>
        <th scope="col">원격제어정보</th>
        <th scope="col">PC전원</th>
        <th scope="col">원격재부팅</th>
        <th scope="col">알림쪽지</th>
        <th scope="col">A/S신청</th>
        <th scope="col">기간연장</th>
        <th scope="col">구매포인트</th>
    </tr>
    </thead>
    <tbody>

    <?php
	$now_datetime = date("Y-m-d H:i:s");

    $sql = " select *
				from smart_rental_comspec
					where member_id = '{$member_mb_id_esc}' AND (start_date != '' AND start_date IS NOT NULL) AND (exp_date != '' AND exp_date IS NOT NULL)
					and ((TO_DAYS('$now_datetime') - TO_DAYS(exp_date)) <= 0)
					order by (
					    select IFNULL(MAX(ct_id), 0)
					    from {$g5['g5_shop_cart_table']}
					    where (it_id = no OR ct_2 = no)
					      and ct_status in ('입금','배송','완료','확정')
					      and mb_id = '{$member_mb_id_esc}'
					) desc, no desc
					$limit ";
    $result = sql_query($sql);

	$real_data_cnt = 0;

    for ($i=0; $row=sql_fetch_array($result); $i++)
    {
		// 취소된 주문은 제외 하기 위함.
		$sql_chk = " select * FROM `{$g5['g5_shop_cart_table']}` WHERE (it_id = '{$row['no']}' OR ct_2 = '{$row['no']}') AND (ct_status = '입금' or ct_status = '배송' or ct_status = '완료' or ct_status = '확정') AND mb_id = '{$member_mb_id_esc}' ORDER BY ct_id DESC LIMIT 1 ";
		$result_chk = sql_query($sql_chk);
		$total_chk = @mysqli_num_rows($result_chk);
		$this_ct_id = "";
		if ($total_chk == 0) {
			continue;
		} else {
			$row_chk=sql_fetch_array($result_chk);
			$this_ct_id = $row_chk['ct_id'];
			$this_od_id = $row_chk['od_id'];
			$real_data_cnt++;
		}

		$uid = md5($row['od_id'].$row['od_time'].$row['od_ip']);

        switch($row['od_status']) {
            case '주문':
                $od_status = '<span class="status_01">입금확인중</span>';
                break;
            case '입금':
                $od_status = '<span class="status_02">입금완료</span>';
                break;
            case '준비':
                $od_status = '<span class="status_03">상품준비중</span>';
                break;
            case '배송':
                $od_status = '<span class="status_04">상품배송</span>';
                break;
			case '완료':
				$od_status = '<span class="status_05">배송완료</span>';
				break;
			case '확정':
				$od_status = '<span class="status_07">거래확정</span>'; // 컴뷰어스를 위해 거래확정 항목 추가함. JSLEE
				break;
            default:
                $od_status = '<span class="status_06">주문취소</span>';
                break;
        }
    ?>

    <tr>
		<td><input type='checkbox' name='selno' value='<?php echo $row['no']; ?>'/></td>
        <td><?php echo $row['no']; ?></td>
        <td><?php echo $row['M_storename'];?></td>
        <td style='font-size:0.7rem;'>
			<?php
				$rental_pc_name = str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n","\t","\\t","_x000D_","\\"),array("<br/>","<br/>","<br/>","<br/>","<br/>","<br/>"," "," ","<br/>","\\"),addslashes($row['rental_pc_name']));
				$rental_pc_name = str_replace(array("-"),"",$rental_pc_name);
				$rentalPcName_disp = $rental_pc_name ? "【 " . $row['no'] . "번 렌탈PC별명 】" . "\\n\\n" . "———————————————————————————————" . "\\n\\n" . addslashes($rental_pc_name) . "\\n\\n" . "———————————————————————————————" : "【 " . $row['no'] . "번 렌탈PC별명 】" . "\\n\\n" . "———————————————————————————————" . "\\n\\n" . "- 렌탈PC별명이 등록되지 않았습니다 -" . "\\n\\n" . "———————————————————————————————";
				if ($rental_pc_name) {
					$name_isempty = "no";
				} else {
					$name_isempty = "yes";
				}
				$this_no = $row['no'];
				$encrypt_str = Encrypt("rentalPcName" . "Œ" . time() . "Œ" . $this_no  . "Œ" . $member['mb_id'] . date("iHs"));
			?>
			<?php
				if (mb_strlen($rental_pc_name,'utf8') <= 10) {
					echo $rental_pc_name ? mb_substr($rental_pc_name,0,10,'utf8') . "<br>" : "";
				} else {
					echo $rental_pc_name ? mb_substr($rental_pc_name,0,10,'utf8')."..." . "<br>" : "";
				}
			?>
			<?php if (trim($rental_pc_name) == "-" || trim($rental_pc_name) == "") {	?>
				<button onclick="user_info_edit('<?php echo $row['no']; ?>','<?php echo $encrypt_str; ?>','rentalPcName','<?php echo $name_isempty; ?>','<?php echo $rentalPcName_disp; ?>','<?php echo $rental_pc_name; ?>','unick')"><i class="fa fa-address-card-o" aria-hidden="true" style='zoom:1.5;'></i><div style='zoom:0.7'>&nbsp;PC별명&nbsp;</div></button>
			<?php } else { ?>
				<button onclick="user_info_edit('<?php echo $row['no']; ?>','<?php echo $encrypt_str; ?>','rentalPcName','<?php echo $name_isempty; ?>','<?php echo $rentalPcName_disp; ?>','<?php echo $rental_pc_name; ?>','unick')"><div style='zoom:0.7'>보기·변경</div></button>
			<?php } ?>
		</td>
		<?php /*
        <td>
			<?php
				$rentalPcMemo_disp = $row['rental_pc_memo'] ? "【 " . $row['no'] . "번 렌탈PC메모 】" . "\\n\\n" . "———————————————————————————————" . "\\n\\n" . addslashes($row['rental_pc_memo']) . "\\n\\n" . "———————————————————————————————" : "【 " . $row['no'] . "번 렌탈PC메모 】" . "\\n\\n" . "———————————————————————————————" . "\\n\\n" . "- 메모내용이 없습니다 -" . "\\n\\n" . "———————————————————————————————";
				if (trim($row['rental_pc_memo'])) {
					$memo_isempty = "no";
				} else {
					$memo_isempty = "yes";
				}
				$this_no = $row['no'];
				$encrypt_str = Encrypt("rentalPcMemo" . "Œ" . time() . "Œ" . $this_no  . "Œ" . $member['mb_id'] . date("iHs"));
			?>
			<button onclick="user_info_edit('<?php echo $row['no']; ?>','<?php echo $encrypt_str; ?>','rentalPcMemo','<?php echo $memo_isempty; ?>','<?php echo $rentalPcMemo_disp; ?>','<?php echo addslashes($row['rental_pc_memo']); ?>','umemo')"><i class="fa fa-sticky-note-o" aria-hidden="true" style='zoom:1.5;'></i><div style='zoom:0.7'>메모보기</div></button>
		</td>
		*/ ?>
		<td style='font-size:0.7rem;'>
			<?php
				$rental_pc_memo = str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n","\t","\\t","_x000D_","\\"),array("<br/>","<br/>","<br/>","<br/>","<br/>","<br/>"," "," ","<br/>","\\"),addslashes($row['rental_pc_memo']));
				$rental_pc_memo = str_replace(array("-"),"",$rental_pc_memo);
				$rentalPcMemo_disp = $rental_pc_memo ? "【 " . $row['no'] . "번 렌탈PC메모 】" . "\\n\\n" . "———————————————————————————————" . "\\n\\n" . addslashes($rental_pc_memo) . "\\n\\n" . "———————————————————————————————" : "【 " . $row['no'] . "번 렌탈PC메모 】" . "\\n\\n" . "———————————————————————————————" . "\\n\\n" . "- 렌탈PC메모가 등록되지 않았습니다 -" . "\\n\\n" . "———————————————————————————————";
				if ($rental_pc_memo) {
					$name_isempty = "no";
				} else {
					$name_isempty = "yes";
				}
				$this_no = $row['no'];
				$encrypt_str = Encrypt("rentalPcMemo" . "Œ" . time() . "Œ" . $this_no  . "Œ" . $member['mb_id'] . date("iHs"));
			?>
			<?php
				if (mb_strlen($rental_pc_memo,'utf8') <= 10) {
					echo $rental_pc_memo ? mb_substr($rental_pc_memo,0,10,'utf8') . "<br>" : "";
				} else {
					echo $rental_pc_memo ? mb_substr($rental_pc_memo,0,10,'utf8')."..." . "<br>" : "";
				}
			?>
			<?php if (trim($rental_pc_memo) == "-" || trim($rental_pc_memo) == "") {	?>
				<button onclick="user_info_edit('<?php echo $row['no']; ?>','<?php echo $encrypt_str; ?>','rentalPcMemo','<?php echo $name_isempty; ?>','<?php echo $rentalPcMemo_disp; ?>','<?php echo $rental_pc_memo; ?>','umemo')"><i class="fa fa-sticky-note-o" aria-hidden="true" style='zoom:1.5;'></i><div style='zoom:0.7'>&nbsp;PC메모&nbsp;</div></button>
			<?php } else { ?>
				<button onclick="user_info_edit('<?php echo $row['no']; ?>','<?php echo $encrypt_str; ?>','rentalPcMemo','<?php echo $name_isempty; ?>','<?php echo $rentalPcMemo_disp; ?>','<?php echo $rental_pc_memo; ?>','umemo')"><div style='zoom:0.7'>보기·변경</div></button>
			<?php } ?>
		</td>
        <td>
			<?php
				// SSD
				$SSDinfo = preg_replace("/SSD/", "",$row['SSDinfo']);
				$SSDinfoArr = explode(",",$SSDinfo);
				$SSDinfoDisp = "";
				$cnt=0;
				for ($js=0; $js<count($SSDinfoArr); $js++) {
					if ($SSDinfoArr[$js] == "") continue;
					if (strpos(strtoupper($SSDinfoArr[$js]),"SAMSUNG") === false) {
						$SSDinfoDispArr = explode(" ",trim($SSDinfoArr[$js]));
						if ($cnt==0) {
							$SSDinfoDisp = trim($SSDinfoDispArr[0]);
							$cnt++;
						} else {
							$SSDinfoDisp = $SSDinfoDisp . " + " . trim($SSDinfoDispArr[0]);
						}
					} else {
						if ($cnt==0) {
							$SSDinfoDisp = trim($SSDinfoArr[$js]);
							$cnt++;
						} else {
							$SSDinfoDisp =  $SSDinfoDisp . " + " . trim($SSDinfoArr[$js]);
						}
					}
				}

				// HDD
				$HDDinfo = preg_replace("/HDD/", "",$row['HDDinfo']);
				$HDDinfoArr = explode(",",$HDDinfo);
				$HDDinfoDisp = "";
				$cnt=0;
				for ($js=0; $js<count($HDDinfoArr); $js++) {
					if ($HDDinfoArr[$js] == "") continue;
					if (strpos(strtoupper($HDDinfoArr[$js]),"SAMSUNG") === false) {
						$HDDinfoDispArr = explode(" ",trim($HDDinfoArr[$js]));
						if ($cnt==0) {
							$HDDinfoDisp = trim($HDDinfoDispArr[0]);
							$cnt++;
						} else {
							$HDDinfoDisp = " + " . trim($HDDinfoDispArr[0]);
						}
					} else {

						if ($cnt==0) {
							$HDDinfoDisp  = trim($HDDinfoArr[$js]);
							$cnt++;
						} else {
							$HDDinfoDisp =  " + " . trim($HDDinfoArr[$js]);
						}
					}
				}

				$gpu_ram = ($row['gpu_ram'] > 0) ? " (" . $row['gpu_ram'] . "GB)" : "";

				$comSpecDisp = "【 " . $row['no'] . "번 렌탈PC사양 】" . "\\n" . "OS : " . $row['OperatingSystem'] . "\\n" . "CPU : " . $row['CpuName'] . "\\n" .  "SSD : "  . $SSDinfoDisp .  "\\n" .  "HDD : "  . $HDDinfoDisp . "\\n" . "RAM : " . $row['RAM'] . "GB" . "\\n" .  "GPU : "  . $row['VideoController'] . $gpu_ram;
			?>
			<button onclick="alert('<?php echo $comSpecDisp; ?>')"><i class="fa fa-info-circle" aria-hidden="true" style='zoom:1.5;'></i><div style='zoom:0.7'>사양보기</div></button>
		</td>
        <td class="td_numbig"><?php echo substr($row['start_date'],0,10)."<br>".substr($row['start_date'],11,99);?></td>
        <td class="td_numbig"><?php echo substr($row['exp_date'],0,10)."<br>".substr($row['exp_date'],11,99);?></td>
        <td class="td_numbig">
		<?php
			$endDate = strtotime($row['exp_date']); //마감시간
			$today = strtotime(date("Y-m-d H:i:s")); //현재시간

			$diff = $endDate - $today;

			$days = floor($diff/3600/24);
			$hours = floor($diff/3600);
			$diff = $diff-($hours*3600);
			$min = floor($diff/60);
			$sec = $diff - ($min*60);

			if ($days >= 0) {
				echo $days . "일 남음";
				$isRental = "yes";
			} else {
				echo "렌탈종료";
				$isRental = "no";
			}
		?>
		</td>
        <td>
			<?php
				if ($isRental == "yes") {
			?>
				<div style='display:flex; justify-content:center; align-items:center; flex-direction:column; width:100%;'>
					<div style='display:flex; justify-content:flex-start; align-items:center; width:100%; border-top:1px solid #efefef; border-bottom:1px solid #efefef; box-sizing:border-box;'>
						<div style='display:flex; justify-content:flex-start; align-items:center;width:70px; min-width:70px; max-width:70px; zoom:0.9; padding-left:0px; box-sizing:border-box;'><i class="fa fa-wifi" aria-hidden="true"></i>&nbsp;WAN IP</div>
						<div style='display:flex; justify-content:flex-start; align-items:center; width:110px; min-width:110px; box-sizing:border-box;'>
						<?php
							if ($isRental == "yes") {
								echo $row['extIP'];
							} else {
								echo "-";
							}
						?>
						</div>
					</div>
					<?php if (addslashes(trim($row['AnyDeskID']))!="") { ?>
						<div style='display:flex; justify-content:flex-start; align-items:center; width:100%; border-bottom:1px solid #efefef; box-sizing:border-box;'>
							<div style='display:flex; justify-content:flex-start; align-items:center;width:70px; min-width:70px; max-width:70px; zoom:0.9; padding-left:0px; box-sizing:border-box;'><img src='<?php echo G5_URL?>/mylib/images/anydesk_logo.png' style='height:12px;'></div>
							<div style='display:flex; justify-content:flex-start; align-items:center; width:110px; min-width:110px; box-sizing:border-box;'>
							<?php
								$anydesk_id_str = "원격PC 품번: {$row['no']} &nbsp;,&nbsp;애니데스크ID: " . addslashes(trim($row['AnyDeskID'])) . " 의 암호";
								$anydesk_pwd_str = addslashes(trim($row['AnyDeskPWD']));
								if ($isRental == "yes") {
							?>
									<?php echo "<div style='display:flex; justify-content:flex-start; align-items:center;width:75px; min-width:75px; max-width:75px; box-sizing:border-box;'>" . str_replace([' '], '', trim($row['AnyDeskID'])) . "</div><div style='display:flex; justify-content:flex-start; align-items:center;width:35px; min-width:35px; max-width:35px; box-sizing:border-box;'><i class='fa fa-unlock-alt' aria-hidden='true'></i> " . "<button onclick='prompt(\"$anydesk_id_str\",\"$anydesk_pwd_str\");' style='zoom:0.7; margin-left:5px; box-sizing:border-box;'>암호</button></div>";
									?>
							<?php
								}
							?>
							</div>
						</div>
					<?php } ?>
					<?php if (addslashes(trim($row['TeamViewerID']))!="") { ?>
						<div style='display:flex; justify-content:flex-start; align-items:center; width:100%; border-bottom:1px solid #efefef; box-sizing:border-box;'>
							<div style='display:flex; justify-content:flex-start; align-items:center;width:70px; min-width:70px; max-width:70px; zoom:0.9; padding-left:0px; box-sizing:border-box;'><img src='<?php echo G5_URL?>/mylib/images/teamviewer_logo.png' style='height:12px;'></div>
							<?php
								$teamviewer_id_str = "원격PC 품번: {$row['no']} &nbsp;,&nbsp;팀뷰어ID: " . addslashes(trim($row['TeamViewerID'])) . " 의 암호";
								$teamviewer_pwd_str = addslashes(trim($row['TeamViewerPWD']));
								if ($isRental == "yes") {
							?>
									<?php echo "<div style='display:flex; justify-content:flex-start; align-items:center;width:75px; min-width:75px; max-width:75px; box-sizing:border-box;'>" . str_replace([' '], '', trim($row['TeamViewerID'])) . "</div><div style='display:flex; justify-content:flex-start; align-items:center;width:35px; min-width:35px; max-width:35px; box-sizing:border-box;'><i class='fa fa-unlock-alt' aria-hidden='true'></i> " . "<button onclick='prompt(\"$teamviewer_id_str\",\"$teamviewer_pwd_str\");' style='zoom:0.7; margin-left:5px; box-sizing:border-box;'>암호</button></div>";
									?>
							<?php
								}
							?>
						</div>
					<?php } ?>
				</div>
			<?php
				} else {
					echo "N/A";
				}
			?>
		</td>
        <td>
			<?php
			if ($isRental == "yes") {
				$LastUpdateTime = $row['LastUpdateTime']; // 앱에서 마지막으로 업데이트한 일시
				$str_lastUpdateTime = strtotime($LastUpdateTime);
				$str_nowTime = strtotime(date("Y-m-d H:i:s"));
				if (($str_lastUpdateTime+120) < $str_nowTime) { // 70초가 지났는지 체크해서 true라면 offline 상태로 판단
					$isOnline_icon = "<i class='fa fa-plug' aria-hidden='true' style='width:20%; min-width:30px; max-width:40px; zoom:1.5; color:#a7a7a7; padding:2px 2px 2px; border:1px solid #ffffff;'><div style='display:flex; justify-content:center; align-items:center; zoom:0.6; margin-top:5px;'>OFF</div></i>"; // OFFLINE
					$isOnline = "OFF"; // OFFLINE
				} else {
					$isOnline_icon = "<i class='fa fa-power-off' aria-hidden='true' style='width:20%; min-width:30px; max-width:40px; zoom:1.5; color:#6699ff; padding:2px 2px 2px; border:1px solid #ffffff;'><div style='display:flex; justify-content:center; align-items:center; zoom:0.6; margin-top:5px;'>ON</div></i>"; // ONLINE
					$isOnline = "ON"; // ONLINE
				}
			} else {
				$isOnline_icon = "N/A";
				$isOnline = "OFF"; // OFFLINE
			}
			echo $isOnline_icon;
			?>
		</td>
        <td>
			<?php
			if ($isRental == "yes") {
				if ($isOnline == "ON") {
			    	$this_no = $row['no'];
			    	$encrypt_str = Encrypt("reboot" . "Œ" . time() . "Œ" . $this_no  . "Œ" . $member['mb_id'] . date("iHs"));
					//$Restart_icon = "<button id='rcmd_reboot_".$this_no."' onclick='mypagercmd(&quot;$this_no&quot;, &quot;$encrypt_str&quot;, &quot;reboot&quot;);' style='border:1px solid #6699ff;'><i class='fa fa-repeat' aria-hidden='true' style='zoom:1.5; color:#6699ff; padding:2px 2px 2px;'></i></button>"; // 재시작
					$Restart_icon = "<i class='fa fa-windows' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#6699ff; padding:2px 2px 2px; border:1px solid #6699ff; cursor:pointer;' onclick='mypagercmd(&quot;$this_no&quot;, &quot;$encrypt_str&quot;, &quot;reboot&quot;);'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px;'>REBOOT</div></i>"; // REBOOT
				} else if ($isOnline == "OFF") {
					//$Restart_icon = "<button style='border:1px solid #a7a7a7;'><i class='fa fa-repeat' aria-hidden='true' style='zoom:1.5; color:#a7a7a7; padding:2px 2px 2px;'></i></button>"; // 재시작불가(전원OFF상태일때)
					$Restart_icon = "<i class='fa fa-windows' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#a7a7a7; padding:2px 2px 2px; border:1px solid #a7a7a7; cursor:no-drop;'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px;'>REBOOT</div></i>"; // REBOOT
				}
			} else {
				$Restart_icon =  "N/A";
			}
			echo $Restart_icon;
			?>
		</td>

		<td>
			<?php
				// 쪽지 전체 갯수
				$sql_minimsg_all = "SELECT count(*) as cnt_minimsg_all FROM g5_memo WHERE no='{$this_no}' AND me_recv_mb_id='{$member['mb_id']}' ";
				$result_minimsg_all = sql_fetch($sql_minimsg_all);
				$total_minimsg_all = $result_minimsg_all['cnt_minimsg_all'];
				// 안 읽은 쪽지 유무 체크 (렌탈마켓용)
				$sql_minimsg = "SELECT count(*) as cnt_minimsg FROM g5_memo WHERE no='{$this_no}' AND me_recv_mb_id='{$member['mb_id']}' AND me_read_datetime='0000-00-00 00:00:00' ";
				$result_minimsg = sql_fetch($sql_minimsg);
				$total_minimsg = $result_minimsg['cnt_minimsg'];
				if ($total_minimsg > 0) {
					$unreadmsg_cnt = $total_minimsg;
					//$href_data = "/bbs/memo.php?kind=recv&no=".$this_no;
					$href_data = "/bbs/memo_form.php?me_recv_mb_id=cs&storeid=".$row['M_storeid']."&no=".$row['no'];

					//$AsRequest_icon = "<i class='fa fa-comment' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#6699ff; padding:2px 2px 2px; border:1px solid #6699ff; cursor:pointer;' onclick='window.open(&quot;{$href_data}&quot;,&quot;memo_popup&quot;,&quot;location=no,directories=no,resizable=no,status=no,toolbar=no,menubar=no,scrollbars=yes,width=1210,height=910&quot;);'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px;'>안읽음<span style='color:red; font-weight:1000; margin-left:2px;'>{$unreadmsg_cnt}</span></div></i>"; // 예) 알림 1

					$AsRequest_icon = "<i class='fa fa-comment' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#6699ff; padding:2px 2px 2px; border:1px solid #6699ff; cursor:pointer;' onclick='window.open(&quot;{$href_data}&quot;,&quot;win_".$member['mb_id']."&quot;,&quot;left=400,top=50,width=450,height=600,scrollbars=1&quot;);'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px;'>안읽음<span style='color:red; font-weight:1000; margin-left:2px;'>{$unreadmsg_cnt}</span></div></i>"; // 예) 알림 1

					echo "$AsRequest_icon";
				} else {
					$href_data = "/bbs/memo_form.php?me_recv_mb_id=cs&storeid=".$row['M_storeid']."&no=".$row['no'];
					$AsRequest_icon = "<i class='fa fa-commenting-o' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#6699ff; padding:2px 2px 2px; border:1px solid #6699ff; cursor:pointer;' onclick='window.open(&quot;{$href_data}&quot;,&quot;win_".$member['mb_id']."&quot;,&quot;left=400,top=50,width=450,height=600,scrollbars=1&quot;);'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px; color:#6699ff;'>읽음<span style='color:#6699ff; font-weight:1000; margin-left:2px;'>{$total_minimsg_all}</span></div></i>"; // 예) 알림 0
					echo "$AsRequest_icon";
				}
			?>
		</td>

		<td>
			<?php
				$this_no = $row['no'];
				$encrypt_str = Encrypt("asreq" . "Œ" . time() . "Œ" . $this_no  . "Œ" . $member['mb_id'] . date("iHs"));
				$AsRequest_icon = "<i class='fa fa-wrench' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#6699ff; padding:2px 2px 2px; border:1px solid #6699ff; cursor:pointer;' onclick='mypagercmd(&quot;$this_no&quot;, &quot;$encrypt_str&quot;, &quot;asreq&quot;);'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px;'>A/S신청</div></i>"; // A/S신청
				echo "$AsRequest_icon";
			?>
		</td>

		<td>
			<?php
				$this_no = $row['no'];
				$encrypt_str = Encrypt("rtextdate" . "Œ" . time() . "Œ" . $this_no  . "Œ" . $member['mb_id'] . date("iHs"));
				$RentalExtensionDate_icon = "<i class='fa fa-credit-card' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#6699ff; padding:2px 2px 2px; border:1px solid #6699ff; cursor:pointer;' onclick='mypagercmd(&quot;$this_no&quot;, &quot;$encrypt_str&quot;, &quot;rtextdate&quot;);'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px;'>기간연장</div></i>"; // 기간연장신청
				echo "$RentalExtensionDate_icon";
			?>
		</td>

		<td>
			<?php
				$this_no = $row['no'];
				$sql_od = " select * from {$g5['g5_shop_order_table']} where mb_id = '{$member_mb_id_esc}' and od_id = '{$this_od_id}' order by od_id desc limit 1 ";
				$result_od = sql_query($sql_od);
				$row_od = sql_fetch_array($result_od);
				$sql_ct = " select * from {$g5['g5_shop_cart_table']} where ct_id = '{$this_ct_id}' order by ct_id desc limit 1 ";
				$result_ct = sql_query($sql_ct);
				$row_ct = sql_fetch_array($result_ct);
				$sum_point = $row_ct['ct_point'];

				switch($row_ct['ct_status']) {
					case '주문':
						$ct_status = '<span class="status_01">입금확인중</span>';
						$sum_point_disp = "-";
						break;
					case '입금':
						$ct_status = '<span class="status_02">입금완료</span>';
						$sum_point_disp = "적립하기";
						break;
					case '준비':
						$ct_status = '<span class="status_03">상품준비중</span>';
						$sum_point_disp = "적립하기";
						break;
					case '배송':
						$ct_status = '<span class="status_04">상품배송</span>';
						$sum_point_disp = "적립하기";
						break;
					case '완료':
						$ct_status = '<span class="status_05">배송완료</span>';
						$sum_point_disp = "적립하기";
						break;
					case '확정':
						$ct_status = '<span class="status_07">거래확정</span>'; // 컴뷰어스를 위해 거래확정 항목 추가함. JSLEE
						$sum_point_disp = "적립됨";
						break;
					default:
						$ct_status = '<span class="status_06">주문취소</span>';
						$sum_point_disp = "-";
						break;
				}


                $encrypt_str = Encrypt("pntreq2" . "Œ" . time() . "Œ" . $this_od_id . "Œ" . $this_ct_id  . "Œ" . $member['mb_id'] . date("iHs"));
                if ($sum_point_disp=="적립됨") {
                    echo "<div style='width:100%; padding:2px 2px 2px;'>".display_point($sum_point)."<br>$sum_point_disp</div>";
                } else if ($sum_point_disp=="-") {
                    echo "<div style='width:100%; padding:2px 2px 2px;'>$sum_point_disp</div>";
                } else if ($sum_point_disp=="적립하기") {
                    echo "<i class='fa fa-check' aria-hidden='true' style='width:20%; min-width:35px; max-width:35px; zoom:1.3; color:#6699ff; padding:2px 2px 2px; border:1px solid #6699ff; cursor:pointer;' onclick='putorderpoint2(&quot;$this_od_id&quot;, &quot;$this_ct_id&quot;, &quot;$encrypt_str&quot;, &quot;pntreq2&quot;, &quot;".display_point($sum_point)."&quot;);'><div style='display:flex; justify-content:center; align-items:center; zoom:0.57; border-bottom:1px solid #efefef; margin-top:5px;'>$sum_point_disp</div></i>";
                }
            ?>
		</td>

	</tr>

    <?php
    }

    if ($real_data_cnt == 0)
        echo '<tr><td colspan="13" class="empty_table">렌탈PC이용내역이 없습니다.</td></tr>';
    ?>
    </tbody>
    </table>
</div>


<script>
function mypagercmd(no, key, cmd) {
	var prompt_text = '';
	var input_value = '';
	var confirm_text = '';
	var result_text = '';
	switch (cmd)
	{
		case "reboot":
			confirm_text = "품번 " + no + " 렌탈PC를 강제로 재시작 시키겠습니까?\n\n(주의: 이 명령은 취소하실 수 없습니다.)";
			result_text = "재부팅 명령이 실행되었습니다.";
			if (confirm(confirm_text))
			{
				$.ajax({
					url: '/mylib/mypage_cmd_ajax.php',
					type: 'POST',
					dataType: 'html',
					data: {
						no: no,
						key: key,
						cmd: cmd,
						content: '',
						mb_id: "<?php echo $member['mb_id'];?>",
						action:'ajax'
					},
					success:function(data)
					{
						if(data)
						{
							alert(result_text);
						}
					}
				});
			} else {
				//alert("취소완료!");
			}
			break;

		case "asreq":
			/*
			prompt_text = "[알림] A/S신청은 접수순으로 처리되며 취소가 불가능합니다." + "\n\n품번 " + no + " 렌탈PC에 대하여 A/S신청을 하실려면\n아래 입력창에 내용을 작성하신 후 확인 버튼을 누르세요.";
			var input_value = prompt(prompt_text, '');
			result_text = "품번 " + no + " 렌탈PC에 대한 A/S신청이 접수되었습니다.";
			confirm_text = "아래의 내용으로 품번 " + no + " 렌탈PC에 대한 A/S신청을 정말로 제출 하시겠습니까?\n\n" + input_value;
			if (input_value != "" && input_value != null) {
				if (confirm(confirm_text))
				{
					$.ajax({
						url: '/mylib/mypage_cmd_ajax.php',
						type: 'POST',
						dataType: 'html',
						data: {
							no: no,
							key: key,
							cmd: cmd,
							content: input_value,
							mb_id: "<?php echo $member['mb_id'];?>",
							action:'ajax'
						},
						success:function(data)
						{
							if(data == "success")
							{
								alert(result_text);
								return false;
							} else {
								alert(data);
							}
						}
					});
				} else {
					//alert("취소완료!");
				}
			} else {
					alert("입력하신 내용이 없으므로 A/S신청을 취소하였습니다.\n필요시 다시 시도해 주십시오.");
					return false;
			}
			*/
			confirm_text = "[알림] A/S신청은 접수순으로 실시간 처리되므로 취소가 불가능합니다." + "\n\n품번 " + no + " 렌탈PC를 A/S신청 하실려면 확인 버튼을 누르세요.";
			if (confirm(confirm_text))
			{
				var link = "/bbs/write.php?bo_table=as&rtno="+no;
				location.replace(link);
			}
			break;

		case "rtextdate":
			confirm_text = "기간연장 대상이 " + no + "번 렌탈PC가 맞는지 한번 더 확인해 주십시오!!\n이 렌탈PC에 대하여 정말로 기간연장신청을 하시겠습니까?";
			result_text = no + "번 렌탈PC에 대한 기간연장 요청이 접수되었습니다.";
			if (confirm(confirm_text))
			{
				$.ajax({
					url: '/mylib/mypage_cmd_ajax.php',
					type: 'POST',
					dataType: 'html',
					data: {
						no: no,
						key: key,
						cmd: cmd,
						content: '',
						mb_id: "<?php echo $member['mb_id'];?>",
						action:'ajax'
					},
					success:function(data)
					{
						if(data)
						{
							if (data == "fail") {
								alert("시스템 장애가 발생하였습니다.\n만일 오류라고 판단되면 관리자에게 반드시 신고해 주십시요!");
							} else {
								var link = "/shop/item.php?it_id="+data;
								location.replace(link);
							}
						}
					}
				});
			} else {
				//alert("취소완료!");
			}
			break;

		case "rtextdatelist":
			var extMonth = $("#extMonth").val();
			confirm_text = "기간연장 대상이 아래의 렌탈PC품번들이 맞는 지 한번 더 확인해 주십시오!!\n이 렌탈PC에 대하여 전부 " + extMonth + "개월간 기간연장신청을 하시겠습니까?\n\n[선택하신 렌탈PC품번]\n" + no;
			result_text = "아래에 나열된 렌탈PC 품번에 대하여 기간연장 요청이 접수되었습니다.\n\n" + no;
			if (confirm(confirm_text))
			{
				showLoading(); // 로딩바 표시
				$.ajax({
					url: '/mylib/mypage_cmd_ajax.php',
					type: 'POST',
					dataType: 'html',
					data: {
						no: no.trim(),
						key: key,
						cmd: cmd,
						content: '',
						mb_id: "<?php echo $member['mb_id'];?>",
						extMonth: extMonth,
						action:'ajax'
					},
					success:function(data)
					{
						if(data)
						{
							if (data == "fail") {
								alert("시스템 장애가 발생하였습니다.\n만일 오류라고 판단되면 관리자에게 반드시 신고해 주십시요!");
							} else {
								var link = "/shop/cart.php";
								location.replace(link);
							}
						}
					}
				});
			} else {
				//alert("취소완료!");
			}
			break;


	}


}
</script>

<script>
function selectAll(selectAll)  {
	const checkboxes = document.getElementsByName('selno');

	checkboxes.forEach((checkbox) => {
		checkbox.checked = selectAll.checked;
	})
}
</script>

<script>
    function putorderpoint2(this_od_id,this_ct_id,encrypt_str,sum_point_disp, sum_point) {
		console.log(this_od_id,this_ct_id,encrypt_str,sum_point_disp, sum_point);
        if (confirm("[중요고지]\n구매포인트 ("+sum_point+")은 거래확정처리와 동시에 적립이 됩니다.\n적립된 포인트는 결제시 제한없이 사용하실 수 있습니다.\n구매확정이 된 이후에 취소/환불을 신청하시는 경우 포인트로만 환불 받으실 수 있습니다.\n아래 확인 버튼을 누르면 즉시 거래확정이 되며 이용약관에 동의한 것으로 간주됩니다.")) {
            $.ajax({
                url: '/mylib/mypage_putorderpoint2_ajax.php',
                type: 'POST',
                dataType: 'html',
                data: {
                    this_od_id: this_od_id,
                    this_ct_id: this_ct_id,
                    encrypt_str: encrypt_str,
                    sum_point_disp: sum_point_disp,
                    mb_id: '<?php echo $member['mb_id']?>',
                    action:'ajax'
                },
                success:function(data)
                {
                    if(data)
                    {
                        //console.log(data);
                        if (data.trim() == "success") {
                            alert("거래확정후 구매포인트 ("+sum_point+")이 적립되었습니다.");
                            location.reload(false);
                        } else {
                            alert("구매포인트가 적립되지 않았습니다. 관리자에게 요청 해 주십시오. (오류코드:MP2-001)");
                        }
                    }
                }
            });
        }
    }
</script>


<script>
//function mypagercmd(no, key, cmd) {
function user_info_edit(no, key, cmd, isempty, memo_disp, memo, item) {
	var prompt_text = '';
	var input_value = '';
	var confirm_text = '';
	var result_text = '';
	var edit_type_str = '';
	var edit_item_str = '';

	switch (isempty) {
		case 'yes':
			edit_type_str = "등록";
			break;
		case 'no':
			edit_type_str = "수정";
			break;
		default:
			return false;
	}
	switch (item) {
		case 'umemo':
			edit_item_str = "PC메모를";
			break;
		case 'unick':
			edit_item_str = "PC별명을";
			break;
		default:
			return false;
	}

	var textStr = null;
	if (confirm(memo_disp + "\n\n" + edit_item_str + " " + edit_type_str + " 하실려면 아래 확인 버튼을 누르십시오.")) {
		textStr = prompt(memo,memo);
	}
	if (textStr === null) {
		//alert("취소 하였습니다.")
        return false; //break out of the function early
    }
	if (memo == textStr) {
		alert("동일한 PC별명이므로 변경하지 않았습니다.");
		return false;
	}
	if (textStr!==undefined && textStr!==null && textStr!=='') {
		textStr = textStr.trim();
	} else {

	}

	if (textStr == undefined || textStr == null) textStr = "";
	confirm_text = "———————————————————————————————\n\n" + textStr + "\n\n———————————————————————————————" + "\n\n위의 내용으로 품번 " + no + "번의 " + edit_item_str + " " + edit_type_str+" 하시겠습니까?";
	result_text = "입력하신 내용으로 "+edit_type_str+" 되었습니다.\n\n";
	if (confirm(confirm_text))
	{
		$.ajax({
			url: '/mylib/mypage_user_info_edit_ajax.php',
			type: 'POST',
			dataType: 'html',
			data: {
				no: no,
				key: key,
				cmd: cmd,
				content: textStr,
				mb_id: "<?php echo $member['mb_id'];?>",
				item: item,
				action:'ajax'
			},
			success:function(data)
			{
				if(data)
				{
					if (data == "fail") {
						alert("시스템 장애가 발생하였습니다.\n만일 오류라고 판단되면 관리자에게 반드시 신고해 주십시요!");
					} else {
						alert(result_text);
						location.reload(true);
					}
				}
			}
		});
	} else {
		//alert("취소완료!");
	}

}



</script>
<!-- } 렌탈PC 이용내역 목록 끝 -->