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

<h1><i class="fa fa-cube"></i> 내상품(일반/경매)관리 (RPC)</h1>
<link rel="stylesheet" href="<?php echo G5_URL; ?>/css/lock_filter_loading.css">

<?php
if ($member['mb_id'] == 'comviewers') {
?>
<div style="display: flex; margin-bottom: 10px;">
    <div style="flex: 1; text-align: left;">
        <div id="execute-btn" class="btn btn-danger btn-sm"><i class="fa fa-upload"></i> 컴뷰어스 리셀러 노출 승인 품번 자동 신규등록/업데이트 실행</div>
    </div>
</div>
<div id="result-layer" style="display: none; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background: rgba(0,0,0,0.5); border: 1px solid #ccc; padding: 20px; overflow: auto; z-index: 2000;">
    <div id="result-content" style="position: fixed; top: 60px; left: 20%; width: calc(100% - 40%); height: calc(100% - 40px); background: transparent; box-sizing: border-box;">
    </div>
	<button id="close-layer" class="btn btn-sm" style="position: fixed; top: 13px; right: 13px; color: red;"><i class="fa fa-close"></i> Close</button>
</div>

<script>
$(document).ready(function() {
    // AJAX 요청 및 결과 표시
    $('#execute-btn').on('click', function() {
        $.ajax({
            url: '<?php echo G5_URL?>/__api/get_comviewers.com_ajax.php',
            method: 'GET',
            dataType: 'json',
            success: function(data) {
                $('#result-content').html('<pre>' + JSON.stringify(data, null, 2) + '</pre>');
                $('#result-layer').show();
                // 배경 페이지 스크롤 방지 및 스크롤바 공간 보존
                $('body').css({
                    'overflow': 'hidden',
                    'padding-right': '17px' // 스크롤바 너비에 따라 조정
                });
            }
        });
    });

    // 레이어 닫기 버튼 이벤트 리스너
    $('#close-layer').on('click', function() {
        $('#result-layer').hide();
        // 배경 페이지 스크롤 허용 및 원래 상태로 복원
        $('body').css({
            'overflow': 'auto',
            'padding-right': '0'
        });
    });
});
</script>

<?php
}
?>

