<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * 商品マスタメンテ在庫更新
 *
 * @package     Admin.Itemmanage.Change.Stock.Update.Form
 * @author      H.Watanabe <hiroshi.watanabe@netnee.jp>
 * @access      public
 */
class Admin_Itemmanage_Change_Stock_Update_Form
{
    var $actionnm;
    var $view;
    var $stockview;
    var $div;

    var $result;
    var $struct;
    var $stock;
    var $from;

    var $cd;
    var $structcd;
    var $stockcd;
    var $itemupdate;

    var $itemdiv;
    var $jancode;
    var $hinban;
    var $itemtitle;
    var $release_date_start;
    var $release_date_end;
    var $publish_date_start;
    var $publish_date_end;
    var $maker_capital;
    var $maker_name;
    var $media;
    var $cast;
    var $situation;
    var $photo_situation;
    var $publish_situation;
    var $sort;
    var $genre_select;

    var $itemnm;
    var $makeritemcd;
    var $medianm;

    var $sellingprice;
    var $sellingprice2;
    var $costprice;
    var $souryouprc;
    var $souryouprc2;
    var $supplidiv;
    var $stocktitlecdcont;
    var $stocktitlecdcont2;
    var $condition;
    var $condition2;
    var $stockstate;
    var $scdstartdate;
    var $scdcompdate;
    var $itemexp;
    var $updcnt;

    var $stocktype;

    var $fromlist_salestartdate;
    var $fromlist_orderclosedate;

    var $stocktitlecd;

    var $orderitemcd;
    var $orderstructcd;

    /**
     * execute
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Change_Stock_Update_Formが実行されました", "Admin_Itemmanage_Change_Stock_Update_Form#execute");

        $div = (empty($this->div)) ? 2 : 1;

        $this->result = $this->view->getOneItem();
        $this->struct = $this->view->getOneStruct();

        $this->stock = $this->stockview->getStockTilteSelect($this->cd,$this->structcd,$this->stockcd);


        if ( !isset($this->sellingprice) && !isset($this->souryouprc) && !isset($this->costprice) && !isset($this->supplidiv) &&
                !isset($this->stocktitlecdcont) && !isset($this->condition) && !isset($this->stockstate) && !isset($this->scdstartdate) &&
                !isset($this->scdcompdate) &&!isset($this->itemexp) && !isset($this->updcnt) ){
            $this->sellingprice = $this->stock["sellingprice"];
            $this->sellingprice2 = $this->stock["sellingprice"];
            $this->souryouprc   = $this->stock["souryouprc"];
            $this->souryouprc2   = $this->stock["souryouprc"];
            $this->costprice    = $this->stock["costprice"];
            $this->supplidiv    = $this->stock["supplidiv"];
            $this->stocktitlecdcont = $this->stock["stocktitlecdcont"];
            $this->stocktitlecdcont2 = $this->stock["stocktitlecdcont"];
            $this->condition    = $this->stock["condition"];
            $this->condition2    = $this->stock["condition"];
            $this->stockstate   = $this->stock["stockstate"];
            $this->scdstartdate = $this->stock["scdstartdate"];
            $this->scdcompdate  = $this->stock["scdcompdate"];
            $this->itemexp      = $this->stock["itemexp"];
            $this->updcnt       = $this->stock["updcnt"];
            $this->stocktitlecd = $this->stock["stocktitlecd"];
        }

        $this->orderitemcd = $this->stock["orderitemcd"];
        $this->orderstructcd = $this->stock["orderstructcd"];


        return 'success_form';
    }


    /**
    * マスタより
    */
    function SupplidivList()
    {
        return $this->itemupdate->SupplidivList();
    }

    function ConditionList()
    {
        return $this->itemupdate->ConditionList();
    }

    function StockstateList()
    {
        $today = date("Y-m-d");

   if($this->fromlist_salestartdate and $this->fromlist_orderclosedate){
        if($this->fromlist_salestartdate <= $today or $this->fromlist_orderclosedate <= $today){
         $case = "1";
        }elseif($this->stocktype == 1){
        $case  = 5;
        }else{
          $case  = $this->stocktype;
          if(!$case) $case = 5;
        }
   }

   if(!$this->fromlist_orderclosedate)
        if($this->fromlist_salestartdate <= $today){
         $case = "1";
        }elseif($this->stocktype == 1){
        $case  = 5;
        }else{
        $case  = $this->stocktype;
           if(!$case) $case = 5;
        }


        // 冾ｪNULL
        if (!$this->fromlist_salestartdate) {
            $case = "3";
        }

        return $this->itemupdate->StockstateListbyCase($case );
    }


}
?>
