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

    function checkMode()
    {
        $res = false;
        if($this -> mode == "change") {
            $this -> pagetitle  = "変更";
            $this -> buttonname = "一覧";
            $this -> buttonurl  = "dispatch_customer_itemattribute_reviewlist";

            //$res = $this -> c_review -> update($this->auth->getAuthData("membercd"), $this -> reviewcd, $this -> rank, $this -> comment);
        } elseif($this -> mode == "insert") {
            $this -> pagetitle  = "登録";
            $this -> buttonname = "詳細";
            $this -> buttonurl  = "dispatch_customer_itemattribute_reviewlist";

            //$res = $this -> c_review -> insert($this->auth->getAuthData("membercd"), $this -> itemcd, $this -> rank, $this -> comment);
        }
        return $res;
    }    

    function getPagetitle()
    {
        return $this -> pagetitle;
    }
    
    function getButtonname()
    {
        return $this -> buttonname;
    }
    
    function getButtonurl()
    {
        return $this -> buttonurl;
    }
    
    function getItemCd()
    {
        return $this -> itemcd;
    }
}
?>
