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

Source for file LC_Page_Mypage_Delivery.php

Documentation is available at LC_Page_Mypage_Delivery.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/mypage/LC_Page_AbstractMypage_Ex.php';
  26.  
  27. /**
  28.  * お届け先編集 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Mypage_Delivery.php 21103 2011-08-02 20:10:38Z 468 $
  33.  */
  34. class LC_Page_Mypage_Delivery extends LC_Page_AbstractMypage_Ex {
  35.  
  36.     // }}}
  37.     // {{{ functions
  38.  
  39.     /**
  40.      * Page を初期化する.
  41.      *
  42.      * @return void 
  43.      */
  44.     function init({
  45.         parent::init();
  46.         $this->tpl_subtitle 'お届け先追加・変更';
  47.         $this->tpl_mypageno 'delivery';
  48.         $masterData         new SC_DB_MasterData_Ex();
  49.         $this->arrPref      $masterData->getMasterData('mtb_pref');
  50.         $this->httpCacheControl('nocache');
  51.     }
  52.  
  53.     /**
  54.      * Page のプロセス.
  55.      *
  56.      * @return void 
  57.      */
  58.     function process({
  59.         parent::process();
  60.     }
  61.  
  62.     /**
  63.      * Page のAction.
  64.      *
  65.      * @return void 
  66.      */
  67.     function action({
  68.         $objCustomer    new SC_Customer_Ex();
  69.         $customer_id    $objCustomer->getValue('customer_id');
  70.         $objFormParam   new SC_FormParam_Ex();
  71.  
  72.         $this->lfInitParam($objFormParam);
  73.         $objFormParam->setParam($_POST);
  74.         $objFormParam->convParam();
  75.  
  76.         switch($this->getMode()) {
  77.  
  78.         // お届け先の削除
  79.         case 'delete':
  80.             if ($objFormParam->checkError()) {
  81.                 SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
  82.                 exit;
  83.             }
  84.  
  85.             $this->deleteOtherDeliv($customer_id$objFormParam->getValue('other_deliv_id'));
  86.             break;
  87.             
  88.         // スマートフォン版のもっと見るボタン用
  89.         case 'getList':
  90.                 $arrData $objFormParam->getHashArray();
  91.                 //別のお届け先情報
  92.                 $arrOtherDeliv $this->getOtherDeliv($customer_id(($arrData['pageno'1SEARCH_PMAX));
  93.                 //県名をセット
  94.                 $arrOtherDeliv $this->setPref($arrOtherDeliv$this->arrPref);
  95.                 $arrOtherDeliv['delivCount'count($arrOtherDeliv);
  96.                 $this->arrOtherDeliv $arrOtherDeliv;
  97.                 echo SC_Utils_Ex::jsonEncode($this->arrOtherDeliv);
  98.                 exit;
  99.                 break;
  100.  
  101.         // お届け先の表示
  102.         default:
  103.             break;
  104.         }
  105.  
  106.         //別のお届け先情報
  107.         $this->arrOtherDeliv $this->getOtherDeliv($customer_id);
  108.  
  109.         //お届け先登録数
  110.         $this->tpl_linemax count($this->arrOtherDeliv);
  111.         
  112.         // 1ページあたりの件数
  113.         $this->dispNumber SEARCH_PMAX;
  114.     }
  115.  
  116.     /**
  117.      * デストラクタ.
  118.      *
  119.      * @return void 
  120.      */
  121.     function destroy({
  122.         parent::destroy();
  123.     }
  124.  
  125.     /**
  126.      * フォームパラメータの初期化
  127.      *
  128.      * @return SC_FormParam 
  129.      */
  130.     function lfInitParam(&$objFormParam{
  131.         $objFormParam->addParam('お届け先ID''other_deliv_id'INT_LEN''array('EXIST_CHECK''NUM_CHECK''MAX_LENGTH_CHECK'));
  132.         $objFormParam->addParam("現在ページ""pageno"INT_LEN'n'array("NUM_CHECK""MAX_LENGTH_CHECK")""false);
  133.     }
  134.  
  135.     /**
  136.      * お届け先の取得
  137.      *
  138.      * @param integer $customerId 
  139.      * @param integer $startno 
  140.      * @return array 
  141.      */
  142.     function getOtherDeliv($customer_id$startno ''{
  143.         $objQuery   =SC_Query_Ex::getSingletonInstance();
  144.         $objQuery->setOrder('other_deliv_id DESC');
  145.         //スマートフォン用の処理
  146.         if ($startno != ''{
  147.             $objQuery->setLimitOffset(SEARCH_PMAX$startno);
  148.         }
  149.         return $objQuery->select('*''dtb_other_deliv''customer_id = ?'array($customer_id));
  150.     }
  151.  
  152.     /**
  153.      * お届け先の削除
  154.      *
  155.      * @param integer $customerId 
  156.      * @param integer $delivId 
  157.      */
  158.     function deleteOtherDeliv($customer_id$deliv_id{
  159.         $where      'customer_id = ? AND other_deliv_id = ?';
  160.         $objQuery   =SC_Query_Ex::getSingletonInstance();
  161.         $objQuery->delete("dtb_other_deliv"$wherearray($customer_id$deliv_id));
  162.     }
  163.     
  164.     /**
  165.      * 県名をセット
  166.      *
  167.      * @param array $arrOtherDeliv 
  168.      * @param array $arrPref 
  169.      *  return array
  170.      */
  171.     function setPref($arrOtherDeliv$arrPref{
  172.         if (is_array($arrOtherDeliv)) {
  173.             foreach($arrOtherDeliv as $key => $arrDeliv{
  174.                 $arrOtherDeliv[$key]['prefname'$arrPref[$arrDeliv['pref']];
  175.             }
  176.         }
  177.         return $arrOtherDeliv;
  178.     }
  179. }

Documentation generated on Fri, 24 Feb 2012 14:02:05 +0900 by Seasoft