<?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     [[package名]]
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Customer_Itembuy_Order_Detail
{
//評価情報
    var $rank;
    var $comment;

//商品詳細情報　仮
    var $mode;
    var $no;
    var $row;

//表示用データに格納するための配列変数
    var $order_title;
    var $order_date;
    var $itemcd;

    var $c_list;
    var $c_valuation;

    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Customer_Itembuy_Order_Detailが実行されました", "Customer_Itembuy_Order_Detail#execute");
        $res = $this -> check_status();
        if($res)
        {
            $this -> setDetail();
            $this -> setvaluation();
            return 'success';   
        }
        else
        {
            return 'input';
        }
    }

    function getMode()
    {
        return $this -> mode;
    }
    
    function getRank()
    {
        return $this -> rank;
    }
    
    function getComment()
    {
        return $this -> comment;
    }

    function setValuation()
    {
        if(is_null($this -> rank) && is_null($this -> comment))
        {
            $res = $this -> c_valuation -> select($this -> no);
            if($res == false)
            {
                $this -> rank = "";
                $this -> comment = "";
            }
            else
            {
                $this -> rank    = $res['valuation'];
                $this -> comment = $res['comment'];
            }
        }        
    }

    function setDetail()
    {            
//注文日取得
        $onetitle = $this -> c_list -> select_One_OrderTitle($this -> no);
        $this -> order_date = $onetitle['orderdate'];

//タイトル名取得
        $onedetail = $this -> c_list -> select_One_OrderDetail($this -> no, $this -> row);
        $item = $this -> c_list -> select_ItemBasicAttr($onedetail["itemcd"]);
        $this -> order_title = $item['itemnm'];
        $this -> itemcd = $onedetail["itemcd"];
    }

    function getDetail()
    {
//smartyに与える配列の作成
//[0]に注文番号、[1]に注文行、[2]に注文日、[3]にタイトル [4]に商品コード
        $array = array();
        $count = 0;
        $array[0] = $this -> no;
        $array[1] = $this -> row;
        $array[2] = $this -> order_date;
        $array[3] = $this -> order_title;
        $array[4] = $this -> itemcd;
        return $array;
    }

    function check_status()
    {
        if(!(is_null($this -> mode)) && !(is_null($this -> no)) && !(is_null($this -> row)))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
?>
