<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


//JSONを扱うためのパーサ
//require_once(WEBAPP_DIR."/JSON.php");

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * [[機能説明]]
 *
 * @package     [[package名]]
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Customer_Mypage_Moremember_Update_Form
{
    var $tilte;
    var $session;
    var $basicinfo;        //会員登録時に記入済みの情報
    var $yearloopcnt;      //年を選択するリストのsectionループ回数
    var $c_genre;          //ジャンル情報用ＤＢクラス
    var $genrelist;        //foreachで並べるためのジャンル名の配列
    var $c_moremember;     //その他の登録情報用ＤＢクラス
    var $otherinfo;        //その他の登録情報
    var $otherinfo_serial; //その他の登録情報シリアライズ化
    var $auth;             //ログイン情報
    var $dispatch_customer_mypage_moremember_update_form; //確認画面から戻ってきたか否か
    
    var $change;
        
    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        $membercd = $this->auth->getAuthData("membercd");
        
        //ループ回数の決定　下限が1900　上限が「今年」
        $this->yearloopcnt = date('Y') - 1900 + 1;
        
        //ジャンル情報の取得
        $this->genrelist   = $this->c_genre->selectAll();
        
        //会員登録時に記入した情報の取得
        
        // 基本情報を入力
	    $data = $this->c_moremember->getBasicAttr($membercd);
	    $this->basicinfo['lastnm']   = $data['lastnm'];
	    $this->basicinfo['firstnm']  = $data['firstnm'];
	    $this->basicinfo['mailaddr'] = $data['mailaddr'];
        // リストから遷移してきたときはDBの値で入力項目を初期化する。
        if($this->change != 1)
        {
        
            $this->otherinfo->nickname         = $data['nicknm'];
            if (is_null($data['birthdate'])) {
                $this->otherinfo->select_year  = "";
                $this->otherinfo->select_month = "";
                $this->otherinfo->select_day   = "";
            } else {
                $this->otherinfo->select_year  = mb_substr($data['birthdate'], 0, 4);
            	$this->otherinfo->select_month = mb_substr($data['birthdate'], 5, 2);
            	$this->otherinfo->select_day   = mb_substr($data['birthdate'], 8, 2);
            }
            $this->otherinfo->introduce_myself = $data['selfintro'];
            $this->otherinfo->updCnt           = $data['updcnt'];
            $this->otherinfo->category         = $this->c_moremember->getGenreMember($membercd);
        }
        //$this->basicinfo = $this->c_moremember->getBasicAttr(10001);
        $log =& LogFactory::getLog();
        $log->debug("Customer_Mypage_Moremember_Update_Formが実行されました", "Customer_Mypage_Moremember_Update_Form#execute");
        return 'success';
    }
    
    function getYearLoopCount()
    {
        return $this -> yearloopcnt;
    }
    
    function getGenreList()
    {
        return $this -> genrelist;
    }
    
    function getBasicinfo()
    {
        return $this -> basicinfo;
    }
    
    function getOtherinfo()
    {
        return $this -> otherinfo;
    }

    function setOtherinfo_serial($value)
    {
        $value = urldecode($value);
        $this -> otherinfo_serial = $value;
        $this -> otherinfo = unserialize($value);
    }
    
    function getGenreExists($var)
    {

        $genrecd = $var["genrecd"];
        
        foreach($this->otherinfo->category as $selectGenre){
        
            if($selectGenre == $genrecd) return true;
        }
        
        return false;
        
    }

}
?>
