Index: /branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Holiday_Ex.php
===================================================================
--- /branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Holiday_Ex.php	(revision 22575)
+++ /branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Holiday_Ex.php	(revision 22575)
@@ -0,0 +1,39 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 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_REALDIR . 'helper/SC_Helper_Holiday.php';
+
+/**
+ * 休日を管理するヘルパークラス(拡張).
+ *
+ * LC_Helper_Holiday をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Holiday_Ex extends SC_Helper_Holiday
+{
+    //put your code here
+}
Index: /branches/version-2_12-dev/data/class/helper/SC_Helper_Holiday.php
===================================================================
--- /branches/version-2_12-dev/data/class/helper/SC_Helper_Holiday.php	(revision 22575)
+++ /branches/version-2_12-dev/data/class/helper/SC_Helper_Holiday.php	(revision 22575)
@@ -0,0 +1,158 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 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 pineray
+ * @version $Id:$
+ */
+class SC_Helper_Holiday
+{
+    /**
+     * 休日の情報を取得.
+     * 
+     * @param integer $holiday_id 休日ID
+     * @param boolean $has_deleted 削除された休日も含む場合 true; 初期値 false
+     * @return array
+     */
+    public function get($holiday_id, $has_deleted = false)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $where = 'holiday_id = ?';
+        if (!$has_deleted) {
+            $where .= ' AND del_flg = 0';
+        }
+        $arrRet = $objQuery->select('*', 'dtb_holiday', $where, array($holiday_id));
+        return $arrRet[0];
+    }
+
+    /**
+     * 休日一覧の取得.
+     *
+     * @param boolean $has_deleted 削除された休日も含む場合 true; 初期値 false
+     * @return array
+     */
+    public function getList($has_deleted = false)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $col = 'holiday_id, title, month, day';
+        $where = '';
+        if (!$has_deleted) {
+            $where .= 'del_flg = 0';
+        }
+        $table = 'dtb_holiday';
+        $objQuery->setOrder('rank DESC');
+        $arrRet = $objQuery->select($col, $table, $where);
+        return $arrRet;
+    }
+
+    /**
+     * 休日の登録.
+     * 
+     * @param array $sqlval
+     * @return multiple 登録成功:休日ID, 失敗:FALSE
+     */
+    public function save($sqlval)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+
+        $holiday_id = $sqlval['holiday_id'];
+        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
+        // 新規登録
+        if ($holiday_id == '') {
+            // INSERTの実行
+            $sqlval['rank'] = $objQuery->max('rank', 'dtb_holiday') + 1;
+            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
+            $sqlval['holiday_id'] = $objQuery->nextVal('dtb_holiday_holiday_id');
+            $ret = $objQuery->insert('dtb_holiday', $sqlval);
+        // 既存編集
+        } else {
+            unset($sqlval['creator_id']);
+            unset($sqlval['create_date']);
+            $where = 'holiday_id = ?';
+            $ret = $objQuery->update('dtb_holiday', $sqlval, $where, array($holiday_id));
+        }
+        return ($ret) ? $sqlval['holiday_id'] : FALSE;
+    }
+
+    /**
+     * 休日の削除.
+     * 
+     * @param integer $holiday_id 休日ID
+     * @return void
+     */
+    public function delete($holiday_id)
+    {
+        $objDb = new SC_Helper_DB_Ex();
+        // ランク付きレコードの削除
+        $objDb->sfDeleteRankRecord('dtb_holiday', 'holiday_id', $holiday_id, '', true);
+    }
+
+    /**
+     * 休日の表示順をひとつ上げる.
+     * 
+     * @param integer $holiday_id 休日ID
+     * @return void
+     */
+    public function rankUp($holiday_id)
+    {
+        $objDb = new SC_Helper_DB_Ex();
+        $objDb->sfRankUp('dtb_holiday', 'holiday_id', $holiday_id);
+    }
+
+    /**
+     * 休日の表示順をひとつ下げる.
+     * 
+     * @param integer $holiday_id 休日ID
+     * @return void
+     */
+    public function rankDown($holiday_id)
+    {
+        $objDb = new SC_Helper_DB_Ex();
+        $objDb->sfRankDown('dtb_holiday', 'holiday_id', $holiday_id);
+    }
+
+    /**
+     * 同じ日付の休日が存在するか確認.
+     * 
+     * @param integer $month
+     * @param integer $day
+     * @param integer $holiday_id
+     * @return boolean 同日付の休日が存在:true
+     */
+    public function isDateExist($month, $day, $holiday_id = NULL)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $where = 'del_flg = 0 AND month = ? AND day = ?';
+        $arrVal = array($month, $day);
+        if (!SC_Utils_Ex::isBlank($holiday_id)) {
+            $where .= ' AND holiday_id <> ?';
+            $arrVal[] = $holiday_id;
+        }
+        $arrRet = $objQuery->select('holiday_id, title', 'dtb_holiday', $where, $arrVal);
+
+        return !SC_Utils_Ex::isBlank($arrRet);
+    }
+}
Index: /branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php
===================================================================
--- /branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php	(revision 22567)
+++ /branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php	(revision 22575)
@@ -72,5 +72,5 @@
     {
 
-        $objDb = new SC_Helper_DB_Ex();
+        $objHoliday = new SC_Helper_Holiday_Ex();
 
         $objDate = new SC_Date_Ex();
@@ -80,20 +80,10 @@
         $mode = $this->getMode();
 
-        if (!empty($_POST)) {
-
-            $objFormParam = new SC_FormParam_Ex();
-            $this->lfInitParam($mode, $objFormParam);
-            $objFormParam->setParam($_POST);
-            $objFormParam->convParam();
-            $holiday_id = $objFormParam->getValue('holiday_id');
-
-            $this->arrErr = $this->lfCheckError($mode, $objFormParam);
-            if (!empty($this->arrErr['holiday_id'])) {
-                trigger_error('', E_USER_ERROR);
-                return;
-            }
-
-            $post = $objFormParam->getHashArray();
-        }
+        $objFormParam = new SC_FormParam_Ex();
+        $this->lfInitParam($mode, $objFormParam);
+        $objFormParam->setParam($_POST);
+        $objFormParam->convParam();
+
+        $holiday_id = $objFormParam->getValue('holiday_id');
 
         // 要求判定
@@ -101,45 +91,40 @@
             // 編集処理
             case 'edit':
-                // POST値の引き継ぎ
-                $this->arrForm = $this->arrForm = $_POST;
+                $this->arrErr = $this->lfCheckError($objFormParam, $objHoliday);
+                if (!SC_Utils_Ex::isBlank($this->arrErr['holiday_id'])) {
+                    trigger_error('', E_USER_ERROR);
+                    return;
+                }
 
                 if (count($this->arrErr) <= 0) {
-                    // 新規作成
-                    if ($post['holiday_id'] == '') {
-                        $this->lfInsertClass($this->arrForm, $_SESSION['member_id']);
+                    // POST値の引き継ぎ
+                    $arrParam = $objFormParam->getHashArray();
+                    // 登録実行
+                    $res_holiday_id = $this->doRegist($holiday_id, $arrParam, $objHoliday);
+                    if ($res_holiday_id !== FALSE) {
+                        // 完了メッセージ
+                        $holiday_id = $res_holiday_id;
+                        $this->tpl_onload = "alert('登録が完了しました。');";
                     }
-                    // 既存編集
-                    else {
-                        $this->lfUpdateClass($this->arrForm, $post['holiday_id']);
-                    }
-
-                    // 再表示
-                    $this->objDisplay->reload();
-                } else {
-                    // POSTデータを引き継ぐ
-                    $this->tpl_holiday_id = $post['holiday_id'];
                 }
+                // POSTデータを引き継ぐ
+                $this->tpl_holiday_id = $holiday_id;
+
                 break;
             // 削除
             case 'delete':
-                $objDb->sfDeleteRankRecord('dtb_holiday', 'holiday_id', $post['holiday_id'], '', true);
-
-                // 再表示
-                $this->objDisplay->reload();
+                $objHoliday->delete($holiday_id);
                 break;
             // 編集前処理
             case 'pre_edit':
                 // 編集項目を取得する。
-                $arrHolidayData = $this->lfGetHolidayDataByHolidayID($post['holiday_id']);
-
-                // 入力項目にカテゴリ名を入力する。
-                $this->arrForm['title'] = $arrHolidayData[0]['title'];
-                $this->arrForm['month'] = $arrHolidayData[0]['month'];
-                $this->arrForm['day'] = $arrHolidayData[0]['day'];
+                $arrHolidayData = $objHoliday->get($holiday_id);
+                $objFormParam->setParam($arrHolidayData);
+
                 // POSTデータを引き継ぐ
-                $this->tpl_holiday_id = $post['holiday_id'];
+                $this->tpl_holiday_id = $holiday_id;
                 break;
             case 'down':
-                $objDb->sfRankDown('dtb_holiday', 'holiday_id', $post['holiday_id']);
+                $objHoliday->rankDown($holiday_id);
 
                 // 再表示
@@ -147,5 +132,5 @@
                 break;
             case 'up':
-                $objDb->sfRankUp('dtb_holiday', 'holiday_id', $post['holiday_id']);
+                $objHoliday->rankUp($holiday_id);
 
                 // 再表示
@@ -156,8 +141,7 @@
         }
 
-        $this->arrHoliday = $this->lfGetHolidayList();
-        // POSTデータを引き継ぐ
-        $this->tpl_holiday_id = $holiday_id;
-
+        $this->arrForm = $objFormParam->getFormParamList();
+
+        $this->arrHoliday = $objHoliday->getList();
     }
 
