{action->getRequestPOST assign=requestPOST}
{action->getRequestGET assign=requestGET}
{action->getPager assign=pagelink}
{action->getSupplier assign=supplier}

{include file="admin/header.html"}
{include file="admin/gnavi.html"}

<div id="container">

{include file="admin/menu/submenu_item.html"}

<!-- ↓段組み　メイン側 -->
<div id="main">

<h3>商品発注入力</h3>


<!-- ↓仕入れ価格計算スクリプト -->
{literal}
<script language="JavaScript">
function setPrice(target)
{
    var unit = (document.getElementById('u'+target).value!="")?document.getElementById('u'+target).value:0;
    var num  = (document.getElementById('n'+target).value!="")?document.getElementById('n'+target).value:0;
    var price= document.getElementById('p'+target);
    var sum  = isNaN(parseInt(unit) * parseInt(num))?0:parseInt(unit) * parseInt(num);
    
    price.innerHTML = addComma(sum);
}

function addComma(x) { //追加 07/07/12 冨永 http://www.geocities.co.jp/SiliconValley/4334/unibon/javascript/formatnumber.htmlを参考 注:小数点には対応させず
    var s = "" + x;
    var p = s.length;
    var r = "";
    
    for (var i = 0; i < p; i++) {
        var c = s.substring(p - 1 - i, p - 1 - i + 1);
        if (c < "0" || c > "9") {
            r = s.substring(0, p - i) + r;
            break;
        }
        if (i > 0 && i % 3 == 0) {
            r = "," + r;
        }
        r = c + r;
    }
    return r;
}
</script>
{/literal}
<!-- ↑仕入れ価格計算スクリプト -->

<!-- ↓検索フォーム -->
<table border="0" cellspacing="0" cellpadding="0" class="border-non">
<tr>
  <td>
<strong>並び替え</strong>&nbsp;&nbsp;
  <!-- <a href="{$scriptName}?action=admin_itemmanage_order_list&sort=makernm&{$requestGET}">メーカー</a>&nbsp;&nbsp; -->
  <a href="{$scriptName}?action=admin_itemmanage_order_list&sort=makeritemcd&{$requestGET}">品番</a>&nbsp;&nbsp;
  <a href="{$scriptName}?action=admin_itemmanage_order_list&sort=itemnm&{$requestGET}">商品名</a>&nbsp;&nbsp;
  <a href="{$scriptName}?action=admin_itemmanage_order_list&sort=advancenum&{$requestGET}">予約数</a>&nbsp;&nbsp;
  <a href="{$scriptName}?action=admin_itemmanage_order_list&sort=orderednum&{$requestGET}">発注済み</a>&nbsp;&nbsp;
</td></tr></table><!-- ↑検索フォーム -->

<!--↓エラーメッセージ -->
{errorList->getMessages assign=errmsg}
{if $errmsg}
<div class="error">
  <ul class="alert">
  {foreach from=$errmsg item=msg}
    <li>{$msg|escape}</li>
  {/foreach}
  </ul>
</div>
{/if}
<!--↑エラーメッセージ -->

<!-- ↓入力フォーム -->
<form name="from1" id="form1" action="{$scriptName}" method="POST">
<input type="hidden" name="div" value="{$action.div}">
{$requestPOST}
<input type="hidden" name="sort" value="{$action.sort}">
<input type="hidden" name="pageID" value="{$action.pageID}">

<!-- ↓アイテム -->
<div class="item">

{assign var="suppliediv" value=$action.suppliediv|default:0 }
<!-- ↓仕入先 -->
<table border="0" cellspacing="0" cellpadding="0" class="hyou">
  <tr>
    <th>仕入先</th>
    <td>
      仕入先<select name="suppliercd" id="suppliercd">
        <option value="0">--仕入先--</option>
        {foreach from=$supplier item=data}
        <option value="{$data.suppliercd}"{if $data.suppliercd == $action.suppliercd}selected{/if}>
        {$data.suppliernm}</option>
        {/foreach}
      </select>
      仕入区分<select name="suppliediv" id="suppliediv">
{*        <option value="0">--仕入区分--</option> *}
        <option value="1"{if $suppliediv == "1"}selected{/if}>通常仕入</option>
        <option value="2"{if $suppliediv == "2"}selected{/if}>委託仕入</option>
{*        <option value="3"{if $suppliediv == "3"}selected{/if}>社内移動</option> *}
{*        <option value="4"{if $suppliediv == "4"}selected{/if}>返品</option> *}
      </select>
      注文番号<input type="text" name="ordercd" value="{$action.ordercd}">
    </td>
  </tr>
</table>
<!-- ↑仕入先 -->

