<?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.Preitem.View
 * @author      H.Watanabe <hiroshi.watanabe@netnee.jp>
 * @access      public
 */
class Admin_Itemmanage_Preitem_View
{
    // components
    var $actionChain;
    var $tmaker;
    var $view;
    var $m_name;
    var $castnm;
    var $media_list;
    var $tname;
    var $genreview;
    var $genre_search;
    var $db_preitem;
    var $lg_itemupdate;
    
    var $title;
    var $pagename;

    // param
    var $preitemcd;
    //-- param 
    
    var $result;
    var $genre;
    var $basic_option;
    //var $struct_option;
    
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Preitem_Viewが実行されました", "Admin_Itemmanage_Preitem_View#execute");
        
        $errorList =& $this->actionChain->getCurErrorList();
        
        $this->result = $this->db_preitem->getOnePreItem($this->preitemcd);
        $this->genre = $this->db_preitem->getOnePreGenre($this->preitemcd);
        
        $this->basic_option = $this->lg_itemupdate->getOptionList(100,200);
        //$this->struct_option = $this->lg_itemupdate->getOptionList(200,300);
        
        return 'success';
    }
    
    /**
     * ページリンク取得
     * 
     * @return object ページリンク
     */
    function getLink()
    {
        return $this->links;
    }

    function getSearchQuery()
    {
        $this->q = "&itemnm=".               urlencode($this->itemnm) .
                   "&sellercd=".             urlencode($this->sellercd) .
                   "&download=".               urlencode($this->download);

        if (is_array($this->genre_select)) {
            foreach($this->genre_select as $val) {
                if(is_numeric($val)) $this->q .= "&genre_select[]=". $val;
            }
        } else {
            $this->q .= "&genre_select[]=". $this->genre_select;
        }


        return $this->q;
    }

    function getCastname($params)
    {
        return $this->castnm[$params["itemcd"]];
    }
    

    function getMediaList() {
        $this->media_list = $this->tname->selectDivAll(4);
        return $this->media_list;
    }

    function getMakername($params) {
        $m = $this->tmaker->viewselectKey(1,$params["makercd"]);
        return $m["makernm"];
    }

    function getStockcount($params) {
        $d = $this->view->getStockcount($params["itemcd"],$params["structcd"]);
        return $d;
    }

    function getGenreSearch() {
        $this->genre_search = $this->genreview->selectAll(NULL);
        foreach ($this->genre_search as $key => $val) {
            if (!empty($val["parentcd"])) {
                $this->genre_search[$key]["checked"] = "";
                if (in_array($val["genrecd"], $this->genre_select)) {
                    $this->genre_search[$key]["checked"] = "checked";
	            }
            } else {
                unset($this->genre_search[$key]);
            }
        }
        return $this->genre_search;
    }

}
?>
