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

if(!function_exists('vpn_grade_badge_html')) {
    function vpn_grade_badge_html($grade) {
        $grade = strtoupper(trim((string)$grade));
        if($grade === '') return '';
        $c = array('BASIC'=>'#6c757d','PLUS'=>'#0d6efd','PRO'=>'#198754','ULTRA'=>'#6f42c1','MAX'=>'#dc3545');
        $bg = isset($c[$grade]) ? $c[$grade] : '#555';
        return '<span class="vpn-grade-badge" style="display:inline-block;padding:1px 8px;border-radius:0;font-size:11px;font-weight:700;letter-spacing:.4px;background:'.htmlspecialchars($bg,ENT_QUOTES).';color:#fff;margin-right:4px;vertical-align:middle;">'.htmlspecialchars($grade,ENT_QUOTES).'</span>';
    }
}
if(!function_exists('vpn_country_flag')) {
    function vpn_country_flag($short) {
        static $map=array('KOR'=>'KR','USA'=>'US','JPN'=>'JP','CHN'=>'CN','GBR'=>'GB','DEU'=>'DE','FRA'=>'FR','SGP'=>'SG','HKG'=>'HK','TWN'=>'TW','AUS'=>'AU','NLD'=>'NL','CAN'=>'CA','IND'=>'IN','RUS'=>'RU','VNM'=>'VN','THA'=>'TH','IDN'=>'ID','MYS'=>'MY','PHL'=>'PH','BRA'=>'BR','MEX'=>'MX','NOR'=>'NO','SWE'=>'SE','FIN'=>'FI','CHE'=>'CH','AUT'=>'AT','ESP'=>'ES','ITA'=>'IT','POL'=>'PL','UKR'=>'UA');
        $short=strtoupper(trim((string)$short));
        $c=isset($map[$short])?$map[$short]:(strlen($short)===2?$short:'');
        if(strlen($c)!==2) return '';
        $l=strtolower($c);
        return '<img src="https://flagcdn.com/20x15/'.$l.'.png" srcset="https://flagcdn.com/40x30/'.$l.'.png 2x" width="20" height="15" alt="'.htmlspecialchars($c,ENT_QUOTES).'" style="display:inline-block;vertical-align:middle;border-radius:2px;border:1px solid rgba(0,0,0,.08);">';
    }
}
if(!function_exists('vpn_category_badge_html')) {
    function vpn_category_badge_html($spec_os) {
        $parts = explode('-', trim((string)$spec_os));
        $cat = strtoupper(trim($parts[0]));
        if($cat === '') return '';
        return '<span class="vpn-category-badge" style="display:inline-block;padding:1px 8px;border-radius:0;font-size:11px;font-weight:700;letter-spacing:.4px;background:#0891b2;color:#fff;margin-right:4px;vertical-align:middle;">'.htmlspecialchars($cat,ENT_QUOTES).'</span>';
    }
}

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$skin_url.'/style.css" media="screen">', 0);

if($header_skin)
	include_once('./header.php');

?>

