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


//JSONを扱うためのパーサ
//require_once(WEBAPP_DIR."/JSON.php");

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

/**
 * [[機能説明]]
 *
 * @package     [[package名]]
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Customer_Itembuy_Valuation_Form
{
//評価情報
    var $rank;
    var $comment;

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

//テーブル
    var $c_valuation;
    var $c_list;

//出力
    var $sellername;
    var $orderdate;
    var $ordertitles;

    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Customer_Itembuy_Valuation_Formが実行されました", "Customer_Itembuy_Valuation_Form#execute");
        $this -> setValuation();
        $this -> setList();
        return 'success';
    }

    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 setList()
    { 
        $res = $this -> c_list -> getSellerInfo($this->no);
        if(!empty($res["nicknm"]) ) {
            $this -> sellername = $res["nicknm"];
        } else if(!empty($res["firstnm"]) && !empty($res["lastnm"]) ) {
            $this -> sellername = $res["lastnm"] . $res["firstnm"];
        } else {
            $this -> sellername = "onedepo";
        }
        
        $details = $this -> c_list -> selectOrderDetail($this->no, $this->mode);

        $this -> orderdate = $details[0]["orderdate"];
        foreach($details as $detail) {
            //商品コードをもとに、商品タイトル情報を取得　　変数に格納
            $item = $this -> c_list -> select_ItemBasicAttr($detail["itemcd"]);
            $this->ordertitles[] = array("itemnm" => $detail["itemnm"] ." ". $detail["variationnm"],
                                         "itemcd" => $detail["itemcd"]);
       }
    }
}
?>
