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

<h1><i class="fa fa-cube"></i> 내상품관리 (원격제어컴퓨터(경매))</h1>

<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; ?>">
		<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>
				</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>
			</div>
			<div class="col-sm-3">
				<div class="form-group">
					<a href="./?ap=item" class="btn btn-danger btn-sm btn-block"><i class="fa fa-upload"></i> 신규등록</a>
				</div>
			</div>
		</div>
	</form>
</div>

<h3>
	<i class="fa fa-cubes"></i> <?php echo number_format($total_count); ?> Items
</h3>

<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="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;
		}
	}
</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)">
			</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_os', 'ap='.$ap.'&amp;sca='.$sca); ?>OS</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_ram', 'ap='.$ap.'&amp;sca='.$sca); ?>RAM</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_gpu', 'ap='.$ap.'&amp;sca='.$sca); ?>GPU</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_ssd', 'ap='.$ap.'&amp;sca='.$sca); ?>SSD</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_hdd', 'ap='.$ap.'&amp;sca='.$sca); ?>HDD</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_keyboard', 'ap='.$ap.'&amp;sca='.$sca); ?>KEYBOARD</a></th>
			<th class="text-center" scope="col"><?php echo subject_sort_link('it_spec_mouse', 'ap='.$ap.'&amp;sca='.$sca); ?>MOUSE</a></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); ?>판매가 [1일요금]</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 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; ?>">
	            <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>
				<div class="text-muted" style="margin-top:4px;">
					<?php echo apms_pt_it('',$list[$i]['pt_it']);?>
					<?php echo ($list[$i]['ca_name1']) ? ' / '.$list[$i]['ca_name1'] : '';?>
					<?php echo ($list[$i]['ca_name2']) ? ' / '.$list[$i]['ca_name2'] : '';?>
					<?php // echo ($list[$i]['ca_name3']) ? ' / '.$list[$i]['ca_name3'] : '';?>
				</div>
			</td>
			<td class="text-center"> <!-- OS -->
				<?php echo $list[$i]['it_spec_os']; ?>
			</td>
			<td class="text-center"> <!-- RAM -->
				<?php echo trim($list[$i]['it_spec_ram_type'] . " " .$list[$i]['it_spec_ram']); ?>
			</td>
			<td class="text-center"> <!-- GPU -->
				<?php echo $list[$i]['it_spec_gpu']; ?>
			</td>
			<td class="text-center"> <!-- SSD -->
				<?php echo $list[$i]['it_spec_ssd_type'] . " " . $list[$i]['it_spec_ssd']; ?>
			</td>
			<td class="text-center"> <!-- HDD -->
				<?php echo $list[$i]['it_spec_hdd_type'] . " " . $list[$i]['it_spec_hdd']; ?>
			</td>
			<td class="text-center"> <!-- KEYBOARD -->
				<?php echo $list[$i]['it_spec_keyboard']; ?>
			</td>
			<td class="text-center"> <!-- MOUSE -->
				<?php echo $list[$i]['it_spec_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"> <!-- 판매가 [1일요금] -->
				<?php echo number_format($list[$i]['it_price']) . " Point"; ?>
			</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">
				<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']; ?>"><span style='padding:5px; background:#eee; border:1px solid #ddd;'>수정</span></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="12" 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>
