<?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     Seller.Itemexhibit.Now.Complete
 * @author      S.Oguma <shinichiro.oguma@netnee.jp>
 * @access      public
 */
class Seller_Itemexhibit_Now_Complete
{
    var $auth;
    var $session;
    var $tname;

    var $title;

    var $results;
    var $actionChain;

    var $list_check;
    var $list_check_serial;

    // 入力パラメータ
    var $cd;           // itemcd|structcd|stockcd|updcnt
    var $upduser;

    // DB
    var $itemexhibit;
    var $data;
    var $cnt;
    
    // エラー処理
    var $errormsg;

	var $sort;
	var $pageID;
	var $listsize;

    /**
     * Actionの実行
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Seller_Itemexhibit_Now_Completeが実行されました", "Seller_Itemexhibit_Now_Complete#execute");

        // コード展開 & DBへの要求リスト作成
        if( is_array($this->cd) )
        {
            $params = array();

            //cd = itemcd|structcd|stockcd|updcnt
            $cnt = 0;
            foreach( $this->cd as $key=>$val)
            {
	            $cnt++;
	            if( preg_match("/^([0-9]+)\|([0-9]+)\|([0-9]+)\|([0-9]+)$/", $val, $match) )
	            {
                    $params[] = array(
                    "itemcd"   => $match[1],
                    "structcd" => $match[2],
                    "stockcd"  => $match[3],
                    "updcnt"   => $match[4]
                    );
                } else {
	                $this->errormsg = "無効なコードが指定されました";
	                return "invalidToken";
                }
            }
        } else {
	        $this->errormsg = "コードが指定されていません";
	        return "invalidToken";
        }

        $sellercd=$this->auth->getAuthData("membercd"); 
        // 削除
        foreach ( $params as $key=>$val ) {
            $this->itemexhibit->delete($val["itemcd"],
                                       $val["structcd"],
                                       $val["stockcd"],
                                       $sellercd,
                                       $this->upduser,
                                       $val["updcnt"]);
        }

        return 'success';
    }

	function setList_check(&$list_check)
	{
   		 $this -> list_check =& $list_check;
	}

    function setList_check_serial($value)
    {
        $value = urldecode($value);
        $this -> list_check_serial = $value;
        $this -> list_check = unserialize($value);
    }

    function getCondition()
    {
        return $this->tname->selectDivAll(9);
    }
    function getConditionName()
    {
        $condition = $this->tname->selectKey(9, $this->itemregist->condition);
        return $condition["name"];
    }

}
?>