Source for file LC_Page_Products_Detail.php
Documentation is available at LC_Page_Products_Detail.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");
if (file_exists(MODULE_PATH . "mdl_gmopg/inc/function.php")) {
require_once(MODULE_PATH . "mdl_gmopg/inc/function.php");
* @author LOCKON CO.,LTD.
* @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
$masterData = new SC_DB_MasterData_Ex();
$this->arrSTATUS = $masterData->getMasterData("mtb_status");
$this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
$objDb = new SC_Helper_DB_Ex();
$helper = new SC_Helper_PageLayout_Ex();
$helper->sfGetPageLayout($this, false, "products/detail.php");
// 管理ページからの確認の場合は、非公開の商品も表示する。
if(isset ($_GET['admin']) && $_GET['admin'] == 'on') {
$where = "del_flg = 0 AND status = 1";
if(isset ($_POST['mode']) && $_POST['mode'] != "") {
$tmp_id = $_POST['product_id'];
$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) {
$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'));
$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->tpl_product_id = $tmp_id;
if (!isset ($_POST['mode'])) $_POST['mode'] = "";
if(count($this->arrErr) == 0) {
$classcategory_id1 = $_POST['classcategory_id1'];
$classcategory_id2 = $_POST['classcategory_id2'];
if (!empty($_POST['gmo_oneclick'])) {
$objCartSess->delAllProducts();
if(!$this->tpl_classcat_find1) {
$classcategory_id1 = '0';
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->setRegistFlag();
$objCartSess->saveCurrentCart($objSiteSess->getUniqId());
URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true));
$arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = alldtl.product_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"];
$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);
$this->objUpFile->setDBFileList($this->arrProduct);
$this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) {
$this->arrTrackbackView = "OFF";
$this->arrTrackbackView = "ON";
$this->trackback_url = TRACKBACK_TO_URL . $tmp_id;
$this->tpl_title = "商品詳細 ". $this->arrProduct["name"];
$objView->assignobj($this);
$objView->display(SITE_FRAME);
$objDb = new SC_Helper_DB_Ex();
if (!isset ($_POST['mode'])) $_POST['mode'] = "";
if(!empty($_POST['mode'])) {
$tmp_id = $_POST['product_id'];
$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)) {
$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'));
$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->tpl_product_id = $tmp_id;
if($this->tpl_classcat_find1) {
if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
if($this->tpl_classcat_find2) {
if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
if(count($this->arrErr) == 0) {
$classcategory_id1 = $_POST['classcategory_id1'];
$classcategory_id2 = $_POST['classcategory_id2'];
if(!$this->tpl_classcat_find1) {
$classcategory_id1 = '0';
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'));
$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"];
$arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']);
$tpl_subtitle = $arrFirstCat['name'];
$this->tpl_subtitle = $tpl_subtitle;
$this->objUpFile->setDBFileList($this->arrProduct);
$this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
$this->tpl_title = "商品詳細 ". $this->arrProduct["name"];
$objView->assignobj($this);
$objView->display(SITE_FRAME);
$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);
$objDb = new SC_Helper_DB_Ex();
$arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
$arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
$this->tpl_class_name1 = isset ($arrClassName[$arrProductsClass[0]['class_id1']])
? $arrClassName[$arrProductsClass[0]['class_id1']] : "";
$this->tpl_class_name2 = isset ($arrClassName[$arrProductsClass[0]['class_id2']])
? $arrClassName[$arrProductsClass[0]['class_id2']] : "";
$count = count($arrProductsClass);
$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') {
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 (!isset ($arrList[$list_id])) $arrList[$list_id] = "";
if($arrList[$list_id] == "") {
$arrList[$list_id] = "\tlist". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
$arrList[$list_id].= ", '". $arrClassCatName[$classcat_id2]. "'";
if (!isset ($arrVal[$list_id])) $arrVal[$list_id] = "";
if($arrVal[$list_id] == "") {
$arrVal[$list_id] = "\tval". $list_id. " = new Array('', '". $classcat_id2. "'";
$arrVal[$list_id].= ", '". $classcat_id2. "'";
$arrList[$list_id].= ");\n";
$arrVal[$list_id].= ");\n";
$this->arrClassCat1 = $arrSele;
$lists = "\tlists = new Array(";
foreach($arrList as $val) {
$vals = "\tvals = new Array(";
foreach($arrVal as $val) {
if (!isset ($_POST['classcategory_id2'])) $_POST['classcategory_id2'] = "";
$this->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . htmlspecialchars($_POST['classcategory_id2'], ENT_QUOTES) . "');";
if($arrProductsClass[0]['classcategory_id1'] != '0') {
if($arrProductsClass[0]['classcategory_id2'] != '0') {
$this->tpl_classcat_find1 = $classcat_find1;
$this->tpl_classcat_find2 = $classcat_find2;
$this->tpl_stock_find = $stock_find;
$objDb = new SC_Helper_DB_Ex();
$arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
$arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
$objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
$objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
$count = count($arrProductsClass);
for ($i = 0; $i < $count; $i++ ) {
if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
$classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
$arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
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];
$objPage->arrClassCat1 = $arrSele1;
$objPage->arrClassCat2 = $arrSele2;
if($arrProductsClass[0]['classcategory_id1'] != '0') {
if($arrProductsClass[0]['classcategory_id2'] != '0') {
$objPage->tpl_classcat_find1 = $classcat_find1;
$objPage->tpl_classcat_find2 = $classcat_find2;
$objPage->tpl_stock_find = $stock_find;
$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"));
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));
$objQuery->setOrder("rank DESC");
$arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
$from = "vw_products_allclass AS T1 "
. " SELECT max(T2.rank) AS product_rank, "
. " FROM dtb_product_categories T2 "
. " GROUP BY product_id) AS T3 USING (product_id)";
$objQuery->setOrder("T3.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, T3.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'];
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"));
$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
$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 = ? ";
$arrProducts = $objQuery->select($col, $from, $where, $arrval);
$col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
$where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX;
$arrReview = $objQuery->select($col, $from, $where, $arrval);
$col = "blog_name, url, title, excerpt, title, create_date";
$where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX;
$arrTrackback = $objQuery->select($col, $from, $where, $arrval);
//payment_id 1:クレジット 2:ショッピングローン
$col = "payment_id, rule, payment_method";
$objQuery->setOrder($order);
$arrRet = $objQuery->select($col, $from, $where);
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);
* @param object 顧客管理用クラスオブジェクト
// ログイン中のユーザーかつ、お気に入り商品機能ONの時
if ( $objCustomer->isLoginSuccess() === true && OPTION_FAVOFITE_PRODUCT == 1 ){
$add_favorite_product_id = $_POST['favorite_product_id']; // お気に入りに追加する商品ID
$customer_id = $objCustomer->getValue('customer_id'); // ログイン中の顧客ID
// お気に入りに商品を追加する際のエラーチェックを行う
$this->arrErr = array(); // エラー内容
if( count($this->arrErr) == 0 ) {
* 商品をお気に入りにいれる際のエラーチェックを行う
* @param int $customer_id 顧客ID
* @param int $add_favorite_product_id お気に入りに追加する商品ID
$objDb = new SC_Helper_DB_Ex();
if( !SC_Utils_Ex::sfIsInt($add_favorite_product_id) || !$objDb->sfIsRecord('dtb_products', 'product_id', $add_favorite_product_id, 'del_flg = 0 AND status = 1') ) {
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
// 既にお気に入り商品として追加されていないかチェック
if (SC_Helper_DB_Ex::sfDataExists( 'dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $add_favorite_product_id)) ) {
$this->arrErr['add_favorite'. $add_favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />";
$this->add_favorite_product_id = $add_favorite_product_id;
* @param int $customer_id 顧客ID
* @param int $add_favorite_product_id お気に入りに追加する商品ID
$sqlval['customer_id'] = $customer_id;
$sqlval['product_id'] = $add_favorite_product_id;
$sqlval['update_date'] = "now()";
$sqlval['create_date'] = "now()";
$objQuery->insert('dtb_customer_favorite_products', $sqlval);
Documentation generated on Fri, 24 Feb 2012 13:59:41 +0900 by Seasoft
|