<?php include_once( "../../../../spider.inc.php" ); ?>
{charset:UTF-8}
{template:admin_default.tpl}
{module:system.login.Require}
{module:shopping.category.LoadList}
{module:shopping.flag.LoadList}
{module:shopping.product.unit.LoadList}
{module:shopping.promotion.LoadList get(pr=1000)}
{preset:page_title 'ショップ管理 > ' . SHOPPING_LABEL_PRODUCT . '管理 > 販売単位の一覧と検索'}

	<div class="panc">
		<a href="../../../">管理パネルトップ</a>
		&gt; <a href="../../">ショップ管理</a>
		&gt; <a href="../">{write:SHOPPING_LABEL_PRODUCT}管理</a>
		&gt; 販売単位管理
	</div>

	<h1>ショップ管理 &gt; {write:SHOPPING_LABEL_PRODUCT}管理 &gt; 販売単位管理</h1>

<style type="text/css">
<!--
.status_0 { background-color: #FFdddd; }
.status_91 { background-color: #d0d0d0; }
.status_101 { };
//-->
</style>

	{if:IS_ERROR}
		<h2>
			エラー
		</h2>
		<ul>
		{foreach:errors error}
			<li>{write:error}</li>
		{/foreach}
	</ul>
	{/if}

	<form name="sform" action="./index.php" method="get">
	<input type="hidden" name="pn" value="{write:shopping.product.unit.page_number}" />
	<table style="margin:0 auto;width:96%;">
	<tbody>
	<tr>
		<td style="line-height:2em;vertical-align:top;">
			カテゴリ：<select name="shpci" onchange="document.sform.submit();">
				<option value=""{if:count(shopping.product.unit.category_id_array)=0} selected{/if}>全て</option>
			{foreach:shopping.category.data_array num category_object}
			{set:child_category_array category_object::child_category_object_array}
				<option value="{write:category_object->'category_id'}"
					{if:in_array(category_object::category_id,shopping.product.unit.category_id_array)} selected{/if}
					>{write:category_object->'category_name'}</option>
				{foreach:child_category_array child_category_object}
				{set:grand_child_category_array child_category_object::child_category_object_array}
				<option value="{write:child_category_object->'category_id'}"
					{if:in_array(child_category_object::category_id,shopping.product.unit.category_id_array)} selected{/if}
					>&nbsp;┣&nbsp;{write:child_category_object->'category_name'}</option>
					{foreach:grand_child_category_array grand_child_category_object}
					<option value="{write:grand_child_category_object->'category_id'}"
						{if:in_array(grand_child_category_object::category_id,shopping.product.unit.category_id_array)} selected{/if}
						>&nbsp;&nbsp;┣&nbsp;{write:grand_child_category_object->'category_name'}</option>
					{/foreach}
				{/foreach}
			{/foreach}
			</select>
			<nobr>状態：<select name="shpstf" onchange="document.sform.submit();">
				<option value=""{if:strlen(shopping.product.unit.status_flag)=0} selected{/if}>全て</option>
				{foreach:SHOPPING_PRODUCT_STATUS_HASH key status_name}
					{if:key<=230}
					<option value="{write:key}"
						{if:key=shopping.product.unit.status_flag and strlen(shopping.product.unit.status_flag)>0} selected{/if}
						>{write:status_name}</option>
					{/if}
				{/foreach}
			</select></nobr>
			<span style="white-space:nowrap;">
				&nbsp;価格帯：<input type="text" name="shpll" size="6" value="{write:shopping.product.unit.lowerLimit}" />円
				～ <input type="text" name="shpul" size="6" value="{write:shopping.product.unit.upperLimit}" />円
			</span>
			<br />
			<nobr>{write:SHOPPING_LABEL_PRODUCT}フラグ：<select name="shpfi" onchange="document.sform.submit();">
				<option value=""{if:strlen(shopping.product.unit.flag_id)=0} selected{/if}>全て</option>
				{foreach:shopping.flag.flag_object_array key flagObject}
					<option value="{write:flagObject->'flag_id'}"
						{if:flagObject->'flag_id'=shopping.product.unit.flag_id and strlen(shopping.product.unit.flag_id)>0} selected{/if}
						>{write:flagObject->'flag_name'}</option>
				{/foreach}
			</select></nobr>
			<br />
			<nobr>検索ワード：<input type="text" name="shpq" value="{write:shopping.product.unit.query}" /> <input type="submit" value="検索実行" /></nobr>
		</td>
		<td style="text-align:right;line-height:2em;">
			<nobr>
			<input type="button" value="{write:SHOPPING_LABEL_PRODUCT}追加" onclick="shoppingProductUnitAdd()"
			/><br />
			<?php for ( $key=0;$key<=1;$key++ ) { $request_object->setAttribute('key',$key); ?>
			並べ替え項目<?php echo $key+1; ?>：<select name="shpsi[]" onchange="document.sform.submit();">
				<option value="order"{if:shopping.product.unit.sort_item_array[key]=='order'} selected{/if}>順序</option>
				<option value="reg"{if:shopping.product.unit.sort_item_array[key]=='reg'} selected{/if}>登録日</option>
				<option value="upd"{if:shopping.product.unit.sort_item_array[key]=='upd'} selected{/if}>更新日</option>
				<option value="dname"{if:shopping.product.unit.sort_item_array[key]=='dname'} selected{/if}>{write:SHOPPING_LABEL_PRODUCT}販売単位名</option>
				<option value="did"{if:shopping.product.unit.sort_item_array[key]=='did'} selected{/if}>{write:SHOPPING_LABEL_PRODUCT}販売単位ID</option>
			</select>
			並び順 <select name="shpso[]" onchange="document.sform.submit();">
				<option value="asc"{if:shopping.product.unit.sort_order_array[key]='ASC'} selected{/if}>昇順</option>
				<option value="desc"{if:shopping.product.unit.sort_order_array[key]='DESC' or strlen(shopping.product.unit.sort_item_array[key])==0} selected{/if}>降順</option>
			</select><br />
			<?php } ?>
			ページ表示数：<select name="pr" onchange="document.sform.submit();">
				<option value="1"{if:shopping.product.unit.page_rows==1} selected{/if}>1</option>
				<option value="5"{if:shopping.product.unit.page_rows==5} selected{/if}>5</option>
				<option value="10"{if:shopping.product.unit.page_rows==10} selected{/if}>10</option>
				<option value="20"{if:shopping.product.unit.page_rows==20} selected{/if}>20</option>
				<option value="50"{if:shopping.product.unit.page_rows==50} selected{/if}>50</option>
				<option value="100"{if:shopping.product.unit.page_rows==100} selected{/if}>100</option>
			</select>
			</nobr>
		</td>
	</tr>
	</tbody>
	</table>

	<table style="margin:0 auto;width:96%;">
	<tbody>
	<tr>
		<td colspan="2" style="text-align:right;">
			<input type="button" name="" value="CSVアップロード" 
				onclick="window.location.href='./upload/form.php';"
			/><input type="button" name="" value="CSVダウンロード" 
				onclick="window.location.href='./download/form.php?dt=s';"
			/>
		</td>
	</tr>
	</tbody>
	</table>
	</form>
	
	<br />
	<table class="paging" style="margin:0 auto;width:96%;border-style:none;">
	<tbody>
	<tr>
		<td style="width:6em;">
			{if:shopping.product.unit.has_prev_page}
				<input type="button" value="前のページ" onclick="FormerCommon.prevPage()" />
			{else}
			{/if}
		</td>
		<td style="text-align:center;">
			{write:shopping.product.unit.total_count}件  {write:shopping.product.unit.page_number} / {write:shopping.product.unit.total_page}ページ
		</td>
		<td style="width:6em;">
			{if:shopping.product.unit.has_next_page}
				<input type="button" value="次のページ" onclick="FormerCommon.nextPage()" />
			{else}
			{/if}
		</td>
	</tr>
	</tbody>
	</table>
	<table class="list" style="margin:0 auto;width:96%;">
	<tbody>
	<tr class="list">
		<th style="width:80px;">代表画像</th>
		<th>{write:SHOPPING_LABEL_PRODUCT}情報</th>
		<th>販売単位情報</th>
		<th style="width:3em;white-space:nowrap;">操作</th>
	</tr>
	{foreach:shopping.product.unit.unit_array unitObject}
	{set:product shopping.product.unit.product_array[unitObject->'product_id']}
	<tr class="status_{write:product->'status_flag'}" style="{if:product::is_lock}background-color:{if:product::is_editable}#FFFFDD{else}#FFE0E0{/if}{/if};">
		<td class="status_{write:product->'status_flag'}" style="width:80px;vertical-align:middle;text-align:center;">
			{set:fileIdArray product::fileIdArray}
			{if:strlen(fileIdArray[0])>0}
				<img src="/file/download.php?fi={write:fileIdArray[0]}&amp;w=80&amp;h=80" />
			{else}
				画像なし
			{/if}
		</td>
		<td class="status_{write:product->'status_flag'}" style="padding:0px;">
			<table style="border-style:none;border-collapse:collapse;width:100%;margin:0px;height:100%;">
			<tbody>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">{write:SHOPPING_LABEL_PRODUCT}ID</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;">{write:product->'product_id'}</td>
			</tr>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">{write:SHOPPING_LABEL_PRODUCT}名</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;font-weight:bold;color:#000080;">{write:product->'product_name'}</td>
			</tr>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">販売対象</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;>
					{foreach:SHOPPING_PRODUCT_OPEN_TARGET_HASH targetChar targetName}
						{if:in_array(targetChar,product->'openTargetArray')}<span style="white-space:nowrap;"> {write:targetName}</span>{/if}
					{/foreach}
					{foreach:shopping.promotion.promotion_array promotionObject}
						{if:in_array(promotionObject->'promotion_id',product->'openTargetArray')}<span style="white-space:nowrap;"> {write:promotionObject->'promotion_name'}</span>{/if}
					{/foreach}
				</td>
			</tr>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">カテゴリ</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;color:#000080;">
					{foreach:shopping.category.data_array num category_object}
					{set:child_category_array category_object::child_category_object_array}
						{if:in_array(category_object->'category_id', product->'categoryIdArray')}<span style="color:#008080;">{write:category_object->'category_name'}</span><br />{/if}
						{foreach:child_category_array child_category_object}
						{set:grand_child_category_array child_category_object::child_category_object_array}
							{if:in_array(child_category_object->'category_id', product->'categoryIdArray')}{write:category_object->'category_name'}&nbsp;-&nbsp;<span style="color:#008080;font-weight:bold;">{write:child_category_object->'category_name'}</span><br />{/if}
							{foreach:grand_child_category_array grand_child_category_object}
								{if:in_array(grand_child_category_object->'category_id', product->'categoryIdArray')}{write:category_object->'category_name'}&nbsp;-&nbsp;{write:child_category_object->'category_name'}&nbsp;-&nbsp;<span style="color:#008080;font-weight:bold;">{write:grand_child_category_object->'category_name'}</span><br />{/if}
							{/foreach}
						{/foreach}
					{/foreach}
				</td>
			</tr>
			</tbody>
			</table>
		</td>
		<td class="status_{write:product->'status_flag'}" style="padding:0px;">
			<table style="border-style:none;border-collapse:collapse;width:100%;margin:0px;height:100%;">
			<tbody>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">販売単位</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;">{write:unitObject->'unit_name'}</td>
			</tr>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">属性</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;">
					{foreach:SHOPPING_PRODUCT_OPEN_TARGET_HASH targetChar targetName}{if:strpos(unitObject->'open_target',targetChar)!==false}{write:mb_substr(targetName,0,1)}{/if}{/foreach}
					{if:unitObject->'delivery_type'=='1'}クール便{/if}
					{if:unitObject->'discount_exception'=='1'}割引除外{/if}
				</td>
			</tr>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">販売価格</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;">
					&yen;{write:number_format(unitObject->'price_sell')}-
					{if:unitObject->'price_monthly'>0}<br />(月額課金:&yen;{write:number_format(unitObject->'price_monthly')}-){/if}
				</td>
			</tr>
			<tr>
				<th style="width:5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">在庫</th>
				<th style="width:0.5em;border-style:none;white-space:nowrap;background-color:transparent;color:#909090;">:</th>
				<td style="border-style:none;">
					{if:unitObject->'stock'<0}
						無制限
					{else}
						{write:unitObject->'stock'}
					{/if}
				</td>
			</tr>
			</tbody>
			</table>
		</td>
		<td class="status_{write:unitObject->'status_flag'}" style="width:3em;text-align:center;line-height:1.5em;white-space:nowrap;">
			{write:SHOPPING_PRODUCT_STATUS_HASH[unitObject->'status_flag']}<br />
			<a href="javascript:shoppingProductUnitDetail({write:unitObject->'unit_number'});"
				title=""
				>詳細</a><br />
			{if:unitObject->'is_editable'}
			<a href="javascript:changeStatusProductUnit({write:unitObject->'unit_number'});"
				title=""
				>状態</a><br />
			<a href="javascript:shoppingProductUnitModify({write:unitObject->'unit_number'});"
				title=""
				>編集</a><br />
			{/if}
		</td>
	</tr>
	{/foreach}
	</tbody>
	</table>
	<table class="paging" style="margin:0 auto;width:96%;border-style:none;">
	<tbody>
	<tr>
		<td style="width:6em;">
			{if:shopping.product.unit.has_prev_page}
				<input type="button" value="前のページ" onclick="FormerCommon.prevPage()" />
			{else}
			{/if}
		</td>
		<td style="text-align:center;">
			{write:shopping.product.unit.total_count}件  {write:shopping.product.unit.page_number} / {write:shopping.product.unit.total_page}ページ
		</td>
		<td style="width:6em;">
			{if:shopping.product.unit.has_next_page}
				<input type="button" value="次のページ" onclick="FormerCommon.nextPage()" />
			{else}
			{/if}
		</td>
	</tr>
	</tbody>
	</table>

