<?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_Seller_Insert_Form
{
    var $seller_db;
    var $seller;
    var $seller_serial;
    
    var $c_pref;
    var $auth;           //Authモジュール
    var $change;
    
    var $ba; //前のアクション
    var $itemcd;
    var $memberview;
    
//    var $sellerstructure; //出品者情報構成
//    var $structureJson_serial;   //出品者情報構成のJSON文字列
    
    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        // 支払先をカードのみに
        $this -> seller -> paymode = "account";
        
        //県データを変数に取っておく
        $this->preflist = $this->c_pref->selectAll();
        $log =& LogFactory::getLog();
        $log->debug("Customer_Mypage_Seller_Insert_Formが実行されました", "Customer_Mypage_Seller_Insert_Form#execute");
        
        $memberCd = $this -> auth -> getAuthData("membercd");
        if($memberCd && empty($this -> seller -> memberCd) && empty($this -> change) && $this -> change != 1 ){
            $res = $this -> setSellerInfo($memberCd);
        }
        
        return 'success';
    }

    function getPrefData()
    {
        $res = $this->preflist;
        return $res;
    }
    
    function setSeller(&$value)
    {
        $this -> seller =& $value;
    }
    
    function getSeller()
    {
        return $this -> seller;
    }
    
    function setSeller_serial($value)
    {
        $value = urldecode($value);
        $this -> seller_serial = $value;
        $this -> seller = unserialize($value);
    }
    
    function getSeller_serial()
    {
        return urlencode(serialize($this->seller));
    }
    
    function setSellerInfo($memberCd)
    {
        $sellerInfo = $this -> seller_db -> getSellerInfo($memberCd);
        if($sellerInfo === false) return false;
        
        //前処理
        $postalCode = split("-", $sellerInfo['deppostalcd']);
        $phoneNo    = split("-", $sellerInfo['deptelno1']);
        //$news       = mberegi_replace("< *br */? *>", "",  $sellerInfo['news']);
        
        $this -> seller -> post_code_a = $postalCode[0];
        $this -> seller -> post_code_b = $postalCode[1];
        $this -> seller -> pref        = $sellerInfo['depprefcd'];
        $this -> seller -> address1    = $sellerInfo['depaddr1'];
        $this -> seller -> address2    = $sellerInfo['depaddr2'];
        $this -> seller -> phone_a     = $phoneNo[0];
        $this -> seller -> phone_b     = $phoneNo[1];
        $this -> seller -> phone_c     = $phoneNo[2];
        //$this -> seller -> destination = $sellerInfo['depaddressee'];

        $this -> seller -> receive_bank = $sellerInfo['depbanknm'];
        $this -> seller -> receive_branch = $sellerInfo['depbranchnm'];
        $this -> seller -> receive_account = $sellerInfo['depaccount'];
        $this -> seller -> receive_account_num = $sellerInfo['depaccountno'];
        $this -> seller -> receive_account_name = $sellerInfo['depaccountnm'];
        
        $this -> seller -> paymode = $sellerInfo['payinfo'];
        if($this -> seller -> paymode == 2){
            $this -> seller -> pay_bank = $sellerInfo['paybanknm'];
            $this -> seller -> pay_branch = $sellerInfo['paybranchnm'];
            $this -> seller -> pay_account = $sellerInfo['payaccount'];
            $this -> seller -> pay_account_num = $sellerInfo['payaccountno'];
            $this -> seller -> pay_account_name = $sellerInfo['payaccountnm'];
        }
        
        $this -> seller -> card_type = $sellerInfo['credittype'];
        $this -> seller -> card_name = $sellerInfo['creditaccountnm'];
        $this -> seller -> card_num = $sellerInfo['creditaccountno'];
        $this -> seller -> card_limit_y = $sellerInfo['creditexpireyear'];
        $this -> seller -> card_limit_m = $sellerInfo['creditexpiremonth'];
        $this -> seller -> card_sec_code = $sellerInfo['securitycd'];
        
        if($this -> seller -> pay_bank || $sellerInfo['paybanknm']){
            $this -> seller -> paymode = "account";
        } else {
            $this -> seller -> paymode = "card";
        }

        $this -> seller -> sellerdiv    = $sellerInfo['sellerdiv'];
        
        //$this -> seller -> news = $sellerInfo['news'];
        $this -> seller -> news = $sellerInfo['news'];

        $this -> seller -> sellersouryou = $sellerInfo['sellersouryou'];
        $this -> seller -> sellersouryoumax = $sellerInfo['sellersouryoumax'];

        $this -> seller -> updCnt = $sellerInfo['updcnt'];
        $this -> seller -> memberCd = $memberCd;
        
    }

    function getMemberInfo() {
        $cd = $this->auth->getAuthData("membercd");
        $memberdata = $this->memberview->getMemberData($cd);
        return $memberdata;
    }
    
/*
    function getSellerstructure()
    {
        return $this -> sellerstructure;
    }
    
    function getStructureJson_serial()
    {
        return urlencode($this -> structureJson_serial);
    }
    
    function setStructureJson_serial($value)
    {
        $json = new Services_JSON();
        $this -> structureJson_serial = urldecode($value);
        $this->sellerstructure = $json->decode($this -> structureJson_serial);
    }
    
    function getStructurejson_serial_back()
    {
        return $this->structureJson_serial;
    }
*/
    
}
?>
