<?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: */

require_once 'Pager.php';

/**
 * 出品登録-商品一覧リスト
 *
 * @package     Seller.Itemexhibit.Register.List
 * @author      S.Oguma <shinichiro.oguma@netnee.jp>
 * @access      public
 */
class Seller_Itemexhibit_Register_List
{
    /**
     * Pager設定
     */
    var $Pager_perPage_list;
    var $Pager_delta;
    var $Pager_append;
    var $Pager_clearIfVoid;
    var $Pager_linkClass;
    var $Pager_urlVar;
    var $Pager_useSessions;
    var $Pager_closeSession;
    var $Pager_mode;
    var $Pager_prevImg;
    var $Pager_nextImg;
    var $Pager_altPage;
    var $Pager_altPrev;
    var $Pager_altNext;
    var $Pager_altFirst;
    var $Pager_altLast;
    var $Pager_firstPagePre;
    var $Pager_firstPageText;
    var $Pager_firstPagePost;
    var $Pager_lastPagePre;
    var $Pager_lastPageText;
    var $Pager_lastPagePost;
    var $Pager_separator;
    var $Pager_spacesBeforeSeparator;
    var $Pager_spacesAfterSeparator;

    var $view;
    var $auth;
    var $itemsearch;
    var $sidemenu;
    var $t_tag;
    var $session;
    var $c_mypage;
    var $status;

    var $bodyid;

    var $results;
    var $cast;
    var $genre;
    var $img;
    var $pagedata;
    var $nowpages;
    var $totalpages;
    var $links;
    var $rc;
    var $from;
    var $div;

    var $start;
    var $end;

    var $list;
    var $sort;
    var $medianm;

    var $q;
    var $select;
    var $media;
    var $q_select;
    var $keyword;
    var $itemnumber;
    var $jancode;

    var $title;

    var $actionChain;
	var $upduser;      // 更新ユーザ

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

        $errorList =& $this->actionChain->getCurErrorList();

        if( $this->auth->auth->session['data']['membercd'] == "" ) {
            return 'login';
        }

/* 2007/06/15 oguma 出品可能な商品の「ショップの販売商品が無い」という条件削除 #412
   2007/06/19 oguma 下記条件は「出品者情報が登録済みかどうか」のチェックなので復活
*/
        $membercd = $this -> auth -> getAuthData("membercd");
        if (!empty($membercd)) {
            $this->status = $this -> c_mypage -> checkStatus($membercd);
        }

        if (!$this->status['scd'])
        {
            //$errorList -> add(1, "OneDepoのみで販売されているか登録されている商品がありません。");
            $errorList -> add(1, "出品者情報が登録されていません。");
            return 'input';
        }
/* 2007/06/19 oguma 上記条件は「出品者情報が登録済みかどうか」のチェックなので復活
 #412 2007/06/15 oguma */

        if($this->keyword == "" && $this->itemnumber == "" && $this->jancode == "")
        {
            $errorList -> add(1, "キーワード、品番、ＪＡＮコードのいずれかを入力してください。");
            return 'input';
        }
        else
        {
	        $this->list = "list";

	        // １ページの行数
	        $perPage = $this->Pager_perPage_list;

	        if (!is_numeric($this->from)) {
	            $this->from = 1;
	        }
	        $from = ($this->from-1)*$perPage;

	        $this->q_select = 'all';
	        $this->q = $this->keyword;

	        $this->etc = array();

            $parameters = array("makeritemcd" => $this->itemnumber,
                                "jancd"       => $this->jancode,
                                "media"       => $this->medianm
                               );

	        $this->results = $this->view->getNewitemList4exhibit($this->sort, 
	                                                             $perPage, 
	                                                             $from,
	                                                             $this->q, 
	                                                             $parameters);

	        // Pager設定
	        $pager_ini = array(
	            'totalItems'            => $this->results["recordcount"],
	            'perPage'               => $perPage,                 // 1ページ表示件数
	            'delta'                 => $this->Pager_delta,       // 表示ページから、前後に表示するページ数
	            'append'                => $this->Pager_append,
	            'clearIfVoid'           => $this->Pager_clearIfVoid,
	            'linkClass'             => $this->Pager_linkClass,
	            'urlVar'                => $this->Pager_urlVar,
	            'useSessions'           => $this->Pager_useSessions,
	            'closeSession'          => $this->Pager_closeSession,
	            'mode'                  => $this->Pager_mode,
	            'prevImg'               => $this->Pager_prevImg,
	            'nextImg'               => $this->Pager_nextImg,
	            'altPage'               => $this->Pager_altPage,
	            'altPrev'               => $this->Pager_altPrev,
	            'altNext'               => $this->Pager_altNext,
	            'altFirst'              => $this->Pager_altFirst,
	            'altLast'               => $this->Pager_altLast,
	            'firstPagePre'          => $this->Pager_firstPagePre,
	            'firstPageText'         => $this->Pager_firstPageText,
	            'firstPagePost'         => $this->Pager_firstPagePost,
	            'lastPagePre'           => $this->Pager_lastPagePre,
	            'lastPageText'          => $this->Pager_lastPageText,
	            'lastPagePost'          => $this->Pager_lastPagePost,
	            'separator'             => $this->Pager_separator, 
	            'spacesBeforeSeparator' => $this->Pager_spacesBeforeSeparator,
	            'spacesAfterSeparator'  => $this->Pager_spacesAfterSeparator
	        );

	        // Pager出力
	        $pager = & Pager::factory($pager_ini);
	        $this->pagedata = $pager->getPageData();
	        $this->nowpages = $pager->getCurrentPageID();
	        $this->totalpages = $pager->numPages();
	        $this->links = $pager->getLinks();

	        // レコードカウント
	        $this->rc = ($this->results["recordcount"] > 0) ? $this->results["recordcount"] : 0;
	        unset($this->results["recordcount"]);
	        // 表示件数 ○～○件
	        $this->start = $from+1;
	        $this->end = ($this->rc < ($from+$perPage)) ? $this->rc : ($from+$perPage);

	        $this->cast = $this->view->getCastListWomen();
	        $this->genre = $this->view->getGenreForItemcd();

            return 'success';
        }
        
    }

    function getLink()
    {
        return $this->links;
    }

    function getCastList($params)
    {
        return $this->cast[$params["itemcd"]];
    }

    function getGenreList($params)
    {
        return $this->genre[$params["itemcd"]];
    }

    function getNewmember_serial()
    {
        return urlencode(serialize($this->newmember));
    }

    function setActionChain(&$value)
    {
        $this -> actionChain =& $value;
    }

    function checkExhibit($params) {
        if (strtotime($params["salestartdate"]) <= time()) return true;
        return false;
    }
    
}
?>
