<?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.Reference
 * @author      netnee <mail@example.com>
 * @access      public
 */
class Admin_Itemmanage_Reference
{
    var $view;
    var $itemupdate;
    
    var $title;
    var $pagename;
    
    var $result;
    var $castnm;
    var $genrenm;
    var $img;
    
    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 $cd;
    var $from;
    var $fromdetai;
    var $structcount;
    
    var $option01;
    var $option02;
    var $option03;
    var $option04;
    var $option05;
    var $option06;
    var $option07;
    var $option08;
    var $option09;
    var $option10;

    var $basic_option;
    var $struct_option;

    var $dlitem;
    var $db_image;

	var $data;
	var $seller;
    var $dl;

    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Referenceが実行されました", "Admin_Itemmanage_Reference#execute");
        
        $this->result = $this->view->getOneItem(NULL);
        $this->structcount = count($this->result);
        
        $g = $this->view->getGenreForItemcd();
        $c = "";
        foreach ($g[$this->result[0]["itemcd"]] as $val) {$c[] = $val[0];}
        $this->genrenm = $this->view->getGenreTree($c);

        $this->img = $this->view->getItemImageForItemcd();
        
        $this->basic_option = $this->itemupdate->getOptionList(100,200);
        $this->struct_option = $this->itemupdate->getOptionList(200,300);

        $this->fromdetai = "1";


        // 構成コードがない場合は、最低価格を持つ構成を設定
        if (empty($this->scd)) {
            $d = $this->view->getLowprice($this->cd);

            if (!empty($d)) {
                $this->scd = $d["structcd"];
            } else {
                $this->scd = $this->result[0]["structcd"];
                foreach ($this->result as $val) {
                    if ($this->scd >= $val["structcd"]) $this->scd = $val["structcd"];
                }
            }
        }

    // 出品者名の取得
        if (USE_FUNCTIONAL_EXHIBIT) {
            $this->seller = $this->view->getStockSellData($this->cd, $this->scd);
        }
               
        return 'success';
    }
    
    
    function getCastname($params)
    {
        return $this->castnm[$params["itemcd"]];
    }
    
    function getGenrename($params)
    {
        return $this->genrenm[$params["itemcd"]];
    }
    
    function getImage($params)
    {
        return $this->img[$params["itemcd"]][$params["size"]];
    }
    
    function getDlitemData($params)
    {
        return $this->dlitem->getDownloadItem($params["itemcd"], $params["structcd"]);
    }
    function getDlitemStock($params)
    {
        return $this->dlitem->getDownloadStock($params["itemcd"], $params["structcd"]);
    }


    function getMovieExists($params)
    {
        return $this->db_image->selectKey(4, "O", $params["itemcd"], $params["structcd"], 0, 0);
    }
    
    function getImageExists($params)
    {
        return $this->db_image->selectKey(3, $params["size"], $params["itemcd"], $params["structcd"], 0, 0);
    }
}
?>
