Source for file LC_Page_Admin_Basis.php

Documentation is available at LC_Page_Admin_Basis.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.php 17623 2008-09-22 14:41:51Z Yammy $
  33.  */
  34. class LC_Page_Admin_Basis extends LC_Page {
  35.  
  36.     // }}}
  37.     // {{{ functions
  38.  
  39.     /**
  40.      * Page を初期化する.
  41.      *
  42.      * @return void 
  43.      */
  44.     function init({
  45.         parent::init();
  46.         $this->tpl_mainpage = 'basis/index.tpl';
  47.         $this->tpl_subnavi 'basis/subnavi.tpl';
  48.         $this->tpl_subno 'index';
  49.         $this->tpl_mainno = 'basis';
  50.         $masterData new SC_DB_MasterData_Ex();
  51.         $this->arrPref $masterData->getMasterData("mtb_pref"array("pref_id""pref_name""rank"));
  52.         $this->arrTAXRULE $masterData->getMasterData("mtb_taxrule");
  53.         $this->tpl_subtitle 'SHOPマスタ';
  54.  
  55.         //定休日用配列
  56.         $this->arrRegularHoliday[0'日';
  57.         $this->arrRegularHoliday[1'月';
  58.         $this->arrRegularHoliday[2'火';
  59.         $this->arrRegularHoliday[3'水';
  60.         $this->arrRegularHoliday[4'木';
  61.         $this->arrRegularHoliday[5'金';
  62.         $this->arrRegularHoliday[6'土';
  63.     }
  64.  
  65.     /**
  66.      * Page のプロセス.
  67.      *
  68.      * @return void 
  69.      */
  70.     function process({
  71.         $conn new SC_DBConn();
  72.         $objView new SC_AdminView();
  73.         $objSess new SC_Session();
  74.         $objQuery new SC_Query();
  75.  
  76.         // 認証可否の判定
  77.         SC_Utils_Ex::sfIsSuccess($objSess);
  78.  
  79.         $cnt $objQuery->count("dtb_baseinfo");
  80.  
  81.         if ($cnt 0{
  82.             $this->tpl_mode "update";
  83.         else {
  84.             $this->tpl_mode "insert";
  85.         }
  86.  
  87.         if(isset($_POST['mode']&& !empty($_POST["mode"])) {
  88.             // POSTデータの引き継ぎ
  89.             $this->arrForm $_POST;
  90.  
  91.             // 入力データの変換
  92.             $this->arrForm $this->lfConvertParam($this->arrForm);
  93.             $this->arrForm['regular_holiday_ids'$_POST['regular_holiday_ids'];  // 定休日情報を付加
  94.             // 入力データのエラーチェック
  95.             $this->arrErr $this->lfErrorCheck($this->arrForm);
  96.  
  97.             if(count($this->arrErr== 0{
  98.                 switch($_POST['mode']{
  99.                 case 'update':
  100.                     $this->lfUpdateData($this->arrForm);    // 既存編集
  101.                     break;
  102.                 case 'insert':
  103.                     $this->lfInsertData($this->arrForm);    // 新規作成
  104.                     break;
  105.                 default:
  106.                     break;
  107.                 }
  108.                 $this->tpl_onload = "window.alert('SHOPマスタの登録が完了しました。');";
  109.             }
  110.             ifempty($this->arrForm['regular_holiday_ids']) ) {
  111.                 $this->arrSel array();
  112.             else {
  113.                 $this->arrSel $this->arrForm['regular_holiday_ids'];
  114.             }
  115.         else {
  116.             $arrCol $this->lfGetCol();
  117.             $col    SC_Utils_Ex::sfGetCommaList($arrCol);
  118.             $arrRet $objQuery->select($col"dtb_baseinfo");
  119.             $this->arrForm $arrRet[0];
  120.  
  121.             $regular_holiday_ids explode('|'$this->arrForm['regular_holiday_ids']);
  122.             $this->arrForm['regular_holiday_ids'$regular_holiday_ids;
  123.         }
  124.  
  125.         $objView->assignobj($this);
  126.         $objView->display(MAIN_FRAME);
  127.     }
  128.  
  129.     /**
  130.      * デストラクタ.
  131.      *
  132.      * @return void 
  133.      */
  134.     function destroy({
  135.         parent::destroy();
  136.     }
  137.  
  138.     // 基本情報用のカラムを取り出す。
  139.     function lfGetCol({
  140.         $arrCol array(
  141.             "company_name",
  142.             "company_kana",
  143.             "shop_name",
  144.             "shop_kana",
  145.             "zip01",
  146.             "zip02",
  147.             "pref",
  148.             "addr01",
  149.             "addr02",
  150.             "tel01",
  151.             "tel02",
  152.             "tel03",
  153.             "fax01",
  154.             "fax02",
  155.             "fax03",
  156.             "business_hour",
  157.             "email01",
  158.             "email02",
  159.             "email03",
  160.             "email04",
  161.             "tax",
  162.             "tax_rule",
  163.             "free_rule",
  164.             "good_traded",
  165.             "message",
  166.             "regular_holiday_ids"
  167.  
  168.         );
  169.         return $arrCol;
  170.     }
  171.  
  172.     function lfUpdateData($array{
  173.         $objQuery new SC_Query();
  174.         $arrCol $this->lfGetCol();
  175.         foreach($arrCol as $val{
  176.             //配列の場合は、パイプ区切りの文字列に変換
  177.             if(is_array($array[$val])) {
  178.                 $sqlval[$valimplode("|"$array[$val]);
  179.             else {
  180.                 $sqlval[$val$array[$val];
  181.             }
  182.         }
  183.         $sqlval['update_date''Now()';
  184.         // UPDATEの実行
  185.         $ret $objQuery->update("dtb_baseinfo"$sqlval);
  186.     }
  187.  
  188.     function lfInsertData($array{
  189.         $objQuery new SC_Query();
  190.         $arrCol $this->lfGetCol();
  191.         foreach($arrCol as $val{
  192.             $sqlval[$val$array[$val];
  193.         }
  194.         $sqlval['update_date''Now()';
  195.         // INSERTの実行
  196.         $ret $objQuery->insert("dtb_baseinfo"$sqlval);
  197.     }
  198.  
  199.     /* 取得文字列の変換 */
  200.     function lfConvertParam($array{
  201.         /*
  202.          *    文字列の変換
  203.          *    K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
  204.          *    C :  「全角ひら仮名」を「全角かた仮名」に変換
  205.          *    V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
  206.          *    n :  「全角」数字を「半角(ハンカク)」に変換
  207.          *  a :  全角英数字を半角英数字に変換する
  208.          */
  209.         // 人物基本情報
  210.  
  211.         // スポット商品
  212.         $arrConvList['company_name'"KVa";
  213.         $arrConvList['company_kana'"KVC";
  214.         $arrConvList['shop_name'"KVa";
  215.         $arrConvList['shop_kana'"KVC";
  216.         $arrConvList['addr01'"KVa";
  217.         $arrConvList['addr02'"KVa";
  218.         $arrConvList['zip01'"n";
  219.         $arrConvList['zip02'"n";
  220.         $arrConvList['tel01'"n";
  221.         $arrConvList['tel02'"n";
  222.         $arrConvList['tel03'"n";
  223.         $arrConvList['fax01'"n";
  224.         $arrConvList['fax02'"n";
  225.         $arrConvList['fax03'"n";
  226.         $arrConvList['email01'"a";
  227.         $arrConvList['email02'"a";
  228.         $arrConvList['email03'"a";
  229.         $arrConvList['email04'"a";
  230.         $arrConvList['tax'"n";
  231.         $arrConvList['free_rule'"n";
  232.         $arrConvList['business_hour'"KVa";
  233.         $arrConvList['good_traded'"";
  234.         $arrConvList['message'"";
  235.  
  236.         return SC_Utils_Ex::mbConvertKanaWithArray($array$arrConvList);
  237.     }
  238.  
  239.     // 入力エラーチェック
  240.     function lfErrorCheck($array{
  241.         $objErr new SC_CheckError($array);
  242.  
  243.         $objErr->doFunc(array("会社名""company_name"STEXT_LEN)array("MAX_LENGTH_CHECK"));
  244.         $objErr->doFunc(array("会社名(カナ)""company_kana"STEXT_LEN)array("KANA_CHECK","MAX_LENGTH_CHECK"));
  245.         $objErr->doFunc(array("店名""shop_name"STEXT_LEN)array("EXIST_CHECK","MAX_LENGTH_CHECK"));
  246.         $objErr->doFunc(array("店名(カナ)""shop_kana"STEXT_LEN)array("KANA_CHECK","MAX_LENGTH_CHECK"));
  247.         // 郵便番号チェック
  248.         $objErr->doFunc(array("郵便番号1","zip01",ZIP01_LEN ,array("EXIST_CHECK""NUM_CHECK","NUM_COUNT_CHECK"));
  249.         $objErr->doFunc(array("郵便番号2","zip02",ZIP02_LEN ,array("EXIST_CHECK""NUM_CHECK","NUM_COUNT_CHECK"));
  250.         $objErr->doFunc(array("郵便番号""zip01""zip02")array("ALL_EXIST_CHECK"));
  251.         // 住所チェック
  252.         $objErr->doFunc(array("都道府県""pref")array("EXIST_CHECK"));
  253.         $objErr->doFunc(array("住所1""addr01"STEXT_LEN)array("EXIST_CHECK""MAX_LENGTH_CHECK"));
  254.         $objErr->doFunc(array("住所2""addr02"STEXT_LEN)array("EXIST_CHECK""MAX_LENGTH_CHECK"));
  255.         // メールチェック
  256.         $objErr->doFunc(array('商品注文受付メールアドレス'"email01"STEXT_LEN,array("EXIST_CHECK""EMAIL_CHECK""EMAIL_CHAR_CHECK""MAX_LENGTH_CHECK"));
  257.         $objErr->doFunc(array('問い合わせ受付メールアドレス'"email02"STEXT_LEN,array("EXIST_CHECK""EMAIL_CHECK""EMAIL_CHAR_CHECK""MAX_LENGTH_CHECK"));
  258.         $objErr->doFunc(array('メール送信元メールアドレス'"email03"STEXT_LEN,array("EXIST_CHECK""EMAIL_CHECK""EMAIL_CHAR_CHECK""MAX_LENGTH_CHECK"));
  259.         $objErr->doFunc(array('送信エラー受付メールアドレス'"email04"STEXT_LEN,array("EXIST_CHECK""EMAIL_CHECK""EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"));
  260.         // 電話番号チェック
  261.         $objErr->doFunc(array("TEL""tel01""tel02""tel03"TEL_ITEM_LEN)array("TEL_CHECK"));
  262.         $objErr->doFunc(array("FAX""fax01""fax02""fax03"TEL_ITEM_LEN)array("TEL_CHECK"));
  263.         // その他
  264.         $objErr->doFunc(array("消費税率""tax"PERCENTAGE_LEN)array("EXIST_CHECK""NUM_CHECK""MAX_LENGTH_CHECK"));
  265.         $objErr->doFunc(array("送料無料条件""free_rule"PRICE_LEN)array("NUM_CHECK""MAX_LENGTH_CHECK"));
  266.         $objErr->doFunc(array("店舗営業時間""business_hour"STEXT_LEN)array("MAX_LENGTH_CHECK"));
  267.  
  268.         $objErr->doFunc(array("取扱商品""good_traded"LLTEXT_LEN)array("MAX_LENGTH_CHECK"));
  269.         $objErr->doFunc(array("メッセージ""message"LLTEXT_LEN)array("MAX_LENGTH_CHECK"));
  270.  
  271.         return $objErr->arrErr;
  272.     }
  273. }
  274. ?>

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