<?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.Insert.Form
 * @author      H.Watanabe <hiroshi.watanabe@netnee.jp>
 * @access      public
 */
class Admin_Itemmanage_Change_Stock_Insert_Form
{
    var $actionnm;
    var $view;
    var $stockview;
    var $itemupdate;
    var $from;
    var $div;

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

    var $cd;
    var $structcd;
    var $st;

    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 $costprice;
    var $souryouprc;
    var $supplidiv;
    var $stocktitlecdcont;
    var $condition;
    var $stockstate;
    var $itemexp;
    var $updcnt;

    var $stocktype;
    var $fromlist_salestartdate;
    var $fromlist_orderclosedate;

    /**
     * execute
     *
     * @access  public
     */
    function execute()
    {

        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Change_Stock_Insert_Formが実行されました", "Admin_Itemmanage_Change_Stock_Insert_Form#execute");

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

        if(!$this->souryouprc){
          $this->souryouprc = IMPORT_SOURYOUPRC;
        }
        
        $this->result = $this->view->getOneItem();
        $this->struct = $this->view->getOneStruct();
        $this->stock = $this->stockview->getStock($this->cd,$this->structcd);

        $this->st = $this->stock[0]["stockstate"];

        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";
            } else {
                $case  = $this->stocktype;
                if (!$case) $case = 5;
            }
        }

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

        // 発売日がNULL
        if (!$this->fromlist_salestartdate) {
            $case = "3";
        }

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