<?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_Itemattribute_Review_Confirm
{
//変更か登録かを確認する変数
    var $mode;
//変更か登録かで変化するページタイトル・ボタンの名前・URL
    var $pagetitle;
//入力されるランクとコメントの値
    var $rank;
    var $comment;
    var $itemcd;   //登録用
    var $updcnt;
//データベースから値をもらってくるためのID　変更用
    var $reviewcd;
//表示用変数
    var $detail;
	var $session;
//table操作
    var $c_item;
	var $c_review;
	
	var $auth;
	
	var $rtn_review;
    var $rtn_item;
    
    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Customer_Itemattribute_Review_Confirmが実行されました", "Customer_Itemattribute_Review_Confirm#execute");
        
        $this->rtn_item = $this -> c_item -> getItemName($this -> itemcd);
        
        // レビュー情報
        $this->rtn_review = $this -> c_review -> getItemReview($this->auth->getAuthData("membercd"), $this->itemcd);
        
        if($this->rtn_review==false) {
            $this->mode = 'insert';
            $this->pagetitle = '登録';
        } else {
            $this->mode = 'change';
            $this->pagetitle = '変更';
        }
        
        $this->rtn_item = $this -> c_item -> getItemName($this -> itemcd);
        
        return 'success';
        
        
        
    }

    function checkMode()
    {
        $res = true;
        if($this -> mode == "change"){
            $this -> pagetitle  = "変更";
        } elseif($this -> mode == "insert") {
            $this -> pagetitle  = "登録";
        } else {
            $res = false;
        }
        return $res;
    }

    function setDetail()
    {
        $item = $this -> c_review -> getItemReview($this->auth->getAuthData("membercd"), $this->itemcd);

        if($item){
            $this -> detail["itemcd"]      = $this->itemcd;
            $this -> detail["reviewcd"]    = $item["reviewcd"];
            $this -> detail["itemnm"]      = $item["itemnm"];
            $this -> detail["year"]        = substr($item["createdate"], 0, 4);
            $this -> detail["month"]       = substr($item["createdate"], 5, 2);
            $this -> detail["day"]         = substr($item["createdate"], 8, 2);
            $this -> detail['updcnt']      = $item["updcnt"];

        } else {
            $item = $this -> c_item -> getItemName($this -> itemcd);
            $this -> detail["itemcd"] = $this -> itemcd;
            $this -> detail["itemnm"] = $item["itemnm"];
        }

        return true;
        /*
        $res = true;
        if($this -> mode == "change") {
            $item = $this -> c_review -> selectOne($this->auth->getAuthData("membercd"), $this -> reviewcd);
            $this -> detail["reviewcd"]    = $item["reviewcd"];
            $this -> detail["itemnm"]      = $item["itemnm"];
            $this -> detail["year"]        = substr($item["createdate"], 0, 4);
            $this -> detail["month"]       = substr($item["createdate"], 5, 2);
            $this -> detail["day"]         = substr($item["createdate"], 8, 2);
        } elseif($this -> mode == "insert") {
            $item = $this -> c_item -> getItemName($this -> itemcd);
            $this -> detail["itemcd"] = $this -> itemcd;
            $this -> detail["itemnm"] = $item["itemnm"];
        } else {
            $res = false;
        }
        return $res;
		*/

    }

    function getDetail()
    {
    	return $this -> detail;
    }
    function getMode()
    {
        return $this -> mode;
    }
    function getPagetitle()
    {
        return $this -> pagetitle;
    }
    function getRank()
    {
        return $this -> rank;
    }    
    function getComment()
    {
        return $this -> comment;
    }
}
?>