<div class="well" style="padding-bottom:3px;">
	<form class="form" role="form" name="flist">
	<input type="hidden" name="ap" value="<?php echo $ap;?>">
	<input type="hidden" name="save_stx" value="<?php echo $stx; ?>">
	<?php
	$filter_common_qs = 'ap='.urlencode($ap)
		.'&amp;sca='.urlencode($sca)
		.'&amp;stx='.urlencode($stx)
		.'&amp;save_stx='.urlencode($stx)
		.'&amp;sfl='.urlencode($sfl)
		.'&amp;sst='.urlencode($sst)
		.'&amp;sod='.urlencode($sod)
		.'&amp;vpn_conflict_window='.urlencode($vpn_conflict_window);
	$url_lock_all = './?'.$filter_common_qs.'&amp;lock_only=1';
	$url_lock_paid = './?'.$filter_common_qs.'&amp;lock_only=1&amp;lock_reason=paid';
	$url_lock_cancelled = './?'.$filter_common_qs.'&amp;lock_only=1&amp;lock_reason=cancelled';
	?>
		<div class="row">
			<div class="col-sm-3">
				<div class="form-group">
					<label for="sca" class="sound_only">분류선택</label>
					<select name="sca" id="sca" class="form-control input-sm">
						<option value="">카테고리</option>
						<?php echo $category_options;?>
					</select>
				    <script>document.getElementById("sca").value = "<?php echo $sca; ?>";</script>
				</div>
			</div>
			<div class="col-sm-3">
				<div class="form-group">
					<div class="form-group">
					    <label for="stx" class="sound_only">검색어</label>
					    <input type="text" name="stx" value="<?php echo $stx ?>" id="stx" class="form-control input-sm" placeholder="상품명 검색어">
					    <div style="margin-top:6px;">
							<label for="lock_only" style="font-weight:normal; margin:0;">
								<input type="checkbox" name="lock_only" id="lock_only" value="1" <?php echo ($lock_only === '1') ? 'checked' : ''; ?>> 영구잠금만
							</label>
						</div>
						<div style="margin-top:6px;">
							<label for="lock_reason_all" style="font-weight:normal; margin-right:8px;">
								<input type="radio" name="lock_reason" id="lock_reason_all" value="" <?php echo ($lock_reason === '') ? 'checked' : ''; ?>> 전체
							</label>
							<label for="lock_reason_paid" style="font-weight:normal; margin-right:8px;">
								<input type="radio" name="lock_reason" id="lock_reason_paid" value="paid" <?php echo ($lock_reason === 'paid') ? 'checked' : ''; ?>> 결제완료형
							</label>
							<label for="lock_reason_cancelled" style="font-weight:normal; margin:0;">
								<input type="radio" name="lock_reason" id="lock_reason_cancelled" value="cancelled" <?php echo ($lock_reason === 'cancelled') ? 'checked' : ''; ?>> 취소/반품형
							</label>
						</div>
					</div>
				</div>
			</div>
			<div class="col-sm-3">
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm btn-block"><i class="fa fa-search"></i> 보기</button>
					<div style="margin-top:6px;">
						<label for="vpn_conflict_window" class="sr-only">VPN 자동변경 기준</label>
						<select name="vpn_conflict_window" id="vpn_conflict_window" class="form-control input-sm">
							<option value="all"<?php echo get_selected($vpn_conflict_window, 'all'); ?>>VPN 자동변경 전체</option>
							<option value="30d"<?php echo get_selected($vpn_conflict_window, '30d'); ?>>VPN 자동변경 최근 30일</option>
						</select>
					</div>
				</div>
			</div>
			<div class="col-sm-3">
				<div class="form-group">
					<a href="./?ap=item&amp;fn=3&amp;cfn=1" class="btn btn-danger btn-sm btn-block"><i class="fa fa-upload"></i> 신규등록</a>
				</div>
			</div>
		</div>
	</form>
</div>

<div id="lockFilterLoadingRpc" class="lock-filter-loading" style="display:none;">
	<span class="lock-filter-loading__badge">
		<span class="lock-filter-loading__spinner"></span>
		<span>필터 적용 중...</span>
	</span>
</div>

<script>
$(function() {
	var $form = $('form[name="flist"]');
	var $loading = $('#lockFilterLoadingRpc');
	if(!$form.length) return;

	$form.on('submit', function() {
		$loading.show();
	});

	$('#lock_only, input[name="lock_reason"]').on('change', function() {
		if($(this).attr('name') === 'lock_reason') {
			var val = $('input[name="lock_reason"]:checked').val() || '';
			if(val !== '') {
				$('#lock_only').prop('checked', true);
			}
		}
		$form.trigger('submit');
	});
});
</script>

<h3>
	<i class="fa fa-cubes"></i> <?php echo number_format($total_count); ?> Items
</h3>
<div class="text-muted" style="margin-top:-8px; margin-bottom:12px; font-size:12px;">
	<a href="<?php echo $url_lock_all; ?>">영구잠금(현재검색)</a>: <b><?php echo number_format($lock_stats['locked']); ?></b>건
	/ <a href="<?php echo $url_lock_paid; ?>">결제완료형</a>: <b><?php echo number_format($lock_stats['paid']); ?></b>건
	/ <a href="<?php echo $url_lock_cancelled; ?>">결제후 취소·반품형</a>: <b><?php echo number_format($lock_stats['cancelled']); ?></b>건
</div>