<!-- ↓ページナビ、データ件数（上） -->
<table class="border-non" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <div class="pagenavi">
        {$pagelink}
      </div>
    </td>
    <td>
      <div class="detanumber1">
        {$action.count}件のデータ
      </div>
    </td>
  </tr>
</table>
<!-- ↑ページナビ、データ件数（上） -->

<!-- ↓検索結果 -->
<table border="0" cellspacing="0" cellpadding="0" class="hyou">
  <tr>
    <th rowspan=2>チェ<br>ック</th>

    <th rowspan=2>品番</th>
    <th rowspan=2>商品名</th>


    <th class="closing_date">発注締切日</th>

    <th rowspan=2>仕入<br>単価</th>
    <th rowspan=2>予約<br>数</th>
    <th rowspan=2>発注<br>済み</th>
    <th rowspan=2>発注<br>数</th>
    <th rowspan=2>発注<br>金額</th>
  </tr>
  <tr>
       <th class="sell_date">発売日</th>
  </tr>
  
  {foreach from=$action.data item=data key=key}
  <tr>
    <td rowspan=2>
        <input type="checkbox" name="ischecked[{$key}]" value="1" {if $action.ischecked[$key] ==1}checked{/if}>
        <input type="hidden" name="itemcd[{$key}]" value="{$data.itemcd}">
        <input type="hidden" name="structcd[{$key}]" value="{$data.structcd}">
    </td>

    <td rowspan=2>{$data.makeritemcd}</td>
    <td rowspan=2>{$data.itemnm}&nbsp;{$data.variationnm}</td>


    <td class="closing_date">{$data.orderclosedate|date_format:"%Y/%m/%d"}</td>

    <td rowspan=2><input type="text" name="orderunitprice[{$key}]" id="u{$key}" onchange="setPrice({$key})" value="{if $action.orderunitprice[$key]}{$action.orderunitprice[$key]}{else}{$data.orderunitprice|default:0}{/if}" size=5>&nbsp;円</td>
    <td rowspan=2>{$data.advancenum|default:0 }</td>
    <td rowspan=2>{$data.orderednum|default:0 }</td>
    <td rowspan=2><input type="text" name="ordernum[{$key}]" id="n{$key}" onchange="setPrice({$key})" value="{if $action.ordernum[$key]}{$action.ordernum[$key]}{else}{$data.ordernum}{/if}" size=5>&nbsp;</td>

    {if $action.orderunitprice[$key]}
      {assign var="orderunitprice" value=$action.orderunitprice[$key]|floor}
    {else}
      {assign var="orderunitprice" value=$data.orderunitprice[$key]|floor}
    {/if}

    {if $action.ordernum[$key]}
      {assign var="ordernum" value=$action.ordernum[$key]|floor}
    {else}
      {assign var="ordernum" value=$data.ordernum[$key]|floor}
    {/if}
    
    <td rowspan=2><span id="p{$key}">{math equation="x * y" x=$orderunitprice y=$ordernum assign=orderprice}{$orderprice|number_format}</span>円</td>
  </tr>
  <tr>
      <td class="sell_date">{$data.salestartdate|date_format:"%Y/%m/%d"}</td>
  </tr>
  
  {/foreach}
  {if $action.count == 0}
    <td class="name" colspan="14" align="center">該当するデータは現在登録されておりません。</td>
  {/if}

</table>
<!-- ↑検索結果 -->

<!-- ↓ページナビ、データ件数（下） -->
<table class="border-non" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <div class="pagenavi">
        {$pagelink}
      </div>
    </td>
    <td>
      <div class="detanumber1">
        {$action.count}件のデータ
      </div>
    </td>
  </tr>
</table>
<!-- ↑ページナビ、データ件数（下） -->


<table border="0" cellspacing="0" cellpadding="0">
   <tr>
          <td><input type="submit" name="dispatch_admin_itemmanage_order_list" value="絞込み">&nbsp;&nbsp;
			       <input type="submit" name="dispatch_admin_itemmanage_order_confirm" value="確定">
			   </td>
         <td width="173">
		 <input type="submit" name="dispatch_admin_itemmanage_order_fileoutput" value="ファイル出力">&nbsp;&nbsp;
         <input type="button" onclick="location.href='{$scriptName}?action=admin_itemmanage_order_search&div={$action.div}&{$requestGET}'" value="戻る">
		 </td>
         </tr>
 </table>
 
</div>
<!-- ↑アイテム -->

</form>
<!-- ↑入力フォーム -->

<div class="pagetop" title="ページトップへ"><a href="#top">ページトップへ</a></div>

</div>
<!--End of main-->

<div class="cr"></div>
</div>
<!--End of container-->

{include file="admin/footer.html"}
