Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Mypage_DeliveryAddr.php

Documentation is available at LC_Page_Mypage_DeliveryAddr.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  */
  23.  
  24. // {{{ requires
  25. require_once(CLASS_PATH "pages/LC_Page.php");
  26.  
  27. /**
  28.  * お届け先追加 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Mypage_DeliveryAddr.php 18734 2010-06-22 08:45:33Z nanasess $
  33.  */
  34.  
  35.     // }}}
  36.     // {{{ functions
  37.  
  38.     /**
  39.      * Page を初期化する.
  40.      *
  41.      * @return void 
  42.      */
  43.     function init({
  44.         parent::init();
  45.         $this->tpl_mainpage = TEMPLATE_DIR 'mypage/delivery_addr.tpl';
  46.         $this->tpl_title = "新しいお届け先の追加・変更";
  47.         $masterData new SC_DB_MasterData_Ex();
  48.         $this->arrPref$masterData->getMasterData("mtb_pref",
  49.                             array("pref_id""pref_name""rank"));
  50.         $this->allowClientCache();
  51.     }
  52.  
  53.     /**
  54.      * Page のプロセス.
  55.      *
  56.      * @return void 
  57.      */
  58.     function process({
  59.         $objView new SC_SiteView(false);
  60.         $objQuery new SC_Query();
  61.         $objCustomer new SC_Customer();
  62.         $ParentPage MYPAGE_DELIVADDR_URL;
  63.  
  64.         // GETでページを指定されている場合には指定ページに戻す
  65.         if (isset($_GET['page'])) {
  66.             $ParentPage htmlspecialchars($_GET['page'],ENT_QUOTES);
  67.         }else if(isset($_POST['ParentPage'])) {
  68.             $ParentPage htmlspecialchars($_POST['ParentPage'],ENT_QUOTES);
  69.         }
  70.         $this->ParentPage $ParentPage;
  71.  
  72.         //ログイン判定
  73.         if (!$objCustomer->isLoginSuccess()){
  74.             SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
  75.         }
  76.  
  77.         if (!isset($_POST['mode'])) $_POST['mode'"";
  78.         if (!isset($_GET['other_deliv_id'])) $_GET['other_deliv_id'"";
  79.  
  80.         if ($_POST['mode'== ""){
  81.             $_SESSION['other_deliv_id'$_GET['other_deliv_id'];
  82.         }
  83.  
  84.         if ($_GET['other_deliv_id'!= ""){
  85.             //不正アクセス判定
  86.             $flag $objQuery->count("dtb_other_deliv""customer_id=? AND other_deliv_id=?"array($objCustomer->getValue("customer_id")$_SESSION['other_deliv_id']));
  87.             if (!$objCustomer->isLoginSuccess(|| $flag == 0){
  88.                 SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
  89.             }
  90.         }
  91.  
  92.         //別のお届け先DB登録用カラム配列
  93.         $arrRegistColumn array(
  94.                                  array(  "column" => "name01",        "convert" => "aKV" ),
  95.                                  array(  "column" => "name02",        "convert" => "aKV" ),
  96.                                  array(  "column" => "kana01",        "convert" => "CKV" ),
  97.                                  array(  "column" => "kana02",        "convert" => "CKV" ),
  98.                                  array(  "column" => "zip01",        "convert" => "n" ),
  99.                                  array(  "column" => "zip02",        "convert" => "n" ),
  100.                                  array(  "column" => "pref",        "convert" => "n" ),
  101.                                  array(  "column" => "addr01",        "convert" => "aKV" ),
  102.                                  array(  "column" => "addr02",        "convert" => "aKV" ),
  103.                                  array(  "column" => "tel01",        "convert" => "n" ),
  104.                                  array(  "column" => "tel02",        "convert" => "n" ),
  105.                                  array(  "column" => "tel03",        "convert" => "n" ),
  106.                                  );
  107.  
  108.  
  109.         if ($_GET['other_deliv_id'!= ""){
  110.             //別のお届け先情報取得
  111.             $arrOtherDeliv $objQuery->select("*""dtb_other_deliv""other_deliv_id=? "array($_SESSION['other_deliv_id']));
  112.             $this->arrForm $arrOtherDeliv[0];
  113.         }
  114.  
  115.         switch ($_POST['mode']{
  116.             case 'edit':
  117.                 $_POST $this->lfConvertParam($_POST,$arrRegistColumn);
  118.                 $this->arrErr $this->lfErrorCheck($_POST);
  119.                 if ($this->arrErr){
  120.                     foreach ($_POST as $key => $val){
  121.                         if ($val != ""$this->arrForm[$key$val;
  122.                     }
  123.                 else {
  124.                     //別のお届け先登録数の取得
  125.                     $deliv_count $objQuery->count("dtb_other_deliv""customer_id=?"array($objCustomer->getValue('customer_id')));
  126.                     if ($deliv_count DELIV_ADDR_MAX or isset($_POST['other_deliv_id'])){
  127.                         if(strlen($_POST['other_deliv_id'!= 0)){
  128.                             $deliv_count $objQuery->count("dtb_other_deliv","customer_id=? and other_deliv_id = ?" ,array($objCustomer->getValue('customer_id')$_POST['other_deliv_id']));
  129.                             if ($deliv_count == 0{
  130.                                 SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
  131.                             }else{
  132.                                 $this->lfRegistData($_POST,$arrRegistColumn$objCustomer);
  133.                             }
  134.                         }else{
  135.                             $this->lfRegistData($_POST,$arrRegistColumn$objCustomer);
  136.                         }
  137.                     }
  138.                         if$_POST['ParentPage'== MYPAGE_DELIVADDR_URL || $_POST['ParentPage'== URL_DELIV_TOP ){
  139.                             $this->tpl_onload = "fnUpdateParent('"$this->getLocation($_POST['ParentPage']."'); window.close();";
  140.                         }else{
  141.                             SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
  142.                         }
  143.                 }
  144.                 break;
  145.         }
  146.  
  147.         $objView->assignobj($this);
  148.         $objView->display($this->tpl_mainpage);
  149.     }
  150.  
  151.     /**
  152.      * デストラクタ.
  153.      *
  154.      * @return void 
  155.      */
  156.     function destroy({
  157.         parent::destroy();
  158.     }
  159.  
  160.     /* エラーチェック */
  161.     function lfErrorCheck({
  162.         $objErr new SC_CheckError();
  163.  
  164.         $objErr->doFunc(array("お名前(姓)"'name01'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  165.         $objErr->doFunc(array("お名前(名)"'name02'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK"));
  166.         $objErr->doFunc(array("フリガナ(姓)"'kana01'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK""KANA_CHECK"));
  167.         $objErr->doFunc(array("フリガナ(名)"'kana02'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK""KANA_CHECK"));
  168.         $objErr->doFunc(array("郵便番号1""zip01"ZIP01_LEN ,array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  169.         $objErr->doFunc(array("郵便番号2""zip02"ZIP02_LEN ,array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  170.         $objErr->doFunc(array("郵便番号""zip01""zip02")array("ALL_EXIST_CHECK"));
  171.         $objErr->doFunc(array("都道府県"'pref')array("SELECT_CHECK","NUM_CHECK"));
  172.         $objErr->doFunc(array("ご住所(1)""addr01"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  173.         $objErr->doFunc(array("ご住所(2)""addr02"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  174.         $objErr->doFunc(array("お電話番号1"'tel01')array("EXIST_CHECK"));
  175.         $objErr->doFunc(array("お電話番号2"'tel02')array("EXIST_CHECK"));
  176.         $objErr->doFunc(array("お電話番号3"'tel03')array("EXIST_CHECK"));
  177.         $objErr->doFunc(array("お電話番号""tel01""tel02""tel03"TEL_LEN,array("TEL_CHECK"));
  178.         return $objErr->arrErr;
  179.  
  180.     }
  181.  
  182.     /* 登録実行 */
  183.     function lfRegistData($array$arrRegistColumn&$objCustomer{
  184.         $objConn new SC_DBConn();
  185.         foreach ($arrRegistColumn as $data{
  186.             if (strlen($array$data["column"] ]0{
  187.                 $arrRegist$data["column"] ] $array$data["column"] ];
  188.             }
  189.         }
  190.  
  191.         $arrRegist['customer_id'$objCustomer->getvalue('customer_id');
  192.  
  193.         //-- 編集登録実行
  194.         $objConn->query("BEGIN");
  195.         if ($array['other_deliv_id'!= ""){
  196.             $objConn->autoExecute("dtb_other_deliv"$arrRegist,
  197.                                   "other_deliv_id = "
  198.                                   . SC_Utils_Ex::sfQuoteSmart($array["other_deliv_id"]));
  199.         }else{
  200.             $objConn->autoExecute("dtb_other_deliv"$arrRegist);
  201.         }
  202.         $objConn->query("COMMIT");
  203.     }
  204.  
  205.     //---- 取得文字列の変換
  206.     function lfConvertParam($array$arrRegistColumn{
  207.         /*
  208.          *    文字列の変換
  209.          *    K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
  210.          *    C :  「全角ひら仮名」を「全角かた仮名」に変換
  211.          *    V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
  212.          *    n :  「全角」数字を「半角(ハンカク)」に変換
  213.          *  a :  全角英数字を半角英数字に変換する
  214.          */
  215.         // カラム名とコンバート情報
  216.         foreach ($arrRegistColumn as $data{
  217.             $arrConvList$data["column"] ] $data["convert"];
  218.         }
  219.  
  220.         // 文字変換
  221.         foreach ($arrConvList as $key => $val{
  222.             // POSTされてきた値のみ変換する。
  223.             if(strlen(($array[$key])) 0{
  224.                 $array[$keymb_convert_kana($array[$key,$val);
  225.             }
  226.         }
  227.         return $array;
  228.     }
  229. }
  230. ?>

Documentation generated on Fri, 24 Feb 2012 13:59:35 +0900 by Seasoft