<form class="form" role="form" name="fitemlistupdate" method="post" action="./itemlistupdate.php" onsubmit="return fitemlist_submit(this);" autocomplete="off">
<input type="hidden" name="ap" value="<?php echo $ap;?>">
<input type="hidden" name="sca" value="<?php echo $sca; ?>">
<input type="hidden" name="sst" value="<?php echo $sst; ?>">
<input type="hidden" name="sod" value="<?php echo $sod; ?>">
<input type="hidden" name="sfl" value="<?php echo $sfl; ?>">
<input type="hidden" name="stx" value="<?php echo $stx; ?>">
<input type="hidden" name="lock_only" value="<?php echo $lock_only; ?>">
<input type="hidden" name="lock_reason" value="<?php echo $lock_reason; ?>">
<input type="hidden" name="vpn_conflict_window" value="<?php echo $vpn_conflict_window; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">

<style>
	.flag-and-city {
		display: flex;
		align-items: center;
		flex-direction: row;
		justify-content: center;
		gap: 5px;
		line-height: 1.2;
		max-width: 100%;
	}
	.flag-and-city img {
		height: 15px;
		width: 23px;
		border: 1px solid #ddd;
		border-radius: 2px;
		object-fit: cover;
	}
	.flag-and-city span {
		display: inline-block;
		font-size: 12px;
		color: #4b5f73;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		max-width: 120px;
	}
	@media (max-width: 1400px) {
		.flag-and-city span { max-width: 100px; }
	}
	@media (max-width: 1200px) {
		.flag-and-city span { max-width: 84px; }
	}
	@media (max-width: 992px) {
		.flag-and-city span { max-width: 68px; }
	}
	@media (max-width: 768px) {
		.flag-and-city span { max-width: 56px; }
	}
	@media (max-width: 480px) {
		.flag-and-city {
			flex-direction: column;
			gap: 3px;
		}
		.flag-and-city span {
			max-width: 72px;
			text-align: center;
		}
	}
	/* 선택삭제/선택수정 버튼 다크모드 */
	[data-site-theme="dark"] .btn-default {
		background: #2c2c32 !important;
		border-color: #4a4a52 !important;
		color: #c4c4cc !important;
	}
	[data-site-theme="dark"] .btn-default:hover,
	[data-site-theme="dark"] .btn-default:focus {
		background: #3a3a42 !important;
		border-color: #5a5a62 !important;
		color: #e4e4e8 !important;
	}
	/* PC 스펙 칩 */
	.il-spec-grid { display:flex; flex-wrap:wrap; gap:3px; min-width:220px; }
	.il-spec-chip { display:inline-flex; align-items:center; gap:3px; background:#f0f4f8; border:1px solid #e2e8f0; border-radius:4px; padding:2px 5px; }
	.il-spec-chip .sc-l { font-size:9px; font-weight:800; color:#64748b; letter-spacing:.3px; flex-shrink:0; }
	.il-spec-chip .sc-v { font-size:11px; color:#1e293b; max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
	[data-site-theme="dark"] .il-spec-chip { background:#252530; border-color:#3a3a42; }
	[data-site-theme="dark"] .il-spec-chip .sc-l { color:#71717a; }
	[data-site-theme="dark"] .il-spec-chip .sc-v { color:#d4d4d8; }
	.vpn-conflict-mini { margin-top:6px; line-height:1.4; }
	.vpn-conflict-mini .badge { display:inline-block; padding:2px 8px; border-radius:999px; background:#eef7ee; color:#1f6b2a; font-size:11px; font-weight:600; }
	.vpn-conflict-mini .meta { margin-left:6px; color:#666; font-size:11px; }
	.vpn-conflict-mini .pair { display:block; margin-top:3px; color:#666; font-size:11px; word-break:break-all; }
	/* 상품종류 배지 */
	.vpn-type-badge {
		display: inline-block; padding: 2px 7px; border-radius: 4px;
		font-size: 11px; font-weight: 700; white-space: nowrap;
	}
	.vpn-type-IKEv2    { background:#dbeafe; color:#1e40af; border:1px solid #93c5fd; }
	.vpn-type-PPTP     { background:#f3f4f6; color:#374151; border:1px solid #d1d5db; }
	.vpn-type-OpenVPN  { background:#d1fae5; color:#065f46; border:1px solid #6ee7b7; }
	.vpn-type-WireGuard{ background:#fef3c7; color:#92400e; border:1px solid #fcd34d; }
	.vpn-type-L2TP     { background:#ede9fe; color:#4c1d95; border:1px solid #c4b5fd; }
	.vpn-type-RPC      { background:#fee2e2; color:#991b1b; border:1px solid #fca5a5; }
	/* 상품등급 배지 */
	.vpn-grade-badge {
		display: inline-block; padding: 2px 7px; border-radius: 4px;
		font-size: 11px; font-weight: 700; white-space: nowrap;
	}
	.vpn-grade-BASIC { background:#f3f4f6; color:#374151; border:1px solid #d1d5db; }
	.vpn-grade-PLUS  { background:#dbeafe; color:#1e40af; border:1px solid #93c5fd; }
	.vpn-grade-PRO   { background:#d1fae5; color:#065f46; border:1px solid #6ee7b7; }
	.vpn-grade-ULTRA { background:#fef3c7; color:#92400e; border:1px solid #fcd34d; }
	.vpn-grade-MAX   { background:#fae8ff; color:#6b21a8; border:1px solid #d8b4fe; }
</style>

	<div class="table-responsive">
		<table class="table tbl bg-white">
		<tbody>
		<tr class="bg-black">
			<th width="40" class="text-center" scope="col">
				<label for="chkall" class="sound_only">전체</label>
				<input type="checkbox" name="chkall" value="1" id="chkall" onclick="check_all(this.form)" style="zoom:1.5;">
			</th>
			<th width="60" class="text-center" scope="col">순서</th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_sales_type', 'ap='.$ap.'&amp;sca='.$sca); ?>적용메뉴</th>
			<?php /*
			<th width="100" class="text-center" scope="col"><?php echo subject_sort_link('it_id', 'ap='.$ap.'&amp;sca='.$sca); ?>상품코드</a></th>
			<th width="60" class="text-center" scope="col">이미지</th>
			*/ ?>
			<th class="text-center" scope="col">관리컴퓨터별명</th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_name', 'ap='.$ap.'&amp;sca='.$sca); ?>상품명</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_grade', 'ap='.$ap.'&amp;sca='.$sca); ?>상품등급</a></th>
			<th class="text-center" scope="col">PC 스펙</th>
			<th class="text-center" scope="col">KBD/MOUSE</th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_remote_sw', 'ap='.$ap.'&amp;sca='.$sca); ?>원격접속IP</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_remote_sw', 'ap='.$ap.'&amp;sca='.$sca); ?>원격제어S/W</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_app_ver', 'ap='.$ap.'&amp;sca='.$sca); ?>APP설치</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_buy_min_qty', 'ap='.$ap.'&amp;sca='.$sca); ?>최소계약</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_buy_max_qty', 'ap='.$ap.'&amp;sca='.$sca); ?>최대계약</a></th>
			<th class="text-right" scope="col"><?php echo subject_sort_link('it_price', 'ap='.$ap.'&amp;sca='.$sca); ?>판매가 [1H/1D/1M]</a></th>
			<th class="text-right" scope="col"><?php echo subject_sort_link('it_install_price', 'ap='.$ap.'&amp;sca='.$sca); ?>개통비/설치비</a></th>
			<th class="text-center" scope="col">상태<!-- / 주문일시 / 주문회원ID / 주문일수 / 주문금액 --></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_use', 'ap='.$ap.'&amp;sca='.$sca); ?>판매</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_soldout', 'ap='.$ap.'&amp;sca='.$sca); ?>품절</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_auction', 'ap='.$ap.'&amp;sca='.$sca); ?>경매</a></th>
			<th width="60" class="text-center" scope="col">관리</th>
			<?php /*
			<th width="60" class="text-center" scope="col">비고</th>
			*/ ?>
		</tr>
		<?php for ($i=0; $i < count($list); $i++) { ?>
		<tr>
			<td class="text-center">
				<label for="chk_<?php echo $i; ?>" class="sound_only"><?php echo get_text($list[$i]['it_name']); ?></label>
				<input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i; ?>" style="zoom:1.5;">
	            <input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $list[$i]['it_id']; ?>">
			</td>
			<td class="text-center">
	            <input type="text" name="pt_show[<?php echo $i; ?>]" value="<?php echo $list[$i]['pt_show']; ?>" size="4" class="frm_input">
			</td>
			<td class="text-center">
				<a href="<?php echo $list[$i]['href']; ?>">
					<?php echo strtoupper($list[$i]['it_spec_sales_type']);?>
				</a>
			</td>
			<?php /*
			<td class="text-center">
				<a href="<?php echo $list[$i]['href']; ?>">
					<nobr><?php echo $list[$i]['it_id'];?></nobr>
				</a>
			</td>
			<td class="text-center">
				<a href="<?php echo $list[$i]['href']; ?>">
					<?php echo get_it_image($list[$i]['it_id'], 40, 40);?>
				</a>
			</td>
			*/ ?>

			<td class="text-center">
				<?php echo $list[$i]['it_spec_mgr_nickname']; ?>
			</td>
			<td>
				<a href="<?php echo $list[$i]['href']; ?>"><b><?php echo $list[$i]['it_name'];?></b></a>
				<?php if (apms_pt_it('',$list[$i]['pt_it'])) { ?>
				<div class="text-muted" style="margin-top:2px; font-size:11px;"><?php echo apms_pt_it('',$list[$i]['pt_it']);?></div>
				<?php } ?>
				<?php if (!empty($list[$i]['vpn_id_conflict_count'])) { ?>
				<div class="vpn-conflict-mini">
					<span class="badge">VPN ID 자동변경 <?php echo number_format((int)$list[$i]['vpn_id_conflict_count']); ?>건</span>
					<?php if (!empty($list[$i]['vpn_id_conflict_last'])) { ?><span class="meta"><?php echo $list[$i]['vpn_id_conflict_last']; ?></span><?php } ?>
					<?php if (!empty($list[$i]['vpn_id_conflict_last_od_id'])) { ?>
						<div class="meta" style="margin-left:0; margin-top:3px;">
							<a href="./inquiryview.php?no=<?php echo urlencode($list[$i]['vpn_id_conflict_last_od_id']); ?>" class="win_point">최근 주문 <?php echo get_text($list[$i]['vpn_id_conflict_last_od_id']); ?></a>
						</div>
					<?php } ?>
					<?php if (!empty($list[$i]['vpn_id_conflict_last_pair'])) { ?><span class="pair"><?php echo get_text($list[$i]['vpn_id_conflict_last_pair']); ?></span><?php } ?>
				</div>
				<?php } ?>
			</td>
			<td class="text-center"> <!-- 상품등급 -->
				<?php
				$grade = $list[$i]['it_spec_grade'];
				if ($grade) {
					$safe = htmlspecialchars($grade);
					echo '<span class="vpn-grade-badge vpn-grade-'.$safe.'">'.$safe.'</span>';
				} else {
					echo '<span style="color:#9ca3af;">-</span>';
				}
				?>
			</td>
			<td class="text-left"> <!-- PC 스펙 -->
				<?php
				$_os  = trim($list[$i]['it_spec_os'] ?? '');
				$_cpu = trim($list[$i]['it_spec_cpu'] ?? '');
				$_ram = trim(($list[$i]['it_spec_ram_type'] ?? '') . ' ' . ($list[$i]['it_spec_ram'] ?? ''));
				$_gpu = trim($list[$i]['it_spec_gpu'] ?? '');
				$_ssd = trim(($list[$i]['it_spec_ssd_type'] ?? '') . ' ' . ($list[$i]['it_spec_ssd'] ?? ''));
				$_hdd = trim(($list[$i]['it_spec_hdd_type'] ?? '') . ' ' . ($list[$i]['it_spec_hdd'] ?? ''));
				// CPU 단축
				if ($_cpu) {
					if (preg_match('/(i[3579]-[\w]+)/i', $_cpu, $_m)) $_cpu_s = $_m[1];
					elseif (preg_match('/(Ryzen\s+[39]\s+[\w]+)/i', $_cpu, $_m)) $_cpu_s = str_replace('Ryzen ', 'R', $_m[1]);
					elseif (strlen($_cpu) > 18) $_cpu_s = substr($_cpu, 0, 16) . '…';
					else $_cpu_s = $_cpu;
				}
				// GPU 단축
				if ($_gpu) {
					if (preg_match('/(RTX\s*[\d]+(?:\s*[\w]+)?|GTX\s*[\d]+(?:\s*[\w]+)?|RX\s*[\d]+(?:\s*[\w]+)?)/i', $_gpu, $_m)) $_gpu_s = trim($_m[1]);
					elseif (strlen($_gpu) > 16) $_gpu_s = substr($_gpu, 0, 14) . '…';
					else $_gpu_s = $_gpu;
				}
				// OS 단축
				if ($_os) {
					$_os_s = str_replace(['Windows ', 'Enterprise', 'Professional'], ['Win', 'Ent', 'Pro'], $_os);
					if (strlen($_os_s) > 13) $_os_s = substr($_os_s, 0, 11) . '…';
				}
				$_il_chips = [];
				if (!empty($_os))  $_il_chips[] = ['OS',  $_os_s,  $_os];
				if (!empty($_cpu)) $_il_chips[] = ['CPU', $_cpu_s, $_cpu];
				if (!empty($_ram)) $_il_chips[] = ['RAM', $_ram,   $_ram];
				if (!empty($_gpu)) $_il_chips[] = ['GPU', $_gpu_s, $_gpu];
				if (!empty($_ssd)) $_il_chips[] = ['SSD', $_ssd,   $_ssd];
				if (!empty($_hdd)) $_il_chips[] = ['HDD', $_hdd,   $_hdd];
				if ($_il_chips) {
					echo '<div class="il-spec-grid">';
					foreach ($_il_chips as $_c) {
						echo '<span class="il-spec-chip">'
						   . '<span class="sc-l">'.htmlspecialchars($_c[0]).'</span>'
						   . '<span class="sc-v" title="'.htmlspecialchars($_c[2]).'">'.htmlspecialchars($_c[1]).'</span>'
						   . '</span>';
					}
					echo '</div>';
				} else {
					echo '<span style="color:#9ca3af;">-</span>';
				}
				?>
			</td>
			<td class="text-center"> <!-- KBD/MOUSE -->
				<?php
				$_kbd   = $list[$i]['it_spec_keyboard'] ?: '-';
				$_mouse = $list[$i]['it_spec_mouse'] ?: '-';
				echo htmlspecialchars($_kbd) . ' / ' . htmlspecialchars($_mouse);
				?>
			</td>
			<td class="text-center"> <!-- 원격접속IP -->
				<?php echo $list[$i]['it_spec_remote_ip']; ?>
			</td>
			<td class="text-left"> <!-- 원격접속S/W -->
				<?php echo $list[$i]['it_spec_remote_program']; ?>
			</td>
			<td class="text-center"> <!-- APP VERSION -->
				<?php echo $list[$i]['it_spec_app_ver']; ?>
			</td>
			<td class="text-center"> <!-- 최소구매일수 -->
				<?php
					$min_hours = apms_buy_qty_to_hours($list[$i]['it_buy_min_qty']);
					echo apms_contract_hours_text($min_hours);
				?>
			</td>
			<td class="text-center"> <!-- 최대구매일수 -->
				<?php
					$max_hours = apms_buy_qty_to_hours($list[$i]['it_buy_max_qty']);
					echo apms_contract_hours_text($max_hours);
				?>
			</td>
			<td class="text-right"> <!-- 판매가 [1H/1D/1M] -->
				<div><?php echo number_format((int)$list[$i]['it_price_1h']) . ' / ' . number_format((int)$list[$i]['it_price_1d']) . ' / ' . number_format((int)$list[$i]['it_price_1m']) . " Point"; ?></div>
				<div class="text-muted" style="font-size:11px; margin-top:2px;">
					<?php echo $list[$i]['it_billing_plan_label']; ?>
				</div>
			</td>
			<td class="text-right"> <!-- 개통비 -->
				<?php echo number_format($list[$i]['it_install_price']) . " Point"; ?>
			</td>
			<td class="text-center"> <!-- 상태 -->
				<?php echo $list[$i]['ct_status'];?>
			</td>
	        <td class="text-center">
		        <label for="use_<?php echo $i; ?>" class="sound_only">판매</label>
			    <input type="checkbox" name="it_use[<?php echo $i; ?>]" <?php echo ($list[$i]['it_use'] ? 'checked' : ''); ?> value="1" id="use_<?php echo $i; ?>" style="zoom:1.5;">
	        </td>
	        <td class="text-center">
		        <label for="usoldout_<?php echo $i; ?>" class="sound_only">품절</label>
			    <input type="checkbox" name="it_soldout[<?php echo $i; ?>]" <?php echo ($list[$i]['it_soldout'] ? 'checked' : ''); ?> value="1" id="soldout_<?php echo $i; ?>" style="zoom:1.5;">
	        </td>
			<td class="text-center">
		        <label for="usoldout_<?php echo $i; ?>" class="sound_only">경매</label>
				<input type="checkbox" name="auction_on[<?php echo $i; ?>]" <?php echo ($list[$i]['auction_on'] ? 'checked' : ''); ?> value="1" id="auction_<?php echo $i; ?>" onclick="this.checked = <?php echo ($list[$i]['auction_on'] ? 'true' : 'false'); ?>; alert('경매 상태 변경은 수정 페이지에서만 가능합니다.')" style="zoom:1.5;">
	        </td>
			<td class="text-center">
				<a href="./?ap=item&amp;w=u&amp;it_id=<?php echo $list[$i]['it_id']; ?>&amp;fn=<?php echo $list[$i]['pt_form'];?>&amp;ca_id=<?php echo $list[$i]['ca_id']; ?>" class="partner-edit-btn">수정</a>
			</td>
			<?php /*
			<td class="text-center">
				<?php echo ($list[$i]['pt_reserve_use']) ? subject_sort_link('pt_reserve_use', 'mode=list&amp;sca='.$sca, 1).'예약</a>' : ''; ?>
			</td>
			*/ ?>
		</tr>
		<?php } ?>
		<?php if ($i == 0) { ?>
			<tr><td colspan="20" class="text-center">등록된 자료가 없습니다.</td></tr>
		<?php } ?>
		</tbody>
		</table>
	</div>

	<div style="margin-bottom:20px;">
		<div class="form-group pull-left">
			<input type="submit" name="act_button" value="선택삭제" onclick="document.pressed=this.value" class="btn btn-default btn-sm">
		    <input type="submit" name="act_button" value="선택수정" onclick="document.pressed=this.value" class="btn btn-default btn-sm">
		</div>
		<?php if($total_count > 0) { ?>
			<div class="pull-right">
				<ul class="pagination pagination-sm en" style="margin-top:0; padding-top:0;">
					<?php echo apms_paging($write_pages, $page, $total_page, $list_page); ?>
				</ul>
			</div>
		<?php } ?>
		<div class="clearfix"></div>
	</div>

</form>

<script>
function fitemlist_submit(f)
{
    if (!is_checked("chk[]")) {
        alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
        return false;
    }

    if(document.pressed == "선택삭제") {
        if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
            return false;
        }
    }

    return true;
}
</script>
