開発メモ

開発用のメモです。

EC CUBE 時限公開プラグイン 改修( 検索機能追加)

検索対象外になる商品を del_flg = 9 にすることで他のプラグインに影響しない検索結果対応

<?php
require_once dirname ( __FILE__ ) . "/define.php";

class AutoDisplay extends SC_Plugin_Base {

    // TODO コンストラクタ
    public function __construct(array $arrSelfInfo) {

        parent::__construct ( $arrSelfInfo );

    }

    function install(array $arrPlugin, SC_Plugin_Installer $installer) {

        $installer->addColumn ( "dtb_products", "auto_display_status", "int not null default 0" );
        $installer->addColumn ( "dtb_products", "auto_display_start_date", "timestamp" );
        $installer->addColumn ( "dtb_products", "auto_display_end_date", "timestamp" );

        $table = "mtb_auto_display_status";
        $installer->sql ( "CREATE TABLE " . $table . " (id INT PRIMARY KEY, name TEXT, rank int)" );
        $installer->insert ( $table, array (
            "id" => 0,
            "name" => "常時公開",
            "rank" => 0
        ) );
        $installer->insert ( $table, array (
            "id" => 1,
            "name" => "時限公開",
            "rank" => 1
        ) );

    }

    function uninstall(array $arrPlugin, SC_Plugin_Installer $installer) {

        $installer->dropColumn ( "dtb_products", "auto_display_status" );
        $installer->dropColumn ( "dtb_products", "auto_display_start_date" );
        $installer->dropColumn ( "dtb_products", "auto_display_end_date" );

        $installer->sql ( "DROP TABLE " . $table );

    }

    // TODO [HOOKPOINT] 事前処理
    function preProcess(LC_Page $objPage) {


    }

