Source for file LC_Page_Admin_Basis_Delivery_Input.php

Documentation is available at LC_Page_Admin_Basis_Delivery_Input.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2007 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_Admin_Basis_Delivery_Input.php 17580 2008-08-28 23:15:31Z Seasoft $
  33.  */
  34.  
  35.     // {{{ properties
  36.  
  37.     /** フォームパラメータの配列 */
  38.     var $objFormParam;
  39.  
  40.     // }}}
  41.     // {{{ functions
  42.  
  43.     /**
  44.      * Page を初期化する.
  45.      *
  46.      * @return void 
  47.      */
  48.     function init({
  49.         parent::init();
  50.         $this->tpl_mainpage = 'basis/delivery_input.tpl';
  51.         $this->tpl_subnavi 'basis/subnavi.tpl';
  52.         $this->tpl_subno 'delivery';
  53.         $this->tpl_mainno = 'basis';
  54.         $masterData new SC_DB_MasterData_Ex();
  55.         $this->arrPref $masterData->getMasterData("mtb_pref"array("pref_id""pref_name""rank"));
  56.         $this->tpl_subtitle '配送業者設定';
  57.     }
  58.  
  59.     /**
  60.      * Page のプロセス.
  61.      *
  62.      * @return void 
  63.      */
  64.     function process({
  65.         $conn new SC_DBConn();
  66.         $objView new SC_AdminView();
  67.         $objSess new SC_Session();
  68.         $objQuery new SC_Query();
  69.  
  70.         // 認証可否の判定
  71.         SC_Utils_Ex::sfIsSuccess($objSess);
  72.  
  73.         // パラメータ管理クラス
  74.         $this->objFormParam = new SC_FormParam();
  75.         // パラメータ情報の初期化
  76.         $this->lfInitParam();
  77.         // POST値の取得
  78.         $this->objFormParam->setParam($_POST);
  79.  
  80.         if (!isset($_POST['mode'])) $_POST['mode'"";
  81.  
  82.         switch($_POST['mode']{
  83.         case 'edit':
  84.             // 入力値の変換
  85.             $this->objFormParam->convParam();
  86.             $this->arrErr $this->lfCheckError();
  87.             if(count($this->arrErr== 0{
  88.                 $this->tpl_deliv_id $this->lfRegistData();
  89.                 $this->tpl_onload = "window.alert('配送業者設定が完了しました。');";
  90.             }
  91.             break;
  92.         case 'pre_edit':
  93.             if($_POST['deliv_id'!= ""{
  94.                 $this->lfGetDelivData($_POST['deliv_id']);
  95.                 $this->tpl_deliv_id $_POST['deliv_id'];
  96.             }
  97.             break;
  98.         default:
  99.             break;
  100.         }
  101.  
  102.         $this->arrForm $this->objFormParam->getFormParamList();
  103.         $objView->assignobj($this);
  104.         $objView->display(MAIN_FRAME);
  105.     }
  106.  
  107.     /**
  108.      * デストラクタ.
  109.      *
  110.      * @return void 
  111.      */
  112.     function destroy({
  113.         parent::destroy();
  114.     }
  115.  
  116.     /* パラメータ情報の初期化 */
  117.     function lfInitParam({
  118.         $this->objFormParam->addParam("配送業者名""name"STEXT_LEN"KVa"array("EXIST_CHECK""MAX_LENGTH_CHECK"));
  119.         $this->objFormParam->addParam("名称""service_name"STEXT_LEN"KVa"array("EXIST_CHECK""MAX_LENGTH_CHECK"));
  120.         $this->objFormParam->addParam("伝票No.確認URL""confirm_url"STEXT_LEN"n"array("URL_CHECK""MAX_LENGTH_CHECK")"http://");
  121.  
  122.         for($cnt 1$cnt <= DELIVTIME_MAX$cnt++{
  123.             $this->objFormParam->addParam("配送時間$cnt""deliv_time$cnt"STEXT_LEN"KVa"array("MAX_LENGTH_CHECK"));
  124.         }
  125.  
  126.         if(INPUT_DELIV_FEE{
  127.             for($cnt 1$cnt <= DELIVFEE_MAX$cnt++{
  128.                 $this->objFormParam->addParam("配送料金$cnt""fee$cnt"PRICE_LEN"n"array("EXIST_CHECK""MAX_LENGTH_CHECK""NUM_CHECK"));
  129.             }
  130.         }
  131.     }
  132.  
  133.     
  134.     /**
  135.      * 配送情報を登録する
  136.      *
  137.      * @return $deliv_id 
  138.      */
  139.     function lfRegistData({
  140.         $arrRet $this->objFormParam->getHashArray();
  141.         $objQuery new SC_Query();
  142.         $objQuery->begin();
  143.  
  144.         // 入力データを渡す。
  145.         $sqlval['name'$arrRet['name'];
  146.         $sqlval['service_name'$arrRet['service_name'];
  147.         $sqlval['confirm_url'$arrRet['confirm_url'];
  148.         $sqlval['creator_id'$_SESSION['member_id'];
  149.         $sqlval['update_date''Now()';
  150.  
  151.  
  152.         // deliv_id が決まっていた場合
  153.         if($_POST['deliv_id'!= ""{
  154.             $deliv_id $_POST['deliv_id'];
  155.             $where "deliv_id = ?";
  156.             $objQuery->update("dtb_deliv"$sqlval$wherearray($deliv_id));
  157.  
  158.             // 配送時間の登録
  159.             $table "dtb_delivtime";
  160.             $where "deliv_id = ? AND time_id = ?";
  161.             for($cnt 1$cnt <= DELIVTIME_MAX$cnt++{
  162.                 $sqlval array();
  163.                 $keyname "deliv_time".$cnt;
  164.                 $arrval array($deliv_id($cnt $deliv_id));
  165.                 // 既存データの有無を確認
  166.                 $curData $objQuery->select("*"$table$where$arrval);
  167.  
  168.                 if(strcmp($arrRet[$keyname]""!= 0{
  169.                     $sqlval['deliv_time'$arrRet[$keyname];
  170.  
  171.                     // 入力が空ではなく、DBに情報があれば更新
  172.                     if(count($curData)) {
  173.                         $objQuery->update($table$sqlval$where$arrval);
  174.                     }
  175.                     // DBに情報がなければ登録
  176.                     else {
  177.                         $sqlval['deliv_id'$deliv_id;
  178.                         $sqlval['time_id'($cnt $deliv_id);
  179.                         $objQuery->insert($table$sqlval);
  180.                     }
  181.                 }
  182.                 // 入力が空で、DBに情報がある場合は削除
  183.                 else if(count($curData)) {
  184.                     $objQuery->delete($table$where$arrval);
  185.                 }
  186.             }
  187.  
  188.             // 配送料の登録
  189.             if(INPUT_DELIV_FEE{
  190.                 for($cnt 1$cnt <= DELIVFEE_MAX$cnt++{
  191.                     $keyname "fee".$cnt;
  192.                     if(strcmp($arrRet[$keyname]""!= 0{
  193.                         $sqlval array('fee' => $arrRet[$keyname]);
  194.                         $objQuery->update("dtb_delivfee"$sqlval"deliv_id = ? AND pref = ?"array($deliv_id$cnt));
  195.                     }
  196.                 }
  197.             }
  198.         }
  199.         else {
  200.             // 登録する配送業者IDの取得
  201.  
  202.             if (DB_TYPE == "pgsql"{
  203.                 $deliv_id $objQuery->nextval('dtb_deliv''deliv_id');
  204.                 $sqlval['deliv_id'$deliv_id;
  205.             }
  206.  
  207.             $sqlval['rank'$objQuery->max("dtb_deliv""rank"1;
  208.             $sqlval['create_date''Now()';
  209.             // INSERTの実行
  210.             $objQuery->insert("dtb_deliv"$sqlval);
  211.  
  212.             if (DB_TYPE == "mysql"{
  213.                 $deliv_id $objQuery->nextval('dtb_deliv''deliv_id');
  214.             }
  215.  
  216.             $sqlval array();
  217.             // 配送時間の設定
  218.             for($cnt 1$cnt <= DELIVTIME_MAX$cnt++{
  219.                 $keyname "deliv_time$cnt";
  220.                 if($arrRet[$keyname!= ""{
  221.                     $sqlval['deliv_id'$deliv_id;
  222.                     $sqlval['time_id'($cnt $deliv_id);
  223.                     $sqlval['deliv_time'$arrRet[$keyname];
  224.                     // INSERTの実行
  225.                     $objQuery->insert("dtb_delivtime"$sqlval);
  226.                 }
  227.             }
  228.  
  229.             if(INPUT_DELIV_FEE{
  230.                 $sqlval array();
  231.                 // 配送料金の設定
  232.                 for($cnt 1$cnt <= DELIVFEE_MAX$cnt++{
  233.                     $keyname "fee$cnt";
  234.                     if($arrRet[$keyname!= ""{
  235.                         $sqlval['deliv_id'$deliv_id;
  236.                         $sqlval['fee'$arrRet[$keyname];
  237.                         $sqlval['pref'$cnt;
  238.                         // INSERTの実行
  239.                         $objQuery->insert("dtb_delivfee"$sqlval);
  240.                     }
  241.                 }
  242.             }
  243.         }
  244.         $objQuery->commit();
  245.         return $deliv_id;
  246.     }
  247.     
  248.  
  249.     /* 配送業者情報の取得 */
  250.     function lfGetDelivData($deliv_id{
  251.         $objQuery new SC_Query();
  252.         // 配送業者一覧の取得
  253.         $col "deliv_id, name, service_name, confirm_url";
  254.         $where "deliv_id = ?";
  255.         $table "dtb_deliv";
  256.         $arrRet $objQuery->select($col$table$wherearray($deliv_id));
  257.         $this->objFormParam->setParam($arrRet[0]);
  258.         // 配送時間の取得
  259.         $col "deliv_time";
  260.         $where "deliv_id = ?  ORDER BY time_id";
  261.         $table "dtb_delivtime";
  262.         $arrRet $objQuery->select($col$table$wherearray($deliv_id));
  263.         $this->objFormParam->setParamList($arrRet'deliv_time');
  264.         // 配送料金の取得
  265.         $col "fee";
  266.         $where "deliv_id = ? ORDER BY pref";
  267.         $table "dtb_delivfee";
  268.         $arrRet $objQuery->select($col$table$wherearray($deliv_id));
  269.         $this->objFormParam->setParamList($arrRet'fee');
  270.     }
  271.  
  272.     /* 入力内容のチェック */
  273.     function lfCheckError({
  274.         // 入力データを渡す。
  275.         $arrRet =  $this->objFormParam->getHashArray();
  276.         $objErr new SC_CheckError($arrRet);
  277.         $objErr->arrErr $this->objFormParam->checkError();
  278.  
  279.         if(!isset($objErr->arrErr['name']&& $_POST['deliv_id'== ""{
  280.             // 既存チェック
  281.             $objDb new SC_Helper_DB_Ex();
  282.             $ret $objDb->sfIsRecord("dtb_deliv""service_name"array($arrRet['service_name']));
  283.             if ($ret{
  284.                 $objErr->arrErr['name'"※ 同じ名称の組み合わせは登録できません。<br>";
  285.             }
  286.         }
  287.  
  288.         return $objErr->arrErr;
  289.     }
  290. }
  291. ?>

Documentation generated on Tue, 28 Apr 2009 18:10:42 +0900 by phpDocumentor 1.4.2