<?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_Check
{
//評価情報
    var $rank;
    var $comment;

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

//テーブル
    var $c_list;

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

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

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

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

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

//出品者コード取得
        $stock_detail = $this -> c_list -> select_ExStockDetail($onedetail["itemcd"], $onedetail["structcd"], $onedetail["stockcd"]);
        $this -> seller_code = $stock_detail["sellercd"];
//出品者名取得
        $Member_Basic_Attr = $this -> c_list -> select_MemberBasicAttr($stock_detail["sellercd"]);
        $this -> seller_name = $Member_Basic_Attr["lastnm"] . $Member_Basic_Attr["firstnm"];
    }
*/
    function check_status()
    {
//        if(!(is_null($this -> mode)) && !(is_null($this -> no)) && !(is_null($this -> row)) && !is_null($this -> rank))
        if(!(is_null($this -> mode)) && !(is_null($this -> no)) && !is_null($this -> rank)) {
            return true;
        } else {
            return false;
        }
    }
    
    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"]);
       }	
    }
}
?>
