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

Source for file LC_Page_Admin_Customer_Edit.php

Documentation is available at LC_Page_Admin_Customer_Edit.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2011 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
  26.  
  27. /**
  28.  * 顧客情報修正 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Admin_Customer_Edit.php 21118 2011-08-03 12:28:10Z kajiwara $
  33.  */
  34. class LC_Page_Admin_Customer_Edit extends LC_Page_Admin_Ex {
  35.  
  36.     // }}}
  37.     // {{{ functions
  38.  
  39.     /**
  40.      * Page を初期化する.
  41.      *
  42.      * @return void 
  43.      */
  44.     function init() {
  45.         parent::init();
  46.         $this->tpl_mainpage = 'customer/edit.tpl';
  47.         $this->tpl_mainno = 'customer';
  48.         $this->tpl_subno = 'index';
  49.         $this->tpl_pager = 'pager.tpl';
  50.         $this->tpl_maintitle = '顧客管理';
  51.         $this->tpl_subtitle = '顧客登録';
  52.  
  53.         $masterData = new SC_DB_MasterData_Ex();
  54.         $this->arrPref = $masterData->getMasterData('mtb_pref');
  55.         $this->arrJob = $masterData->getMasterData("mtb_job");
  56.         $this->arrSex = $masterData->getMasterData("mtb_sex");
  57.         $this->arrReminder = $masterData->getMasterData("mtb_reminder");
  58.         $this->arrStatus = $masterData->getMasterData("mtb_customer_status");
  59.         $this->arrMailMagazineType = $masterData->getMasterData("mtb_mail_magazine_type");
  60.  
  61.         // 日付プルダウン設定
  62.         $objDate = new SC_Date_Ex(BIRTH_YEAR);
  63.         $this->arrYear = $objDate->getYear();
  64.         $this->arrMonth = $objDate->getMonth();
  65.         $this->arrDay = $objDate->getDay();
  66.  
  67.         // 支払い方法種別
  68.         $objDb = new SC_Helper_DB_Ex();
  69.         $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
  70.     }
  71.  
  72.     /**
  73.      * Page のプロセス.
  74.      *
  75.      * @return void 
  76.      */
  77.     function process() {
  78.         $this->action();
  79.         $this->sendResponse();
  80.     }
  81.  
  82.     /**
  83.      * Page のアクション.
  84.      *
  85.      * @return void 
  86.      */
  87.     function action() {
  88.         // パラメーター管理クラス
  89.         $objFormParam = new SC_FormParam_Ex();
  90.         // 検索引き継ぎ用パラメーター管理クラス
  91.         $objFormSearchParam = new SC_FormParam_Ex();
  92.  
  93.         // モードによる処理切り替え
  94.         switch ($this->getMode()) {
  95.         case 'edit_search':
  96.             //検索引き継ぎ用パラメーター処理
  97.             $this->lfInitSearchParam($objFormSearchParam);
  98.             $objFormSearchParam->setParam($_REQUEST);
  99.             $this->arrErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
  100.             $this->arrSearchData = $objFormSearchParam->getSearchArray();
  101.             if(!SC_Utils_Ex::isBlank($this->arrErr)) {
  102.                 return;
  103.             }
  104.             //指定顧客の情報をセット
  105.             $this->arrForm = SC_Helper_Customer_Ex::sfGetCustomerData($objFormSearchParam->getValue("edit_customer_id"), true);
  106.             //購入履歴情報の取得
  107.             list($this->tpl_linemax, $this->arrPurchaseHistory, $this->objNavi) = $this->lfPurchaseHistory($objFormSearchParam->getValue("edit_customer_id"));
  108.             $this->arrPagenavi = $this->objNavi->arrPagenavi;
  109.             $this->arrPagenavi['mode'] = 'return';
  110.             $this->tpl_pageno = '0';
  111.             break;
  112.         case 'confirm':
  113.             //パラメーター処理
  114.             $this->lfInitParam($objFormParam);
  115.             $objFormParam->setParam($_POST);
  116.             $objFormParam->convParam();
  117.             // 入力パラメーターチェック
  118.             $this->arrErr = $this->lfCheckError($objFormParam);
  119.             $this->arrForm = $objFormParam->getHashArray();
  120.             //検索引き継ぎ用パラメーター処理
  121.             $this->lfInitSearchParam($objFormSearchParam);
  122.             $objFormSearchParam->setParam($objFormParam->getValue("search_data"));
  123.             $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
  124.             $this->arrSearchData = $objFormSearchParam->getSearchArray();
  125.             if(!SC_Utils_Ex::isBlank($this->arrErr) or !SC_Utils_Ex::isBlank($this->arrSearchErr)) {
  126.                 return;
  127.             }
  128.             // 確認画面テンプレートに切り替え
  129.             $this->tpl_mainpage = 'customer/edit_confirm.tpl';
  130.             break;
  131.         case 'return':
  132.             //パラメーター処理
  133.             $this->lfInitParam($objFormParam);
  134.             $objFormParam->setParam($_POST);
  135.             $objFormParam->convParam();
  136.             // 入力パラメーターチェック
  137.             $this->arrErr = $this->lfCheckError($objFormParam);
  138.             $this->arrForm = $objFormParam->getHashArray();
  139.             //検索引き継ぎ用パラメーター処理
  140.             $this->lfInitSearchParam($objFormSearchParam);
  141.             $objFormSearchParam->setParam($objFormParam->getValue("search_data"));
  142.             $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
  143.             $this->arrSearchData = $objFormSearchParam->getSearchArray();
  144.             if(!SC_Utils_Ex::isBlank($this->arrErr) or !SC_Utils_Ex::isBlank($this->arrSearchErr)) {
  145.                 return;
  146.             }
  147.             //購入履歴情報の取得
  148.             list($this->tpl_linemax, $this->arrPurchaseHistory, $this->objNavi) = $this->lfPurchaseHistory($objFormParam->getValue("customer_id"), $objFormParam->getValue("search_pageno"));
  149.             $this->arrPagenavi = $this->objNavi->arrPagenavi;
  150.             $this->arrPagenavi['mode'] = 'return';
  151.             $this->tpl_pageno = $objFormParam->getValue("search_pageno");
  152.  
  153.             break;
  154.         case 'complete':
  155.             //登録・保存処理
  156.             //パラメーター処理
  157.             $this->lfInitParam($objFormParam);
  158.             $objFormParam->setParam($_POST);
  159.             $objFormParam->convParam();
  160.             // 入力パラメーターチェック
  161.             $this->arrErr = $this->lfCheckError($objFormParam);
  162.             $this->arrForm = $objFormParam->getHashArray();
  163.             //検索引き継ぎ用パラメーター処理
  164.             $this->lfInitSearchParam($objFormSearchParam);
  165.             $objFormSearchParam->setParam($objFormParam->getValue("search_data"));
  166.             $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
  167.             $this->arrSearchData = $objFormSearchParam->getSearchArray();
  168.             if(!SC_Utils_Ex::isBlank($this->arrErr) or !SC_Utils_Ex::isBlank($this->arrSearchErr)) {
  169.                 return;
  170.             }
  171.             $this->lfRegistData($objFormParam);
  172.             $this->tpl_mainpage = 'customer/edit_complete.tpl';
  173.             break;
  174.         case 'complete_return':
  175.             //検索引き継ぎ用パラメーター処理
  176.             $this->lfInitParam($objFormParam);
  177.             $objFormParam->setParam($_POST);
  178.             $this->lfInitSearchParam($objFormSearchParam);
  179.             $objFormSearchParam->setParam($objFormParam->getValue("search_data"));
  180.             $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
  181.             $this->arrSearchData = $objFormSearchParam->getSearchArray();
  182.             if(!SC_Utils_Ex::isBlank($this->arrSearchErr)) {
  183.                 return;
  184.             }
  185.         default:
  186.             break;
  187.         }
  188.     }
  189.  
  190.     /**
  191.      * デストラクタ.
  192.      *
  193.      * @return void 
  194.      */
  195.     function destroy() {
  196.         parent::destroy();
  197.     }
  198.  
  199.     /**
  200.      * パラメーター情報の初期化
  201.      *
  202.      * @param array $objFormParam フォームパラメータークラス
  203.      * @return void 
  204.      */
  205.     function lfInitParam(&$objFormParam) {
  206.         // 顧客項目のパラメーター取得
  207.         SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam, true);
  208.         // 検索結果一覧画面への戻り用パラメーター
  209.         $objFormParam->addParam("検索用データ", "search_data", "", "", array(), "", false);
  210.         // 顧客購入履歴ページング用
  211.         $objFormParam->addParam("", "search_pageno", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"), "", false);
  212.     }
  213.  
  214.     /**
  215.      * 検索パラメーター引き継ぎ用情報の初期化
  216.      *
  217.      * @param array $objFormParam フォームパラメータークラス
  218.      * @return void 
  219.      */
  220.     function lfInitSearchParam(&$objFormParam) {
  221.         SC_Helper_Customer_Ex::sfSetSearchParam($objFormParam);
  222.         // 初回受け入れ時用
  223.         $objFormParam->addParam("編集対象顧客ID", "edit_customer_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
  224.     }
  225.  
  226.     /**
  227.      * 検索パラメーターエラーチェック
  228.      *
  229.      * @param array $objFormParam フォームパラメータークラス
  230.      * @return array エラー配列
  231.      */
  232.     function lfCheckErrorSearchParam(&$objFormParam) {
  233.         return SC_Helper_Customer_Ex::sfCheckErrorSearchParam($objFormParam);
  234.     }
  235.  
  236.     /**
  237.      * フォーム入力パラメーターエラーチェック
  238.      *
  239.      * @param array $objFormParam フォームパラメータークラス
  240.      * @return array エラー配列
  241.      */
  242.     function lfCheckError(&$objFormParam) {
  243.         $arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam, true);
  244.  
  245.         //メアド重複チェック(共通ルーチンは使えない)
  246.         $objQuery   =& SC_Query_Ex::getSingletonInstance();
  247.         $col = "email, email_mobile, customer_id";
  248.         $table = "dtb_customer";
  249.         $where = "del_flg <> 1 AND (email Like ? OR email_mobile Like ?)";
  250.         $arrVal = array($objFormParam->getValue('email'), $objFormParam->getValue('email_mobile'));
  251.         if($objFormParam->getValue("customer_id")) {
  252.             $where .= " AND customer_id <> ?";
  253.             $arrVal[] = $objFormParam->getValue("customer_id");
  254.         }
  255.         $arrData = $objQuery->getRow($col, $table, $where, $arrVal);
  256.         if(!SC_Utils_Ex::isBlank($arrData['email'])) {
  257.             if($arrData['email'] == $objFormParam->getValue('email')) {
  258.                 $arrErr['email'] = '※ すでに他の顧客(ID:' . $arrData['customer_id'] . ')が使用しているアドレスです。';
  259.             }else if($arrData['email'] == $objFormParam->getValue('email_mobile')) {
  260.                 $arrErr['email_mobile'] = '※ すでに他の顧客(ID:' . $arrData['customer_id'] . ')が使用しているアドレスです。';
  261.             }
  262.         }
  263.         if(!SC_Utils_Ex::isBlank($arrData['email_mobile'])) {
  264.             if($arrData['email_mobile'] == $objFormParam->getValue('email_mobile')) {
  265.                 $arrErr['email_mobile'] = '※ すでに他の顧客(ID:' . $arrData['customer_id'] . ')が使用している携帯アドレスです。';
  266.             }else if($arrData['email_mobile'] == $objFormParam->getValue('email')) {
  267.                 if ($arrErr['email'] == "") {
  268.                     $arrErr['email'] = '※ すでに他の顧客(ID:' . $arrData['customer_id'] . ')が使用している携帯アドレスです。';
  269.                 }
  270.             }
  271.         }
  272.         return $arrErr;
  273.     }
  274.  
  275.     /**
  276.      * 登録処理
  277.      *
  278.      * @param array $objFormParam フォームパラメータークラス
  279.      * @return array エラー配列
  280.      */
  281.     function lfRegistData(&$objFormParam) {
  282.         $objQuery   =& SC_Query_Ex::getSingletonInstance();
  283.         // 登録用データ取得
  284.         $arrData = $objFormParam->getDbArray();
  285.         // 足りないものを作る
  286.         if(!SC_Utils_Ex::isBlank($objFormParam->getValue('year'))) {
  287.             $arrData['birth'] = $objFormParam->getValue('year') . '/'
  288.                             . $objFormParam->getValue('month') . '/'
  289.                             . $objFormParam->getValue('day')
  290.                             . ' 00:00:00';
  291.         }
  292.  
  293.         if(!is_numeric($arrData['customer_id'])) {
  294.             $arrData['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId('r');
  295.         }else {
  296.             $arrOldCustomerData = SC_Helper_Customer_Ex::sfGetCustomerData($arrData['customer_id']);
  297.             if($arrOldCustomerData['status'] != $arrData['status']) {
  298.                 $arrData['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId('r');
  299.             }
  300.         }
  301.         return SC_Helper_Customer_Ex::sfEditCustomerData($arrData, $arrData['customer_id']);
  302.     }
  303.  
  304.     /**
  305.      * 購入履歴情報の取得
  306.      *
  307.      * @param array $arrParam 検索パラメーター連想配列
  308.      * @return array( integer 全体件数, mixed 顧客データ一覧配列, mixed SC_PageNaviオブジェクト)
  309.      */
  310.     function lfPurchaseHistory($customer_id, $pageno = 0){
  311.         if(SC_Utils_Ex::isBlank($customer_id)) {
  312.             return array('0', array(), NULL);
  313.         }
  314.         $objQuery =& SC_Query_Ex::getSingletonInstance();
  315.         $page_max = SEARCH_PMAX;
  316.         $table = "dtb_order";
  317.         $where = "customer_id = ? AND del_flg <> 1";
  318.         $arrVal = array($customer_id);
  319.         //購入履歴の件数取得
  320.         $linemax = $objQuery->count($table, $where, $arrVal);
  321.         // ページ送りの取得
  322.         $objNavi = new SC_PageNavi_Ex($pageno, $linemax, $page_max, "fnNaviSearchPage2", NAVI_PMAX);
  323.         // 取得範囲の指定(開始行番号、行数のセット)
  324.         $objQuery->setLimitOffset($page_max, $objNavi->start_row);
  325.         // 表示順序
  326.         $order = "order_id DESC";
  327.         $objQuery->setOrder($order);
  328.         //購入履歴情報の取得
  329.         $arrPurchaseHistory = $objQuery->select("*", $table, $where, $arrVal);
  330.  
  331.         return array($linemax, $arrPurchaseHistory, $objNavi);
  332.     }
  333. }
  334. ?>

Documentation generated on Fri, 24 Feb 2012 14:01:13 +0900 by Seasoft