Source for file LC_Page_Campaign.php
Documentation is available at LC_Page_Campaign.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2010 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");
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Campaign.php 18735 2010-06-22 08:53:31Z nanasess $
$dir_name = dirname($_SERVER['PHP_SELF']);
$arrDir = split('/', $dir_name);
$dir_name = $arrDir[count($arrDir) - 1];
/* セッションにキャンペーンデータを書き込む */
$objCampaignSess->setIsCampaign();
$campaign_id = $objQuery->get("dtb_campaign", "campaign_id", "directory_name = ? AND del_flg = 0", array($dir_name));
$objCampaignSess->setCampaignId($campaign_id);
$objCampaignSess->setCampaignDir($dir_name);
// カートに入れないページの場合のページ(申込のみページ)へリダイレクト
$cart_flg = $objQuery->get("dtb_campaign", "cart_flg", "campaign_id = ?", array($campaign_id));
$status = CAMPAIGN_TEMPLATE_ACTIVE;
$status = CAMPAIGN_TEMPLATE_END;
if($_GET['init'] != "") {
$this->tpl_init = 'false';
$this->tpl_init = 'true';
if(count($this->arrErr) == 0) {
$classcategory_id = "classcategory_id". $_POST['product_id'];
$classcategory_id1 = $_POST[$classcategory_id. '_1'];
$classcategory_id2 = $_POST[$classcategory_id. '_2'];
$quantity = "quantity". $_POST['product_id'];
if(!$this->tpl_classcat_find1[$_POST['product_id']]) {
$classcategory_id1 = '0';
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], $campaign_id);
$this->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name . "/" . $status;
$objView->assignobj($this);
* 戻り値:キャンペーン中なら true 終了なら false
$col = "limit_count, total_count, start_date, end_date";
$arrRet = $objQuery->select($col, "dtb_campaign", "directory_name = ? AND del_flg = 0", array($directory_name));
$start_date = (date("YmdHis", strtotime($arrRet[0]['start_date'])));
$now_date = (date("YmdHis"));
// キャンペーンが開催期間で、かつ申込制限内である
if($now_date > $start_date && $now_date < $end_date
&& ($arrRet[0]['limit_count'] > $arrRet[0]['total_count'] || $arrRet[0]['limit_count'] < 1)) {
$objDb = new SC_Helper_DB_Ex();
$arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
$arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
$arrProductIds = split('-', $ids);
$arrProductIds[0] = $ids;
$where = "product_id IN (";
foreach($arrProductIds as $key => $val) {
if($count > 0) $where .= ",";
$arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval);
for($i = 0; $i < count($arrProducts); $i++ ) {
$this->lfMakeSelect($arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
foreach($arrProducts as $key => $val) {
$arrCamp[$val['product_id']] = $val;
$this->arrProducts = $arrCamp;
function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
$this->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']];
$this->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']];
$count = count($arrProductsClass);
$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') {
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];
$classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
if($arrList[$list_id] == "") {
$arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
$arrList[$list_id].= ", '". $arrClassCatName[$classcat_id2]. "'";
if($arrVal[$list_id] == "") {
$arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
$arrVal[$list_id].= ", '". $classcat_id2. "'";
$arrList[$list_id].= ");\n";
$arrVal[$list_id].= ");\n";
$this->arrClassCat1[$product_id] = $arrSele;
$lists = "\tlists". $product_id. " = new Array(";
foreach($arrList as $val) {
$lists.= ",list". $product_id. "_". $no;
$lists.= "list". $product_id. "_". $no;
$vals = "\tvals". $product_id. " = new Array(";
foreach($arrVal as $val) {
$vals.= ",val". $product_id. "_". $no;
$vals.= "val". $product_id. "_". $no;
$classcategory_id = "classcategory_id". $product_id;
$this->tpl_onload .= "lnSetSelect('". $classcategory_id. "_1','". $classcategory_id. "_2','". $product_id. "','". $_POST[$classcategory_id. "_2"]. "'); ";
if($arrProductsClass[0]['classcategory_id1'] != '0') {
if($arrProductsClass[0]['classcategory_id2'] != '0') {
$this->tpl_classcat_find1[$product_id] = $classcat_find1;
$this->tpl_classcat_find2[$product_id] = $classcat_find2;
$this->tpl_stock_find[$product_id] = $stock_find;
if(SC_Utils_Ex::sfIsInt($product_id)) {
$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));
$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"));
//在庫が無限または購入制限値が設定値より大きい場合
if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
$this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
$this->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
//payment_id 1:代金引換 2:銀行振り込み 3:現金書留
$col = "payment_id, rule, payment_method";
$objQuery->setOrder($order);
$arrRet = $objQuery->select($col, $from, $where);
Documentation generated on Fri, 24 Feb 2012 13:59:15 +0900 by Seasoft
|