    // TODO [HOOKPOINT] 事後処理
    function process(LC_Page $objPage) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理
    function prefilterTransform(&$source, LC_Page_Ex $objPage, $filename) {

        $objTransform = new SC_Helper_Transform_Ex ( $source );
        if (GC_Utils_Ex::isFrontFunction ()) {
            $device_type_id = SC_Display_Ex::detectDevice ();
            switch ($device_type_id) {
            case DEVICE_TYPE_PC :
                $filename = str_replace ( TEMPLATE_REALDIR, '', $filename );
                self::prefilterTransform_pc ( $source, $objPage, $filename, $objTransform );
                break;

            case DEVICE_TYPE_SMARTPHONE :
                $filename = str_replace ( SMARTPHONE_TEMPLATE_REALDIR, '', $filename );
                self::prefilterTransform_sp ( $source, $objPage, $filename, $objTransform );
                break;

            case DEVICE_TYPE_MOBILE :
                $filename = str_replace ( MOBILE_TEMPLATE_REALDIR, '', $filename );
                self::prefilterTransform_mb ( $source, $objPage, $filename, $objTransform );
                break;

            default :
                break;
            }
        } else {
            $filename = str_replace ( TEMPLATE_ADMIN_REALDIR, '', $filename );
            self::prefilterTransform_ad ( $source, $objPage, $filename, $objTransform );
        }

        $source = $objTransform->getHTML ();

    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (PC用)
    function prefilterTransform_pc(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (スマホ用)
    function prefilterTransform_sp(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (携帯電話用)
    function prefilterTransform_mb(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (管理画面)
    function prefilterTransform_ad(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {

        $plugin_code = $this->arrSelfInfo ["plugin_code"];

        $plugin_dir = PLUGIN_UPLOAD_REALDIR . $plugin_code;

        switch ($filename) {
        case "products/index.tpl" :

            echo $filename;

            $html = file_get_contents ( $plugin_dir . "/template/admin/products/index_search.tpl" );
            $objTransform->select ( "table", 0 )->appendChild ( $html );

            $html = file_get_contents ( $plugin_dir . "/template/admin/products/index_result_th.tpl" );
            $objTransform->select ( "#products-search-result", 0 )->find ( "tr th", 6 )->appendChild ( $html );

            $html = file_get_contents ( $plugin_dir . "/template/admin/products/index_result_td.tpl" );
            $objTransform->select ( "#products-search-result", 0 )->find ( "tr td", 6 )->appendChild ( $html );

            break;

        case "products/confirm.tpl" :

            $html = file_get_contents ( $plugin_dir . "/template/admin/products/confirm.tpl" );
            $objTransform->select ( "table", 0 )->find ( "tr", 2 )->insertAfter ( $html );

            break;

        case "products/product.tpl" :
            $html = file_get_contents ( $plugin_dir . "/template/admin/products/product.tpl" );
            $objTransform->select ( ".form", 0 )->find ( "tr", 4 )->insertAfter ( $html );

            break;
        }

    }

    // TODO [HOOKPOINT] クラス読み込み
    function loadClassFileChange(&$classname, &$classpath) {


    }

    // TODO [HOOKPOINT] フォーム追加処理
    function SC_FormParam_construct($class_name, SC_FormParam $objFormParam) {

        if (strcmp ( $class_name, "LC_Page_Admin_Products_Product" ) === 0) {
            $objFormParam->addParam ( "[検索データ] 時限公開設定", "search_auto_display_status", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ) );

            self::setDateParam ( $objFormParam, "[検索データ] 公開開始日時・開始", "search_auto_display_start_date_start" );
            self::setDateParam ( $objFormParam, "[検索データ] 公開開始日時・終了", "search_auto_display_start_date_end" );
            self::setDateParam ( $objFormParam, "[検索データ] 公開終了日時・開始", "search_auto_display_end_date_start" );
            self::setDateParam ( $objFormParam, "[検索データ] 公開終了日時・終了", "search_auto_display_end_date_end" );

            $objFormParam->addParam ( "時限公開設定", "auto_display_status", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ) );

            self::setDateParam ( $objFormParam, "公開開始日時", "auto_display_start_date" );
            self::setDateParam ( $objFormParam, "公開終了日時", "auto_display_end_date" );
        } elseif (strcmp ( $class_name, "LC_Page_Admin_Products" ) === 0) {
            $objFormParam->addParam ( "時限公開設定", "search_auto_display_status", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ) );

            self::setDateParam ( $objFormParam, "公開開始日時・開始", "search_auto_display_start_date_start" );
            self::setDateParam ( $objFormParam, "公開開始日時・終了", "search_auto_display_start_date_end" );
            self::setDateParam ( $objFormParam, "公開終了日時・開始", "search_auto_display_end_date_start" );
            self::setDateParam ( $objFormParam, "公開終了日時・終了", "search_auto_display_end_date_end" );
        }

    }

    function setDateParam(SC_FormParam $objFormParam, $dispname, $keyname) {

        $objFormParam->addParam ( "$dispname(年)", "{$keyname}_year", INT_LEN, "a", array (
            "NUM_CHECK",
            "MAX_LENGTH_CHECK"
        ), '', false );
        $objFormParam->addParam ( "$dispname(月)", "{$keyname}_month", INT_LEN, "a", array (
            "NUM_CHECK",
            "MAX_LENGTH_CHECK"
        ), '', false );
        $objFormParam->addParam ( "$dispname(日)", "{$keyname}_day", INT_LEN, "a", array (
            "NUM_CHECK",
            "MAX_LENGTH_CHECK"
        ), '', false );
        $objFormParam->addParam ( "$dispname(時)", "{$keyname}_hour", INT_LEN, "a", array (
            "NUM_CHECK",
            "MAX_LENGTH_CHECK"
        ), '', false );
        $objFormParam->addParam ( "$dispname(分)", "{$keyname}_min", INT_LEN, "a", array (
            "NUM_CHECK",
            "MAX_LENGTH_CHECK"
        ), '', false );
        $objFormParam->addParam ( "$dispname(秒)", "{$keyname}_sec", INT_LEN, "a", array (
            "NUM_CHECK",
            "MAX_LENGTH_CHECK"
        ), 0, false );

    }

    function LC_Page_Products_List_action_before(LC_Page_Products_List $objPage) {

        self::changeProductStatus ( $objPage );

    }

    function LC_Page_Products_Detail_action_before(LC_Page_Products_Detail $objPage) {

        self::changeProductStatus ( $objPage );

    }

    function LC_Page_Admin_Products_action_check(LC_Page_Admin_Products &$objPage) {

        $objFormParam = new SC_FormParam_Ex ();
        $objPage->lfInitParam ( $objFormParam );
        self::SC_FormParam_construct ( get_class ( $objPage ), $objFormParam );

        $objFormParam->setParam ( $_POST );

        $objErr = new SC_CheckError_Ex ( $objFormParam->getHashArray () );

        $objErr->arrErr = $objPage->lfCheckError ( $objFormParam );
        if (count ( $objErr->arrErr )) {
            if (count ( $objPage->arrErr )) {
                $objErr->arrErr = array_merge ( $objErr->arrErr, $objPage->arrErr );
            }
        } else {
            $objErr->arrErr = $objPage->arrErr;
        }

        if (SC_Utils_Ex::isBlank ( $objPage->arrForm )) {
            $objPage->arrForm = $objFormParam->getHashArray ();
        }

        self::checkDate ( $objErr, "公開開始日・開始", "search_auto_display_start_date_start" );
        self::checkDate ( $objErr, "公開開始日・終了", "search_auto_display_start_date_end" );
        self::checkDate ( $objErr, "公開終了日・開始", "search_auto_display_end_date_start" );
        self::checkDate ( $objErr, "公開終了日・終了", "search_auto_display_end_date_end" );

        self::checkSetTerm ( $objErr, "公開開始日・開始", "公開開始日・終了", "search_auto_display_start_date_start", "search_auto_display_start_date_end" );
        self::checkSetTerm ( $objErr, "公開開始日・開始", "公開終了日・開始", "search_auto_display_start_date_start", "search_auto_display_end_date_start" );
        self::checkSetTerm ( $objErr, "公開開始日・開始", "公開終了日・終了", "search_auto_display_start_date_start", "search_auto_display_end_date_end" );
        self::checkSetTerm ( $objErr, "公開開始日・終了", "公開終了日・終了", "search_auto_display_start_date_end", "search_auto_display_end_date_end" );

        $objPage->arrErr = $objErr->arrErr;

    }

    function LC_Page_Admin_Products_action_before(LC_Page_Admin_Products $objPage) {

        $objQuery = SC_Query_Ex::getSingletonInstance ();
        $objQuery->begin ();

        // 管理画面上での検索除外対象を復活させる
        $objQuery->update ( "dtb_products", array (
            "del_flg" => 0
        ), "del_flg = 9" );

        self::LC_Page_Admin_Products_action_check ( $objPage );

        if (SC_Utils_Ex::isBlank ( $objPage->arrErr )) {
            $objQuery->setWhere ( "" );
            $arrVal = array ();

            $objSql = new SC_SelectSql_Ex ();

            $column = "auto_display_start_date";

            $from_year = "search_{$column}_start_year";
            $from_month = "search_{$column}_start_month";
            $from_day = "search_{$column}_start_day";
            $to_year = "search_{$column}_end_year";
            $to_month = "search_{$column}_end_month";
            $to_day = "search_{$column}_end_day";

            if (is_numeric ( $objPage->arrForm [$from_year] ) || is_numeric ( $objPage->arrForm [$to_year] )) {
                $from_year = $objPage->arrForm [$from_year];
                $from_month = $objPage->arrForm [$from_month];
                $from_day = $objPage->arrForm [$from_day];
                $to_year = $objPage->arrForm [$to_year];
                $to_month = $objPage->arrForm [$to_month];
                $to_day = $objPage->arrForm [$to_day];

                $arrVal = array_merge ( $arrVal, $objSql->selectTermRange ( $from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column ) );
            }

            $column = "auto_display_end_date";

            $from_year = "search_{$column}_start_year";
            $from_month = "search_{$column}_start_month";
            $from_day = "search_{$column}_start_day";
            $to_year = "search_{$column}_end_year";
            $to_month = "search_{$column}_end_month";
            $to_day = "search_{$column}_end_day";

            if (is_numeric ( $objPage->arrForm [$from_year] ) || is_numeric ( $objPage->arrForm [$to_year] )) {
                $from_year = $objPage->arrForm [$from_year];
                $from_month = $objPage->arrForm [$from_month];
                $from_day = $objPage->arrForm [$from_day];
                $to_year = $objPage->arrForm [$to_year];
                $to_month = $objPage->arrForm [$to_month];
                $to_day = $objPage->arrForm [$to_day];

                $arrVal = array_merge ( $arrVal, $objSql->selectTermRange ( $from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column ) );
            }

            $column = "auto_display_end_date";
            $search = "search_{$column}";

            if (is_numeric ( $objPage->arrForm [$search] )) {
                $objPage->arrForm [$search] = array (
                    $objPage->arrForm [$search]
                );
            }
            if (is_array ( $objPage->arrForm [$search] )) {
                $arrVal = array_merge ( $arrVal, $objSql->setItemTerm ( $objPage->arrForm [$search], $column ) );
            }

            $objSql->setSelect ( "SELECT product_id FROM dtb_products" );
            $select = $objSql->getSql ( 1 );

            if (count ( $arrVal ) > 0) {
                $objQuery->update ( "dtb_products", array (
                    "del_flg" => 9
                ), "product_id NOT IN ($select) AND del_flg = 0", $arrVal );
            }
        }

        self::changeProductStatus ( $objPage );

    }

    function LC_Page_Admin_Products_action_after(LC_Page_Admin_Products $objPage) {

        $objQuery = SC_Query_Ex::getSingletonInstance ();

        $masterDate = new SC_DB_MasterData_Ex ();

        $table = "mtb_auto_display_status";
        $objPage->arrAutoDispStatus = $masterDate->getMasterData ( $table );

        $objDate = new SC_Date_Ex ( RELEASE_YEAR );

        $objPage->arrDispYear = $objDate->getYear ();
        $objPage->arrDispMonth = $objDate->getMonth ();
        $objPage->arrDispDay = $objDate->getDay ();
        $objPage->arrDispHour = $objDate->getHour ();
        $objPage->arrDispMinutes = $objDate->getMinutesInterval ();

        // 管理画面上での検索除外対象を復活させる
        $objQuery->update ( "dtb_products", array (
            "del_flg" => 0
        ), "del_flg = 9" );

        if ($objQuery->inTransaction ()) {
            $objQuery->commit ();
        }

        self::LC_Page_Admin_Products_action_check ( $objPage );

        if (! SC_Utils_Ex::isBlank ( $objPage->arrErr )) {
            $objPage->arrProducts = array ();
            $objPage->arrPagenavi = null;
        } else {
            foreach ( $objPage->arrProducts as &$arrProduct ) {
                $arrProduct = array_merge ( $arrProduct, $objQuery->getRow ( "auto_display_status,auto_display_start_date,auto_display_end_date", "dtb_products", "product_id = ?", array (
                    $arrProduct ["product_id"]
                ) ) );
            }
        }

    }

    function LC_Page_Admin_Products_Product_action_after(LC_Page_Admin_Products_Product $objPage) {

        $objQuery = SC_Query_Ex::getSingletonInstance ();

        $masterDate = new SC_DB_MasterData_Ex ();

        $table = "mtb_auto_display_status";
        $objPage->arrAutoDispStatus = $masterDate->getMasterData ( $table );

        $objDate = new SC_Date_Ex ( RELEASE_YEAR );

        $objPage->arrDispYear = $objDate->getYear ();
        $objPage->arrDispMonth = $objDate->getMonth ();
        $objPage->arrDispDay = $objDate->getDay ();
        $objPage->arrDispHour = $objDate->getHour ();
        $objPage->arrDispMinutes = $objDate->getMinutesInterval ();

        switch ($objPage->getMode ()) {
        case 'pre_edit' :
            if (is_numeric ( $objPage->arrForm ["product_id"] )) {
                $product_id = $objPage->arrForm ["product_id"];
                $product = $objQuery->getRow ( "*", "dtb_products", "product_id=?", ( array ) $product_id );
                // auto_display_status,auto_display_start_date,auto_display_end_date

                $objPage->arrForm ["auto_display_status"] = $product ["auto_display_status"];

                if (! empty ( $product ["auto_display_start_date"] )) {
                    $objPage->arrForm ["auto_display_start_date_year"] = date ( "Y", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_month"] = date ( "m", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_day"] = date ( "d", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_hour"] = date ( "h", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_min"] = date ( "i", strtotime ( $product ["auto_display_start_date"] ) );
                }

                if (! empty ( $product ["auto_display_end_date"] )) {
                    $objPage->arrForm ["auto_display_end_date_year"] = date ( "Y", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_month"] = date ( "m", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_day"] = date ( "d", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_hour"] = date ( "h", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_min"] = date ( "i", strtotime ( $product ["auto_display_end_date"] ) );
                }
            }
            break;

        case 'edit' :
            self::LC_Page_Admin_Products_Product_action_after_check ( $objPage );
            break;

        case 'complete' :
            if (SC_Utils_Ex::isBlank ( $objPage->arrErr )) {
                if (is_numeric ( $objPage->arrForm ["product_id"] )) {
                    $product_id = $objPage->arrForm ["product_id"];

                    $arrVal = array ();
                    $arrVal ["auto_display_status"] = $_POST ["auto_display_status"];

                    $year = $_POST ["auto_display_start_date_year"];
                    $month = $_POST ["auto_display_start_date_month"];
                    $day = $_POST ["auto_display_start_date_day"];
                    $hour = $_POST ["auto_display_start_date_hour"];
                    $minutes = $_POST ["auto_display_start_date_min"];
                    $arrVal ["auto_display_start_date"] = SC_Utils_Ex::sfGetTimestampistime ( $year, $month, $day, $hour, $minutes );

                    $year = $_POST ["auto_display_end_date_year"];
                    $month = $_POST ["auto_display_end_date_month"];
                    $day = $_POST ["auto_display_end_date_day"];
                    $hour = $_POST ["auto_display_end_date_hour"];
                    $minutes = $_POST ["auto_display_end_date_min"];
                    $arrVal ["auto_display_end_date"] = SC_Utils_Ex::sfGetTimestampistime ( $year, $month, $day, $hour, $minutes, true );

                    $objQuery->update ( "dtb_products", $arrVal, "product_id=?", ( array ) $product_id );
                }
            }
            break;
        }

    }

    function LC_Page_Admin_Products_Product_action_after_check(LC_Page_Admin_Products_Product $objPage) {

        $objErr = new SC_CheckError_Ex ( $objPage->arrForm );
        if (count ( $objPage->arrErr ) > 0) {
            $objErr->arrErr = $objPage->arrErr;
        }

        $objErr->doFunc ( array (
            "時限公開設定",
            "auto_display_status"
        ), array (
            "EXIST_CHECK"
        ) );

        self::checkDate ( $objErr, "公開開始日時", "auto_display_start_date" );
        self::checkDate ( $objErr, "公開終了日時", "auto_display_end_date" );

        self::checkSetTerm2 ( $objErr, "公開開始日時", "公開終了日時", "auto_display_start_date", "auto_display_end_date" );

        if ($objPage->arrForm ["auto_display_status"] == "1") {
            if (SC_Utils_Ex::isBlank ( $objErr->arrErr )) {
                $objErr->doFunc ( array (
                    "公開開始日時または公開終了日時",
                    "auto_display_start_date_year",
                    "auto_display_end_date_year"
                ), array (
                    "ONE_EXIST_CHECK"
                ) );
            }
        }

        $objPage->arrErr = $objErr->arrErr;
        if (count ( $objPage->arrErr ) > 0) {

            // アップロードファイル情報の初期化
            $objUpFile = new SC_UploadFile_Ex ( IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR );
            $objPage->lfInitFile ( $objUpFile );
            $objUpFile->setHiddenFileList ( $_POST );

            // ダウンロード販売ファイル情報の初期化
            $objDownFile = new SC_UploadFile_Ex ( DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR );
            $objPage->lfInitDownFile ( $objDownFile );
            $objDownFile->setHiddenFileList ( $_POST );

            // 入力画面表示設定
            $objPage->arrForm = $objPage->lfSetViewParam_InputPage ( $objUpFile, $objDownFile, $objPage->arrForm );
            // ページonload時のJavaScript設定
            $objPage->tpl_onload = $objPage->lfSetOnloadJavaScript_InputPage ();

            $objPage->tpl_mainpage = 'products/product.tpl';
            $objPage->tpl_subtitle = '商品登録';
        }

    }

    function checkDate(SC_CheckError &$objErr, $disp_name, $yearname) {

        if (is_numeric ( $objErr->arrParam ["{$yearname}_year"] )) {
            $objErr->doFunc ( array (
                $disp_name,
                "{$yearname}_year",
                "{$yearname}_month",
                "{$yearname}_day"
            ), array (
                "CHECK_DATE"
            ) );
        }

    }

    function checkSetTerm(SC_CheckError &$objErr, $disp_name1, $disp_name2, $yearname1, $yearname2) {

        $objErr->doFunc ( array (
            $disp_name1,
            $disp_name2,
            "{$yearname1}_year",
            "{$yearname1}_month",
            "{$yearname1}_day",
            "{$yearname2}_year",
            "{$yearname2}_month",
            "{$yearname2}_day"
        ), array (
            "CHECK_SET_TERM"
        ) );

    }

    function checkSetTerm2(SC_CheckError &$objErr, $disp_name1, $disp_name2, $yearname1, $yearname2) {

        $objErr->doFunc ( array (
            $disp_name1,
            $disp_name2,
            "{$yearname1}_year",
            "{$yearname1}_month",
            "{$yearname1}_day",
            "{$yearname1}_hour",
            "{$yearname1}_min",
            "{$yearname1}_sec",
            "{$yearname2}_year",
            "{$yearname2}_month",
            "{$yearname2}_day",
            "{$yearname2}_hour",
            "{$yearname2}_min",
            "{$yearname2}_sec"
        ), array (
            "CHECK_SET_TERM2"
        ) );

    }

    function sfGetTimestamp(LC_Page $objPage, $keyname, $last) {

        $year = $objPage->arrForm ["{$keyname}_year"];
        $month = $objPage->arrForm ["{$keyname}_month"];
        $day = $objPage->arrForm ["{$keyname}_day"];
        return SC_Utils_Ex::sfGetTimestamp ( $year, $month, $day, $last );

    }

    function changeProductStatus(LC_Page $objPage) {

        $objQuery = SC_Query_Ex::getSingletonInstance ();
        $objQuery->begin ();

        // 管理画面上での検索除外対象を復活させる
        $objQuery->update ( "dtb_products", array (
            "del_flg" => 0
        ), "del_flg = 9" );

        // 期間外(非公開)
        $objQuery->update ( "dtb_products", array (
            "status" => "2",
            "update_date" => "CURRENT_TIMESTAMP"
        ), "     auto_display_status = 1
             AND del_flg             = 0
             AND status              = 1
             AND CASE WHEN auto_display_start_date IS NOT NULL
                           THEN auto_display_start_date > CURRENT_TIMESTAMP
                      WHEN auto_display_end_date   IS NOT NULL
                           THEN auto_display_end_date   < CURRENT_TIMESTAMP
                      ELSE FALSE END" );

        // 期間内(公開)
        $objQuery->update ( "dtb_products", array (
            "status" => "1",
            "update_date" => "CURRENT_TIMESTAMP"
        ), "     auto_display_status = 1
             AND del_flg             = 0
             AND status              = 2
             AND CASE WHEN auto_display_start_date IS NOT NULL
                           THEN NOT auto_display_start_date > CURRENT_TIMESTAMP
                      WHEN auto_display_end_date   IS NOT NULL
                           THEN NOT auto_display_end_date   < CURRENT_TIMESTAMP
                      ELSE FALSE END" );

        $objQuery->commit ();

        // 商品数量を再計算
        $objDb = new SC_Helper_DB_Ex ();
        $objDb->sfCountCategory ( $objQuery );
        $objDb->sfCountMaker ( $objQuery );

    }

}

EC CUBE 時限公開プラグイン

追加カラム

dtb_products

カラム名 カラムタイプ 備考
auto_display_status int not null default 0 時限公開設定
auto_display_start_date timestamp 公開開始日
auto_display_end_date timestamp 公開終了日

追加マスタ

mtb_auto_display_start_date

その他マスターとほぼ同様の構成

<?php
require_once dirname ( __FILE__ ) . "/define.php";

class AutoDisplay extends SC_Plugin_Base {

    // TODO コンストラクタ
    public function __construct(array $arrSelfInfo) {

        parent::__construct ( $arrSelfInfo );

    }

    function install(array $arrPlugin, SC_Plugin_Installer $installer) {

        $objQuery = new SC_Query_Ex ();
        $listTable = $objQuery->listTables ();

        $installer->addColumn ( "dtb_products", "auto_display_status", "int not null default 0" );
        $installer->addColumn ( "dtb_products", "auto_display_start_date", "timestamp" );
        $installer->addColumn ( "dtb_products", "auto_display_end_date", "timestamp" );

        $table = "mtb_auto_display_start_date";
        $installer->sql ( "CREATE TABLE " . $table . " (id INT PRIMARY KEY, name TEXT, rank int)" );
        $installer->insert ( $table, array (
            "id" => 0,
            "name" => "常時公開",
            "rank" => 0
        ) );
        $installer->insert ( $table, array (
            "id" => 1,
            "name" => "時限公開",
            "rank" => 1
        ) );

    }

    function uninstall(array $arrPlugin, SC_Plugin_Installer $installer) {

        $installer->dropColumn ( "dtb_products", "auto_display_status" );
        $installer->dropColumn ( "dtb_products", "auto_display_start_date" );
        $installer->dropColumn ( "dtb_products", "auto_display_end_date" );

        $installer->sql ( "DROP TABLE " . $table );

    }

    // TODO [HOOKPOINT] 事前処理
    function preProcess(LC_Page $objPage) {


    }

    // TODO [HOOKPOINT] 事後処理
    function process(LC_Page $objPage) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理
    function prefilterTransform(&$source, LC_Page_Ex $objPage, $filename) {

        $objTransform = new SC_Helper_Transform_Ex ( $source );
        if (GC_Utils_Ex::isFrontFunction ()) {
            $device_type_id = SC_Display_Ex::detectDevice ();
            switch ($device_type_id) {
            case DEVICE_TYPE_PC :
                $filename = str_replace ( TEMPLATE_REALDIR, '', $filename );
                self::prefilterTransform_pc ( $source, $objPage, $filename, $objTransform );
                break;

            case DEVICE_TYPE_SMARTPHONE :
                $filename = str_replace ( SMARTPHONE_TEMPLATE_REALDIR, '', $filename );
                self::prefilterTransform_sp ( $source, $objPage, $filename, $objTransform );
                break;

            case DEVICE_TYPE_MOBILE :
                $filename = str_replace ( MOBILE_TEMPLATE_REALDIR, '', $filename );
                self::prefilterTransform_mb ( $source, $objPage, $filename, $objTransform );
                break;

            default :
                break;
            }
        } else {
            $filename = str_replace ( TEMPLATE_ADMIN_REALDIR, '', $filename );
            self::prefilterTransform_ad ( $source, $objPage, $filename, $objTransform );
        }

        $source = $objTransform->getHTML ();

    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (PC用)
    function prefilterTransform_pc(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (スマホ用)
    function prefilterTransform_sp(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (携帯電話用)
    function prefilterTransform_mb(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {


    }

    // TODO [HOOKPOINT] テンプレートコンパイル前前処理 (管理画面)
    function prefilterTransform_ad(&$source, LC_Page_Ex $objPage, $filename, SC_Helper_Transform &$objTransform) {

        switch ($filename) {
        case "products/confirm.tpl" :
            $html = <<<'__EOL___'
<tr>
    <th>時限公開設定</th>
    <td><!--{$arrAutoDispStatus[$arrForm.auto_display_status]}--></td>
</tr>
<tr>
    <th>公開開始日時</th>
    <td>
        <!--{if $arrForm.auto_display_start_date_year}-->
        <!--{$arrForm.auto_display_start_date_year}-->年
        <!--{$arrForm.auto_display_start_date_month}-->月
        <!--{$arrForm.auto_display_start_date_day}-->日
        <!--{$arrForm.auto_display_start_date_hour}-->時
        <!--{$arrForm.auto_display_start_date_min}-->分
        <!--{else}-->(未設定)<!--{/if}-->
    </td>
</tr>
<tr>
    <th>公開終了日時</th>
    <td>
        <!--{if $arrForm.auto_display_end_date_year}-->
        <!--{$arrForm.auto_display_end_date_year}-->年
        <!--{$arrForm.auto_display_end_date_month}-->月
        <!--{$arrForm.auto_display_end_date_day}-->日
        <!--{$arrForm.auto_display_end_date_hour}-->時
        <!--{$arrForm.auto_display_end_date_min}-->分
        <!--{else}-->(未設定)<!--{/if}-->
    </td>
</tr>

__EOL___;

            $objTransform->select ( "table", 0 )->find ( "tr", 2 )->insertAfter ( $html );

            break;

        case "products/product.tpl" :
            $html = <<<'__EOL___'
<tr>
    <th>時限公開設定<span class='attention'>*</span></th>
    <td style="<!--{$arrErr.auto_display_status|sfGetErrorColor}-->">
        <!--{if $arrErr.auto_display_status}-->
        <div class="attention"><!--{$arrErr.auto_display_status}--></div>
        <!--{/if}-->
        <!--{html_radios options=$arrAutoDispStatus name="auto_display_status" selected=$arrForm.auto_display_status}-->
    </td>
</tr>
<tr>
    <th>公開開始日時</th>
    <td style="<!--{$arrErr.auto_display_start_date_year|sfGetErrorColor}-->">
        <!--{if $arrErr.auto_display_start_date_year}-->
        <div class="attention"><!--{$arrErr.auto_display_start_date_year}--></div>
        <!--{/if}-->
        <select name="auto_display_start_date_year" style="<!--{$arrErr.auto_display_start_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispYear selected=$arrForm.auto_display_start_date_year}-->
        </select>年
        <select name="auto_display_start_date_month" style="<!--{$arrErr.auto_display_start_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispMonth selected=$arrForm.auto_display_start_date_month}-->
        </select>月
        <select name="auto_display_start_date_day" style="<!--{$arrErr.auto_display_start_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispDay selected=$arrForm.auto_display_start_date_day}-->
        </select>日
        <select name="auto_display_start_date_hour" style="<!--{$arrErr.auto_display_start_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispHour selected=$arrForm.auto_display_start_date_hour}-->
        </select>時
        <select name="auto_display_start_date_min" style="<!--{$arrErr.auto_display_start_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispMinutes selected=$arrForm.auto_display_start_date_min}-->
        </select>分
        <button type="button" onclick="$(this).parents('td').children('select').val('')">クリア</button>
    </td>
</tr>
<tr>
    <th>公開終了日時</th>
    <td style="<!--{$arrErr.auto_display_end_date_year|sfGetErrorColor}-->">
        <!--{if $arrErr.auto_display_end_date_year}-->
        <div class="attention"><!--{$arrErr.auto_display_end_date_year}--></div>
        <!--{/if}-->
        <select name="auto_display_end_date_year" style="<!--{$arrErr.auto_display_end_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispYear selected=$arrForm.auto_display_end_date_year}-->
        </select>年
        <select name="auto_display_end_date_month" style="<!--{$arrErr.auto_display_end_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispMonth selected=$arrForm.auto_display_end_date_month}-->
        </select>月
        <select name="auto_display_end_date_day" style="<!--{$arrErr.auto_display_end_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispDay selected=$arrForm.auto_display_end_date_day}-->
        </select>日
        <select name="auto_display_end_date_hour" style="<!--{$arrErr.auto_display_end_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispHour selected=$arrForm.auto_display_end_date_hour}-->
        </select>時
        <select name="auto_display_end_date_min" style="<!--{$arrErr.auto_display_end_date_year|sfGetErrorColor}-->">
            <option selected value="">----</option>
            <!--{html_options options=$arrDispMinutes selected=$arrForm.auto_display_end_date_min}-->
        </select>分
        <button type="button" onclick="$(this).parents('td').children('select').val('')">クリア</button>
    </td>
</tr>

__EOL___;

            $objTransform->select ( ".form", 0 )->find ( "tr", 4 )->insertAfter ( $html );

            break;
        }

    }

    // TODO [HOOKPOINT] クラス読み込み
    function loadClassFileChange(&$classname, &$classpath) {


    }

    // TODO [HOOKPOINT] フォーム追加処理
    function SC_FormParam_construct($class_name, SC_FormParam $objFormParam) {

        if (strpos ( $class_name, "LC_Page_Admin_Products_Product" ) !== false) {

            $objFormParam->addParam ( "時限公開設定", "auto_display_status", INT_LEN, "a", array (
                "NUM_CHECK",
                "EXIST_CHECK",
                "MAX_LENGTH_CHECK"
            ) );

            switch ($_REQUEST ["mode"]) {
            case "pre_edit" :
            case "copy" :
                $objFormParam->overwriteParam ( "auto_display_status", "arrCheck", array (
                    "NUM_CHECK",
                    "MAX_LENGTH_CHECK"
                ) );

                break;

            default :
                break;
            }

            $objFormParam->addParam ( "公開開始日時(年)", "auto_display_start_date_year", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開開始日時(月)", "auto_display_start_date_month", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開開始日時(日)", "auto_display_start_date_day", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開開始日時(時)", "auto_display_start_date_hour", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開開始日時(分)", "auto_display_start_date_min", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開開始日時(秒)", "auto_display_start_date_sec", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), 0, false );

            $objFormParam->addParam ( "公開終了日時(年)", "auto_display_end_date_year", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開終了日時(月)", "auto_display_end_date_month", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開終了日時(日)", "auto_display_end_date_day", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開終了日時(時)", "auto_display_end_date_hour", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開終了日時(分)", "auto_display_end_date_min", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), '', false );
            $objFormParam->addParam ( "公開終了日時(秒)", "auto_display_end_date_sec", INT_LEN, "a", array (
                "NUM_CHECK",
                "MAX_LENGTH_CHECK"
            ), 0, false );
        }

    }

    function LC_Page_Products_List_action_before(LC_Page_Products_List $objPage) {

        self::LC_Page_Products_Common_action_before ( $objPage );

    }

    function LC_Page_Products_Detail_action_before(LC_Page_Products_Detail $objPage) {

        self::LC_Page_Products_Common_action_before ( $objPage );

    }

    function LC_Page_Products_Common_action_before(LC_Page $objPage) {

        $objQuery = SC_Query_Ex::getSingletonInstance ();

        // 期間外(非公開)
        $objQuery->update ( "dtb_products", array (
            "status" => "2",
            "update_date" => "CURRENT_TIMESTAMP"
        ), "     auto_display_status = 1
             AND del_flg             = 0
             AND status              = 1
             AND CASE WHEN auto_display_start_date IS NOT NULL
                           THEN auto_display_start_date > CURRENT_TIMESTAMP
                      WHEN auto_display_end_date   IS NOT NULL
                           THEN auto_display_end_date   < CURRENT_TIMESTAMP
                      ELSE FALSE END" );

        // 期間内(公開)
        $objQuery->update ( "dtb_products", array (
            "status" => "1",
            "update_date" => "CURRENT_TIMESTAMP"
        ), "     auto_display_status = 1
             AND del_flg             = 0
             AND status              = 2
             AND CASE WHEN auto_display_start_date IS NOT NULL
                           THEN NOT auto_display_start_date > CURRENT_TIMESTAMP
                      WHEN auto_display_end_date   IS NOT NULL
                           THEN NOT auto_display_end_date   < CURRENT_TIMESTAMP
                      ELSE FALSE END" );

        // 商品数量を再計算
        $objDb = new SC_Helper_DB_Ex ();
        $objDb->sfCountCategory ( $objQuery );
        $objDb->sfCountMaker ( $objQuery );

    }

    function LC_Page_Admin_Products_Product_action_after(LC_Page_Admin_Products_Product $objPage) {

        $objQuery = new SC_Query_Ex ();
        $listTable = $objQuery->listTables ();

        $masterDate = new SC_DB_MasterData_Ex ();

        $table = "mtb_auto_display_start_date";
        $objPage->arrAutoDispStatus = $masterDate->getMasterData ( $table );

        $objDate = new SC_Date_Ex ( RELEASE_YEAR );

        $objPage->arrDispYear = $objDate->getYear ();
        $objPage->arrDispMonth = $objDate->getMonth ();
        $objPage->arrDispDay = $objDate->getDay ();
        $objPage->arrDispHour = $objDate->getHour ();
        $objPage->arrDispMinutes = $objDate->getMinutesInterval ();

        $objQuery = SC_Query_Ex::getSingletonInstance ();

        switch ($objPage->getMode ()) {
        case 'pre_edit' :
            if (is_numeric ( $objPage->arrForm ["product_id"] )) {
                $product_id = $objPage->arrForm ["product_id"];
                $product = $objQuery->getRow ( "*", "dtb_products", "product_id=?", ( array ) $product_id );
                // auto_display_status,auto_display_start_date,auto_display_end_date

                $objPage->arrForm ["auto_display_status"] = $product ["auto_display_status"];

                if (! empty ( $product ["auto_display_start_date"] )) {
                    $objPage->arrForm ["auto_display_start_date_year"] = date ( "Y", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_month"] = date ( "m", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_day"] = date ( "d", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_hour"] = date ( "h", strtotime ( $product ["auto_display_start_date"] ) );
                    $objPage->arrForm ["auto_display_start_date_min"] = date ( "i", strtotime ( $product ["auto_display_start_date"] ) );
                }

                if (! empty ( $product ["auto_display_end_date"] )) {
                    $objPage->arrForm ["auto_display_end_date_year"] = date ( "Y", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_month"] = date ( "m", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_day"] = date ( "d", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_hour"] = date ( "h", strtotime ( $product ["auto_display_end_date"] ) );
                    $objPage->arrForm ["auto_display_end_date_min"] = date ( "i", strtotime ( $product ["auto_display_end_date"] ) );
                }
            }
            break;

        case 'edit' :
            self::LC_Page_Admin_Products_Product_action_after_check ( $objPage );
            break;

        case 'complete' :
            if (SC_Utils_Ex::isBlank ( $objPage->arrErr )) {
                if (is_numeric ( $objPage->arrForm ["product_id"] )) {
                    $product_id = $objPage->arrForm ["product_id"];

                    $arrVal = array ();
                    $arrVal ["auto_display_status"] = $_POST ["auto_display_status"];

                    $year = $_POST ["auto_display_start_date_year"];
                    $month = $_POST ["auto_display_start_date_month"];
                    $day = $_POST ["auto_display_start_date_day"];
                    $hour = $_POST ["auto_display_start_date_hour"];
                    $minutes = $_POST ["auto_display_start_date_min"];
                    $arrVal ["auto_display_start_date"] = SC_Utils_Ex::sfGetTimestampistime ( $year, $month, $day, $hour, $minutes );

                    $year = $_POST ["auto_display_end_date_year"];
                    $month = $_POST ["auto_display_end_date_month"];
                    $day = $_POST ["auto_display_end_date_day"];
                    $hour = $_POST ["auto_display_end_date_hour"];
                    $minutes = $_POST ["auto_display_end_date_min"];
                    $arrVal ["auto_display_end_date"] = SC_Utils_Ex::sfGetTimestampistime ( $year, $month, $day, $hour, $minutes, true );

                    $objQuery->update ( "dtb_products", $arrVal, "product_id=?", ( array ) $product_id );
                }
            }
            break;
        }

    }

    function LC_Page_Admin_Products_Product_action_after_check(LC_Page_Admin_Products_Product $objPage) {

        $objErr = new SC_CheckError_Ex ( $objPage->arrForm );
        if (count ( $objPage->arrErr ) > 0) {
            $objErr->arrErr = $objPage->arrErr;
        }
        $objErr->doFunc ( array (
            "公開開始日時",
            "公開終了日時",
            "auto_display_start_date_year",
            "auto_display_start_date_month",
            "auto_display_start_date_day",
            "auto_display_start_date_hour",
            "auto_display_start_date_min",
            "auto_display_start_date_sec",
            "auto_display_end_date_year",
            "auto_display_end_date_month",
            "auto_display_end_date_day",
            "auto_display_end_date_hour",
            "auto_display_end_date_min",
            "auto_display_end_date_sec"
        ), array (
            "CHECK_SET_TERM2"
        ) );
        if (is_numeric ( $objPage->arrForm ["auto_display_start_date_year"] )) {
            $objErr->doFunc ( array (
                "公開開始日時",
                "auto_display_start_date_year",
                "auto_display_start_date_month",
                "auto_display_start_date_day",
                "auto_display_start_date_hour",
                "auto_display_start_date_min"
            ), array (
                "CHECK_DATE2"
            ) );
        }
        if (is_numeric ( $objPage->arrForm ["auto_display_end_date_year"] )) {
            $objErr->doFunc ( array (
                "公開終了日時",
                "auto_display_end_date_year",
                "auto_display_end_date_month",
                "auto_display_end_date_day",
                "auto_display_end_date_hour",
                "auto_display_end_date_min"
            ), array (
                "CHECK_DATE2"
            ) );
        }
        if ($objPage->arrForm ["auto_display_status"] == "1") {
            if (SC_Utils_Ex::isBlank ( $objErr->arrErr )) {
                $objErr->doFunc ( array (
                    "公開開始日時または公開終了日時",
                    "auto_display_start_date_year",
                    "auto_display_end_date_year"
                ), array (
                    "ONE_EXIST_CHECK"
                ) );
            }
        }

        $objPage->arrErr = $objErr->arrErr;
        if (count ( $objPage->arrErr ) > 0) {

            // アップロードファイル情報の初期化
            $objUpFile = new SC_UploadFile_Ex ( IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR );
            $objPage->lfInitFile ( $objUpFile );
            $objUpFile->setHiddenFileList ( $_POST );

            // ダウンロード販売ファイル情報の初期化
            $objDownFile = new SC_UploadFile_Ex ( DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR );
            $objPage->lfInitDownFile ( $objDownFile );
            $objDownFile->setHiddenFileList ( $_POST );

            // 入力画面表示設定
            $objPage->arrForm = $objPage->lfSetViewParam_InputPage ( $objUpFile, $objDownFile, $objPage->arrForm );
            // ページonload時のJavaScript設定
            $objPage->tpl_onload = $objPage->lfSetOnloadJavaScript_InputPage ();

            $objPage->tpl_mainpage = 'products/product.tpl';
            $objPage->tpl_subtitle = '商品登録';
        }

    }

}

EC CUBE 休日テーブル更新

<?php
$id = 0;
$this-> objQuery-> delete($table);
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "元日(1月1日)",
    'month' => 1,
    'day' => 1,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "成人の日(1月第2月曜日)",
    'month' => 1,
    'day' => date("d", strtotime('second monday of ' . date("Y-01-01"))),
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "建国記念の日(2月11日)",
    'month' => 2,
    'day' => 11,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "春分の日(3月21日)",
    'month' => 3,
    'day' => 21,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "昭和の日(4月29日)",
    'month' => 4,
    'day' => 29,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "憲法記念日(5月3日)",
    'month' => 5,
    'day' => 3,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "みどりの日(5月4日)",
    'month' => 5,
    'day' => 4,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "こどもの日(5月5日)",
    'month' => 5,
    'day' => 5,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "海の日(7月第3月曜日)",
    'month' => 7,
    'day' => date("d", strtotime('third monday of ' . date("Y-07-01"))),
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "敬老の日(9月第3月曜日)",
    'month' => 9,
    'day' => date("d", strtotime('third monday of ' . date("Y-09-01"))),
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
if (date("d", strtotime('third monday of ' . date("Y-09-01")) == 21)) {
    $this-> objQuery-> insert($table, array(
        'holiday_id' => ++$id,
        'title' => "国民の休日(9月22日)",
        'month' => 9,
        'day' => 22,
        'rank' => $id - 1,
        'creator_id' => 0,
        'create_date' => "",
        'update_date' => "",
        'create_date' => "CURRENT_TIMESTAMP",
        'update_date' => "CURRENT_TIMESTAMP",
        'del_flg' => 0
    ));
}
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "秋分の日(9月23日)",
    'month' => 9,
    'day' => 23,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "体育の日(10月第2月曜日)",
    'month' => 10,
    'day' => date("d", strtotime('second monday of ' . date("Y-10-01"))),
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "文化の日(11月3日)",
    'month' => 11,
    'day' => 3,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "勤労感謝の日(11月23日)",
    'month' => 11,
    'day' => 23,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
$this-> objQuery-> insert($table, array(
    'holiday_id' => ++$id,
    'title' => "天皇誕生日(12月23日)",
    'month' => 21,
    'day' => 23,
    'rank' => $id - 1,
    'creator_id' => 0,
    'create_date' => "",
    'update_date' => "",
    'create_date' => "CURRENT_TIMESTAMP",
    'update_date' => "CURRENT_TIMESTAMP",
    'del_flg' => 0
));
Twitter: @asahina_alice