<?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     [[package名]]
 * @author      H.Watanabe <hiroshi.watanabe@netnee.jp>
 * @access      public
 */
class Admin_Itemmanage_Serieschange_List
{
    /**
     * [[機能説明]]
     *
     * @access  public
     */
     
    var $title;
    var $pagename;
    var $div;
    
    //component
    var $db_series;
    var $db_item;
    var $actionChain;
    
    // post
    var $maker_capi;
    var $makercd;
    var $labelcd;
    var $src_title;
    
    // list
    var $series_check;  //シリーズのcheckbox
    var $results;       //検索商品
    
    //* Pager↓
    var $srcdispnum;        // 表示件数
    var $srcdispnumlist;    // 表示件数リスト
    
    var $pagedata;  // Pagerデータ
    var $links;     // Pagerリンク
    var $from;    // 現在のページID
    var $cont;
    
    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;
    //* Pager↑
    
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Serieschange_listが実行されました", "Admin_Itemmanage_Serieschange_list#execute");

        $errorList =& $this->actionChain->getCurErrorList();
        
        if( $this->makercd == 0 ) {
            $errorList->add('nomaker', 'メーカーを選択してください');
            return 'error';
        }
        //メーカーコードからシリーズのcheckbox一覧取得
        $this->series_check = $this->db_series->viewSelectFromMakercd($this->makercd);
        if( empty( $this->series_check) ) {
            $errorList->add('noseries', 'シリーズのないメーカーです');
            return 'error';
        }
        if (!is_numeric($this->from)) {
            $this->from = 1;
        }
        $from = ($this->from-1)*$this->Pager_perPage;
        
        $div = (empty($this->div)) ? 2 : 1;
        
        $this->results = $this->db_item->SeriesChangeList($this->Pager_perPage, 
                                                         $from, 
                                                         $this->makercd, 
                                                         $this->labelcd, 
                                                         $this->src_title, 
                                                         $div);
        // Pager設定
        $params = array(
            'totalItems'    => $this->results["recordcount"],
            'perPage'       => $this->Pager_perPage,       // １ページの行数
            'delta'         => $this->Pager_delta,       // 表示ページから、前後に表示するページ数
            'append'        => $this->Pager_append,
            'clearIfVoid'   => $this->Pager_clearIfVoid,
            '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($params);
        $this->pagedata = $pager->getPageData();
        $this->links = $pager->getLinks();
        $this->cont = $this->results["recordcount"];
        unset($this->results["recordcount"]);

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