@@ -172,52 +156,17 @@
     }
 
-    function lfGetHolidayDataByHolidayID($holiday_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-
-        $where = 'holiday_id = ?';
-        return $objQuery->select('title, month, day', 'dtb_holiday', $where, array($holiday_id));
-    }
-
-    function lfGetHolidayList()
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-
-        $where = 'del_flg <> 1';
-        $objQuery->setOrder('rank DESC');
-        return $objQuery->select('holiday_id, title, month, day', 'dtb_holiday', $where);
-    }
-
-    /* DBへの挿入 */
-    function lfInsertClass($arrData, $member_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        // INSERTする値を作成する。
-        $sqlval['title'] = $arrData['title'];
-        $sqlval['month'] = $arrData['month'];
-        $sqlval['day'] = $arrData['day'];
-        $sqlval['creator_id'] = $member_id;
-        $sqlval['rank'] = $objQuery->max('rank', 'dtb_holiday') + 1;
-        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
-        $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
-        // INSERTの実行
-        $sqlval['holiday_id'] = $objQuery->nextVal('dtb_holiday_holiday_id');
-        $ret = $objQuery->insert('dtb_holiday', $sqlval);
-        return $ret;
-    }
-
-    /* DBへの更新 */
-    function lfUpdateClass($arrData)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        // UPDATEする値を作成する。
-        $sqlval['title'] = $arrData['title'];
-        $sqlval['month'] = $arrData['month'];
-        $sqlval['day'] = $arrData['day'];
-        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
-        $where = 'holiday_id = ?';
-        // UPDATEの実行
-        $ret = $objQuery->update('dtb_holiday', $sqlval, $where, array($arrData['holiday_id']));
-        return $ret;
+    /**
+     * 登録処理を実行.
+     * 
+     * @param integer $holiday_id
+     * @param array $sqlval
+     * @param object $objHoliday
+     * @return multiple
+     */
+    function doRegist($holiday_id, $sqlval, SC_Helper_Holiday_Ex $objHoliday)
+    {
+        $sqlval['holiday_id'] = $holiday_id;
+        $sqlval['creator_id'] = $_SESSION['member_id'];
+        return $objHoliday->save($sqlval);
     }
 
