Index: branches/version-2/data/class/helper/SC_Helper_Mail.php
===================================================================
--- branches/version-2/data/class/helper/SC_Helper_Mail.php	(revision 18176)
+++ branches/version-2/data/class/helper/SC_Helper_Mail.php	(revision 18176)
@@ -0,0 +1,241 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * メール関連 のヘルパークラス.
+ *
+ * @package Helper
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class SC_Helper_Mail {
+
+    /** メールテンプレートのパス */
+    var $arrMAILTPLPATH;
+
+    /**
+     * コンストラクタ.
+     */
+    function SC_Helper_Mail() {
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrMAILTPLPATH =  $masterData->getMasterData("mtb_mail_tpl_path");
+        $this->arrPref = $masterData->getMasterData("mtb_pref",
+                                 array("pref_id", "pref_name", "rank"));
+    }
+
+    /* DBに登録されたテンプレートメールの送信 */
+    function sfSendTemplateMail($to, $to_name, $template_id, &$objPage) {
+
+        $objQuery = new SC_Query();
+        // メールテンプレート情報の取得
+        $where = "template_id = ?";
+        $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id));
+        $objPage->tpl_header = $arrRet[0]['header'];
+        $objPage->tpl_footer = $arrRet[0]['footer'];
+        $tmp_subject = $arrRet[0]['subject'];
+
+        $objSiteInfo = new SC_SiteInfo();
+        $arrInfo = $objSiteInfo->data;
+
+        $objMailView = new SC_SiteView();
+        // メール本文の取得
+        $objMailView->assignobj($objPage);
+        $body = $objMailView->fetch($this->arrMAILTPLPATH[$template_id]);
+
+        // メール送信処理
+        $objSendMail = new SC_SendMail_Ex();
+        $from = $arrInfo['email03'];
+        $error = $arrInfo['email04'];
+        $tosubject = $tmp_subject;
+        $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error);
+        $objSendMail->setTo($to, $to_name);
+        $objSendMail->sendMail();    // メール送信
+    }
+
+    /* 受注完了メール送信 */
+    function sfSendOrderMail($order_id, $template_id, $subject = "", $header = "", $footer = "", $send = true) {
+
+        $objPage = new LC_Page();
+        $objSiteInfo = new SC_SiteInfo();
+        $arrInfo = $objSiteInfo->data;
+        $objPage->arrInfo = $arrInfo;
+
+        $objQuery = new SC_Query();
+
+        if($subject == "" && $header == "" && $footer == "") {
+            // メールテンプレート情報の取得
+            $where = "template_id = ?";
+            $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array('1'));
+            $objPage->tpl_header = $arrRet[0]['header'];
+            $objPage->tpl_footer = $arrRet[0]['footer'];
+            $tmp_subject = $arrRet[0]['subject'];
+        } else {
+            $objPage->tpl_header = $header;
+            $objPage->tpl_footer = $footer;
+            $tmp_subject = $subject;
+        }
+
+        // 受注情報の取得
+        $where = "order_id = ?";
+        $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
+        $arrOrder = $arrRet[0];
+        $arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id));
+
+        $objPage->Message_tmp = $arrOrder['message'];
+
+        // 顧客情報の取得
+        $customer_id = $arrOrder['customer_id'];
+        $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
+        $arrCustomer = isset($arrRet[0]) ? $arrRet[0] : "";
+
+        $objPage->arrCustomer = $arrCustomer;
+        $objPage->arrOrder = $arrOrder;
+
+        //その他決済情報
+        if($arrOrder['memo02'] != "") {
+            $arrOther = unserialize($arrOrder['memo02']);
+
+            foreach($arrOther as $other_key => $other_val){
+                if(SC_Utils_Ex::sfTrim($other_val["value"]) == ""){
+                    $arrOther[$other_key]["value"] = "";
+                }
+            }
+
+            $objPage->arrOther = $arrOther;
+        }
+
+        // 都道府県変換
+        $objPage->arrOrder['deliv_pref'] = $this->arrPref[$objPage->arrOrder['deliv_pref']];
+
+        $objPage->arrOrderDetail = $arrOrderDetail;
+
+        $objCustomer = new SC_Customer();
+        $objPage->tpl_user_point = $objCustomer->getValue('point');
+
+        $objMailView = new SC_SiteView();
+        // メール本文の取得
+        $objMailView->assignobj($objPage);
+        $body = $objMailView->fetch($this->arrMAILTPLPATH[$template_id]);
+
+        // メール送信処理
+        $objSendMail = new SC_SendMail_Ex();
+        $bcc = $arrInfo['email01'];
+        $from = $arrInfo['email03'];
+        $error = $arrInfo['email04'];
+
+        $tosubject = $this->sfMakeSubject($objQuery, $objMailView,
+                                             $objPage, $tmp_subject);
+
+        $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
+        $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." 様");
+
+
+        // 送信フラグ:trueの場合は、送信する。
+        if($send) {
+            if ($objSendMail->sendMail()) {
+                $this->sfSaveMailHistory($order_id, $template_id, $tosubject, $body);
+            }
+        }
+
+        return $objSendMail;
+    }
+
+    // テンプレートを使用したメールの送信
+    function sfSendTplMail($to, $subject, $tplpath, &$objPage) {
+        $objMailView = new SC_SiteView();
+        $objSiteInfo = new SC_SiteInfo();
+        $arrInfo = $objSiteInfo->data;
+        // メール本文の取得
+        $objPage->tpl_shopname=$arrInfo['shop_name'];
+        $objPage->tpl_infoemail = $arrInfo['email02'];
+        $objMailView->assignobj($objPage);
+        $body = $objMailView->fetch($tplpath);
+        // メール送信処理
+        $objSendMail = new SC_SendMail_Ex();
+        $to = mb_encode_mimeheader($to);
+        $bcc = $arrInfo['email01'];
+        $from = $arrInfo['email03'];
+        $error = $arrInfo['email04'];
+        $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
+        $objSendMail->sendMail();
+    }
+
+    // 通常のメール送信
+    function sfSendMail($to, $subject, $body) {
+        $objSiteInfo = new SC_SiteInfo();
+        $arrInfo = $objSiteInfo->data;
+        // メール送信処理
+        $objSendMail = new SC_SendMail_Ex();
+        $bcc = $arrInfo['email01'];
+        $from = $arrInfo['email03'];
+        $error = $arrInfo['email04'];
+        $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
+        $objSendMail->sendMail();
+    }
+
+    //件名にテンプレートを用いる
+    function sfMakeSubject(&$objQuery, &$objMailView, &$objPage, $subject){
+
+        $arrInfo = $objQuery->select("*","dtb_baseinfo");
+        $arrInfo = $arrInfo[0];
+        $objPage->tpl_shopname=$arrInfo['shop_name'];
+        $objPage->tpl_infoemail=$subject;
+        $objMailView->assignobj($objPage);
+        $mailtitle = $objMailView->fetch('mail_templates/mail_title.tpl');
+        $ret = $mailtitle.$subject;
+        return $ret;
+    }
+
+    // メール配信履歴への登録
+    function sfSaveMailHistory($order_id, $template_id, $subject, $body) {
+        $sqlval['subject'] = $subject;
+        $sqlval['order_id'] = $order_id;
+        $sqlval['template_id'] = $template_id;
+        $sqlval['send_date'] = "Now()";
+        if (!isset($_SESSION['member_id'])) $_SESSION['member_id'] = "";
+        if($_SESSION['member_id'] != "") {
+            $sqlval['creator_id'] = $_SESSION['member_id'];
+        } else {
+            $sqlval['creator_id'] = '0';
+        }
+        $sqlval['mail_body'] = $body;
+
+        $objQuery = new SC_Query();
+        $objQuery->insert("dtb_mail_history", $sqlval);
+    }
+
+    /* 会員登録があるかどうかのチェック(仮会員を含まない) */
+    function sfCheckCustomerMailMaga($email) {
+        $col = "email, mailmaga_flg, customer_id";
+        $from = "dtb_customer";
+        $where = "(email = ? OR email_mobile = ?) AND status = 2 AND del_flg = 0";
+        $objQuery = new SC_Query();
+        $arrRet = $objQuery->select($col, $from, $where, array($email));
+        // 会員のメールアドレスが登録されている
+        if(!empty($arrRet[0]['customer_id'])) {
+            return true;
+        }
+        return false;
+    }
+}
+?>
Index: branches/version-2/data/class/helper/SC_Helper_DB.php
===================================================================
--- branches/version-2/data/class/helper/SC_Helper_DB.php	(revision 18176)
+++ branches/version-2/data/class/helper/SC_Helper_DB.php	(revision 18176)
@@ -0,0 +1,1562 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * DB関連のヘルパークラス.
+ *
+ * @package Helper
+ * @author LOCKON CO.,LTD.
+ * @version $Id:SC_Helper_DB.php 15532 2007-08-31 14:39:46Z nanasess $
+ */
+class SC_Helper_DB {
+
+    // {{{ properties
+
+    /** ルートカテゴリ取得フラグ */
+    var $g_root_on;
+
+    /** ルートカテゴリID */
+    var $g_root_id;
+
+    /** 選択中カテゴリ取得フラグ */
+    var $g_category_on;
+
+    /** 選択中カテゴリID */
+    var $g_category_id;
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * データベースのバージョンを所得する.
+     *
+     * @param string $dsn データソース名
+     * @return string データベースのバージョン
+     */
+    function sfGetDBVersion($dsn = "") {
+        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
+        return $dbFactory->sfGetDBVersion($dsn);
+    }
+
+    /**
+     * テーブルの存在をチェックする.
+     *
+     * @param string $table_name チェック対象のテーブル名
+     * @param string $dsn データソース名
+     * @return テーブルが存在する場合 true
+     */
+    function sfTabaleExists($table_name, $dsn = "") {
+        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
+        $dsn = $dbFactory->getDSN($dsn);
+
+        $objQuery = new SC_Query($dsn, true, true);
+        // 正常に接続されている場合
+        if(!$objQuery->isError()) {
+            list($db_type) = split(":", $dsn);
+            $sql = $dbFactory->getTableExistsSql();
+            $arrRet = $objQuery->getAll($sql, array($table_name));
+            if(count($arrRet) > 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * カラムの存在チェックと作成を行う.
+     *
+     * チェック対象のテーブルに, 該当のカラムが存在するかチェックする.
+     * 引数 $add が true の場合, 該当のカラムが存在しない場合は, カラムの生成を行う.
+     * カラムの生成も行う場合は, $col_type も必須となる.
+     *
+     * @param string $table_name テーブル名
+     * @param string $column_name カラム名
+     * @param string $col_type カラムのデータ型
+     * @param string $dsn データソース名
+     * @param bool $add カラムの作成も行う場合 true
+     * @return bool カラムが存在する場合とカラムの生成に成功した場合 true,
+     * 			     テーブルが存在しない場合 false,
+     * 				 引数 $add == false でカラムが存在しない場合 false
+     */
+    function sfColumnExists($table_name, $col_name, $col_type = "", $dsn = "", $add = false) {
+        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
+        $dsn = $dbFactory->getDSN($dsn);
+
+        // テーブルが無ければエラー
+        if(!$this->sfTabaleExists($table_name, $dsn)) return false;
+
+        $objQuery = new SC_Query($dsn, true, true);
+        // 正常に接続されている場合
+        if(!$objQuery->isError()) {
+            list($db_type) = split(":", $dsn);
+
+            // カラムリストを取得
+            $arrRet = $dbFactory->sfGetColumnList($table_name);
+            if(count($arrRet) > 0) {
+                if(in_array($col_name, $arrRet)){
+                    return true;
+                }
+            }
+        }
+
+        // カラムを追加する
+        if($add){
+            $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type ");
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * インデックスの存在チェックと作成を行う.
+     *
+     * チェック対象のテーブルに, 該当のインデックスが存在するかチェックする.
+     * 引数 $add が true の場合, 該当のインデックスが存在しない場合は, インデックスの生成を行う.
+     * インデックスの生成も行う場合で, DB_TYPE が mysql の場合は, $length も必須となる.
+     *
+     * @param string $table_name テーブル名
+     * @param string $column_name カラム名
+     * @param string $index_name インデックス名
+     * @param integer|string $length インデックスを作成するデータ長
+     * @param string $dsn データソース名
+     * @param bool $add インデックスの生成もする場合 true
+     * @return bool インデックスが存在する場合とインデックスの生成に成功した場合 true,
+     * 			     テーブルが存在しない場合 false,
+     * 				 引数 $add == false でインデックスが存在しない場合 false
+     */
+    function sfIndexExists($table_name, $col_name, $index_name, $length = "", $dsn = "", $add = false) {
+        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
+        $dsn = $dbFactory->getDSN($dsn);
+
+        // テーブルが無ければエラー
+        if (!$this->sfTabaleExists($table_name, $dsn)) return false;
+
+        $objQuery = new SC_Query($dsn, true, true);
+        $arrRet = $dbFactory->getTableIndex($index_name, $table_name);
+
+        // すでにインデックスが存在する場合
+        if(count($arrRet) > 0) {
+            return true;
+        }
+
+        // インデックスを作成する
+        if($add){
+            $dbFactory->createTableIndex($index_name, $table_name, $col_name, $length());
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * データの存在チェックを行う.
+     *
+     * @param string $table_name テーブル名
+     * @param string $where データを検索する WHERE 句
+     * @param string $dsn データソース名
+     * @param string $sql データの追加を行う場合の SQL文
+     * @param bool $add データの追加も行う場合 true
+     * @return bool データが存在する場合 true, データの追加に成功した場合 true,
+     *               $add == false で, データが存在しない場合 false
+     */
+    function sfDataExists($table_name, $where, $arrval, $dsn = "", $sql = "", $add = false) {
+        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
+        $dsn = $dbFactory->getDSN($dsn);
+
+        $objQuery = new SC_Query($dsn, true, true);
+        $count = $objQuery->count($table_name, $where, $arrval);
+
+        if($count > 0) {
+            $ret = true;
+        } else {
+            $ret = false;
+        }
+        // データを追加する
+        if(!$ret && $add) {
+            $objQuery->exec($sql);
+        }
+        return $ret;
+    }
+
+    /**
+     * 店舗基本情報を取得する.
+     *
+     * @return array 店舗基本情報の配列
+     */
+    function sf_getBasisData() {
+        $objQuery = new SC_Query();
+        $arrRet = $objQuery->select('*', 'dtb_baseinfo');
+
+        if (isset($arrRet[0])) return $arrRet[0];
+
+        return array();
+    }
+
+    /* 選択中のアイテムのルートカテゴリIDを取得する */
+    function sfGetRootId() {
+
+        if(!$this->g_root_on)	{
+            $this->g_root_on = true;
+            $objQuery = new SC_Query();
+
+            if (!isset($_GET['product_id'])) $_GET['product_id'] = "";
+            if (!isset($_GET['category_id'])) $_GET['category_id'] = "";
+
+            if(!empty($_GET['product_id']) || !empty($_GET['category_id'])) {
+                // 選択中のカテゴリIDを判定する
+                $category_id = $this->sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
+                // ROOTカテゴリIDの取得
+                $arrRet = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
+                $root_id = isset($arrRet[0]) ? $arrRet[0] : "";
+            } else {
+                // ROOTカテゴリIDをなしに設定する
+                $root_id = "";
+            }
+            $this->g_root_id = $root_id;
+        }
+        return $this->g_root_id;
+    }
+
+    /**
+     * 商品規格情報を取得する.
+     *
+     * @param array $arrID 規格ID
+     * @return array 規格情報の配列
+     */
+    function sfGetProductsClass($arrID) {
+        list($product_id, $classcategory_id1, $classcategory_id2) = $arrID;
+
+        if($classcategory_id1 == "") {
+            $classcategory_id1 = '0';
+        }
+        if($classcategory_id2 == "") {
+            $classcategory_id2 = '0';
+        }
+
+        // 商品規格取得
+        $objQuery = new SC_Query();
+        $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited";
+        $table = "vw_product_class AS prdcls";
+        $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
+        $objQuery->setorder("rank1 DESC, rank2 DESC");
+        $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2));
+        return $arrRet[0];
+    }
+
+    /**
+     * 支払い方法を取得する.
+     *
+     * @return void
+     */
+    function sfGetPayment() {
+        $objQuery = new SC_Query();
+        // 購入金額が条件額以下の項目を取得
+        $where = "del_flg = 0";
+        $objQuery->setorder("fix, rank DESC");
+        $arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where);
+        return $arrRet;
+    }
+
+    /**
+     * カート内商品の集計処理を行う.
+     *
+     * @param LC_Page $objPage ページクラスのインスタンス
+     * @param SC_CartSession $objCartSess カートセッションのインスタンス
+     * @param array $arrInfo 商品情報の配列
+     * @return LC_Page 集計処理後のページクラスインスタンス
+     */
+    function sfTotalCart(&$objPage, $objCartSess, $arrInfo) {
+
+        // 規格名一覧
+        $arrClassName = $this->sfGetIDValueList("dtb_class", "class_id", "name");
+        // 規格分類名一覧
+        $arrClassCatName = $this->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+
+        $objPage->tpl_total_pretax = 0;		// 費用合計(税込み)
+        $objPage->tpl_total_tax = 0;		// 消費税合計
+        if (USE_POINT === true) {
+            $objPage->tpl_total_point = 0;		// ポイント合計
+        }
+
+        // カート内情報の取得
+        $arrCart = $objCartSess->getCartList();
+        $max = count($arrCart);
+        $cnt = 0;
+
+        for ($i = 0; $i < $max; $i++) {
+            // 商品規格情報の取得
+            $arrData = $this->sfGetProductsClass($arrCart[$i]['id']);
+            $limit = "";
+            // DBに存在する商品
+            if (count($arrData) > 0) {
+
+                // 購入制限数を求める。
+                if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') {
+                    if($arrData['sale_limit'] < $arrData['stock']) {
+                        $limit = $arrData['sale_limit'];
+                    } else {
+                        $limit = $arrData['stock'];
+                    }
+                } else {
+                    if ($arrData['sale_unlimited'] != '1') {
+                        $limit = $arrData['sale_limit'];
+                    }
+                    if ($arrData['stock_unlimited'] != '1') {
+                        $limit = $arrData['stock'];
+                    }
+                }
+
+                if($limit != "" && $limit < $arrCart[$i]['quantity']) {
+                    // カート内商品数を制限に合わせる
+                    $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit);
+                    $quantity = $limit;
+                    $objPage->tpl_message = "※「" . $arrData['name'] . "」は販売制限しております、一度にこれ以上の購入はできません。";
+                } else {
+                    $quantity = $arrCart[$i]['quantity'];
+                }
+
+                $objPage->arrProductsClass[$cnt] = $arrData;
+                $objPage->arrProductsClass[$cnt]['quantity'] = $quantity;
+                $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no'];
+                $objPage->arrProductsClass[$cnt]['class_name1'] =
+                    isset($arrClassName[$arrData['class_id1']])
+                        ? $arrClassName[$arrData['class_id1']] : "";
+
+                $objPage->arrProductsClass[$cnt]['class_name2'] =
+                    isset($arrClassName[$arrData['class_id2']])
+                        ? $arrClassName[$arrData['class_id2']] : "";
+
+                $objPage->arrProductsClass[$cnt]['classcategory_name1'] =
+                    $arrClassCatName[$arrData['classcategory_id1']];
+
+                $objPage->arrProductsClass[$cnt]['classcategory_name2'] =
+                    $arrClassCatName[$arrData['classcategory_id2']];
+
+                // 画像サイズ
+                $main_image_path = IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"]);
+                if(file_exists($main_image_path)) {
+                    list($image_width, $image_height) = getimagesize($main_image_path);
+                } else {
+                    $image_width = 0;
+                    $image_height = 0;
+                }
+
+                $objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60;
+                $objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80;
+                // 価格の登録
+                if ($arrData['price02'] != "") {
+                    $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']);
+                    $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02'];
+                } else {
+                    $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']);
+                    $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01'];
+                }
+                // ポイント付与率の登録
+                if (USE_POINT === true) {
+                    $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']);
+                }
+                // 商品ごとの合計金額
+                $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']);
+                // 送料の合計を計算する
+                $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']);
+                $cnt++;
+            } else {
+                // DBに商品が見つからない場合はカート商品の削除
+                $objCartSess->delProductKey('id', $arrCart[$i]['id']);
+            }
+        }
+
+        // 全商品合計金額(税込み)
+        $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
+        // 全商品合計消費税
+        $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo);
+        // 全商品合計ポイント
+        if (USE_POINT === true) {
+            $objPage->tpl_total_point = $objCartSess->getAllProductsPoint();
+        }
+
+        return $objPage;
+    }
+
+    /**
+     * 受注一時テーブルへの書き込み処理を行う.
+     *
+     * @param string $uniqid ユニークID
+     * @param array $sqlval SQLの値の配列
+     * @return void
+     */
+    function sfRegistTempOrder($uniqid, $sqlval) {
+        if($uniqid != "") {
+            // 既存データのチェック
+            $objQuery = new SC_Query();
+            $where = "order_temp_id = ?";
+            $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid));
+            // 既存データがない場合
+            if ($cnt == 0) {
+                // 初回書き込み時に会員の登録済み情報を取り込む
+                $sqlval = $this->sfGetCustomerSqlVal($uniqid, $sqlval);
+                $sqlval['create_date'] = "now()";
+                $objQuery->insert("dtb_order_temp", $sqlval);
+            } else {
+                $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
+            }
+        }
+    }
+
+    /**
+     * 会員情報から SQL文の値を生成する.
+     *
+     * @param string $uniqid ユニークID
+     * @param array $sqlval SQL の値の配列
+     * @return array 会員情報を含んだ SQL の値の配列
+     */
+    function sfGetCustomerSqlVal($uniqid, $sqlval) {
+        $objCustomer = new SC_Customer();
+        // 会員情報登録処理
+        if ($objCustomer->isLoginSuccess(true)) {
+            // 登録データの作成
+            $sqlval['order_temp_id'] = $uniqid;
+            $sqlval['update_date'] = 'Now()';
+            $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
+            $sqlval['order_name01'] = $objCustomer->getValue('name01');
+            $sqlval['order_name02'] = $objCustomer->getValue('name02');
+            $sqlval['order_kana01'] = $objCustomer->getValue('kana01');
+            $sqlval['order_kana02'] = $objCustomer->getValue('kana02');
+            $sqlval['order_sex'] = $objCustomer->getValue('sex');
+            $sqlval['order_zip01'] = $objCustomer->getValue('zip01');
+            $sqlval['order_zip02'] = $objCustomer->getValue('zip02');
+            $sqlval['order_pref'] = $objCustomer->getValue('pref');
+            $sqlval['order_addr01'] = $objCustomer->getValue('addr01');
+            $sqlval['order_addr02'] = $objCustomer->getValue('addr02');
+            $sqlval['order_tel01'] = $objCustomer->getValue('tel01');
+            $sqlval['order_tel02'] = $objCustomer->getValue('tel02');
+            $sqlval['order_tel03'] = $objCustomer->getValue('tel03');
+            if (defined('MOBILE_SITE')) {
+                $email_mobile = $objCustomer->getValue('email_mobile');
+                if (empty($email_mobile)) {
+                    $sqlval['order_email'] = $objCustomer->getValue('email');
+                } else {
+                    $sqlval['order_email'] = $email_mobile;
+                }
+            } else {
+                $sqlval['order_email'] = $objCustomer->getValue('email');
+            }
+            $sqlval['order_job'] = $objCustomer->getValue('job');
+            $sqlval['order_birth'] = $objCustomer->getValue('birth');
+        }
+        return $sqlval;
+    }
+
+    /**
+     * 会員編集登録処理を行う.
+     *
+     * @param array $array パラメータの配列
+     * @param array $arrRegistColumn 登録するカラムの配列
+     * @return void
+     */
+    function sfEditCustomerData($array, $arrRegistColumn) {
+        $objQuery = new SC_Query();
+
+        foreach ($arrRegistColumn as $data) {
+            if ($data["column"] != "password") {
+                if($array[ $data['column'] ] != "") {
+                    $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
+                } else {
+                    $arrRegist[ $data['column'] ] = NULL;
+                }
+            }
+        }
+        if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) {
+            $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00";
+        } else {
+            $arrRegist["birth"] = NULL;
+        }
+
+        //-- パスワードの更新がある場合は暗号化。（更新がない場合はUPDATE文を構成しない）
+        if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC);
+        $arrRegist["update_date"] = "NOW()";
+
+        //-- 編集登録実行
+        $objQuery->begin();
+        $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id']));
+        $objQuery->commit();
+    }
+
+    /**
+     * 受注番号、利用ポイント、加算ポイントから最終ポイントを取得する.
+     *
+     * @param integer $order_id 受注番号
+     * @param integer $use_point 利用ポイント
+     * @param integer $add_point 加算ポイント
+     * @return array 最終ポイントの配列
+     */
+    function sfGetCustomerPoint($order_id, $use_point, $add_point) {
+        $objQuery = new SC_Query();
+        $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id));
+        $customer_id = $arrRet[0]['customer_id'];
+        if($customer_id != "" && $customer_id >= 1) {
+            if (USE_POINT === true) {
+                $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
+                $point = $arrRet[0]['point'];
+                $total_point = $arrRet[0]['point'] - $use_point + $add_point;
+            } else {
+                $total_point = "";
+                $point = "";
+            }
+        } else {
+            $total_point = 0;
+            $point = 0;
+        }
+        return array($point, $total_point);
+    }
+
+    /**
+     * 顧客番号、利用ポイント、加算ポイントから最終ポイントを取得する.
+     *
+     * @param integer $customer_id 顧客番号
+     * @param integer $use_point 利用ポイント
+     * @param integer $add_point 加算ポイント
+     * @return array 最終ポイントの配列
+     */
+    function sfGetCustomerPointFromCid($customer_id, $use_point, $add_point) {
+        $objQuery = new SC_Query();
+        if (USE_POINT === true) {
+                $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
+                $point = $arrRet[0]['point'];
+                $total_point = $arrRet[0]['point'] - $use_point + $add_point;
+        } else {
+            $total_point = 0;
+            $point = 0;
+        }
+        return array($point, $total_point);
+    }
+    /**
+     * カテゴリツリーの取得を行う.
+     *
+     * @param integer $parent_category_id 親カテゴリID
+     * @param bool $count_check 登録商品数のチェックを行う場合 true
+     * @return array カテゴリツリーの配列
+     */
+    function sfGetCatTree($parent_category_id, $count_check = false) {
+        $objQuery = new SC_Query();
+        $col = "";
+        $col .= " cat.category_id,";
+        $col .= " cat.category_name,";
+        $col .= " cat.parent_category_id,";
+        $col .= " cat.level,";
+        $col .= " cat.rank,";
+        $col .= " cat.creator_id,";
+        $col .= " cat.create_date,";
+        $col .= " cat.update_date,";
+        $col .= " cat.del_flg, ";
+        $col .= " ttl.product_count";
+        $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id";
+        // 登録商品数のチェック
+        if($count_check) {
+            $where = "del_flg = 0 AND product_count > 0";
+        } else {
+            $where = "del_flg = 0";
+        }
+        $objQuery->setoption("ORDER BY rank DESC");
+        $arrRet = $objQuery->select($col, $from, $where);
+
+        $arrParentID = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
+
+        foreach($arrRet as $key => $array) {
+            foreach($arrParentID as $val) {
+                if($array['category_id'] == $val) {
+                    $arrRet[$key]['display'] = 1;
+                    break;
+                }
+            }
+        }
+
+        return $arrRet;
+    }
+
+    /**
+     * カテゴリツリーの取得を複数カテゴリーで行う.
+     *
+     * @param integer $product_id 商品ID
+     * @param bool $count_check 登録商品数のチェックを行う場合 true
+     * @return array カテゴリツリーの配列
+     */
+    function sfGetMultiCatTree($product_id, $count_check = false) {
+        $objQuery = new SC_Query();
+        $col = "";
+        $col .= " cat.category_id,";
+        $col .= " cat.category_name,";
+        $col .= " cat.parent_category_id,";
+        $col .= " cat.level,";
+        $col .= " cat.rank,";
+        $col .= " cat.creator_id,";
+        $col .= " cat.create_date,";
+        $col .= " cat.update_date,";
+        $col .= " cat.del_flg, ";
+        $col .= " ttl.product_count";
+        $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id";
+        // 登録商品数のチェック
+        if($count_check) {
+            $where = "del_flg = 0 AND product_count > 0";
+        } else {
+            $where = "del_flg = 0";
+        }
+        $objQuery->setoption("ORDER BY rank DESC");
+        $arrRet = $objQuery->select($col, $from, $where);
+
+        $arrCategory_id = $this->sfGetCategoryId($product_id);
+
+        $arrCatTree = array();
+        foreach ($arrCategory_id as $pkey => $parent_category_id) {
+            $arrParentID = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
+
+            foreach($arrParentID as $pid) {
+                foreach($arrRet as $key => $array) {
+                    if($array['category_id'] == $pid) {
+                        $arrCatTree[$pkey][] = $arrRet[$key];
+                        break;
+                    }
+                }
+            }
+        }
+
+        return $arrCatTree;
+    }
+
+    /**
+     * 親カテゴリーを連結した文字列を取得する.
+     *
+     * @param integer $category_id カテゴリID
+     * @return string 親カテゴリーを連結した文字列
+     */
+    function sfGetCatCombName($category_id){
+        // 商品が属するカテゴリIDを縦に取得
+        $objQuery = new SC_Query();
+        $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
+        $ConbName = "";
+
+        // カテゴリー名称を取得する
+        foreach($arrCatID as $key => $val){
+            $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
+            $arrVal = array($val);
+            $CatName = $objQuery->getOne($sql,$arrVal);
+            $ConbName .= $CatName . ' | ';
+        }
+        // 最後の ｜ をカットする
+        $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2);
+
+        return $ConbName;
+    }
+
+    /**
+     * 指定したカテゴリーIDの大カテゴリーを取得する.
+     *
+     * @param integer $category_id カテゴリID
+     * @return array 指定したカテゴリーIDの大カテゴリー
+     */
+    function sfGetFirstCat($category_id){
+        // 商品が属するカテゴリIDを縦に取得
+        $objQuery = new SC_Query();
+        $arrRet = array();
+        $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
+        $arrRet['id'] = $arrCatID[0];
+
+        // カテゴリー名称を取得する
+        $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
+        $arrVal = array($arrRet['id']);
+        $arrRet['name'] = $objQuery->getOne($sql,$arrVal);
+
+        return $arrRet;
+    }
+
+    /**
+     * カテゴリツリーの取得を行う.
+     *
+     * $products_check:true商品登録済みのものだけ取得する
+     *
+     * @param string $addwhere 追加する WHERE 句
+     * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true
+     * @param string $head カテゴリ名のプレフィックス文字列
+     * @return array カテゴリツリーの配列
+     */
+    function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) {
+        $objQuery = new SC_Query();
+        $where = "del_flg = 0";
+
+        if($addwhere != "") {
+            $where.= " AND $addwhere";
+        }
+
+        $objQuery->setoption("ORDER BY rank DESC");
+
+        if($products_check) {
+            $col = "T1.category_id, category_name, level";
+            $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id";
+            $where .= " AND product_count > 0";
+        } else {
+            $col = "category_id, category_name, level";
+            $from = "dtb_category";
+        }
+
+        $arrRet = $objQuery->select($col, $from, $where);
+
+        $max = count($arrRet);
+        for($cnt = 0; $cnt < $max; $cnt++) {
+            $id = $arrRet[$cnt]['category_id'];
+            $name = $arrRet[$cnt]['category_name'];
+            $arrList[$id] = str_repeat($head, $arrRet[$cnt]['level']) . $name;
+        }
+        return $arrList;
+    }
+
+    /**
+     * カテゴリーツリーの取得を行う.
+     *
+     * 親カテゴリの Value=0 を対象とする
+     *
+     * @param bool $parent_zero 親カテゴリの Value=0 の場合 true
+     * @return array カテゴリツリーの配列
+     */
+    function sfGetLevelCatList($parent_zero = true) {
+        $objQuery = new SC_Query();
+        $col = "category_id, parent_category_id, category_name, level";
+        $where = "del_flg = 0";
+        $objQuery->setoption("ORDER BY rank DESC");
+        $arrRet = $objQuery->select($col, "dtb_category", $where);
+        $max = count($arrRet);
+
+        for($cnt = 0; $cnt < $max; $cnt++) {
+            if($parent_zero) {
+                if($arrRet[$cnt]['level'] == LEVEL_MAX) {
+                    $arrValue[$cnt] = $arrRet[$cnt]['category_id'];
+                } else {
+                    $arrValue[$cnt] = "";
+                }
+            } else {
+                $arrValue[$cnt] = $arrRet[$cnt]['category_id'];
+            }
+
+            $arrOutput[$cnt] = "";
+
+            // 子カテゴリから親カテゴリを検索
+            $parent_category_id = $arrRet[$cnt]['parent_category_id'];
+            for($cat_cnt = $arrRet[$cnt]['level']; $cat_cnt > 1; $cat_cnt--) {
+
+                foreach ($arrRet as $arrCat) {
+                    // 親が見つかったら順番に代入
+                    if ($arrCat['category_id'] == $parent_category_id) {
+
+                        $arrOutput[$cnt] = CATEGORY_HEAD
+                            . $arrCat['category_name'] . $arrOutput[$cnt];
+                        $parent_category_id = $arrCat['parent_category_id'];
+                    }
+                }
+            }
+            $arrOutput[$cnt].= CATEGORY_HEAD . $arrRet[$cnt]['category_name'];
+        }
+
+        return array($arrValue, $arrOutput);
+    }
+
+    /**
+     * 選択中の商品のカテゴリを取得する.
+     *
+     * @param integer $product_id プロダクトID
+     * @param integer $category_id カテゴリID
+     * @return array 選択中の商品のカテゴリIDの配列
+     *
+     */
+    function sfGetCategoryId($product_id, $category_id = 0, $closed = false) {
+        if ($closed) {
+            $status = "";
+        } else {
+            $status = "status = 1";
+        }
+
+        if(!$this->g_category_on) {
+            $this->g_category_on = true;
+            $category_id = (int) $category_id;
+            $product_id = (int) $product_id;
+            if(SC_Utils_Ex::sfIsInt($category_id) && $this->sfIsRecord("dtb_category","category_id", $category_id)) {
+                $this->g_category_id = array($category_id);
+            } else if (SC_Utils_Ex::sfIsInt($product_id) && $this->sfIsRecord("dtb_products","product_id", $product_id, $status)) {
+                $objQuery = new SC_Query();
+                $where = "product_id = ?";
+                $category_id = $objQuery->getCol("dtb_product_categories", "category_id", "product_id = ?", array($product_id));
+                $this->g_category_id = $category_id;
+            } else {
+                // 不正な場合は、空の配列を返す。
+                $this->g_category_id = array();
+            }
+        }
+        return $this->g_category_id;
+    }
+
+    /**
+     * 商品をカテゴリの先頭に追加する.
+     *
+     * @param integer $category_id カテゴリID
+     * @param integer $product_id プロダクトID
+     * @return void
+     */
+    function addProductBeforCategories($category_id, $product_id) {
+
+        $sqlval = array("category_id" => $category_id,
+                        "product_id" => $product_id);
+
+        $objQuery = new SC_Query();
+
+        // 現在の商品カテゴリを取得
+        $arrCat = $objQuery->select("product_id, category_id, rank",
+                                    "dtb_product_categories",
+                                    "category_id = ?",
+                                    array($category_id));
+
+        $max = "0";
+        foreach ($arrCat as $val) {
+            // 同一商品が存在する場合は登録しない
+            if ($val["product_id"] == $product_id) {
+                return;
+            }
+            // 最上位ランクを取得
+            $max = ($max < $val["rank"]) ? $val["rank"] : $max;
+        }
+        $sqlval["rank"] = $max + 1;
+        $objQuery->insert("dtb_product_categories", $sqlval);
+    }
+
+    /**
+     * 商品をカテゴリの末尾に追加する.
+     *
+     * @param integer $category_id カテゴリID
+     * @param integer $product_id プロダクトID
+     * @return void
+     */
+    function addProductAfterCategories($category_id, $product_id) {
+        $sqlval = array("category_id" => $category_id,
+                        "product_id" => $product_id);
+
+        $objQuery = new SC_Query();
+
+        // 現在の商品カテゴリを取得
+        $arrCat = $objQuery->select("product_id, category_id, rank",
+                                    "dtb_product_categories",
+                                    "category_id = ?",
+                                    array($category_id));
+
+        $min = 0;
+        foreach ($arrCat as $val) {
+            // 同一商品が存在する場合は登録しない
+            if ($val["product_id"] == $product_id) {
+                return;
+            }
+            // 最下位ランクを取得
+            $min = ($min < $val["rank"]) ? $val["rank"] : $min;
+        }
+        $sqlval["rank"] = $min;
+        $objQuery->insert("dtb_product_categories", $sqlval);
+    }
+
+    /**
+     * 商品をカテゴリから削除する.
+     *
+     * @param integer $category_id カテゴリID
+     * @param integer $product_id プロダクトID
+     * @return void
+     */
+    function removeProductByCategories($category_id, $product_id) {
+        $sqlval = array("category_id" => $category_id,
+                        "product_id" => $product_id);
+        $objQuery = new SC_Query();
+        $objQuery->delete("dtb_product_categories",
+                          "category_id = ? AND product_id = ?", $sqlval);
+    }
+
+    /**
+     * 商品カテゴリを更新する.
+     *
+     * @param array $arrCategory_id 登録するカテゴリIDの配列
+     * @param integer $product_id プロダクトID
+     * @return void
+     */
+    function updateProductCategories($arrCategory_id, $product_id) {
+        $objQuery = new SC_Query();
+
+        // 現在のカテゴリ情報を取得
+        $arrCurrentCat = $objQuery->select("product_id, category_id, rank",
+                                           "dtb_product_categories",
+                                           "product_id = ?",
+                                           array($product_id));
+
+        // 登録するカテゴリ情報と比較
+        foreach ($arrCurrentCat as $val) {
+
+            // 登録しないカテゴリを削除
+            if (!in_array($val["category_id"], $arrCategory_id)) {
+                $this->removeProductByCategories($val["category_id"], $product_id);
+            }
+        }
+
+        // カテゴリを登録
+        foreach ($arrCategory_id as $category_id) {
+            $this->addProductBeforCategories($category_id, $product_id);
+        }
+    }
+
+    /**
+     * カテゴリ数の登録を行う.
+     *
+     * @param SC_Query $objQuery SC_Query インスタンス
+     * @return void
+     */
+    function sfCategory_Count($objQuery){
+        $sql = "";
+
+        //テーブル内容の削除
+        $objQuery->query("DELETE FROM dtb_category_count");
+        $objQuery->query("DELETE FROM dtb_category_total_count");
+
+        //各カテゴリ内の商品数を数えて格納
+        $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) ";
+        $sql .= " SELECT T1.category_id, count(T2.category_id), now() ";
+        $sql .= " FROM dtb_category AS T1 LEFT JOIN dtb_product_categories AS T2";
+        $sql .= " ON T1.category_id = T2.category_id ";
+        $sql .= " LEFT JOIN dtb_products AS T3";
+        $sql .= " ON T2.product_id = T3.product_id";
+        $sql .= " WHERE T3.del_flg = 0 AND T3.status = 1 ";
+        $sql .= " GROUP BY T1.category_id, T2.category_id ";
+        $objQuery->query($sql);
+
+        //子カテゴリ内の商品数を集計する
+        $arrCat = $objQuery->getAll("SELECT * FROM dtb_category");
+
+        $sql = "";
+        foreach($arrCat as $key => $val){
+
+            // 子ID一覧を取得
+            $arrRet = $this->sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']);
+            $line = SC_Utils_Ex::sfGetCommaList($arrRet);
+
+            $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) ";
+            $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count ";
+            $sql .= " WHERE category_id IN (" . $line . ")";
+
+            $objQuery->query($sql, array($val['category_id']));
+        }
+    }
+
+    /**
+     * 子IDの配列を返す.
+     *
+     * @param string $table テーブル名
+     * @param string $pid_name 親ID名
+     * @param string $id_name ID名
+     * @param integer $id ID
+     * @param array 子ID の配列
+     */
+    function sfGetChildsID($table, $pid_name, $id_name, $id) {
+        $arrRet = $this->sfGetChildrenArray($table, $pid_name, $id_name, $id);
+        return $arrRet;
+    }
+
+    /**
+     * 階層構造のテーブルから子ID配列を取得する.
+     *
+     * @param string $table テーブル名
+     * @param string $pid_name 親ID名
+     * @param string $id_name ID名
+     * @param integer $id ID番号
+     * @return array 子IDの配列
+     */
+    function sfGetChildrenArray($table, $pid_name, $id_name, $id) {
+        $objQuery = new SC_Query();
+        $col = $pid_name . "," . $id_name;
+         $arrData = $objQuery->select($col, $table);
+
+        $arrPID = array();
+        $arrPID[] = $id;
+        $arrChildren = array();
+        $arrChildren[] = $id;
+
+        $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID);
+
+        while(count($arrRet) > 0) {
+            $arrChildren = array_merge($arrChildren, $arrRet);
+            $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet);
+        }
+
+        return $arrChildren;
+    }
+
+    /**
+     * 親ID直下の子IDをすべて取得する.
+     *
+     * @param array $arrData 親カテゴリの配列
+     * @param string $pid_name 親ID名
+     * @param string $id_name ID名
+     * @param array $arrPID 親IDの配列
+     * @return array 子IDの配列
+     */
+    function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) {
+        $arrChildren = array();
+        $max = count($arrData);
+
+        for($i = 0; $i < $max; $i++) {
+            foreach($arrPID as $val) {
+                if($arrData[$i][$pid_name] == $val) {
+                    $arrChildren[] = $arrData[$i][$id_name];
+                }
+            }
+        }
+        return $arrChildren;
+    }
+
+    /**
+     * 所属するすべての階層の親IDを配列で返す.
+     *
+     * @param SC_Query $objQuery SC_Query インスタンス
+     * @param string $table テーブル名
+     * @param string $pid_name 親ID名
+     * @param string $id_name ID名
+     * @param integer $id ID
+     * @return array 親IDの配列
+     */
+    function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) {
+        $arrRet = $this->sfGetParentsArray($table, $pid_name, $id_name, $id);
+        // 配列の先頭1つを削除する。
+        array_shift($arrRet);
+        return $arrRet;
+    }
+
+    /**
+     * 階層構造のテーブルから親ID配列を取得する.
+     *
+     * @param string $table テーブル名
+     * @param string $pid_name 親ID名
+     * @param string $id_name ID名
+     * @param integer $id ID
+     * @return array 親IDの配列
+     */
+    function sfGetParentsArray($table, $pid_name, $id_name, $id) {
+        $objQuery = new SC_Query();
+        $col = $pid_name . "," . $id_name;
+        $arrData = $objQuery->select($col, $table);
+
+        $arrParents = array();
+        $arrParents[] = $id;
+        $child = $id;
+
+        $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $child);
+
+        while($ret != "") {
+            $arrParents[] = $ret;
+            $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret);
+        }
+
+        $arrParents = array_reverse($arrParents);
+
+        return $arrParents;
+    }
+
+    /**
+     * カテゴリから商品を検索する場合のWHERE文と値を返す.
+     *
+     * @param integer $category_id カテゴリID
+     * @return array 商品を検索する場合の配列
+     */
+    function sfGetCatWhere($category_id) {
+        // 子カテゴリIDの取得
+        $arrRet = $this->sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id);
+        $tmp_where = "";
+        foreach ($arrRet as $val) {
+            if($tmp_where == "") {
+                $tmp_where.= " category_id IN ( ?";
+            } else {
+                $tmp_where.= ",? ";
+            }
+            $arrval[] = $val;
+        }
+        $tmp_where.= " ) ";
+        return array($tmp_where, $arrval);
+    }
+
+    /**
+     * 受注一時テーブルから情報を取得する.
+     *
+     * @param integer $order_temp_id 受注一時ID
+     * @return array 受注一時情報の配列
+     */
+    function sfGetOrderTemp($order_temp_id) {
+        $objQuery = new SC_Query();
+        $where = "order_temp_id = ?";
+        $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id));
+        return $arrRet[0];
+    }
+
+    /**
+     * SELECTボックス用リストを作成する.
+     *
+     * @param string $table テーブル名
+     * @param string $keyname プライマリーキーのカラム名
+     * @param string $valname データ内容のカラム名
+     * @return array SELECT ボックス用リストの配列
+     */
+    function sfGetIDValueList($table, $keyname, $valname) {
+        $objQuery = new SC_Query();
+        $col = "$keyname, $valname";
+        $objQuery->setwhere("del_flg = 0");
+        $objQuery->setorder("rank DESC");
+        $arrList = $objQuery->select($col, $table);
+        $count = count($arrList);
+        for($cnt = 0; $cnt < $count; $cnt++) {
+            $key = $arrList[$cnt][$keyname];
+            $val = $arrList[$cnt][$valname];
+            $arrRet[$key] = $val;
+        }
+        return $arrRet;
+    }
+
+    /**
+     * ランキングを上げる.
+     *
+     * @param string $table テーブル名
+     * @param string $colname カラム名
+     * @param string|integer $id テーブルのキー
+     * @param string $andwhere SQL の AND 条件である WHERE 句
+     * @return void
+     */
+    function sfRankUp($table, $colname, $id, $andwhere = "") {
+        $objQuery = new SC_Query();
+        $objQuery->begin();
+        $where = "$colname = ?";
+        if($andwhere != "") {
+            $where.= " AND $andwhere";
+        }
+        // 対象項目のランクを取得
+        $rank = $objQuery->get($table, "rank", $where, array($id));
+        // ランクの最大値を取得
+        $maxrank = $objQuery->max($table, "rank", $andwhere);
+        // ランクが最大値よりも小さい場合に実行する。
+        if($rank < $maxrank) {
+            // ランクが一つ上のIDを取得する。
+            $where = "rank = ?";
+            if($andwhere != "") {
+                $where.= " AND $andwhere";
+            }
+            $uprank = $rank + 1;
+            $up_id = $objQuery->get($table, $colname, $where, array($uprank));
+            // ランク入れ替えの実行
+            $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?";
+            if($andwhere != "") {
+                $sqlup.= " AND $andwhere";
+            }
+            $objQuery->exec($sqlup, array($rank + 1, $id));
+            $objQuery->exec($sqlup, array($rank, $up_id));
+        }
+        $objQuery->commit();
+    }
+
+    /**
+     * ランキングを下げる.
+     *
+     * @param string $table テーブル名
+     * @param string $colname カラム名
+     * @param string|integer $id テーブルのキー
+     * @param string $andwhere SQL の AND 条件である WHERE 句
+     * @return void
+     */
+    function sfRankDown($table, $colname, $id, $andwhere = "") {
+        $objQuery = new SC_Query();
+        $objQuery->begin();
+        $where = "$colname = ?";
+        if($andwhere != "") {
+            $where.= " AND $andwhere";
+        }
+        // 対象項目のランクを取得
+        $rank = $objQuery->get($table, "rank", $where, array($id));
+
+        // ランクが1(最小値)よりも大きい場合に実行する。
+        if($rank > 1) {
+            // ランクが一つ下のIDを取得する。
+            $where = "rank = ?";
+            if($andwhere != "") {
+                $where.= " AND $andwhere";
+            }
+            $downrank = $rank - 1;
+            $down_id = $objQuery->get($table, $colname, $where, array($downrank));
+            // ランク入れ替えの実行
+            $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?";
+            if($andwhere != "") {
+                $sqlup.= " AND $andwhere";
+            }
+            $objQuery->exec($sqlup, array($rank - 1, $id));
+            $objQuery->exec($sqlup, array($rank, $down_id));
+        }
+        $objQuery->commit();
+    }
+
+    /**
+     * 指定順位へ移動する.
+     *
+     * @param string $tableName テーブル名
+     * @param string $keyIdColumn キーを保持するカラム名
+     * @param string|integer $keyId キーの値
+     * @param integer $pos 指定順位
+     * @param string $where SQL の AND 条件である WHERE 句
+     * @return void
+     */
+    function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = "") {
+        $objQuery = new SC_Query();
+        $objQuery->begin();
+
+        // 自身のランクを取得する
+        $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ? AND " . $where, array($keyId));
+
+        $max = $objQuery->max($tableName, "rank", $where);
+        // 値の調整（逆順）
+        if($pos > $max) {
+            $position = 1;
+        } else if($pos < 1) {
+            $position = $max;
+        } else {
+            $position = $max - $pos + 1;
+        }
+
+        //入れ替え先の順位が入れ換え元の順位より大きい場合
+        if( $position > $rank ) $term = "rank - 1";
+
+        //入れ替え先の順位が入れ換え元の順位より小さい場合
+        if( $position < $rank ) $term = "rank + 1";
+
+        // XXX 入れ替え先の順位が入れ替え元の順位と同じ場合
+        if (!isset($term)) $term = "rank";
+
+        // 指定した順位の商品から移動させる商品までのrankを１つずらす
+        $sql = "UPDATE $tableName SET rank = $term WHERE rank BETWEEN ? AND ?";
+        if($where != "") {
+            $sql.= " AND $where";
+        }
+        if( $position > $rank ) $objQuery->exec( $sql, array($rank, $position));
+        if( $position < $rank ) $objQuery->exec( $sql, array($position, $rank));
+           // 指定した順位へrankを書き換える。
+        $sql  = "UPDATE $tableName SET rank = ? WHERE $keyIdColumn = ? ";
+        if($where != "") {
+            $sql.= " AND $where";
+        }
+        $objQuery->exec( $sql, array( $position, $keyId ) );
+        $objQuery->commit();
+    }
+
+    /**
+     * ランクを含むレコードを削除する.
+     *
+     * レコードごと削除する場合は、$deleteをtrueにする
+     *
+     * @param string $table テーブル名
+     * @param string $colname カラム名
+     * @param string|integer $id テーブルのキー
+     * @param string $andwhere SQL の AND 条件である WHERE 句
+     * @param bool $delete レコードごと削除する場合 true,
+     *                     レコードごと削除しない場合 false
+     * @return void
+     */
+    function sfDeleteRankRecord($table, $colname, $id, $andwhere = "",
+                                $delete = false) {
+        $objQuery = new SC_Query();
+        $objQuery->begin();
+        // 削除レコードのランクを取得する。
+        $where = "$colname = ?";
+        if($andwhere != "") {
+            $where.= " AND $andwhere";
+        }
+        $rank = $objQuery->get($table, "rank", $where, array($id));
+
+        if(!$delete) {
+            // ランクを最下位にする、DELフラグON
+            $sqlup = "UPDATE $table SET rank = 0, del_flg = 1 ";
+            $sqlup.= "WHERE $colname = ?";
+            // UPDATEの実行
+            $objQuery->exec($sqlup, array($id));
+        } else {
+            $objQuery->delete($table, "$colname = ?", array($id));
+        }
+
+        // 追加レコードのランクより上のレコードを一つずらす。
+        $where = "rank > ?";
+        if($andwhere != "") {
+            $where.= " AND $andwhere";
+        }
+        $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
+        $objQuery->exec($sqlup, array($rank));
+        $objQuery->commit();
+    }
+
+    /**
+     * 親IDの配列を元に特定のカラムを取得する.
+     *
+     * @param SC_Query $objQuery SC_Query インスタンス
+     * @param string $table テーブル名
+     * @param string $id_name ID名
+     * @param string $col_name カラム名
+     * @param array $arrId IDの配列
+     * @return array 特定のカラムの配列
+     */
+    function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) {
+        $col = $col_name;
+        $len = count($arrId);
+        $where = "";
+
+        for($cnt = 0; $cnt < $len; $cnt++) {
+            if($where == "") {
+                $where = "$id_name = ?";
+            } else {
+                $where.= " OR $id_name = ?";
+            }
+        }
+
+        $objQuery->setorder("level");
+        $arrRet = $objQuery->select($col, $table, $where, $arrId);
+        return $arrRet;
+    }
+
+    /**
+     * カテゴリ変更時の移動処理を行う.
+     *
+     * @param SC_Query $objQuery SC_Query インスタンス
+     * @param string $table テーブル名
+     * @param string $id_name ID名
+     * @param string $cat_name カテゴリ名
+     * @param integer $old_catid 旧カテゴリID
+     * @param integer $new_catid 新カテゴリID
+     * @param integer $id ID
+     * @return void
+     */
+    function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) {
+        if ($old_catid == $new_catid) {
+            return;
+        }
+        // 旧カテゴリでのランク削除処理
+        // 移動レコードのランクを取得する。
+        $where = "$id_name = ?";
+        $rank = $objQuery->get($table, "rank", $where, array($id));
+        // 削除レコードのランクより上のレコードを一つ下にずらす。
+        $where = "rank > ? AND $cat_name = ?";
+        $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
+        $objQuery->exec($sqlup, array($rank, $old_catid));
+        // 新カテゴリでの登録処理
+        // 新カテゴリの最大ランクを取得する。
+        $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1;
+        $where = "$id_name = ?";
+        $sqlup = "UPDATE $table SET rank = ? WHERE $where";
+        $objQuery->exec($sqlup, array($max_rank, $id));
+    }
+
+    /**
+     * 配送時間を取得する.
+     *
+     * @param integer $payment_id 支払い方法ID
+     * @return array 配送時間の配列
+     */
+    function sfGetDelivTime($payment_id = "") {
+        $objQuery = new SC_Query();
+
+        $deliv_id = "";
+        $arrRet = array();
+
+        if($payment_id != "") {
+            $where = "del_flg = 0 AND payment_id = ?";
+            $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
+            $deliv_id = $arrRet[0]['deliv_id'];
+        }
+
+        if($deliv_id != "") {
+            $objQuery->setorder("time_id");
+            $where = "deliv_id = ?";
+            $arrRet= $objQuery->select("time_id, deliv_time", "dtb_delivtime", $where, array($deliv_id));
+        }
+
+        return $arrRet;
+    }
+
+    /**
+     * 都道府県、支払い方法から配送料金を取得する.
+     *
+     * @param integer $pref 都道府県ID
+     * @param integer $payment_id 支払い方法ID
+     * @return string 指定の都道府県, 支払い方法の配送料金
+     */
+    function sfGetDelivFee($arrData) {
+        $pref = $arrData['deliv_pref'];
+        $payment_id = isset($arrData['payment_id']) ? $arrData['payment_id'] : "";
+
+        $objQuery = new SC_Query();
+
+        $deliv_id = "";
+
+        // 支払い方法が指定されている場合は、対応した配送業者を取得する
+        if($payment_id != "") {
+            $where = "del_flg = 0 AND payment_id = ?";
+            $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
+            $deliv_id = $arrRet[0]['deliv_id'];
+        // 支払い方法が指定されていない場合は、先頭の配送業者を取得する
+        } else {
+            $where = "del_flg = 0";
+            $objQuery->setOrder("rank DESC");
+            $objQuery->setLimitOffset(1);
+            $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where);
+            $deliv_id = $arrRet[0]['deliv_id'];
+        }
+
+        // 配送業者から配送料を取得
+        if($deliv_id != "") {
+
+            // 都道府県が指定されていない場合は、東京都の番号を指定しておく
+            if($pref == "") {
+                $pref = 13;
+            }
+
+            $objQuery = new SC_Query();
+            $where = "deliv_id = ? AND pref = ?";
+            $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref));
+        }
+        return $arrRet[0]['fee'];
+    }
+
+    /**
+     * 集計情報を元に最終計算を行う.
+     *
+     * @param array $arrData 各種情報
+     * @param LC_Page $objPage LC_Page インスタンス
+     * @param SC_CartSession $objCartSess SC_CartSession インスタンス
+     * @param array $arrInfo 店舗情報の配列
+     * @param SC_Customer $objCustomer SC_Customer インスタンス
+     * @return array 最終計算後の配列
+     */
+    function sfTotalConfirm($arrData, &$objPage, &$objCartSess, $arrInfo, $objCustomer = "") {
+        // 未定義変数を定義
+        if (!isset($arrData['deliv_pref'])) $arrData['deliv_pref'] = "";
+        if (!isset($arrData['payment_id'])) $arrData['payment_id'] = "";
+        if (!isset($arrData['charge'])) $arrData['charge'] = "";
+        if (!isset($arrData['use_point'])) $arrData['use_point'] = "";
+
+        // 商品の合計個数
+        $total_quantity = $objCartSess->getTotalQuantity(true);
+
+        // 税金の取得
+        $arrData['tax'] = $objPage->tpl_total_tax;
+        // 小計の取得
+        $arrData['subtotal'] = $objPage->tpl_total_pretax;
+
+        // 合計送料の取得
+        $arrData['deliv_fee'] = 0;
+
+        // 商品ごとの送料が有効の場合
+        if (OPTION_PRODUCT_DELIV_FEE == 1) {
+            $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee();
+        }
+
+        // 配送業者の送料が有効の場合
+        if (OPTION_DELIV_FEE == 1) {
+            // 送料の合計を計算する
+            $arrData['deliv_fee'] += $this->sfGetDelivFee($arrData);
+        }
+
+        // 送料無料の購入数が設定されている場合
+        if(DELIV_FREE_AMOUNT > 0) {
+            if($total_quantity >= DELIV_FREE_AMOUNT) {
+                $arrData['deliv_fee'] = 0;
+            }
+        }
+
+        // 送料無料条件が設定されている場合
+        if($arrInfo['free_rule'] > 0) {
+            // 小計が無料条件を超えている場合
+            if($arrData['subtotal'] >= $arrInfo['free_rule']) {
+                $arrData['deliv_fee'] = 0;
+            }
+        }
+
+        // 合計の計算
+        $arrData['total'] = $objPage->tpl_total_pretax;	// 商品合計
+        $arrData['total']+= $arrData['deliv_fee'];		// 送料
+        $arrData['total']+= $arrData['charge'];			// 手数料
+        // お支払い合計
+        $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE);
+        // 加算ポイントの計算
+        if (USE_POINT === false) {
+            $arrData['add_point'] = 0;
+        } else {
+            $arrData['add_point'] = SC_Utils::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo);
+
+            if($objCustomer != "") {
+                // 誕生日月であった場合
+                if($objCustomer->isBirthMonth()) {
+                    $arrData['birth_point'] = BIRTH_MONTH_POINT;
+                    $arrData['add_point'] += $arrData['birth_point'];
+                }
+            }
+        }
+
+        if($arrData['add_point'] < 0) {
+            $arrData['add_point'] = 0;
+        }
+        return $arrData;
+    }
+
+    /**
+     * レコードの存在チェックを行う.
+     *
+     * @param string $table テーブル名
+     * @param string $col カラム名
+     * @param array $arrval 要素の配列
+     * @param array $addwhere SQL の AND 条件である WHERE 句
+     * @return bool レコードが存在する場合 true
+     */
+    function sfIsRecord($table, $col, $arrval, $addwhere = "") {
+        $objQuery = new SC_Query();
+        $arrCol = split("[, ]", $col);
+
+        $where = "del_flg = 0";
+
+        if($addwhere != "") {
+            $where.= " AND $addwhere";
+        }
+
+        foreach($arrCol as $val) {
+            if($val != "") {
+                if($where == "") {
+                    $where = "$val = ?";
+                } else {
+                    $where.= " AND $val = ?";
+                }
+            }
+        }
+        $ret = $objQuery->get($table, $col, $where, $arrval);
+
+        if($ret != "") {
+            return true;
+        }
+        return false;
+    }
+
+}
+?>
Index: branches/version-2/data/class/helper/SC_Helper_CSV.php
===================================================================
--- branches/version-2/data/class/helper/SC_Helper_CSV.php	(revision 18176)
+++ branches/version-2/data/class/helper/SC_Helper_CSV.php	(revision 18176)
@@ -0,0 +1,415 @@
+<?php
+  /*
+   * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+   *
+   * http://www.lockon.co.jp/
+   */
+
+  /**
+   * CSV 関連 のヘルパークラス.
+   *
+   * @package Page
+   * @author LOCKON CO.,LTD.
+   * @version $Id$
+   */
+class SC_Helper_CSV {
+
+    // {{{ properties
+
+    /** 項目英名 */
+    var $arrSubnavi;
+
+    /** 項目名 */
+    var $arrSubnaviName;
+
+    /** レビュー管理項目 */
+    var $arrREVIEW_CVSCOL;
+
+    /** レビュータイトル */
+    var $arrREVIEW_CVSTITLE;
+
+    /** トラックバック項目 */
+    var $arrTRACKBACK_CVSCOL;
+
+    /** トラックバックタイトル */
+    var $arrTRACKBACK_CVSTITLE;
+
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * デフォルトコンストラクタ.
+     */
+    function SC_Helper_CSV() {
+        $this->init();
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrPref = $masterData->getMasterData("mtb_pref",
+                                  array("pref_id", "pref_name", "rank"));
+        $this->arrSex = $masterData->getMasterData("mtb_sex");
+        $this->arrDISP = $masterData->getMasterData("mtb_disp");
+        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
+    }
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * CSV 項目を出力する.
+     *
+     * @param integer $csv_id CSV ID
+     * @param string $where SQL の WHERE 句
+     * @param array $arrVal WHERE 句の要素
+     * @return array CSV 項目の配列
+     */
+    function sfgetCsvOutput($csv_id = "", $where = "", $arrVal = array()){
+        $objQuery = new SC_Query();
+        $arrData = array();
+        $ret = array();
+
+        $sql = "";
+        $sql .= " SELECT ";
+        $sql .= "     no, ";
+        $sql .= "     csv_id, ";
+        $sql .= "     col, ";
+        $sql .= "     disp_name, ";
+        $sql .= "     rank, ";
+        $sql .= "     status, ";
+        $sql .= "     create_date, ";
+        $sql .= "     update_date ";
+        $sql .= " FROM ";
+        $sql .= "     dtb_csv ";
+
+        if ($where != "") {
+            $sql .= $where;
+            $arrData = $arrVal;
+        }elseif($csv_id != ""){
+            $sql .= " WHERE csv_id = ? ";
+            $arrData = array($csv_id);
+        }
+
+        $sql .= " ORDER BY ";
+        $sql .= "     rank , no";
+        $sql .= " ";
+
+        $ret = $objQuery->getall($sql, $arrData);
+
+        return $ret;
+    }
+
+
+    // CSV出力データを作成する。(商品)
+    function lfGetProductsCSV($where, $option, $arrval, $arrOutputCols) {
+        $objDb = new SC_Helper_DB_Ex();
+
+        $from = "vw_product_class AS prdcls";
+        $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true, array('category_id'));
+
+        $objQuery = new SC_Query();
+        $objQuery->setoption($option);
+
+        $list_data = $objQuery->select($cols, $from, $where, $arrval);
+        $max = count($list_data);
+
+        // 規格分類名一覧
+        if (in_array('classcategory_id1', $arrOutputCols) || in_array('classcategory_id2', $arrOutputCols)) {
+            $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+        }
+
+        if (!isset($data)) $data = "";
+        for($i = 0; $i < $max; $i++) {
+            // 関連商品情報の付与
+            if (in_array('classcategory_id1', $arrOutputCols)) {
+                $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']];
+            }
+            if (in_array('classcategory_id2', $arrOutputCols)) {
+                $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']];
+            }
+
+            if (in_array('category_id', $arrOutputCols)) {
+                $arrCategory_id = $objQuery->getCol("dtb_product_categories",
+                                  "category_id",
+                                  "product_id = ?",
+                                  array($list_data[$i]['product_id']));
+
+                // カテゴリID 付与
+                for ($j = 0; $j < count($arrCategory_id); $j++) {
+                    $list_data[$i]['category_id'] .= $arrCategory_id[$j];
+                    if ($j < count($arrCategory_id) - 1) {
+                        $list_data[$i]['category_id'] .= "|";
+                    }
+                }
+            }
+
+            // 各項目をCSV出力用に変換する。
+            $data .= $this->lfMakeProductsCSV($list_data[$i], $arrOutputCols);
+        }
+        return $data;
+    }
+
+    // CSV出力データを作成する。(レビュー)
+    function lfGetReviewCSV($where, $option, $arrval) {
+
+        $from = "dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ";
+        $cols = SC_Utils_Ex::sfGetCommaList($this->arrREVIEW_CVSCOL);
+
+        $objQuery = new SC_Query();
+        $objQuery->setoption($option);
+
+        $list_data = $objQuery->select($cols, $from, $where, $arrval);
+
+        $max = count($list_data);
+        if (!isset($data)) $data = "";
+        for($i = 0; $i < $max; $i++) {
+            // 各項目をCSV出力用に変換する。
+            $data .= $this->lfMakeReviewCSV($list_data[$i]);
+        }
+        return $data;
+    }
+
+    // CSV出力データを作成する。(トラックバック)
+    function lfGetTrackbackCSV($where, $option, $arrval) {
+        $from = "dtb_trackback AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ";
+        $cols = SC_Utils_Ex::sfGetCommaList($this->arrTRACKBACK_CVSCOL);
+
+        $objQuery = new SC_Query();
+        $objQuery->setoption($option);
+
+        $list_data = $objQuery->select($cols, $from, $where, $arrval);
+
+        $max = count($list_data);
+        if (!isset($data)) $data = "";
+        for($i = 0; $i < $max; $i++) {
+            // 各項目をCSV出力用に変換する。
+            $data .= $this->lfMakeTrackbackCSV($list_data[$i]);
+        }
+        return $data;
+    }
+
+    // CSV出力データを作成する。(カテゴリ)
+    function lfGetCategoryCSV($where, $option, $arrval, $arrOutputCols) {
+        $objDb = new SC_Helper_DB_Ex();
+
+        $from = "dtb_category";
+        $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols);
+
+        $objQuery = new SC_Query();
+        $objQuery->setoption($option);
+
+        $list_data = $objQuery->select($cols, $from, $where, $arrval);
+        $max = count($list_data);
+
+        if (!isset($data)) $data = "";
+        for($i = 0; $i < $max; $i++) {
+            // 各項目をCSV出力用に変換する。
+            $data .= $this->lfMakeCSV($list_data[$i]);
+        }
+        return $data;
+    }
+
+    // CSV出力データを作成する。
+    function lfGetCSV($from, $where, $option, $arrval, $arrCsvOutputCols = "") {
+
+        $cols = SC_Utils_Ex::sfGetCommaList($arrCsvOutputCols);
+
+        $objQuery = new SC_Query();
+        $objQuery->setoption($option);
+
+        $list_data = $objQuery->select($cols, $from, $where, $arrval);
+
+        $max = count($list_data);
+        if (!isset($data)) $data = "";
+        for($i = 0; $i < $max; $i++) {
+            // 各項目をCSV出力用に変換する。
+            $data .= $this->lfMakeCSV($list_data[$i]);
+        }
+        return $data;
+    }
+
+    // 各項目をCSV出力用に変換する。
+    function lfMakeCSV($list) {
+        $line = "";
+
+        reset($list);
+        while(list($key, $val) = each($list)){
+            $tmp = "";
+            switch($key) {
+            case 'order_pref':
+                $tmp = $this->arrPref[$val];
+                break;
+            case 'deliv_pref':
+                $tmp = $this->arrPref[$val];
+                break;
+            default:
+                $tmp = $val;
+                break;
+            }
+
+            $tmp = ereg_replace("[\",]", " ", $tmp);
+            $line .= "\"".$tmp."\",";
+        }
+        // 文末の","を変換
+        $line = $this->replaceLineSuffix($line);
+        return $line;
+    }
+
+    // 各項目をCSV出力用に変換する。(商品)
+    function lfMakeProductsCSV($list, $arrOutputCols) {
+        $line = "";
+        if(is_array($list)) {
+            reset($arrOutputCols);
+            while(list($key, $val) = each($arrOutputCols)){
+                $tmp = "";
+                switch($key) {
+                case 'point_rate':
+                    if($val == "") {
+                        $tmp = '0';
+                    } else {
+                        $tmp = $list[$val];
+                    }
+                    break;
+                default:
+                    $tmp = $list[$val];
+                    break;
+                }
+                $tmp = str_replace("\"", "\\\"", $tmp);
+                $line .= "\"".$tmp."\",";
+            }
+            // 文末の","を変換
+            $line = $this->replaceLineSuffix($line);
+        }
+        return $line;
+    }
+
+    // 各項目をCSV出力用に変換する。(レビュー)
+    function lfMakeReviewCSV($list) {
+        $line = "";
+        reset($list);
+        while(list($key, $val) = each($list)){
+            $tmp = "";
+            switch($key) {
+            case 'sex':
+                $tmp = isset($this->arrSex[$val]) ? $this->arrSex[$val] : "";
+                break;
+            case 'recommend_level':
+                $tmp = isset($this->arrRECOMMEND[$val]) ? $this->arrRECOMMEND[$val]
+                                                        : "";
+                break;
+            case 'status':
+                $tmp = isset($this->arrDISP[$val]) ? $this->arrDISP[$val] : "";
+                break;
+            default:
+                $tmp = $val;
+                break;
+            }
+
+            $tmp = ereg_replace("[\",]", " ", $tmp);
+            $line .= "\"".$tmp."\",";
+        }
+        // 文末の","を変換
+        $line = $this->replaceLineSuffix($line);
+        return $line;
+    }
+
+    // 各項目をCSV出力用に変換する。(トラックバック)
+    function lfMakeTrackbackCSV($list) {
+        $line = "";
+        reset($list);
+        while(list($key, $val) = each($list)){
+            $tmp = "";
+            switch($key) {
+            case 'status':
+                $tmp = $this->arrTrackBackStatus[$val];
+                break;
+            default:
+                $tmp = $val;
+                break;
+            }
+
+            $tmp = ereg_replace("[\",]", " ", $tmp);
+            $line .= "\"".$tmp."\",";
+        }
+        // 文末の","を変換
+        $line = $this->replaceLineSuffix($line);
+        return $line;
+    }
+
+    /**
+     * 行末の ',' を CRLF へ変換する.
+     *
+     * @access private
+     * @param string $line CSV出力用の1行分の文字列
+     * @return string 行末の ',' を CRLF に変換した文字列
+     */
+    function replaceLineSuffix($line) {
+        return mb_ereg_replace(",$", "\r\n", $line);
+    }
+
+    /**
+     * 項目情報を初期化する.
+     *
+     * @access private
+     * @return void
+     */
+    function init() {
+        $this->arrSubnavi = array(
+                                  1 => 'product',
+                                  2 => 'customer',
+                                  3 => 'order',
+                                  4 => 'campaign',
+                                  5 => 'category',
+                                  6 => 'csv_sql'
+                                  );
+
+        $this->arrSubnaviName = array(
+                                      1 => '商品管理',
+                                      2 => '顧客管理',
+                                      3 => '受注管理',
+                                      4 => 'キャンペーン',
+                                      5 => 'カテゴリ',
+                                      6 => '高度な設定');
+
+
+        $this->arrREVIEW_CVSCOL = array(
+                                        'B.name',
+                                        'A.status',
+                                        'A.create_date',
+                                        'A.reviewer_name',
+                                        'A.sex',
+                                        'A.recommend_level',
+                                        'A.title',
+                                        'A.comment'
+                                        );
+
+        $this->arrREVIEW_CVSTITLE = array(
+                                          '商品名',
+                                          'レビュー表示',
+                                          '投稿日',
+                                          '投稿者名',
+                                          '性別',
+                                          'おすすめレベル',
+                                          'タイトル',
+                                          'コメント'
+                                          );
+
+        $this->arrTRACKBACK_CVSTITLE = array(
+                                             '商品名',
+                                             'ブログ名',
+                                             'ブログ記事タイトル',
+                                             'ブログ記事内容',
+                                             '状態',
+                                             '投稿日'
+                                             );
+
+        $this->arrTRACKBACK_CVSCOL = array(
+                                           'B.name',
+                                           'A.blog_name',
+                                           'A.title',
+                                           'A.excerpt',
+                                           'A.status',
+                                           'A.create_date'
+                                           );
+    }
+}
+?>
Index: branches/version-2/data/class/util/SC_Utils.php
===================================================================
--- branches/version-2/data/class/util/SC_Utils.php	(revision 18176)
+++ branches/version-2/data/class/util/SC_Utils.php	(revision 18176)
@@ -0,0 +1,2026 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * 各種ユーティリティクラス.
+ *
+ * 主に static 参照するユーティリティ系の関数群
+ *
+ * :XXX: 内部でインスタンスを生成している関数は, Helper クラスへ移動するべき...
+ *
+ * @package Util
+ * @author LOCKON CO.,LTD.
+ * @version $Id:SC_Utils.php 15532 2007-08-31 14:39:46Z nanasess $
+ */
+class SC_Utils {
+
+    /**
+     * サイト管理情報から値を取得する。
+     * データが存在する場合、必ず1以上の数値が設定されている。
+     * 0を返した場合は、呼び出し元で対応すること。
+     *
+     * @param $control_id 管理ID
+     * @param $dsn DataSource
+     * @return $control_flg フラグ
+     */
+    function sfGetSiteControlFlg($control_id, $dsn = "") {
+
+        // データソース
+        if($dsn == "") {
+            if(defined('DEFAULT_DSN')) {
+                $dsn = DEFAULT_DSN;
+            } else {
+                return;
+            }
+        }
+
+        // クエリ生成
+        $target_column = "control_flg";
+        $table_name = "dtb_site_control";
+        $where = "control_id = ?";
+        $arrval = array($control_id);
+        $control_flg = 0;
+
+        // クエリ発行
+        $objQuery = new SC_Query($dsn, true, true);
+        $arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval);
+
+        // データが存在すればフラグを取得する
+        if (count($arrSiteControl) > 0) {
+            $control_flg = $arrSiteControl[0]["control_flg"];
+        }
+
+        return $control_flg;
+    }
+
+    // インストール初期処理
+    function sfInitInstall() {
+        // インストール済みが定義されていない。
+        if(!defined('ECCUBE_INSTALL')) {
+            if(!ereg("/install/", $_SERVER['PHP_SELF'])) {
+                header("Location: ./install/"); // TODO 絶対URL にする
+            }
+        } else {
+            $path = HTML_PATH . "install/index.php";
+            if(file_exists($path)) {
+                SC_Utils::sfErrorHeader("&gt;&gt; /install/index.phpは、インストール完了後にファイルを削除してください。");
+            }
+        }
+    }
+
+    // 装飾付きエラーメッセージの表示
+    function sfErrorHeader($mess, $print = false) {
+        global $GLOBAL_ERR;
+        $GLOBAL_ERR.="<div style='color: #F00; font-weight: bold; font-size: 12px;"
+            . "background-color: #FEB; text-align: center; padding: 5px;'>";
+        $GLOBAL_ERR.= $mess;
+        $GLOBAL_ERR.= "</div>";
+        if($print) {
+            print($GLOBAL_ERR);
+        }
+    }
+
+    /* エラーページの表示 */
+    function sfDispError($type) {
+
+        require_once(CLASS_EX_PATH . "page_extends/error/LC_Page_Error_DispError_Ex.php");
+
+        $objPage = new LC_Page_Error_DispError_Ex();
+        register_shutdown_function(array($objPage, "destroy"));
+        $objPage->init();
+        $objPage->type = $type;
+        $objPage->process();
+        exit;
+    }
+
+    /* サイトエラーページの表示 */
+    function sfDispSiteError($type, $objSiteSess = "", $return_top = false, $err_msg = "", $is_mobile = false) {
+        global $objCampaignSess;
+
+        require_once(CLASS_EX_PATH . "page_extends/error/LC_Page_Error_Ex.php");
+
+        $objPage = new LC_Page_Error_Ex();
+        register_shutdown_function(array($objPage, "destroy"));
+        $objPage->init();
+        $objPage->type = $type;
+        $objPage->objSiteSess = $objSiteSess;
+        $objPage->return_top = $return_top;
+        $objPage->err_msg = $err_msg;
+        $objPage->is_mobile = (defined('MOBILE_SITE')) ? true : false;
+        $objPage->process();
+        exit;
+    }
+
+    /* 認証の可否判定 */
+    function sfIsSuccess($objSess, $disp_error = true) {
+        $ret = $objSess->IsSuccess();
+        if($ret != SUCCESS) {
+            if($disp_error) {
+                // エラーページの表示
+                SC_Utils::sfDispError($ret);
+            }
+            return false;
+        }
+        // リファラーチェック(CSRFの暫定的な対策)
+        // 「リファラ無」 の場合はスルー
+        // 「リファラ有」 かつ 「管理画面からの遷移でない」 場合にエラー画面を表示する
+        if ( empty($_SERVER['HTTP_REFERER']) ) {
+            // TODO 警告表示させる？
+            // sfErrorHeader('>> referrerが無効になっています。');
+        } else {
+            $domain  = SC_Utils::sfIsHTTPS() ? SSL_URL : SITE_URL;
+            $pattern = sprintf('|^%s.*|', $domain);
+            $referer = $_SERVER['HTTP_REFERER'];
+
+            // 管理画面から以外の遷移の場合はエラー画面を表示
+            if (!preg_match($pattern, $referer)) {
+                if ($disp_error) SC_Utils::sfDispError(INVALID_MOVE_ERRORR);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 文字列をアスタリスクへ変換する.
+     *
+     * @param string $passlen 変換する文字列
+     * @return string アスタリスクへ変換した文字列
+     */
+    function lfPassLen($passlen){
+        $ret = "";
+        for ($i=0;$i<$passlen;true){
+            $ret.="*";
+            $i++;
+        }
+        return $ret;
+    }
+
+    /**
+     * HTTPSかどうかを判定
+     *
+     * @return bool
+     */
+    function sfIsHTTPS () {
+        // HTTPS時には$_SERVER['HTTPS']には空でない値が入る
+        // $_SERVER['HTTPS'] != 'off' はIIS用
+        if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     *  正規の遷移がされているかを判定
+     *  前画面でuniqidを埋め込んでおく必要がある
+     *  @param  obj  SC_Session, SC_SiteSession
+     *  @return bool
+     */
+    function sfIsValidTransition($objSess) {
+        // 前画面からPOSTされるuniqidが正しいものかどうかをチェック
+        $uniqid = $objSess->getUniqId();
+        if ( !empty($_POST['uniqid']) && ($_POST['uniqid'] === $uniqid) ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /* 前のページで正しく登録が行われたか判定 */
+    function sfIsPrePage(&$objSiteSess, $is_mobile = false) {
+        $ret = $objSiteSess->isPrePage();
+        if($ret != true) {
+            // エラーページの表示
+            SC_Utils::sfDispSiteError(PAGE_ERROR, $objSiteSess, false, "", $is_mobile);
+        }
+    }
+
+    function sfCheckNormalAccess(&$objSiteSess, &$objCartSess) {
+        // ユーザユニークIDの取得
+        $uniqid = $objSiteSess->getUniqId();
+        // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。
+        $objCartSess->saveCurrentCart($uniqid);
+        // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー)
+        $ret = $objSiteSess->checkUniqId();
+        if($ret != true) {
+            // エラーページの表示
+            SC_Utils_Ex::sfDispSiteError(CANCEL_PURCHASE, $objSiteSess);
+        }
+
+        // カート内が空でないか || 購入ボタンを押してから変化がないか
+        $quantity = $objCartSess->getTotalQuantity();
+        $ret = $objCartSess->checkChangeCart();
+        if($ret == true || !($quantity > 0)) {
+            // カート情報表示に強制移動する
+            // FIXME false を返して, Page クラスで遷移させるべき...
+            if (defined("MOBILE_SITE")) {
+                header("Location: ". MOBILE_URL_CART_TOP
+                       . "?" . session_name() . "=" . session_id());
+            } else {
+                header("Location: ".URL_CART_TOP);
+            }
+            exit;
+        }
+        return $uniqid;
+    }
+
+    /* DB用日付文字列取得 */
+    function sfGetTimestamp($year, $month, $day, $last = false) {
+        if($year != "" && $month != "" && $day != "") {
+            if($last) {
+                $time = "23:59:59";
+            } else {
+                $time = "00:00:00";
+            }
+            $date = $year."-".$month."-".$day." ".$time;
+        } else {
+            $date = "";
+        }
+        return     $date;
+    }
+
+    // INT型の数値チェック
+    function sfIsInt($value) {
+        if($value != "" && strlen($value) <= INT_LEN && is_numeric($value)) {
+            return true;
+        }
+        return false;
+    }
+
+    function sfCSVDownload($data, $prefix = ""){
+
+        if($prefix == "") {
+            $dir_name = SC_Utils::sfUpDirName();
+            $file_name = $dir_name . date("ymdHis") .".csv";
+        } else {
+            $file_name = $prefix . date("ymdHis") .".csv";
+        }
+
+        /* HTTPヘッダの出力 */
+        Header("Content-disposition: attachment; filename=${file_name}");
+        Header("Content-type: application/octet-stream; name=${file_name}");
+        Header("Cache-Control: ");
+        Header("Pragma: ");
+
+        if (mb_internal_encoding() == CHAR_CODE){
+            $data = mb_convert_encoding($data,'SJIS-Win',CHAR_CODE);
+        }
+
+        /* データを出力 */
+        echo $data;
+    }
+
+    /* 1階層上のディレクトリ名を取得する */
+    function sfUpDirName() {
+        $path = $_SERVER['PHP_SELF'];
+        $arrVal = split("/", $path);
+        $cnt = count($arrVal);
+        return $arrVal[($cnt - 2)];
+    }
+
+
+
+
+    /**
+     * 現在のサイトを更新（ただしポストは行わない）
+     *
+     * @deprecated LC_Page::reload() を使用して下さい.
+     */
+    function sfReload($get = "") {
+        if ($_SERVER["SERVER_PORT"] == "443" ){
+            $url = ereg_replace(URL_DIR . "$", "", SSL_URL);
+        } else {
+            $url = ereg_replace(URL_DIR . "$", "", SITE_URL);
+        }
+
+        if($get != "") {
+            header("Location: ". $url . $_SERVER['PHP_SELF'] . "?" . $get);
+        } else {
+            header("Location: ". $url . $_SERVER['PHP_SELF']);
+        }
+        exit;
+    }
+
+    // チェックボックスの値をマージ
+    function sfMergeCBValue($keyname, $max) {
+        $conv = "";
+        $cnt = 1;
+        for($cnt = 1; $cnt <= $max; $cnt++) {
+            if ($_POST[$keyname . $cnt] == "1") {
+                $conv.= "1";
+            } else {
+                $conv.= "0";
+            }
+        }
+        return $conv;
+    }
+
+    // html_checkboxesの値をマージして2進数形式に変更する。
+    function sfMergeCheckBoxes($array, $max) {
+        $ret = "";
+        if(is_array($array)) {
+            foreach($array as $val) {
+                $arrTmp[$val] = "1";
+            }
+        }
+        for($i = 1; $i <= $max; $i++) {
+            if(isset($arrTmp[$i]) && $arrTmp[$i] == "1") {
+                $ret.= "1";
+            } else {
+                $ret.= "0";
+            }
+        }
+        return $ret;
+    }
+
+
+    // html_checkboxesの値をマージして「-」でつなげる。
+    function sfMergeParamCheckBoxes($array) {
+        $ret = '';
+        if(is_array($array)) {
+            foreach($array as $val) {
+                if($ret != "") {
+                    $ret.= "-$val";
+                } else {
+                    $ret = $val;
+                }
+            }
+        } else {
+            $ret = $array;
+        }
+        return $ret;
+    }
+
+    // html_checkboxesの値をマージしてSQL検索用に変更する。
+    function sfSearchCheckBoxes($array) {
+        $max = 0;
+        $ret = "";
+        foreach($array as $val) {
+            $arrTmp[$val] = "1";
+            if($val > $max) {
+                $max = $val;
+            }
+        }
+        for($i = 1; $i <= $max; $i++) {
+            if($arrTmp[$i] == "1") {
+                $ret.= "1";
+            } else {
+                $ret.= "_";
+            }
+        }
+
+        if($ret != "") {
+            $ret.= "%";
+        }
+        return $ret;
+    }
+
+    // 2進数形式の値をhtml_checkboxes対応の値に切り替える
+    function sfSplitCheckBoxes($val) {
+        $arrRet = array();
+        $len = strlen($val);
+        for($i = 0; $i < $len; $i++) {
+            if(substr($val, $i, 1) == "1") {
+                $arrRet[] = ($i + 1);
+            }
+        }
+        return $arrRet;
+    }
+
+    // チェックボックスの値をマージ
+    function sfMergeCBSearchValue($keyname, $max) {
+        $conv = "";
+        $cnt = 1;
+        for($cnt = 1; $cnt <= $max; $cnt++) {
+            if ($_POST[$keyname . $cnt] == "1") {
+                $conv.= "1";
+            } else {
+                $conv.= "_";
+            }
+        }
+        return $conv;
+    }
+
+    // チェックボックスの値を分解
+    function sfSplitCBValue($val, $keyname = "") {
+        $len = strlen($val);
+        $no = 1;
+        for ($cnt = 0; $cnt < $len; $cnt++) {
+            if($keyname != "") {
+                $arr[$keyname . $no] = substr($val, $cnt, 1);
+            } else {
+                $arr[] = substr($val, $cnt, 1);
+            }
+            $no++;
+        }
+        return $arr;
+    }
+
+    // キーと値をセットした配列を取得
+    function sfArrKeyValue($arrList, $keyname, $valname, $len_max = "", $keysize = "") {
+        $arrRet = array();
+        $max = count($arrList);
+
+        if($len_max != "" && $max > $len_max) {
+            $max = $len_max;
+        }
+
+        for($cnt = 0; $cnt < $max; $cnt++) {
+            if($keysize != "") {
+                $key = SC_Utils::sfCutString($arrList[$cnt][$keyname], $keysize);
+            } else {
+                $key = $arrList[$cnt][$keyname];
+            }
+            $val = $arrList[$cnt][$valname];
+
+            if(!isset($arrRet[$key])) {
+                $arrRet[$key] = $val;
+            }
+
+        }
+        return $arrRet;
+    }
+
+    // キーと値をセットした配列を取得(値が複数の場合)
+    function sfArrKeyValues($arrList, $keyname, $valname, $len_max = "", $keysize = "", $connect = "") {
+
+        $max = count($arrList);
+
+        if($len_max != "" && $max > $len_max) {
+            $max = $len_max;
+        }
+
+        for($cnt = 0; $cnt < $max; $cnt++) {
+            if($keysize != "") {
+                $key = SC_Utils::sfCutString($arrList[$cnt][$keyname], $keysize);
+            } else {
+                $key = $arrList[$cnt][$keyname];
+            }
+            $val = $arrList[$cnt][$valname];
+
+            if($connect != "") {
+                $arrRet[$key].= "$val".$connect;
+            } else {
+                $arrRet[$key][] = $val;
+            }
+        }
+        return $arrRet;
+    }
+
+    // 配列の値をカンマ区切りで返す。
+    function sfGetCommaList($array, $space=true, $arrPop = array()) {
+        if (count($array) > 0) {
+            $line = "";
+            foreach($array as $val) {
+                if (!in_array($val, $arrPop)) {
+                    if ($space) {
+                        $line .= $val . ", ";
+                    } else {
+                        $line .= $val . ",";
+                    }
+                }
+            }
+            if ($space) {
+                $line = ereg_replace(", $", "", $line);
+            } else {
+                $line = ereg_replace(",$", "", $line);
+            }
+            return $line;
+        } else {
+            return false;
+        }
+
+    }
+
+    /* 配列の要素をCSVフォーマットで出力する。*/
+    function sfGetCSVList($array) {
+        $line = "";
+        if (count($array) > 0) {
+            foreach($array as $key => $val) {
+                $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE);
+                $line .= "\"".$val."\",";
+            }
+            $line = ereg_replace(",$", "\r\n", $line);
+        }else{
+            return false;
+        }
+        return $line;
+    }
+
+    /* 配列の要素をPDFフォーマットで出力する。*/
+    function sfGetPDFList($array) {
+        foreach($array as $key => $val) {
+            $line .= "\t".$val;
+        }
+        $line.="\n";
+        return $line;
+    }
+
+
+
+    /*-----------------------------------------------------------------*/
+    /*    check_set_term
+    /*    年月日に別れた2つの期間の妥当性をチェックし、整合性と期間を返す
+    /*　引数 (開始年,開始月,開始日,終了年,終了月,終了日)
+    /*　戻値 array(１，２，３）
+    /*          １．開始年月日 (YYYY/MM/DD 000000)
+    /*            ２．終了年月日 (YYYY/MM/DD 235959)
+    /*            ３．エラー ( 0 = OK, 1 = NG )
+    /*-----------------------------------------------------------------*/
+    function sfCheckSetTerm ( $start_year, $start_month, $start_day, $end_year, $end_month, $end_day ) {
+
+        // 期間指定
+        $error = 0;
+        if ( $start_month || $start_day || $start_year){
+            if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1;
+        } else {
+            $error = 1;
+        }
+        if ( $end_month || $end_day || $end_year){
+            if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2;
+        }
+        if ( ! $error ){
+            $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000";
+            $date2 = $end_year   ."/".sprintf("%02d",$end_month)   ."/".sprintf("%02d",$end_day)   ." 235959";
+            if ($date1 > $date2) $error = 3;
+        } else {
+            $error = 1;
+        }
+        return array($date1, $date2, $error);
+    }
+
+    // エラー箇所の背景色を変更するためのfunction SC_Viewで読み込む
+    function sfSetErrorStyle(){
+        return 'style="background-color:'.ERR_COLOR.'"';
+    }
+
+    /* DBに渡す数値のチェック
+     * 10桁以上はオーバーフローエラーを起こすので。
+     */
+    function sfCheckNumLength( $value ){
+        if ( ! is_numeric($value)  ){
+            return false;
+        }
+
+        if ( strlen($value) > 9 ) {
+            return false;
+        }
+
+        return true;
+    }
+
+    // 一致した値のキー名を取得
+    function sfSearchKey($array, $word, $default) {
+        foreach($array as $key => $val) {
+            if($val == $word) {
+                return $key;
+            }
+        }
+        return $default;
+    }
+
+    function sfGetErrorColor($val) {
+        if($val != "") {
+            return "background-color:" . ERR_COLOR;
+        }
+        return "";
+    }
+
+    function sfGetEnabled($val) {
+        if( ! $val ) {
+            return " disabled=\"disabled\"";
+        }
+        return "";
+    }
+
+    function sfGetChecked($param, $value) {
+        if($param == $value) {
+            return "checked=\"checked\"";
+        }
+        return "";
+    }
+
+    function sfTrim($str) {
+        $ret = mb_ereg_replace("^[　 \n\r]*", "", $str);
+        $ret = mb_ereg_replace("[　 \n\r]*$", "", $ret);
+        return $ret;
+    }
+
+    /* 税金計算 */
+    function sfTax($price, $tax, $tax_rule) {
+        $real_tax = $tax / 100;
+        $ret = $price * $real_tax;
+        switch($tax_rule) {
+        // 四捨五入
+        case 1:
+            $ret = round($ret);
+            break;
+        // 切り捨て
+        case 2:
+            $ret = floor($ret);
+            break;
+        // 切り上げ
+        case 3:
+            $ret = ceil($ret);
+            break;
+        // デフォルト:切り上げ
+        default:
+            $ret = ceil($ret);
+            break;
+        }
+        return $ret;
+    }
+
+    /* 税金付与 */
+    function sfPreTax($price, $tax, $tax_rule) {
+        $real_tax = $tax / 100;
+        $ret = $price * (1 + $real_tax);
+
+        switch($tax_rule) {
+        // 四捨五入
+        case 1:
+            $ret = round($ret);
+            break;
+        // 切り捨て
+        case 2:
+            $ret = floor($ret);
+            break;
+        // 切り上げ
+        case 3:
+            $ret = ceil($ret);
+            break;
+        // デフォルト:切り上げ
+        default:
+            $ret = ceil($ret);
+            break;
+        }
+        return $ret;
+    }
+
+    // 桁数を指定して四捨五入
+    function sfRound($value, $pow = 0){
+        $adjust = pow(10 ,$pow-1);
+
+        // 整数且つ0出なければ桁数指定を行う
+        if(SC_Utils::sfIsInt($adjust) and $pow > 1){
+            $ret = (round($value * $adjust)/$adjust);
+        }
+
+        $ret = round($ret);
+
+        return $ret;
+    }
+
+    /* ポイント付与 */
+    function sfPrePoint($price, $point_rate, $rule = POINT_RULE, $product_id = "") {
+        if(SC_Utils::sfIsInt($product_id)) {
+            $objQuery = new SC_Query();
+            $where = "now() >= cast(start_date as date) AND ";
+            $where .= "now() < cast(end_date as date) AND ";
+
+            $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )";
+            //登録(更新)日付順
+            $objQuery->setorder('update_date DESC');
+            //キャンペーンポイントの取得
+            $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id));
+        }
+        //複数のキャンペーンに登録されている商品は、最新のキャンペーンからポイントを取得
+        if(isset($arrRet[0]['campaign_point_rate'])
+           && $arrRet[0]['campaign_point_rate'] != "") {
+
+            $campaign_point_rate = $arrRet[0]['campaign_point_rate'];
+            $real_point = $campaign_point_rate / 100;
+        } else {
+            $real_point = $point_rate / 100;
+        }
+        $ret = $price * $real_point;
+        switch($rule) {
+        // 四捨五入
+        case 1:
+            $ret = round($ret);
+            break;
+        // 切り捨て
+        case 2:
+            $ret = floor($ret);
+            break;
+        // 切り上げ
+        case 3:
+            $ret = ceil($ret);
+            break;
+        // デフォルト:切り上げ
+        default:
+            $ret = ceil($ret);
+            break;
+        }
+        //キャンペーン商品の場合
+        if(isset($campaign_point_rate) && $campaign_point_rate != "") {
+            $ret = "(".$arrRet[0]['campaign_name']."ポイント率".$campaign_point_rate."%)".$ret;
+        }
+        return $ret;
+    }
+
+    /* 規格分類の件数取得 */
+    function sfGetClassCatCount() {
+        $sql = "select count(dtb_class.class_id) as count, dtb_class.class_id ";
+        $sql.= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id ";
+        $sql.= "where dtb_class.del_flg = 0 AND dtb_classcategory.del_flg = 0 ";
+        $sql.= "group by dtb_class.class_id, dtb_class.name";
+        $objQuery = new SC_Query();
+        $arrList = $objQuery->getall($sql);
+        // キーと値をセットした配列を取得
+        $arrRet = SC_Utils::sfArrKeyValue($arrList, 'class_id', 'count');
+
+        return $arrRet;
+    }
+
+    /* 規格の登録 */
+    function sfInsertProductClass($objQuery, $arrList, $product_id , $product_class_id = "") {
+        // すでに規格登録があるかどうかをチェックする。
+        $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
+        $count = $objQuery->count("dtb_products_class", $where,  array($product_id));
+
+        // すでに規格登録がない場合
+        if($count == 0) {
+            // 既存規格の削除
+            $where = "product_id = ?";
+            $objQuery->delete("dtb_products_class", $where, array($product_id));
+
+            // 配列の添字を定義
+            $checkArray = array("product_code", "stock", "stock_unlimited", "price01", "price02");
+            $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray);
+
+            $sqlval['product_id'] = $product_id;
+            if(strlen($product_class_id ) > 0 ){
+                $sqlval['product_class_id'] = $product_class_id;
+            }
+            $sqlval['classcategory_id1'] = '0';
+            $sqlval['classcategory_id2'] = '0';
+            $sqlval['product_code'] = $arrList["product_code"];
+            $sqlval['stock'] = $arrList["stock"];
+            $sqlval['stock_unlimited'] = $arrList["stock_unlimited"];
+            $sqlval['price01'] = $arrList['price01'];
+            $sqlval['price02'] = $arrList['price02'];
+            $sqlval['creator_id'] = $_SESSION['member_id'];
+            $sqlval['create_date'] = "now()";
+
+            if($_SESSION['member_id'] == "") {
+                $sqlval['creator_id'] = '0';
+            }
+
+            // INSERTの実行
+            $objQuery->insert("dtb_products_class", $sqlval);
+        }
+    }
+
+    function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) {
+        $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
+        $objQuery = new SC_Query();
+        $ret = $objQuery->get("dtb_products_class", "product_class_id", $where, Array($product_id, $classcategory_id1, $classcategory_id2));
+        return $ret;
+    }
+
+    /* 文末の「/」をなくす */
+    function sfTrimURL($url) {
+        $ret = ereg_replace("[/]+$", "", $url);
+        return $ret;
+    }
+
+    /* DBから取り出した日付の文字列を調整する。*/
+    function sfDispDBDate($dbdate, $time = true) {
+        list($y, $m, $d, $H, $M) = split("[- :]", $dbdate);
+
+        if(strlen($y) > 0 && strlen($m) > 0 && strlen($d) > 0) {
+            if ($time) {
+                $str = sprintf("%04d/%02d/%02d %02d:%02d", $y, $m, $d, $H, $M);
+            } else {
+                $str = sprintf("%04d/%02d/%02d", $y, $m, $d, $H, $M);
+            }
+        } else {
+            $str = "";
+        }
+        return $str;
+    }
+
+    /* 配列をキー名ごとの配列に変更する */
+    function sfSwapArray($array, $isColumnName = true) {
+        $arrRet = array();
+        $max = count($array);
+        for($i = 0; $i < $max; $i++) {
+            $j = 0;
+            foreach($array[$i] as $key => $val) {
+                if ($isColumnName) {
+                    $arrRet[$key][] = $val;
+                } else {
+                    $arrRet[$j][] = $val;
+                }
+                $j++;
+            }
+        }
+        return $arrRet;
+    }
+
+    /**
+     * 連想配列から新たな配列を生成して返す.
+     *
+     * $requires が指定された場合, $requires に含まれるキーの値のみを返す.
+     *
+     * @param array 連想配列
+     * @param array 必須キーの配列
+     * @return array 連想配列の値のみの配列
+     */
+    function getHash2Array($hash, $requires = array()) {
+        $array = array();
+        $i = 0;
+        foreach ($hash as $key => $val) {
+            if (!empty($requires)) {
+                if (in_array($key, $requires)) {
+                    $array[$i] = $val;
+                    $i++;
+                }
+            } else {
+                $array[$i] = $val;
+                $i++;
+            }
+        }
+        return $array;
+    }
+
+    /* かけ算をする（Smarty用) */
+    function sfMultiply($num1, $num2) {
+        return ($num1 * $num2);
+    }
+
+    // カードの処理結果を返す
+    function sfGetAuthonlyResult($dir, $file_name, $name01, $name02, $card_no, $card_exp, $amount, $order_id, $jpo_info = "10"){
+
+        $path = $dir .$file_name;        // cgiファイルのフルパス生成
+        $now_dir = getcwd();            // requireがうまくいかないので、cgi実行ディレクトリに移動する
+        chdir($dir);
+
+        // パイプ渡しでコマンドラインからcgi起動
+        $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info";
+
+        $tmpResult = popen($cmd, "r");
+
+        // 結果取得
+        while( ! FEOF ( $tmpResult ) ) {
+            $result .= FGETS($tmpResult);
+        }
+        pclose($tmpResult);                //     パイプを閉じる
+        chdir($now_dir);                //　元にいたディレクトリに帰る
+
+        // 結果を連想配列へ格納
+        $result = ereg_replace("&$", "", $result);
+        foreach (explode("&",$result) as $data) {
+            list($key, $val) = explode("=", $data, 2);
+            $return[$key] = $val;
+        }
+
+        return $return;
+    }
+
+    /* 加算ポイントの計算式 */
+    function sfGetAddPoint($totalpoint, $use_point, $arrInfo) {
+        if( USE_POINT === false ) return ;
+        // 購入商品の合計ポイントから利用したポイントのポイント換算価値を引く方式
+        $add_point = $totalpoint - intval($use_point * ($arrInfo['point_rate'] / 100));
+
+        if($add_point < 0) {
+            $add_point = '0';
+        }
+        return $add_point;
+    }
+
+    /* 一意かつ予測されにくいID */
+    function sfGetUniqRandomId($head = "") {
+        // 予測されないようにランダム文字列を付与する。
+        $random = GC_Utils_Ex::gfMakePassword(8);
+        // 同一ホスト内で一意なIDを生成
+        $id = uniqid($head);
+        return ($id . $random);
+    }
+
+    // カテゴリ別オススメ品の取得
+    function sfGetBestProducts( $conn, $category_id = 0){
+        // 既に登録されている内容を取得する
+        $sql = "SELECT name, main_image, main_list_image, price01_min, price01_max, price02_min, price02_max, point_rate,
+                 A.product_id, A.comment FROM dtb_best_products as A LEFT JOIN vw_products_allclass AS allcls
+                USING (product_id) WHERE A.category_id = ? AND A.del_flg = 0 AND status = 1 ORDER BY A.rank";
+        $arrItems = $conn->getAll($sql, array($category_id));
+
+        return $arrItems;
+    }
+
+    // 特殊制御文字の手動エスケープ
+    function sfManualEscape($data) {
+        // 配列でない場合
+        if(!is_array($data)) {
+            if (DB_TYPE == "pgsql") {
+                $ret = pg_escape_string($data);
+            }else if(DB_TYPE == "mysql"){
+                $ret = mysql_real_escape_string($data);
+            }
+            $ret = ereg_replace("%", "\\%", $ret);
+            $ret = ereg_replace("_", "\\_", $ret);
+            return $ret;
+        }
+
+        // 配列の場合
+        foreach($data as $val) {
+            if (DB_TYPE == "pgsql") {
+                $ret = pg_escape_string($val);
+            }else if(DB_TYPE == "mysql"){
+                $ret = mysql_real_escape_string($val);
+            }
+
+            $ret = ereg_replace("%", "\\%", $ret);
+            $ret = ereg_replace("_", "\\_", $ret);
+            $arrRet[] = $ret;
+        }
+
+        return $arrRet;
+    }
+
+    /**
+     * ドメイン間で有効なセッションのスタート
+     * 共有SSL対応のための修正により、この関数は廃止します。
+     * セッションはrequire.phpを読み込んだ際に開始されます。
+     */
+    function sfDomainSessionStart() {
+        /**
+         * 2.1.1ベータからはSC_SessionFactory_UseCookie::initSession()で処理するため、
+         * ここでは何も処理しない
+         */
+        if (defined('SESSION_KEEP_METHOD')) {
+            return;
+        }
+
+        if (session_id() === "") {
+
+            session_set_cookie_params(0, "/", DOMAIN_NAME);
+
+            if (!ini_get("session.auto_start")) {
+                // セッション開始
+                session_start();
+            }
+        }
+    }
+
+    /* 文字列に強制的に改行を入れる */
+    function sfPutBR($str, $size) {
+        $i = 0;
+        $cnt = 0;
+        $line = array();
+        $ret = "";
+
+        while($str[$i] != "") {
+            $line[$cnt].=$str[$i];
+            $i++;
+            if(strlen($line[$cnt]) > $size) {
+                $line[$cnt].="<br />";
+                $cnt++;
+            }
+        }
+
+        foreach($line as $val) {
+            $ret.=$val;
+        }
+        return $ret;
+    }
+
+    // 二回以上繰り返されているスラッシュ[/]を一つに変換する。
+    function sfRmDupSlash($istr){
+        if(ereg("^http://", $istr)) {
+            $str = substr($istr, 7);
+            $head = "http://";
+        } else if(ereg("^https://", $istr)) {
+            $str = substr($istr, 8);
+            $head = "https://";
+        } else {
+            $str = $istr;
+        }
+        $str = ereg_replace("[/]+", "/", $str);
+        $ret = $head . $str;
+        return $ret;
+    }
+
+    /**
+     * テキストファイルの文字エンコーディングを変換する.
+     *
+     * $filepath に存在するテキストファイルの文字エンコーディングを変換する.
+     * 変換前の文字エンコーディングは, mb_detect_order で設定した順序で自動検出する.
+     * 変換後は, 変換前のファイル名に「enc_」というプレフィクスを付与し,
+     * $out_dir で指定したディレクトリへ出力する
+     *
+     * TODO $filepath のファイルがバイナリだった場合の扱い
+     * TODO fwrite などでのエラーハンドリング
+     *
+     * @access public
+     * @param string $filepath 変換するテキストファイルのパス
+     * @param string $enc_type 変換後のファイルエンコーディングの種類を表す文字列
+     * @param string $out_dir 変換後のファイルを出力するディレクトリを表す文字列
+     * @return string 変換後のテキストファイルのパス
+     */
+    function sfEncodeFile($filepath, $enc_type, $out_dir) {
+        $ifp = fopen($filepath, "r");
+
+        // 正常にファイルオープンした場合
+        if ($ifp !== false) {
+
+            $basename = basename($filepath);
+            $outpath = $out_dir . "enc_" . $basename;
+
+            $ofp = fopen($outpath, "w+");
+
+            while(!feof($ifp)) {
+                $line = fgets($ifp);
+                $line = mb_convert_encoding($line, $enc_type, "auto");
+                fwrite($ofp,  $line);
+            }
+
+            fclose($ofp);
+            fclose($ifp);
+        }
+        // ファイルが開けなかった場合はエラーページを表示
+          else {
+              SC_Utils::sfDispError('');
+              exit;
+        }
+        return     $outpath;
+    }
+
+    function sfCutString($str, $len, $byte = true, $commadisp = true) {
+        if($byte) {
+            if(strlen($str) > ($len + 2)) {
+                $ret =substr($str, 0, $len);
+                $cut = substr($str, $len);
+            } else {
+                $ret = $str;
+                $commadisp = false;
+            }
+        } else {
+            if(mb_strlen($str) > ($len + 1)) {
+                $ret = mb_substr($str, 0, $len);
+                $cut = mb_substr($str, $len);
+            } else {
+                $ret = $str;
+                $commadisp = false;
+            }
+        }
+
+        // 絵文字タグの途中で分断されないようにする。
+        if (isset($cut)) {
+            // 分割位置より前の最後の [ 以降を取得する。
+            $head = strrchr($ret, '[');
+
+            // 分割位置より後の最初の ] 以前を取得する。
+            $tail_pos = strpos($cut, ']');
+            if ($tail_pos !== false) {
+                $tail = substr($cut, 0, $tail_pos + 1);
+            }
+
+            // 分割位置より前に [、後に ] が見つかった場合は、[ から ] までを
+            // 接続して絵文字タグ1個分になるかどうかをチェックする。
+            if ($head !== false && $tail_pos !== false) {
+                $subject = $head . $tail;
+                if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) {
+                    // 絵文字タグが見つかったので削除する。
+                    $ret = substr($ret, 0, -strlen($head));
+                }
+            }
+        }
+
+        if($commadisp){
+            $ret = $ret . "...";
+        }
+        return $ret;
+    }
+
+    // 年、月、締め日から、先月の締め日+1、今月の締め日を求める。
+    function sfTermMonth($year, $month, $close_day) {
+        $end_year = $year;
+        $end_month = $month;
+
+        // 開始月が終了月と同じか否か
+        $same_month = false;
+
+        // 該当月の末日を求める。
+        $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
+
+        // 月の末日が締め日より少ない場合
+        if($end_last_day < $close_day) {
+            // 締め日を月末日に合わせる
+            $end_day = $end_last_day;
+        } else {
+            $end_day = $close_day;
+        }
+
+        // 前月の取得
+        $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year));
+        $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year));
+        // 前月の末日を求める。
+        $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year));
+
+        // 前月の末日が締め日より少ない場合
+        if ($start_last_day < $close_day) {
+            // 月末日に合わせる
+            $tmp_day = $start_last_day;
+        } else {
+            $tmp_day = $close_day;
+        }
+
+        // 先月の末日の翌日を取得する
+        $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
+        $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
+        $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
+
+        // 日付の作成
+        $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day);
+        $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day);
+
+        return array($start_date, $end_date);
+    }
+
+    // PDF用のRGBカラーを返す
+    function sfGetPdfRgb($hexrgb) {
+        $hex = substr($hexrgb, 0, 2);
+        $r = hexdec($hex) / 255;
+
+        $hex = substr($hexrgb, 2, 2);
+        $g = hexdec($hex) / 255;
+
+        $hex = substr($hexrgb, 4, 2);
+        $b = hexdec($hex) / 255;
+
+        return array($r, $g, $b);
+    }
+
+    //メルマガ仮登録とメール配信
+    /*
+     * FIXME
+     */
+    function sfRegistTmpMailData($mail_flag, $email){
+        $objQuery = new SC_Query();
+        $objConn = new SC_DBConn();
+        $objPage = new LC_Page();
+
+        $random_id = sfGetUniqRandomId();
+        $arrRegistMailMagazine["mail_flag"] = $mail_flag;
+        $arrRegistMailMagazine["email"] = $email;
+        $arrRegistMailMagazine["temp_id"] =$random_id;
+        $arrRegistMailMagazine["end_flag"]='0';
+        $arrRegistMailMagazine["update_date"] = 'now()';
+
+        //メルマガ仮登録用フラグ
+        $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email));
+        $objConn->query("BEGIN");
+        switch ($flag){
+            case '0':
+            $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine);
+            break;
+
+            case '1':
+                $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = " .SC_Utils::sfQuoteSmart($email));
+            break;
+        }
+        $objConn->query("COMMIT");
+        $subject = sfMakeSubject('メルマガ仮登録が完了しました。');
+        $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id'];
+        switch ($mail_flag){
+            case '1':
+            $objPage->tpl_name = "登録";
+            $objPage->tpl_kindname = "HTML";
+            break;
+
+            case '2':
+            $objPage->tpl_name = "登録";
+            $objPage->tpl_kindname = "テキスト";
+            break;
+
+            case '3':
+            $objPage->tpl_name = "解除";
+            break;
+        }
+            $objPage->tpl_email = $email;
+        sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage);
+    }
+
+    // 再帰的に多段配列を検索して一次元配列(Hidden引渡し用配列)に変換する。
+    function sfMakeHiddenArray($arrSrc, $arrDst = array(), $parent_key = "") {
+        if(is_array($arrSrc)) {
+            foreach($arrSrc as $key => $val) {
+                if($parent_key != "") {
+                    $keyname = $parent_key . "[". $key . "]";
+                } else {
+                    $keyname = $key;
+                }
+                if(is_array($val)) {
+                    $arrDst = SC_Utils::sfMakeHiddenArray($val, $arrDst, $keyname);
+                } else {
+                    $arrDst[$keyname] = $val;
+                }
+            }
+        }
+        return $arrDst;
+    }
+
+    // DB取得日時をタイムに変換
+    function sfDBDatetoTime($db_date) {
+        $date = ereg_replace("\..*$","",$db_date);
+        $time = strtotime($date);
+        return $time;
+    }
+
+    /**
+     * テンプレートを切り替えて出力する
+     *
+     * @deprecated 2008/04/02以降使用不可
+     */
+    function sfCustomDisplay(&$objPage, $is_mobile = false) {
+        $basename = basename($_SERVER["REQUEST_URI"]);
+
+        if($basename == "") {
+            $path = $_SERVER["REQUEST_URI"] . "index.php";
+        } else {
+            $path = $_SERVER["REQUEST_URI"];
+        }
+
+        if(isset($_GET['tpl']) && $_GET['tpl'] != "") {
+            $tpl_name = $_GET['tpl'];
+        } else {
+            $tpl_name = ereg_replace("^/", "", $path);
+            $tpl_name = ereg_replace("/", "_", $tpl_name);
+            $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name);
+        }
+
+        $template_path = TEMPLATE_FTP_DIR . $tpl_name;
+echo $template_path;
+        if($is_mobile === true) {
+            $objView = new SC_MobileView();
+            $objView->assignobj($objPage);
+            $objView->display(SITE_FRAME);
+        } else if(file_exists($template_path)) {
+            $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR);
+            $objView->assignobj($objPage);
+            $objView->display($tpl_name);
+        } else {
+            $objView = new SC_SiteView();
+            $objView->assignobj($objPage);
+            $objView->display(SITE_FRAME);
+        }
+    }
+
+    // PHPのmb_convert_encoding関数をSmartyでも使えるようにする
+    function sf_mb_convert_encoding($str, $encode = 'CHAR_CODE') {
+        return  mb_convert_encoding($str, $encode);
+    }
+
+    // PHPのmktime関数をSmartyでも使えるようにする
+    function sf_mktime($format, $hour=0, $minute=0, $second=0, $month=1, $day=1, $year=1999) {
+        return  date($format,mktime($hour, $minute, $second, $month, $day, $year));
+    }
+
+    // PHPのdate関数をSmartyでも使えるようにする
+    function sf_date($format, $timestamp = '') {
+        return  date( $format, $timestamp);
+    }
+
+    // チェックボックスの型を変換する
+    function sfChangeCheckBox($data , $tpl = false){
+        if ($tpl) {
+            if ($data == 1){
+                return 'checked';
+            }else{
+                return "";
+            }
+        }else{
+            if ($data == "on"){
+                return 1;
+            }else{
+                return 2;
+            }
+        }
+    }
+
+    // 2つの配列を用いて連想配列を作成する
+    function sfarrCombine($arrKeys, $arrValues) {
+
+        if(count($arrKeys) <= 0 and count($arrValues) <= 0) return array();
+
+        $keys = array_values($arrKeys);
+        $vals = array_values($arrValues);
+
+        $max = max( count( $keys ), count( $vals ) );
+        $combine_ary = array();
+        for($i=0; $i<$max; $i++) {
+            $combine_ary[$keys[$i]] = $vals[$i];
+        }
+        if(is_array($combine_ary)) return $combine_ary;
+
+        return false;
+    }
+
+    /* 子ID所属する親IDを取得する */
+    function sfGetParentsArraySub($arrData, $pid_name, $id_name, $child) {
+        $max = count($arrData);
+        $parent = "";
+        for($i = 0; $i < $max; $i++) {
+            if($arrData[$i][$id_name] == $child) {
+                $parent = $arrData[$i][$pid_name];
+                break;
+            }
+        }
+        return $parent;
+    }
+
+    /* 階層構造のテーブルから与えられたIDの兄弟を取得する */
+    function sfGetBrothersArray($arrData, $pid_name, $id_name, $arrPID) {
+        $max = count($arrData);
+
+        $arrBrothers = array();
+        foreach($arrPID as $id) {
+            // 親IDを検索する
+            for($i = 0; $i < $max; $i++) {
+                if($arrData[$i][$id_name] == $id) {
+                    $parent = $arrData[$i][$pid_name];
+                    break;
+                }
+            }
+            // 兄弟IDを検索する
+            for($i = 0; $i < $max; $i++) {
+                if($arrData[$i][$pid_name] == $parent) {
+                    $arrBrothers[] = $arrData[$i][$id_name];
+                }
+            }
+        }
+        return $arrBrothers;
+    }
+
+    /* 階層構造のテーブルから与えられたIDの直属の子を取得する */
+    function sfGetUnderChildrenArray($arrData, $pid_name, $id_name, $parent) {
+        $max = count($arrData);
+
+        $arrChildren = array();
+        // 子IDを検索する
+        for($i = 0; $i < $max; $i++) {
+            if($arrData[$i][$pid_name] == $parent) {
+                $arrChildren[] = $arrData[$i][$id_name];
+            }
+        }
+        return $arrChildren;
+    }
+
+    // SQLシングルクォート対応
+    function sfQuoteSmart($in){
+
+        if (is_int($in) || is_double($in)) {
+            return $in;
+        } elseif (is_bool($in)) {
+            return $in ? 1 : 0;
+        } elseif (is_null($in)) {
+            return 'NULL';
+        } else {
+            return "'" . str_replace("'", "''", $in) . "'";
+        }
+    }
+
+    // ディレクトリを再帰的に生成する
+    function sfMakeDir($path) {
+        static $count = 0;
+        $count++;  // 無限ループ回避
+        $dir = dirname($path);
+        if(ereg("^[/]$", $dir) || ereg("^[A-Z]:[\\]$", $dir) || $count > 256) {
+            // ルートディレクトリで終了
+            return;
+        } else {
+            if(is_writable(dirname($dir))) {
+                if(!file_exists($dir)) {
+                    mkdir($dir);
+                    GC_Utils::gfPrintLog("mkdir $dir");
+                }
+            } else {
+                SC_Utils::sfMakeDir($dir);
+                if(is_writable(dirname($dir))) {
+                    if(!file_exists($dir)) {
+                        mkdir($dir);
+                        GC_Utils::gfPrintLog("mkdir $dir");
+                    }
+                }
+           }
+        }
+        return;
+    }
+
+    // ディレクトリ以下のファイルを再帰的にコピー
+    function sfCopyDir($src, $des, $mess = "", $override = false){
+        if(!is_dir($src)){
+            return false;
+        }
+
+        $oldmask = umask(0);
+        $mod= stat($src);
+
+        // ディレクトリがなければ作成する
+        if(!file_exists($des)) {
+            if(!mkdir($des, $mod[2])) {
+                print("path:" . $des);
+            }
+        }
+
+        $fileArray=glob( $src."*" );
+        foreach( $fileArray as $key => $data_ ){
+            // CVS管理ファイルはコピーしない
+            if(ereg("/CVS/Entries", $data_)) {
+                break;
+            }
+            if(ereg("/CVS/Repository", $data_)) {
+                break;
+            }
+            if(ereg("/CVS/Root", $data_)) {
+                break;
+            }
+
+            mb_ereg("^(.*[\/])(.*)",$data_, $matches);
+            $data=$matches[2];
+            if( is_dir( $data_ ) ){
+                $mess = SC_Utils::sfCopyDir( $data_.'/', $des.$data.'/', $mess);
+            }else{
+                if(!$override && file_exists($des.$data)) {
+                    $mess.= $des.$data . "：ファイルが存在します\n";
+                } else {
+                    if(@copy( $data_, $des.$data)) {
+                        $mess.= $des.$data . "：コピー成功\n";
+                    } else {
+                        $mess.= $des.$data . "：コピー失敗\n";
+                    }
+                }
+                $mod=stat($data_ );
+            }
+        }
+        umask($oldmask);
+        return $mess;
+    }
+
+    // 指定したフォルダ内のファイルを全て削除する
+    function sfDelFile($dir){
+        if(file_exists($dir)) {
+            $dh = opendir($dir);
+            // フォルダ内のファイルを削除
+            while($file = readdir($dh)){
+                if ($file == "." or $file == "..") continue;
+                $del_file = $dir . "/" . $file;
+                if(is_file($del_file)){
+                    $ret = unlink($dir . "/" . $file);
+                }else if (is_dir($del_file)){
+                    $ret = SC_Utils::sfDelFile($del_file);
+                }
+
+                if(!$ret){
+                    return $ret;
+                }
+            }
+
+            // 閉じる
+            closedir($dh);
+
+            // フォルダを削除
+            return rmdir($dir);
+        }
+    }
+
+    /*
+     * 関数名：sfWriteFile
+     * 引数1 ：書き込むデータ
+     * 引数2 ：ファイルパス
+     * 引数3 ：書き込みタイプ
+     * 引数4 ：パーミッション
+     * 戻り値：結果フラグ 成功なら true 失敗なら false
+     * 説明　：ファイル書き出し
+     */
+    function sfWriteFile($str, $path, $type, $permission = "") {
+        //ファイルを開く
+        if (!($file = fopen ($path, $type))) {
+            return false;
+        }
+
+        //ファイルロック
+        flock ($file, LOCK_EX);
+        //ファイルの書き込み
+        fputs ($file, $str);
+        //ファイルロックの解除
+        flock ($file, LOCK_UN);
+        //ファイルを閉じる
+        fclose ($file);
+        // 権限を指定
+        if($permission != "") {
+            chmod($path, $permission);
+        }
+
+        return true;
+    }
+
+    function sfFlush($output = " ", $sleep = 0){
+        // 実行時間を制限しない
+        set_time_limit(0);
+        // 出力をバッファリングしない(==日本語自動変換もしない)
+        ob_end_clean();
+
+        // IEのために256バイト空文字出力
+        echo str_pad('',256);
+
+        // 出力はブランクだけでもいいと思う
+        echo $output;
+        // 出力をフラッシュする
+        flush();
+
+        ob_flush();
+        ob_start();
+
+        // 時間のかかる処理
+        sleep($sleep);
+    }
+
+    // @versionの記載があるファイルからバージョンを取得する。
+    function sfGetFileVersion($path) {
+        if(file_exists($path)) {
+            $src_fp = fopen($path, "rb");
+            if($src_fp) {
+                while (!feof($src_fp)) {
+                    $line = fgets($src_fp);
+                    if(ereg("@version", $line)) {
+                        $arrLine = split(" ", $line);
+                        $version = $arrLine[5];
+                    }
+                }
+                fclose($src_fp);
+            }
+        }
+        return $version;
+    }
+
+    // 指定したURLに対してPOSTでデータを送信する
+    function sfSendPostData($url, $arrData, $arrOkCode = array()){
+        require_once(DATA_PATH . "module/Request.php");
+
+        // 送信インスタンス生成
+        $req = new HTTP_Request($url);
+
+        $req->addHeader('User-Agent', 'DoCoMo/2.0　P2101V(c100)');
+        $req->setMethod(HTTP_REQUEST_METHOD_POST);
+
+        // POSTデータ送信
+        $req->addPostDataArray($arrData);
+
+        // エラーが無ければ、応答情報を取得する
+        if (!PEAR::isError($req->sendRequest())) {
+
+            // レスポンスコードがエラー判定なら、空を返す
+            $res_code = $req->getResponseCode();
+
+            if(!in_array($res_code, $arrOkCode)){
+                $response = "";
+            }else{
+                $response = $req->getResponseBody();
+            }
+
+        } else {
+            $response = "";
+        }
+
+        // POSTデータクリア
+        $req->clearPostData();
+
+        return $response;
+    }
+
+    /**
+     * $array の要素を $arrConvList で指定した方式で mb_convert_kana を適用する.
+     *
+     * @param array $array 変換する文字列の配列
+     * @param array $arrConvList mb_convert_kana の適用ルール
+     * @return array 変換後の配列
+     * @see mb_convert_kana
+     */
+    function mbConvertKanaWithArray($array, $arrConvList) {
+        foreach ($arrConvList as $key => $val) {
+            if(isset($array[$key])) {
+                $array[$key] = mb_convert_kana($array[$key] ,$val);
+            }
+        }
+        return $array;
+    }
+
+    /**
+     * 配列の添字が未定義の場合は空文字を代入して定義する.
+     *
+     * @param array $array 添字をチェックする配列
+     * @param array $defineIndexes チェックする添字
+     * @return array 添字を定義した配列
+     */
+    function arrayDefineIndexes($array, $defineIndexes) {
+        foreach ($defineIndexes as $key) {
+            if (!isset($array[$key])) $array[$key] = "";
+        }
+        return $array;
+    }
+
+    /**
+     * XML宣言を出力する.
+     *
+     * XML宣言があると問題が発生する UA は出力しない.
+     *
+     * @return string XML宣言の文字列
+     */
+    function printXMLDeclaration() {
+        $ua = $_SERVER['HTTP_USER_AGENT'];
+        if (!preg_match("/MSIE/", $ua) || preg_match("/MSIE 7/", $ua)) {
+            print("<?xml version='1.0' encoding='" . CHAR_CODE . "'?>\n");
+        }
+    }
+
+    /*
+     * 関数名：sfGetFileList()
+     * 説明　：指定パス配下のディレクトリ取得
+     * 引数1 ：取得するディレクトリパス
+     */
+    function sfGetFileList($dir) {
+        $arrFileList = array();
+        $arrDirList = array();
+
+        if (is_dir($dir)) {
+            if ($dh = opendir($dir)) {
+                $cnt = 0;
+                // 行末の/を取り除く
+                while (($file = readdir($dh)) !== false) $arrDir[] = $file;
+                $dir = ereg_replace("/$", "", $dir);
+                // アルファベットと数字でソート
+                natcasesort($arrDir);
+                foreach($arrDir as $file) {
+                    // ./ と ../を除くファイルのみを取得
+                    if($file != "." && $file != "..") {
+
+                        $path = $dir."/".$file;
+                        // SELECT内の見た目を整えるため指定文字数で切る
+                        $file_name = SC_Utils::sfCutString($file, FILE_NAME_LEN);
+                        $file_size = SC_Utils::sfCutString(SC_Utils::sfGetDirSize($path), FILE_NAME_LEN);
+                        $file_time = date("Y/m/d", filemtime($path));
+
+                        // ディレクトリとファイルで格納配列を変える
+                        if(is_dir($path)) {
+                            $arrDirList[$cnt]['file_name'] = $file;
+                            $arrDirList[$cnt]['file_path'] = $path;
+                            $arrDirList[$cnt]['file_size'] = $file_size;
+                            $arrDirList[$cnt]['file_time'] = $file_time;
+                            $arrDirList[$cnt]['is_dir'] = true;
+                        } else {
+                            $arrFileList[$cnt]['file_name'] = $file;
+                            $arrFileList[$cnt]['file_path'] = $path;
+                            $arrFileList[$cnt]['file_size'] = $file_size;
+                            $arrFileList[$cnt]['file_time'] = $file_time;
+                            $arrFileList[$cnt]['is_dir'] = false;
+                        }
+                        $cnt++;
+                    }
+                }
+                closedir($dh);
+            }
+        }
+
+        // フォルダを先頭にしてマージ
+        return array_merge($arrDirList, $arrFileList);
+    }
+
+    /*
+     * 関数名：sfGetDirSize()
+     * 説明　：指定したディレクトリのバイト数を取得
+     * 引数1 ：ディレクトリ
+     */
+    function sfGetDirSize($dir) {
+        if(file_exists($dir)) {
+            // ディレクトリの場合下層ファイルの総量を取得
+            if (is_dir($dir)) {
+                $handle = opendir($dir);
+                while ($file = readdir($handle)) {
+                    // 行末の/を取り除く
+                    $dir = ereg_replace("/$", "", $dir);
+                    $path = $dir."/".$file;
+                    if ($file != '..' && $file != '.' && !is_dir($path)) {
+                        $bytes += filesize($path);
+                    } else if (is_dir($path) && $file != '..' && $file != '.') {
+                        // 下層ファイルのバイト数を取得する為、再帰的に呼び出す。
+                        $bytes += SC_Utils::sfGetDirSize($path);
+                    }
+                }
+            } else {
+                // ファイルの場合
+                $bytes = filesize($dir);
+            }
+        }
+        // ディレクトリ(ファイル)が存在しない場合は0byteを返す
+        if($bytes == "") $bytes = 0;
+
+        return $bytes;
+    }
+
+    /*
+     * 関数名：sfDeleteDir()
+     * 説明　：指定したディレクトリを削除
+     * 引数1 ：削除ファイル
+     */
+    function sfDeleteDir($dir) {
+        $arrResult = array();
+        if(file_exists($dir)) {
+            // ディレクトリかチェック
+            if (is_dir($dir)) {
+                if ($handle = opendir("$dir")) {
+                    $cnt = 0;
+                    while (false !== ($item = readdir($handle))) {
+                        if ($item != "." && $item != "..") {
+                            if (is_dir("$dir/$item")) {
+                                sfDeleteDir("$dir/$item");
+                            } else {
+                                $arrResult[$cnt]['result'] = @unlink("$dir/$item");
+                                $arrResult[$cnt]['file_name'] = "$dir/$item";
+                            }
+                        }
+                        $cnt++;
+                    }
+                }
+                closedir($handle);
+                $arrResult[$cnt]['result'] = @rmdir($dir);
+                $arrResult[$cnt]['file_name'] = "$dir/$item";
+            } else {
+                // ファイル削除
+                $arrResult[0]['result'] = @unlink("$dir");
+                $arrResult[0]['file_name'] = "$dir";
+            }
+        }
+
+        return $arrResult;
+    }
+
+    /*
+     * 関数名：sfGetFileTree()
+     * 説明　：ツリー生成用配列取得(javascriptに渡す用)
+     * 引数1 ：ディレクトリ
+     * 引数2 ：現在のツリーの状態開いているフォルダのパスが | 区切りで格納
+     */
+    function sfGetFileTree($dir, $tree_status) {
+
+        $cnt = 0;
+        $arrTree = array();
+        $default_rank = count(split('/', $dir));
+
+        // 文末の/を取り除く
+        $dir = ereg_replace("/$", "", $dir);
+        // 最上位層を格納(user_data/)
+        if(sfDirChildExists($dir)) {
+            $arrTree[$cnt]['type'] = "_parent";
+        } else {
+            $arrTree[$cnt]['type'] = "_child";
+        }
+        $arrTree[$cnt]['path'] = $dir;
+        $arrTree[$cnt]['rank'] = 0;
+        $arrTree[$cnt]['count'] = $cnt;
+        // 初期表示はオープン
+        if($_POST['mode'] != '') {
+            $arrTree[$cnt]['open'] = lfIsFileOpen($dir, $tree_status);
+        } else {
+            $arrTree[$cnt]['open'] = true;
+        }
+        $cnt++;
+
+        sfGetFileTreeSub($dir, $default_rank, $cnt, $arrTree, $tree_status);
+
+        return $arrTree;
+    }
+
+    /*
+     * 関数名：sfGetFileTree()
+     * 説明　：ツリー生成用配列取得(javascriptに渡す用)
+     * 引数1 ：ディレクトリ
+     * 引数2 ：デフォルトの階層(/区切りで　0,1,2・・・とカウント)
+     * 引数3 ：連番
+     * 引数4 ：現在のツリーの状態開いているフォルダのパスが | 区切りで格納
+     */
+    function sfGetFileTreeSub($dir, $default_rank, &$cnt, &$arrTree, $tree_status) {
+
+        if(file_exists($dir)) {
+            if ($handle = opendir("$dir")) {
+                while (false !== ($item = readdir($handle))) $arrDir[] = $item;
+                // アルファベットと数字でソート
+                natcasesort($arrDir);
+                foreach($arrDir as $item) {
+                    if ($item != "." && $item != "..") {
+                        // 文末の/を取り除く
+                        $dir = ereg_replace("/$", "", $dir);
+                        $path = $dir."/".$item;
+                        // ディレクトリのみ取得
+                        if (is_dir($path)) {
+                            $arrTree[$cnt]['path'] = $path;
+                            if(sfDirChildExists($path)) {
+                                $arrTree[$cnt]['type'] = "_parent";
+                            } else {
+                                $arrTree[$cnt]['type'] = "_child";
+                            }
+
+                            // 階層を割り出す
+                            $arrCnt = split('/', $path);
+                            $rank = count($arrCnt);
+                            $arrTree[$cnt]['rank'] = $rank - $default_rank + 1;
+                            $arrTree[$cnt]['count'] = $cnt;
+                            // フォルダが開いているか
+                            $arrTree[$cnt]['open'] = lfIsFileOpen($path, $tree_status);
+                            $cnt++;
+                            // 下層ディレクトリ取得の為、再帰的に呼び出す
+                            sfGetFileTreeSub($path, $default_rank, $cnt, $arrTree, $tree_status);
+                        }
+                    }
+                }
+            }
+            closedir($handle);
+        }
+    }
+
+    /*
+     * 関数名：sfDirChildExists()
+     * 説明　：指定したディレクトリ配下にファイルがあるか
+     * 引数1 ：ディレクトリ
+     */
+    function sfDirChildExists($dir) {
+        if(file_exists($dir)) {
+            if (is_dir($dir)) {
+                $handle = opendir($dir);
+                while ($file = readdir($handle)) {
+                    // 行末の/を取り除く
+                    $dir = ereg_replace("/$", "", $dir);
+                    $path = $dir."/".$file;
+                    if ($file != '..' && $file != '.' && is_dir($path)) {
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+
+    /*
+     * 関数名：lfIsFileOpen()
+     * 説明　：指定したファイルが前回開かれた状態にあったかチェック
+     * 引数1 ：ディレクトリ
+     * 引数2 ：現在のツリーの状態開いているフォルダのパスが | 区切りで格納
+     */
+    function lfIsFileOpen($dir, $tree_status) {
+        $arrTreeStatus = split('\|', $tree_status);
+        if(in_array($dir, $arrTreeStatus)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /*
+     * 関数名：sfDownloadFile()
+     * 引数1 ：ファイルパス
+     * 説明　：ファイルのダウンロード
+     */
+    function sfDownloadFile($file) {
+         // ファイルの場合はダウンロードさせる
+        Header("Content-disposition: attachment; filename=".basename($file));
+        Header("Content-type: application/octet-stream; name=".basename($file));
+        Header("Cache-Control: ");
+        Header("Pragma: ");
+        echo (sfReadFile($file));
+    }
+
+    /*
+     * 関数名：sfCreateFile()
+     * 引数1 ：ファイルパス
+     * 引数2 ：パーミッション
+     * 説明　：ファイル作成
+     */
+    function sfCreateFile($file, $mode = "") {
+        // 行末の/を取り除く
+        if($mode != "") {
+            $ret = @mkdir($file, $mode);
+        } else {
+            $ret = @mkdir($file);
+        }
+
+        return $ret;
+    }
+
+    /*
+     * 関数名：sfReadFile()
+     * 引数1 ：ファイルパス
+     * 説明　：ファイル読込
+     */
+    function sfReadFile($filename) {
+        $str = "";
+        // バイナリモードでオープン
+        $fp = @fopen($filename, "rb" );
+        //ファイル内容を全て変数に読み込む
+        if($fp) {
+            $str = @fread($fp, filesize($filename)+1);
+        }
+        @fclose($fp);
+
+        return $str;
+    }
+
+   /**
+     * CSV出力用データ取得
+     *
+     * @return string
+     */
+    function getCSVData($array, $arrayIndex) {
+        for ($i = 0; $i < count($array); $i++){
+            // インデックスが設定されている場合
+            if (is_array($arrayIndex) && 0 < count($arrayIndex)){
+                for ($j = 0; $j < count($arrayIndex); $j++ ){
+                    if ( $j > 0 ) $return .= ",";
+                    $return .= "\"";
+                    $return .= mb_ereg_replace("<","＜",mb_ereg_replace( "\"","\"\"",$array[$i][$arrayIndex[$j]] )) ."\"";
+                }
+            } else {
+                for ($j = 0; $j < count($array[$i]); $j++ ){
+                    if ( $j > 0 ) $return .= ",";
+                    $return .= "\"";
+                    $return .= mb_ereg_replace("<","＜",mb_ereg_replace( "\"","\"\"",$array[$i][$j] )) ."\"";
+                }
+            }
+            $return .= "\n";
+        }
+        return $return;
+    }
+
+   /**
+     * 配列をテーブルタグで出力する。
+     *
+     * @return string
+     */
+    function getTableTag($array) {
+        $html = "<table>";
+        $html.= "<tr>";
+        foreach($array[0] as $key => $val) {
+            $html.="<th>$key</th>";
+        }
+        $html.= "</tr>";
+
+        $cnt = count($array);
+
+        for($i = 0; $i < $cnt; $i++) {
+            $html.= "<tr>";
+          foreach($array[$i] as $val) {
+                $html.="<td>$val</td>";
+            }
+            $html.= "</tr>";
+        }
+        return $html;
+    }
+
+    /**
+     * 出力バッファをフラッシュし, バッファリングを開始する.
+     *
+     * @return void
+     */
+    function flush() {
+        flush();
+        ob_end_flush();
+        ob_start();
+    }
+
+    /* デバッグ用 ------------------------------------------------------------------------------------------------*/
+    function sfPrintR($obj) {
+        print("<div style='font-size: 12px;color: #00FF00;'>\n");
+        print("<strong>**デバッグ中**</strong><br />\n");
+        print("<pre>\n");
+        //print_r($obj);
+        var_dump($obj);
+        print("</pre>\n");
+        print("<strong>**デバッグ中**</strong></div>\n");
+    }
+}
+?>
Index: branches/version-2/data/class/SC_Fpdf.php
===================================================================
--- branches/version-2/data/class/SC_Fpdf.php	(revision 18176)
+++ branches/version-2/data/class/SC_Fpdf.php	(revision 18176)
@@ -0,0 +1,356 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/*----------------------------------------------------------------------
+ * [名称] SC_Fpdf
+ * [概要] pdfファイルを表示する。
+ *----------------------------------------------------------------------
+ */
+
+require(DATA_PATH . 'pdf/japanese.php');
+define('PDF_TEMPLATE_DIR', DATA_PATH . 'pdf/');
+define('PDF_IMG_DIR', HTML_PATH. USER_DIR. USER_PACKAGE_DIR. TEMPLATE_NAME. '/img/pdf/');
+
+class SC_Fpdf {
+    function SC_Fpdf($download, $title, $tpl_pdf = "template_nouhin01.pdf") {
+        $this->arrData = $arrData;
+        // デフォルトの設定
+        $this->tpl_pdf = PDF_TEMPLATE_DIR . $tpl_pdf;  // テンプレートファイル
+        $this->pdf_download = $download;      // PDFのダウンロード形式（0:表示、1:ダウンロード）
+        $this->tpl_title = $title;
+        $this->tpl_dispmode = "real";      // 表示モード
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));
+        $this->width_cell = array(110.3,12,21.7,24.5);
+
+        $this->label_cell[] = $this->sjis_conv("商品名 / 商品コード / [ 規格 ]");
+        $this->label_cell[] = $this->sjis_conv("数量");
+        $this->label_cell[] = $this->sjis_conv("単価");
+        $this->label_cell[] = $this->sjis_conv("金額(税込)");
+
+        $this->arrMessage = array(
+          'このたびはお買上げいただきありがとうございます。',
+          '下記の内容にて納品させていただきます。',
+          'ご確認いただきますよう、お願いいたします。'
+        );
+
+        $this->pdf  = new PDF_Japanese();
+
+        // SJISフォント
+        $this->pdf->AddSJISFont();
+
+        //ページ総数取得
+        $this->pdf->AliasNbPages();
+
+        // マージン設定
+        $this->pdf->SetMargins(15, 20);
+
+        // PDFを読み込んでページ数を取得
+        $pageno = $this->pdf->setSourceFile($this->tpl_pdf);
+    }
+
+
+    function setData($arrData) {
+        $this->arrData = $arrData;
+
+        // ページ番号よりIDを取得
+        $tplidx = $this->pdf->ImportPage(1);
+
+        // ページを追加（新規）
+        $this->pdf->AddPage();
+
+        //表示倍率(100%)
+        $this->pdf->SetDisplayMode($this->tpl_dispmode);
+
+        if(SC_Utils_Ex::sfIsInt($arrData['order_id'])) {
+          $this->disp_mode = true;
+          $order_id = $arrData['order_id'];
+        }
+
+        // テンプレート内容の位置、幅を調整 ※useTemplateに引数を与えなければ100%表示がデフォルト
+        $this->pdf->useTemplate($tplidx);
+
+        $this->setShopData();
+        $this->setMessageData();
+        $this->setOrderData();
+        $this->setEtcData();
+
+    }
+
+    function setShopData() {
+        // ショップ情報
+
+        $objInfo = new SC_SiteInfo();
+        $arrInfo = $objInfo->data;
+
+        $this->lfText(125, 60, $arrInfo['shop_name'], 8, 'B');          //ショップ名
+        $this->lfText(125, 63, $arrInfo['law_url'], 8);          //URL
+        $this->lfText(125, 68, $arrInfo['law_company'], 8);        //会社名
+        $text = "〒 ".$arrInfo['law_zip01']." - ".$arrInfo['law_zip02'];
+        $this->lfText(125, 71, $text, 8);  //郵便番号
+        $text = $this->arrPref[$arrInfo['law_pref']].$arrInfo['law_addr01'];
+        $this->lfText(125, 74, $text, 8);  //都道府県+住所1
+        $this->lfText(125, 77, $arrInfo['law_addr02'], 8);          //住所2
+
+        $text = "TEL: ".$arrInfo['law_tel01']."-".$arrInfo['law_tel02']."-".$arrInfo['law_tel03'];
+        if ( strlen($arrInfo['law_fax01']) > 0 && strlen($arrInfo['law_fax02']) > 0 && strlen($arrInfo['law_fax03']) > 0 ) {
+            $text .= "　FAX: ".$arrInfo['law_fax01']."-".$arrInfo['law_fax02']."-".$arrInfo['law_fax03'];
+        }
+        $this->lfText(125, 80, $text, 8);  //TEL・FAX
+
+        if ( strlen($arrInfo['law_email']) > 0 ) {
+            $text = "Email: ".$arrInfo['law_email'];
+            $this->lfText(125, 83, $text, 8);      //Email
+        }
+
+        //ロゴ画像
+        $logo_file = PDF_TEMPLATE_DIR . 'logo.png';
+        $this->pdf->Image($logo_file, 124, 46, 40);
+    }
+
+    function setMessageData() {
+        // メッセージ
+        $this->lfText(27, 70, $this->arrData['msg1'], 8);  //メッセージ1
+        $this->lfText(27, 74, $this->arrData['msg2'], 8);  //メッセージ2
+        $this->lfText(27, 78, $this->arrData['msg3'], 8);  //メッセージ3
+        $text = "作成日: ".$this->arrData['year']."年".$this->arrData['month']."月".$this->arrData['day']."日";
+        $this->lfText(158, 288, $text, 8);  //作成日
+    }
+
+    function setOrderData() {
+        // ショップ情報
+        $objInfo = new SC_SiteInfo();
+        $arrInfo = $objInfo->data;
+        // DBから受注情報を読み込む
+        $this->lfGetOrderData($this->arrData['order_id']);
+
+        // 購入者情報
+        $text = "〒 ".$this->arrDisp['order_zip01']." - ".$this->arrDisp['order_zip02'];
+        $this->lfText(23, 43, $text, 10); //購入者郵便番号
+        $text = $this->arrPref[$this->arrDisp['order_pref']] . $this->arrDisp['order_addr01'];
+        $this->lfText(27, 47, $text, 10); //購入者都道府県+住所1
+        $this->lfText(27, 51, $this->arrDisp['order_addr02'], 10); //購入者住所2
+        $text = $this->arrDisp['order_name01']."　".$this->arrDisp['order_name02']."　様";
+        $this->lfText(27, 59, $text, 11); //購入者氏名
+
+        // お届け先情報
+        $this->pdf->SetFont('SJIS', '', 10);
+        $text = "〒 ".$this->arrDisp['deliv_zip01']." - ".$this->arrDisp['deliv_zip02'];
+        $this->lfText(22, 128, $text, 10); //お届け先郵便番号
+        $text = $this->arrPref[$this->arrDisp['deliv_pref']] . $this->arrDisp['deliv_addr01'];
+        $this->lfText(26, 132, $text, 10); //お届け先都道府県+住所1
+        $this->lfText(26, 136, $this->arrDisp['deliv_addr02'], 10); //お届け先住所2
+        $text = $this->arrDisp['deliv_name01']."　".$this->arrDisp['deliv_name02']."　様";
+        $this->lfText(26, 140, $text, 10); //お届け先氏名
+
+        $this->lfText(144, 121, SC_Utils_Ex::sfDispDBDate($this->arrDisp['create_date']), 10); //ご注文日
+        $this->lfText(144, 131, $this->arrDisp['order_id'], 10); //注文番号
+
+        $this->pdf->SetFont('SJIS', 'B', 15);
+        $this->pdf->Cell(0, 10, $this->sjis_conv($this->tpl_title), 0, 2, 'C', 0, '');  //文書タイトル（納品書・請求書）
+        $this->pdf->Cell(0, 66, '', 0, 2, 'R', 0, '');
+        $this->pdf->Cell(5, 0, '', 0, 0, 'R', 0, '');
+        $this->pdf->Cell(67, 8, $this->sjis_conv(number_format($this->arrDisp['payment_total'])." 円"), 0, 2, 'R', 0, '');
+        $this->pdf->Cell(0, 45, '', 0, 2, '', 0, '');
+
+        $this->pdf->SetFont('SJIS', '', 8);
+
+        $monetary_unit = $this->sjis_conv("円");
+        $point_unit = $this->sjis_conv("pt");
+
+        // 購入商品情報
+        for ($i = 0; $i < count($this->arrDisp['quantity']); $i++) {
+
+          // 購入数量
+          $data[0] = $this->arrDisp['quantity'][$i];
+
+          // 税込金額（単価）
+          $data[1] = SC_Utils_Ex::sfPreTax($this->arrDisp['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']);
+
+          // 小計（商品毎）
+          $data[2] = $data[0] * $data[1];
+
+          $arrOrder[$i][0]  = $this->sjis_conv($this->arrDisp['product_name'][$i]." / ");
+          $arrOrder[$i][0] .= $this->sjis_conv($this->arrDisp['product_code'][$i]." / ");
+          if($this->arrDisp['classcategory_name1'][$i]) {
+            $arrOrder[$i][0] .= $this->sjis_conv(" [ ".$this->arrDisp['classcategory_name1'][$i]);
+            if($this->arrDisp['classcategory_name2'][$i] == "") {
+              $arrOrder[$i][0] .= " ]";
+            } else {
+              $arrOrder[$i][0] .= $this->sjis_conv(" * ".$this->arrDisp['classcategory_name2'][$i]." ]");
+            }
+          }
+          $arrOrder[$i][1]  = number_format($data[0]);
+          $arrOrder[$i][2]  = number_format($data[1]).$monetary_unit;
+          $arrOrder[$i][3]  = number_format($data[2]).$monetary_unit;
+
+        }
+
+        $arrOrder[$i][0] = "";
+        $arrOrder[$i][1] = "";
+        $arrOrder[$i][2] = "";
+        $arrOrder[$i][3] = "";
+
+        $i++;
+        $arrOrder[$i][0] = "";
+        $arrOrder[$i][1] = "";
+        $arrOrder[$i][2] = $this->sjis_conv("商品合計");
+        $arrOrder[$i][3] = number_format($this->arrDisp['subtotal']).$monetary_unit;
+
+        $i++;
+        $arrOrder[$i][0] = "";
+        $arrOrder[$i][1] = "";
+        $arrOrder[$i][2] = $this->sjis_conv("送料");
+        $arrOrder[$i][3] = number_format($this->arrDisp['deliv_fee']).$monetary_unit;
+
+        $i++;
+        $arrOrder[$i][0] = "";
+        $arrOrder[$i][1] = "";
+        $arrOrder[$i][2] = $this->sjis_conv("手数料");
+        $arrOrder[$i][3] = number_format($this->arrDisp['charge']).$monetary_unit;
+
+        $i++;
+        $arrOrder[$i][0] = "";
+        $arrOrder[$i][1] = "";
+        $arrOrder[$i][2] = $this->sjis_conv("値引き");
+        $arrOrder[$i][3] = "- ".number_format(($this->arrDisp['use_point'] * POINT_VALUE) + $this->arrDisp['discount']).$monetary_unit;
+
+        $i++;
+        $arrOrder[$i][0] = "";
+        $arrOrder[$i][1] = "";
+        $arrOrder[$i][2] = $this->sjis_conv("請求金額");
+        $arrOrder[$i][3] = number_format($this->arrDisp['payment_total']).$monetary_unit;
+
+        $i++;
+        $arrOrder[$i][0] = "";
+        $arrOrder[$i][1] = "";
+        $arrOrder[$i][2] = "";
+        $arrOrder[$i][3] = "";
+
+        // ポイント表記
+        if ($this->arrData['disp_point'] && $this->arrDisp['customer_id']) {
+          $i++;
+          $arrOrder[$i][0] = "";
+          $arrOrder[$i][1] = "";
+          $arrOrder[$i][2] = $this->sjis_conv("利用ポイント");
+          $arrOrder[$i][3] = number_format($this->arrDisp['use_point']).$point_unit;
+
+          $i++;
+          $arrOrder[$i][0] = "";
+          $arrOrder[$i][1] = "";
+          $arrOrder[$i][2] = $this->sjis_conv("加算ポイント");
+          $arrOrder[$i][3] = number_format($this->arrDisp['add_point']).$point_unit;
+
+          $i++;
+          $arrOrder[$i][0] = "";
+          $arrOrder[$i][1] = "";
+          $arrOrder[$i][2] = $this->sjis_conv("所有ポイント");
+          $arrOrder[$i][3] = number_format($this->arrDisp['point']).$point_unit;
+        }
+
+        $this->pdf->FancyTable($this->label_cell, $arrOrder, $this->width_cell);
+    }
+
+    function setEtcData() {
+        $this->pdf->Cell(0, 10, '', 0, 1, 'C', 0, '');
+        $this->pdf->SetFont('SJIS', '', 9);
+        $this->pdf->MultiCell(0, 6, $this->sjis_conv("＜ 備 考 ＞"), 'T', 2, 'L', 0, '');  //備考
+        $this->pdf->Ln();
+        $this->pdf->SetFont('SJIS', '', 8);
+        $this->pdf->MultiCell(0, 4, $this->sjis_conv($this->arrData['etc1']."\n".$this->arrData['etc2']."\n".$this->arrData['etc3']), '', 2, 'L', 0, '');  //備考
+    }
+
+    function createPdf() {
+        // PDFをブラウザに送信
+ob_clean();
+        if ($this->pdf->PageNo() == 1) {
+            $filename = "nouhinsyo-No".$this->arrData['order_id'].".pdf";
+          } else {
+            $filename = "nouhinsyo.pdf";
+          }
+          $this->pdf->Output($this->sjis_conv($filename), D);
+
+        // 入力してPDFファイルを閉じる
+        $this->pdf->Close();
+    }
+
+    // PDF_Japanese::Text へのパーサー
+    function lfText($x, $y, $text, $size, $style = '') {
+        $text = mb_convert_encoding($text, "SJIS", CHAR_CODE);
+
+        $this->pdf->SetFont('SJIS', $style, $size);
+        $this->pdf->Text($x, $y, $text);
+    }
+
+
+    // 受注データの取得
+    function lfGetOrderData($order_id) {
+        if(SC_Utils_Ex::sfIsInt($order_id)) {
+            // DBから受注情報を読み込む
+            $objQuery = new SC_Query();
+            $where = "order_id = ?";
+            $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
+            #$objFormParam->setParam($arrRet[0]);
+            list($point, $total_point) = SC_Helper_DB_Ex::sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
+            #$objFormParam->setValue('total_point', $total_point);
+            #$objFormParam->setValue('point', $point);
+            $arrRet[0]['total_point'] = $total_point;
+            $arrRet[0]['point'] = $point;
+            $this->arrDisp = $arrRet[0];
+
+            // 受注詳細データの取得
+            $arrRet = $this->lfGetOrderDetail($order_id);
+            $arrRet = SC_Utils_Ex::sfSwapArray($arrRet);
+            $this->arrDisp = array_merge($this->arrDisp, $arrRet);
+            #$objFormParam->setParam($arrRet);
+
+            // その他支払い情報を表示
+            if($this->arrDisp["memo02"] != "") $this->arrDisp["payment_info"] = unserialize($this->arrDisp["memo02"]);
+            if($this->arrDisp["memo01"] == PAYMENT_CREDIT_ID){
+                  $this->arrDisp["payment_type"] = "クレジット決済";
+            } elseif ($this->arrDisp["memo01"] == PAYMENT_CONVENIENCE_ID) {
+                  $this->arrDisp["payment_type"] = "コンビニ決済";
+            } else {
+                  $this->arrDisp["payment_type"] = "お支払い";
+            }
+        }
+    }
+
+    // 受注詳細データの取得
+    function lfGetOrderDetail($order_id) {
+      $objQuery = new SC_Query();
+      $col = "product_id, classcategory_id1, classcategory_id2, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate";
+      $where = "order_id = ?";
+      $objQuery->setorder("classcategory_id1, classcategory_id2");
+      $arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id));
+      return $arrRet;
+    }
+
+    // 文字コードSJIS変換 -> japanese.phpで使用出来る文字コードはSJISのみ
+    function sjis_conv($conv_str) {
+      return (mb_convert_encoding($conv_str, "SJIS", CHAR_CODE));
+    }
+
+
+}
+?>
Index: branches/version-2/data/class/pages/mypage/LC_Page_Mypage_DeliveryAddr.php
===================================================================
--- branches/version-2/data/class/pages/mypage/LC_Page_Mypage_DeliveryAddr.php	(revision 18176)
+++ branches/version-2/data/class/pages/mypage/LC_Page_Mypage_DeliveryAddr.php	(revision 18176)
@@ -0,0 +1,229 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * お届け先追加 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Mypage_DeliveryAddr extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = TEMPLATE_DIR . 'mypage/delivery_addr.tpl';
+        $this->tpl_title = "新しいお届け先の追加･変更";
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrPref= $masterData->getMasterData("mtb_pref",
+                            array("pref_id", "pref_name", "rank"));
+        $this->allowClientCache();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_SiteView(false);
+        $objQuery = new SC_Query();
+        $objCustomer = new SC_Customer();
+        $ParentPage = MYPAGE_DELIVADDR_URL;
+
+        // GETでページを指定されている場合には指定ページに戻す
+        if (isset($_GET['page'])) {
+            $ParentPage = htmlspecialchars($_GET['page'],ENT_QUOTES);
+        }
+        $this->ParentPage = $ParentPage;
+
+        //ログイン判定
+        if (!$objCustomer->isLoginSuccess()){
+            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+        }
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+        if (!isset($_GET['other_deliv_id'])) $_GET['other_deliv_id'] = "";
+
+        if ($_POST['mode'] == ""){
+            $_SESSION['other_deliv_id'] = $_GET['other_deliv_id'];
+        }
+
+        if ($_GET['other_deliv_id'] != ""){
+            //不正アクセス判定
+            $flag = $objQuery->count("dtb_other_deliv", "customer_id=? AND other_deliv_id=?", array($objCustomer->getValue("customer_id"), $_SESSION['other_deliv_id']));
+            if (!$objCustomer->isLoginSuccess() || $flag == 0){
+                SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+            }
+        }
+
+        //別のお届け先ＤＢ登録用カラム配列
+        $arrRegistColumn = array(
+                                 array(  "column" => "name01",		"convert" => "aKV" ),
+                                 array(  "column" => "name02",		"convert" => "aKV" ),
+                                 array(  "column" => "kana01",		"convert" => "CKV" ),
+                                 array(  "column" => "kana02",		"convert" => "CKV" ),
+                                 array(  "column" => "zip01",		"convert" => "n" ),
+                                 array(  "column" => "zip02",		"convert" => "n" ),
+                                 array(  "column" => "pref",		"convert" => "n" ),
+                                 array(  "column" => "addr01",		"convert" => "aKV" ),
+                                 array(  "column" => "addr02",		"convert" => "aKV" ),
+                                 array(  "column" => "tel01",		"convert" => "n" ),
+                                 array(  "column" => "tel02",		"convert" => "n" ),
+                                 array(  "column" => "tel03",		"convert" => "n" ),
+                                 );
+
+
+        if ($_GET['other_deliv_id'] != ""){
+            //別のお届け先情報取得
+            $arrOtherDeliv = $objQuery->select("*", "dtb_other_deliv", "other_deliv_id=? ", array($_SESSION['other_deliv_id']));
+            $this->arrForm = $arrOtherDeliv[0];
+        }
+
+        switch ($_POST['mode']) {
+            case 'edit':
+                $_POST = $this->lfConvertParam($_POST,$arrRegistColumn);
+                $this->arrErr = $this->lfErrorCheck($_POST);
+                if ($this->arrErr){
+                    foreach ($_POST as $key => $val){
+                        if ($val != "") $this->arrForm[$key] = $val;
+                    }
+                } else {
+                    //別のお届け先登録数の取得
+                    $deliv_count = $objQuery->count("dtb_other_deliv", "customer_id=?", array($objCustomer->getValue('customer_id')));
+                    if ($deliv_count < DELIV_ADDR_MAX or isset($_POST['other_deliv_id'])){
+                        if(strlen($_POST['other_deliv_id'] != 0)){
+                            $deliv_count = $objQuery->count("dtb_other_deliv","customer_id=? and other_deliv_id = ?" ,array($objCustomer->getValue('customer_id'), $_POST['other_deliv_id']));
+                            if ($deliv_count == 0) {
+                                SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+                            }else{
+                                $this->lfRegistData($_POST,$arrRegistColumn, $objCustomer);                                
+                            }
+                        }else{
+                            $this->lfRegistData($_POST,$arrRegistColumn, $objCustomer);                            
+                        }
+                    }
+                        if( $_POST['ParentPage'] == MYPAGE_DELIVADDR_URL || $_POST['ParentPage'] == URL_DELIV_TOP ){
+                            $this->tpl_onload = "fnUpdateParent('". $this->getLocation($_POST['ParentPage']) ."'); window.close();";
+                        }else{
+                            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+                        }
+                }
+                break;
+        }
+
+        $objView->assignobj($this);
+        $objView->display($this->tpl_mainpage);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* エラーチェック */
+    function lfErrorCheck() {
+        $objErr = new SC_CheckError();
+
+        $objErr->doFunc(array("お名前（姓）", 'name01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("お名前（名）", 'name02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("フリガナ（姓）", 'kana01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array("フリガナ（名）", 'kana02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array("郵便番号1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
+        $objErr->doFunc(array("都道府県", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
+        $objErr->doFunc(array("ご住所（1）", "addr01", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("ご住所（2）", "addr02", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("お電話番号1", 'tel01'), array("EXIST_CHECK","NUM_CHECK"));
+        $objErr->doFunc(array("お電話番号2", 'tel02'), array("EXIST_CHECK","NUM_CHECK"));
+        $objErr->doFunc(array("お電話番号3", 'tel03'), array("EXIST_CHECK","NUM_CHECK"));
+        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03", TEL_LEN) ,array("TEL_CHECK"));
+        return $objErr->arrErr;
+
+    }
+
+    /* 登録実行 */
+    function lfRegistData($array, $arrRegistColumn, &$objCustomer) {
+        $objConn = new SC_DBConn();
+        foreach ($arrRegistColumn as $data) {
+            if (strlen($array[ $data["column"] ]) > 0) {
+                $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
+            }
+        }
+
+        $arrRegist['customer_id'] = $objCustomer->getvalue('customer_id');
+
+        //-- 編集登録実行
+        $objConn->query("BEGIN");
+        if ($array['other_deliv_id'] != ""){
+            $objConn->autoExecute("dtb_other_deliv", $arrRegist,
+                                  "other_deliv_id = "
+                                  . SC_Utils_Ex::sfQuoteSmart($array["other_deliv_id"]));
+        }else{
+            $objConn->autoExecute("dtb_other_deliv", $arrRegist);
+        }
+        $objConn->query("COMMIT");
+    }
+
+    //----　取得文字列の変換
+    function lfConvertParam($array, $arrRegistColumn) {
+        /*
+         *	文字列の変換
+         *	K :  「半角(ﾊﾝｶｸ)片仮名」を「全角片仮名」に変換
+         *	C :  「全角ひら仮名」を「全角かた仮名」に変換
+         *	V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
+         *	n :  「全角」数字を「半角(ﾊﾝｶｸ)」に変換
+         *  a :  全角英数字を半角英数字に変換する
+         */
+        // カラム名とコンバート情報
+        foreach ($arrRegistColumn as $data) {
+            $arrConvList[ $data["column"] ] = $data["convert"];
+        }
+
+        // 文字変換
+        foreach ($arrConvList as $key => $val) {
+            // POSTされてきた値のみ変換する。
+            if(strlen(($array[$key])) > 0) {
+                $array[$key] = mb_convert_kana($array[$key] ,$val);
+            }
+        }
+        return $array;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/mypage/LC_Page_Mypage_History.php
===================================================================
--- branches/version-2/data/class/pages/mypage/LC_Page_Mypage_History.php	(revision 18176)
+++ branches/version-2/data/class/pages/mypage/LC_Page_Mypage_History.php	(revision 18176)
@@ -0,0 +1,215 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 購入履歴 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Mypage_History extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = TEMPLATE_DIR . 'mypage/history.tpl';
+        $this->tpl_title = "MYページ/購入履歴詳細";
+        $this->tpl_navi = TEMPLATE_DIR . 'mypage/navi.tpl';
+        $this->tpl_column_num = 1;
+        $this->tpl_mainno = 'mypage';
+        $this->tpl_mypageno = 'index';
+        $this->allowClientCache();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_SiteView();
+        $objQuery = new SC_Query();
+        $objCustomer = new SC_Customer();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // レイアウトデザインを取得
+        $objLayout = new SC_Helper_PageLayout_Ex();
+        $objLayout->sfGetPageLayout($this, false, "mypage/index.php");
+
+        //不正アクセス判定
+        $from = "dtb_order";
+        $where = "del_flg = 0 AND customer_id = ? AND order_id = ? ";
+        $arrval = array($objCustomer->getValue('customer_id'), $_POST['order_id']);
+        //DBに情報があるか判定
+        $cnt = $objQuery->count($from, $where, $arrval);
+        //ログインしていない、またはDBに情報が無い場合
+        if (!$objCustomer->isLoginSuccess() || $cnt == 0){
+            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+        } else {
+            //受注詳細データの取得
+            $this->arrDisp = $this->lfGetOrderData($_POST['order_id']);
+            // 支払い方法の取得
+            $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
+            // 配送時間の取得
+            $arrRet = $objDb->sfGetDelivTime($this->arrDisp['payment_id']);
+            $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
+
+            //マイページトップ顧客情報表示用
+            $this->CustomerName1 = $objCustomer->getvalue('name01');
+            $this->CustomerName2 = $objCustomer->getvalue('name02');
+            $this->CustomerPoint = $objCustomer->getvalue('point');
+        }
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrPref = $masterData->getMasterData("mtb_pref",
+                                 array("pref_id", "pref_name", "rank"));
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . 'mypage/history.tpl';
+        $this->tpl_title = 'MYページ/購入履歴一覧';
+        $this->allowClientCache();
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        define ("HISTORY_NUM", 5);
+
+        $objView = new SC_MobileView();
+        $objQuery = new SC_Query();
+        $objCustomer = new SC_Customer();
+        $pageNo = isset($_GET['pageno']) ? (int) $_GET['pageno'] : 0; // TODO
+
+        // ログインチェック
+        if(!isset($_SESSION['customer'])) {
+            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
+        }
+
+        $col = "order_id, create_date, payment_id, payment_total";
+        $from = "dtb_order";
+        $where = "del_flg = 0 AND customer_id=?";
+        $arrval = array($objCustomer->getvalue('customer_id'));
+        $order = "order_id DESC";
+
+        $linemax = $objQuery->count($from, $where, $arrval);
+        $this->tpl_linemax = $linemax;
+
+        // 取得範囲の指定(開始行番号、行数のセット)
+        $objQuery->setlimitoffset(HISTORY_NUM, $pageNo);
+        // 表示順序
+        $objQuery->setorder($order);
+
+        //購入履歴の取得
+        $this->arrOrder = $objQuery->select($col, $from, $where, $arrval);
+
+        // next
+        if ($pageNo + HISTORY_NUM < $linemax) {
+            $next = "<a href='history.php?pageno=" . ($pageNo + HISTORY_NUM) . "'>次へ→</a>";
+        } else {
+            $next = "";
+        }
+
+        // previous
+        if ($pageNo - HISTORY_NUM > 0) {
+            $previous = "<a href='history.php?pageno=" . ($pageNo - HISTORY_NUM) . "'>←前へ</a>";
+        } elseif ($pageNo == 0) {
+            $previous = "";
+        } else {
+            $previous = "<a href='history.php?pageno=0'>←前へ</a>";
+        }
+
+        // bar
+        if ($next != '' && $previous != '') {
+            $bar = " | ";
+        } else {
+            $bar = "";
+        }
+
+        $this->tpl_strnavi = $previous . $bar . $next;
+        $objView->assignobj($this);				//$objpage内の全てのテンプレート変数をsmartyに格納
+        $objView->display(SITE_FRAME);				//パスとテンプレート変数の呼び出し、実行
+    }
+
+    //受注詳細データの取得
+    function lfGetOrderData($order_id) {
+        //受注番号が数字であれば
+        if(SC_Utils_Ex::sfIsInt($order_id)) {
+            // DBから受注情報を読み込む
+            $objQuery = new SC_Query();
+            $col = "order_id, create_date, payment_id, subtotal, tax, use_point, add_point, discount, ";
+            $col .= "deliv_fee, charge, payment_total, deliv_name01, deliv_name02, deliv_kana01, deliv_kana02, ";
+            $col .= "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_time_id, deliv_date ";
+            $from = "dtb_order";
+            $where = "order_id = ?";
+            $arrRet = $objQuery->select($col, $from, $where, array($order_id));
+            $arrOrder = $arrRet[0];
+            // 受注詳細データの取得
+            $arrRet = $this->lfGetOrderDetail($order_id);
+            $arrOrderDetail = SC_Utils_Ex::sfSwapArray($arrRet);
+            $arrData = array_merge($arrOrder, $arrOrderDetail);
+        }
+        return $arrData;
+    }
+
+    // 受注詳細データの取得
+    function lfGetOrderDetail($order_id) {
+        $objQuery = new SC_Query();
+        $col = "product_id, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate";
+        $where = "order_id = ?";
+        $objQuery->setorder("classcategory_id1, classcategory_id2");
+        $arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id));
+        return $arrRet;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/mypage/LC_Page_Mypage_HistoryDetail.php
===================================================================
--- branches/version-2/data/class/pages/mypage/LC_Page_Mypage_HistoryDetail.php	(revision 18176)
+++ branches/version-2/data/class/pages/mypage/LC_Page_Mypage_HistoryDetail.php	(revision 18176)
@@ -0,0 +1,148 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 受注履歴 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Mypage_HistoryDetail extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->tpl_mainpage = 'mypage/history_detail.tpl';
+        $this->tpl_title = "MYページ/購入履歴詳細";
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $objView = new SC_MobileView();
+        $objQuery = new SC_Query();
+        $objCustomer = new SC_Customer();
+        $objDb = new SC_Helper_DB_Ex();
+
+
+        //不正アクセス判定
+        $from = "dtb_order";
+        $where = "del_flg = 0 AND customer_id = ? AND order_id = ? ";
+        $arrval = array($objCustomer->getValue('customer_id'), $_POST['order_id']);
+        //DBに情報があるか判定
+        $cnt = $objQuery->count($from, $where, $arrval);
+
+        //ログインしていない、またはDBに情報が無い場合
+        if (!$objCustomer->isLoginSuccess(true) or $cnt == 0){
+            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
+        } else {
+            //受注詳細データの取得
+            $this->arrDisp = $this->lfGetOrderData($_POST['order_id']);
+            // 支払い方法の取得
+            $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
+            // 配送時間の取得
+            $arrRet = $objDb->sfGetDelivTime($this->arrDisp['payment_id']);
+            $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
+
+            //マイページトップ顧客情報表示用
+            $this->CustomerName1 = $objCustomer->getvalue('name01');
+            $this->CustomerName2 = $objCustomer->getvalue('name02');
+            $this->CustomerPoint = $objCustomer->getvalue('point');
+        }
+
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+
+    //受注詳細データの取得
+    function lfGetOrderData($order_id) {
+        //受注番号が数字であれば
+        if(SC_Utils_Ex::sfIsInt($order_id)) {
+            // DBから受注情報を読み込む
+            $objQuery = new SC_Query();
+            $col = "order_id, create_date, payment_id, subtotal, tax, use_point, add_point, discount, ";
+            $col .= "deliv_fee, charge, payment_total, deliv_name01, deliv_name02, deliv_kana01, deliv_kana02, ";
+            $col .= "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_time_id, deliv_date ";
+            $from = "dtb_order";
+            $where = "order_id = ?";
+            $arrRet = $objQuery->select($col, $from, $where, array($order_id));
+            $arrOrder = $arrRet[0];
+            // 受注詳細データの取得
+            $arrRet = $this->lfGetOrderDetail($order_id);
+            $arrOrderDetail = SC_Utils_Ex::sfSwapArray($arrRet);
+            $arrData = array_merge($arrOrder, $arrOrderDetail);
+        }
+        return $arrData;
+    }
+
+    // 受注詳細データの取得
+    function lfGetOrderDetail($order_id) {
+        $objQuery = new SC_Query();
+        $col = "product_id, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate";
+        $where = "order_id = ?";
+        $objQuery->setorder("classcategory_id1, classcategory_id2");
+        $arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id));
+        return $arrRet;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/mypage/LC_Page_Mypage_Change.php
===================================================================
--- branches/version-2/data/class/pages/mypage/LC_Page_Mypage_Change.php	(revision 18176)
+++ branches/version-2/data/class/pages/mypage/LC_Page_Mypage_Change.php	(revision 18176)
@@ -0,0 +1,858 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+if (file_exists(MODULE_PATH . "mdl_gmopg/inc/function.php")) {
+    require_once(MODULE_PATH . "mdl_gmopg/inc/function.php");
+}
+
+/**
+ * 登録内容変更 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Mypage_Change extends LC_Page {
+
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = TEMPLATE_DIR . 'mypage/change.tpl';
+        $this->tpl_title = 'MYページ/会員登録内容変更(入力ページ)';
+        $this->tpl_navi = TEMPLATE_DIR . 'mypage/navi.tpl';
+        $this->tpl_mainno = 'mypage';
+        $this->tpl_mypageno = 'change';
+        $this->tpl_column_num = 1;
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
+        $this->arrPref = $masterData->getMasterData("mtb_pref",
+                                 array("pref_id", "pref_name", "rank"));
+        $this->arrJob = $masterData->getMasterData("mtb_job");
+        $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
+        $this->arrSex = $masterData->getMasterData("mtb_sex");
+        $this->allowClientCache();
+
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_SiteView();
+        $this->objQuery = new SC_Query();
+        $this->objCustomer = new SC_Customer();
+        $this->objFormParam = new SC_FormParam();
+
+        // レイアウトデザインを取得
+        $objLayout = new SC_Helper_PageLayout_Ex();
+        $objLayout->sfGetPageLayout($this, false, "mypage/index.php");
+
+        //日付プルダウン設定
+        $objDate = new SC_Date(1901);
+        $this->arrYear = $objDate->getYear();
+        $this->arrMonth = $objDate->getMonth();
+        $this->arrDay = $objDate->getDay();
+
+        // ログインチェック
+        if (!$this->objCustomer->isLoginSuccess()){
+            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+        }else {
+            //マイページトップ顧客情報表示用
+            $this->CustomerName1 = $this->objCustomer->getvalue('name01');
+            $this->CustomerName2 = $this->objCustomer->getvalue('name02');
+            $this->CustomerPoint = $this->objCustomer->getvalue('point');
+        }
+
+        //---- 登録用カラム配列
+        $arrRegistColumn = array(
+                                 array(  "column" => "name01",      "convert" => "aKV" ),
+                                 array(  "column" => "name02",      "convert" => "aKV" ),
+                                 array(  "column" => "kana01",      "convert" => "CKV" ),
+                                 array(  "column" => "kana02",      "convert" => "CKV" ),
+                                 array(  "column" => "zip01",       "convert" => "n" ),
+                                 array(  "column" => "zip02",       "convert" => "n" ),
+                                 array(  "column" => "pref",        "convert" => "n" ),
+                                 array(  "column" => "addr01",      "convert" => "aKV" ),
+                                 array(  "column" => "addr02",      "convert" => "aKV" ),
+                                 array(  "column" => "email",       "convert" => "a" ),
+                                 array(  "column" => "email_mobile", "convert" => "a" ),
+                                 array(  "column" => "tel01",       "convert" => "n" ),
+                                 array(  "column" => "tel02",       "convert" => "n" ),
+                                 array(  "column" => "tel03",       "convert" => "n" ),
+                                 array(  "column" => "fax01",       "convert" => "n" ),
+                                 array(  "column" => "fax02",       "convert" => "n" ),
+                                 array(  "column" => "fax03",       "convert" => "n" ),
+                                 array(  "column" => "sex",         "convert" => "n" ),
+                                 array(  "column" => "job",         "convert" => "n" ),
+                                 array(  "column" => "birth",       "convert" => "n" ),
+                                 array(  "column" => "password",    "convert" => "an" ),
+                                 array(  "column" => "reminder",    "convert" => "n" ),
+                                 array(  "column" => "reminder_answer", "convert" => "aKV" ),
+                                 array(  "column" => "mailmaga_flg", "convert" => "n" )
+                                 );
+
+        //メールアドレス種別
+        $arrMailType = array("email" => true, "email_mobile" => true);
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        switch ($_POST['mode']){
+
+        case 'confirm':
+
+            //エラーなしでかつメールアドレスが重複していない場合
+            if ($this->checkErrorTotal($arrRegistColumn, $arrMailType)) {
+
+                //確認ページへ
+                $this->tpl_mainpage = TEMPLATE_DIR . 'mypage/change_confirm.tpl';
+                $this->tpl_title = 'MYページ/会員登録内容変更(確認ページ)';
+                $passlen = strlen($this->arrForm['password']);
+                $this->passlen = $this->lfPassLen($passlen);
+            } else {
+                $this->lfFormReturn($this->arrForm,$this);
+            }
+
+            break;
+
+        case 'return':
+            $this->arrForm = $_POST;
+            $this->lfFormReturn($this->arrForm,$this);
+            break;
+
+        case 'gmo_oneclick':
+            sfGMOMypageEdit();
+            $this->arrForm = $this->lfGetCustomerData();
+            $this->arrForm['password'] = DEFAULT_PASSWORD;
+            $this->arrForm['password02'] = DEFAULT_PASSWORD;
+            break;
+        case 'complete':
+            //エラーなしでかつメールアドレスが重複していない場合
+            if ($this->checkErrorTotal($arrRegistColumn, $arrMailType)) {
+                $this->arrForm['customer_id'] = $this->objCustomer->getValue('customer_id');
+                //-- 編集登録
+                $objDb = new SC_Helper_DB_Ex();
+                $objDb->sfEditCustomerData($this->arrForm, $arrRegistColumn);
+                //セッション情報を最新の状態に更新する
+                $this->objCustomer->updateSession();
+
+                // Do楽SNS連携モジュールユーザ情報更新処理
+                if (function_exists('sfUpdateSourakuSNSUserInfo')) {
+                    sfUpdateSourakuSNSUserInfo();
+                }
+
+                //完了ページへ
+                $this->sendRedirect($this->getLocation("./change_complete.php"));
+                exit;
+            } else {
+                SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+            }
+            break;
+
+        default:
+            //顧客情報取得
+            $this->arrForm = $this->lfGetCustomerData();
+            $this->arrForm['password'] = DEFAULT_PASSWORD;
+            $this->arrForm['password02'] = DEFAULT_PASSWORD;
+            break;
+        }
+
+        //誕生日データ登録の有無
+        $arrCustomer = $this->lfGetCustomerData();
+        if ($arrCustomer['birth'] != ""){
+            $this->birth_check = true;
+        }
+
+        $objView->assignobj($this);             //$objpage内の全てのテンプレート変数をsmartyに格納
+        $objView->display(SITE_FRAME);              //パスとテンプレート変数の呼び出し、実行
+
+
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->tpl_mainpage = 'mypage/change.tpl';		// メインテンプレート
+        $this->tpl_title .= '登録変更(1/3)';			// ページタイトル
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
+        $this->arrPref = $masterData->getMasterData("mtb_pref",
+                                 array("pref_id", "pref_name", "rank"));
+        $this->arrJob = $masterData->getMasterData("mtb_job");
+        $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
+        $this->arrSex = $masterData->getMasterData("mtb_sex");
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $objDb = new SC_Helper_DB_Ex();
+        $CONF = $objDb->sf_getBasisData();					// 店舗基本情報
+        $objConn = new SC_DbConn();
+        $objView = new SC_MobileView();
+        $this->objDate = new SC_Date(START_BIRTH_YEAR, date("Y",strtotime("now")));
+        $this->arrYear = $this->objDate->getYear();
+        $this->arrMonth = $this->objDate->getMonth();
+        $this->arrDay = $this->objDate->getDay();
+
+        $this->objQuery = new SC_Query();
+        $this->objCustomer = new SC_Customer();
+
+        //メールアドレス種別
+        $arrMailType = array("email" => true, "email_mobile" => true);
+
+        //---- 登録用カラム配列
+        $arrRegistColumn = array(
+                                 array(  "column" => "name01", "convert" => "aKV" ),
+                                 array(  "column" => "name02", "convert" => "aKV" ),
+                                 array(  "column" => "kana01", "convert" => "CKV" ),
+                                 array(  "column" => "kana02", "convert" => "CKV" ),
+                                 array(  "column" => "zip01", "convert" => "n" ),
+                                 array(  "column" => "zip02", "convert" => "n" ),
+                                 array(  "column" => "pref", "convert" => "n" ),
+                                 array(  "column" => "addr01", "convert" => "aKV" ),
+                                 array(  "column" => "addr02", "convert" => "aKV" ),
+                                 array(  "column" => "email", "convert" => "a" ),
+                                 array(  "column" => "email_mobile", "convert" => "a" ),
+                                 array(  "column" => "tel01", "convert" => "n" ),
+                                 array(  "column" => "tel02", "convert" => "n" ),
+                                 array(  "column" => "tel03", "convert" => "n" ),
+                                 array(  "column" => "fax01", "convert" => "n" ),
+                                 array(  "column" => "fax02", "convert" => "n" ),
+                                 array(  "column" => "fax03", "convert" => "n" ),
+                                 array(  "column" => "sex", "convert" => "n" ),
+                                 array(  "column" => "job", "convert" => "n" ),
+                                 array(  "column" => "birth", "convert" => "n" ),
+                                 array(  "column" => "reminder", "convert" => "n" ),
+                                 array(  "column" => "reminder_answer", "convert" => "aKV"),
+                                 array(  "column" => "password", "convert" => "a" ),
+                                 array(  "column" => "mailmaga_flg", "convert" => "n" )
+                                 );
+
+        //---- 登録除外用カラム配列
+        $arrRejectRegistColumn = array("year", "month", "day", "email02", "email_mobile02", "password02");
+
+        $this->arrForm = $this->lfGetCustomerData();
+        $this->arrForm['password'] = DEFAULT_PASSWORD;
+
+        if ($_SERVER["REQUEST_METHOD"] == "POST") {
+
+            //-- POSTデータの引き継ぎ
+            $this->arrForm = array_merge($this->arrForm, $_POST);
+
+            if (!isset($this->arrForm['year'])) $this->arrForm['year'] = "";
+            if($this->arrForm['year'] == '----') {
+                $this->arrForm['year'] = '';
+            }
+
+            // emailはすべて小文字で処理
+            $this->paramToLower($_POST );
+
+            //-- 入力データの変換
+            $this->arrForm = $this->lfConvertParam($this->arrForm, $arrRegistColumn);
+
+            // 戻るボタン用処理
+            if (!empty($_POST["return"])) {
+                switch ($_POST["mode"]) {
+                case "complete":
+                    $_POST["mode"] = "set3";
+                    break;
+                case "confirm":
+                    $_POST["mode"] = "set2";
+                    break;
+                default:
+                    $_POST["mode"] = "set1";
+                    break;
+                }
+            }
+
+            //--　入力エラーチェック
+            if ($_POST["mode"] == "set1") {
+                $this->arrErr = $this->lfErrorCheck1($this->arrForm);
+                $this->tpl_mainpage = 'mypage/change.tpl';
+                $this->tpl_title = '登録変更(1/3)';
+            } elseif ($_POST["mode"] == "set2") {
+                $this->arrErr = $this->lfErrorCheck2($this->arrForm);
+                $this->tpl_mainpage = 'mypage/set1.tpl';
+                $this->tpl_title = '登録変更(2/3)';
+            } else {
+                $this->arrErr = $this->lfErrorCheck3($this->arrForm);
+                $this->tpl_mainpage = 'mypage/set2.tpl';
+                $this->tpl_title = '登録変更(3/3)';
+            }
+
+            if ($this->arrErr || !empty($_POST["return"])) {		// 入力エラーのチェック
+                //-- データの設定
+                if ($_POST["mode"] == "set1") {
+                    $checkVal = array("email", "email_mobile", "password", "reminder", "reminder_answer", "name01", "name02", "kana01", "kana02");
+                } elseif ($_POST["mode"] == "set2") {
+                    $checkVal = array("sex", "year", "month", "day", "zip01", "zip02");
+                } else {
+                    $checkVal = array("pref", "addr01", "addr02", "tel01", "tel02", "tel03", "mailmaga_flg");
+                }
+
+                foreach($this->arrForm as $key => $val) {
+                    if ($key != "return" && $key != "mode" && $key != "confirm" && $key != session_name() && !in_array($key, $checkVal)) {
+                        $this->list_data[ $key ] = $val;
+                    }
+                }
+
+            } else {
+
+                //--　テンプレート設定
+                if ($_POST["mode"] == "set1") {
+                    $this->tpl_mainpage = 'mypage/set1.tpl';
+                    $this->tpl_title = '登録変更(2/3)';
+                } elseif ($_POST["mode"] == "set2") {
+                    $this->tpl_mainpage = 'mypage/set2.tpl';
+                    $this->tpl_title = '登録変更(3/3)';
+                } elseif ($_POST["mode"] == "confirm") {
+                    //パスワード表示
+                    $passlen = strlen($this->arrForm['password']);
+                    $this->passlen = $this->lfPassLen($passlen);
+
+                    // メール受け取り
+                    if (!isset($_POST['mailmaga_flg'])) $_POST['mailmaga_flg'] = "";
+                    if (strtolower($_POST['mailmaga_flg']) == "on") {
+                        $this->arrForm['mailmaga_flg'] = "2";
+                    } else {
+                        $this->arrForm['mailmaga_flg'] = "3";
+                    }
+
+                    $this->tpl_mainpage = 'mypage/change_confirm.tpl';
+                    $this->tpl_title = '登録変更(確認ページ)';
+
+                }
+
+                //-- データ設定
+                unset($this->list_data);
+                if ($_POST["mode"] == "set1") {
+                    $checkVal = array("sex", "year", "month", "day", "zip01", "zip02");
+                } elseif ($_POST["mode"] == "set2") {
+                    $checkVal = array("pref", "addr01", "addr02", "tel01", "tel02", "tel03", "mailmaga_flg");
+                } else {
+                    $checkVal = array();
+                }
+
+                foreach($this->arrForm as $key => $val) {
+                    if ($key != "return" && $key != "mode" && $key != "confirm" && $key != session_name() && !in_array($key, $checkVal)) {
+                        $this->list_data[ $key ] = $val;
+                    }
+                }
+
+
+                //--　仮登録と完了画面
+                if ($_POST["mode"] == "complete") {
+                    //エラーなしでかつメールアドレスが重複していない場合
+                    if($this->checkErrorTotal($arrRegistColumn, $arrMailType, true)) {
+                        $this->arrForm['customer_id'] = $this->objCustomer->getValue('customer_id');
+                        //-- 編集登録
+                        $objDb->sfEditCustomerData($this->arrForm, $arrRegistColumn);
+                        //セッション情報を最新の状態に更新する
+                        $this->objCustomer->updateSession();
+                        //完了ページへ
+                        $this->sendRedirect($this->getLocation("./change_complete.php"), true);
+                        exit;
+                    } else {
+                        SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
+                    }
+                }
+            }
+        }
+
+        $arrPrivateVariables = array('secret_key', 'first_buy_date', 'last_buy_date', 'buy_times', 'buy_total', 'point', 'note', 'status', 'create_date', 'update_date', 'del_flg', 'cell01', 'cell02', 'cell03', 'mobile_phone_id');
+        foreach ($arrPrivateVariables as $key) {
+            unset($this->list_data[$key]);
+        }
+
+        //---- ページ表示
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * すべてのエラーチェックを行う.
+     *
+     * @param array $arrRegistColumn 登録カラムの配列
+     * @param array $arrMailType メール種別とフラグを格納した配列
+     * @param bool $isMobile モバイル版登録チェックの場合 true
+     * @return bool エラーの無い場合 true
+     */
+    function checkErrorTotal(&$arrRegistColumn, &$arrMailType, $isMobile = false) {
+        //-- 入力データの変換
+        $this->arrForm = $_POST;
+        $this->arrForm = $this->lfConvertParam($this->arrForm, $arrRegistColumn);
+
+        // emailはすべて小文字で処理
+        $this->paramToLower($arrRegistColumn);
+
+        //エラーチェック
+        $this->arrErr = $isMobile
+            ? $this->lfErrorCheckMobile($this->arrForm)
+            : $this->lfErrorCheck($this->arrForm);
+
+        //メールアドレスを変更している場合、メールアドレスの重複チェック
+        $arrMailType2 = $arrMailType;
+        foreach ($arrMailType as $mailType => $mailTypeValue) {
+
+            if ($this->arrForm[$mailType]
+                != $this->objCustomer->getValue($mailType)){
+
+                $email_cnt = $this->objQuery->count("dtb_customer",
+                                 "del_flg=0 AND " . $mailType . "= ?",
+                                  array($this->arrForm[$mailType]));
+                if ($email_cnt > 0){
+                    $arrMailType2[$mailTypeValue] = false;
+                    $this->arrErr[$mailType] .= "既に使用されているメールアドレスです。";
+                }
+            }
+        }
+
+        // エラーが存在せず, メールアドレスの重複が無い場合は true
+        if (empty($this->arrErr)
+            && $arrMailType2['email'] == true
+            && $arrMailType2['email_mobile'] == true) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /* パラメータ情報の初期化 */
+    function lfInitParam() {
+        $this->objFormParam->addParam("お名前(姓)", "name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("お名前(名)", "name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("フリガナ(セイ)", "kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("フリガナ(メイ)", "kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("郵便番号1", "zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $this->objFormParam->addParam("郵便番号2", "zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $this->objFormParam->addParam("都道府県", "pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("ご住所1", "addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("ご住所2", "addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("お電話番号1", "tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+        $this->objFormParam->addParam("お電話番号2", "tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+        $this->objFormParam->addParam("お電話番号3", "tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+    }
+
+    //エラーチェック
+
+    function lfErrorCheck($array) {
+        $objErr = new SC_CheckError($array);
+
+        $objErr->doFunc(array("お名前（姓）", 'name01', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("お名前（名）", 'name02', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("フリガナ（セイ）", 'kana01', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array("フリガナ（メイ）", 'kana02', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array("郵便番号1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
+        $objErr->doFunc(array("都道府県", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
+        $objErr->doFunc(array("ご住所1", "addr01", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("ご住所2", "addr02", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array('メールアドレス', "email", MTEXT_LEN) ,array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array('メールアドレス(確認)', "email02", MTEXT_LEN) ,array("EXIST_CHECK", "EMAIL_CHECK","NO_SPTAB" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK"));
+        $objErr->doFunc(array('携帯メールアドレス', "email_mobile", MTEXT_LEN) ,array("EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK", "MOBILE_EMAIL_CHECK"));
+        $objErr->doFunc(array('携帯メールアドレス(確認)', "email_mobile02", MTEXT_LEN), array("EMAIL_CHECK","NO_SPTAB" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK", "MOBILE_EMAIL_CHECK"));
+        $objErr->doFunc(array('携帯メールアドレス', '携帯メールアドレス(確認)', "email_mobile", "email_mobile02") ,array("EQUAL_CHECK"));
+        $objErr->doFunc(array("お電話番号1", 'tel01'), array("EXIST_CHECK","SPTAB_CHECK"));
+        $objErr->doFunc(array("お電話番号2", 'tel02'), array("EXIST_CHECK","SPTAB_CHECK"));
+        $objErr->doFunc(array("お電話番号3", 'tel03'), array("EXIST_CHECK","SPTAB_CHECK"));
+        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03", TEL_LEN) ,array("TEL_CHECK"));
+        $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03", TEL_LEN) ,array("TEL_CHECK"));
+        $objErr->doFunc(array("ご性別", "sex") ,array("SELECT_CHECK", "NUM_CHECK"));
+        $objErr->doFunc(array("ご職業", "job") ,array("NUM_CHECK"));
+        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_DATE"));
+        $objErr->doFunc(array("パスワード", 'password', PASSWORD_LEN1, PASSWORD_LEN2), array("EXIST_CHECK", "ALNUM_CHECK", "NUM_RANGE_CHECK"));
+        $objErr->doFunc(array("パスワード(確認)", 'password02', PASSWORD_LEN1, PASSWORD_LEN2), array("EXIST_CHECK", "ALNUM_CHECK", "NUM_RANGE_CHECK"));
+        $objErr->doFunc(array("パスワード", 'パスワード(確認)', 'password', 'password02'), array("EQUAL_CHECK"));
+        $objErr->doFunc(array("パスワードを忘れたときの質問", "reminder") ,array("SELECT_CHECK", "NUM_CHECK"));
+        $objErr->doFunc(array("パスワードを忘れたときの答え", "reminder_answer", STEXT_LEN) ,array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("メールマガジン", "mailmaga_flg") ,array("SELECT_CHECK", "NUM_CHECK"));
+        return $objErr->arrErr;
+
+    }
+
+    //----　取得文字列の変換
+    function lfConvertParam($array, $arrRegistColumn) {
+        /*
+         *  文字列の変換
+         *  K :  「半角(ﾊﾝｶｸ)片仮名」を「全角片仮名」に変換
+         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
+         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
+         *  n :  「全角」数字を「半角(ﾊﾝｶｸ)」に変換
+         *  a :  全角英数字を半角英数字に変換する
+         */
+        // カラム名とコンバート情報
+        foreach ($arrRegistColumn as $data) {
+            $arrConvList[ $data["column"] ] = $data["convert"];
+        }
+
+        // 文字変換
+        foreach ($arrConvList as $key => $val) {
+            // POSTされてきた値のみ変換する。
+            if (isset($array[$key])) {
+                if(strlen(($array[$key])) > 0) {
+                    $array[$key] = mb_convert_kana($array[$key] ,$val);
+                }
+            }
+        }
+        return $array;
+    }
+
+    //顧客情報の取得
+    function lfGetCustomerData(){
+        //顧客情報取得
+        $ret = $this->objQuery->select("*","dtb_customer","customer_id=?", array($this->objCustomer->getValue('customer_id')));
+        $arrForm = $ret[0];
+
+        //誕生日の年月日取得
+        if (isset($arrForm['birth'])){
+            $birth = split(" ", $arrForm["birth"]);
+            list($year, $month, $day) = split("-",$birth[0]);
+
+            $arrForm['year'] = $year;
+            $arrForm['month'] = $month;
+            $arrForm['day'] = $day;
+
+        }
+        return $arrForm;
+    }
+
+    /**
+     * 編集登録
+     * TODO
+     * @deprecated 未使用?
+     */
+    function lfRegistData($array, $arrRegistColumn) {
+
+        foreach ($arrRegistColumn as $data) {
+            if ($data["column"] != "password") {
+                if($array[ $data['column'] ] == "") {
+                    $arrRegist[ $data['column'] ] = NULL;
+                } else {
+                    $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
+                }
+            }
+        }
+        if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) {
+            $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00";
+        } else {
+            $arrRegist["birth"] = NULL;
+        }
+
+        //-- パスワードの更新がある場合は暗号化。（更新がない場合はUPDATE文を構成しない）
+        if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC);
+        $arrRegist["update_date"] = "NOW()";
+
+        //-- 編集登録実行
+        $this->objQuery->begin();
+        $this->objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($this->objCustomer->getValue('customer_id')));
+        $this->objQuery->commit();
+    }
+
+    //確認ページ用パスワード表示用
+
+    function lfPassLen($passlen){
+        $ret = "";
+        for ($i=0;$i<$passlen;true){
+            $ret.="*";
+            $i++;
+        }
+        return $ret;
+    }
+
+    //エラー、戻る時にフォームに入力情報を返す
+    function lfFormReturn($array, &$objPage){
+        foreach($array as $key => $val){
+            switch ($key){
+            case 'password':
+            case 'password02':
+                $objPage->$key = $val;
+                break;
+            default:
+                $array[ $key ] = $val;
+                break;
+            }
+        }
+    }
+
+
+    // }}}
+    // {{{ mobile functions
+
+    /**
+     * TODO
+     * @deprecated 未使用?
+     */
+    function lfRegistDataMobile ($array, $arrRegistColumn,
+                                 $arrRejectRegistColumn) {
+
+        // 仮登録
+        foreach ($arrRegistColumn as $data) {
+            if (strlen($array[ $data["column"] ]) > 0 && ! in_array($data["column"], $arrRejectRegistColumn)) {
+                $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
+            }
+        }
+
+        // 誕生日が入力されている場合
+        if (strlen($array["year"]) > 0 ) {
+            $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00";
+        }
+
+        // パスワードの暗号化
+        $arrRegist["password"] = sha1($arrRegist["password"] . ":" . AUTH_MAGIC);
+
+        $count = 1;
+        while ($count != 0) {
+            $uniqid = SC_Utils_Ex::sfGetUniqRandomId("t");
+            $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($uniqid));
+        }
+
+        $arrRegist["secret_key"] = $uniqid;		// 仮登録ID発行
+        $arrRegist["create_date"] = "now()"; 	// 作成日
+        $arrRegist["update_date"] = "now()"; 	// 更新日
+        $arrRegist["first_buy_date"] = "";	 	// 最初の購入日
+
+
+        //-- 仮登録実行
+        $this->objQuery->insert("dtb_customer", $arrRegist);
+
+        return $uniqid;
+    }
+
+
+    //エラーチェック
+
+    function lfErrorCheckMobile($array) {
+        $objErr = new SC_CheckError($array);
+
+        $objErr->doFunc(array("お名前（姓）", 'name01', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("お名前（名）", 'name02', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("お名前（カナ/姓）", 'kana01', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array("お名前（カナ/名）", 'kana02', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array("郵便番号1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
+        $objErr->doFunc(array("都道府県", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
+        $objErr->doFunc(array("市区町村", "addr01", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("番地", "addr02", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array('メールアドレス', "email", MTEXT_LEN) ,array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array('携帯メールアドレス', "email_mobile", MTEXT_LEN) ,array("EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK", "MOBILE_EMAIL_CHECK"));
+        $objErr->doFunc(array("電話番号1", 'tel01'), array("EXIST_CHECK","SPTAB_CHECK"));
+        $objErr->doFunc(array("電話番号2", 'tel02'), array("EXIST_CHECK","SPTAB_CHECK"));
+        $objErr->doFunc(array("電話番号3", 'tel03'), array("EXIST_CHECK","SPTAB_CHECK"));
+        $objErr->doFunc(array("電話番号", "tel01", "tel02", "tel03", TEL_LEN) ,array("TEL_CHECK"));
+        $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03", TEL_LEN) ,array("TEL_CHECK"));
+        $objErr->doFunc(array("性別", "sex") ,array("SELECT_CHECK", "NUM_CHECK"));
+        $objErr->doFunc(array("ご職業", "job") ,array("NUM_CHECK"));
+        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_DATE"));
+        $objErr->doFunc(array("パスワード", 'password', PASSWORD_LEN1, PASSWORD_LEN2), array("EXIST_CHECK", "ALNUM_CHECK", "NUM_RANGE_CHECK"));
+        $objErr->doFunc(array("パスワード確認用の質問", "reminder") ,array("SELECT_CHECK", "NUM_CHECK"));
+        $objErr->doFunc(array("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN) ,array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
+        return $objErr->arrErr;
+
+    }
+
+
+    //---- 入力エラーチェック
+    function lfErrorCheck1($array) {
+
+        $objErr = new SC_CheckError($array);
+
+        $objErr->doFunc(array("お名前（姓）", 'name01', STEXT_LEN), array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("お名前（名）", 'name02', STEXT_LEN), array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("お名前（カナ/姓）", 'kana01', STEXT_LEN), array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array("お名前（カナ/名）", 'kana02', STEXT_LEN), array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
+        $objErr->doFunc(array('メールアドレス', "email", MTEXT_LEN) ,array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array('携帯メールアドレス', "email_mobile", MTEXT_LEN) ,array("NO_SPTAB", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK", "MOBILE_EMAIL_CHECK"));
+
+        //現会員の判定 →　現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
+        $array["customer_id"] = $this->objCustomer->getValue('customer_id');
+        if (strlen($array["email"]) > 0) {
+            $arrRet = $this->objQuery->select("email, update_date, del_flg", "dtb_customer","customer_id <> ? and (email = ? OR email_mobile = ?) ORDER BY del_flg", array($array["customer_id"], $array["email"], $array["email"]));
+
+            if(count($arrRet) > 0) {
+                if($arrRet[0]['del_flg'] != '1') {
+                    // 会員である場合
+                    $objErr->arrErr["email"] .= "※ すでに会員登録で使用されているメールアドレスです。<br />";
+                } else {
+                    // 退会した会員である場合
+                    $leave_time = SC_Utils_Ex::sfDBDatetoTime($arrRet[0]['update_date']);
+                    $now_time = time();
+                    $pass_time = $now_time - $leave_time;
+                    // 退会から何時間-経過しているか判定する。
+                    $limit_time = ENTRY_LIMIT_HOUR * 3600;
+                    if($pass_time < $limit_time) {
+                        $objErr->arrErr["email"] .= "※ 退会から一定期間の間は、同じメールアドレスを使用することはできません。<br />";
+                    }
+                }
+            }
+        }
+
+        $objErr->doFunc(array("パスワード", 'password', PASSWORD_LEN1, PASSWORD_LEN2), array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK", "NUM_RANGE_CHECK"));
+        $objErr->doFunc(array("パスワード確認用の質問", "reminder") ,array("SELECT_CHECK", "NUM_CHECK"));
+        $objErr->doFunc(array("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN) ,array("EXIST_CHECK","SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
+
+        return $objErr->arrErr;
+    }
+
+    //---- 入力エラーチェック
+    function lfErrorCheck2($array) {
+
+        $objErr = new SC_CheckError($array);
+
+        $objErr->doFunc(array("郵便番号1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
+
+        $objErr->doFunc(array("性別", "sex") ,array("SELECT_CHECK", "NUM_CHECK"));
+        $objErr->doFunc(array("生年月日 (年)", "year", 4), array("SPTAB_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        if (!empty($array["year"])) {
+            $objErr->doFunc(array("生年月日 (年)", "year", $this->objDate->getStartYear()), array("MIN_CHECK"));
+            $objErr->doFunc(array("生年月日 (年)", "year", $this->objDate->getEndYear()), array("MAX_CHECK"));
+        }
+        if (!isset($objErr->arrErr['year']) && !isset($objErr->arrErr['month']) && !isset($objErr->arrErr['day'])) {
+            $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_DATE"));
+        }
+
+        return $objErr->arrErr;
+    }
+
+    //---- 入力エラーチェック
+    function lfErrorCheck3($array) {
+
+        $objErr = new SC_CheckError($array);
+
+        $objErr->doFunc(array("都道府県", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
+        $objErr->doFunc(array("市区町村", "addr01", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("番地", "addr02", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("電話番号1", 'tel01'), array("EXIST_CHECK","SPTAB_CHECK" ));
+        $objErr->doFunc(array("電話番号2", 'tel02'), array("EXIST_CHECK","SPTAB_CHECK" ));
+        $objErr->doFunc(array("電話番号3", 'tel03'), array("EXIST_CHECK","SPTAB_CHECK" ));
+        $objErr->doFunc(array("電話番号", "tel01", "tel02", "tel03",TEL_ITEM_LEN) ,array("TEL_CHECK"));
+
+        return $objErr->arrErr;
+    }
+
+    // 郵便番号から住所の取得
+    function lfGetAddress($zipcode) {
+        global $arrPref;
+
+        $conn = new SC_DBconn(ZIP_DSN);
+
+        // 郵便番号検索文作成
+        $zipcode = mb_convert_kana($zipcode ,"n");
+        $sqlse = "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?";
+
+        $data_list = $conn->getAll($sqlse, array($zipcode));
+
+        // インデックスと値を反転させる。
+        $arrREV_PREF = array_flip($arrPref);
+
+        /*
+          総務省からダウンロードしたデータをそのままインポートすると
+          以下のような文字列が入っているので	対策する。
+          ・（１・１９丁目）
+          ・以下に掲載がない場合
+        */
+        $town =  $data_list[0]['town'];
+        $town = ereg_replace("（.*）$","",$town);
+        $town = ereg_replace("以下に掲載がない場合","",$town);
+        $data_list[0]['town'] = $town;
+        $data_list[0]['state'] = $arrREV_PREF[$data_list[0]['state']];
+
+        return $data_list;
+    }
+
+    //顧客情報の取得
+    function lfGetCustomerDataMobile(){
+
+        //顧客情報取得
+        $ret = $this->objQuery->select("*","dtb_customer","customer_id=?", array($this->objCustomer->getValue('customer_id')));
+        $arrForm = $ret[0];
+        //$arrForm['email'] = $arrForm['email_mobile'];
+
+        //メルマガフラグ取得
+        // TODO たぶん未使用
+        $arrForm['mailmaga_flg'] = $this->objQuery->get("dtb_customer","mailmaga_flg","email_mobile=?", array($this->objCustomer->getValue('email_mobile')));
+
+        //誕生日の年月日取得
+        if (isset($arrForm['birth'])){
+            $birth = split(" ", $arrForm["birth"]);
+            list($year, $month, $day) = split("-",$birth[0]);
+
+            $arrForm['year'] = $year;
+            $arrForm['month'] = $month;
+            $arrForm['day'] = $day;
+
+        }
+        return $arrForm;
+    }
+
+    /**
+     * フォームパラメータの内容を小文字に変換する.
+     *
+     * @param array $arrParam パラメータ名の配列
+     * @return void
+     */
+    function paramToLower(&$arrParam) {
+        foreach ($arrParam as $key => $val) {
+            if (!isset($val)) {
+                $this->arrForm[$key] = "";
+            }elseif($key == 'email' || $key == 'email_mobile'){
+                $this->arrForm[$key] = strtolower($val);
+            }
+        }
+    }
+}
+?>
Index: branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Complete.php
===================================================================
--- branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Complete.php	(revision 18176)
+++ branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Complete.php	(revision 18176)
@@ -0,0 +1,682 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * ご注文完了 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id:LC_Page_Shopping_Complete.php 15532 2007-08-31 14:39:46Z nanasess $
+ */
+class LC_Page_Shopping_Complete extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'shopping/complete.tpl';
+        $this->tpl_title = "ご注文完了";
+        $this->tpl_column_num = 1;
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrCONVENIENCE = $masterData->getMasterData("mtb_convenience");
+        $this->arrCONVENIMESSAGE = $masterData->getMasterData("mtb_conveni_message");
+
+        $this->allowClientCache();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        global $objCampaignSess;
+
+        $conn = new SC_DBConn();
+        $objView = new SC_SiteView();
+        $this->objSiteSess = new SC_SiteSession();
+        $this->objCartSess = new SC_CartSession();
+        $this->objCampaignSess = new SC_CampaignSession();
+        $objSiteInfo = $objView->objSiteInfo;
+        $this->arrInfo = $objSiteInfo->data;
+        $this->objCustomer = new SC_Customer();
+        $mailHelper = new SC_Helper_Mail_Ex();
+
+        // 前のページで正しく登録手続きが行われたか判定
+        SC_Utils_Ex::sfIsPrePage($this->objSiteSess);
+        // ユーザユニークIDの取得と購入状態の正当性をチェック
+        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($this->objSiteSess, $this->objCartSess);
+        if ($uniqid != "") {
+
+            // 完了処理
+            $objQuery = new SC_Query();
+            $objQuery->begin();
+            $order_id = $this->lfDoComplete($objQuery, $uniqid);
+            $objQuery->commit();
+
+            // セッションに保管されている情報を更新する
+            $this->objCustomer->updateSession();
+
+            // 完了メール送信
+            if($order_id != "") {
+                $mailHelper->sfSendOrderMail($order_id, '1');
+            }
+
+            // その他情報の取得
+            $arrResults = $objQuery->getall("SELECT memo02, memo05 FROM dtb_order WHERE order_id = ? ", array($order_id));
+
+            if (count($arrResults) > 0) {
+                if (isset($arrResults[0]["memo02"]) || isset($arrResults[0]["memo05"])) {
+                    // 完了画面で表示する決済内容
+                    $arrOther = unserialize($arrResults[0]["memo02"]);
+                    // 完了画面から送信する決済内容
+                    $arrModuleParam = unserialize($arrResults[0]["memo05"]);
+
+                    // データを編集
+                    foreach($arrOther as $key => $val){
+                        // URLの場合にはリンクつきで表示させる
+                        if (preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $val["value"])) {
+                            $arrOther[$key]["value"] = "<a href='#' onClick=\"window.open('". $val["value"] . "'); \" >" . $val["value"] ."</a>";
+                        }
+                    }
+
+                    $this->arrOther = $arrOther;
+                    $this->arrModuleParam = $arrModuleParam;
+                }
+            }
+
+            // アフィリエイト用コンバージョンタグの設定
+            $this->tpl_conv_page = AFF_SHOPPING_COMPLETE;
+            $this->tpl_aff_option = "order_id=$order_id";
+            //合計価格の取得
+            $total = $objQuery->get("dtb_order", "total", "order_id = ? ", array($order_id));
+            if($total != "") {
+                $this->tpl_aff_option.= "|total=$total";
+            }
+
+            // TradeSafe連携用
+            if (function_exists('sfTSRequest')) {
+                sfTSRequest($order_id);
+            }
+        }
+
+        // キャンペーンからの遷移かチェック
+        $this->is_campaign = $this->objCampaignSess->getIsCampaign();
+        $this->campaign_dir = $this->objCampaignSess->getCampaignDir();
+
+        $objView->assignobj($this);
+        // フレームを選択(キャンペーンページから遷移なら変更)
+        $this->objCampaignSess->pageView($objView);
+
+        // セッション開放
+        $this->objCampaignSess->delCampaign();
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->init();
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $conn = new SC_DBConn();
+        $objView = new SC_MobileView();
+        $this->objSiteSess = new SC_SiteSession();
+        $this->objCartSess = new SC_CartSession();
+        $objSiteInfo = $objView->objSiteInfo;
+        $this->arrInfo = $objSiteInfo->data;
+        $this->objCustomer = new SC_Customer();
+        $mailHelper = new SC_Helper_Mail_Ex();
+
+        // 前のページで正しく登録手続きが行われたか判定
+        SC_Utils_Ex::sfIsPrePage($this->objSiteSess, true);
+        // ユーザユニークIDの取得と購入状態の正当性をチェック
+        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($this->objSiteSess, $this->objCartSess);
+        if ($uniqid != "") {
+
+            // 完了処理
+            $objQuery = new SC_Query();
+            $objQuery->begin();
+            $order_id = $this->lfDoComplete($objQuery, $uniqid);
+            $objQuery->commit();
+
+            // セッションに保管されている情報を更新する
+            $this->objCustomer->updateSession();
+
+            // 完了メール送信
+            if($order_id != "") {
+                $mailHelper->sfSendOrderMail($order_id, '2');
+            }
+
+            //その他情報の取得
+            $other_data = $objQuery->get("dtb_order", "memo02", "order_id = ? ", array($order_id));
+            if($other_data != "") {
+                $arrOther = unserialize($other_data);
+
+                // データを編集
+                foreach($arrOther as $key => $val){
+                    // URLの場合にはリンクつきで表示させる
+                    if (preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $val["value"])) {
+                        $arrOther[$key]["value"] = "<a href='". $val["value"]. "'>". $val["value"]. "</a>";
+                    }
+                }
+
+                $this->arrOther = $arrOther;
+
+            }
+
+            // アフィリエイト用コンバージョンタグの設定
+            $this->tpl_conv_page = AFF_SHOPPING_COMPLETE;
+            $this->tpl_aff_option = "order_id=$order_id";
+            //合計価格の取得
+            $total = $objQuery->get("dtb_order", "total", "order_id = ? ", array($order_id));
+            if($total != "") {
+                $this->tpl_aff_option.= "|total=$total";
+            }
+
+            // TS連携モジュールの実行
+            if (function_exists('sfTSRequest')) {
+                sfTSRequest($order_id);
+            }
+        }
+
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+
+    // エビスタグ引渡し用データを生成する
+    function lfGetEbisData($order_id) {
+        $objQuery = new SC_Query();
+        $col = "customer_id, total, order_sex, order_job, to_number(to_char(age(current_timestamp, order_birth), 'YYY'), 999) AS order_age";
+        $arrRet = $objQuery->select($col, "dtb_order", "order_id = ?", array($order_id));
+
+        if($arrRet[0]['customer_id'] > 0) {
+            // 会員番号
+            $arrEbis['m1id'] = $arrRet[0]['customer_id'];
+            // 非会員or会員
+            $arrEbis['o5id'] = '1';
+        } else {
+            // 会員番号
+            $arrEbis['m1id'] = '';
+            // 非会員or会員
+            $arrEbis['o5id'] = '2';
+        }
+
+        // 購入金額
+        $arrEbis['a1id'] = $arrRet[0]['total'];
+        // 性別
+        $arrEbis['o2id'] = $arrRet[0]['order_sex'];
+        // 年齢
+        $arrEbis['o3id'] = $arrRet[0]['order_age'];
+        // 職業
+        $arrEbis['o4id'] = $arrRet[0]['order_job'];
+
+        $objQuery->setgroupby("product_id");
+        $arrRet = $objQuery->select("product_id", "dtb_order_detail", "order_id = ?", array($order_id));
+        $arrProducts = sfSwapArray($arrRet);
+
+        $line = "";
+        // 商品IDをアンダーバーで接続する。
+        foreach($arrProducts['product_id'] as $val) {
+            if($line != "") {
+                $line .= "_$val";
+            } else {
+                $line .= "$val";
+            }
+        }
+
+        // 商品ID
+        $arrEbis['o1id'] = $line;
+
+        return $arrEbis;
+    }
+
+    /**
+     * 購入完了処理
+     *
+     * @param object $objQuery
+     * @param string $uniqid
+     * @return string $order_id
+     */
+    function lfDoComplete(&$objQuery, $uniqid) {
+        $objDb = new SC_Helper_DB_Ex();
+
+        // 一時受注テーブルの読込
+        $arrData = $objDb->sfGetOrderTemp($uniqid);
+
+        // 会員情報登録処理
+        if ($this->objCustomer->isLoginSuccess(true)) {
+            // 新お届け先の登録
+            $this->lfSetNewAddr($uniqid, $this->objCustomer->getValue('customer_id'));
+            // 購入集計を顧客テーブルに反映
+            $this->lfSetCustomerPurchase($this->objCustomer->getValue('customer_id'), $arrData, $objQuery);
+        } else {
+            //購入時強制会員登録
+            switch(PURCHASE_CUSTOMER_REGIST) {
+            //無効
+            case '0':
+                // 購入時会員登録
+                if(isset($arrData['member_check']) && $arrData['member_check'] == '1') {
+                    // 仮会員登録
+                    $customer_id = $this->lfRegistPreCustomer($arrData, $this->arrInfo);
+                    // 購入集計を顧客テーブルに反映
+                    $this->lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
+                }
+                break;
+            //有効
+            case '1':
+                // 仮会員登録
+                $customer_id = $this->lfRegistPreCustomer($arrData, $this->arrInfo);
+                // 購入集計を顧客テーブルに反映
+                $this->lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
+                break;
+            }
+
+        }
+        // 一時テーブルを受注テーブルに格納する
+        if (defined("MOBILE_SITE")) {
+            $order_id = $this->lfRegistOrder($objQuery, $arrData);
+        } else {
+            $order_id = $this->lfRegistOrder($objQuery, $arrData, $this->objCampaignSess);
+        }
+        // カート商品を受注詳細テーブルに格納する
+        $this->lfRegistOrderDetail($objQuery, $order_id, $this->objCartSess);
+        // 受注一時テーブルの情報を削除する。
+        $this->lfDeleteTempOrder($objQuery, $uniqid);
+        // キャンペーンからの遷移の場合登録する。
+        if (!defined("MOBILE_SITE")) {
+            if($this->objCampaignSess->getIsCampaign() and $this->objCartSess->chkCampaign($this->objCampaignSess->getCampaignId())) {
+                $this->lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id);
+            }
+        }
+
+        // セッションカート内の商品を削除する。
+        $this->objCartSess->delAllProducts();
+        // 注文一時IDを解除する。
+        $this->objSiteSess->unsetUniqId();
+
+        return $order_id;
+    }
+
+    // 会員登録（仮登録）
+    function lfRegistPreCustomer($arrData, $arrInfo) {
+        // 購入時の会員登録
+        $sqlval['name01'] = $arrData['order_name01'];
+        $sqlval['name02'] = $arrData['order_name02'];
+        $sqlval['kana01'] = $arrData['order_kana01'];
+        $sqlval['kana02'] = $arrData['order_kana02'];
+        $sqlval['zip01'] = $arrData['order_zip01'];
+        $sqlval['zip02'] = $arrData['order_zip02'];
+        $sqlval['pref'] = $arrData['order_pref'];
+        $sqlval['addr01'] = $arrData['order_addr01'];
+        $sqlval['addr02'] = $arrData['order_addr02'];
+        $sqlval['email'] = $arrData['order_email'];
+        $sqlval['tel01'] = $arrData['order_tel01'];
+        $sqlval['tel02'] = $arrData['order_tel02'];
+        $sqlval['tel03'] = $arrData['order_tel03'];
+        $sqlval['fax01'] = $arrData['order_fax01'];
+        $sqlval['fax02'] = $arrData['order_fax02'];
+        $sqlval['fax03'] = $arrData['order_fax03'];
+        $sqlval['sex'] = $arrData['order_sex'];
+        $sqlval['password'] = $arrData['password'];
+        $sqlval['reminder'] = $arrData['reminder'];
+        $sqlval['reminder_answer'] = $arrData['reminder_answer'];
+
+        // メルマガ配信用フラグの判定
+        switch($arrData['mail_flag']) {
+        case '1':	// HTMLメール
+            $mail_flag = 4;
+            break;
+        case '2':	// TEXTメール
+            $mail_flag = 5;
+            break;
+        case '3':	// 希望なし
+            $mail_flag = 6;
+            break;
+        default:
+            $mail_flag = 6;
+            break;
+        }
+        // メルマガフラグ
+        $sqlval['mailmaga_flg'] = $mail_flag;
+
+        // 会員仮登録
+        $sqlval['status'] = 1;
+        // URL判定用キー
+        $sqlval['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId("t");
+
+        $objQuery = new SC_Query();
+        $sqlval['create_date'] = "now()";
+        $sqlval['update_date'] = "now()";
+        $objQuery->insert("dtb_customer", $sqlval);
+
+        // 顧客IDの取得
+        $arrRet = $objQuery->select("customer_id", "dtb_customer", "secret_key = ?", array($sqlval['secret_key']));
+        $customer_id = $arrRet[0]['customer_id'];
+
+        //　仮登録完了メール送信
+        $objMailPage = $this;
+        $objMailPage->to_name01 = $arrData['order_name01'];
+        $objMailPage->to_name02 = $arrData['order_name02'];
+        $objMailPage->CONF = $arrInfo;
+        $objMailPage->uniqid = $sqlval['secret_key'];
+        $objMailView = new SC_SiteView();
+        $objMailView->assignobj($objMailPage);
+        $body = $objMailView->fetch("mail_templates/customer_mail.tpl");
+
+        $mailHelper = new SC_Helper_Mail_Ex();
+
+        $objMail = new SC_SendMail();
+        $objMail->setItem(
+                            ''										//　宛先
+                            , $mailHelper->sfMakeSubject($objQuery,$objMailView,$objMailPage,"会員登録のご確認")		//　サブジェクト
+                            , $body									//　本文
+                            , $arrInfo['email03']					//　配送元アドレス
+                            , $arrInfo['shop_name']					//　配送元　名前
+                            , $arrInfo["email03"]					//　reply_to
+                            , $arrInfo["email04"]					//　return_path
+                            , $arrInfo["email04"]					//  Errors_to
+                            , $arrInfo["email01"]					//  Bcc
+                                                            );
+        // 宛先の設定
+        $name = $arrData['order_name01'] . $arrData['order_name02'] ." 様";
+        $objMail->setTo($arrData['order_email'], $name);
+        $objMail->sendMail();
+
+        return $customer_id;
+    }
+
+    // 受注テーブルへ登録
+    function lfRegistOrder($objQuery, $arrData, $objCampaignSess = null) {
+        $sqlval = $arrData;
+
+        // 受注テーブルに書き込まない列を除去
+        unset($sqlval['mailmaga_flg']);		// メルマガチェック
+        unset($sqlval['deliv_check']);		// 別のお届け先チェック
+        unset($sqlval['point_check']);		// ポイント利用チェック
+        unset($sqlval['member_check']);		// 購入時会員チェック
+        unset($sqlval['password']);			// ログインパスワード
+        unset($sqlval['reminder']);			// リマインダー質問
+        unset($sqlval['reminder_answer']);	// リマインダー答え
+        unset($sqlval['mail_flag']);		// メールフラグ
+        unset($sqlval['session']);		    // セッション情報
+
+        // 注文ステータス:指定が無ければ新規受付に設定
+        if($sqlval["status"] == ""){
+            $sqlval['status'] = '1';
+        }
+
+        // 別のお届け先を指定していない場合、配送先に登録住所をコピーする。
+        if($arrData["deliv_check"] == "-1") {
+            $sqlval['deliv_name01'] = $arrData['order_name01'];
+            $sqlval['deliv_name02'] = $arrData['order_name02'];
+            $sqlval['deliv_kana01'] = $arrData['order_kana01'];
+            $sqlval['deliv_kana02'] = $arrData['order_kana02'];
+            $sqlval['deliv_pref'] = $arrData['order_pref'];
+            $sqlval['deliv_zip01'] = $arrData['order_zip01'];
+            $sqlval['deliv_zip02'] = $arrData['order_zip02'];
+            $sqlval['deliv_addr01'] = $arrData['order_addr01'];
+            $sqlval['deliv_addr02'] = $arrData['order_addr02'];
+            $sqlval['deliv_tel01'] = $arrData['order_tel01'];
+            $sqlval['deliv_tel02'] = $arrData['order_tel02'];
+            $sqlval['deliv_tel03'] = $arrData['order_tel03'];
+        }
+
+        $order_id = $arrData['order_id'];		// オーダーID
+        $sqlval['create_date'] = 'now()';		// 受注日
+
+        // キャンペーンID
+        if (!defined("MOBILE_SITE")) {
+            if($objCampaignSess->getIsCampaign()) $sqlval['campaign_id'] = $objCampaignSess->getCampaignId();
+        }
+
+        // ゲットの値をインサート
+        //$sqlval = lfGetInsParam($sqlval);
+
+        // INSERTの実行
+        $objQuery->insert("dtb_order", $sqlval);
+
+        return $order_id;
+    }
+
+    // 受注詳細テーブルへ登録
+    function lfRegistOrderDetail(&$objQuery, $order_id, &$objCartSess) {
+        $objDb = new SC_Helper_DB_Ex();
+        // カート内情報の取得
+        $arrCart = $objCartSess->getCartList();
+        $max = count($arrCart);
+
+        // 既に存在する詳細レコードを消しておく。
+        $objQuery->delete("dtb_order_detail", "order_id = $order_id");
+
+        // 規格名一覧
+        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
+        // 規格分類名一覧
+        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+
+        for ($i = 0; $i < $max; $i++) {
+            // 商品規格情報の取得
+            $arrData = $objDb->sfGetProductsClass($arrCart[$i]['id']);
+
+            // 存在する商品のみ表示する。
+            if($arrData != "") {
+                $sqlval['order_id'] = $order_id;
+                $sqlval['product_id'] = $arrCart[$i]['id'][0];
+                $sqlval['classcategory_id1'] = $arrCart[$i]['id'][1];
+                $sqlval['classcategory_id2'] = $arrCart[$i]['id'][2];
+                $sqlval['product_name'] = $arrData['name'];
+                $sqlval['product_code'] = $arrData['product_code'];
+                $sqlval['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
+                $sqlval['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
+                $sqlval['point_rate'] = $arrCart[$i]['point_rate'];
+                $sqlval['price'] = $arrCart[$i]['price'];
+                $sqlval['quantity'] = $arrCart[$i]['quantity'];
+                $this->lfReduceStock($objQuery, $arrCart[$i]['id'], $arrCart[$i]['quantity']);
+                // INSERTの実行
+                $objQuery->insert("dtb_order_detail", $sqlval);
+            } else {
+                if (defined("MOBILE_SITE")) {
+                    SC_Utils_Ex::sfDispSiteError(CART_NOT_FOUND, "", false, "", true);
+                } else {
+                    SC_Utils_Ex::sfDispSiteError(CART_NOT_FOUND);
+                }
+            }
+        }
+    }
+
+    // キャンペーン受注テーブルへ登録
+    function lfRegistCampaignOrder(&$objQuery, &$objCampaignSess, $order_id) {
+
+        // 受注データを取得
+        $cols = "order_id, campaign_id, customer_id, message, order_name01, order_name02,".
+                "order_kana01, order_kana02, order_email, order_tel01, order_tel02, order_tel03,".
+                "order_fax01, order_fax02, order_fax03, order_zip01, order_zip02, order_pref, order_addr01,".
+                "order_addr02, order_sex, order_birth, order_job, deliv_name01, deliv_name02, deliv_kana01,".
+                "deliv_kana02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_fax01, deliv_fax02, deliv_fax03,".
+                "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, payment_total";
+
+        $arrOrder = $objQuery->select($cols, "dtb_order", "order_id = ?", array($order_id));
+
+        $sqlval = $arrOrder[0];
+        $sqlval['create_date'] = 'now()';
+
+        // INSERTの実行
+        $objQuery->insert("dtb_campaign_order", $sqlval);
+
+        // 申し込み数の更新
+        $total_count = $objQuery->get("dtb_campaign", "total_count", "campaign_id = ?", array($sqlval['campaign_id']));
+        $arrCampaign['total_count'] = $total_count += 1;
+        $objQuery->update("dtb_campaign", $arrCampaign, "campaign_id = ?", array($sqlval['campaign_id']));
+
+    }
+
+
+
+    /* 受注一時テーブルの削除 */
+    function lfDeleteTempOrder(&$objQuery, $uniqid) {
+        $where = "order_temp_id = ?";
+        $sqlval['del_flg'] = 1;
+        $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
+        // $objQuery->delete("dtb_order_temp", $where, array($uniqid));
+    }
+
+    // 受注一時テーブルの住所が登録済みテーブルと異なる場合は、別のお届け先に追加する
+    function lfSetNewAddr($uniqid, $customer_id) {
+        $objQuery = new SC_Query();
+        $diff = false;
+        $find_same = false;
+
+        $col = "deliv_name01,deliv_name02,deliv_kana01,deliv_kana02,deliv_tel01,deliv_tel02,deliv_tel03,deliv_zip01,deliv_zip02,deliv_pref,deliv_addr01,deliv_addr02";
+        $where = "order_temp_id = ?";
+        $arrRet = $objQuery->select($col, "dtb_order_temp", $where, array($uniqid));
+
+        // 要素名のdeliv_を削除する。
+        foreach($arrRet[0] as $key => $val) {
+            $keyname = ereg_replace("^deliv_", "", $key);
+            $arrNew[$keyname] = $val;
+        }
+
+        // 会員情報テーブルとの比較
+        $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
+        $where = "customer_id = ?";
+        $arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
+
+        // 会員情報の住所と異なる場合
+        if($arrNew != $arrCustomerAddr[0]) {
+            // 別のお届け先テーブルの住所と比較する
+            $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
+            $where = "customer_id = ?";
+            $arrOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($customer_id));
+
+            foreach($arrOtherAddr as $arrval) {
+                if($arrNew == $arrval) {
+                    // すでに同じ住所が登録されている
+                    $find_same = true;
+                }
+            }
+
+            if(!$find_same) {
+                $diff = true;
+            }
+        }
+
+        // 新しいお届け先が登録済みのものと異なる場合は別のお届け先テーブルに登録する
+        if($diff) {
+            $sqlval = $arrNew;
+            $sqlval['customer_id'] = $customer_id;
+            $objQuery->insert("dtb_other_deliv", $sqlval);
+        }
+    }
+
+    /* 購入情報を会員テーブルに登録する */
+    function lfSetCustomerPurchase($customer_id, $arrData, &$objQuery) {
+        $col = "first_buy_date, last_buy_date, buy_times, buy_total, point";
+        $where = "customer_id = ?";
+        $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
+        $sqlval = $arrRet[0];
+
+        if($sqlval['first_buy_date'] == "") {
+            $sqlval['first_buy_date'] = "Now()";
+        }
+        $sqlval['last_buy_date'] = "Now()";
+        $sqlval['buy_times']++;
+        $sqlval['buy_total']+= $arrData['total'];
+        if (USE_POINT === false) {
+            $sqlval['point'] = $sqlval['point'];
+        } else {
+            //$sqlval['point'] = ($sqlval['point'] - $arrData['use_point']);
+            $sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
+        }
+
+        // ポイントが不足している場合
+        if($sqlval['point'] < 0) {
+            $objQuery->rollback();
+            SC_Utils_Ex::sfDispSiteError(LACK_POINT);
+        }
+
+        $objQuery->update("dtb_customer", $sqlval, $where, array($customer_id));
+    }
+
+    // 在庫を減らす処理
+    function lfReduceStock(&$objQuery, $arrID, $quantity) {
+        $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
+        $arrRet = $objQuery->select("stock, stock_unlimited", "dtb_products_class", $where, $arrID);
+
+        // 売り切れエラー
+        if(($arrRet[0]['stock_unlimited'] != '1' && $arrRet[0]['stock'] < $quantity) || $quantity == 0) {
+            $objQuery->rollback();
+            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, "", true);
+        // 無制限の場合、在庫はNULL
+        } elseif($arrRet[0]['stock_unlimited'] == '1') {
+            $sqlval['stock'] = null;
+            $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
+        // 在庫を減らす
+        } else {
+            $sqlval['stock'] = ($arrRet[0]['stock'] - $quantity);
+            if($sqlval['stock'] == "") {
+                $sqlval['stock'] = '0';
+            }
+            $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
+        }
+    }
+
+    // GETの値をインサート用に整える
+    function lfGetInsParam($sqlVal){
+        $objDb = new SC_Helper_DB_Ex();
+        foreach($_GET as $key => $val){
+            // カラムの存在チェック
+            if($objDb->sfColumnExists("dtb_order", $key)) $sqlVal[$key] = $val;
+        }
+
+        return $sqlVal;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Confirm.php
===================================================================
--- branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Confirm.php	(revision 18176)
+++ branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Confirm.php	(revision 18176)
@@ -0,0 +1,281 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 入力内容確認のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id:LC_Page_Shopping_Confirm.php 15532 2007-08-31 14:39:46Z nanasess $
+ */
+class LC_Page_Shopping_Confirm extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'shopping/confirm.tpl';
+        $this->tpl_column_num = 1;
+        $this->tpl_css = URL_DIR.'css/layout/shopping/confirm.css';
+        $this->tpl_title = "ご入力内容のご確認";
+        $masterData = new SC_DB_MasterData();
+        $this->arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));
+        $this->arrSex = $masterData->getMasterData("mtb_sex");
+        $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
+        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
+
+        $this->allowClientCache();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        global $objCampaignSess;
+
+        $objView = new SC_SiteView();
+        $objCartSess = new SC_CartSession();
+        $objSiteInfo = $objView->objSiteInfo;
+        $objSiteSess = new SC_SiteSession();
+        $objCampaignSess = new SC_CampaignSession();
+        $objCustomer = new SC_Customer();
+        $arrInfo = $objSiteInfo->data;
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // 前のページで正しく登録手続きが行われた記録があるか判定
+        SC_Utils_Ex::sfIsPrePage($objSiteSess);
+
+        // ユーザユニークIDの取得と購入状態の正当性をチェック
+        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
+        $this->tpl_uniqid = $uniqid;
+
+        // カート集計処理
+        $objDb->sfTotalCart($this, $objCartSess, $arrInfo);
+        // 一時受注テーブルの読込
+        $arrData = $objDb->sfGetOrderTemp($uniqid);
+        // カート集計を元に最終計算
+        $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo, $objCustomer, $objCampaignSess);
+        // キャンペーンからの遷移で送料が無料だった場合の処理
+        if($objCampaignSess->getIsCampaign()) {
+            $deliv_free_flg = $objQuery->get("dtb_campaign", "deliv_free_flg", "campaign_id = ?", array($objCampaignSess->getCampaignId()));
+            // 送料無料が設定されていた場合
+            if($deliv_free_flg) {
+                $arrData['payment_total'] -= $arrData['deliv_fee'];
+                $arrData['deliv_fee'] = 0;
+            }
+        }
+
+
+        // カート内の商品の売り切れチェック
+        $objCartSess->chkSoldOut($objCartSess->getCartList());
+
+        // 会員ログインチェック
+        if($objCustomer->isLoginSuccess()) {
+            $this->tpl_login = '1';
+            $this->tpl_user_point = $objCustomer->getValue('point');
+        }
+
+        // 決済区分を取得する
+        $payment_type = "";
+        if($objDb->sfColumnExists("dtb_payment", "memo01")){
+            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
+            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
+            $arrPayment = $objQuery->getall($sql, array($arrData['payment_id']));
+            $payment_type = $arrPayment[0]["memo03"];
+        }
+        $this->payment_type = $payment_type;
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        switch($_POST['mode']) {
+        // 前のページに戻る
+        case 'return':
+            // 正常な推移であることを記録しておく
+            $objSiteSess->setRegistFlag();
+            $this->sendRedirect($this->getLocation(URL_SHOP_PAYMENT));
+            exit;
+            break;
+        case 'confirm':
+            // この時点でオーダーIDを確保しておく（クレジット、コンビニ決済で必要なため）
+            // postgresqlとmysqlとで処理を分ける
+            if (DB_TYPE == "pgsql") {
+                $order_id = $objQuery->nextval("dtb_order","order_id");
+            }elseif (DB_TYPE == "mysql") {
+                $order_id = $objQuery->get_auto_increment("dtb_order");
+            }
+            $arrData["order_id"] = $order_id;
+
+            // セッション情報を保持
+            $arrData['session'] = serialize($_SESSION);
+
+            // 集計結果を受注一時テーブルに反映
+            $objDb->sfRegistTempOrder($uniqid, $arrData);
+            // 正常に登録されたことを記録しておく
+            $objSiteSess->setRegistFlag();
+
+            // 決済方法により画面切替
+            if($payment_type != "") {
+                // TODO 決済方法のモジュールは Plugin として実装したい
+                $_SESSION["payment_id"] = $arrData['payment_id'];
+                $this->sendRedirect($this->getLocation(URL_SHOP_MODULE));
+            }else{
+                $this->sendRedirect($this->getLocation(URL_SHOP_COMPLETE));
+            }
+            exit;
+            break;
+        default:
+            break;
+        }
+
+        $this->arrData = $arrData;
+        $this->arrInfo = $arrInfo;
+        $objView->assignobj($this);
+        // フレームを選択(キャンペーンページから遷移なら変更)
+        $objCampaignSess->pageView($objView);
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->init();
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $objView = new SC_MobileView();
+        $objCartSess = new SC_CartSession();
+        $objSiteInfo = $objView->objSiteInfo;
+        $objSiteSess = new SC_SiteSession();
+        $objCustomer = new SC_Customer();
+        $arrInfo = $objSiteInfo->data;
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // 前のページで正しく登録手続きが行われた記録があるか判定
+        SC_Utils_Ex::sfIsPrePage($objSiteSess, true);
+
+        // ユーザユニークIDの取得と購入状態の正当性をチェック
+        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
+        $this->tpl_uniqid = $uniqid;
+
+        // カート集計処理
+        $objDb->sfTotalCart($this, $objCartSess, $arrInfo);
+        // 一時受注テーブルの読込
+        $arrData = $objDb->sfGetOrderTemp($uniqid);
+        // カート集計を元に最終計算
+        $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo, $objCustomer);
+
+        // カート内の商品の売り切れチェック
+        $objCartSess->chkSoldOut($objCartSess->getCartList());
+
+        // 会員ログインチェック
+        if($objCustomer->isLoginSuccess(true)) {
+            $this->tpl_login = '1';
+            $this->tpl_user_point = $objCustomer->getValue('point');
+        }
+
+        // 決済区分を取得する
+        $payment_type = "";
+        if($objDb->sfColumnExists("dtb_payment", "memo01")){
+            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
+            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
+            $arrPayment = $objQuery->getall($sql, array($arrData['payment_id']));
+            $payment_type = $arrPayment[0]["memo03"];
+        }
+        $this->payment_type = $payment_type;
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        switch($_POST['mode']) {
+            // 前のページに戻る
+        case 'return':
+            // 正常な推移であることを記録しておく
+            $objSiteSess->setRegistFlag();
+            $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_PAYMENT), true);
+            exit;
+            break;
+        case 'confirm':
+            // この時点でオーダーIDを確保しておく（クレジット、コンビニ決済で必要なため）
+            // postgresqlとmysqlとで処理を分ける
+            if (DB_TYPE == "pgsql") {
+                $order_id = $objQuery->nextval("dtb_order","order_id");
+            }elseif (DB_TYPE == "mysql") {
+                $order_id = $objQuery->get_auto_increment("dtb_order");
+            }
+            $arrData["order_id"] = $order_id;
+
+            // セッション情報を保持
+            $arrData['session'] = serialize($_SESSION);
+
+            // 集計結果を受注一時テーブルに反映
+            $objDb->sfRegistTempOrder($uniqid, $arrData);
+            // 正常に登録されたことを記録しておく
+            $objSiteSess->setRegistFlag();
+
+            // 決済方法により画面切替
+            if($payment_type != "") {
+                $_SESSION["payment_id"] = $arrData['payment_id'];
+                $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_MODULE), true);
+            }else{
+                $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_COMPLETE), true);
+            }
+            exit;
+            break;
+        default:
+            break;
+        }
+        $this->arrData = $arrData;
+        $this->arrInfo = $arrInfo;
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+}
+?>
Index: branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Payment.php
===================================================================
--- branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Payment.php	(revision 18176)
+++ branches/version-2/data/class/pages/shopping/LC_Page_Shopping_Payment.php	(revision 18176)
@@ -0,0 +1,564 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 支払い方法選択 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id:LC_Page_Shopping_Payment.php 15532 2007-08-31 14:39:46Z nanasess $
+ */
+class LC_Page_Shopping_Payment extends LC_Page {
+
+    // {{{ properties
+
+    /** フォームパラメータの配列 */
+    var $objFormParam;
+
+    /** 顧客情報のインスタンス */
+    var $objCustomer;
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'shopping/payment.tpl';
+        $this->tpl_column_num = 1;
+        $this->tpl_onload = 'fnCheckInputPoint();';
+        $this->tpl_title = "お支払方法・お届け時間等の指定";
+
+        $this->allowClientCache();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        global $objCampaignSess;
+
+        $objView = new SC_SiteView();
+        $objSiteSess = new SC_SiteSession();
+        $objCartSess = new SC_CartSession();
+        $objCampaignSess = new SC_CampaignSession();
+        $objDb = new SC_Helper_DB_Ex();
+        $this->objCustomer = new SC_Customer();
+        $objSiteInfo = $objView->objSiteInfo;
+        $arrInfo = $objSiteInfo->data;
+
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+        // POST値の取得
+        $this->objFormParam->setParam($_POST);
+
+        // ユーザユニークIDの取得と購入状態の正当性をチェック
+        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
+        // ユニークIDを引き継ぐ
+        $this->tpl_uniqid = $uniqid;
+
+        // 会員ログインチェック
+        if($this->objCustomer->isLoginSuccess()) {
+            $this->tpl_login = '1';
+            $this->tpl_user_point = $this->objCustomer->getValue('point');
+            //戻り先URL
+            $this->tpl_back_url = URL_DELIV_TOP;
+        } else {
+            $this->tpl_back_url = URL_SHOP_TOP . "?from=nonmember";
+        }
+
+        // 金額の取得 (購入途中で売り切れた場合にはこの関数内にてその商品の個数が０になる)
+        $objDb->sfTotalCart($this, $objCartSess, $arrInfo);
+
+        if (empty($arrData)) $arrData = array();
+        $this->arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo);
+
+        // カート内の商品の売り切れチェック
+        $objCartSess->chkSoldOut($objCartSess->getCartList());
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        switch($_POST['mode']) {
+        case 'confirm':
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError($this->arrData );
+            // 入力エラーなし
+            if(count($this->arrErr) == 0) {
+                // DBへのデータ登録
+                $this->lfRegistData($uniqid);
+                // 正常に登録されたことを記録しておく
+                $objSiteSess->setRegistFlag();
+                // 確認ページへ移動
+                $this->sendRedirect($this->getLocation(URL_SHOP_CONFIRM, array(), true));
+                exit;
+            }else{
+                // ユーザユニークIDの取得
+                $uniqid = $objSiteSess->getUniqId();
+                // 受注一時テーブルからの情報を格納
+                $this->lfSetOrderTempData($uniqid);
+            }
+            break;
+        // 前のページに戻る
+        case 'return':
+            // 非会員の場合
+            // 正常な推移であることを記録しておく
+            $objSiteSess->setRegistFlag();
+            $this->sendRedirect(URL_SHOP_TOP);
+            exit;
+            break;
+        // 支払い方法が変更された場合
+        case 'payment':
+            // ここのbreakは、意味があるので外さないで下さい。
+            break;
+        default:
+            // 受注一時テーブルからの情報を格納
+            $this->lfSetOrderTempData($uniqid);
+            break;
+        }
+
+        // 店舗情報の取得
+        $arrInfo = $objSiteInfo->data;
+        // 購入金額の取得得
+        $total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
+        // 支払い方法の取得
+        $this->arrPayment = $this->lfGetPayment($total_pretax);
+        // 配送時間の取得
+        $arrRet = $objDb->sfGetDelivTime($this->objFormParam->getValue('payment_id'));
+        $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
+
+        // 配送日一覧の取得
+        $this->arrDelivDate = $this->lfGetDelivDate();
+
+        $this->arrForm = $this->objFormParam->getFormParamList();
+
+        $objView->assignobj($this);
+        // フレームを選択(キャンペーンページから遷移なら変更)
+        $objCampaignSess->pageView($objView);
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->init();
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $objView = new SC_MobileView();
+        $objSiteSess = new SC_SiteSession();
+        $objCartSess = new SC_CartSession();
+        $this->objCustomer = new SC_Customer();
+        $objDb = new SC_Helper_DB_Ex();
+        $objSiteInfo = $objView->objSiteInfo;
+        $arrInfo = $objSiteInfo->data;
+
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+        // POST値の取得
+        $this->objFormParam->setParam($_POST);
+
+        // ユーザユニークIDの取得と購入状態の正当性をチェック
+        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
+        // ユニークIDを引き継ぐ
+        $this->tpl_uniqid = $uniqid;
+
+        // 会員ログインチェック
+        if($this->objCustomer->isLoginSuccess(true)) {
+            $this->tpl_login = '1';
+            $this->tpl_user_point = $this->objCustomer->getValue('point');
+        }
+
+        // 金額の取得 (購入途中で売り切れた場合にはこの関数内にてその商品の個数が０になる)
+        $objDb->sfTotalCart($this, $objCartSess, $arrInfo);
+        if (empty($arrData)) $arrData = array();
+        $this->arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo);
+
+        // カート内の商品の売り切れチェック
+        $objCartSess->chkSoldOut($objCartSess->getCartList(), true);
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        // 戻るボタンの処理
+        if (!empty($_POST['return'])) {
+            switch ($_POST['mode']) {
+            case 'confirm':
+                $_POST['mode'] = 'payment';
+                break;
+            default:
+                // 正常な推移であることを記録しておく
+                $objSiteSess->setRegistFlag();
+                $this->sendRedirect(MOBILE_URL_SHOP_TOP, true);
+                exit;
+            }
+        }
+
+        switch($_POST['mode']) {
+            // 支払い方法指定 → 配達日時指定
+        case 'deliv_date':
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError($this->arrData);
+            if (!isset($this->arrErr['payment_id'])) {
+                // 支払い方法の入力エラーなし
+                $this->tpl_mainpage = 'shopping/deliv_date.tpl';
+                $this->tpl_title = "配達日時指定";
+                break;
+            } else {
+                // ユーザユニークIDの取得
+                $uniqid = $objSiteSess->getUniqId();
+                // 受注一時テーブルからの情報を格納
+                $this->lfSetOrderTempData($uniqid);
+            }
+            break;
+        case 'confirm':
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError($this->arrData );
+            // 入力エラーなし
+            if(count($this->arrErr) == 0) {
+                // DBへのデータ登録
+                $this->lfRegistData($uniqid);
+                // 正常に登録されたことを記録しておく
+                $objSiteSess->setRegistFlag();
+                // 確認ページへ移動
+                $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_CONFIRM), true);
+                exit;
+            }else{
+                // ユーザユニークIDの取得
+                $uniqid = $objSiteSess->getUniqId();
+                // 受注一時テーブルからの情報を格納
+                $this->lfSetOrderTempData($uniqid);
+                if (!isset($this->arrErr['payment_id'])) {
+                    // 支払い方法の入力エラーなし
+                    $this->tpl_mainpage = 'shopping/deliv_date.tpl';
+                    $this->tpl_title = "配達日時指定";
+                }
+            }
+            break;
+            // 前のページに戻る
+        case 'return':
+            // 非会員の場合
+            // 正常な推移であることを記録しておく
+            $objSiteSess->setRegistFlag();
+            $this->sendRedirect(MOBILE_URL_SHOP_TOP, true);
+            exit;
+            break;
+            // 支払い方法が変更された場合
+        case 'payment':
+            // ここのbreakは、意味があるので外さないで下さい。
+            break;
+        default:
+            // 受注一時テーブルからの情報を格納
+            $this->lfSetOrderTempData($uniqid);
+            break;
+        }
+
+        // 店舗情報の取得
+        $arrInfo = $objSiteInfo->data;
+        // 購入金額の取得得
+        $total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
+        // 支払い方法の取得
+        $this->arrPayment = $this->lfGetPayment($total_pretax);
+        // 配送時間の取得
+        $arrRet = $objDb->sfGetDelivTime($this->objFormParam->getValue('payment_id'));
+        $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
+
+        // 配送日一覧の取得
+        $this->arrDelivDate = $this->lfGetDelivDate();
+
+        $this->arrForm = $this->objFormParam->getFormParamList();
+
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* パラメータ情報の初期化 */
+    function lfInitParam() {
+        $this->objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("ポイント", "use_point", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK", "ZERO_START"));
+        $this->objFormParam->addParam("配達時間", "deliv_time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("ご質問", "message", LTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("ポイントを使用する", "point_check", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '2');
+        $this->objFormParam->addParam("配達日", "deliv_date", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+    }
+
+    function lfGetPayment($total_pretax) {
+        $objQuery = new SC_Query();
+        $objQuery->setorder("rank DESC");
+        //削除されていない支払方法を取得
+        $arrRet = $objQuery->select("payment_id, payment_method, rule, upper_rule, note, payment_image", "dtb_payment", "del_flg = 0 AND deliv_id IN (SELECT deliv_id FROM dtb_deliv WHERE del_flg = 0) ");
+        //利用条件から支払可能方法を判定
+        foreach($arrRet as $data) {
+            //下限と上限が設定されている
+            if($data['rule'] > 0 && $data['upper_rule'] > 0) {
+                if($data['rule'] <= $total_pretax && $data['upper_rule'] >= $total_pretax) {
+                    $arrPayment[] = $data;
+                }
+            //下限のみ設定されている
+            } elseif($data['rule'] > 0) {
+                if($data['rule'] <= $total_pretax) {
+                    $arrPayment[] = $data;
+                }
+            //上限のみ設定されている
+            } elseif($data['upper_rule'] > 0) {
+                if($data['upper_rule'] >= $total_pretax) {
+                    $arrPayment[] = $data;
+                }
+            //設定なし
+            } else {
+                $arrPayment[] = $data;
+            }
+        }
+        return $arrPayment;
+    }
+
+    /* 入力内容のチェック */
+    function lfCheckError($arrData) {
+        // 入力データを渡す。
+        $arrRet =  $this->objFormParam->getHashArray();
+        $objErr = new SC_CheckError($arrRet);
+        $objErr->arrErr = $this->objFormParam->checkError();
+
+        if (USE_POINT === false) {
+            $_POST['point_check'] = "";
+            $_POST['use_point'] = "0";
+        }
+        if (!isset($_POST['point_check'])) $_POST['point_check'] = "";
+
+        if($_POST['point_check'] == '1') {
+            $objErr->doFunc(array("ポイントを使用する", "point_check"), array("EXIST_CHECK"));
+            $objErr->doFunc(array("ポイント", "use_point"), array("EXIST_CHECK"));
+            $max_point = $this->objCustomer->getValue('point');
+            if($max_point == "") {
+                $max_point = 0;
+            }
+            // FIXME mobile 互換のため br は閉じない...
+            if($arrRet['use_point'] > $max_point) {
+                $objErr->arrErr['use_point'] = "※ ご利用ポイントが所持ポイントを超えています。<br>";
+            }
+            if(($arrRet['use_point'] * POINT_VALUE) > $arrData['subtotal']) {
+                $objErr->arrErr['use_point'] = "※ ご利用ポイントがご購入金額を超えています。<br>";
+            }
+        }
+
+        $objView = new SC_MobileView();
+        $objSiteInfo = $objView->objSiteInfo;
+        $arrInfo = $objSiteInfo->data;
+        $objCartSess = new SC_CartSession();
+        $arrInfo = $objSiteInfo->data;
+        // 購入金額の取得得
+        $total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
+        // 支払い方法の取得
+        $arrPayment = $this->lfGetPayment($total_pretax);
+        $pay_flag = true;
+        foreach ($arrPayment as $key => $payment) {
+            if ($payment['payment_id'] == $arrRet['payment_id']) {
+                $pay_flag = false;
+                break;
+            }
+        }
+        if ($pay_flag && $arrRet['payment_id'] != "" ) {
+            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
+        }
+
+        return $objErr->arrErr;
+    }
+
+    /* 支払い方法文字列の取得 */
+    function lfGetPaymentInfo($payment_id) {
+        $objQuery = new SC_Query();
+        $where = "payment_id = ?";
+        $arrRet = $objQuery->select("payment_method, charge", "dtb_payment", $where, array($payment_id));
+        return (array($arrRet[0]['payment_method'], $arrRet[0]['charge']));
+    }
+
+    /* 配送時間文字列の取得 */
+    function lfGetDelivTimeInfo($time_id) {
+        $objQuery = new SC_Query();
+        $where = "time_id = ?";
+        $arrRet = $objQuery->select("deliv_id, deliv_time", "dtb_delivtime", $where, array($time_id));
+        return (array($arrRet[0]['deliv_id'], $arrRet[0]['deliv_time']));
+    }
+
+    /* DBへデータの登録 */
+    function lfRegistData($uniqid) {
+        $arrRet = $this->objFormParam->getHashArray();
+        $sqlval = $this->objFormParam->getDbArray();
+        // 登録データの作成
+        $sqlval['order_temp_id'] = $uniqid;
+        $sqlval['update_date'] = 'Now()';
+
+        if($sqlval['payment_id'] != "") {
+            list($sqlval['payment_method'], $sqlval['charge']) = $this->lfGetPaymentInfo($sqlval['payment_id']);
+        } else {
+            $sqlval['payment_id'] = '0';
+            $sqlval['payment_method'] = "";
+        }
+
+        if($sqlval['deliv_time_id'] != "") {
+            list($sqlval['deliv_id'], $sqlval['deliv_time']) = $this->lfGetDelivTimeInfo($sqlval['deliv_time_id']);
+        } else {
+            $sqlval['deliv_time_id'] = '0';
+            $sqlval['deliv_id'] = '0';
+            $sqlval['deliv_time'] = "";
+        }
+
+        // 使用ポイントの設定
+        if($sqlval['point_check'] != '1') {
+            $sqlval['use_point'] = 0;
+        }
+
+        $objDb = new SC_Helper_DB_Ex();
+        $objDb->sfRegistTempOrder($uniqid, $sqlval);
+    }
+
+    /* 配達日一覧を取得する */
+    function lfGetDelivDate() {
+        $objCartSess = new SC_CartSession();
+        $objQuery = new SC_Query();
+        // 商品IDの取得
+        $max = $objCartSess->getMax();
+        for($i = 1; $i <= $max; $i++) {
+            if($_SESSION[$objCartSess->key][$i]['id'][0] != "") {
+                $arrID['product_id'][$i] = $_SESSION[$objCartSess->key][$i]['id'][0];
+            }
+        }
+        if(count($arrID['product_id']) > 0) {
+            $id = implode(",", $arrID['product_id']);
+            //商品から発送目安の取得
+            $deliv_date = $objQuery->get("dtb_products", "MAX(deliv_date_id)", "product_id IN (".$id.")");
+            //発送目安
+            switch($deliv_date) {
+            //即日発送
+            case '1':
+                $start_day = 1;
+                break;
+            //1-2日後
+            case '2':
+                $start_day = 3;
+                break;
+            //3-4日後
+            case '3':
+                $start_day = 5;
+                break;
+            //1週間以内
+            case '4':
+                $start_day = 8;
+                break;
+            //2週間以内
+            case '5':
+                $start_day = 15;
+                break;
+            //3週間以内
+            case '6':
+                $start_day = 22;
+                break;
+            //1ヶ月以内
+            case '7':
+                $start_day = 32;
+                break;
+            //2ヶ月以降
+            case '8':
+                $start_day = 62;
+                break;
+            //お取り寄せ(商品入荷後)
+            case '9':
+                $start_day = "";
+                break;
+            default:
+                //お届け日が設定されていない場合
+                $start_day = "";
+                break;
+            }
+            //配達可能日のスタート値から、配達日の配列を取得する
+            $arrDelivDate = $this->lfGetDateArray($start_day, DELIV_DATE_END_MAX);
+        }
+        return $arrDelivDate;
+    }
+
+    //配達可能日のスタート値から、配達日の配列を取得する
+    function lfGetDateArray($start_day, $end_day) {
+        $masterData = new SC_DB_MasterData();
+        $arrWDAY = $masterData->getMasterData("mtb_wday");
+        //配達可能日のスタート値がセットされていれば
+        if($start_day >= 1) {
+            $now_time = time();
+            $max_day = $start_day + $end_day;
+            // 集計
+            for ($i = $start_day; $i < $max_day; $i++) {
+                // 基本時間から日数を追加していく
+                $tmp_time = $now_time + ($i * 24 * 3600);
+                list($y, $m, $d, $w) = split(" ", date("y m d w", $tmp_time));
+                $val = sprintf("%02d/%02d/%02d(%s)", $y, $m, $d, $arrWDAY[$w]);
+                $arrDate[$val] = $val;
+            }
+        } else {
+            $arrDate = false;
+        }
+        return $arrDate;
+    }
+
+    //一時受注テーブルからの情報を格納する
+    function lfSetOrderTempData($uniqid) {
+
+        $objQuery = new SC_Query();
+        $col = "payment_id, use_point, deliv_time_id, message, point_check, deliv_date";
+        $from = "dtb_order_temp";
+        $where = "order_temp_id = ?";
+        $arrRet = $objQuery->select($col, $from, $where, array($uniqid));
+        // DB値の取得
+        $this->objFormParam->setParam($arrRet[0]);
+        return $this->objFormParam;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/admin/LC_Page_Admin_Login.php
===================================================================
--- branches/version-2/data/class/pages/admin/LC_Page_Admin_Login.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/LC_Page_Admin_Login.php	(revision 18176)
@@ -0,0 +1,147 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 管理者ログイン のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Login extends LC_Page {
+
+    // {{{ properties
+
+    /** SC_Session インスタンス */
+    var $objSess;
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $conn = new SC_DBConn();
+        $this->objSess = new SC_Session();
+        $ret = false;
+
+        if (!isset($_POST['login_id'])) $_POST['login_id'] = "";
+        if (!isset($_POST['password'])) $_POST['password'] = "";
+
+
+        // 入力判定
+        if(strlen($_POST{'login_id'}) > 0 && strlen($_POST{'password'}) >= ID_MIN_LEN && strlen($_POST{'password'}) <= ID_MAX_LEN) {
+            // 認証パスワードの判定
+            $ret = $this->fnCheckPassword($conn);
+        }
+
+        if($ret) {
+            // 成功
+            $this->sendRedirect($this->getLocation(URL_HOME));
+            exit;
+        } else {
+            // エラーページの表示
+            SC_Utils_Ex::sfDispError(LOGIN_ERROR);
+            exit;
+        }
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* 認証パスワードの判定 */
+    function fnCheckPassword($conn) {
+        $sql = "SELECT member_id, password, authority, login_date, name FROM dtb_member WHERE login_id = ? AND del_flg <> 1 AND work = 1";
+        $arrcol = array ($_POST['login_id']);
+        // DBから暗号化パスワードを取得する。
+        $data_list = $conn->getAll($sql ,$arrcol);
+        // パスワードの取得
+        $password = $data_list[0]['password'];
+        // ユーザ入力パスワードの判定
+        $ret = sha1($_POST['password'] . ":" . AUTH_MAGIC);
+
+        if ($ret == $password) {
+               // セッション登録
+            $this->fnSetLoginSession($data_list[0]['member_id'], $data_list[0]['authority'], $data_list[0]['login_date'], $data_list[0]['name']);
+            // ログイン日時の登録
+            $this->fnSetLoginDate();
+            return true;
+        }
+
+        // パスワード
+        GC_Utils_Ex::gfPrintLog($_POST['login_id'] . " password incorrect.");
+        return false;
+    }
+
+    /* 認証セッションの登録 */
+    function fnSetLoginSession($member_id,$authority,$login_date, $login_name = '') {
+
+        // 認証済みの設定
+        $this->objSess->SetSession('cert', CERT_STRING);
+        $this->objSess->SetSession('login_id', $_POST{'login_id'});
+        $this->objSess->SetSession('authority', $authority);
+        $this->objSess->SetSession('member_id', $member_id);
+        $this->objSess->SetSession('login_name', $login_name);
+        $this->objSess->SetSession('uniqid', $this->objSess->getUniqId());
+
+        if(strlen($login_date) > 0) {
+            $this->objSess->SetSession('last_login', $login_date);
+        } else {
+            $this->objSess->SetSession('last_login', date("Y-m-d H:i:s"));
+        }
+        $sid = $this->objSess->GetSID();
+        // ログに記録する
+        GC_Utils_Ex::gfPrintLog("login : user=".$_SESSION{'login_id'}." auth=".$_SESSION{'authority'}." lastlogin=". $_SESSION{'last_login'} ." sid=".$sid);
+    }
+
+    /* ログイン日時の更新 */
+    function fnSetLoginDate() {
+        $oquery = new SC_Query();
+        $sqlval['login_date'] = date("Y-m-d H:i:s");
+        $member_id = $this->objSess->GetSession('member_id');
+        $where = "member_id = " . $member_id;
+        $ret = $oquery->update("dtb_member", $sqlval, $where);
+    }
+}
+?>
Index: branches/version-2/data/class/pages/admin/mail/LC_Page_Admin_Mail.php
===================================================================
--- branches/version-2/data/class/pages/admin/mail/LC_Page_Admin_Mail.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/mail/LC_Page_Admin_Mail.php	(revision 18176)
@@ -0,0 +1,733 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * メルマガ管理 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Mail extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'mail/index.tpl';
+        $this->tpl_mainno = 'mail';
+        $this->tpl_subnavi = 'mail/subnavi.tpl';
+        $this->tpl_subno = "index";
+        $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
+        $this->tpl_subtitle = '配信内容設定';
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));
+        $this->arrJob = $masterData->getMasterData("mtb_job");
+        $this->arrJob["不明"] = "不明";
+        $this->arrSex = $masterData->getMasterData("mtb_sex");
+        $this->arrMailType = $masterData->getMasterData("mtb_mail_type");
+        $this->arrPageRows = $masterData->getMasterData("mtb_page_rows");
+        // ページナビ用
+        $this->tpl_pageno = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
+        $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
+        $this->arrHtmlmail[''] = "すべて";
+        $this->arrHtmlmail[1] = $this->arrMAILMAGATYPE[1];
+        $this->arrHtmlmail[2] = $this->arrMAILMAGATYPE[2];
+        $this->arrMagazineTypeAll = $masterData->getMasterData("mtb_magazine_type");
+
+        //---- 検索用項目配列
+        $this->arrHtmlmail = array( "" => "両方",  1 => "HTML", 2 => "TEXT" );
+
+
+        //---- 配列内容専用項目の配列
+        $this->arrRegistColumn = array(
+              array(  "column" => "template_id",    "convert" => "n" ),
+              array(  "column" => "mail_method",    "convert" => "n" ),
+              array(  "column" => "send_year",      "convert" => "n" ),
+              array(  "column" => "send_month",     "convert" => "n" ),
+              array(  "column" => "send_day",       "convert" => "n" ),
+              array(  "column" => "send_hour",      "convert" => "n" ),
+              array(  "column" => "send_minutes",   "convert" => "n" ),
+              array(  "column" => "subject",        "convert" => "aKV" ),
+              array(  "column" => "body",           "convert" => "KV" )
+              );
+
+        //---- メルマガ会員種別
+        $this->arrCustomerType = array(1 => "会員",
+                                       2 => "非会員",
+                                       //3 => "CSV登録"
+                                       );
+
+        //---- 検索項目
+        $this->arrSearchColumn = array(
+             array(  "column" => "name",                "convert" => "aKV"),
+             array(  "column" => "pref",                "convert" => "n" ),
+             array(  "column" => "kana",                "convert" => "CKV"),
+             array(  "column" => "sex",                 "convert" => "" ),
+             array(  "column" => "tel",                 "convert" => "n" ),
+             array(  "column" => "job",                 "convert" => "" ),
+             array(  "column" => "email",               "convert" => "a" ),
+             array(  "column" => "email_mobile",        "convert" => "a" ),
+             array(  "column" => "htmlmail",            "convert" => "n" ),
+             array(  "column" => "customer",            "convert" => "" ),
+             array(  "column" => "buy_total_from",      "convert" => "n" ),
+             array(  "column" => "buy_total_to",        "convert" => "n" ),
+             array(  "column" => "buy_times_from",      "convert" => "n" ),
+             array(  "column" => "buy_times_to",        "convert" => "n" ),
+             array(  "column" => "birth_month",         "convert" => "n" ),
+             array(  "column" => "b_start_year",        "convert" => "n" ),
+             array(  "column" => "b_start_month",       "convert" => "n" ),
+             array(  "column" => "b_start_day",         "convert" => "n" ),
+             array(  "column" => "b_end_year",          "convert" => "n" ),
+             array(  "column" => "b_end_month",         "convert" => "n" ),
+             array(  "column" => "b_end_day",           "convert" => "n" ),
+             array(  "column" => "start_year",          "convert" => "n" ),
+             array(  "column" => "start_month",         "convert" => "n" ),
+             array(  "column" => "start_day",           "convert" => "n" ),
+             array(  "column" => "end_year",            "convert" => "n" ),
+             array(  "column" => "end_month",           "convert" => "n" ),
+             array(  "column" => "end_day",             "convert" => "n" ),
+             array(  "column" => "buy_start_year",      "convert" => "n" ),
+             array(  "column" => "buy_start_month",     "convert" => "n" ),
+             array(  "column" => "buy_start_day",       "convert" => "n" ),
+             array(  "column" => "buy_end_year",        "convert" => "n" ),
+             array(  "column" => "buy_end_month",       "convert" => "n" ),
+             array(  "column" => "buy_end_day",         "convert" => "n" ),
+             array(  "column" => "buy_product_code",    "convert" => "aKV" ),
+             array(  "column" => "buy_product_name",    "convert" => "aKV" ),
+             array(  "column" => "category_id",         "convert" => "" ),
+             array(  "column" => "buy_total_from",      "convert" => "n" ),
+             array(  "column" => "buy_total_to",        "convert" => "n" ),
+             array(  "column" => "campaign_id",         "convert" => "" ),
+             array(  "column" => "mail_type",           "convert" => "" )
+             );
+
+        if (!isset($_POST['htmlmail'])) $_POST['htmlmail'] = "";
+        if (!isset($_POST['mail_type'])) $_POST['mail_type'] = "";
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+        if (!isset($_POST['buy_product_code'])) $_POST['buy_product_code'] = "";
+        if (!isset($_GET['mode'])) $_GET['mode'] = "";
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+
+        //---- ページ初期設定
+        $conn = new SC_DBConn();
+        $objView = new SC_AdminView();
+        $objDate = new SC_Date();
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+        $this->objDate = $objDate;
+        $this->arrTemplate = $this->getTemplateList($conn);
+
+        $objSess = new SC_Session();
+
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        /*
+         query:配信履歴「確認」
+        */
+        if ($_GET["mode"] == "query" && SC_Utils_Ex::sfCheckNumLength($_GET["send_id"])) {
+            // 送信履歴より、送信条件確認画面
+            $sql = "SELECT search_data FROM dtb_send_history WHERE send_id = ?";
+            $result = $conn->getOne($sql, array($_GET["send_id"]));
+            $tpl_path = "mail/query.tpl";
+
+            $list_data = unserialize($result);
+
+            // 都道府県を変換
+            $list_data['pref_disp'] = $this->arrPref[$list_data['pref']];
+
+            // 配信形式
+            $list_data['htmlmail_disp'] = $this->arrHtmlmail[$list_data['htmlmail']];
+
+            // 性別の変換
+            if (count($list_data['sex']) > 0) {
+                foreach($list_data['sex'] as $key => $val){
+                    $list_data['sex'][$key] = $this->arrSex[$val];
+                    $sex_disp .= $list_data['sex'][$key] . " ";
+                }
+                $list_data['sex_disp'] = $sex_disp;
+            }
+
+            // 職業の変換
+            if (count($list_data['job']) > 0) {
+                foreach($list_data['job'] as $key => $val){
+                    $list_data['job'][$key] = $this->arrJob[$val];
+                    $job_disp .= $list_data['job'][$key] . " ";
+                }
+                $list_data['job_disp'] = $job_disp;
+            }
+
+            // カテゴリ変換
+            $arrCatList = $objDb->sfGetCategoryList();
+            $list_data['category_name'] = $arrCatList[$list_data['category_id']];
+
+            $this->list_data = $list_data;
+            $this->arrCampaignList = $this->lfGetCampaignList($objQuery);
+            
+            $objView->assignobj($this);
+            $objView->display($tpl_path);
+            exit;
+        }
+
+        if($_POST['mode'] == 'delete') {
+        }
+
+        switch($_POST['mode']) {
+            /*
+             search:「検索」ボタン
+             back:検索結果画面「戻る」ボタン
+            */
+        case 'delete':
+        case 'search':
+        case 'back':
+            //-- 入力値コンバート
+            $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn);
+
+            //-- 入力エラーのチェック
+            $this->arrErr = $this->lfErrorCheck($this->list_data);
+
+            //-- 検索開始
+            if (!is_array($this->arrErr)) {
+                $this->list_data['name'] = isset($this->list_data['name'])
+                    ? SC_Utils_Ex::sfManualEscape($this->list_data['name']) : "";
+                // hidden要素作成
+                $this->arrHidden = $this->lfGetHidden($this->list_data);
+
+                //-- 検索データ取得
+                $objSelect = new SC_CustomerList($this->list_data, "magazine");
+                // 生成されたWHERE文を取得する
+                list($where, $arrval) = $objSelect->getWhere();
+
+                // 「WHERE」部分を削除する。
+                $where = ereg_replace("^WHERE", "", $where);
+
+                // 検索結果の取得
+                $from = "dtb_customer";
+
+                // 行数の取得
+                $linemax = $objQuery->count($from, $where, $arrval);
+                $this->tpl_linemax = $linemax;               // 何件が該当しました。表示用
+
+                // ページ送りの取得
+                $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnResultPageNavi", NAVI_PMAX);
+                $this->arrPagenavi = $objNavi->arrPagenavi;
+                $startno = $objNavi->start_row;
+
+                // 取得範囲の指定(開始行番号、行数のセット)
+                $objQuery->setlimitoffset(SEARCH_PMAX, $startno);
+                // 表示順序
+                $objQuery->setorder("customer_id DESC");
+
+                // 検索結果の取得
+                $col = $objSelect->getMailMagazineColumn($this->lfGetIsMobile($_POST['mail_type']));
+                $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
+                //現在時刻の取得
+                $this->arrNowDate = $this->lfGetNowDate();
+            }
+            break;
+            /*
+             input:検索結果画面「htmlmail内容設定」ボタン
+            */
+        case 'input':
+            //-- 入力値コンバート
+            $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn);
+            //-- 入力エラーのチェック
+            $this->arrErr = $this->lfErrorCheck($this->list_data);
+            //-- エラーなし
+            if (!is_array($this->arrErr)) {
+                //-- 現在時刻の取得
+                $this->arrNowDate = $this->lfGetNowDate();
+                $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成
+                $this->tpl_mainpage = 'mail/input.tpl';
+            }
+            break;
+            /*
+             template:テンプレート選択
+            */
+        case 'template':
+            //-- 入力値コンバート
+            $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn);
+
+            //-- 時刻設定の取得
+            $this->arrNowDate['year'] = isset($_POST['send_year']) ? $_POST['send_year'] : "";
+            $this->arrNowDate['month'] = isset($_POST['send_month']) ? $_POST['send_month'] : "";
+            $this->arrNowDate['day'] = isset($_POST['send_day']) ? $_POST['send_day'] : "";
+            $this->arrNowDate['hour'] = isset($_POST['send_hour']) ? $_POST['send_hour'] : "";
+            $this->arrNowDate['minutes'] = isset($_POST['send_minutes']) ? $_POST['send_minutes'] : "";
+
+            //-- 入力エラーのチェック
+            $this->arrErr = $this->lfErrorCheck($this->list_data);
+
+            //-- 検索開始
+            if ( ! is_array($this->arrErr)) {
+                $this->list_data['name'] = isset($this->list_data['name']) ? SC_Utils_Ex::sfManualEscape($this->list_data['name']) : "";
+                $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成
+
+                $this->tpl_mainpage = 'mail/input.tpl';
+                $template_data = $this->getTemplateData($conn, $_POST['template_id']);
+                if ( $template_data ){
+                    foreach( $template_data as $key=>$val ){
+                        $this->list_data[$key] = $val;
+                    }
+                }
+
+                //-- HTMLテンプレートを使用する場合は、HTMLソースを生成してBODYへ挿入
+                if ( $this->list_data["mail_method"] == 3) {
+                    $objTemplate = new LC_HTMLtemplate;
+                    $objTemplate->list_data = lfGetHtmlTemplateData($_POST['template_id']);
+                    $objSiteInfo = new SC_SiteInfo();
+                    $objTemplate->arrInfo = $objSiteInfo->data;
+                    //メール担当写真の表示
+                    $objUpFile = new SC_UploadFile(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
+                    $objUpFile->addFile("メール担当写真", 'charge_image', array('jpg'), IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
+                    $objUpFile->setDBFileList($objTemplate->list_data);
+                    $objTemplate->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
+                    $objMakeTemplate = new SC_AdminView();
+                    $objMakeTemplate->assignobj($objTemplate);
+                    $this->list_data["body"] = $objMakeTemplate->fetch("mail/html_template.tpl");
+                }
+            }
+            break;
+            /*
+             regist_confirm:「入力内容を確認」
+             regist_back:「テンプレート設定画面へ戻る」
+             regist_complete:「登録」
+            */
+        case 'regist_confirm':
+        case 'regist_back':
+        case 'regist_complete':
+            //-- 入力値コンバート
+            $this->arrCheckColumn = array_merge( $this->arrSearchColumn, $this->arrRegistColumn );
+            $this->list_data = $this->lfConvertParam($_POST, $this->arrCheckColumn);
+
+            //現在時刻の取得
+            $this->arrNowDate = $this->lfGetNowDate();
+
+            //-- 入力エラーのチェック
+            $this->arrErr = $this->lfErrorCheck($this->list_data, 1);
+            $this->tpl_mainpage = 'mail/input.tpl';
+            $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成
+
+            //-- 検索開始
+            if ( ! is_array($this->arrErr)) {
+                $this->list_data['name'] =
+                    isset($this->list_data['name'])
+                    ? SC_Utils_Ex::sfManualEscape($this->list_data['name']) : "";
+
+                if ( $_POST['mode'] == 'regist_confirm'){
+                    $this->tpl_mainpage = 'mail/input_confirm.tpl';
+                } else if( $_POST['mode'] == 'regist_complete' ){
+                    $this->lfRegistData($conn, $this->list_data);
+                    if(MELMAGA_SEND == true) {
+                        if(MELMAGA_BATCH_MODE) {
+                            $this->sendRedirect($this->getLocation(URL_DIR . "admin/mail/history.php"));
+                        } else {
+                            $this->sendRedirect($this->getLocation(URL_DIR . "admin/mail/sendmail.php", array("mode" => "now")));
+                        }
+                        exit;
+                    } else {
+                        SC_Utils_Ex::sfErrorHeader(">> 本サイトではメルマガ配信は行えません。");
+                    }
+                }
+            }
+            break;
+        default:
+            $this->list_data['mail_type'] = 1;
+            break;
+        }
+
+        // 配信時間の年を、「現在年~現在年＋１」の範囲に設定
+        for ($year=date("Y"); $year<=date("Y") + 1;$year++){
+            $arrYear[$year] = $year;
+        }
+        $this->arrYear = $arrYear;
+
+        $this->arrCustomerOrderId = $this->lfGetCustomerOrderId($_POST['buy_product_code']);
+
+        $this->arrCatList = $objDb->sfGetCategoryList();
+
+        $this->arrCampaignList = $this->lfGetCampaignList($objQuery);
+
+        //---- ページ表示
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    // 商品コードで検索された場合にヒットした受注番号を取得する。
+    function lfGetCustomerOrderId($keyword) {
+        $arrCustomerOrderId = null;
+        if($keyword != "") {
+            $col = "dtb_order.customer_id, dtb_order.order_id";
+            $from = "dtb_order LEFT JOIN dtb_order_detail USING(order_id)";
+            $where = "product_code LIKE ? AND del_flg = 0";
+            $val = SC_Utils_Ex::sfManualEscape($keyword);
+            $arrVal[] = "%$val%";
+            $objQuery = new SC_Query();
+            $objQuery->setgroupby("customer_id, order_id");
+            $arrRet = $objQuery->select($col, $from, $where, $arrVal);
+            $arrCustomerOrderId = SC_Utils_Ex::sfArrKeyValues($arrRet, "customer_id", "order_id");
+        }
+        return $arrCustomerOrderId;
+    }
+
+    function lfMakeCsvData(&$conn, $send_id){
+        $arrTitle  = array(  'name01','email');
+
+        $sql = "SELECT name01,email FROM dtb_send_customer WHERE send_id = ? ORDER BY email";
+        $result = $conn->getAll($sql, array($send_id) );
+
+        if ( $result ){
+            $return = SC_Utils_Ex::getCSVData( $result, $arrTitle);
+        }
+        return $return;
+    }
+
+    //現在時刻の取得（配信時間デフォルト値）
+    function lfGetNowDate(){
+        $nowdate = date("Y/n/j/G/i");
+        list($year, $month, $day, $hour, $minute) = split("[/]", $nowdate);
+        $arrNowDate = array( 'year' => $year, 'month' => $month, 'day' => $day, 'hour' => $hour, 'minutes' => $minute);
+        foreach ($arrNowDate as $key => $val){
+            switch ($key){
+            case 'minutes':
+                $val = ereg_replace('^[0]','', $val);
+                if ($val < 30){
+                    $list_date[$key] = '30';
+                }else{
+                    $list_date[$key] = '00';
+                }
+                break;
+            case 'year':
+            case 'month':
+            case 'day':
+                $list_date[$key] = $val;
+                break;
+            }
+        }
+        if ($arrNowDate['minutes'] < 30){
+            $list_date['hour'] = $hour;
+        }else{
+            $list_date['hour'] = $hour + 1;
+        }
+        return $list_date;
+    }
+
+    // 配信内容と配信リストを書き込む
+    function lfRegistData(&$conn, $arrData){
+
+        $objQuery = new SC_Query();
+        $objSelect = new SC_CustomerList($this->lfConvertParam($arrData, $this->arrSearchColumn), "magazine" );
+
+        $search_data = $conn->getAll($objSelect->getListMailMagazine($this->lfGetIsMobile($_POST['mail_type'])), $objSelect->arrVal);
+        $dataCnt = count($search_data);
+
+        $dtb_send_history = array();
+        if(DB_TYPE=='pgsql'){
+            $dtb_send_history["send_id"] = $objQuery->nextval('dtb_send_history', 'send_id');
+        }
+        $dtb_send_history["mail_method"] = $arrData['mail_method'];
+        $dtb_send_history["subject"] = $arrData['subject'];
+        $dtb_send_history["body"] = $arrData['body'];
+        if(MELMAGA_BATCH_MODE) {
+            $dtb_send_history["start_date"] = $arrData['send_year'] ."/".$arrData['send_month']."/".$arrData['send_day']." ".$arrData['send_hour'].":".$arrData['send_minutes'];
+        } else {
+            $dtb_send_history["start_date"] = "now()";
+        }
+        $dtb_send_history["creator_id"] = $_SESSION['member_id'];
+        $dtb_send_history["send_count"] = $dataCnt;
+        $arrData['body'] = "";
+        $dtb_send_history["search_data"] = serialize($arrData);
+        $dtb_send_history["update_date"] = "now()";
+        $dtb_send_history["create_date"] = "now()";
+        $objQuery->insert("dtb_send_history", $dtb_send_history );
+        if(DB_TYPE == "mysql"){
+            $dtb_send_history["send_id"] = $objQuery->nextval('dtb_send_history','send_id');
+        }
+        if ( is_array( $search_data ) ){
+            foreach( $search_data as $line ){
+                $dtb_send_customer = array();
+                $dtb_send_customer["customer_id"] = $line["customer_id"];
+                $dtb_send_customer["send_id"] = $dtb_send_history["send_id"];
+                $dtb_send_customer["email"] = $line["email"];
+
+                $dtb_send_customer["name"] = $line["name01"] . " " . $line["name02"];
+
+                $conn->autoExecute("dtb_send_customer", $dtb_send_customer );
+            }
+        }
+    }
+
+    // キャンペーン一覧
+    function lfGetCampaignList(&$objQuery) {
+        $arrCampaign = null;
+        $sql = "SELECT campaign_id, campaign_name FROM dtb_campaign ORDER BY update_date DESC";
+        $arrResult = $objQuery->getall($sql);
+
+        foreach($arrResult as $arrVal) {
+            $arrCampaign[$arrVal['campaign_id']] = $arrVal['campaign_name'];
+        }
+
+        return $arrCampaign;
+    }
+
+    function lfGetIsMobile($mail_type) {
+        // 検索結果の取得
+        $is_mobile = false;
+        switch($mail_type) {
+        case 1:
+            $is_mobile = false;
+            break;
+        case 2:
+            $is_mobile = true;
+            break;
+        default:
+            $is_mobile = false;
+            break;
+        }
+
+        return $is_mobile;
+    }
+
+
+    //---- HTMLテンプレートを使用する場合、データを取得する。
+    function lfGetHtmlTemplateData($id) {
+
+        global $conn;
+        $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ?";
+        $result = $conn->getAll($sql, array($id));
+        $list_data = $result[0];
+
+        // メイン商品の情報取得
+        $sql = "SELECT name, main_image, point_rate, deliv_fee, price01_min, price01_max, price02_min, price02_max FROM vw_products_allclass AS allcls WHERE product_id = ?";
+        $main = $conn->getAll($sql, array($list_data["main_product_id"]));
+        $list_data["main"] = $main[0];
+
+        // サブ商品の情報取得
+        $sql = "SELECT product_id, name, main_list_image, price01_min, price01_max, price02_min, price02_max FROM vw_products_allclass AS allcls WHERE product_id = ?";
+        $k = 0;
+        $l = 0;
+        for ($i = 1; $i <= 12; $i ++) {
+            if ($l == 4) {
+                $l = 0;
+                $k ++;
+            }
+            $result = "";
+            $j = sprintf("%02d", $i);
+            if ($i > 0 && $i < 5 ) $k = 0;
+            if ($i > 4 && $i < 9 ) $k = 1;
+            if ($i > 8 && $i < 13 ) $k = 2;
+
+            if (is_numeric($list_data["sub_product_id" .$j])) {
+                $result = $conn->getAll($sql, array($list_data["sub_product_id" .$j]));
+                $list_data["sub"][$k][$l] = $result[0];
+                $list_data["sub"][$k]["data_exists"] = "OK";    //当該段にデータが１つ以上存在するフラグ
+            }
+            $l ++;
+        }
+        return $list_data;
+    }
+
+    //---   テンプレートの種類を返す
+    function lfGetTemplateMethod($conn, $templata_id){
+
+        if ( SC_Utils_Ex::sfCheckNumLength($template_id) ){
+            $sql = "SELECT mail_method FROM dtb_mailmaga_template WEHRE template_id = ?";
+        }
+    }
+
+    //---   hidden要素出力用配列の作成
+    function lfGetHidden( $array ){
+        if ( is_array($array) ){
+            foreach( $array as $key => $val ){
+                if ( is_array( $val )){
+                    for ( $i=0; $i<count($val); $i++){
+                        $return[ $key.'['.$i.']'] = $val[$i];
+                    }
+                } else {
+                    $return[$key] = $val;
+                }
+            }
+        }
+        return $return;
+    }
+
+    //----　取得文字列の変換
+    function lfConvertParam($array, $arrSearchColumn) {
+
+        // 文字変換
+        foreach ($arrSearchColumn as $data) {
+            $arrConvList[ $data["column"] ] = $data["convert"];
+        }
+
+        $new_array = array();
+        foreach ($arrConvList as $key => $val) {
+            if (isset($array[$key]) &&  strlen($array[$key]) > 0 ){                        // データのあるものだけ返す
+                $new_array[$key] = $array[$key];
+                if( strlen($val) > 0) {
+                    $new_array[$key] = mb_convert_kana($new_array[$key] ,$val);
+                }
+            }
+        }
+        return $new_array;
+
+    }
+
+
+    //---- 入力エラーチェック
+    function lfErrorCheck($array, $flag = '') {
+
+        // flag は登録時用
+
+        $objErr = new SC_CheckError($array);
+
+        $objErr->doFunc(array("顧客コード", "customer_id", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("都道府県", "pref", 2), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("顧客名", "name", STEXT_LEN), array("MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("顧客名(カナ)", "kana", STEXT_LEN), array("KANA_CHECK", "MAX_LENGTH_CHECK"));
+
+        $objErr->doFunc(array('メールアドレス', "email", STEXT_LEN) ,array("EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("電話番号", "tel", TEL_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+
+        $objErr->doFunc(array("購入回数(開始)", "buy_times_from", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("購入回数(終了)", "buy_times_to", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+        if (!isset($array['buy_total_from'])) $array['buy_total_from'] = "";
+        if (!isset($array['buy_total_to'])) $array['buy_total_to'] = "";
+        if (!isset($array['buy_times_from'])) $array['buy_times_from'] = "";
+        if (!isset($array['buy_times_from'])) $array['buy_times_from'] = "";
+        if ((is_numeric($array["buy_total_from"]) && is_numeric($array["buy_total_to"]) ) && ($array["buy_times_from"] > $array["buy_times_to"]) ) $objErr->arrErr["buy_times_from"] .= "※ 購入回数の指定範囲が不正です。";
+
+        $objErr->doFunc(array("誕生月", "birth_month", 2), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+
+        $objErr->doFunc(array("誕生日(開始日)", "b_start_year", "b_start_month", "b_start_day",), array("CHECK_DATE"));
+        $objErr->doFunc(array("誕生日(終了日)", "b_end_year", "b_end_month", "b_end_day"), array("CHECK_DATE"));
+        $objErr->doFunc(array("誕生日(開始日)","誕生日(終了日)", "b_start_year", "b_start_month", "b_start_day", "b_end_year", "b_end_month", "b_end_day"), array("CHECK_SET_TERM"));
+
+        $objErr->doFunc(array("登録・更新日(開始日)", "start_year", "start_month", "start_day",), array("CHECK_DATE"));
+        $objErr->doFunc(array("登録・更新日(終了日)", "end_year", "end_month", "end_day"), array("CHECK_DATE"));
+        $objErr->doFunc(array("登録・更新日(開始日)","登録・更新日(終了日)", "start_year", "start_month", "start_day", "end_year", "end_month", "end_day"), array("CHECK_SET_TERM"));
+
+        $objErr->doFunc(array("最終購入日(開始日)", "buy_start_year", "buy_start_month", "buy_start_day",), array("CHECK_DATE"));
+        $objErr->doFunc(array("最終購入(終了日)", "buy_end_year", "buy_end_month", "buy_end_day"), array("CHECK_DATE"));
+        $objErr->doFunc(array("最終購入日(開始日)","登録・更新日(終了日)", "buy_start_year", "buy_start_month", "buy_start_day", "buy_end_year", "buy_end_month", "buy_end_day"), array("CHECK_SET_TERM"));
+
+        $objErr->doFunc(array("購入商品コード", "buy_product_code", STEXT_LEN), array("MAX_LENGTH_CHECK"));
+
+        $objErr->doFunc(array("購入商品名", "buy_product_name", STEXT_LEN), array("MAX_LENGTH_CHECK"));
+
+        $objErr->doFunc(array("購入金額(開始)", "buy_total_from", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("購入金額(終了)", "buy_total_to", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
+
+        $objErr->doFunc(array("キャンペーン", "campaign_id", INT_LEN), array("NUM_CHECK"));
+
+        //購入金額(from) ＞ 購入金額(to) の場合はエラーとする
+        if ( (is_numeric($array["buy_total_from"]) && is_numeric($array["buy_total_to"]) ) &&
+             ($array["buy_total_from"] > $array["buy_total_to"]) ) {
+            $objErr->arrErr["buy_total_from"] .= "※ 購入金額の指定範囲が不正です。";
+        }
+
+        if ( $flag ){
+            $objErr->doFunc(array("テンプレート", "template_id"), array("EXIST_CHECK", "NUM_CHECK"));
+            $objErr->doFunc(array("メール送信法法", "mail_method"), array("EXIST_CHECK", "NUM_CHECK"));
+
+            if(MELMAGA_BATCH_MODE) {
+                $objErr->doFunc(array("配信日（年）","send_year"), array("EXIST_CHECK", "NUM_CHECK"));
+                $objErr->doFunc(array("配信日（月）","send_month"), array("EXIST_CHECK", "NUM_CHECK"));
+                $objErr->doFunc(array("配信日（日）","send_day"), array("EXIST_CHECK", "NUM_CHECK"));
+                $objErr->doFunc(array("配信日（時）","send_hour"), array("EXIST_CHECK", "NUM_CHECK"));
+                $objErr->doFunc(array("配信日（分）","send_minutes"), array("EXIST_CHECK", "NUM_CHECK"));
+                $objErr->doFunc(array("配信日", "send_year", "send_month", "send_day"), array("CHECK_DATE"));
+                $objErr->doFunc(array("配信日", "send_year", "send_month", "send_day","send_hour", "send_minutes"), array("ALL_EXIST_CHECK"));
+            }
+            $objErr->doFunc(array("Subject", "subject", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
+            $objErr->doFunc(array("本文", 'body', LLTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));    // HTMLテンプレートを使用しない場合
+        }
+
+        return $objErr->arrErr;
+    }
+
+    /* テンプレートIDとsubjectの配列を返す */
+    function getTemplateList($conn){
+        $return = "";
+        $sql = "SELECT template_id, subject, mail_method FROM dtb_mailmaga_template WHERE del_flg = 0 ";
+        if ($_POST["htmlmail"] == 2 || $_POST['mail_type'] == 2) {
+            $sql .= " AND mail_method = 2 ";    //TEXT希望者へのTESTメールテンプレートリスト
+        }
+        $sql .= " ORDER BY template_id DESC";
+        $result = $conn->getAll($sql);
+
+        if ( is_array($result) ){
+            foreach( $result as $line ){
+                $return[$line['template_id']] = "【" . $this->arrMagazineTypeAll[$line['mail_method']] . "】" . $line['subject'];
+            }
+        }
+
+        return $return;
+    }
+
+    /* テンプレートIDからテンプレートデータを取得 */
+    function getTemplateData($conn, $id){
+
+        if ( SC_Utils_Ex::sfCheckNumLength($id) ){
+            $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ? ORDER BY template_id DESC";
+            $result = $conn->getAll( $sql, array($id) );
+            if ( is_array($result) ) {
+                $return = $result[0];
+            }
+        }
+        return $return;
+    }
+
+}
+class LC_HTMLtemplate {
+    var $list_data;
+}
+
+?>
Index: branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php
===================================================================
--- branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php	(revision 18176)
@@ -0,0 +1,726 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 商品登録 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Products_Product extends LC_Page {
+
+    // {{{ properties
+
+    /** ファイル管理クラスのインスタンス */
+    var $objUpFile;
+
+    /** hidden 項目の配列 */
+    var $arrHidden;
+
+    /** エラー情報 */
+    var $arrErr;
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'products/product.tpl';
+        $this->tpl_subnavi = 'products/subnavi.tpl';
+        $this->tpl_mainno = 'products';
+        $this->tpl_subno = 'product';
+        $this->tpl_subtitle = '商品登録';
+        $this->arrErr = array();
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrSRANK = $masterData->getMasterData("mtb_srank");
+        $this->arrDISP = $masterData->getMasterData("mtb_disp");
+        $this->arrCLASS = $masterData->getMasterData("mtb_class");
+        $this->arrSTATUS = $masterData->getMasterData("mtb_status");
+        $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image");
+        $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date");
+        $this->arrAllowedTag = $masterData->getMasterData("mtb_allowed_tag");
+        $this->tpl_nonclass = true;
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_AdminView();
+        $objSiteInfo = new SC_SiteInfo();
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // 認証可否の判定
+        $objSess = new SC_Session();
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        // ファイル管理クラス
+        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
+
+        // ファイル情報の初期化
+        $this->lfInitFile();
+        // Hiddenからのデータを引き継ぐ
+        $this->objUpFile->setHiddenFileList($_POST);
+
+        // 規格の有り無し判定
+        $this->tpl_nonclass = $this->lfCheckNonClass($_POST['product_id']);
+
+        // 検索パラメータの引き継ぎ
+        foreach ($_POST as $key => $val) {
+            if (ereg("^search_", $key)) {
+                $this->arrSearchHidden[$key] = $val;
+            }
+        }
+
+        // FORMデータの引き継ぎ
+        $this->arrForm = $_POST;
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        switch($_POST['mode']) {
+        // 検索画面からの編集
+        case 'pre_edit':
+        case 'copy' :
+            // 編集時
+            if(SC_Utils_Ex::sfIsInt($_POST['product_id'])){
+                // DBから商品情報の読込
+                $arrForm = $this->lfGetProduct($_POST['product_id']);
+                // DBデータから画像ファイル名の読込
+                $this->objUpFile->setDBFileList($arrForm);
+
+                if($_POST['mode'] == "copy"){
+                    $arrForm["copy_product_id"] = $arrForm["product_id"];
+                    $arrForm["product_id"] = "";
+                    // 画像ファイルのコピー
+                    $arrKey = $this->objUpFile->keyname;
+                    $arrSaveFile = $this->objUpFile->save_file;
+
+                    foreach($arrSaveFile as $key => $val){
+                        $this->lfMakeScaleImage($arrKey[$key], $arrKey[$key], true);
+                    }
+                }
+                $this->arrForm = $arrForm;
+
+                // 商品ステータスの変換
+                $arrRet = SC_Utils_Ex::sfSplitCBValue($this->arrForm['product_flag'], "product_flag");
+                $this->arrForm = array_merge($this->arrForm, $arrRet);
+                // DBからおすすめ商品の読み込み
+                $this->arrRecommend = $this->lfPreGetRecommendProducts($_POST['product_id']);
+
+                $this->lfProductPage();		// 商品登録ページ
+            }
+            break;
+        // 商品登録・編集
+        case 'edit':
+            if($_POST['product_id'] == "" and SC_Utils_Ex::sfIsInt($_POST['copy_product_id'])){
+                $this->tpl_nonclass = $this->lfCheckNonClass($_POST['copy_product_id']);
+            }
+
+            // 入力値の変換
+            $this->arrForm = $this->lfConvertParam($this->arrForm);
+            // エラーチェック
+            $this->arrErr = $this->lfErrorCheck($this->arrForm);
+            // ファイル存在チェック
+            $this->arrErr = array_merge((array)$this->arrErr, (array)$this->objUpFile->checkEXISTS());
+            // エラーなしの場合
+            if(count($this->arrErr) == 0) {
+                $this->lfProductConfirmPage(); // 確認ページ
+            } else {
+                $this->lfProductPage();		// 商品登録ページ
+            }
+            break;
+        // 確認ページから完了ページへ
+        case 'complete':
+            $this->tpl_mainpage = 'products/complete.tpl';
+
+            $this->arrForm['product_id'] = $this->lfRegistProduct($_POST);		// データ登録
+
+            // 件数カウントバッチ実行
+            $objDb->sfCategory_Count($objQuery);
+            // 一時ファイルを本番ディレクトリに移動する
+            $this->objUpFile->moveTempFile();
+
+            break;
+        // 画像のアップロード
+        case 'upload_image':
+            // ファイル存在チェック
+            $this->arrErr = array_merge((array)$this->arrErr, (array)$this->objUpFile->checkEXISTS($_POST['image_key']));
+            // 画像保存処理
+            $this->arrErr[$_POST['image_key']] = $this->objUpFile->makeTempFile($_POST['image_key'],IMAGE_RENAME);
+
+            // 中、小画像生成
+            $this->lfSetScaleImage();
+
+            $this->lfProductPage(); // 商品登録ページ
+            break;
+        // 画像の削除
+        case 'delete_image':
+            $this->objUpFile->deleteFile($_POST['image_key']);
+            $this->lfProductPage(); // 商品登録ページ
+            break;
+        // 確認ページからの戻り
+        case 'confirm_return':
+            $this->lfProductPage();		// 商品登録ページ
+            break;
+        // おすすめ商品選択
+        case 'recommend_select' :
+            $this->lfProductPage();		// 商品登録ページ
+            break;
+        default:
+            $this->lfProductPage();		// 商品登録ページ
+            break;
+        }
+
+        if($_POST['mode'] != 'pre_edit') {
+            // おすすめ商品の読み込み
+            $this->arrRecommend = $this->lfGetRecommendProducts();
+        }
+
+        // 基本情報を渡す
+        $this->arrInfo = $objSiteInfo->data;
+
+        // サブ情報の入力があるかどうかチェックする
+        $sub_find = false;
+        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
+            if(	(isset($this->arrForm['sub_title'.$cnt])
+                 && !empty($this->arrForm['sub_title'.$cnt])) ||
+                (isset($this->arrForm['sub_comment'.$cnt])
+                 && !empty($this->arrForm['sub_comment'.$cnt])) ||
+                (isset($this->arrForm['sub_image'.$cnt])
+                 && !empty($this->arrForm['sub_image'.$cnt])) ||
+                (isset($this->arrForm['sub_large_image'.$cnt])
+                 && !empty($this->arrForm['sub_large_image'.$cnt])) ||
+                (isset($this->arrForm['sub_image'.$cnt])
+                 && is_array($this->arrFile['sub_image'.$cnt])) ||
+                (isset($this->arrForm['sub_large_image'.$cnt])
+                 && is_array($this->arrFile['sub_large_image'.$cnt]))) {
+                $sub_find = true;
+                break;
+            }
+        }
+        // サブ情報表示・非表示のチェックに使用する。
+        $this->sub_find = $sub_find;
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* おすすめ商品の読み込み */
+    function lfGetRecommendProducts() {
+        $objQuery = new SC_Query();
+        $arrRecommend = array();
+        for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {
+            $keyname = "recommend_id" . $i;
+            $delkey = "recommend_delete" . $i;
+            $commentkey = "recommend_comment" . $i;
+
+            if (!isset($_POST[$delkey])) $_POST[$delkey] = null;
+
+            if((isset($_POST[$keyname]) && !empty($_POST[$keyname])) && $_POST[$delkey] != 1) {
+                $arrRet = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($_POST[$keyname]));
+                $arrRecommend[$i] = $arrRet[0];
+                $arrRecommend[$i]['product_id'] = $_POST[$keyname];
+                $arrRecommend[$i]['comment'] = $this->arrForm[$commentkey];
+            }
+        }
+        return $arrRecommend;
+    }
+
+    /* おすすめ商品の登録 */
+    function lfInsertRecommendProducts($objQuery, $arrList, $product_id) {
+        // 一旦オススメ商品をすべて削除する
+        $objQuery->delete("dtb_recommend_products", "product_id = ?", array($product_id));
+        $sqlval['product_id'] = $product_id;
+        $rank = RECOMMEND_PRODUCT_MAX;
+        for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {
+            $keyname = "recommend_id" . $i;
+            $commentkey = "recommend_comment" . $i;
+            $deletekey = "recommend_delete" . $i;
+
+            if (!isset($arrList[$deletekey])) $arrList[$deletekey] = null;
+
+            if($arrList[$keyname] != "" && $arrList[$deletekey] != '1') {
+                $sqlval['recommend_product_id'] = $arrList[$keyname];
+                $sqlval['comment'] = $arrList[$commentkey];
+                $sqlval['rank'] = $rank;
+                $sqlval['creator_id'] = $_SESSION['member_id'];
+                $sqlval['create_date'] = "now()";
+                $sqlval['update_date'] = "now()";
+                $objQuery->insert("dtb_recommend_products", $sqlval);
+                $rank--;
+            }
+        }
+    }
+
+    /* 登録済みおすすめ商品の読み込み */
+    function lfPreGetRecommendProducts($product_id) {
+        $arrRecommend = array();
+        $objQuery = new SC_Query();
+        $objQuery->setorder("rank DESC");
+        $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
+        $max = count($arrRet);
+        $no = 1;
+
+        for($i = 0; $i < $max; $i++) {
+            $arrProductInfo = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($arrRet[$i]['recommend_product_id']));
+            $arrRecommend[$no] = $arrProductInfo[0];
+            $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
+            $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
+            $no++;
+        }
+        return $arrRecommend;
+    }
+
+    /* 商品情報の読み込み */
+    function lfGetProduct($product_id) {
+        $objQuery = new SC_Query();
+        $col = "*";
+        $table = "vw_products_nonclass AS noncls ";
+        $where = "product_id = ?";
+
+        $arrRet = $objQuery->select($col, $table, $where, array($product_id));
+
+        // カテゴリID を取得
+        $arrRet[0]['category_id'] = $objQuery->getCol("dtb_product_categories",
+                                                      "category_id",
+                                                      "product_id = ?",
+                                                      array($product_id));
+        //編集時に規格IDが変わってしまうのを防ぐために規格が登録されていなければ規格IDを取得する
+        if( $this->lfCheckNonClass($_POST['product_id']) ){
+            $arrRet[0]['product_class_id'] = SC_Utils::sfGetProductClassId($product_id,"0","0");
+        }
+        return $arrRet[0];
+    }
+
+    /* 商品登録ページ表示用 */
+    function lfProductPage() {
+        $objDb = new SC_Helper_DB_Ex();
+
+        // カテゴリの読込
+        list($this->arrCatVal, $this->arrCatOut) = $objDb->sfGetLevelCatList(false);
+
+        if (isset($this->arrForm['category_id']) && !is_array($this->arrForm['category_id'])) {
+            $this->arrForm['category_id'] = unserialize($this->arrForm['category_id']);
+        }
+        if($this->arrForm['status'] == "") {
+            $this->arrForm['status'] = DEFAULT_PRODUCT_DISP;
+        }
+
+        if(isset($this->arrForm['product_flag']) && !is_array($this->arrForm['product_flag'])) {
+            // 商品ステータスの分割読込
+            $this->arrForm['product_flag'] = SC_Utils_Ex::sfSplitCheckBoxes($this->arrForm['product_flag']);
+        }
+
+        // HIDDEN用に配列を渡す。
+        $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objUpFile->getHiddenFileList());
+        // Form用配列を渡す。
+        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
+
+
+        // アンカーを設定
+        if (isset($_POST['image_key']) && !empty($_POST['image_key'])) {
+            $anchor_hash = "location.hash='#" . $_POST['image_key'] . "'";
+        } elseif (isset($_POST['anchor_key']) && !empty($_POST['anchor_key'])) {
+            $anchor_hash = "location.hash='#" . $_POST['anchor_key'] . "'";
+        } else {
+            $anchor_hash = "";
+        }
+
+        $this->tpl_onload = "fnCheckSaleLimit('" . DISABLED_RGB . "'); fnCheckStockLimit('" . DISABLED_RGB . "'); fnMoveSelect('category_id_unselect', 'category_id');" . $anchor_hash;
+    }
+
+    /* ファイル情報の初期化 */
+    function lfInitFile() {
+        $this->objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
+        $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
+        $this->objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT);
+        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
+            $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT);
+            $this->objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT);
+        }
+        $this->objUpFile->addFile("商品比較画像", 'file1', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, OTHER_IMAGE1_WIDTH, OTHER_IMAGE1_HEIGHT);
+        $this->objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false);
+    }
+
+    /* 商品の登録 */
+    function lfRegistProduct($arrList) {
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+        $objQuery->begin();
+
+        // 配列の添字を定義
+        $checkArray = array("name", "status", "product_flag",
+                            "main_list_comment", "main_comment", "point_rate",
+                            "deliv_fee", "comment1", "comment2", "comment3",
+                            "comment4", "comment5", "comment6", "main_list_comment",
+                            "sale_limit", "sale_unlimited", "deliv_date_id", "note");
+        $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray);
+
+        // INSERTする値を作成する。
+        $sqlval['name'] = $arrList['name'];
+        $sqlval['status'] = $arrList['status'];
+        $sqlval['product_flag'] = $arrList['product_flag'];
+        $sqlval['main_list_comment'] = $arrList['main_list_comment'];
+        $sqlval['main_comment'] = $arrList['main_comment'];
+        $sqlval['point_rate'] = $arrList['point_rate'];
+        $sqlval['deliv_fee'] = $arrList['deliv_fee'];
+        $sqlval['comment1'] = $arrList['comment1'];
+        $sqlval['comment2'] = $arrList['comment2'];
+        $sqlval['comment3'] = $arrList['comment3'];
+        $sqlval['comment4'] = $arrList['comment4'];
+        $sqlval['comment5'] = $arrList['comment5'];
+        $sqlval['comment6'] = $arrList['comment6'];
+        $sqlval['main_list_comment'] = $arrList['main_list_comment'];
+        $sqlval['sale_limit'] = $arrList['sale_limit'];
+        $sqlval['sale_unlimited'] = $arrList['sale_unlimited'];
+        $sqlval['deliv_date_id'] = $arrList['deliv_date_id'];
+        $sqlval['note'] = $arrList['note'];
+        $sqlval['update_date'] = "Now()";
+        $sqlval['creator_id'] = $_SESSION['member_id'];
+        $arrRet = $this->objUpFile->getDBFileList();
+        $sqlval = array_merge($sqlval, $arrRet);
+
+        $arrList['category_id'] = unserialize($arrList['category_id']);
+
+        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
+            $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt];
+            $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt];
+        }
+
+        if($arrList['product_id'] == "") {
+            // product_id 取得（PostgreSQLの場合）
+            if(DB_TYPE=='pgsql'){
+                $product_id = $objQuery->nextval("dtb_products", "product_id");
+                $sqlval['product_id'] = $product_id;
+            }
+
+            // INSERTの実行
+            $sqlval['create_date'] = "Now()";
+            $objQuery->insert("dtb_products", $sqlval);
+
+            // product_id 取得（MySQLの場合）
+            if(DB_TYPE=='mysql'){
+                $product_id = $objQuery->nextval("dtb_products", "product_id");
+            }
+
+            // カテゴリを更新
+            $objDb->updateProductCategories($arrList['category_id'], $product_id);
+
+            // コピー商品の場合には規格もコピーする
+            if($_POST["copy_product_id"] != "" and SC_Utils_Ex::sfIsInt($_POST["copy_product_id"])){
+                // dtb_products_class のカラムを取得
+                $dbFactory = SC_DB_DBFactory_Ex::getInstance();
+                $arrColList = $dbFactory->sfGetColumnList("dtb_products_class", $objQuery);
+                $arrColList_tmp = array_flip($arrColList);
+
+                // コピーしない列
+                unset($arrColList[$arrColList_tmp["product_class_id"]]);	 //規格ID
+                unset($arrColList[$arrColList_tmp["product_id"]]);			 //商品ID
+                unset($arrColList[$arrColList_tmp["create_date"]]);
+
+                $col = SC_Utils_Ex::sfGetCommaList($arrColList);
+
+                $objQuery->query("INSERT INTO dtb_products_class (product_id, create_date, ". $col .") SELECT ?, now(), " . $col. " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"]));
+
+            }
+
+        } else {
+            $product_id = $arrList['product_id'];
+            // 削除要求のあった既存ファイルの削除
+            $arrRet = $this->lfGetProduct($arrList['product_id']);
+            $this->objUpFile->deleteDBFile($arrRet);
+
+            // UPDATEの実行
+            $where = "product_id = ?";
+            $objQuery->update("dtb_products", $sqlval, $where, array($product_id));
+
+            // カテゴリを更新
+            $objDb->updateProductCategories($arrList['category_id'], $product_id);
+        }
+
+        //商品登録の時は規格を生成する。複製の場合は規格も複製されるのでこの処理は不要。
+        if( $_POST["copy_product_id"] == "" ){
+            // 規格登録
+            SC_Utils_Ex::sfInsertProductClass($objQuery, $arrList, $product_id , $arrList['product_class_id'] );
+        }
+
+        // おすすめ商品登録
+        $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id);
+
+        $objQuery->commit();
+        return $product_id;
+    }
+
+
+    /* 取得文字列の変換 */
+    function lfConvertParam($array) {
+        /*
+         *	文字列の変換
+         *	K :  「半角(ﾊﾝｶｸ)片仮名」を「全角片仮名」に変換
+         *	C :  「全角ひら仮名」を「全角かた仮名」に変換
+         *	V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
+         *	n :  「全角」数字を「半角(ﾊﾝｶｸ)」に変換
+         */
+
+        // スポット商品
+        $arrConvList['name'] = "KVa";
+        $arrConvList['main_list_comment'] = "KVa";
+        $arrConvList['main_comment'] = "KVa";
+        $arrConvList['note'] = "KVa";
+        $arrConvList['price01'] = "n";
+        $arrConvList['price02'] = "n";
+        $arrConvList['stock'] = "n";
+        $arrConvList['sale_limit'] = "n";
+        $arrConvList['point_rate'] = "n";
+        $arrConvList['product_code'] = "KVna";
+        $arrConvList['comment1'] = "a";
+        $arrConvList['deliv_fee'] = "n";
+
+        // 詳細-サブ
+        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
+            $arrConvList["sub_title$cnt"] = "KVa";
+        }
+        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
+            $arrConvList["sub_comment$cnt"] = "KVa";
+        }
+
+        // おすすめ商品
+        for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) {
+            $arrConvList["recommend_comment$cnt"] = "KVa";
+        }
+
+        // 文字変換
+        foreach ($arrConvList as $key => $val) {
+            // POSTされてきた値のみ変換する。
+            if(isset($array[$key])) {
+                $array[$key] = mb_convert_kana($array[$key] ,$val);
+            }
+        }
+
+        if (!isset($array['product_flag'])) $array['product_flag'] = "";
+        $array['product_flag'] = SC_Utils_Ex::sfMergeCheckBoxes($array['product_flag'], count($this->arrSTATUS));
+
+        return $array;
+    }
+
+    // 入力エラーチェック
+    function lfErrorCheck($array) {
+
+        $objErr = new SC_CheckError($array);
+        $objErr->doFunc(array("商品名", "name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("一覧-メインコメント", "main_list_comment", MTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("詳細-メインコメント", "main_comment", LLTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("詳細-メインコメント", "main_comment", $this->arrAllowedTag), array("HTML_TAG_CHECK"));
+        $objErr->doFunc(array("ポイント付与率", "point_rate", PERCENTAGE_LEN), array("EXIST_CHECK", "NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("商品送料", "deliv_fee", PRICE_LEN), array("NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("備考欄(SHOP専用)", "note", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("検索ワード", "comment3", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("メーカーURL", "comment1", URL_LEN), array("SPTAB_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("発送日目安", "deliv_date_id", INT_LEN), array("NUM_CHECK"));
+
+        if($this->tpl_nonclass) {
+            $objErr->doFunc(array("商品コード", "product_code", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK","MAX_LENGTH_CHECK"));
+            $objErr->doFunc(array("通常価格", "price01", PRICE_LEN), array("ZERO_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+            $objErr->doFunc(array("商品価格", "price02", PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "ZERO_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+
+            if(!isset($array['stock_unlinited']) && $array['stock_unlimited'] != "1") {
+                $objErr->doFunc(array("在庫数", "stock", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+            }
+        }
+
+        if(!isset($array['sale_unlimited']) && $array['sale_unlimited'] != "1") {
+            $objErr->doFunc(array("購入制限", "sale_limit", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+        }
+
+        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
+            $objErr->doFunc(array("詳細-サブタイトル$cnt", "sub_title$cnt", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+            $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+            $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", $this->arrAllowedTag),  array("HTML_TAG_CHECK"));
+        }
+
+        for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) {
+
+            if (!isset($_POST["recommend_delete$cnt"]))  $_POST["recommend_delete$cnt"] = "";
+
+            if(isset($_POST["recommend_id$cnt"])
+               && $_POST["recommend_id$cnt"] != ""
+               && $_POST["recommend_delete$cnt"] != 1) {
+                $objErr->doFunc(array("おすすめ商品コメント$cnt", "recommend_comment$cnt", LTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+            }
+        }
+
+        // カテゴリID のチェック
+        if (empty($array['category_id'])) {
+            $objErr->arrErr['category_id'] = "※ 商品カテゴリが選択されていません。<br />";
+        } else {
+            $arrCategory_id = array();
+            for ($i = 0; $i < count($array['category_id']); $i++) {
+                $arrCategory_id['category_id' . $i] = $array['category_id'][$i];
+            }
+            $objCheckCategory = new SC_CheckError($arrCategory_id);
+            for ($i = 0; $i < count($array['category_id']); $i++) {
+                $objCheckCategory->doFunc(array("商品カテゴリ", "category_id" . $i, STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+            }
+            if (!empty($objCheckCategory->arrErr)) {
+                $objErr->arrErr = array_merge($objErr->arrErr,
+                                              $objCheckCategory->arrErr);
+            }
+        }
+        return $objErr->arrErr;
+    }
+
+    /* 確認ページ表示用 */
+    function lfProductConfirmPage() {
+        $this->tpl_mainpage = 'products/confirm.tpl';
+        $this->arrForm['mode'] = 'complete';
+
+        $objDb = new SC_Helper_DB_Ex();
+
+        // カテゴリ表示
+        $this->arrCategory_id = $this->arrForm['category_id'];
+        $this->arrCatList = array();
+        list($arrCatVal, $arrCatOut) = $objDb->sfGetLevelCatList(false);
+        for ($i = 0; $i < count($arrCatVal); $i++) {
+            $this->arrCatList[$arrCatVal[$i]] = $arrCatOut[$i];
+        }
+
+        // hidden に渡す値は serialize する
+        $this->arrForm['category_id'] = serialize($this->arrForm['category_id']);
+
+        // Form用配列を渡す。
+        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
+    }
+
+    /* 規格あり判定用(規格が登録されていない場合:TRUE) */
+    function lfCheckNonClass($product_id) {
+        if(SC_Utils_Ex::sfIsInt($product_id)) {
+            $objQuery  = new SC_Query();
+            $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
+            $count = $objQuery->count("dtb_products_class", $where, array($product_id));
+            if($count > 0) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    // 縮小した画像をセットする
+    function lfSetScaleImage(){
+
+        $subno = str_replace("sub_large_image", "", $_POST['image_key']);
+        switch ($_POST['image_key']){
+            case "main_large_image":
+                // 詳細メイン画像
+                $this->lfMakeScaleImage($_POST['image_key'], "main_image");
+            case "main_image":
+                // 一覧メイン画像
+                $this->lfMakeScaleImage($_POST['image_key'], "main_list_image");
+                break;
+            case "sub_large_image" . $subno:
+                // サブメイン画像
+                $this->lfMakeScaleImage($_POST['image_key'], "sub_image" . $subno);
+                break;
+            default:
+                break;
+        }
+    }
+
+    // 縮小画像生成
+    function lfMakeScaleImage($from_key, $to_key, $forced = false){
+        $arrImageKey = array_flip($this->objUpFile->keyname);
+
+        if($this->objUpFile->temp_file[$arrImageKey[$from_key]]){
+            $from_path = $this->objUpFile->temp_dir . $this->objUpFile->temp_file[$arrImageKey[$from_key]];
+        }elseif($this->objUpFile->save_file[$arrImageKey[$from_key]]){
+            $from_path = $this->objUpFile->save_dir . $this->objUpFile->save_file[$arrImageKey[$from_key]];
+        }else{
+            return "";
+        }
+
+        if(file_exists($from_path)){
+            // 元画像サイズを取得
+            list($from_w, $from_h) = getimagesize($from_path);
+
+            // 生成先の画像サイズを取得
+            $to_w = $this->objUpFile->width[$arrImageKey[$to_key]];
+            $to_h = $this->objUpFile->height[$arrImageKey[$to_key]];
+
+
+            if($forced) $this->objUpFile->save_file[$arrImageKey[$to_key]] = "";
+
+            if(empty($this->objUpFile->temp_file[$arrImageKey[$to_key]]) &&
+               empty($this->objUpFile->save_file[$arrImageKey[$to_key]])) {
+
+                // リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける
+                $dst_file = $this->objUpFile->lfGetTmpImageName(IMAGE_RENAME, "", $this->objUpFile->temp_file[$arrImageKey[$from_key]]) . $this->lfGetAddSuffix($to_key);
+                $path = $this->objUpFile->makeThumb($from_path, $to_w, $to_h, $dst_file);
+                $this->objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path);
+            }
+        }else{
+            return "";
+        }
+    }
+
+    // リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける
+    function lfGetAddSuffix($to_key){
+        if( IMAGE_RENAME === true ){ return ; }
+
+        // 自動生成される画像名
+        $dist_name = "";
+        switch($to_key){
+            case "main_list_image":
+                $dist_name = '_s';
+                break;
+            case "main_image":
+                $dist_name = '_m';
+                break;
+            default;
+                $arrRet = explode('sub_image', $to_key);
+                $dist_name = '_sub' .$arrRet[1];
+                break;
+        }
+        return $dist_name;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_Trackback.php
===================================================================
--- branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_Trackback.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_Trackback.php	(revision 18176)
@@ -0,0 +1,275 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
+
+/**
+ * トラックバック管理 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Products_Trackback extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'products/trackback.tpl';
+        $this->tpl_subnavi = 'products/subnavi.tpl';
+        $this->tpl_mainno = 'products';
+        $this->tpl_subno = 'trackback';
+        $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
+        $this->tpl_subtitle = 'トラックバック管理';
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrPageMax = $masterData->getMasterData("mtb_page_max");
+        $this->arrTrackBackStatus = $masterData->getMasterData("mtb_track_back_status");
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_AdminView();
+        $objSess = new SC_Session();
+        $objDate = new SC_Date();
+        $objQuery = new SC_Query();
+
+        // 状態の設定
+
+
+        // 登録・更新検索開始年
+        $objDate->setStartYear(RELEASE_YEAR);
+        $objDate->setEndYear(DATE("Y"));
+        $this->arrStartYear = $objDate->getYear();
+        $this->arrStartMonth = $objDate->getMonth();
+        $this->arrStartDay = $objDate->getDay();
+        // 登録・更新検索終了年
+        $objDate->setStartYear(RELEASE_YEAR);
+        $objDate->setEndYear(DATE("Y"));
+        $this->arrEndYear = $objDate->getYear();
+        $this->arrEndMonth = $objDate->getMonth();
+        $this->arrEndDay = $objDate->getDay();
+
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        // トラックバック情報のカラムの取得(viewとの結合のため、テーブルをAと定義しておく)
+        $select = "A.trackback_id, A.product_id, A.blog_name, A.title, A.url, ";
+        $select .= "A.excerpt, A.status, A.create_date, A.update_date, B.name";
+        $from = "dtb_trackback AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
+
+        // 検索ワードの引き継ぎ
+        foreach ($_POST as $key => $val) {
+            if (ereg("^search_", $key)) {
+                $this->arrHidden[$key] = $val;
+            }
+        }
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        // トラックバックの削除
+        if ($_POST['mode'] == "delete") {
+            $objQuery->exec("UPDATE dtb_trackback SET del_flg = 1, update_date = now() WHERE trackback_id = ?", array($_POST['trackback_id']));
+        }
+
+        if ($_POST['mode'] == 'search' || $_POST['mode'] == 'csv' || $_POST['mode'] == 'delete'){
+
+            //削除されていない商品を検索
+            $where="A.del_flg = 0 AND B.del_flg = 0";
+            $this->arrForm = $_POST;
+
+            //エラーチェック
+            $this->arrErr = $this->lfCheckError();
+
+            if (!$this->arrErr) {
+                foreach ($_POST as $key => $val) {
+
+                    $val = SC_Utils_Ex::sfManualEscape($val);
+
+                    if ($val == "") {
+                        continue;
+                    }
+
+                    switch ($key) {
+
+                    case 'search_blog_name':
+                        $val = ereg_replace(" ", "%", $val);
+                        $val = ereg_replace("　", "%", $val);
+                        $where.= " AND A.blog_name ILIKE ? ";
+                        $arrval[] = "%$val%";
+                        break;
+
+                    case 'search_blog_title':
+                        $val = ereg_replace(" ", "%", $val);
+                        $val = ereg_replace("　", "%", $val);
+                        $where.= " AND A.title ILIKE ? ";
+                        $arrval[] = "%$val%";
+                        break;
+
+                    case 'search_blog_url':
+                        $val = ereg_replace(" ", "%", $val);
+                        $val = ereg_replace("　", "%", $val);
+                        $where.= " AND A.url ILIKE ? ";
+                        $arrval[] = "%$val%";
+                        break;
+
+                    case 'search_status':
+                        if (isset($_POST['search_status'])) {
+                            $where.= " AND A.status = ? ";
+                            $arrval[] = $val;
+                        }
+                        break;
+
+                    case 'search_name':
+                        $val = ereg_replace(" ", "%", $val);
+                        $val = ereg_replace("　", "%", $val);
+                        $where.= " AND B.name ILIKE ? ";
+                        $arrval[] = "%$val%";
+                        break;
+
+                    case 'search_product_code':
+                        $val = ereg_replace(" ", "%", $val);
+                        $val = ereg_replace("　", "%", $val);
+                        $where.= " AND B.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? )";
+                        $arrval[] = "%$val%";
+                        break;
+
+                    case 'search_startyear':
+                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
+                            $date = sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
+                            $where.= " AND A.create_date >= ? ";
+                            $arrval[] = $date;
+                        }
+                        break;
+
+                    case 'search_endyear':
+                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
+                            $date = sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
+
+                            $end_date = date("Y/m/d",strtotime("1 day" ,strtotime($date)));
+
+                            $where.= " AND A.create_date <= cast('$end_date' as date) ";
+                        }
+                        break;
+                    }
+
+                }
+
+            }
+
+            $order = "A.create_date DESC";
+
+            // ページ送りの処理
+            if(is_numeric($_POST['search_page_max'])) {
+                $page_max = $_POST['search_page_max'];
+            } else {
+                $page_max = SEARCH_PMAX;
+            }
+
+            if (!isset($arrval)) $arrval = array();
+
+            $linemax = $objQuery->count($from, $where, $arrval);
+            $this->tpl_linemax = $linemax;
+
+            $this->tpl_pageno =
+                isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
+
+            // ページ送りの取得
+            $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $page_max,
+                                       "fnNaviSearchPage", NAVI_PMAX);
+            $this->arrPagenavi = $objNavi->arrPagenavi;
+            $startno = $objNavi->start_row;
+
+
+
+            // 取得範囲の指定(開始行番号、行数のセット)
+            $objQuery->setlimitoffset($page_max, $startno);
+
+            // 表示順序
+            $objQuery->setorder($order);
+
+            //検索結果の取得
+            $this->arrTrackback = $objQuery->select($select, $from, $where, $arrval);
+
+            //CSVダウンロード
+            if ($_POST['mode'] == 'csv'){
+
+                $objCSV = new SC_Helper_CSV_Ex();
+
+                // オプションの指定
+                $option = "ORDER BY A.trackback_id";
+                // CSV出力タイトル行の作成
+                $head = SC_Utils_Ex::sfGetCSVList($objCSV->arrTRACKBACK_CVSTITLE);
+                $data = $objCSV->lfGetTrackbackCSV($where, '', $arrval);
+                // CSVを送信する。
+                SC_Utils_Ex::sfCSVDownload($head.$data);
+                exit;
+            }
+        }
+
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    // 入力エラーチェック
+    function lfCheckError() {
+        $objErr = new SC_CheckError();
+        switch ($_POST['mode']){
+        case 'search':
+            $objErr->doFunc(array("投稿者", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
+            $objErr->doFunc(array("開始日", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
+            $objErr->doFunc(array("終了日", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE"));
+            $objErr->doFunc(array("開始日", "終了日", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM"));
+            break;
+
+        case 'complete':
+            $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
+            $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+            $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+            break;
+        }
+        return $objErr->arrErr;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php
===================================================================
--- branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php	(revision 18176)
@@ -0,0 +1,202 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * レビュー編集 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Products_ReviewEdit extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'products/review_edit.tpl';
+        $this->tpl_subnavi = 'products/subnavi.tpl';
+        $this->tpl_mainno = 'products';
+        $this->tpl_subno = 'review';
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
+        $this->tpl_subtitle = 'レビュー管理';
+        $this->arrSex = $masterData->getMasterData("mtb_sex");
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_AdminView();
+        $objSess = new SC_Session();
+        $this->objQuery = new SC_Query();
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        //検索ワードの引継ぎ
+        foreach ($_POST as $key => $val){
+            if (ereg("^search_", $key)){
+                $this->arrSearchHidden[$key] = $val;
+            }
+        }
+
+        //取得文字列の変換用カラム
+        $arrRegistColumn = array (
+                                  array( "column" => "update_date"),
+                                  array( "column" => "status"),
+                                  array( "column" => "recommend_level"),
+                                  array(	"column" => "title","convert" => "KVa"),
+                                  array(	"column" => "comment","convert" => "KVa"),
+                                  array(	"column" => "reviewer_name","convert" => "KVa"),
+                                  array(	"column" => "reviewer_url","convert" => "KVa"),
+                                  array(	"column" => "sex","convert" => "n")
+
+                                  );
+
+        //レビューIDを渡す
+        $this->tpl_review_id = isset($_POST['review_id']) ? $_POST['review_id'] : "";
+        //レビュー情報のカラムの取得
+        $this->arrReview = $this->lfGetReviewData($this->tpl_review_id);
+        //登録済みのステータスを渡す
+        $this->tpl_pre_status = $this->arrReview['status'];
+        //商品ごとのレビュー表示数取得
+        $count = $this->objQuery->count("dtb_review", "del_flg=0 AND status=1 AND product_id=?", array($this->arrReview['product_id']));
+        //両方選択可能
+        $this->tpl_status_change = true;
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+        switch($_POST['mode']) {
+            //登録
+        case 'complete':
+            //フォーム値の変換
+            $arrReview = $this->lfConvertParam($_POST, $arrRegistColumn);
+            $this->arrErr = $this->lfCheckError($arrReview);
+            //エラー無し
+            if (!$this->arrErr){
+                //レビュー情報の編集登録
+                $this->lfRegistReviewData($arrReview, $arrRegistColumn);
+                $this->arrReview = $arrReview;
+                $this->tpl_onload = "confirm('登録が完了しました。');";
+            }
+            break;
+        default:
+            break;
+        }
+
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+
+    // 入力エラーチェック
+    function lfCheckError($array) {
+        $objErr = new SC_CheckError($array);
+        $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
+        $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("投稿者名", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("ホームページアドレス", "reviewer_url", URL_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objErr->doFunc(array("性別", "sex", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        return $objErr->arrErr;
+    }
+
+    //----　取得文字列の変換
+    function lfConvertParam($array, $arrRegistColumn) {
+        /*
+         *	文字列の変換
+         *	K :  「半角(ﾊﾝｶｸ)片仮名」を「全角片仮名」に変換
+         *	C :  「全角ひら仮名」を「全角かた仮名」に変換
+         *	V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
+         *	n :  「全角」数字を「半角(ﾊﾝｶｸ)」に変換
+         *  a :  全角英数字を半角英数字に変換する
+         */
+        // カラム名とコンバート情報
+        foreach ($arrRegistColumn as $data) {
+            $arrConvList[ $data["column"] ] = isset($data["convert"])
+                ? $data["convert"] : "";
+        }
+
+        // 文字変換
+        foreach ($arrConvList as $key => $val) {
+            // POSTされてきた値のみ変換する。
+            if(strlen(($array[$key])) > 0) {
+                $array[$key] = mb_convert_kana($array[$key] ,$val);
+            }
+        }
+        return $array;
+    }
+
+    //レビュー情報の取得
+    function lfGetReviewData($review_id){
+        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
+        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
+        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
+        $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ";
+        $arrReview = $this->objQuery->select($select, $from, $where, array($review_id));
+        if(!empty($arrReview)) {
+            $this->arrReview = $arrReview[0];
+        } else {
+            SC_Utils_Ex::sfDispError("");
+        }
+        return $this->arrReview;
+    }
+
+    //レビュー情報の編集登録
+    function lfRegistReviewData($array, $arrRegistColumn){
+        foreach ($arrRegistColumn as $data) {
+            if (strlen($array[ $data["column"] ]) > 0 ) {
+                $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
+            }
+            if ($data['column'] == 'update_date'){
+                $arrRegist['update_date'] = 'now()';
+            }
+        }
+        //登録実行
+        $this->objQuery->begin();
+        $this->objQuery->update("dtb_review", $arrRegist, "review_id='".$_POST['review_id']."'");
+        $this->objQuery->commit();
+    }
+}
+?>
Index: branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php
===================================================================
--- branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php	(revision 18176)
@@ -0,0 +1,779 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/* GMO決済モジュール連携用 */
+if (file_exists(MODULE_PATH . 'mdl_gmopg/inc/include.php') === TRUE) {
+  require_once(MODULE_PATH . 'mdl_gmopg/inc/include.php');
+}
+
+/* ペイジェント決済モジュール連携用 */
+if (file_exists(MODULE_PATH . 'mdl_paygent/include.php') === TRUE) {
+    require_once(MODULE_PATH . 'mdl_paygent/include.php');
+}
+
+/* F-REGI決済モジュール連携用 */
+if (file_exists(MODULE_PATH. 'mdl_fregi/LC_Page_Mdl_Fregi_Config.php') === TRUE) {
+    require_once(MODULE_PATH. 'mdl_fregi/LC_Page_Mdl_Fregi_Config.php');
+}
+
+/* SPS決済モジュール連携用 */
+if (file_exists(MODULE_PATH . 'mdl_sps/request.php') === TRUE) {
+    require_once(MODULE_PATH . 'mdl_sps/request.php');
+}
+
+
+/**
+ * 受注修正 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Order_Edit extends LC_Page {
+
+    // {{{ properties
+
+    /** 表示モード */
+    var $disp_mode;
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'order/edit.tpl';
+        $this->tpl_subnavi = 'order/subnavi.tpl';
+        $this->tpl_mainno = 'order';
+        $this->tpl_subno = 'index';
+        $this->tpl_subtitle = '受注管理';
+        if (empty($_GET['order_id']) && empty($_POST['order_id'])) {
+            $this->tpl_subno = 'add';
+            $this->tpl_mode = 'add';
+            $this->tpl_subtitle = '新規受注入力';
+        }
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrPref = $masterData->getMasterData("mtb_pref",
+                                 array("pref_id", "pref_name", "rank"));
+        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
+
+        /* ペイジェント決済モジュール連携用 */
+        if(function_exists("sfPaygentOrderPage")) {
+            $this->arrFormKind = sfPaygentOrderPage();
+        }
+
+        /* F-REGI決済モジュール連携用 */
+        if (file_exists(MODULE_PATH. 'mdl_fregi/LC_Page_Mdl_Fregi_Config.php') === TRUE) {
+            global $arrFregiPayment;
+            $this->arrFregiPayment = $arrFregiPayment;
+            global $arrFregiDispKind;
+            $this->arrFregiDispKind = $arrFregiDispKind;
+        }
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $conn = new SC_DBConn();
+        $objView = new SC_AdminView();
+        $objSess = new SC_Session();
+        $objSiteInfo = new SC_SiteInfo();
+        $objDb = new SC_Helper_DB_Ex();
+        $arrInfo = $objSiteInfo->data;
+
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        // 検索パラメータの引き継ぎ
+        foreach ($_POST as $key => $val) {
+            if (ereg("^search_", $key)) {
+                $this->arrSearchHidden[$key] = $val;
+            }
+        }
+
+        // 表示モード判定
+        if(isset($_GET['order_id']) &&
+            SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
+            $this->disp_mode = true;
+            $order_id = $_GET['order_id'];
+        } else {
+            $order_id = $_POST['order_id'];
+        }
+        $this->tpl_order_id = $order_id;
+
+        // DBから受注情報を読み込む
+        $this->lfGetOrderData($order_id);
+
+        switch($_POST['mode']) {
+        case 'pre_edit':
+        case 'order_id':
+            break;
+        case 'edit':
+        case 'add':
+            // POST情報で上書き
+            $this->objFormParam->setParam($_POST);
+
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError();
+            $this->arrErr = array_merge( (array) $this->arrErr, (array)$this->lfCheek($arrInfo, $_POST['mode']) );
+
+            if(count($this->arrErr) == 0) {
+                if ($_POST['mode'] == 'add') {
+                    $order_id = $this->lfRegistNewData();
+
+                    $this->tpl_order_id = $order_id;
+                    $this->tpl_mode = 'edit';
+
+                    $arrData['order_id'] = $order_id;
+                    $this->objFormParam->setParam($arrData);
+
+                    $text = "'新規受注を登録しました。'";
+                } else {
+                    $this->lfRegistData($_POST['order_id']);
+                    $text = "'受注履歴を編集しました。'";
+                }
+                // DBから受注情報を再読込
+                $this->lfGetOrderData($order_id);
+                $this->tpl_onload = "window.alert(".$text.");";
+            }
+            break;
+            // 再計算
+        case 'cheek':
+            // POST情報で上書き
+            $this->objFormParam->setParam($_POST);
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError();
+            if(count($this->arrErr) == 0) {
+                $this->arrErr = $this->lfCheek($arrInfo, $_POST['mode']);
+            }
+            break;
+        /* ペイジェント決済モジュール連携用 */
+        case 'paygent_order':
+            $this->paygent_return = sfPaygentOrder($_POST['paygent_type'], $order_id);
+            break;
+        /* 商品削除*/
+        case 'delete_product':
+            $delete_no = $_POST['delete_no'];
+            foreach ($_POST AS $key=>$val) {
+                if (is_array($val)) {
+                    foreach ($val AS $k=>$v) {
+                        if ($k != $delete_no) {
+                            $arrData[$key][] = $v;
+                        }
+                    }
+                } else {
+                    $arrData[$key] = $val;
+                }
+            }
+            // 情報上書き
+            $this->objFormParam->setParam($arrData);
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError();
+            if(count($this->arrErr) == 0) {
+                $this->arrErr = $this->lfCheek($arrInfo, $_POST['mode']);
+            }
+            break;
+        /* 商品追加ポップアップより商品選択後、商品情報取得*/
+        case 'select_product_detail':
+            // POST情報で上書き
+            $this->objFormParam->setParam($_POST);
+            if (!empty($_POST['add_product_id'])) {
+                $this->lfInsertProduct($_POST['add_product_id'], $_POST['add_classcategory_id1'], $_POST['add_classcategory_id2']);
+            } elseif (!empty($_POST['edit_product_id'])) {
+                $this->lfUpdateProduct($_POST['edit_product_id'], $_POST['edit_classcategory_id1'], $_POST['edit_classcategory_id2'], $_POST['no']);
+            }
+            $arrData = $_POST;
+            foreach ($this->arrForm AS $key=>$val) {
+                if (is_array($val)) {
+                    $arrData[$key] = $this->arrForm[$key]['value'];
+                } else {
+                    $arrData[$key] = $val;
+                }
+            }
+            // 情報上書き
+            $this->objFormParam->setParam($arrData);
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError();
+            if(count($this->arrErr) == 0) {
+                $this->arrErr = $this->lfCheek($arrInfo, $_POST['mode']);
+            }
+            break;
+        /* 顧客検索ポップアップより顧客指定後、顧客情報取得*/
+        case 'search_customer':
+            // POST情報で上書き
+            $this->objFormParam->setParam($_POST);
+
+            // 検索結果から顧客IDを指定された場合、顧客情報をフォームに代入する
+            $this->lfSetCustomerInfo($_POST['edit_customer_id']);
+
+            break;
+        /* F-REGI決済モジュール連携用 */
+        case 'fregi_status':
+            $objFregiConfig = new LC_Page_Mdl_Fregi_Config();
+            $this->fregi_err = $objFregiConfig->getSaleInfo($order_id, $this->arrDisp);
+            $this->lfGetOrderData($order_id);
+            break;
+        case 'fregi_card':
+            $objFregiConfig = new LC_Page_Mdl_Fregi_Config();
+            $this->fregi_card_err = $objFregiConfig->setCardInfo($_POST['card_status'], $order_id, $this->arrDisp);
+            $this->lfGetOrderData($order_id);
+            break;
+        /* SPS決済モジュール連携用 */
+        case 'sps_request':
+            $objErr = new SC_CheckError($_POST);
+            $objErr->doFunc(array("年","sps_year"), array('EXIST_CHECK'));
+            $objErr->doFunc(array("月","sps_month"), array('EXIST_CHECK'));
+            $objErr->doFunc(array("日","sps_date"), array('EXIST_CHECK'));
+            $objErr->doFunc(array("売上・返金日", "sps_year", "sps_month", "sps_date"), array("CHECK_DATE"));
+            if ($objErr->arrErr) {
+                $this->arrErr = $objErr->arrErr;
+                break;
+            }
+            $sps_return = sfSpsRequest( $order_id, $_POST['request_type'] );
+            // DBから受注情報を再読込
+            $this->lfGetOrderData($order_id);
+            $this->tpl_onload = "window.alert('".$sps_return."');";
+            break;
+
+        /* GMOPG連携用 */
+        case 'gmopg_order_edit':
+            require_once(MODULE_PATH . 'mdl_gmopg/class/LC_Mdl_GMOPG_OrderEdit.php');
+            $objGMOOrderEdit = new LC_MDL_GMOPG_OrderEdit;
+            $this->gmopg_order_edit_result = $objGMOOrderEdit->proccess();
+            $this->lfGetOrderData($order_id);
+            break;
+        default:
+            break;
+        }
+
+        // 支払い方法の取得
+        $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
+        // 配送時間の取得
+        $arrRet = $objDb->sfGetDelivTime($this->objFormParam->getValue('payment_id'));
+        $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
+
+        $this->arrForm = $this->objFormParam->getFormParamList();
+        $this->product_count = count($this->arrForm['quantity']['value']);
+
+        // アンカーを設定
+        if (isset($_POST['anchor_key']) && !empty($_POST['anchor_key'])) {
+            $anchor_hash = "location.hash='#" . $_POST['anchor_key'] . "'";
+        } else {
+            $anchor_hash = "";
+        }
+        $this->tpl_onload .= $anchor_hash;
+
+        $this->arrInfo = $arrInfo;
+
+        /**
+         * SPS決済 クレジット判定用処理
+         */
+        if (file_exists(MODULE_PATH . 'mdl_sps/request.php') === TRUE) {
+            $objQuery = new SC_Query();
+            $this->paymentType = $objQuery->getall("SELECT module_code, memo03 FROM dtb_payment WHERE payment_id = ? ", array($this->arrForm["payment_id"]['value']));
+            $objDate = new SC_Date();
+            $objDate->setStartYear(RELEASE_YEAR);
+            $this->arrYear = $objDate->getYear();
+            $this->arrMonth = $objDate->getMonth();
+            $this->arrDay = $objDate->getDay();
+        }
+
+        $objView->assignobj($this);
+        // 表示モード判定
+        if(!$this->disp_mode) {
+            $objView->display(MAIN_FRAME);
+        } else {
+            $objView->display('order/disp.tpl');
+        }
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* パラメータ情報の初期化 */
+    function lfInitParam() {
+
+        // お客様情報
+        $this->objFormParam->addParam("顧客名1", "order_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("顧客名2", "order_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("顧客名カナ1", "order_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("顧客名カナ2", "order_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("メールアドレス", "order_email", MTEXT_LEN, "KVCa", array("EXIST_CHECK", "NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("郵便番号1", "order_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $this->objFormParam->addParam("郵便番号2", "order_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $this->objFormParam->addParam("都道府県", "order_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("住所1", "order_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("住所2", "order_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("電話番号1", "order_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+        $this->objFormParam->addParam("電話番号2", "order_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+        $this->objFormParam->addParam("電話番号3", "order_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+
+        // 配送先情報
+        $this->objFormParam->addParam("お名前1", "deliv_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("お名前2", "deliv_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("フリガナ1", "deliv_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("フリガナ2", "deliv_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("郵便番号1", "deliv_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $this->objFormParam->addParam("郵便番号2", "deliv_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
+        $this->objFormParam->addParam("都道府県", "deliv_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("住所1", "deliv_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("住所2", "deliv_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("電話番号1", "deliv_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+        $this->objFormParam->addParam("電話番号2", "deliv_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+        $this->objFormParam->addParam("電話番号3", "deliv_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
+
+
+        // 受注商品情報
+        $this->objFormParam->addParam("値引き", "discount", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
+        $this->objFormParam->addParam("送料", "deliv_fee", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("手数料", "charge", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+
+        // ポイント機能ON時のみ
+        if( USE_POINT === true ){
+            $this->objFormParam->addParam("利用ポイント", "use_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        }
+
+        $this->objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("配送時間ID", "deliv_time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("対応状況", "status", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("配達日", "deliv_date", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("お支払方法名称", "payment_method");
+        $this->objFormParam->addParam("配送時間", "deliv_time");
+
+        // 受注詳細情報
+        $this->objFormParam->addParam("単価", "price", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
+        $this->objFormParam->addParam("個数", "quantity", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
+        $this->objFormParam->addParam("商品ID", "product_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
+        $this->objFormParam->addParam("ポイント付与率", "point_rate");
+        $this->objFormParam->addParam("商品コード", "product_code");
+        $this->objFormParam->addParam("商品名", "product_name");
+        $this->objFormParam->addParam("規格1", "classcategory_id1");
+        $this->objFormParam->addParam("規格2", "classcategory_id2");
+        $this->objFormParam->addParam("規格名1", "classcategory_name1");
+        $this->objFormParam->addParam("規格名2", "classcategory_name2");
+        $this->objFormParam->addParam("メモ", "note", MTEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        // DB読込用
+        $this->objFormParam->addParam("小計", "subtotal");
+        $this->objFormParam->addParam("合計", "total");
+        $this->objFormParam->addParam("支払い合計", "payment_total");
+        $this->objFormParam->addParam("加算ポイント", "add_point");
+        $this->objFormParam->addParam("お誕生日ポイント", "birth_point");
+        $this->objFormParam->addParam("消費税合計", "tax");
+        $this->objFormParam->addParam("最終保持ポイント", "total_point");
+        $this->objFormParam->addParam("顧客ID", "customer_id");
+        $this->objFormParam->addParam("現在のポイント", "point");
+        $this->objFormParam->addParam("受注番号", "order_id");
+        $this->objFormParam->addParam("受注日", "create_date");
+        $this->objFormParam->addParam("発送日", "commit_date");
+    }
+
+    function lfGetOrderData($order_id) {
+        if(SC_Utils_Ex::sfIsInt($order_id)) {
+            // DBから受注情報を読み込む
+            $objQuery = new SC_Query();
+            $objDb = new SC_Helper_DB_Ex();
+            $where = "order_id = ?";
+            $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
+            $this->objFormParam->setParam($arrRet[0]);
+            list($point, $total_point) = $objDb->sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
+            $this->objFormParam->setValue('total_point', $total_point);
+            $this->objFormParam->setValue('point', $point);
+            $this->arrForm = $arrRet[0];
+            // 受注詳細データの取得
+            $arrRet = $this->lfGetOrderDetail($order_id);
+            $arrRet = SC_Utils_Ex::sfSwapArray($arrRet);
+            $this->arrForm = array_merge($this->arrForm, $arrRet);
+            $this->objFormParam->setParam($arrRet);
+
+            // その他支払い情報を表示
+            if($this->arrForm["memo02"] != "") $this->arrForm["payment_info"] = unserialize($this->arrForm["memo02"]);
+            if($this->arrForm["memo01"] == PAYMENT_CREDIT_ID){
+                $this->arrForm["payment_type"] = "クレジット決済";
+            }elseif($this->arrForm["memo01"] == PAYMENT_CONVENIENCE_ID){
+                $this->arrForm["payment_type"] = "コンビニ決済";
+            }else{
+                $this->arrForm["payment_type"] = "お支払い";
+            }
+        }
+    }
+
+    // 受注詳細データの取得
+    function lfGetOrderDetail($order_id) {
+        $objQuery = new SC_Query();
+        $col = "product_id, classcategory_id1, classcategory_id2, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate";
+        $where = "order_id = ?";
+        $objQuery->setorder("classcategory_id1, classcategory_id2");
+        $arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id));
+        return $arrRet;
+    }
+
+    /* 入力内容のチェック */
+    function lfCheckError() {
+        // 入力データを渡す。
+        $arrRet =  $this->objFormParam->getHashArray();
+        $objErr = new SC_CheckError($arrRet);
+        $objErr->arrErr = $this->objFormParam->checkError();
+
+        return $objErr->arrErr;
+    }
+
+    /* 計算処理 */
+    function lfCheek($arrInfo,$mode = "") {
+        $objDb = new SC_Helper_DB_Ex();
+        $arrVal = $this->objFormParam->getHashArray();
+        $arrErr = array();
+
+        // 商品の種類数
+        $max = count($arrVal['quantity']);
+        $subtotal = 0;
+        $totalpoint = 0;
+        $totaltax = 0;
+        for($i = 0; $i < $max; $i++) {
+            // 小計の計算
+            $subtotal += SC_Utils_Ex::sfPreTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i];
+            // 小計の計算
+            $totaltax += SC_Utils_Ex::sfTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i];
+            // 加算ポイントの計算
+            $totalpoint += SC_Utils_Ex::sfPrePoint($arrVal['price'][$i], $arrVal['point_rate'][$i]) * $arrVal['quantity'][$i];
+        }
+
+        // 消費税
+        $arrVal['tax'] = $totaltax;
+        // 小計
+        $arrVal['subtotal'] = $subtotal;
+        // 合計
+        $arrVal['total'] = $subtotal - $arrVal['discount'] + $arrVal['deliv_fee'] + $arrVal['charge'];
+        // お支払い合計
+        $arrVal['payment_total'] = $arrVal['total'] - ($arrVal['use_point'] * POINT_VALUE);
+
+        // 加算ポイント
+        $arrVal['add_point'] = SC_Utils_Ex::sfGetAddPoint($totalpoint, $arrVal['use_point'], $arrInfo);
+
+        if (strlen($_POST['customer_id']) >0){
+            list($arrVal['point'], $arrVal['total_point']) = $objDb->sfGetCustomerPointFromCid($_POST['customer_id'], $arrVal['use_point'], $arrVal['add_point']);
+        }else{
+            list($arrVal['point'], $arrVal['total_point']) = $objDb->sfGetCustomerPoint($_POST['order_id'], $arrVal['use_point'], $arrVal['add_point']);
+        }
+        if($arrVal['total'] < 0) {
+            $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />';
+        }
+
+        if($arrVal['payment_total'] < 0) {
+            $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />';
+        }
+        //新規追加受注のみ
+        if ($mode == "add"){
+            if($arrVal['total_point'] < 0) {
+                $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />';
+            }
+        }
+
+        $this->objFormParam->setParam($arrVal);
+        return $arrErr;
+    }
+
+    function lfReCheek($arrData, $arrInfo) {
+        // 情報上書き
+        $this->objFormParam->setParam($arrData);
+        // 入力値の変換
+        $this->objFormParam->convParam();
+        #if(count($this->arrErr) == 0) {
+            $this->arrErr = $this->lfCheek($arrInfo);
+        #}
+    }
+    /* DB登録処理 */
+    function lfRegistData($order_id) {
+        $objQuery = new SC_Query();
+
+        $objQuery->begin();
+
+        // 入力データを渡す。
+        $arrRet =  $this->objFormParam->getHashArray();
+        foreach($arrRet as $key => $val) {
+            // 配列は登録しない
+            if(!is_array($val)) {
+                $sqlval[$key] = $val;
+            }
+        }
+
+        unset($sqlval['total_point']);
+        unset($sqlval['point']);
+
+        $where = "order_id = ?";
+
+        /*
+         * XXX 本来なら配列だが, update 関数を string として
+         *     チェックしているため...
+         */
+        if (!isset($addcol)) $addcol = "";
+
+        // 受注テーブルの更新
+        $objQuery->update("dtb_order", $sqlval, $where, array($order_id), $addcol);
+
+        $sql = "";
+        $sql .= " UPDATE";
+        $sql .= "     dtb_order";
+        $sql .= " SET";
+        $sql .= "     payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = ?)";
+        $sql .= "     ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = ? AND deliv_id = (SELECT deliv_id FROM dtb_payment WHERE payment_id = ? ))";
+        // 受注ステータスの判定
+        if ($sqlval['status'] == ODERSTATUS_COMMIT) {
+            // 受注テーブルの発送済み日を更新する
+            $sql .= "     ,commit_date = 'NOW()'";
+        }
+        $sql .= " WHERE order_id = ?";
+
+        if ($arrRet['deliv_time_id'] == "") {
+            $deliv_time_id = 0;
+        }else{
+            $deliv_time_id = $arrRet['deliv_time_id'];
+        }
+        $arrUpdData = array($arrRet['payment_id'], $deliv_time_id, $arrRet['payment_id'], $order_id);
+        $objQuery->query($sql, $arrUpdData);
+
+        // 受注詳細データの更新
+        $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2"));
+        $objQuery->delete("dtb_order_detail", $where, array($order_id));
+
+
+        $max = count($arrDetail);
+        for($i = 0; $i < $max; $i++) {
+            $sqlval = array();
+            $sqlval['order_id'] = $order_id;
+            $sqlval['product_id']  = $arrDetail[$i]['product_id'];
+            $sqlval['product_code']  = $arrDetail[$i]['product_code'];
+            $sqlval['product_name']  = $arrDetail[$i]['product_name'];
+            $sqlval['price']  = $arrDetail[$i]['price'];
+            $sqlval['quantity']  = $arrDetail[$i]['quantity'];
+            $sqlval['point_rate']  = $arrDetail[$i]['point_rate'];
+            $sqlval['classcategory_id1'] = $arrDetail[$i]['classcategory_id1'];
+            $sqlval['classcategory_id2'] = $arrDetail[$i]['classcategory_id2'];
+            $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1'];
+            $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2'];
+            $objQuery->insert("dtb_order_detail", $sqlval);
+        }
+
+
+        $objQuery->commit();
+    }
+
+    /* DB登録処理(追加) */
+    function lfRegistNewData() {
+        $objQuery = new SC_Query();
+
+        $objQuery->begin();
+
+        // 入力データを渡す。
+        $arrRet =  $this->objFormParam->getHashArray();
+        foreach($arrRet as $key => $val) {
+            // 配列は登録しない
+            if(!is_array($val)) {
+                $sqlval[$key] = $val;
+            }
+        }
+
+        // postgresqlとmysqlとで処理を分ける
+        if (DB_TYPE == "pgsql") {
+            $order_id = $objQuery->nextval("dtb_order","order_id");
+        }elseif (DB_TYPE == "mysql") {
+            $order_id = $objQuery->get_auto_increment("dtb_order");
+        }
+
+        $sqlval['order_id'] = $order_id;
+        $sqlval['create_date'] = "Now()";
+
+        // 注文ステータス:指定が無ければ新規受付に設定
+        if($sqlval["status"] == ""){
+            $sqlval['status'] = '1';
+        }
+
+        // customer_id
+        if($sqlval["customer_id"] == ""){
+            $sqlval['customer_id'] = '0';
+        }
+
+        unset($sqlval['total_point']);
+        unset($sqlval['point']);
+
+        $where = "order_id = ?";
+
+        // 受注ステータスの判定
+        if ($sqlval['status'] == ODERSTATUS_COMMIT) {
+            // 受注テーブルの発送済み日を更新する
+            $sqlval['commit_date'] = "Now()";
+        }
+
+        // 受注テーブルの登録
+        $objQuery->insert("dtb_order", $sqlval);
+
+        $sql = "";
+        $sql .= " UPDATE";
+        $sql .= "     dtb_order";
+        $sql .= " SET";
+        $sql .= "     payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = ?)";
+        $sql .= "     ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = ? AND deliv_id = (SELECT deliv_id FROM dtb_payment WHERE payment_id = ? ))";
+        $sql .= " WHERE order_id = ?";
+
+        if ($arrRet['deliv_time_id'] == "") {
+            $deliv_time_id = 0;
+        } else {
+            $deliv_time_id = $arrRet['deliv_time_id'];
+        }
+        $arrUpdData = array($arrRet['payment_id'], $deliv_time_id, $arrRet['payment_id'], $order_id);
+        $objQuery->query($sql, $arrUpdData);
+
+        // 受注詳細データの更新
+        $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2"));
+        $objQuery->delete("dtb_order_detail", $where, array($order_id));
+
+        $max = count($arrDetail);
+        for($i = 0; $i < $max; $i++) {
+            $sqlval = array();
+            $sqlval['order_id'] = $order_id;
+            $sqlval['product_id']  = $arrDetail[$i]['product_id'];
+            $sqlval['product_code']  = $arrDetail[$i]['product_code'];
+            $sqlval['product_name']  = $arrDetail[$i]['product_name'];
+            $sqlval['price']  = $arrDetail[$i]['price'];
+            $sqlval['quantity']  = $arrDetail[$i]['quantity'];
+            $sqlval['point_rate']  = $arrDetail[$i]['point_rate'];
+            $sqlval['classcategory_id1'] = $arrDetail[$i]['classcategory_id1'];
+            $sqlval['classcategory_id2'] = $arrDetail[$i]['classcategory_id2'];
+            $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1'];
+            $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2'];
+            $objQuery->insert("dtb_order_detail", $sqlval);
+        }
+        $objQuery->commit();
+
+        return $order_id;
+    }
+
+    function lfInsertProduct($product_id, $classcategory_id1, $classcategory_id2) {
+        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2);
+        $this->arrForm = $this->objFormParam->getFormParamList();
+        $this->lfSetProductData($arrProduct);
+    }
+
+    function lfUpdateProduct($product_id, $classcategory_id1, $classcategory_id2, $no) {
+        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2);
+        $this->arrForm = $this->objFormParam->getFormParamList();
+        $this->lfSetProductData($arrProduct, $no);
+    }
+
+    function lfSetProductData($arrProduct, $no = null) {
+        foreach ($arrProduct AS $key=>$val) {
+            if (!is_array($this->arrForm[$key]['value'])) {
+                unset($this->arrForm[$key]['value']);
+            }
+            if ($no === null) {
+                $this->arrForm[$key]['value'][] = $arrProduct[$key];
+            } else {
+                $this->arrForm[$key]['value'][$no] = $arrProduct[$key];
+            }
+        }
+    }
+
+    function lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2) {
+        $objDb = new SC_Helper_DB_Ex();
+        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+        $arrRet = $objDb->sfGetProductsClass(array($product_id, $classcategory_id1, $classcategory_id2));
+
+        $arrProduct['price'] = $arrRet['price02'];
+        $arrProduct['quantity'] = 1;
+        $arrProduct['product_id'] = $arrRet['product_id'];
+        $arrProduct['point_rate'] = $arrRet['point_rate'];
+        $arrProduct['product_code'] = $arrRet['product_code'];
+        $arrProduct['product_name'] = $arrRet['name'];
+        $arrProduct['classcategory_id1'] = $arrRet['classcategory_id1'];
+        $arrProduct['classcategory_id2'] = $arrRet['classcategory_id2'];
+        $arrProduct['classcategory_name1'] = $arrClassCatName[$arrRet['classcategory_id1']];
+        $arrProduct['classcategory_name2'] = $arrClassCatName[$arrRet['classcategory_id2']];
+
+        return $arrProduct;
+    }
+
+    /**
+     * 検索結果から顧客IDを指定された場合、顧客情報をフォームに代入する
+     * @param int $edit_customer_id 顧客ID
+     */
+    function lfSetCustomerInfo($edit_customer_id = ""){
+        // 顧客IDが指定されている場合のみ、処理を実行する
+        if( $edit_customer_id === "" ) return ;
+
+        // 検索で選択された顧客IDが入力されている場合
+        if( is_null($edit_customer_id) === false && 0 < strlen($edit_customer_id) && SC_Utils_Ex::sfIsInt($edit_customer_id) ){
+            $objQuery = new SC_Query();
+
+            // 顧客情報を取得する
+            $arrCustomerInfo = $objQuery->select('*', 'dtb_customer', 'customer_id = ? AND del_flg = 0', array($edit_customer_id));
+
+            // 顧客情報を取得する事が出来たら、テンプレートに値を渡す
+            if( 0 < count($arrCustomerInfo) && is_array($arrCustomerInfo) === true){
+                // カラム名にorder_を付ける(テンプレート側でorder_がついている為
+                foreach($arrCustomerInfo[0] as $index=>$customer_info){
+                    // customer_idにはorder_を付けないようにする
+                    $order_index = ($index == 'customer_id') ? $index : 'order_'.$index;
+                    $arrCustomer[$order_index] = $customer_info;
+                }
+            }
+
+            // hiddenに渡す
+            $this->edit_customer_id = $edit_customer_id;
+
+            // 受注日に現在の時刻を取得し、表示させる
+            $create_date = $objQuery->getall('SELECT now() as create_date;');
+            $arrCustomer['create_date'] = $create_date[0]['create_date'];
+
+            // 情報上書き
+            $this->objFormParam->setParam($arrCustomer);
+            // 入力値の変換
+            $this->objFormParam->convParam();
+        }
+    }
+}
+?>
Index: branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Pdf.php
===================================================================
--- branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Pdf.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Pdf.php	(revision 18176)
@@ -0,0 +1,190 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+require_once(CLASS_PATH . "SC_Fpdf.php");
+
+/**
+ * 帳票出力 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Order_Pdf extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'order/pdf_input.tpl';
+        $this->tpl_subnavi = 'order/subnavi.tpl';
+        $this->tpl_mainno = 'order';
+        $this->tpl_subno = 'pdf';
+        $this->tpl_subtitle = '帳票出力';
+
+        $this->SHORTTEXT_MAX = STEXT_LEN;
+        $this->MIDDLETEXT_MAX = MTEXT_LEN;
+        $this->LONGTEXT_MAX = LTEXT_LEN;
+
+        $this->arrType[0]  = "納品書";
+
+        $this->arrDownload[0] = "ブラウザに開く";
+        $this->arrDownload[1] = "ファイルに保存";
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $conn = new SC_DBConn();
+        $objView = new SC_AdminView();
+        $objDb = new SC_Helper_DB_Ex();
+        $objSess = new SC_Session();
+
+        $objDate = new SC_Date(1901);
+        $objDate->setStartYear(RELEASE_YEAR);
+        $this->arrYear = $objDate->getYear();
+        $this->arrMonth = $objDate->getMonth();
+        $this->arrDay = $objDate->getDay();
+
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        // 画面遷移の正当性チェック用にuniqidを埋め込む
+        $objPage->tpl_uniqid = $objSess->getUniqId();
+
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+        $this->objFormParam->setParam($_POST);
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+        if (!isset($arrRet)) $arrRet = array();
+
+        switch($_POST['mode']) {
+        case "confirm":
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError($arrRet);
+            $arrRet = $this->objFormParam->getHashArray();
+            $this->arrForm = $arrRet;
+            // エラー入力なし
+            if (count($this->arrErr) == 0) {
+                $i = 0;
+                $objFpdf = new SC_Fpdf($arrRet['download'], $arrRet['title']);
+                foreach ( $arrRet['order_id'] AS $key=>$val ) {
+                    $arrPdfData = $arrRet;
+                    $arrPdfData['order_id'] = $val;
+                    $objFpdf->setData($arrPdfData);
+                    ++$i;
+                }
+                $objFpdf->createPdf();
+            }
+            break;
+        default:
+            // タイトルをセット
+            $arrForm['title'] = "お買上げ明細書(納品書)";
+
+            // 今日の日付をセット
+            $arrForm['year']  = date("Y");
+            $arrForm['month'] = date("m");
+            $arrForm['day']   = date("d");
+
+            // メッセージ
+            $arrForm['msg1'] = 'このたびはお買上げいただきありがとうございます。';
+            $arrForm['msg2'] = '下記の内容にて納品させていただきます。';
+            $arrForm['msg3'] = 'ご確認いただきますよう、お願いいたします。';
+
+            // 受注番号があったら、セットする
+            if(SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
+                  $arrForm['order_id'][0] = $_GET['order_id'];
+            } elseif (is_array($_POST['pdf_order_id'])) {
+                    sort($_POST['pdf_order_id']);
+                    foreach ($_POST['pdf_order_id'] AS $key=>$val) {
+                          $arrForm['order_id'][] = $val;
+                    }
+            }
+
+            $this->arrForm = $arrForm;
+            break;
+        }
+
+        $objView->assignobj($this);
+        $objView->display($this->tpl_mainpage);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* パラメータ情報の初期化 */
+    function lfInitParam() {
+        $this->objFormParam->addParam("受注番号", "order_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("発行日", "year", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("発行日", "month", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("発行日", "day", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("帳票の種類", "type", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("ダウンロード方法", "download", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("帳票タイトル", "title", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("帳票メッセージ1行目", "msg1", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("帳票メッセージ2行目", "msg2", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("帳票メッセージ3行目", "msg3", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("備考1行目", "etc1", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("備考2行目", "etc2", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("備考3行目", "etc3", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("ポイント表記", "disp_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
+    }
+
+    /* 入力内容のチェック */
+    function lfCheckError() {
+        // 入力データを渡す。
+        $arrRet =  $this->objFormParam->getHashArray();
+        $objErr = new SC_CheckError($arrRet);
+        $objErr->arrErr = $this->objFormParam->checkError();
+
+        // 特殊項目チェック
+        $objErr->doFunc(array("発行日", "year", "month", "day"), array("CHECK_DATE"));
+
+        return $objErr->arrErr;
+    }
+
+
+}
+
+?>
Index: branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order.php
===================================================================
--- branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order.php	(revision 18176)
@@ -0,0 +1,435 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/* ペイジェント決済モジュール連携用 */
+if (file_exists(MODULE_PATH . 'mdl_paygent/include.php') === TRUE) {
+  require_once(MODULE_PATH . 'mdl_paygent/include.php');
+}
+
+/**
+ * 受注管理 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Order extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'order/index.tpl';
+        $this->tpl_subnavi = 'order/subnavi.tpl';
+        $this->tpl_mainno = 'order';
+        $this->tpl_subno = 'index';
+        $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
+        $this->tpl_subtitle = '受注管理';
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
+        $this->arrORDERSTATUS_COLOR = $masterData->getMasterData("mtb_order_status_color");
+        $this->arrSex = $masterData->getMasterData("mtb_sex");
+        $this->arrPageMax = $masterData->getMasterData("mtb_page_max");
+
+        /* ペイジェント決済モジュール連携用 */
+        if(function_exists("sfPaygentOrderPage")) {
+            $this->arrDispKind = sfPaygentOrderPage();
+        }
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $conn = new SC_DBConn();
+        $objView = new SC_AdminView();
+        $objDb = new SC_Helper_DB_Ex();
+        $objSess = new SC_Session();
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+        $this->objFormParam->setParam($_POST);
+
+        $this->objFormParam->splitParamCheckBoxes('search_order_sex');
+        $this->objFormParam->splitParamCheckBoxes('search_payment_id');
+
+        // 検索ワードの引き継ぎ
+        foreach ($_POST as $key => $val) {
+            if (ereg("^search_", $key)) {
+                switch($key) {
+                case 'search_order_sex':
+                case 'search_payment_id':
+                    $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
+                    break;
+                default:
+                    $this->arrHidden[$key] = $val;
+                    break;
+                }
+            }
+        }
+
+        // ページ送り用
+        $this->arrHidden['search_pageno'] =
+            isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
+
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+        if (!isset($arrRet)) $arrRet = array();
+
+        if($_POST['mode'] == 'delete') {
+            if(SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
+                $objQuery = new SC_Query();
+                $where = "order_id = ?";
+                $sqlval['del_flg'] = '1';
+                $objQuery->update("dtb_order", $sqlval, $where, array($_POST['order_id']));
+            }
+        }
+
+        switch($_POST['mode']) {
+        case 'delete':
+        case 'csv':
+        case 'pdf':
+        case 'delete_all':
+        case 'search':
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError($arrRet);
+            $arrRet = $this->objFormParam->getHashArray();
+            // 入力なし
+            if (count($this->arrErr) == 0) {
+                $where = "del_flg = 0";
+                foreach ($arrRet as $key => $val) {
+                    if($val == "") {
+                        continue;
+                    }
+                    $val = SC_Utils_Ex::sfManualEscape($val);
+
+                    switch ($key) {
+                    case 'search_order_name':
+                        if(DB_TYPE == "pgsql"){
+                            $where .= " AND order_name01||order_name02 ILIKE ?";
+                        }elseif(DB_TYPE == "mysql"){
+                            $where .= " AND concat(order_name01,order_name02) ILIKE ?";
+                        }
+                        $nonsp_val = mb_ereg_replace("[ 　]+","",$val);
+                        $arrval[] = "%$nonsp_val%";
+                        break;
+                    case 'search_order_kana':
+                        if(DB_TYPE == "pgsql"){
+                            $where .= " AND order_kana01||order_kana02 ILIKE ?";
+                        }elseif(DB_TYPE == "mysql"){
+                            $where .= " AND concat(order_kana01,order_kana02) ILIKE ?";
+                        }
+                        $nonsp_val = mb_ereg_replace("[ 　]+","",$val);
+                        $arrval[] = "%$nonsp_val%";
+                        break;
+                    case 'search_order_id1':
+                        $where .= " AND order_id >= ?";
+                        $arrval[] = $val;
+                        break;
+                    case 'search_order_id2':
+                        $where .= " AND order_id <= ?";
+                        $arrval[] = $val;
+                        break;
+                    case 'search_order_sex':
+                        $tmp_where = "";
+                        foreach($val as $element) {
+                            if($element != "") {
+                                if($tmp_where == "") {
+                                    $tmp_where .= " AND (order_sex = ?";
+                                } else {
+                                    $tmp_where .= " OR order_sex = ?";
+                                }
+                                $arrval[] = $element;
+                            }
+                        }
+
+                        if($tmp_where != "") {
+                            $tmp_where .= ")";
+                            $where .= " $tmp_where ";
+                        }
+                        break;
+                    case 'search_order_tel':
+                        if(DB_TYPE == "pgsql"){
+                            $where .= " AND (order_tel01 || order_tel02 || order_tel03) LIKE ?";
+                        }elseif(DB_TYPE == "mysql"){
+                            $where .= " AND concat(order_tel01,order_tel02,order_tel03) LIKE ?";
+                        }
+                        $nonmark_val = ereg_replace("[()-]+","",$val);
+                        $arrval[] = "%$nonmark_val%";
+                        break;
+                    case 'search_order_email':
+                        $where .= " AND order_email ILIKE ?";
+                        $arrval[] = "%$val%";
+                        break;
+                    case 'search_payment_id':
+                        $tmp_where = "";
+                        foreach($val as $element) {
+                            if($element != "") {
+                                if($tmp_where == "") {
+                                    $tmp_where .= " AND (payment_id = ?";
+                                } else {
+                                    $tmp_where .= " OR payment_id = ?";
+                                }
+                                $arrval[] = $element;
+                            }
+                        }
+
+                        if($tmp_where != "") {
+                            $tmp_where .= ")";
+                            $where .= " $tmp_where ";
+                        }
+                        break;
+                    case 'search_total1':
+                        $where .= " AND total >= ?";
+                        $arrval[] = $val;
+                        break;
+                    case 'search_total2':
+                        $where .= " AND total <= ?";
+                        $arrval[] = $val;
+                        break;
+                    case 'search_sorderyear':
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sorderyear'], $_POST['search_sordermonth'], $_POST['search_sorderday']);
+                        $where.= " AND create_date >= ?";
+                        $arrval[] = $date;
+                        break;
+                    case 'search_eorderyear':
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eorderyear'], $_POST['search_eordermonth'], $_POST['search_eorderday']);
+                        $where.= " AND create_date <= ?";
+                        $arrval[] = $date;
+                        break;
+                    case 'search_supdateyear':
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_supdateyear'], $_POST['search_supdatemonth'], $_POST['search_supdateday']);
+                        $where.= " AND update_date >= ?";
+                        $arrval[] = $date;
+                        break;
+                    case 'search_eupdateyear':
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eupdateyear'], $_POST['search_eupdatemonth'], $_POST['search_eupdateday'], true);
+                        $where.= " AND update_date <= ?";
+                        $arrval[] = $date;
+                        break;
+                    case 'search_sbirthyear':
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sbirthyear'], $_POST['search_sbirthmonth'], $_POST['search_sbirthday']);
+                        $where.= " AND order_birth >= ?";
+                        $arrval[] = $date;
+                        break;
+                    case 'search_ebirthyear':
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_ebirthyear'], $_POST['search_ebirthmonth'], $_POST['search_ebirthday'], true);
+                        $where.= " AND order_birth <= ?";
+                        $arrval[] = $date;
+                        break;
+                    case 'search_order_status':
+                        $where.= " AND status = ?";
+                        $arrval[] = $val;
+                        break;
+                    default:
+                        if (!isset($arrval)) $arrval = array();
+                        break;
+                    }
+                }
+
+                $order = "update_date DESC";
+
+                switch($_POST['mode']) {
+                case 'csv':
+
+                    require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
+                    $objCSV = new SC_Helper_CSV_Ex();
+                    // オプションの指定
+                    $option = "ORDER BY $order";
+
+                    // CSV出力タイトル行の作成
+                    $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(3, " WHERE csv_id = 3 AND status = 1"));
+
+                    if (count($arrCsvOutput) <= 0) break;
+
+                    $arrCsvOutputCols = $arrCsvOutput['col'];
+                    $arrCsvOutputTitle = $arrCsvOutput['disp_name'];
+                    $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle);
+                    $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols);
+
+                    // CSVを送信する。
+                    SC_Utils_Ex::sfCSVDownload($head.$data);
+                    exit;
+                    break;
+                case 'pdf':
+                    $objFpdf = new SC_Fpdf(1, '納品書');
+                    $objFpdf->setData($arrRet);
+                    $objFpdf->createPdf();
+                    break;
+                case 'delete_all':
+                    // 検索結果をすべて削除
+                    $sqlval['del_flg'] = 1;
+                    $objQuery = new SC_Query();
+                    $objQuery->update("dtb_order", $sqlval, $where, $arrval);
+                    break;
+                default:
+                    // 読み込む列とテーブルの指定
+                    $col = "*";
+                    $from = "dtb_order";
+
+                    $objQuery = new SC_Query();
+                    // 行数の取得
+                    $linemax = $objQuery->count($from, $where, $arrval);
+                    $this->tpl_linemax = $linemax;               // 何件が該当しました。表示用
+
+                    // ページ送りの処理
+                    if(is_numeric($_POST['search_page_max'])) {
+                        $page_max = $_POST['search_page_max'];
+                    } else {
+                        $page_max = SEARCH_PMAX;
+                    }
+
+                    // ページ送りの取得
+                    $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'],
+                                               $linemax, $page_max,
+                                               "fnNaviSearchPage", NAVI_PMAX);
+                    $startno = $objNavi->start_row;
+                    $this->arrPagenavi = $objNavi->arrPagenavi;
+
+                    // 取得範囲の指定(開始行番号、行数のセット)
+                    $objQuery->setlimitoffset($page_max, $startno);
+                    // 表示順序
+                    $objQuery->setorder($order);
+                    // 検索結果の取得
+                    $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
+                }
+            }
+            break;
+
+        default:
+            break;
+        }
+
+        $objDate = new SC_Date();
+        // 登録・更新日検索用
+        $objDate->setStartYear(RELEASE_YEAR);
+        $objDate->setEndYear(DATE("Y"));
+        $this->arrRegistYear = $objDate->getYear();
+        // 生年月日検索用
+        $objDate->setStartYear(BIRTH_YEAR);
+        $objDate->setEndYear(DATE("Y"));
+        $this->arrBirthYear = $objDate->getYear();
+        // 月日の設定
+        $this->arrMonth = $objDate->getMonth();
+        $this->arrDay = $objDate->getDay();
+
+        // 入力値の取得
+        $this->arrForm = $this->objFormParam->getFormParamList();
+        // 支払い方法の取得
+        $arrRet = $objDb->sfGetPayment();
+        $this->arrPayment = SC_Utils_Ex::sfArrKeyValue($arrRet, 'payment_id', 'payment_method');
+
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* パラメータ情報の初期化 */
+    function lfInitParam() {
+        $this->objFormParam->addParam("受注番号1", "search_order_id1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("受注番号2", "search_order_id2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("対応状況", "search_order_status", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("顧客名", "search_order_name", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("顧客名(カナ)", "search_order_kana", STEXT_LEN, "KVCa", array("KANA_CHECK","MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("性別", "search_order_sex", INT_LEN, "n", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("年齢1", "search_age1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("年齢2", "search_age2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("メールアドレス", "search_order_email", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("TEL", "search_order_tel", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("支払い方法", "search_payment_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("購入金額1", "search_total1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("購入金額2", "search_total2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("表示件数", "search_page_max", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_sorderyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_sordermonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_sorderday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_eorderyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_eordermonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_eorderday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_supdateyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_supdatemonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_supdateday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_eupdateyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_eupdatemonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_eupdateday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_sbirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_sbirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("開始日", "search_sbirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_ebirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_ebirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $this->objFormParam->addParam("終了日", "search_ebirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+    }
+
+    /* 入力内容のチェック */
+    function lfCheckError() {
+        // 入力データを渡す。
+        $arrRet = $this->objFormParam->getHashArray();
+        $objErr = new SC_CheckError($arrRet);
+        $objErr->arrErr = $this->objFormParam->checkError();
+
+        // 特殊項目チェック
+        $objErr->doFunc(array("受注番号1", "受注番号2", "search_order_id1", "search_order_id2"), array("GREATER_CHECK"));
+        $objErr->doFunc(array("年齢1", "年齢2", "search_age1", "search_age2"), array("GREATER_CHECK"));
+        $objErr->doFunc(array("購入金額1", "購入金額2", "search_total1", "search_total2"), array("GREATER_CHECK"));
+        $objErr->doFunc(array("開始日", "search_sorderyear", "search_sordermonth", "search_sorderday"), array("CHECK_DATE"));
+        $objErr->doFunc(array("終了日", "search_eorderyear", "search_eordermonth", "search_eorderday"), array("CHECK_DATE"));
+        $objErr->doFunc(array("開始日", "終了日", "search_sorderyear", "search_sordermonth", "search_sorderday", "search_eorderyear", "search_eordermonth", "search_eorderday"), array("CHECK_SET_TERM"));
+
+        $objErr->doFunc(array("開始日", "search_supdateyear", "search_supdatemonth", "search_supdateday"), array("CHECK_DATE"));
+        $objErr->doFunc(array("終了日", "search_eupdateyear", "search_eupdatemonth", "search_eupdateday"), array("CHECK_DATE"));
+        $objErr->doFunc(array("開始日", "終了日", "search_supdateyear", "search_supdatemonth", "search_supdateday", "search_eupdateyear", "search_eupdatemonth", "search_eupdateday"), array("CHECK_SET_TERM"));
+
+        $objErr->doFunc(array("開始日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday"), array("CHECK_DATE"));
+        $objErr->doFunc(array("終了日", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_DATE"));
+        $objErr->doFunc(array("開始日", "終了日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_SET_TERM"));
+
+        return $objErr->arrErr;
+    }
+
+
+}
+?>
Index: branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php
===================================================================
--- branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php	(revision 18176)
@@ -0,0 +1,174 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 受注メール管理 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Order_Mail extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'order/mail.tpl';
+        $this->tpl_subnavi = 'order/subnavi.tpl';
+        $this->tpl_mainno = 'order';
+        $this->tpl_subno = 'index';
+        $this->tpl_subtitle = '受注管理';
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrMAILTEMPLATE = $masterData->getMasterData("mtb_mail_template");
+
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+
+        $objView = new SC_AdminView();
+        $objSess = new SC_Session();
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        // 検索パラメータの引き継ぎ
+        foreach ($_POST as $key => $val) {
+            if (ereg("^search_", $key)) {
+                $this->arrSearchHidden[$key] = $val;
+            }
+        }
+
+        $this->tpl_order_id = $_POST['order_id'];
+
+        // パラメータ管理クラス
+        $objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam($objFormParam);
+
+        $objMail = new SC_Helper_Mail_Ex();
+
+        switch($_POST['mode']) {
+        case 'pre_edit':
+            break;
+        case 'return':
+            // POST値の取得
+            $objFormParam->setParam($_POST);
+            break;
+        case 'send':
+            // POST値の取得
+            $objFormParam->setParam($_POST);
+            // 入力値の変換
+            $objFormParam->convParam();
+            $this->arrErr = $objFormParam->checkerror();
+            // メールの送信
+            if (count($this->arrErr) == 0) {
+                // 注文受付メール
+                $objMail->sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['header'], $_POST['footer']);
+            }
+            $this->sendRedirect($this->getLocation(URL_SEARCH_ORDER));
+            exit;
+            break;
+        case 'confirm':
+            // POST値の取得
+            $objFormParam->setParam($_POST);
+            // 入力値の変換
+            $objFormParam->convParam();
+            // 入力値の引き継ぎ
+            $this->arrHidden = $objFormParam->getHashArray();
+            $this->arrErr = $objFormParam->checkerror();
+            // メールの送信
+            if (count($this->arrErr) == 0) {
+                // 注文受付メール(送信なし)
+                $objSendMail = $objMail->sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['header'], $_POST['footer'], false);
+                // 確認ページの表示
+                $this->tpl_subject = $_POST['subject'];
+                $this->tpl_body = mb_convert_encoding( $objSendMail->body, CHAR_CODE, "auto" );
+                $this->tpl_to = $objSendMail->tpl_to;
+                $this->tpl_mainpage = 'order/mail_confirm.tpl';
+
+                $objView->assignobj($this);
+                $objView->display(MAIN_FRAME);
+
+                exit;
+            }
+            break;
+        case 'change':
+            // POST値の取得
+            $objFormParam->setValue('template_id', $_POST['template_id']);
+            if(SC_Utils_Ex::sfIsInt($_POST['template_id'])) {
+                $objQuery = new SC_Query();
+                $where = "template_id = ?";
+                $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($_POST['template_id']));
+                $objFormParam->setParam($arrRet[0]);
+            }
+            break;
+        }
+
+        $objQuery = new SC_Query();
+        $col = "send_date, subject, template_id, send_id";
+        $where = "order_id = ?";
+        $objQuery->setorder("send_date DESC");
+
+        if(SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
+            $this->arrMailHistory = $objQuery->select($col, "dtb_mail_history", $where, array($_POST['order_id']));
+        }
+
+        $this->arrForm = $objFormParam->getFormParamList();
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+
+    /* パラメータ情報の初期化 */
+    function lfInitParam(&$objFormParam) {
+
+        $objFormParam->addParam("テンプレート", "template_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
+        $objFormParam->addParam("メールタイトル", "subject", STEXT_LEN, "KVa",  array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
+        $objFormParam->addParam("ヘッダー", "header", LTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
+        $objFormParam->addParam("フッター", "footer", LTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
+    }
+}
+?>
Index: branches/version-2/data/class/pages/admin/contents/LC_Page_Admin_Contents_CsvSql.php
===================================================================
--- branches/version-2/data/class/pages/admin/contents/LC_Page_Admin_Contents_CsvSql.php	(revision 18176)
+++ branches/version-2/data/class/pages/admin/contents/LC_Page_Admin_Contents_CsvSql.php	(revision 18176)
@@ -0,0 +1,416 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * CSV 出力項目設定(高度な設定)のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class LC_Page_Admin_Contents_CsvSql extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'contents/csv_sql.tpl';
+        $this->tpl_subnavi = 'contents/subnavi.tpl';
+        $this->tpl_subno = 'csv';
+        $this->tpl_subno_csv = 'csv_sql';
+        $this->tpl_mainno = "contents";
+        $this->tpl_subtitle = 'CSV出力設定';
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_AdminView();
+        $objDbFactory = SC_DB_DBFactory_Ex::getInstance();
+
+        // 認証可否の判定
+        $objSess = new SC_Session();
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+        if (!isset($_POST['sql_id'])) $_POST['sql_id'] = "";
+        if (!isset($_GET['sql_id'])) $_GET['sql_id'] = "";
+        if (!isset($_POST['selectTable'])) $_POST['selectTable'] = "";
+
+        // SQL_IDの取得
+        if ($_POST['sql_id'] != "") {
+            $sql_id = $_POST['sql_id'];
+        }elseif($_GET['sql_id'] != ""){
+            $sql_id = $_GET['sql_id'];
+        }else{
+            $sql_id = "";
+        }
+
+        $mode = $_POST['mode'];
+
+        switch($_POST['mode']) {
+            // データの登録
+        case "confirm":
+            // エラーチェック
+            $this->arrErr = $this->lfCheckError($_POST);
+
+            if (count($this->arrErr) <= 0){
+                // データの更新
+                $sql_id = $this->lfUpdData($sql_id, $_POST);
+                // 完了メッセージ表示
+                $this->tpl_onload = "alert('登録が完了しました。');";
+            }
+            break;
+
+            // 確認画面
+        case "preview":
+            // SQL文表示
+            $sql = "SELECT \n" . $_POST['csv_sql']; // FIXME
+            $this->sql = $sql;
+
+            // エラー表示
+            $objErrMsg = $this->lfCheckSQL($_POST);
+            if ($objErrMsg != "") {
+                $errMsg = $objErrMsg->message . "\n" . $objErrMsg->userinfo;
+            }
+
+            $this->sqlerr = isset($errMsg) ? $errMsg : "" ;
+
+            $this->objView = $objView;
+
+            // 画面の表示
+            $objView->assignobj($this);
+            $objView->display('contents/csv_sql_view.tpl');
+            exit;
+            break;
+
+            // 新規作成
+        case "new_page":
+            $this->sendRedirect($this->getLocation("./csv_sql.php"));
+            exit;
+            break;
+
+            // データ削除
+        case "delete":
+            $this->lfDelData($sql_id);
+            $this->sendRedirect($this->getLocation("./csv_sql.php"));
+            exit;
+            break;
+
+        case "csv_output":
+            // CSV出力データ取得
+            $arrCsvData = $this->lfGetSqlList(" WHERE sql_id = ?", array($_POST['csv_output_id']));
+
+            $objQuery = new SC_Query();
+
+            $arrCsvOutputData = $objQuery->getall("SELECT " . $arrCsvData[0]['csv_sql']);
+
+            if (count($arrCsvOutputData) > 0) {
+
+                $arrKey = array_keys(SC_Utils_Ex::sfSwapArray($arrCsvOutputData));
+                $i = 0;
+                $header = "";
+                foreach($arrKey as $data) {
+                    if ($i != 0) $header .= ", ";
+                    $header .= $data;
+                    $i ++;
+                }
+                $header .= "\n\r";
+
+                $data = SC_Utils_Ex::getCSVData($arrCsvOutputData, $arrKey);
+                // CSV出力
+                SC_Utils_Ex::sfCSVDownload($header.$data);
+                exit;
+                break;
+            }else{
+                $this->tpl_onload = "alert('出力データがありません。');";
+                $sql_id = "";
+                $_POST="";
+            }
+            break;
+        }
+
+        // mode が confirm 以外のときは完了メッセージは出力しない
+        if ($mode != "confirm" and $mode != "csv_output") {
+            $this->tpl_onload = "";
+        }
+
+        // 登録済みSQL一覧取得
+        $arrSqlList = $this->lfGetSqlList();
+
+        // 編集用SQLデータの取得
+        if ($sql_id != "") {
+            $arrSqlData = $this->lfGetSqlList(" WHERE sql_id = ?", array($sql_id));
+        }
+
+        // テーブル一覧を取得する
+        $arrTableList = $this->lfGetTableList();
+        $arrTableList = SC_Utils_Ex::sfSwapArray($arrTableList);
+
+        // 現在選択されているテーブルを取得する
+        if ($_POST['selectTable'] == ""){
+            $selectTable = $arrTableList['table_name'][0];
+        }else{
+            $selectTable = $_POST['selectTable'];
+        }
+
+        // カラム一覧を取得する
+        $arrColList = $this->lfGetColumnList($selectTable);
+        $arrColList =  SC_Utils_Ex::sfSwapArray($arrColList);
+
+        // 表示させる内容を編集
+        foreach ($arrTableList['description'] as $key => $val) {
+            $arrTableList['description'][$key] = $arrTableList['table_name'][$key] . "：" . $arrTableList['description'][$key];
+        }
+        foreach ($arrColList['description'] as $key => $val) {
+            $arrColList['description'][$key] = $arrColList['column_name'][$key] . "：" . $arrColList['description'][$key];
+        }
+
+
+        $arrDiff = array_diff($objDbFactory->sfGetColumnList($selectTable), $arrColList["column_name"]);
+        $arrColList["column_name"] = array_merge($arrColList["column_name"], $arrDiff);
+        $arrColList["description"] = array_merge($arrColList["description"], $arrDiff);
+
+        // テンプレートに出力するデータをセット
+        $this->arrSqlList = $arrSqlList;	// SQL一覧
+        $this->arrTableList = SC_Utils_Ex::sfarrCombine($arrTableList['table_name'], $arrTableList['description']);	// テーブル一覧
+        $this->arrColList = SC_Utils_Ex::sfarrCombine($arrColList['column_name'],$arrColList['description']);			// カラム一覧
+        $this->selectTable = $selectTable;	// 選択されているテーブル
+        $this->sql_id = $sql_id;			// 選択されているSQL
+
+        // POSTされたデータをセットする
+        if (count($_POST) > 0) {
+            $arrSqlData[0]['sql_name'] = isset($_POST['sql_name']) ? $_POST['sql_name'] : "";
+            $arrSqlData[0]['csv_sql'] = isset($_POST['csv_sql']) ? $_POST['csv_sql'] : "";
+        }
+        $this->arrSqlData = $arrSqlData[0];	// 選択されているSQLデータ
+
+        // 画面の表示
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * テーブル一覧を取得する.
+     *
+     * @return void
+     */
+    function lfGetTableList(){
+        $objQuery = new SC_Query();
+        $arrRet = array();		// 結果取得用
+
+        $sql = "";
+        $sql .= "SELECT table_name, description FROM dtb_table_comment WHERE column_name IS NULL ORDER BY table_name";
+        $arrRet = $objQuery->getAll($sql);
+
+        return $arrRet;
+    }
+
+    /**
+     * テーブルのカラム一覧を取得する.
+     *
+     * @param string $selectTable テーブル名
+     * @return array カラム一覧の配列
+     */
+    function lfGetColumnList($selectTable){
+        $objQuery = new SC_Query();
+        $arrRet = array();		// 結果取得用
+        $sql = "";
+        $sql .= " SELECT column_name, description FROM dtb_table_comment WHERE table_name = ? AND column_name IS NOT NULL";
+        $arrRet = $objQuery->getAll($sql, array($selectTable));
+
+        return $arrRet;
+    }
+
+    /**
+     * 登録済みSQL一覧を取得する.
+     *
+     * @param string $where Where句
+     * @param array $arrData 絞り込みデータ
+     * @return array 取得結果の配列
+     */
+    function lfGetSqlList($where = "" , $arrData = array()){
+        $objQuery = new SC_Query();
+        $arrRet = array();		// 結果取得用
+
+        $sql = "";
+        $sql .= " SELECT";
+        $sql .= "     sql_id,";
+        $sql .= "     sql_name,";
+        $sql .= "     csv_sql,";
+        $sql .= "     update_date,";
+        $sql .= "     create_date";
+        $sql .= " FROM";
+        $sql .= "     dtb_csv_sql";
+
+        // Where句の指定があれば結合する
+        if ($where != "") {
+            $sql .= " $where ";
+        }else{
+            $sql .= " ORDER BY sql_id ";
+        }
+        $sql .= " ";
+
+        // データを引数で渡されている場合にはセットする
+        if (count($arrData) > 0) {
+            $arrRet = $objQuery->getall($sql, $arrData);
+        }else{
+            $arrRet = $objQuery->getall($sql);
+        }
+
+        return $arrRet;
+    }
+
+    /**
+     * 入力項目のエラーチェックを行う.
+     *
+     * @param array POSTデータ
+     * @return array エラー内容の配列
+     */
+    function lfCheckError($data){
+        $objErr = new SC_CheckError();
+        $objErr->doFunc( array("名称", "sql_name"), array("EXIST_CHECK") );
+        $objErr->doFunc( array("SQL文", "csv_sql", "30000"), array("EXIST_CHECK", "MAX_LENGTH_CHECK") );
+
+        // SQLの妥当性チェック
+        if ($objErr->arrErr['csv_sql'] == "") {
+            $objsqlErr = $this->lfCheckSQL($data);
+            if ($objsqlErr != "") {
+                $objErr->arrErr["csv_sql"] = "SQL文が不正です。SQL文を見直してください";
+            }
+        }
+
+        return $objErr->arrErr;
+    }
+
+    /**
+     * 入力されたSQL文が正しいかチェックを行う.
+     *
+     * @param array POSTデータ
+     * @return array エラー内容
+     */
+    function lfCheckSQL($data){
+        $err = "";
+        $objDbConn = new SC_DbConn();
+        $sql = "SELECT " . $data['csv_sql'] . " ";
+        $ret = $objDbConn->conn->query($sql);
+        if ($objDbConn->conn->isError($ret)){
+            $err = $ret;
+        }
+
+        return $err;
+    }
+
+    /**
+     * DBにデータを保存する.
+     *
+     * @param integer $sql_id 更新するデータのSQL_ID
+     * @param array $arrData 更新データの配列
+     * @return integer $sql_id SQL_IDを返す
+     */
+    function lfUpdData($sql_id = "", $arrData = array()){
+        $objQuery = new SC_Query();		// DB操作オブジェクト
+        $sql = "";						// データ取得SQL生成用
+        $arrRet = array();				// データ取得用(更新判定)
+        $arrVal = array();				// データ更新
+
+        // sql_id が指定されている場合にはUPDATE
+        if ($sql_id != "") {
+            // 存在チェック
+            $arrSqlData = $this->lfGetSqlList(" WHERE sql_id = ?", array($sql_id));
+            if (count($arrSqlData) > 0) {
+                // データ更新
+                $sql = "UPDATE dtb_csv_sql SET sql_name = ?, csv_sql = ?, update_date = now() WHERE sql_id = ? ";
+                $arrVal= array($arrData['sql_name'], $arrData['csv_sql'], $sql_id);
+            }else{
+                // データの新規作成
+                $sql_id = "";
+                $sql = "INSERT INTO dtb_csv_sql (sql_name, csv_sql, create_date, update_date) values (?, ?, now(), now()) ";
+                $arrVal= array($arrData['sql_name'], $arrData['csv_sql']);
+
+            }
+        }else{
+            // データの新規作成
+            $sql = "INSERT INTO dtb_csv_sql (sql_name, csv_sql, create_date, update_date) values (?, ?, now(), now()) ";
+            $arrVal= array($arrData['sql_name'], $arrData['csv_sql']);
+        }
+        // SQL実行
+        $arrRet = $objQuery->query($sql,$arrVal);
+
+        // 新規作成時は$sql_idを取得
+        if ($sql_id == "") {
+            $arrNewData = $this->lfGetSqlList(" ORDER BY create_date DESC");
+            $sql_id = $arrNewData[0]['sql_id'];
+        }
+
+        return $sql_id;
+    }
+
+
+    /**
+     * 登録済みデータを削除する.
+     *
+     * @param integer $sql_id 削除するデータのSQL_ID
+     * @return bool 実行結果 TRUE：成功 FALSE：失敗
+     */
+    function lfDelData($sql_id = ""){
+        $objQuery = new SC_Query();		// DB操作オブジェクト
+        $sql = "";						// データ取得SQL生成用
+        $Ret = false;					// 実行結果
+
+        // sql_id が指定されている場合のみ実行
+        if ($sql_id != "") {
+            // データの削除
+            $sql = "DELETE FROM dtb_csv_sql WHERE sql_id = ? ";
+            // SQL実行
+            $ret = $objQuery->query($sql,array($sql_id));
+        }else{
+            $ret = false;
+        }
+
+        // 結果を返す
+        return $ret;
+    }
+}
+?>
Index: branches/version-2/data/class/pages/products/LC_Page_Products_Detail.php
===================================================================
--- branches/version-2/data/class/pages/products/LC_Page_Products_Detail.php	(revision 18176)
+++ branches/version-2/data/class/pages/products/LC_Page_Products_Detail.php	(revision 18176)
@@ -0,0 +1,895 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+if (file_exists(MODULE_PATH . "mdl_gmopg/inc/function.php")) {
+    require_once(MODULE_PATH . "mdl_gmopg/inc/function.php");
+}
+/**
+ * 商品詳細 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
+ */
+class LC_Page_Products_Detail extends LC_Page {
+
+    /** ステータス */
+    var $arrSTATUS;
+
+    /** ステータス画像 */
+    var $arrSTATUS_IMAGE;
+
+    /** 発送予定日 */
+    var $arrDELIVERYDATE;
+
+    /** おすすめレベル */
+    var $arrRECOMMEND;
+
+    /** フォームパラメータ */
+    var $objFormParam;
+
+    /** アップロードファイル */
+    var $objUpFile;
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrSTATUS = $masterData->getMasterData("mtb_status");
+        $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image");
+        $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date");
+        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_SiteView();
+        $objCustomer = new SC_Customer();
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // レイアウトデザインを取得
+        $helper = new SC_Helper_PageLayout_Ex();
+        $helper->sfGetPageLayout($this, false, "products/detail.php");
+
+        // ログイン中のユーザが商品をお気に入りにいれる処理
+        if( $objCustomer->isLoginSuccess() === true && strlen($_POST['mode']) > 0 && $_POST['mode'] == "add_favorite" && strlen($_POST['favorite_product_id']) > 0 ) {
+            // 値の正当性チェック
+            if(!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) {
+                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
+                exit;
+            } else {
+                $this->arrErr = $this->lfCheckError();
+                if(count($this->arrErr) == 0) {
+                    $customer_id = $objCustomer->getValue('customer_id');
+                    $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']);
+                }
+            }
+        }
+
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+        // POST値の取得
+        $this->objFormParam->setParam($_POST);
+
+        // ファイル管理クラス
+        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
+        // ファイル情報の初期化
+        $this->lfInitFile();
+
+        // 管理ページからの確認の場合は、非公開の商品も表示する。
+        if(isset($_GET['admin']) && $_GET['admin'] == 'on') {
+            SC_Utils_Ex::sfIsSuccess(new SC_Session());
+            $status = true;
+            $where = "del_flg = 0";
+        } else {
+            $status = false;
+            $where = "del_flg = 0 AND status = 1";
+        }
+
+        if(isset($_POST['mode']) && $_POST['mode'] != "") {
+            $tmp_id = $_POST['product_id'];
+        } else {
+            $tmp_id = $_GET['product_id'];
+        }
+
+        // 値の正当性チェック
+        if(!SC_Utils_Ex::sfIsInt($_GET['product_id'])
+                || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) {
+            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
+        }
+        // ログイン判定
+        if($objCustomer->isLoginSuccess() === true) {
+            //お気に入りボタン表示
+            $this->tpl_login = true;
+
+        /* 閲覧ログ機能は現在未使用
+
+            $table = "dtb_customer_reading";
+            $where = "customer_id = ? ";
+            $arrval[] = $objCustomer->getValue('customer_id');
+            //顧客の閲覧商品数
+            $rpcnt = $objQuery->count($table, $where, $arrval);
+
+            //閲覧数が設定数以下
+            if ($rpcnt < CUSTOMER_READING_MAX){
+                //閲覧履歴に新規追加
+                lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
+            } else {
+                //閲覧履歴の中で一番古いものを削除して新規追加
+                $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?";
+                $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id")));
+                $where = "customer_id = ? AND update_date = ? ";
+                $arrval = array($objCustomer->getValue("customer_id"), $old);
+                //削除
+                $objQuery->delete($table, $where, $arrval);
+                //追加
+                lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
+            }
+        */
+        }
+
+
+        // 規格選択セレクトボックスの作成
+        $this->lfMakeSelect($tmp_id);
+
+        // 商品IDをFORM内に保持する。
+        $this->tpl_product_id = $tmp_id;
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        switch($_POST['mode']) {
+        case 'cart':
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError();
+            if(count($this->arrErr) == 0) {
+                $objCartSess = new SC_CartSession();
+                $classcategory_id1 = $_POST['classcategory_id1'];
+                $classcategory_id2 = $_POST['classcategory_id2'];
+
+                if (!empty($_POST['gmo_oneclick'])) {
+                    $objCartSess->delAllProducts();
+                }
+
+                // 規格1が設定されていない場合
+                if(!$this->tpl_classcat_find1) {
+                    $classcategory_id1 = '0';
+                }
+
+                // 規格2が設定されていない場合
+                if(!$this->tpl_classcat_find2) {
+                    $classcategory_id2 = '0';
+                }
+
+                $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
+                $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity'));
+
+                if (!empty($_POST['gmo_oneclick'])) {
+                    $objSiteSess = new SC_SiteSession;
+                    $objSiteSess->setRegistFlag();
+                    $objCartSess->saveCurrentCart($objSiteSess->getUniqId());
+
+                    $this->sendRedirect($this->getLocation(
+                        URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true));
+                    exit;
+                }
+
+                $this->sendRedirect($this->getLocation(URL_CART_TOP));
+                exit;
+            }
+            break;
+
+        default:
+            break;
+        }
+
+        $objQuery = new SC_Query();
+        // DBから商品情報を取得する。
+        $arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE product_id = alldtl.product_id AND customer_id = ?) AS favorite_count", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($objCustomer->getValue('customer_id'), $tmp_id));
+        $this->arrProduct = $arrRet[0];
+
+        // 商品コードの取得
+        $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code";
+        $arrProductCode = $objQuery->getall($code_sql, array($tmp_id));
+        $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode);
+        $this->arrProductCode = $arrProductCode["product_code"];
+
+        // 購入制限数を取得
+        if($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) {
+          $this->tpl_sale_limit = SALE_LIMIT_MAX;
+        } else {
+          $this->tpl_sale_limit = $this->arrProduct['sale_limit'];
+        }
+        // サブタイトルを取得
+        $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'],'',$status);
+        $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
+        $this->tpl_subtitle = $arrFirstCat['name'];
+
+        // 関連カテゴリを取得
+        $this->arrRelativeCat = $objDb->sfGetMultiCatTree($tmp_id);
+
+        // DBからのデータを引き継ぐ
+        $this->objUpFile->setDBFileList($this->arrProduct);
+        // ファイル表示用配列を渡す
+        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
+        // 支払方法の取得
+        $this->arrPayment = $this->lfGetPayment();
+        // 入力情報を渡す
+        $this->arrForm = $this->objFormParam->getFormParamList();
+        //レビュー情報の取得
+        $this->arrReview = $this->lfGetReviewData($tmp_id);
+        // トラックバック情報の取得
+
+        // トラックバック機能の稼働状況チェック
+        if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) {
+            $this->arrTrackbackView = "OFF";
+        } else {
+            $this->arrTrackbackView = "ON";
+            $this->arrTrackback = $this->lfGetTrackbackData($tmp_id);
+        }
+        $this->trackback_url = TRACKBACK_TO_URL . $tmp_id;
+        // タイトルに商品名を入れる
+        $this->tpl_title = "商品詳細 ". $this->arrProduct["name"];
+        //オススメ商品情報表示
+        $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id);
+        //この商品を買った人はこんな商品も買っています
+        $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id);
+
+        // 拡大画像のウィンドウサイズをセット
+        if (isset($this->arrFile["main_large_image"])) {
+            $image_path = IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"]);
+        } else {
+            $image_path = "";
+        }
+
+        list($large_width, $large_height) = getimagesize($image_path);
+        $this->tpl_large_width = $large_width + 60;
+        $this->tpl_large_height = $large_height + 80;
+
+        $this->lfConvertParam();
+
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->init();
+        $this->tpl_mainpage = "products/detail.tpl";
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * FIXME 要リファクタリング
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $objView = new SC_MobileView();
+        $objCustomer = new SC_Customer();
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+        // POST値の取得
+        $this->objFormParam->setParam($_POST);
+
+        // ファイル管理クラス
+        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
+        // ファイル情報の初期化
+        $this->lfInitFile();
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+
+        if(!empty($_POST['mode'])) {
+            $tmp_id = $_POST['product_id'];
+        } else {
+            $tmp_id = $_GET['product_id'];
+        }
+
+        // 値の正当性チェック
+        if(!SC_Utils_Ex::sfIsInt($tmp_id)
+                || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, 'del_flg = 0 AND status = 1')) {
+            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
+        }
+
+        // ログイン判定
+        if($objCustomer->isLoginSuccess(true)) {
+            //お気に入りボタン表示
+            $this->tpl_login = true;
+
+            /* 閲覧ログ機能は現在未使用
+
+               $table = "dtb_customer_reading";
+               $where = "customer_id = ? ";
+               $arrval[] = $objCustomer->getValue('customer_id');
+               //顧客の閲覧商品数
+               $rpcnt = $objQuery->count($table, $where, $arrval);
+
+               //閲覧数が設定数以下
+               if ($rpcnt < CUSTOMER_READING_MAX){
+               //閲覧履歴に新規追加
+               lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
+               } else {
+               //閲覧履歴の中で一番古いものを削除して新規追加
+               $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?";
+               $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id")));
+               $where = "customer_id = ? AND update_date = ? ";
+               $arrval = array($objCustomer->getValue("customer_id"), $old);
+               //削除
+               $objQuery->delete($table, $where, $arrval);
+               //追加
+               lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
+               }
+            */
+        }
+
+
+        // 規格選択セレクトボックスの作成
+        $this->lfMakeSelectMobile($this, $tmp_id);
+
+        // 商品IDをFORM内に保持する。
+        $this->tpl_product_id = $tmp_id;
+
+        switch($_POST['mode']) {
+        case 'select':
+            // 規格1が設定されている場合
+            if($this->tpl_classcat_find1) {
+                // templateの変更
+                $this->tpl_mainpage = "products/select_find1.tpl";
+                break;
+            }
+
+        case 'select2':
+            $this->arrErr = $this->lfCheckError();
+
+            // 規格1が設定されている場合
+            if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
+                // templateの変更
+                $this->tpl_mainpage = "products/select_find1.tpl";
+                break;
+            }
+
+            // 規格2が設定されている場合
+            if($this->tpl_classcat_find2) {
+                $this->arrErr = array();
+
+                $this->tpl_mainpage = "products/select_find2.tpl";
+                break;
+            }
+
+        case 'selectItem':
+            $this->arrErr = $this->lfCheckError();
+
+            // 規格1が設定されている場合
+            if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
+                // templateの変更
+                $this->tpl_mainpage = "products/select_find2.tpl";
+                break;
+            }
+            // 商品数の選択を行う
+            $this->tpl_mainpage = "products/select_item.tpl";
+            break;
+
+        case 'cart':
+            // 入力値の変換
+            $this->objFormParam->convParam();
+            $this->arrErr = $this->lfCheckError();
+            if(count($this->arrErr) == 0) {
+                $objCartSess = new SC_CartSession();
+                $classcategory_id1 = $_POST['classcategory_id1'];
+                $classcategory_id2 = $_POST['classcategory_id2'];
+
+                // 規格1が設定されていない場合
+                if(!$this->tpl_classcat_find1) {
+                    $classcategory_id1 = '0';
+                }
+
+                // 規格2が設定されていない場合
+                if(!$this->tpl_classcat_find2) {
+                    $classcategory_id2 = '0';
+                }
+
+                $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
+                $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity'));
+                $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true);
+                exit;
+            }
+            break;
+
+        default:
+            break;
+        }
+
+        $objQuery = new SC_Query();
+        // DBから商品情報を取得する。
+        $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id));
+        $this->arrProduct = $arrRet[0];
+
+        // 商品コードの取得
+        $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code";
+        $arrProductCode = $objQuery->getall($code_sql, array($tmp_id));
+        $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode);
+        $this->arrProductCode = $arrProductCode["product_code"];
+
+        // 購入制限数を取得
+        if($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) {
+            $this->tpl_sale_limit = SALE_LIMIT_MAX;
+        } else {
+            $this->tpl_sale_limit = $this->arrProduct['sale_limit'];
+        }
+
+        // サブタイトルを取得
+        $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']);
+        $tpl_subtitle = $arrFirstCat['name'];
+        $this->tpl_subtitle = $tpl_subtitle;
+
+        // DBからのデータを引き継ぐ
+        $this->objUpFile->setDBFileList($this->arrProduct);
+        // ファイル表示用配列を渡す
+        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
+        // 支払方法の取得
+        $this->arrPayment = $this->lfGetPayment();
+        // 入力情報を渡す
+        $this->arrForm = $this->objFormParam->getFormParamList();
+        //レビュー情報の取得
+        $this->arrReview = $this->lfGetReviewData($tmp_id);
+        // タイトルに商品名を入れる
+        $this->tpl_title = "商品詳細 ". $this->arrProduct["name"];
+        //オススメ商品情報表示
+        $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id);
+        //この商品を買った人はこんな商品も買っています
+        $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id);
+
+        // 拡大画像のウィンドウサイズをセット
+        if (!empty($this->arrFile["main_large_image"])) {
+            list($large_width, $large_height) = getimagesize(IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"]));
+        }
+        $this->tpl_large_width = isset($large_width) ? $large_width + 60 : 0;
+        $this->tpl_large_height = isset($large_height) ? $large_height + 80 : 0;
+
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /* ファイル情報の初期化 */
+    function lfInitFile() {
+        $this->objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg','gif'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
+        $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
+        $this->objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg'), IMAGE_SIZE, false, LARGE_IMAGE_HEIGHT, LARGE_IMAGE_HEIGHT);
+        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
+            $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT);
+            $this->objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg'), IMAGE_SIZE, false, LARGE_SUBIMAGE_HEIGHT, LARGE_SUBIMAGE_HEIGHT);
+        }
+        $this->objUpFile->addFile("商品比較画像", 'file1', array('jpg'), IMAGE_SIZE, false, NORMAL_IMAGE_HEIGHT, NORMAL_IMAGE_HEIGHT);
+        $this->objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false);
+    }
+
+    /* 規格選択セレクトボックスの作成 */
+    function lfMakeSelect($product_id) {
+
+        $objDb = new SC_Helper_DB_Ex();
+        $classcat_find1 = false;
+        $classcat_find2 = false;
+        // 在庫ありの商品の有無
+        $stock_find = false;
+
+        // 規格名一覧
+        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
+        // 規格分類名一覧
+        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+        // 商品規格情報の取得
+        $arrProductsClass = $this->lfGetProductsClass($product_id);
+
+        // 規格1クラス名の取得
+        $this->tpl_class_name1 = isset($arrClassName[$arrProductsClass[0]['class_id1']])
+                                        ? $arrClassName[$arrProductsClass[0]['class_id1']] : "";
+        // 規格2クラス名の取得
+        $this->tpl_class_name2 = isset($arrClassName[$arrProductsClass[0]['class_id2']])
+                                        ? $arrClassName[$arrProductsClass[0]['class_id2']] : "";
+
+        // すべての組み合わせ数
+        $count = count($arrProductsClass);
+
+        $classcat_id1 = "";
+
+        $arrSele = array();
+        $arrList = array();
+
+        $list_id = 0;
+        $arrList[0] = "\tlist0 = new Array('選択してください'";
+        $arrVal[0] = "\tval0 = new Array(''";
+
+        for ($i = 0; $i < $count; $i++) {
+            // 在庫のチェック
+            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
+                continue;
+            }
+
+            $stock_find = true;
+
+            // 規格1のセレクトボックス用
+            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
+                $arrList[$list_id].=");\n";
+                $arrVal[$list_id].=");\n";
+                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
+                $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
+                $list_id++;
+            }
+
+            // 規格2のセレクトボックス用
+            $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
+
+            // セレクトボックス表示値
+            if (!isset($arrList[$list_id])) $arrList[$list_id] = "";
+            if($arrList[$list_id] == "") {
+                $arrList[$list_id] = "\tlist".$list_id." = new Array('選択してください', '".$arrClassCatName[$classcat_id2]."'";
+            } else {
+                $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
+            }
+
+            // セレクトボックスPOST値
+            if (!isset($arrVal[$list_id])) $arrVal[$list_id] = "";
+            if($arrVal[$list_id] == "") {
+                $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'";
+            } else {
+                $arrVal[$list_id].= ", '".$classcat_id2."'";
+            }
+        }
+
+        $arrList[$list_id].=");\n";
+        $arrVal[$list_id].=");\n";
+
+        // 規格1
+        $this->arrClassCat1 = $arrSele;
+
+        $lists = "\tlists = new Array(";
+        $no = 0;
+
+        foreach($arrList as $val) {
+            $this->tpl_javascript.= $val;
+            if ($no != 0) {
+                $lists.= ",list".$no;
+            } else {
+                $lists.= "list".$no;
+            }
+            $no++;
+        }
+        $this->tpl_javascript.=$lists.");\n";
+
+        $vals = "\tvals = new Array(";
+        $no = 0;
+
+        foreach($arrVal as $val) {
+            $this->tpl_javascript.= $val;
+            if ($no != 0) {
+                $vals.= ",val".$no;
+            } else {
+                $vals.= "val".$no;
+            }
+            $no++;
+        }
+        $this->tpl_javascript.=$vals.");\n";
+
+        // 選択されている規格2ID
+        if (!isset($_POST['classcategory_id2'])) $_POST['classcategory_id2'] = "";
+        $this->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . htmlspecialchars($_POST['classcategory_id2'], ENT_QUOTES) . "');";
+
+        // 規格1が設定されている
+        if($arrProductsClass[0]['classcategory_id1'] != '0') {
+            $classcat_find1 = true;
+        }
+
+        // 規格2が設定されている
+        if($arrProductsClass[0]['classcategory_id2'] != '0') {
+            $classcat_find2 = true;
+        }
+
+        $this->tpl_classcat_find1 = $classcat_find1;
+        $this->tpl_classcat_find2 = $classcat_find2;
+        $this->tpl_stock_find = $stock_find;
+    }
+
+    /* 規格選択セレクトボックスの作成
+     * FIXME 要リファクタリング
+     */
+    function lfMakeSelectMobile(&$objPage, $product_id) {
+
+        $objDb = new SC_Helper_DB_Ex();
+        $classcat_find1 = false;
+        $classcat_find2 = false;
+        // 在庫ありの商品の有無
+        $stock_find = false;
+
+        // 規格名一覧
+        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
+        // 規格分類名一覧
+        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+        // 商品規格情報の取得
+        $arrProductsClass = $this->lfGetProductsClass($product_id);
+
+        // 規格1クラス名の取得
+        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
+        // 規格2クラス名の取得
+        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
+
+        // すべての組み合わせ数
+        $count = count($arrProductsClass);
+
+        $classcat_id1 = "";
+
+        $arrSele1 = array();
+        $arrSele2 = array();
+
+        for ($i = 0; $i < $count; $i++) {
+            // 在庫のチェック
+            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
+                continue;
+            }
+
+            $stock_find = true;
+
+            // 規格1のセレクトボックス用
+            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
+                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
+                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
+            }
+
+            // 規格2のセレクトボックス用
+            if($arrProductsClass[$i]['classcategory_id1'] == $_POST['classcategory_id1'] and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
+                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
+                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
+            }
+        }
+
+        // 規格1
+        $objPage->arrClassCat1 = $arrSele1;
+        $objPage->arrClassCat2 = $arrSele2;
+
+        // 規格1が設定されている
+        if($arrProductsClass[0]['classcategory_id1'] != '0') {
+            $classcat_find1 = true;
+        }
+
+        // 規格2が設定されている
+        if($arrProductsClass[0]['classcategory_id2'] != '0') {
+            $classcat_find2 = true;
+        }
+
+        $objPage->tpl_classcat_find1 = $classcat_find1;
+        $objPage->tpl_classcat_find2 = $classcat_find2;
+        $objPage->tpl_stock_find = $stock_find;
+    }
+
+    /* パラメータ情報の初期化 */
+    function lfInitParam() {
+        $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
+        $this->objFormParam->addParam("個数", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+    }
+
+    /* 商品規格情報の取得 */
+    function lfGetProductsClass($product_id) {
+        $arrRet = array();
+        if(SC_Utils_Ex::sfIsInt($product_id)) {
+            // 商品規格取得
+            $objQuery = new SC_Query();
+            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
+            $table = "vw_product_class AS prdcls";
+            $where = "product_id = ?";
+            $objQuery->setorder("rank1 DESC, rank2 DESC");
+            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
+        }
+        return $arrRet;
+    }
+
+    /* 登録済みオススメ商品の読み込み */
+    function lfPreGetRecommendProducts($product_id) {
+        $arrRecommend = array();
+        $objQuery = new SC_Query();
+        $objQuery->setorder("rank DESC");
+        $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
+        $max = count($arrRet);
+        $no = 0;
+        $from = "vw_products_allclass AS T1 "
+                . " JOIN ("
+                . " SELECT max(T2.rank) AS product_rank, "
+                . "        T2.product_id"
+                . "   FROM dtb_product_categories T2  "
+                . " GROUP BY product_id) AS T3 USING (product_id)";
+        $objQuery->setorder("product_rank DESC");
+        for($i = 0; $i < $max; $i++) {
+            $where = "del_flg = 0 AND T3.product_id = ? AND status = 1";
+            $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate, product_rank", $from, $where, array($arrRet[$i]['recommend_product_id']));
+
+            if(count($arrProductInfo) > 0) {
+                $arrRecommend[$no] = $arrProductInfo[0];
+                $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
+                $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
+                $no++;
+            }
+        }
+        return $arrRecommend;
+    }
+
+    /* 入力内容のチェック */
+    function lfCheckError() {
+        if ($_POST['mode'] == "add_favorite") {
+            $objCustomer = new SC_Customer();
+            $objErr = new SC_CheckError();
+            $customer_id = $objCustomer->getValue('customer_id');
+            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
+                $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />";
+            }
+        } else {
+            // 入力データを渡す。
+            $arrRet =  $this->objFormParam->getHashArray();
+            $objErr = new SC_CheckError($arrRet);
+            $objErr->arrErr = $this->objFormParam->checkError();
+
+            // 複数項目チェック
+            if ($this->tpl_classcat_find1) {
+                $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK"));
+            }
+            if ($this->tpl_classcat_find2) {
+                $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK"));
+            }
+        }
+
+        return $objErr->arrErr;
+    }
+
+    //閲覧履歴新規登録
+    function lfRegistReadingData($tmp_id, $customer_id){
+        $objQuery = new SC_Query;
+        $sqlval['customer_id'] = $customer_id;
+        $sqlval['reading_product_id'] = $tmp_id;
+        $sqlval['create_date'] = 'NOW()';
+        $sqlval['update_date'] = 'NOW()';
+        $objQuery->insert("dtb_customer_reading", $sqlval);
+    }
+
+    //この商品を買った人はこんな商品も買っています FIXME
+    function lfGetRelateProducts($tmp_id) {
+        $objQuery = new SC_Query;
+        //自動抽出
+        $objQuery->setorder("random()");
+        //表示件数の制限
+        $objQuery->setlimit(RELATED_PRODUCTS_MAX);
+        //検索条件
+        $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate";
+        $from = "vw_products_allclass AS allcls ";
+        $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? ";
+        $arrval[] = $tmp_id;
+        //結果の取得
+        $arrProducts = $objQuery->select($col, $from, $where, $arrval);
+
+        return $arrProducts;
+    }
+
+    //商品ごとのレビュー情報を取得する
+    function lfGetReviewData($id) {
+        $objQuery = new SC_Query;
+        //商品ごとのレビュー情報を取得する
+        $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
+        $from = "dtb_review";
+        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX;
+        $arrval[] = $id;
+        $arrReview = $objQuery->select($col, $from, $where, $arrval);
+        return $arrReview;
+    }
+
+    /*
+     * 商品ごとのトラックバック情報を取得する
+     *
+     * @param $product_id
+     * @return $arrTrackback
+     */
+    function lfGetTrackbackData($product_id) {
+
+        $arrTrackback = array();
+
+        $objQuery = new SC_Query;
+        //商品ごとのトラックバック情報を取得する
+        $col = "blog_name, url, title, excerpt, title, create_date";
+        $from = "dtb_trackback";
+        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX;
+        $arrval[] = $product_id;
+        $arrTrackback = $objQuery->select($col, $from, $where, $arrval);
+        return $arrTrackback;
+    }
+
+    //支払方法の取得
+    //payment_id	1:クレジット　2:ショッピングローン
+    function lfGetPayment() {
+        $objQuery = new SC_Query;
+        $col = "payment_id, rule, payment_method";
+        $from = "dtb_payment";
+        $where = "del_flg = 0";
+        $order = "payment_id";
+        $objQuery->setorder($order);
+        $arrRet = $objQuery->select($col, $from, $where);
+        return $arrRet;
+    }
+
+    function lfConvertParam() {
+        if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = "";
+        $value = $this->arrForm['quantity']['value'];
+        $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE);
+    }
+
+        /*
+     * お気に入り商品登録
+     */
+    function lfRegistFavoriteProduct($customer_id, $product_id) {
+        $objQuery = new SC_Query();
+        $objConn = new SC_DbConn();
+        $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id));
+
+        if ($count == 0) {
+            $sqlval['customer_id'] = $customer_id;
+            $sqlval['product_id'] = $product_id;
+            $sqlval['update_date'] = "now()";
+            $sqlval['create_date'] = "now()";
+
+            $objQuery->begin();
+            $objQuery->insert('dtb_customer_favorite_products', $sqlval);
+            $objQuery->commit();
+        }
+    }
+}
+?>
Index: branches/version-2/data/class/pages/products/LC_Page_Products_List.php
===================================================================
--- branches/version-2/data/class/pages/products/LC_Page_Products_List.php	(revision 18176)
+++ branches/version-2/data/class/pages/products/LC_Page_Products_List.php	(revision 18176)
@@ -0,0 +1,706 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 商品一覧 のページクラス.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id:LC_Page_Products_List.php 15532 2007-08-31 14:39:46Z nanasess $
+ */
+class LC_Page_Products_List extends LC_Page {
+
+    // {{{ properties
+
+    /** テンプレートクラス名1 */
+    var $tpl_class_name1;
+
+    /** テンプレートクラス名2 */
+    var $tpl_class_name2;
+
+    /** JavaScript テンプレート */
+    var $tpl_javascript;
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+
+        $masterData = new SC_DB_MasterData_Ex();
+        $this->arrSTATUS = $masterData->getMasterData("mtb_status");
+        $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image");
+        $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date");
+        $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max");
+
+        $this->tpl_class_name1 = array();
+        $this->tpl_class_name2 = array();
+        $this->allowClientCache();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objView = new SC_SiteView();
+        $conn = new SC_DBConn();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // レイアウトデザインを取得
+        $helper = new SC_Helper_PageLayout_Ex();
+        $helper->sfGetPageLayout($this, false, DEF_LAYOUT);
+
+        //表示件数の選択
+        if(isset($_POST['disp_number'])
+           && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) {
+            $this->disp_number = $_POST['disp_number'];
+        } else {
+            //最小表示件数を選択
+            $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));
+        }
+
+        //表示順序の保存
+        $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : "";
+
+        // GETのカテゴリIDを元に正しいカテゴリIDを取得する。
+        $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);
+
+        if (!isset($_GET['mode'])) $_GET['mode'] = "";
+        if (!isset($_GET['name'])) $_GET['name'] = "";
+        if (!isset($_POST['orderby'])) $_POST['orderby'] = "";
+        if (empty($arrCategory_id)) $arrCategory_id = array("0");
+
+        // タイトル編集
+        $tpl_subtitle = "";
+        if ($_GET['mode'] == 'search') {
+            $tpl_subtitle = "検索結果";
+        } elseif (empty($arrCategory_id[0])) {
+            $tpl_subtitle = "全商品";
+        } else {
+            $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
+            $tpl_subtitle = $arrFirstCat['name'];
+        }
+
+        $objQuery = new SC_Query();
+        $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id);
+
+        // 以下の条件でBEST商品を表示する
+        // ・BEST最大数の商品が登録されている。
+        // ・カテゴリIDがルートIDである。
+        // ・検索モードでない。
+        if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) {
+            // 商品TOPの表示処理
+            $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]);
+            $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2);
+        } else {
+            if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){
+                // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
+                $arrCategory_id = array(0);
+            }
+
+            // 商品一覧の表示処理
+            $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_POST['orderby']);
+
+            // 検索条件を画面に表示
+            // カテゴリー検索条件
+            if (strlen($_GET['category_id']) == 0) {
+                $arrSearch['category'] = "指定なし";
+            }else{
+                $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id);
+                $arrSearch['category'] = $arrCat;
+            }
+
+            // 商品名検索条件
+            if ($_GET['name'] === "") {
+                $arrSearch['name'] = "指定なし";
+            }else{
+                $arrSearch['name'] = $_GET['name'];
+            }
+        }
+
+        // レイアウトデザインを取得
+        $layout = new SC_Helper_PageLayout_Ex();
+        $layout->sfGetPageLayout($this, false, "products/list.php");
+
+        if(isset($_POST['mode']) && $_POST['mode'] == "cart"
+           && $_POST['product_id'] != "") {
+
+            // 値の正当性チェック
+            if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
+                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
+            } else {
+                // 入力値の変換
+                $this->arrErr = $this->lfCheckError($_POST['product_id']);
+                if(count($this->arrErr) == 0) {
+                    $objCartSess = new SC_CartSession();
+                    $classcategory_id = "classcategory_id". $_POST['product_id'];
+                    $classcategory_id1 = $_POST[$classcategory_id. '_1'];
+                    $classcategory_id2 = $_POST[$classcategory_id. '_2'];
+                    $quantity = "quantity". $_POST['product_id'];
+                    // 規格1が設定されていない場合
+                    if(!$this->tpl_classcat_find1[$_POST['product_id']]) {
+                        $classcategory_id1 = '0';
+                    }
+                    // 規格2が設定されていない場合
+                    if(!$this->tpl_classcat_find2[$_POST['product_id']]) {
+                        $classcategory_id2 = '0';
+                    }
+                    $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
+                    $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
+                    $this->sendRedirect($this->getLocation(URL_CART_TOP));
+                    exit;
+                }
+            }
+        }
+
+        $this->tpl_subtitle = $tpl_subtitle;
+
+        // 支払方法の取得
+        $this->arrPayment = $this->lfGetPayment();
+        // 入力情報を渡す
+        $this->arrForm = $_POST;
+
+        $this->lfConvertParam();
+
+        $this->category_id = $arrCategory_id[0];
+        $this->arrSearch = $arrSearch;
+
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->init();
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * FIXME スパゲッティ...
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $objView = new SC_MobileView();
+        $conn = new SC_DBConn();
+        $objDb = new SC_Helper_DB_Ex();
+
+        //表示件数の選択
+        if(isset($_REQUEST['disp_number'])
+           && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) {
+            $this->disp_number = $_REQUEST['disp_number'];
+        } else {
+            //最小表示件数を選択
+            $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));
+        }
+
+        //表示順序の保存
+        $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : "";
+
+        // GETのカテゴリIDを元に正しいカテゴリIDを取得する。
+        $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);
+
+
+        // タイトル編集
+        $tpl_subtitle = "";
+        $tpl_search_mode = false;
+
+        if (!isset($_GET['mode'])) $_GET['mode'] = "";
+        if (!isset($_POST['mode'])) $_POST['mode'] = "";
+        if (!isset($_GET['name'])) $_GET['name'] = "";
+        if (!isset($_REQUEST['orderby'])) $_REQUEST['orderby'] = "";
+        if (empty($arrCategory_id)) $arrCategory_id = array("0");
+
+        if($_GET['mode'] == 'search'){
+            $tpl_subtitle = "検索結果";
+            $tpl_search_mode = true;
+        }elseif (empty($arrCategory_id)) {
+            $tpl_subtitle = "全商品";
+        }else{
+            $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
+            $tpl_subtitle = $arrFirstCat['name'];
+        }
+
+        $objQuery = new SC_Query();
+        $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id);
+
+        // 以下の条件でBEST商品を表示する
+        // ・BEST最大数の商品が登録されている。
+        // ・カテゴリIDがルートIDである。
+        // ・検索モードでない。
+        if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) {
+            // 商品TOPの表示処理
+
+            $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]);
+            $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2);
+        } else {
+            if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){
+                // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
+                $arrCategory_id = array("");
+            }
+
+            // 商品一覧の表示処理
+            $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']);
+
+            // 検索条件を画面に表示
+            // カテゴリー検索条件
+            if (strlen($_GET['category_id']) == 0) {
+                $arrSearch['category'] = "指定なし";
+            }else{
+                $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id));
+                $arrSearch['category'] = $arrCat;
+            }
+
+            // 商品名検索条件
+            if ($_GET['name'] === "") {
+                $arrSearch['name'] = "指定なし";
+            }else{
+                $arrSearch['name'] = $_GET['name'];
+            }
+        }
+
+        if($_POST['mode'] == "cart" && $_POST['product_id'] != "") {
+            // 値の正当性チェック
+            if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
+                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true);
+            } else {
+                // 入力値の変換
+                $this->arrErr = $this->lfCheckError($_POST['product_id']);
+                if(count($this->arrErr) == 0) {
+                    $objCartSess = new SC_CartSession();
+                    $classcategory_id = "classcategory_id". $_POST['product_id'];
+                    $classcategory_id1 = $_POST[$classcategory_id. '_1'];
+                    $classcategory_id2 = $_POST[$classcategory_id. '_2'];
+                    $quantity = "quantity". $_POST['product_id'];
+                    // 規格1が設定されていない場合
+                    if(!$this->tpl_classcat_find1[$_POST['product_id']]) {
+                        $classcategory_id1 = '0';
+                    }
+                    // 規格2が設定されていない場合
+                    if(!$this->tpl_classcat_find2[$_POST['product_id']]) {
+                        $classcategory_id2 = '0';
+                    }
+                    $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
+                    $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
+                    $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id()));
+                    exit;
+                }
+            }
+        }
+
+
+        // ページ送り機能用のURLを作成する。
+        $objURL = new Net_URL($_SERVER['PHP_SELF']);
+        foreach ($_REQUEST as $key => $value) {
+            if ($key == session_name() || $key == 'pageno') {
+                continue;
+            }
+            $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE));
+        }
+
+        if ($this->objNavi->now_page > 1) {
+            $objURL->addQueryString('pageno', $this->objNavi->now_page - 1);
+            $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString();
+        }
+        if ($this->objNavi->now_page < $this->objNavi->max_page) {
+            $objURL->addQueryString('pageno', $this->objNavi->now_page + 1);
+            $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString();
+        }
+
+        $this->tpl_subtitle = $tpl_subtitle;
+        $this->tpl_search_mode = $tpl_search_mode;
+
+        // 支払方法の取得
+        $this->arrPayment = $this->lfGetPayment();
+        // 入力情報を渡す
+        $this->arrForm = $_POST;
+
+        $this->category_id = $arrCategory_id[0];
+        $this->arrSearch = $arrSearch;
+        $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl";
+
+        $objView->assignobj($this);
+        $objView->display(SITE_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /* カテゴリIDがルートかどうかの判定 */
+    function lfIsRootCategory($category_id) {
+        $objQuery = new SC_Query();
+        $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id));
+        if($level == 1) {
+            return true;
+        }
+        return false;
+    }
+
+    /* 商品一覧の表示 */
+    function lfDispProductsList($category_id, $name, $disp_num, $orderby) {
+
+        $objQuery = new SC_Query();
+        $objDb = new SC_Helper_DB_Ex();
+        $this->tpl_pageno = defined("MOBILE_SITE") ? @$_GET['pageno'] : @$_POST['pageno'];
+
+        //表示順序
+        switch($orderby) {
+
+        //価格順
+        case 'price':
+            $col = "DISTINCT price02_min, product_id, product_code_min, product_code_max,"
+                . " name, comment1, comment2, comment3,"
+                . " main_list_comment, main_image, main_list_image,"
+                . " price01_min, price01_max, price02_max,"
+                . " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max,"
+                . " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee,"
+                . " status, product_flag, create_date, del_flg";
+            $from = "vw_products_allclass AS T1";
+            $order = "price02_min, product_id";
+            break;
+
+        //新着順
+        case 'date':
+            $col = "DISTINCT create_date, product_id, product_code_min, product_code_max,"
+                . " name, comment1, comment2, comment3,"
+                . " main_list_comment, main_image, main_list_image,"
+                . " price01_min, price01_max, price02_min, price02_max,"
+                . " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max,"
+                . " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee,"
+                . " status, product_flag, del_flg";
+            $from = "vw_products_allclass AS T1";
+            $order = "create_date DESC, product_id";
+            break;
+
+        default:
+            $col = "DISTINCT T1.product_id, product_code_min, product_code_max,"
+                . " price01_min, price01_max, price02_min, price02_max,"
+                . " stock_min, stock_max, stock_unlimited_min,"
+                . " stock_unlimited_max, del_flg, status, name, comment1,"
+                . " comment2, comment3, main_list_comment, main_image,"
+                . " main_list_image, product_flag, deliv_date_id, sale_limit,"
+                . " point_rate, sale_unlimited, create_date, deliv_fee, "
+                . " T4.product_rank, T4.category_rank";
+            $from = "vw_products_allclass AS T1"
+                . " JOIN ("
+                . " SELECT max(T3.rank) AS category_rank,"
+                . "        max(T2.rank) AS product_rank,"
+                . "        T2.product_id"
+                . "   FROM dtb_product_categories T2"
+                . "   JOIN dtb_category T3 USING (category_id)"
+                . " GROUP BY product_id) AS T4 USING (product_id)";
+            $order = "T4.category_rank DESC, T4.product_rank DESC";
+            break;
+        }
+
+        // 商品検索条件の作成（未削除、表示）
+        $where = "del_flg = 0 AND status = 1 ";
+        // カテゴリからのWHERE文字列取得
+        if ( $category_id ) {
+            list($tmp_where, $arrval) = $objDb->sfGetCatWhere($category_id);
+            if($tmp_where != "") {
+                $where.= " AND $tmp_where";
+            }
+        }
+
+        // 商品名をwhere文に
+        $name = ereg_replace(",", "", $name);// XXX
+        // 全角スペースを半角スペースに変換
+        $name = str_replace('　', ' ', $name);
+        // スペースでキーワードを分割
+        $names = preg_split("/ +/", $name);
+        // 分割したキーワードを一つずつwhere文に追加
+        foreach ($names as $val) {
+            if ( strlen($val) > 0 ){
+                $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) ";
+                $ret = SC_Utils_Ex::sfManualEscape($val);
+                $arrval[] = "%$ret%";
+                $arrval[] = "%$ret%";
+            }
+        }
+
+        if (empty($arrval)) {
+            $arrval = array();
+        }
+
+        // 行数の取得
+        $linemax = count($objQuery->getAll("SELECT DISTINCT product_id "
+                                         . "FROM vw_products_allclass AS allcls "
+                                         . (!empty($where) ? " WHERE " . $where
+                                                           : ""), $arrval));
+
+        $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用
+
+        // ページ送りの取得
+        $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX);
+
+        $strnavi = $this->objNavi->strnavi;
+        $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi);
+        // 表示文字列
+        $this->tpl_strnavi = empty($strnavi) ? "&nbsp;" : $strnavi;
+        $startno = $this->objNavi->start_row;                 // 開始行
+
+        // 取得範囲の指定(開始行番号、行数のセット)
+        $objQuery->setlimitoffset($disp_num, $startno);
+        // 表示順序
+        $objQuery->setorder($order);
+
+        // 検索結果の取得
+        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval);
+
+        // 規格名一覧
+        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
+        // 規格分類名一覧
+        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
+        // 規格セレクトボックス設定
+        if($disp_num == 15) {
+            for($i = 0; $i < count($this->arrProducts); $i++) {
+                $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
+                // 購入制限数を取得
+                $this->lfGetSaleLimit($this->arrProducts[$i]);
+            }
+        }
+    }
+
+    /* 規格セレクトボックスの作成 */
+    function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
+
+        $classcat_find1 = false;
+        $classcat_find2 = false;
+        // 在庫ありの商品の有無
+        $stock_find = false;
+
+        // 商品規格情報の取得
+        $arrProductsClass = $this->lfGetProductsClass($product_id);
+
+        // 規格1クラス名の取得
+        $this->tpl_class_name1[$product_id] =
+            isset($arrClassName[$arrProductsClass[0]['class_id1']])
+            ? $arrClassName[$arrProductsClass[0]['class_id1']]
+            : "";
+
+        // 規格2クラス名の取得
+        $this->tpl_class_name2[$product_id] =
+            isset($arrClassName[$arrProductsClass[0]['class_id2']])
+            ? $arrClassName[$arrProductsClass[0]['class_id2']]
+            : "";
+
+        // すべての組み合わせ数
+        $count = count($arrProductsClass);
+
+        $classcat_id1 = "";
+
+        $arrSele = array();
+        $arrList = array();
+
+        $list_id = 0;
+        $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";
+        $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
+
+        for ($i = 0; $i < $count; $i++) {
+            // 在庫のチェック
+            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
+                continue;
+            }
+
+            $stock_find = true;
+
+            // 規格1のセレクトボックス用
+            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
+                $arrList[$list_id].=");\n";
+                $arrVal[$list_id].=");\n";
+                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
+                $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
+                $list_id++;
+
+                $arrList[$list_id] = "";
+                $arrVal[$list_id] = "";
+            }
+
+            // 規格2のセレクトボックス用
+            $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
+
+            // セレクトボックス表示値
+            if($arrList[$list_id] == "") {
+                $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
+            } else {
+                $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
+            }
+
+            // セレクトボックスPOST値
+            if($arrVal[$list_id] == "") {
+                $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
+            } else {
+                $arrVal[$list_id].= ", '".$classcat_id2."'";
+            }
+        }
+
+        $arrList[$list_id].=");\n";
+        $arrVal[$list_id].=");\n";
+
+        // 規格1
+        $this->arrClassCat1[$product_id] = $arrSele;
+
+        $lists = "\tlists".$product_id. " = new Array(";
+        $no = 0;
+        foreach($arrList as $val) {
+            $this->tpl_javascript.= $val;
+            if ($no != 0) {
+                $lists.= ",list". $product_id. "_". $no;
+            } else {
+                $lists.= "list". $product_id. "_". $no;
+            }
+            $no++;
+        }
+        $this->tpl_javascript.= $lists.");\n";
+
+        $vals = "\tvals".$product_id. " = new Array(";
+        $no = 0;
+        foreach($arrVal as $val) {
+            $this->tpl_javascript.= $val;
+            if ($no != 0) {
+                $vals.= ",val". $product_id. "_". $no;
+            } else {
+                $vals.= "val". $product_id. "_". $no;
+            }
+            $no++;
+        }
+        $this->tpl_javascript.= $vals.");\n";
+
+        // 選択されている規格2ID
+        $classcategory_id = "classcategory_id". $product_id;
+
+        $classcategory_id_2 = $classcategory_id . "_2";
+        if (!isset($classcategory_id_2)) $classcategory_id_2 = "";
+        if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = "";
+
+        $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', "
+            . "'" . $classcategory_id_2 . "',"
+            . "'" . $product_id . "',"
+            . "'" . $_POST[$classcategory_id_2] ."'); ";
+
+        // 規格1が設定されている
+        if($arrProductsClass[0]['classcategory_id1'] != '0') {
+            $classcat_find1 = true;
+        }
+
+        // 規格2が設定されている
+        if($arrProductsClass[0]['classcategory_id2'] != '0') {
+            $classcat_find2 = true;
+        }
+
+        $this->tpl_classcat_find1[$product_id] = $classcat_find1;
+        $this->tpl_classcat_find2[$product_id] = $classcat_find2;
+        $this->tpl_stock_find[$product_id] = $stock_find;
+    }
+
+    /* 商品規格情報の取得 */
+    function lfGetProductsClass($product_id) {
+        $arrRet = array();
+        if(SC_Utils_Ex::sfIsInt($product_id)) {
+            // 商品規格取得
+            $objQuery = new SC_Query();
+            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
+            $table = "vw_product_class AS prdcls";
+            $where = "product_id = ?";
+            $objQuery->setorder("rank1 DESC, rank2 DESC");
+            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
+        }
+        return $arrRet;
+    }
+
+    /* 入力内容のチェック */
+    function lfCheckError($id) {
+
+        // 入力データを渡す。
+        $objErr = new SC_CheckError();
+
+        $classcategory_id1 = "classcategory_id". $id. "_1";
+        $classcategory_id2 = "classcategory_id". $id. "_2";
+        $quantity = "quantity". $id;
+        // 複数項目チェック
+        if ($this->tpl_classcat_find1[$id]) {
+            $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+        }
+        if ($this->tpl_classcat_find2[$id]) {
+            $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+        }
+        $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+
+        return $objErr->arrErr;
+    }
+
+    // 購入制限数の設定
+    function lfGetSaleLimit($product) {
+        //在庫が無限または購入制限値が設定値より大きい場合
+        if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
+            $this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
+        } else {
+            $this->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
+        }
+    }
+
+    //支払方法の取得
+    //payment_id    1:代金引換　2:銀行振り込み　3:現金書留
+    function lfGetPayment() {
+        $objQuery = new SC_Query;
+        $col = "payment_id, rule, payment_method";
+        $from = "dtb_payment";
+        $where = "del_flg = 0";
+        $order = "payment_id";
+        $objQuery->setorder($order);
+        $arrRet = $objQuery->select($col, $from, $where);
+        return $arrRet;
+    }
+
+    function lfconvertParam () {
+        foreach ($this->arrForm as $key => $value) {
+            if (preg_match('/^quantity[0-9]+/', $key)) {
+                 $this->arrForm[$key]
+                    = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE);
+            }
+        }
+    }
+}
+?>
Index: branches/version-2/data/class/SC_Initial.php
===================================================================
--- branches/version-2/data/class/SC_Initial.php	(revision 18176)
+++ branches/version-2/data/class/SC_Initial.php	(revision 18176)
@@ -0,0 +1,197 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * アプリケーションの初期設定クラス.
+ *
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ */
+class SC_Initial {
+
+    // {{{ cunstructor
+
+    /**
+     * コンストラクタ.
+     */
+    function SC_Initial() {
+
+        /** EC-CUBEのバージョン */
+        define('ECCUBE_VERSION', "2.4.0");
+    }
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * 初期設定を行う.
+     *
+     * @access protected
+     * @return void
+     */
+    function init() {
+        $this->requireInitialConfig();
+        $this->defineDSN();
+        $this->setErrorReporting();
+        $this->defineConstants();
+        $this->mbstringInit();
+        $this->createCacheDir();
+    }
+
+    /**
+     * 初期設定ファイルを読み込む.
+     *
+     * @access protected
+     * @return void
+     */
+    function requireInitialConfig() {
+
+        require_once(realpath(dirname( __FILE__)) ."/../install.php");
+    }
+
+    /**
+     * DSN を定義する.
+     *
+     * @access protected
+     * @return void
+     */
+    function defineDSN() {
+        if(defined('DB_TYPE') && defined('DB_USER') && defined('DB_PASSWORD')
+           && defined('DB_SERVER') && defined('DB_PORT') && defined('DB_NAME')) {
+            /** サイト用DB */
+            define ("DEFAULT_DSN",
+                    DB_TYPE . "://" . DB_USER . ":" . DB_PASSWORD . "@"
+                    . DB_SERVER . ":" .DB_PORT . "/" . DB_NAME);
+        } else {
+            define("DEFAULT_DSN", "pgsql://nobody:password@localhost:5432/eccubedb");
+        }
+    }
+
+
+    /**
+     * エラーレベル設定を行う.
+     *
+     * ・推奨値
+     *   開発時 - E_ALL
+     *   運用時 - E_ALL & ~E_NOTICE
+     *
+     * @access protected
+     * @return void
+     */
+    function setErrorReporting() {
+        error_reporting(E_ALL & ~E_NOTICE);
+    }
+
+    /**
+     * マルチバイト文字列設定を行う.
+     *
+     * TODO SJIS-win や, eucJP-win への対応
+     *
+     * @access protected
+     * @return void
+     */
+    function mbstringInit() {
+        ini_set("mbstring.http_input", CHAR_CODE);
+        ini_set("mbstring.http_output", CHAR_CODE);
+        ini_set("auto_detect_line_endings", 1);
+        ini_set("default_charset", CHAR_CODE);
+        ini_set("mbstring.internal_encoding", CHAR_CODE);
+        ini_set("mbstring.detect_order", "auto");
+        ini_set("mbstring.substitute_character", "none");
+        //ロケールを明示的に設定
+        setlocale(LC_ALL, LOCALE);
+    }
+
+    /**
+     * 定数を設定する.
+     *
+     * mtb_constants.php を読み込んで定数を設定する.
+     * キャッシュディレクトリに存在しない場合は, 初期データからコピーする.
+     *
+     * @access protected
+     * @return void
+     */
+    function defineConstants() {
+
+        $errorMessage = "<div style='color: #F00; font-weight: bold; "
+            . "background-color: #FEB; text-align: center'>"
+            . CACHE_PATH
+            . " にユーザ書込み権限(777等)を付与して下さい。</div>";
+
+        // 定数を設定
+        if (is_file(CACHE_PATH . "mtb_constants.php")) {
+            require_once(CACHE_PATH . "mtb_constants.php");
+
+            // キャッシュが無ければ, 初期データからコピー
+        } elseif (is_file(CACHE_PATH . "../mtb_constants_init.php")) {
+
+            $mtb_constants = file_get_contents(CACHE_PATH . "../mtb_constants_init.php");
+            if (is_writable(CACHE_PATH)) {
+                $handle = fopen(CACHE_PATH . "mtb_constants.php", "w");
+                if (!$handle) {
+                    die($errorMessage);
+                }
+                if (fwrite($handle, $mtb_constants) === false) {
+                    die($errorMessage);
+                }
+                fclose($handle);
+
+                require_once(CACHE_PATH . "mtb_constants.php");
+            } else {
+                die($errorMessage);
+            }
+        } else {
+            die(CACHE_PATH . "../mtb_constants_init.php が存在しません");
+        }
+    }
+
+    /**
+     * 各種キャッシュディレクトリを生成する.
+     *
+     * Smarty キャッシュディレクトリを生成する.
+     *
+     * @access protected
+     * @return void
+     */
+    function createCacheDir() {
+        if (defined("HTML_PATH")) {
+            umask(0);
+        	if (!file_exists(COMPILE_DIR)) {
+                mkdir(COMPILE_DIR);
+            }
+
+            if (!file_exists(MOBILE_COMPILE_DIR)) {
+                mkdir(MOBILE_COMPILE_DIR);
+            }
+
+            if (!file_exists(COMPILE_ADMIN_DIR)) {
+                mkdir(COMPILE_ADMIN_DIR);
+            }
+
+            if (!file_exists(COMPILE_FTP_DIR)) {
+                mkdir(COMPILE_FTP_DIR);
+            }
+        }
+    }
+}
+?>