<style>
	.wishlist-type-nav { margin: 0 0 14px; display: flex; gap: 10px; flex-wrap: wrap; }
	.wishlist-type-nav .wishlist-tab {
		display: inline-flex;
		justify-content: center;
		align-items: center;
		flex: 1 1 0;
		min-width: 0;
		max-width: none;
		height: 38px;
		padding: 0 10px;
		margin-left: 0;
		background: #fff;
		color: #111;
		border: 1px solid #555;
		box-shadow: 0 2px 5px rgba(0,0,0,0.1);
		text-decoration: none;
		font-weight: 600;
		font-size: 14px;
		letter-spacing: -0.2px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.wishlist-type-nav .wishlist-tab:hover,
	.wishlist-type-nav .wishlist-tab:focus {
		color: #111;
		text-decoration: none;
	}
	.wishlist-type-nav .wishlist-tab.active {
		background: #111;
		color: #fff;
		border-color: #111;
		font-weight: 700;
	}
	/* 탭 다크모드 */
	[data-site-theme="dark"] .wishlist-type-nav .wishlist-tab {
		background: #252528;
		color: #c4c4cc;
		border-color: #4a4a52;
		box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
	}
	[data-site-theme="dark"] .wishlist-type-nav .wishlist-tab:hover,
	[data-site-theme="dark"] .wishlist-type-nav .wishlist-tab:focus {
		color: #e4e4e7;
		background: #2c2c32;
	}
	[data-site-theme="dark"] .wishlist-type-nav .wishlist-tab.active {
		background: #3f65a8;
		color: #fff;
		border-color: #3f65a8;
	}
	[data-site-theme="dark"] .wishlist-type-label {
		background: #2a2a32;
		color: #c4c4cc;
	}
	/* 다크모드: 서버사양·상품명 등 인라인 어두운 글자색 보정 */
	[data-site-theme="dark"] .wishlist-table [style*="color:#374151"],
	[data-site-theme="dark"] .wishlist-table [style*="color: #374151"] {
		color: #d1d5db !important;
	}
	[data-site-theme="dark"] .wishlist-table [style*="color:#6b7280"],
	[data-site-theme="dark"] .wishlist-table [style*="color: #6b7280"] {
		color: #9ca3af !important;
	}
	[data-site-theme="dark"] .wishlist-col-spec {
		color: #9ca3af;
	}
	.wishlist-skin { overflow-x: visible; }
	.wishlist-table { width: 100%; min-width: 100%; }
	.wishlist-table--all,
	.wishlist-table--vpn,
	.wishlist-table--rpc,
	.wishlist-table--auction { min-width: 100%; }
	.wishlist-table th,
	.wishlist-table td { vertical-align: middle !important; }
	.wishlist-col-name a { word-break: break-all; }
	.wishlist-col-contract,
	.wishlist-col-price,
	.wishlist-col-date,
	.wishlist-col-action,
	.wishlist-col-id,
	.wishlist-col-status {
		white-space: nowrap;
	}
	.wishlist-col-spec {
		font-size: 12px;
		line-height: 1.55;
		color: #6b7280;
		margin-top: 6px;
		word-break: break-word;
	}
	.wishlist-type-label {
		display: inline-block;
		padding: 2px 8px;
		margin-right: 8px;
		border-radius: 999px;
		font-size: 11px;
		font-weight: 700;
		background: #f1f5f9;
		color: #1f2937;
		vertical-align: middle;
	}
	@media (max-width: 991px) {
		.wishlist-type-nav { gap: 0; }
		.wishlist-type-nav .wishlist-tab {
			flex: 1 1 calc(50% - 10px);
			min-width: 140px;
			max-width: 300px;
			margin: 5px;
			height: 36px;
			padding: 5px 0;
			font-size: 13px;
		}
		.wishlist-skin { overflow-x: auto; -webkit-overflow-scrolling: touch; }
		.wishlist-table { min-width: 980px; }
		.wishlist-table--all { min-width: 1180px; }
		.wishlist-table--vpn { min-width: 1060px; }
		.wishlist-table--rpc { min-width: 1180px; }
		.wishlist-table--auction { min-width: 1080px; }
		.wishlist-table { font-size: 13px; }
	}
	@media (max-width: 640px) {
		.wishlist-type-nav .wishlist-tab {
			flex: 1 1 calc(50% - 10px);
			min-width: 140px;
			max-width: none;
			font-size: 12px;
		}
		.wishlist-table { font-size: 12px; }
		.wishlist-table th,
		.wishlist-table td { padding: 8px 6px !important; }
	}
</style>

<div class="wishlist-type-nav">
	<a href="./wishlist.php" class="wishlist-tab<?php echo (empty($inquiry_type) ? ' active' : ''); ?>">전체</a>
	<a href="./wishlist.php?inquiry_type=vpn" class="wishlist-tab<?php echo ($inquiry_type === 'vpn' ? ' active' : ''); ?>">VPN</a>
	<a href="./wishlist.php?inquiry_type=rpc" class="wishlist-tab<?php echo ($inquiry_type === 'rpc' ? ' active' : ''); ?>">원격제어컴퓨터(일반)</a>
	<a href="./wishlist.php?inquiry_type=auction" class="wishlist-tab<?php echo ($inquiry_type === 'auction' ? ' active' : ''); ?>">원격제어컴퓨터(경매)</a>
</div>

<form name="fwishlist" method="post" action="./cartupdate.php">
<input type="hidden" name="act"       value="multi">
<input type="hidden" name="sw_direct" value="">
<input type="hidden" name="prog"      value="wish">

<?php
$is_vpn_view = ($inquiry_type === 'vpn');
$is_rpc_view = ($inquiry_type === 'rpc');
$is_auction_view = ($inquiry_type === 'auction');
$is_all_view = (!$is_vpn_view && !$is_rpc_view && !$is_auction_view);

if(empty($head_class)) {
	$head_class = 'tr-head border-black';
}
?>

<div class="wishlist-skin">
	<table class="div-table table bg-white wishlist-table <?php echo $is_vpn_view ? 'wishlist-table--vpn' : ($is_rpc_view ? 'wishlist-table--rpc' : ($is_auction_view ? 'wishlist-table--auction' : 'wishlist-table--all')); ?>">
	<tbody>
	<tr class="<?php echo $head_class;?>">
		<th class="text-center" scope="col" width="60">
			<label for="chk_it_id_all" class="sound_only">전체 선택</label>
			<span><input type="checkbox" name="chk_it_id_all" value="1" id="chk_it_id_all" checked="checked"></span>
		</th>
		<?php if ($is_vpn_view) { ?>
			<th class="text-center" scope="col">상품 정보</th>
			<th class="text-center" scope="col">최소계약</th>
			<th class="text-center" scope="col">1일요금</th>
			<th class="text-center" scope="col">보관일시</th>
			<th class="text-center" scope="col">삭제</th>
		<?php } else if ($is_rpc_view) { ?>
			<th class="text-center" scope="col">상품 정보</th>
			<th class="text-center" scope="col">최소계약</th>
			<th class="text-center" scope="col">1일요금</th>
			<th class="text-center" scope="col">개통비/설치비</th>
			<th class="text-center" scope="col">보관일시</th>
			<th class="text-center" scope="col">삭제</th>
		<?php } else if ($is_auction_view) { ?>
			<th class="text-center" scope="col">경매번호</th>
			<th class="text-center" scope="col">경매상품번호</th>
			<th class="text-center" scope="col">상품명</th>
			<th class="text-center" scope="col">경매진행기간</th>
			<th class="text-center" scope="col">현재상태</th>
			<th class="text-center" scope="col">보관일시</th>
			<th class="text-center" scope="col">삭제</th>
		<?php } else { ?>
			<th class="text-center" scope="col">상품 정보</th>
			<th class="text-center" scope="col">최소계약</th>
			<th class="text-center" scope="col">1일요금</th>
			<th class="text-center" scope="col">개통비/설치비</th>
			<th class="text-center" scope="col">보관일시</th>
			<th class="text-center" scope="col">삭제</th>
		<?php } ?>
	</tr>
	<?php
	for($i=0; $i < count($list);$i++) {
		$wish_min_hours = apms_buy_qty_to_hours($list[$i]['it_buy_min_qty']);
		if($wish_min_hours <= 0) {
			$wish_min_hours = 1;
		}
		list($wish_min_day, $wish_min_hour) = apms_contract_day_hour_from_hours($wish_min_hours);
		$os_text = trim(str_ireplace(array('Microsoft', 'Windows'), array('', 'Win'), $list[$i]['it_spec_os']));

		// 판매자 표시 (통신판매중개 플랫폼: 상품별 판매자 명시)
		$_wi_seller_html = '';
		$_wi_pt_id = isset($list[$i]['pt_id']) ? trim((string)$list[$i]['pt_id']) : '';
		if ($_wi_pt_id !== '' && function_exists('get_pt_seller_name')) {
			$_wi_seller_nick = trim((string)get_pt_seller_name($_wi_pt_id));
			if ($_wi_seller_nick !== '') {
				$_wi_seller_html = '<div style="font-size:11px; color:#8a97a5; margin-top:2px;">판매자 <b style="font-weight:600;">'.get_text(cut_str($_wi_seller_nick, 18, '…')).'</b>';
				if (function_exists('get_pt_manner_temperature')) {
					$_wi_seller_html .= ' · 매너온도 '.get_pt_manner_temperature($_wi_pt_id);
				}
				$_wi_seller_html .= '</div>';
			}
		}
	?>
		<tr>
			<td class="text-center">
				<?php if($list[$i]['is_soldout']) { // 품절검사 ?>
					품절
				<?php } else { //품절이 아니면 체크할수 있도록한다 ?>
					<label for="chk_it_id_<?php echo $i; ?>" class="sound_only"><?php echo $list[$i]['it_name']; ?></label>
					<input type="checkbox" name="chk_it_id[<?php echo $i; ?>]" value="1" id="chk_it_id_<?php echo $i; ?>" onclick="out_cd_check(this, '<?php echo $list[$i]['out_cd']; ?>');" checked="checked">
				<?php } ?>
				<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $list[$i]['it_id']; ?>">
				<input type="hidden" name="io_type[<?php echo $list[$i]['it_id']; ?>][0]" value="0">
				<input type="hidden" name="io_id[<?php echo $list[$i]['it_id']; ?>][0]" value="">
				<input type="hidden" name="io_value[<?php echo $list[$i]['it_id']; ?>][0]" value="<?php echo $list[$i]['it_name']; ?>">
				<input type="hidden" name="ct_qty[<?php echo $list[$i]['it_id']; ?>][0]" value="<?php echo $wish_min_day; ?>">
				<input type="hidden" name="ct_qty_hour[<?php echo $list[$i]['it_id']; ?>][0]" value="<?php echo $wish_min_hour; ?>">
			</td>

			<?php if ($is_vpn_view) {
				// VPN: resolve country code
				$_wi_ccode = '';
				if (!empty($list[$i]['it_spec_remote_ip_country_code'])) {
					$_wi_ccode = trim((string)$list[$i]['it_spec_remote_ip_country_code']);
				}
				if (empty($_wi_ccode) && !empty($list[$i]['it_spec_remote_sw'])) {
					$_wi_sw = @json_decode($list[$i]['it_spec_remote_sw'], true);
					if (is_array($_wi_sw) && !empty($_wi_sw[0]['RemoteIP_CountryCode__0'])) {
						$_wi_ccode = trim((string)$_wi_sw[0]['RemoteIP_CountryCode__0']);
					}
				}
			?>
				<td class="wishlist-col-name">
					<div style="display:flex;align-items:flex-start;gap:8px">
						<div style="flex-shrink:0"><?php echo get_it_image($list[$i]['it_id'], 50, 50); ?></div>
						<div>
							<div style="display:flex;align-items:center;gap:4px;flex-wrap:wrap;margin-bottom:3px">
								<?php echo vpn_category_badge_html(isset($list[$i]['it_spec_os']) ? $list[$i]['it_spec_os'] : ''); ?>
								<?php echo vpn_grade_badge_html(isset($list[$i]['it_spec_grade']) ? $list[$i]['it_spec_grade'] : ''); ?>
								<span style="display:inline-block;padding:1px 6px;font-size:11px;font-weight:600;background:#374151;color:#d1d5db;border:1px solid #4b5563;vertical-align:middle;"><?php echo htmlspecialchars(stripslashes($list[$i]['it_name']),ENT_QUOTES); ?></span>
								<?php if (!empty($_wi_ccode)): ?>
								<span style="line-height:1;vertical-align:middle;"><?php echo vpn_country_flag($_wi_ccode); ?></span>
								<?php endif; ?>
							</div>
							<a href="<?php echo $list[$i]['item_href']; ?>" style="font-size:12px;color:#6b7280;"><?php echo htmlspecialchars(stripslashes($list[$i]['it_name']),ENT_QUOTES); ?></a>
						<?php echo $_wi_seller_html; ?>
						</div>
					</div>
				</td>
				<td class="text-center wishlist-col-contract"><?php echo apms_contract_hours_text($wish_min_hours); ?></td>
				<td class="text-right wishlist-col-price"><?php echo number_format($list[$i]['it_price']); ?> Point</td>
				<td class="text-center wishlist-col-date"><?php echo $list[$i]['wi_time']; ?></td>
				<td class="text-center wishlist-col-action"><a href="./wishupdate.php?w=d&amp;wi_id=<?php echo $list[$i]['wi_id']; ?>">삭제</a></td>
			<?php } else if ($is_rpc_view) {
				// RPC: build specs array
				$_wi_rmv = array("(R)","(TM)","with Radeon Graphics","with Radeon Vega Graphics","CPU","Core ","Eight-Processor");
				$_wi_cpu = trim(explode("\xC5\xBD",trim(str_ireplace($_wi_rmv,array_fill(0,count($_wi_rmv),''),(string)($list[$i]['it_spec_cpu']??''))))[0]);
				$_wi_gpu = trim(explode("\xC5\xBD",trim(str_replace(array("(R)","(TM)"),"",(string)($list[$i]['it_spec_gpu']??''))))[0]);
				$_wi_ram = trim((($list[$i]['it_spec_ram_type']??'')?$list[$i]['it_spec_ram_type'].' ':'').(string)($list[$i]['it_spec_ram']??''));
				$_wi_ssd = (($list[$i]['it_spec_ssd']??'')&&$list[$i]['it_spec_ssd']!=='0 GB')?trim((($list[$i]['it_spec_ssd_type']??'')?$list[$i]['it_spec_ssd_type'].' ':'').(string)($list[$i]['it_spec_ssd']??'')):'';
				$_wi_hdd = (($list[$i]['it_spec_hdd']??'')&&$list[$i]['it_spec_hdd']!=='0 GB')?trim((($list[$i]['it_spec_hdd_type']??'')?$list[$i]['it_spec_hdd_type'].' ':'').(string)($list[$i]['it_spec_hdd']??'')):'';
			?>
				<td class="wishlist-col-name">
					<div style="display:flex;align-items:flex-start;gap:8px">
						<div style="flex-shrink:0"><?php echo get_it_image($list[$i]['it_id'], 50, 50); ?></div>
						<div>
							<div style="display:flex;align-items:center;gap:4px;flex-wrap:wrap;margin-bottom:3px">
								<span style="display:inline-block;padding:1px 8px;font-size:11px;font-weight:700;letter-spacing:.4px;background:#0891b2;color:#fff;vertical-align:middle;">RPC</span>
								<?php echo vpn_grade_badge_html(isset($list[$i]['it_spec_grade']) ? $list[$i]['it_spec_grade'] : ''); ?>
								<span style="display:inline-block;padding:1px 6px;font-size:11px;font-weight:600;background:#374151;color:#d1d5db;border:1px solid #4b5563;vertical-align:middle;"><?php echo htmlspecialchars(stripslashes($list[$i]['it_name']),ENT_QUOTES); ?></span>
							</div>
							<div style="display:flex;align-items:center;gap:5px;flex-wrap:wrap;margin-bottom:2px">
								<?php if ($os_text): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">OS</b><?php echo htmlspecialchars($os_text); ?></span><?php endif; ?>
								<?php if ($_wi_cpu): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">CPU</b><?php echo htmlspecialchars($_wi_cpu); ?></span><?php endif; ?>
								<?php if ($_wi_gpu): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">GPU</b><?php echo htmlspecialchars($_wi_gpu); ?></span><?php endif; ?>
								<?php if ($_wi_ram): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">RAM</b><?php echo htmlspecialchars($_wi_ram); ?></span><?php endif; ?>
								<?php if ($_wi_ssd): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">SSD</b><?php echo htmlspecialchars($_wi_ssd); ?></span><?php endif; ?>
								<?php if ($_wi_hdd): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">HDD</b><?php echo htmlspecialchars($_wi_hdd); ?></span><?php endif; ?>
							</div>
							<?php echo $_wi_seller_html; ?>
						</div>
					</div>
				</td>
				<td class="text-center wishlist-col-contract" style="line-height:3em;"><?php echo apms_contract_hours_text($wish_min_hours); ?></td>
				<td class="text-right wishlist-col-price"><?php echo number_format($list[$i]['it_price']); ?> Point</td>
				<td class="text-right wishlist-col-price"><?php echo number_format($list[$i]['it_install_price']); ?> Point</td>
				<td class="text-center wishlist-col-date"><?php echo $list[$i]['wi_time']; ?></td>
				<td class="text-center wishlist-col-action"><a href="./wishupdate.php?w=d&amp;wi_id=<?php echo $list[$i]['wi_id']; ?>">삭제</a></td>
			<?php } else if ($is_auction_view) { ?>
				<td class="text-center wishlist-col-id"><a href="<?php echo $list[$i]['item_href']; ?>"><?php echo !empty($list[$i]['auction_wr_id']) ? $list[$i]['auction_wr_id'] : '-'; ?></a></td>
				<td class="text-center wishlist-col-id"><a href="<?php echo $list[$i]['item_href']; ?>"><?php echo !empty($list[$i]['auction_pcnum']) ? $list[$i]['auction_pcnum'] : ('RPC-A'.$list[$i]['it_id']); ?></a></td>
				<td class="wishlist-col-name"><a href="<?php echo $list[$i]['item_href']; ?>"><?php echo vpn_grade_badge_html(isset($list[$i]['it_spec_grade']) ? $list[$i]['it_spec_grade'] : ''); ?><b><?php echo stripslashes($list[$i]['it_name']); ?></b></a><?php echo $_wi_seller_html; ?></td>
				<td class="text-center"><?php echo !empty($list[$i]['auction_term']) ? $list[$i]['auction_term'] : '-'; ?></td>
				<td class="text-center wishlist-col-status"><?php echo !empty($list[$i]['auction_status']) ? $list[$i]['auction_status'] : '-'; ?></td>
				<td class="text-center wishlist-col-date"><?php echo $list[$i]['wi_time']; ?></td>
				<td class="text-center wishlist-col-action"><a href="./wishupdate.php?w=d&amp;wi_id=<?php echo $list[$i]['wi_id']; ?>">삭제</a></td>
			<?php } else {
				// all view: RPC 뷰와 동일한 카드/컬럼 구성 (VPN 상품은 VPN 배지 표시)
				$_all_is_vpn = in_array(substr((string)($list[$i]['ca_id'] ?? ''), 0, 2), array('30','40'), true);
				if ($_all_is_vpn) {
					$_cat_b = vpn_category_badge_html(isset($list[$i]['it_spec_os']) ? $list[$i]['it_spec_os'] : '');
					if ($_cat_b === '') $_cat_b = '<span style="display:inline-block;padding:1px 8px;font-size:11px;font-weight:700;letter-spacing:.4px;background:#0891b2;color:#fff;vertical-align:middle;">VPN</span>';
				} else {
					$_cat_b = '<span style="display:inline-block;padding:1px 8px;font-size:11px;font-weight:700;letter-spacing:.4px;background:#0891b2;color:#fff;vertical-align:middle;">RPC</span>';
				}
				$_all_ccode = '';
				if (!empty($list[$i]['it_spec_remote_ip_country_code'])) {
					$_all_ccode = trim((string)$list[$i]['it_spec_remote_ip_country_code']);
				}
				if (empty($_all_ccode) && !empty($list[$i]['it_spec_remote_sw'])) {
					$_all_sw = @json_decode($list[$i]['it_spec_remote_sw'], true);
					if (is_array($_all_sw) && !empty($_all_sw[0]['RemoteIP_CountryCode__0'])) {
						$_all_ccode = trim((string)$_all_sw[0]['RemoteIP_CountryCode__0']);
					}
				}
				// 스펙 구성 (RPC 뷰와 동일, VPN 상품은 OS 표기 제외)
				$_wi_rmv = array("(R)","(TM)","with Radeon Graphics","with Radeon Vega Graphics","CPU","Core ","Eight-Processor");
				$_wi_cpu = trim(explode("\xC5\xBD",trim(str_ireplace($_wi_rmv,array_fill(0,count($_wi_rmv),''),(string)($list[$i]['it_spec_cpu']??''))))[0]);
				$_wi_gpu = trim(explode("\xC5\xBD",trim(str_replace(array("(R)","(TM)"),"",(string)($list[$i]['it_spec_gpu']??''))))[0]);
				$_wi_ram = trim((($list[$i]['it_spec_ram_type']??'')?$list[$i]['it_spec_ram_type'].' ':'').(string)($list[$i]['it_spec_ram']??''));
				$_wi_ssd = (($list[$i]['it_spec_ssd']??'')&&$list[$i]['it_spec_ssd']!=='0 GB')?trim((($list[$i]['it_spec_ssd_type']??'')?$list[$i]['it_spec_ssd_type'].' ':'').(string)($list[$i]['it_spec_ssd']??'')):'';
				$_wi_hdd = (($list[$i]['it_spec_hdd']??'')&&$list[$i]['it_spec_hdd']!=='0 GB')?trim((($list[$i]['it_spec_hdd_type']??'')?$list[$i]['it_spec_hdd_type'].' ':'').(string)($list[$i]['it_spec_hdd']??'')):'';
			?>
				<td class="wishlist-col-name">
					<div style="display:flex;align-items:flex-start;gap:8px">
						<div style="flex-shrink:0"><?php echo get_it_image($list[$i]['it_id'], 50, 50); ?></div>
						<div>
							<div style="display:flex;align-items:center;gap:4px;flex-wrap:wrap;margin-bottom:3px">
								<?php echo $_cat_b; ?>
								<?php echo vpn_grade_badge_html(isset($list[$i]['it_spec_grade']) ? $list[$i]['it_spec_grade'] : ''); ?>
								<span style="display:inline-block;padding:1px 6px;font-size:11px;font-weight:600;background:#374151;color:#d1d5db;border:1px solid #4b5563;vertical-align:middle;"><?php echo htmlspecialchars(stripslashes($list[$i]['it_name']),ENT_QUOTES); ?></span>
								<?php if (!empty($_all_ccode)): ?><span style="line-height:1;vertical-align:middle;"><?php echo vpn_country_flag($_all_ccode); ?></span><?php endif; ?>
							</div>
							<div style="display:flex;align-items:center;gap:5px;flex-wrap:wrap;margin-bottom:2px">
								<?php if (!$_all_is_vpn && $os_text): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">OS</b><?php echo htmlspecialchars($os_text); ?></span><?php endif; ?>
								<?php if ($_wi_cpu): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">CPU</b><?php echo htmlspecialchars($_wi_cpu); ?></span><?php endif; ?>
								<?php if ($_wi_gpu): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">GPU</b><?php echo htmlspecialchars($_wi_gpu); ?></span><?php endif; ?>
								<?php if ($_wi_ram): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">RAM</b><?php echo htmlspecialchars($_wi_ram); ?></span><?php endif; ?>
								<?php if ($_wi_ssd): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">SSD</b><?php echo htmlspecialchars($_wi_ssd); ?></span><?php endif; ?>
								<?php if ($_wi_hdd): ?><span style="display:inline-flex;align-items:center;gap:2px;font-size:11px;color:#374151"><b style="color:#6b7280;font-weight:600;font-size:10px">HDD</b><?php echo htmlspecialchars($_wi_hdd); ?></span><?php endif; ?>
							</div>
							<a href="<?php echo $list[$i]['item_href']; ?>" style="font-size:12px;color:#6b7280;"><?php echo htmlspecialchars(stripslashes($list[$i]['it_name']),ENT_QUOTES); ?></a>
							<?php echo $_wi_seller_html; ?>
						</div>
					</div>
				</td>
				<td class="text-center wishlist-col-contract" style="line-height:3em;"><?php echo apms_contract_hours_text($wish_min_hours); ?></td>
				<td class="text-right wishlist-col-price"><?php echo number_format($list[$i]['it_price']); ?> Point</td>
				<td class="text-right wishlist-col-price"><?php echo number_format($list[$i]['it_install_price']); ?> Point</td>
				<td class="text-center wishlist-col-date"><?php echo $list[$i]['wi_time']; ?></td>
				<td class="text-center wishlist-col-action"><a href="./wishupdate.php?w=d&amp;wi_id=<?php echo $list[$i]['wi_id']; ?>">삭제</a></td>
			<?php } ?>
		</tr>
	<?php } ?>
	<?php if ($i == 0) { ?>
		<tr>
			<td colspan="<?php echo ($is_all_view ? 7 : ($is_vpn_view ? 6 : 8)); ?>" class="text-center text-muted" height="150">보관함이 비었습니다.</td>
		</tr>
	<?php } ?>
	</tbody>
	</table>
</div>

<p class="text-center">
	<?php if ($is_auction_view) { ?>
		<span class="text-muted">경매상품은 장바구니 담기를 지원하지 않습니다. 항목명을 눌러 경매 페이지에서 진행해 주세요.</span>
	<?php } else { ?>
		<button type="submit" class="btn btn-black btn-sm" onclick="return fwishlist_check(document.fwishlist,'');">장바구니 담기</button>
	<?php } ?>
	<?php /*
	<button type="submit" class="btn btn-color btn-sm" onclick="return fwishlist_check(document.fwishlist,'direct_buy');">주문하기</button>
	*/ ?>
</p>
</form>

<br>

<script>
    function out_cd_check(fld, out_cd) {
        if (out_cd == 'no'){
            alert("옵션이 있습니다.\n\n클릭하여 상세내용페이지에서 옵션을 선택한 후 주문하십시오.");
            fld.checked = false;
            return;
        }

        if (out_cd == 'tel'){
            alert("전화로 문의해 주십시오.\n\n장바구니에 담아 구입하실 수 없습니다.");
            fld.checked = false;
            return;
        }
    }

    function fwishlist_check(f, act) {
        var k = 0;
        var length = f.elements.length;

        for(i=0; i<length; i++) {
            if (f.elements[i].checked) {
                k++;
            }
        }

        if(k == 0) {
            alert("하나 이상 체크 하십시오");
            return false;
        }

        if (act == "direct_buy") {
            f.sw_direct.value = 1;
        } else {
            f.sw_direct.value = 0;
        }

        return true;
    }

	$(function() {
		// 모두선택
		$("input[name=chk_it_id_all]").click(function() {
			if($(this).is(":checked"))
				$("input[name^=chk_it_id]").attr("checked", true);
			else
				$("input[name^=chk_it_id]").attr("checked", false);
		});
	});
</script>