@@ -226,16 +175,16 @@
         switch ($mode) {
             case 'edit':
+            case 'pre_edit':
                 $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
                 $objFormParam->addParam('月', 'month', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
                 $objFormParam->addParam('日', 'day', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
-                // breakしない
+                $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
+                break;
             case 'delete':
-            case 'pre_edit':
             case 'down':
             case 'up':
+            default:
                 $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
                 break;
-            default:
-                break;
         }
     }
@@ -244,27 +193,16 @@
      * 入力エラーチェック
      *
-     * @param string $mode
+     * @param object $objFormParam
+     * @param object $objHoliday
      * @return array
      */
-    function lfCheckError($mode, &$objFormParam)
-    {
-        $objFormParam->convParam();
+    function lfCheckError(&$objFormParam, SC_Helper_Holiday_Ex &$objHoliday)
+    {
         $arrErr = $objFormParam->checkError();
-        $post = $objFormParam->getHashArray();
-
-        if (!isset($arrErr['date'])) {
-            $objQuery =& SC_Query_Ex::getSingletonInstance();
-            $where = 'del_flg = 0 AND month = ? AND day = ?';
-            $arrWhereVal = array($post['month'], $post['day']);
-            if (!empty($post['holiday_id'])) {
-                $where .= ' AND holiday_id <> ?';
-                $arrWhereVal[] = $post['holiday_id'];
-            }
-            $arrRet = $objQuery->select('count(holiday_id) as count', 'dtb_holiday', $where, $arrWhereVal);
-
-            // 編集中のレコード以外に同じ日付が存在する場合
-            if ($arrRet[0]['count'] > 0) {
-                $arrErr['date'] = '※ 既に同じ日付の登録が存在します。<br>';
-            }
+        $arrForm = $objFormParam->getHashArray();
+
+        // 編集中のレコード以外に同じ日付が存在する場合
+        if ($objHoliday->isDateExist($arrForm['month'], $arrForm['day'], $arrForm['holiday_id'])) {
+            $arrErr['date'] = '※ 既に同じ日付の登録が存在します。<br>';
         }
         return $arrErr;
Index: /branches/version-2_12-dev/data/Smarty/templates/admin/basis/holiday.tpl
===================================================================
--- /branches/version-2_12-dev/data/Smarty/templates/admin/basis/holiday.tpl	(revision 22571)
+++ /branches/version-2_12-dev/data/Smarty/templates/admin/basis/holiday.tpl	(revision 22575)
@@ -34,5 +34,5 @@
             <td>
                 <!--{if $arrErr.title}--><span class="attention"><!--{$arrErr.title}--></span><!--{/if}-->
-                <input type="text" name="title" value="<!--{$arrForm.title|h}-->" maxlength="<!--{$smarty.const.SMTEXT_LEN}-->" style="" size="60" class="box60"/>
+                <input type="text" name="title" value="<!--{$arrForm.title.value|h}-->" maxlength="<!--{$smarty.const.SMTEXT_LEN}-->" style="" size="60" class="box60"/>
                 <span class="attention"> (上限<!--{$smarty.const.SMTEXT_LEN}-->文字)</span>
             </td>
@@ -48,9 +48,9 @@
                 <select name="month" style="<!--{$arrErr.month|sfGetErrorColor}-->">
                     <option value="">--</option>
-                    <!--{html_options options=$arrMonth selected=$arrForm.month}-->
+                    <!--{html_options options=$arrMonth selected=$arrForm.month.value}-->
                 </select>月
                 <select name="day" style="<!--{$arrErr.day|sfGetErrorColor}-->">
                     <option value="">--</option>
-                    <!--{html_options options=$arrDay selected=$arrForm.day}-->
+                    <!--{html_options options=$arrDay selected=$arrForm.day.value}-->
                 </select>日
                 <br />
