<?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_Cancel_Check
{
    var $detail;
    var $itemcd;
    var $c_order;

    var $no;
    var $row;
    var $sqlrow;

    var $mode;
    var $page;
    
    var $session;
    var $auth;

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

        $sellerInfo = $this -> c_order -> getSellerInfo($this->no);
        if($sellerInfo["sellercd"] != "") return 'input';// onedepo以外はキャンセル・返品は不可能

        return $this->getItemData();
    }

    function getItemData()
    {
        $membercd = $this->auth->getAuthData("membercd");
        
        $cd = $this->c_order->select_itemcd($this->no, $this->row);
        $this->itemcd = $cd['itemcd'];

        //ここでSQL
        $this->sqlrow = $this->c_order->select_one($membercd,$this->no,$this->row,$this->itemcd, $cd['structcd']);
        if(count($this->sqlrow) > 0){
            $postdata        = array('orderdate'    =>$this->sqlrow['orderdate'],
            						  'orderno'      =>$this->sqlrow['orderno'],
            						  'itemnm'       =>$this->sqlrow['itemnm'] ." ". $this->sqlrow['variationnm'],
            						  'itemcd'       =>$this->itemcd,
            						  'orderrowno'   =>$this->sqlrow['orderrowno']);
            $this->session->removeParameter("cancel");
        	$this->session->setParameter("cancel", $postdata);
            $this->detail[0] = $this->sqlrow['orderdate'];
            $this->detail[1] = $this->sqlrow['orderno'];
            $this->detail[2] = $this->sqlrow['orderrowno'];
            $this->detail[3] = $this->sqlrow['itemnm'] ." ". $this->sqlrow['variationnm'];
            $this->detail[4] = $this->itemcd;
            return 'success';
        } else {
            return 'input';
        }
    }

    function getDetail()
    {
        return $this -> detail;
    }
/*
    function check_status()
    {
        if(isset($_GET['order_day'])) $this -> detail[0] = $_GET['order_day'];
        if(isset($_GET['order_number'])) $this -> detail[1] = $_GET['order_number'];
        if(isset($_GET['order_title'])) $this -> detail[2] = $_GET['order_title'];
        if(!(is_null($this -> detail)))
        {
            return true;
        }
        else
        {
            return false;
        }
    } */
}
?>
