Source for file LC_Page_Admin_Contents_Campaign.php
Documentation is available at LC_Page_Admin_Contents_Campaign.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.
require_once(CLASS_PATH .
"pages/LC_Page.php");
require_once(CLASS_EX_PATH .
"helper_extends/SC_Helper_CSV_Ex.php");
require_once(CLASS_EX_PATH .
"helper_extends/SC_Helper_FileManager_Ex.php");
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Admin_Contents_Campaign.php 17743 2009-01-17 01:51:29Z Seasoft $
$this->tpl_subnavi =
'contents/subnavi.tpl';
$this->tpl_subno =
"campaign";
$this->tpl_subtitle =
'キャンペーン管理';
// カートに商品が入っているにチェックが入っているかチェック
$objFormParam->setParam($_POST);
$this->is_update = isset
($_POST['is_update']) ?
$_POST['is_update'] :
"";
$this->arrForm =
$objFormParam->getHashArray();
$campaign_id = isset
($_POST['campaign_id']) ?
$_POST['campaign_id'] :
"";
if (!isset
($_POST['mode'])) $_POST['mode'] =
"";
$this->arrErr =
$this->lfErrorCheck($campaign_id, $objQuery, $objFormParam);
if(count($this->arrErr) <=
0) {
$option =
"ORDER BY create_date DESC";
$arrCsvOutput =
SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(4, " WHERE csv_id = 4 AND status = 1"));
if (count($arrCsvOutput) <=
0) break;
$arrCsvOutputCols =
$arrCsvOutput['col'];
$arrCsvOutputTitle =
$arrCsvOutput['disp_name'];
$data =
$objCSV->lfGetCSV("dtb_campaign_order", "campaign_id = ?", $option, array($campaign_id), $arrCsvOutputCols);
$this->campaign_id =
$campaign_id;
$this->arrYear =
$objDate->getYear(min(date('Y'), $this->arrForm['start_year']));
$this->arrMonth =
$objDate->getMonth();
$this->arrDay =
$objDate->getDay();
$this->arrHour =
$objDate->getHour();
$this->arrMinutes =
$objDate->getMinutes();
$objView->assignobj($this);
$objView->display(MAIN_FRAME);
$objFormParam->addParam("キャンペーン名", "campaign_name", MTEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
$objFormParam->addParam("開始日時", "start_year", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("開始日時", "start_month", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("開始日時", "start_day", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("開始日時", "start_hour", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("開始日時", "start_minute", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("停止日時", "end_year", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("停止日時", "end_month", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("停止日時", "end_day", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("停止日時", "end_hour", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("停止日時", "end_minute", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("ディレクトリ名", "directory_name", MTEXT_LEN, "KVa", array("EXIST_CHECK","ALNUM_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
$objFormParam->addParam("申込数制御", "limit_count", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("重複申込制御", "orverlapping_flg", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("カートに商品を入れる", "cart_flg", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
$objFormParam->addParam("送料無料設定", "deliv_free_flg", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
function lfErrorCheck($campaign_id =
"", &$objQuery, &$objFormParam) {
$arrList =
$objFormParam->getHashArray();
$objErr->arrErr =
$objFormParam->checkError();
$objErr->doFunc(array("開始日時", "start_year", "start_month", "start_day", "start_hour", "start_minute", "0"), array("CHECK_DATE2"));
$objErr->doFunc(array("停止日時", "end_year", "end_month", "end_day", "end_hour", "end_minute", "0"), array("CHECK_DATE2"));
$objErr->doFunc(array("開始日時", "停止日時", "start_year", "start_month", "start_day", "start_hour", "start_minute", "00", "end_year", "end_month", "end_day", "end_hour", "end_minute", "59"), array("CHECK_SET_TERM2"));
$objErr->arrErr['campaign_template_path'] =
"※" .
CAMPAIGN_TEMPLATE_PATH .
" へ書き込み権限を与えてください。 <br/>";
$objErr->arrErr['campaign_path'] =
"※" .
CAMPAIGN_PATH .
" へ書き込み権限を与えてください。<br/>";
if(count($objErr->arrErr) <=
0) {
$directory_name =
$objQuery->get("dtb_campaign", "directory_name", "campaign_id = ?", array($campaign_id));
if(file_exists(CAMPAIGN_TEMPLATE_PATH.
$arrList['directory_name']) &&
$directory_name !=
$arrList['directory_name']) {
$objErr->arrErr['directory_name'] =
"※ 同名のディレクトリがすでに存在します。<br/>";
$ret =
$objQuery->get("dtb_campaign", "directory_name", "directory_name = ? AND del_flg = 0", array($arrList['directory_name']));
if($ret !=
"" &&
$directory_name !=
$arrList['directory_name']) {
$objErr->arrErr['directory_name'] =
"※ すでに登録されているディレクトリ名です。<br/>";
* 引数1 :キャンペーンID(アップデート時に指定)
$arrInfo =
$objSiteInfo->data;
$arrList =
$objFormParam->getHashArray();
$start_date =
$arrList['start_year'].
"-".
sprintf("%02d", $arrList['start_month']).
"-".
sprintf("%02d", $arrList['start_day']).
" ".
sprintf("%02d", $arrList['start_hour']).
":".
sprintf("%02d", $arrList['start_minute']).
":00";
$end_date =
$arrList['end_year'].
"-".
sprintf("%02d", $arrList['end_month']).
"-".
sprintf("%02d", $arrList['end_day']).
" ".
sprintf("%02d", $arrList['end_hour']).
":".
sprintf("%02d", $arrList['end_minute']).
":00";
// ポイントレートは設定されていなければ0を挿入
if($arrInfo['point_rate'] ==
"") $arrInfo['point_rate'] =
"0";
if(!$arrList['limit_count']) $arrList['limit_count'] =
"0";
if(!$arrList['orverlapping_flg']) $arrList['orverlapping_flg'] =
"0";
if(!$arrList['cart_flg']) $arrList['cart_flg'] =
"0";
if(!$arrList['deliv_free_flg']) $arrList['deliv_free_flg'] =
"0";
$sqlval['campaign_name'] =
$arrList['campaign_name'];
$sqlval['campaign_point_rate'] =
$arrInfo['point_rate'];
$sqlval['start_date'] =
$start_date;
$sqlval['end_date'] =
$end_date;
$sqlval['directory_name'] =
$arrList['directory_name'];
$sqlval['limit_count'] =
$arrList['limit_count'];
$sqlval['orverlapping_flg'] =
$arrList['orverlapping_flg'];
$sqlval['cart_flg'] =
$arrList['cart_flg'];
$sqlval['deliv_free_flg'] =
$arrList['deliv_free_flg'];
$sqlval['update_date'] =
"now()";
// キャンペーンIDで指定されている場合はupdate
$directory_name =
$objQuery->get("dtb_campaign", "directory_name", "campaign_id = ?", array($campaign_id));
@rename(CAMPAIGN_TEMPLATE_PATH .
$directory_name , CAMPAIGN_TEMPLATE_PATH .
$arrList['directory_name']);
@rename(CAMPAIGN_PATH .
$directory_name , CAMPAIGN_PATH .
$arrList['directory_name']);
$objQuery->update("dtb_campaign", $sqlval, "campaign_id = ?", array($campaign_id));
$this->lfCreateTemplate(CAMPAIGN_TEMPLATE_PATH, $arrList['directory_name'], $objFormParam);
$sqlval['create_date'] =
"now()";
$objQuery->insert("dtb_campaign", $sqlval);
* 関数名:lfGetCampaignList()
$col =
"campaign_id,campaign_name,directory_name,total_count";
$objQuery->setorder("update_date DESC");
$arrRet =
$objQuery->select($col, "dtb_campaign", "del_flg = 0");
$col =
"campaign_id,campaign_name,start_date,end_date,directory_name,limit_count,orverlapping_flg,cart_flg,deliv_free_flg";
$arrRet =
$objQuery->select($col, "dtb_campaign", "campaign_id = ?", array($campaign_id));
$start_date =
(date("Y/m/d/H/i/s" , strtotime($arrRet[0]['start_date'])));
list
($arrRet[0]['start_year'],$arrRet[0]['start_month'],$arrRet[0]['start_day'],$arrRet[0]['start_hour'], $arrRet[0]['start_minute'], $arrRet[0]['start_second']) =
split("/", $start_date);
$end_date =
(date("Y/m/d/H/i/s" , strtotime($arrRet[0]['end_date'])));
list
($arrRet[0]['end_year'],$arrRet[0]['end_month'],$arrRet[0]['end_day'],$arrRet[0]['end_hour'], $arrRet[0]['end_minute'], $arrRet[0]['end_second']) =
split("/", $end_date);
$directory_name =
$objQuery->get("dtb_campaign", "directory_name", "campaign_id = ?", array($campaign_id));
$objFileManager->sfDeleteDir(CAMPAIGN_TEMPLATE_PATH .
$directory_name);
$objFileManager->sfDeleteDir(CAMPAIGN_PATH .
$directory_name);
$sqlval['update_date'] =
"now()";
$objQuery->update("dtb_campaign", $sqlval, "campaign_id = ?", array($campaign_id));
$arrRet =
$objFormParam->getHashArray();
$create_dir =
$dir .
$file;
$create_active_dir =
$create_dir .
"/" .
CAMPAIGN_TEMPLATE_ACTIVE;
$create_end_dir =
$create_dir .
"/" .
CAMPAIGN_TEMPLATE_END;
$default_dir =
TEMPLATE_DIR .
CAMPAIGN_TEMPLATE_DIR;
$default_active_dir =
$default_dir .
"/" .
CAMPAIGN_TEMPLATE_ACTIVE;
$default_end_dir =
$default_dir .
"/" .
CAMPAIGN_TEMPLATE_END;
$ret =
$objFileManager->sfCreateFile($create_dir, 0755);
$ret =
$objFileManager->sfCreateFile($create_active_dir, 0755);
$ret =
$objFileManager->sfCreateFile($create_end_dir, 0755);
$ret =
$objFileManager->sfCreateFile(CAMPAIGN_PATH .
$file);
copy(HTML_PATH .
CAMPAIGN_TEMPLATE_DIR .
"index.php", CAMPAIGN_PATH .
$file .
"/index.php");
copy(HTML_PATH .
CAMPAIGN_TEMPLATE_DIR .
"application.php", CAMPAIGN_PATH .
$file .
"/application.php");
copy(HTML_PATH .
CAMPAIGN_TEMPLATE_DIR .
"complete.php", CAMPAIGN_PATH .
$file .
"/complete.php");
copy(HTML_PATH .
CAMPAIGN_TEMPLATE_DIR .
"entry.php", CAMPAIGN_PATH .
$file .
"/entry.php");
// デフォルトテンプレート作成(キャンペーン中)
SC_Utils_Ex::sfWriteFile($header, $create_active_dir.
"header.tpl", "w");
if(!$arrRet['cart_flg']) {
$contents .=
"\n" .
'<!--{*ログインフォーム*}-->' .
"\n";
$contents .=
'<!--{*会員登録フォーム*}-->'.
"\n";
SC_Utils_Ex::sfWriteFile($contents, $create_active_dir.
"contents.tpl", "w");
SC_Utils_Ex::sfWriteFile($footer, $create_active_dir.
"footer.tpl", "w");
$site_frame =
$header.
"\n";
$site_frame .=
'<script type="text/javascript" src="<!--{$TPL_DIR}-->js/navi.js"></script>'.
"\n";
$site_frame .=
'<script type="text/javascript" src="<!--{$TPL_DIR}-->js/site.js"></script>'.
"\n";
$site_frame .=
'<!--{include file=$tpl_mainpage}-->'.
"\n";
$site_frame .=
$footer.
"\n";
SC_Utils_Ex::sfWriteFile($site_frame, $create_active_dir.
"site_frame.tpl", "w");
/* デフォルトテンプレート作成(キャンペーン終了) */
SC_Utils_Ex::sfWriteFile($header, $create_end_dir.
"header.tpl", "w");
SC_Utils_Ex::sfWriteFile($contents, $create_end_dir.
"contents.tpl", "w");
SC_Utils_Ex::sfWriteFile($footer, $create_end_dir.
"footer.tpl", "w");
* 関数名:lfGetFileContents()
Documentation generated on Tue, 28 Apr 2009 18:10:51 +0900 by phpDocumentor 1.4.2