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

/**
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Seller_Infomation
{
    var $c_seller;
    var $c_member;

    var $cd;
    var $sellerdata;
    var $memberdata;

    var $view;
    var $auth;
    var $session;


	//DB
	var $itemexhibit;
	var $results, $results2;
	var $cnt;
	
	// 入力パラメータ
	var $sort;
	var $pageID;
	var $listsize;
	var $size;
	
	// 検索条件のURLパラメータ
    var $extrastr;
    var $extratag;

	// 検索パラメータ
	var $stockcd;
	var $exdate;
	var $titlenm;
	var $scdcompdate;
	var $membercd;
	var $membernm;
	var $mailaddr;
	var $image;
	var $status;
	
	// リストのページング
	var $pagedata;    // Pagerデータ
	var $nowpages;
	var $totalpages;
	var $links;       // Pagerリンク

	var $Pager_perPage;
	var $Pager_delta;
	var $Pager_append;
	var $Pager_clearIfVoid;
	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 $Pager_curPageSpanPre;
	var $Pager_curPageSpanPost;

    function execute()
    {
        $log =& LogFactory::getLog();
        
        $this->memberdata = $this->c_member->getMemberData($this->cd);
        $this->sellerdata = $this->c_seller->getSellerInfo($this->cd);


		// ページングデフォルト値設定 
		$pageID   = isset($this->pageID)  ?$this->pageID  :1;
		$listsize = 8; //isset($this->listsize)?$this->listsize:$this->Pager_perPage;
		$this->listsize = $listsize;

        // 並び替え
        $sorttype = array(
        "exdate"       => "adddate ",
        "-exdate"      => "adddate DESC ",
        "title"        => "itemnm ",
        "-title"       => "itemnm DESC "
        );
        if (empty($sorttype[$this->sort]))
            $this->sort = "-exdate";

        $sort = $sorttype[$this->sort];
        

        // 検索パラメータ
        $extraval = array();   // ソーティング、ページングなどで検索パラメータの保持に使用
        $where = array();  //　問い合わせに使用
        $where[] = "s.delflg='f'";

        if( isset($this->stockcd) && $this->stockcd!="" ) {
            $where[] = "s.stockcd = ".$this->stockcd;
            $extraval["stockcd"]=$this->stockcd;
        }
        if( isset($this->titlenm) && $this->titlenm!="" ) {
            $where[] = "i.itemnm like '%".$this->titlenm."%'";
            $extraval["titlenm"]=$this->titlenm;
        }
        //if( $this->auth->auth->session['data']['membercd'] == "" ) {
        //    return 'login';
        //}
        //$where[] = "s.sellercd =". $this->cd; //$this->auth->auth->session['data']['membercd'];
        $where[] = "s_a.membercd = ". $this->cd;
        $this->results = $this->itemexhibit->getItemexhibitList2($listsize,
                                                             $listsize*($pageID-1),
                                                             array($where),
                                                             array(),
                                                             $sort);
		array_pop($this->results);

/***************************
        // 検索パラメータ
        $extraval = array();   // ソーティング、ページングなどで検索パラメータの保持に使用
        $where = array();  //　問い合わせに使用
        $where[] = "s.delflg='f'";
        if( isset($this->stockcd) && $this->stockcd!="" ) {
            $where[] = "s.stockcd = ".$this->stockcd;
            $extraval["stockcd"]=$this->stockcd;
        }
        if( isset($this->titlenm) && $this->titlenm!="" ) {
            $where[] = "i.itemnm like '%".$this->titlenm."%'";
            $extraval["titlenm"]=$this->titlenm;
        }
        //if( $this->auth->auth->session['data']['membercd'] == "" ) {
        //    return 'login';
        //}

        //$where[] = "s.sellercd <> ". $this->cd; //$this->auth->auth->session['data']['membercd'];
        $where[] = "s_a.membercd = ". $this->cd; //$this->auth->auth->session['data']['membercd'];

        $this->results2 = $this->itemexhibit->getItemexhibitList2($listsize,
                                                             $listsize*($pageID-1),
                                                             array($where),
                                                             array(),
                                                             $sort);
		array_pop($this->results2);
*****************************/

        return 'success';
    }

    function getInfomationData() {
        return $this->sellerdata["infomation"];
    }

    // 文字列 str を文字数 lmt 以下に丸める
    function strTrimWidth($params){
        return mb_strimwidth($params["str"], 0, $params["lmt"], " …", "UTF-8");
    }
}
?>
