Changeset 17162


Ignore:
Timestamp:
2008/03/17 22:54:44 (16 years ago)
Author:
Yammy
Message:

http://svn.ec-cube.net/open_trac/ticket/254
お気に入り商品登録機能 一式コミット

Location:
branches/comu-ver2
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/Smarty/templates/default/detail.tpl

    r17071 r17162  
    147147        <input type="hidden" name="mode" value="cart" /> 
    148148        <input type="hidden" name="product_id" value="<!--{$tpl_product_id}-->" /> 
     149        <input type="hidden" name="favorite_product_id" value="" /> 
    149150        <!--{if $tpl_classcat_find1}--> 
    150151        <dl> 
     
    194195        <!--{if $tpl_stock_find}--> 
    195196        <p class="btn"> 
     197          <!--{if $smarty.const.OPTION_FAVOFITE_PRODUCT == 1}--> 
     198            <!--{assign var=add_favorite value="add_favorite`$product_id`"}--> 
     199            <!--{if $arrErr[$add_favorite]}--><div class="attention"><!--{$arrErr[$add_favorite]}--></div><!--{/if}--> 
     200            <!--{if !$arrProduct.favorite_count}--> 
     201            <a href="javascript:fnModeSubmit('add_favorite','favorite_product_id','<!--{$arrProduct.product_id}-->');">[お気に入りに追加]</a><br /> 
     202            <!--{else}--> 
     203            [お気に入り登録済]<br /> 
     204            <!--{/if}--> 
     205          <!--{/if}--> 
    196206          <!--★カゴに入れる★--> 
    197207          <a href="javascript:void(document.form1.submit())" onmouseover="chgImg('<!--{$TPL_DIR}-->img/products/b_cartin_on.gif','cart');" onmouseout="chgImg('<!--{$TPL_DIR}-->img/products/b_cartin.gif','cart');"> 
  • branches/comu-ver2/data/Smarty/templates/default/mypage/navi.tpl

    r16582 r17162  
    2929    <li><a href="./index.php" onmouseover="chgImg('<!--{$TPL_DIR}-->img/mypage/navi01_on.jpg','m_navi01');" onmouseout="chgImg('<!--{$TPL_DIR}-->img/mypage/navi01.jpg','m_navi01');"><img src="<!--{$TPL_DIR}-->img/mypage/navi01.jpg" width="170" height="30" alt="購入履歴一覧" border="0" name="m_navi01" /></a></li> 
    3030  <!--{/if}--> 
     31  <!--{if $smarty.const.OPTION_FAVOFITE_PRODUCT == 1}--> 
     32  <!--{if $tpl_mypageno == 'favorite'}--> 
     33    <li><a href="./favorite.php">お気に入り商品</a></li> 
     34  <!--{else}--> 
     35    <li><a href="./favorite.php">お気に入り商品</a></li> 
     36  <!--{/if}--> 
     37  <!--{/if}--> 
    3138  <!--{if $tpl_mypageno == 'change'}--> 
    3239    <li><a href="./change.php"><img src="<!--{$TPL_DIR}-->img/mypage/navi02_on.jpg" width="170" height="30" alt="会員登録内容変更" border="0" name="m_navi02" /></a></li> 
  • branches/comu-ver2/data/class/pages/products/LC_Page_Products_Detail.php

    r17103 r17162  
    8484        $helper->sfGetPageLayout($this, false, "products/detail.php"); 
    8585 
     86        if(isset($_POST['mode']) && $_POST['favorite_product_id'] != "" && $_POST['mode'] == "add_favorite") { 
     87            // 値の正当性チェック 
     88            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")) { 
     89                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 
     90                exit; 
     91            } else { 
     92                $this->arrErr = $this->lfCheckError(); 
     93                if(count($this->arrErr) == 0) { 
     94                    $customer_id = $objCustomer->getValue('customer_id'); 
     95                    $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']); 
     96                } 
     97            } 
     98        } 
     99 
    86100        // パラメータ管理クラス 
    87101        $this->objFormParam = new SC_FormParam(); 
     
    190204        $objQuery = new SC_Query(); 
    191205        // DBから商品情報を取得する。 
    192         $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); 
     206        $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)); 
    193207        $this->arrProduct = $arrRet[0]; 
    194208 
     
    725739    /* 入力内容のチェック */ 
    726740    function lfCheckError() { 
    727         // 入力データを渡す。 
    728         $arrRet =  $this->objFormParam->getHashArray(); 
    729         $objErr = new SC_CheckError($arrRet); 
    730         $objErr->arrErr = $this->objFormParam->checkError(); 
    731  
    732         // 複数項目チェック 
    733         if ($this->tpl_classcat_find1) { 
    734             $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 
    735         } 
    736         if ($this->tpl_classcat_find2) { 
    737             $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 
     741        if ($_POST['mode'] == "add_favorite") { 
     742            $objCustomer = new SC_Customer(); 
     743            $objErr = new SC_CheckError(); 
     744            $customer_id = $objCustomer->getValue('customer_id'); 
     745            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) { 
     746                $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />"; 
     747            } 
     748        } else { 
     749            // 入力データを渡す。 
     750            $arrRet =  $this->objFormParam->getHashArray(); 
     751            $objErr = new SC_CheckError($arrRet); 
     752            $objErr->arrErr = $this->objFormParam->checkError(); 
     753 
     754            // 複数項目チェック 
     755            if ($this->tpl_classcat_find1) { 
     756                $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 
     757            } 
     758            if ($this->tpl_classcat_find2) { 
     759                $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 
     760            } 
    738761        } 
    739762 
     
    838861        } 
    839862    } 
     863 
     864    /* 
     865     * お気に入り商品登録 
     866     */ 
     867    function lfRegistFavoriteProduct($customer_id, $product_id) { 
     868        $objQuery = new SC_Query(); 
     869        $objConn = new SC_DbConn(); 
     870        $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id)); 
     871 
     872        if ($count == 0) { 
     873            $sqlval['customer_id'] = $customer_id; 
     874            $sqlval['product_id'] = $product_id; 
     875 
     876            $objQuery->begin(); 
     877            $objQuery->insert('dtb_customer_favorite_products', $sqlval); 
     878            $objQuery->commit(); 
     879        } 
     880    } 
     881 
    840882} 
    841883?> 
  • branches/comu-ver2/data/mtb_constants_init.php

    r17153 r17162  
    679679/** オーナーズストア通信エラーコード */ 
    680680define('OSTORE_E_C_BATCH_ERR', '2010'); 
     681/** お気に入り商品登録(有効:1 無効:0) */ 
     682define('OPTION_FAVOFITE_PRODUCT','1'); 
    681683?> 
  • branches/comu-ver2/html/install/sql/create_table_mysql.sql

    r17087 r17162  
    461461    create_date datetime NOT NULL, 
    462462    update_date datetime NOT NULL 
     463) TYPE=InnoDB ; 
     464 
     465CREATE TABLE dtb_customer_favorite_products ( 
     466    customer_id int NOT NULL, 
     467    product_id int NOT NULL, 
     468    create_date datetime NOT NULL, 
     469    update_date datetime NOT NULL, 
    463470) TYPE=InnoDB ; 
    464471 
  • branches/comu-ver2/html/install/sql/create_table_pgsql.sql

    r17073 r17162  
    461461    create_date timestamp NOT NULL, 
    462462    update_date timestamp NOT NULL DEFAULT NOW() 
     463); 
     464 
     465CREATE TABLE dtb_customer_favorite_products ( 
     466    customer_id int4 NOT NULL, 
     467    product_id int4 NOT NULL, 
     468    create_date timestamp NOT NULL DEFAULT now(), 
     469    update_date timestamp NOT NULL DEFAULT now(), 
     470    PRIMARY KEY (customer_id, product_id) 
    463471); 
    464472 
  • branches/comu-ver2/html/install/sql/insert_data.sql

    r17156 r17162  
    11141114INSERT INTO mtb_constants VALUES ('OSTORE_E_C_PERMISSION', '"2009"', 521, 'オーナーズストア通信エラーコード'); 
    11151115INSERT INTO mtb_constants VALUES ('OSTORE_E_C_BATCH_ERR', '"2010"', 522, 'オーナーズストア通信エラーコード'); 
     1116INSERT INTO mtb_constants VALUES ('OPTION_FAVOFITE_PRODUCT','1',523,'お気に入り商品登録(有効:1 無効:0)'); 
    11161117 
    11171118INSERT INTO dtb_module (module_id,module_code,module_name,update_date,create_date)values(0,0,'patch',now(),now()); 
Note: See TracChangeset for help on using the changeset viewer.