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-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");
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 $
$this->arrSTATUS =
$masterData->getMasterData("mtb_status");
$this->arrRECOMMEND =
$masterData->getMasterData("mtb_recommend");
$helper->sfGetPageLayout($this, false, "products/detail.php");
if(isset
($_POST['mode']) &&
$_POST['favorite_product_id'] !=
"" &&
$_POST['mode'] ==
"add_favorite") {
if(!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) ||
!$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) {
if(count($this->arrErr) ==
0) {
$customer_id =
$objCustomer->getValue('customer_id');
// 管理機能からの確認の場合は、非公開の商品も表示する。
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'];
||
!$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) {
if($objCustomer->isLoginSuccess()) {
$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 product_id = alldtl.product_id AND customer_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"];
if($this->arrProduct['sale_unlimited'] ==
1 ||
$this->arrProduct['sale_limit'] >
SALE_LIMIT_MAX) {
$this->tpl_sale_limit =
SALE_LIMIT_MAX;
$this->tpl_sale_limit =
$this->arrProduct['sale_limit'];
$this->tpl_subtitle =
$this->arrProduct['name'];
$this->arrRelativeCat =
$objDb->sfGetMultiCatTree($tmp_id);
$this->arrProduct['main_list_image']
=
SC_Utils_Ex::sfNoImageMainList($this->arrProduct['main_list_image']);
$this->arrProduct['main_image']
=
SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) !=
1) {
$this->arrTrackbackView =
"OFF";
$this->arrTrackbackView =
"ON";
$this->trackback_url =
TRACKBACK_TO_URL .
$tmp_id;
if (isset
($this->arrFile["main_large_image"])) {
$image_path =
IMAGE_SAVE_DIR .
basename($this->arrFile["main_large_image"]["filepath"]);
list
($large_width, $large_height) =
getimagesize($image_path);
$this->tpl_large_width =
$large_width +
60;
$this->tpl_large_height =
$large_height +
80;
$objView->assignobj($this);
$objView->display(SITE_FRAME);
if (!isset
($_POST['mode'])) $_POST['mode'] =
"";
if(!empty($_POST['mode'])) {
$tmp_id =
$_POST['product_id'];
$tmp_id =
$_GET['product_id'];
||
!$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, 'del_flg = 0 AND status = 1')) {
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"];
if($this->arrProduct['sale_unlimited'] ==
1 ||
$this->arrProduct['sale_limit'] >
SALE_LIMIT_MAX) {
$this->tpl_sale_limit =
SALE_LIMIT_MAX;
$this->tpl_sale_limit =
$this->arrProduct['sale_limit'];
$this->tpl_subtitle =
$this->arrProduct["name"];
$this->arrProduct['main_list_image']
=
SC_Utils_Ex::sfNoImageMainList($this->arrProduct['main_list_image']);
$this->arrProduct['main_image']
=
SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
$this->tpl_title =
"商品詳細 ".
$this->arrProduct["name"];
if (!empty($this->arrFile["main_large_image"])) {
list
($large_width, $large_height) =
getimagesize(IMAGE_SAVE_DIR .
basename($this->arrFile["main_large_image"]["filepath"]));
$this->tpl_large_width = isset
($large_width) ?
$large_width +
60 :
0;
$this->tpl_large_height = isset
($large_height) ?
$large_height +
80 :
0;
$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);
$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;
$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"));
$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 ($_POST['mode'] ==
"add_favorite") {
$customer_id =
$objCustomer->getValue('customer_id');
if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
$objErr->arrErr['add_favorite'.
$favorite_product_id] =
"※ この商品は既にお気に入りに追加されています。<br />";
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);
$this->objUpFile->setDBFileList($this->arrProduct);
$this->arrFile =
$this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
$this->subImageFlag =
false;
for ($i =
1; $i <=
PRODUCTSUB_MAX; $i++
) {
if ($this->arrFile["sub_image" .
$i]["filepath"] !=
"") {
$this->subImageFlag =
true;
$count =
$objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id));
$sqlval['customer_id'] =
$customer_id;
$sqlval['product_id'] =
$product_id;
$objQuery->insert('dtb_customer_favorite_products', $sqlval);
Documentation generated on Tue, 28 Apr 2009 18:12:41 +0900 by phpDocumentor 1.4.2