お問い合わせ管理プラグインをインストールすると、EC-CUBEで問い合わせが管理できます。このプラグインを利用して、会員のマイページでも問い合わせ履歴を確認できるようにしてみました。
まず、会員毎の問い合わせ履歴を取得するクラスを以下の場所に用意します。
data/class/pages/mypage/LC_Page_Mypage_Contact.php
require_once CLASS_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.php';
/**
* MyPage のページクラス.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Mypage.php 23230 2013-09-19 02:49:03Z m_uehara $
*/
class LC_Page_Mypage_Contact extends LC_Page_AbstractMypage_Ex
{
/** ページナンバー */
public $tpl_pageno;
/**
* Page を初期化する.
*
* @return void
*/
public function init()
{
parent::init();
$this->tpl_subtitle = 'お問い合わせ履歴';
$this->tpl_mypageno = 'contact';
}
/**
* Page のプロセス.
*
* @return void
*/
public function process()
{
parent::process();
}
/**
* Page のAction.
*
* @return void
*/
public function action()
{
$objCustomer = new SC_Customer_Ex();
$customer_id = $objCustomer->getValue('customer_id');
//ページ送り用
$this->objNavi = new SC_PageNavi_Ex($_REQUEST['pageno'],
$this->lfGetContacts($customer_id),
SEARCH_PMAX,
'eccube.movePage',
NAVI_PMAX,
'pageno=#page#',
SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE);
$this->arrContact = $this->lfGetContacts($customer_id, $this->objNavi->start_row);
// 1ページあたりの件数
$this->dispNumber = SEARCH_PMAX;
//対応状況マスターデータ
$masterData = new SC_DB_MasterData_Ex();
$this->arrCONTACTSTATUS = $masterData->getMasterData("mtb_plg_ContactReply_status");
}
/**
* お問い合わせを取得する
*
* @param mixed $customer_id
* @param mixed $objPage
* @access private
* @return array お問い合わせ一覧
*/
function lfGetContacts($customer_id, $startno = -1)
{
$objQuery =& SC_Query_Ex::getSingletonInstance();
$col = <<< __EOS__
*
__EOS__;
$from = <<< __EOS__
plg_ContactReply_contact
__EOS__;
$where = <<< __EOS__
customer_id = ?
AND del_flg = 0
__EOS__;
$arrWhereVal[] = $customer_id;
$order = 'contact_id DESC';
if ($startno == -1) {
return $objQuery->count($from, $where, $arrWhereVal);
}
$objQuery->setLimitOffset(SEARCH_PMAX, $startno);
// 表示順序
$objQuery->setOrder($order);
//お問い合わせ履歴情報の取得の取得
return $objQuery->select($col, $from, $where, $arrWhereVal);
}
}
次に、LC_Page_Mypage_Contactの拡張クラスを以下の場所に用意します。
data/class_extends/pages_extends/mypage/LC_Page_Mypage_Contact_EX.php
require_once CLASS_REALDIR . 'pages/mypage/LC_Page_Mypage_Contact.php';
/**
* 購入履歴 のページクラス(拡張).
*
* LC_Page_Mypage_Contact をカスタマイズする場合はこのクラスを編集する.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Mypage_Contact_Ex.php 22926 2013-06-29 16:24:23Z Seasoft $
*/
class LC_Page_Mypage_Contact_Ex extends LC_Page_Mypage_Contact
{
/**
* Page を初期化する.
*
* @return void
*/
function init()
{
parent::init();
}
/**
* Page のプロセス.
*
* @return void
*/
function process()
{
parent::process();
}
}
問い合わせ履歴一覧ページのテンプレートを以下の場所に用意します。
data/Smarty/templates/default/mypage/contact.tpl
<div id="mypagecolumn">
<h2 class="title"><!--{$tpl_title|h}--></h2>
<!--{if $tpl_navi != ""}-->
<!--{include file=$tpl_navi}-->
<!--{else}-->
<!--{include file=`$smarty.const.TEMPLATE_REALDIR`mypage/navi.tpl}-->
<!--{/if}-->
<div id="mycontents_area">
<form name="form1" id="form1" method="post" action="?">
<input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
<input type="hidden" name="pageno" value="<!--{$objNavi->nowpage}-->" />
<h3><!--{$tpl_subtitle|h}--></h3>
<!--{if $objNavi->all_row > 0}-->
<p><span class="attention"><!--{$objNavi->all_row}-->件</span>のお問い合わせがあります。</p>
<div class="pagenumber_area">
<!--▼ページナビ-->
<!--{$objNavi->strnavi}-->
<!--▲ページナビ-->
</div>
<table summary="お問い合わせ履歴">
<col width="15%" />
<col width="70%" />
<col width="15%" />
<tr>
<th class="alignC">送信日時</th>
<th class="alignC">内容</th>
<th class="alignC">対応状況</th>
</tr>
<!--{section name=cnt loop=$arrContact}-->
<!--{assign var=contact_id value=$arrContact[cnt].contact_id}-->
<!--{assign var=status value=$arrContact[cnt].status}-->
<tr>
<td class="alignC"><!--{$arrContact[cnt].create_date|sfDispDBDate:false}--></td>
<td class="alignL"><!--{$arrContact[cnt].contents|escape|nl2br}--></td>
<td class="alignC"><!--{$arrCONTACTSTATUS[$status]}--></td>
</tr>
<!--{/section}-->
</table>
<!--{else}-->
<p>お問い合わせ履歴はありません。</p>
<!--{/if}-->
</form>
</div>
</div>
マイページのグローバルナビゲーションにもお問い合せ履歴を追加します。
data/Smarty/templates/default/mypage/navi.tpl
<div id="mynavi_area">
<!--{strip}-->
<ul class="mynavi_list clearfix">
<!--{* 会員状態 *}-->
<!--{if $tpl_login}-->
<li><a href="./<!--{$smarty.const.DIR_INDEX_PATH}-->" class="<!--{if $tpl_mypageno == 'index'}--> selected<!--{/if}-->">
購入履歴一覧</a></li>
<!--{if $smarty.const.OPTION_FAVORITE_PRODUCT == 1}-->
<li><a href="favorite.php" class="<!--{if $tpl_mypageno == 'favorite'}--> selected<!--{/if}-->">
お気に入り一覧</a></li>
<!--{/if}-->
<li><a href="contact.php" class="<!--{if $tpl_mypageno == 'contact'}--> selected<!--{/if}-->">
お問い合わせ履歴</a></li>
<li><a href="change.php" class="<!--{if $tpl_mypageno == 'change'}--> selected<!--{/if}-->">
会員登録内容変更</a></li>
<li><a href="delivery.php" class="<!--{if $tpl_mypageno == 'delivery'}--> selected<!--{/if}-->">
お届け先追加・変更</a></li>
<li><a href="refusal.php" class="<!--{if $tpl_mypageno == 'refusal'}--> selected<!--{/if}-->">
退会手続き</a></li>
<!--{* 退会状態 *}-->
<!--{else}-->
<li><a href="<!--{$smarty.const.TOP_URL}-->" class="<!--{if $tpl_mypageno == 'index'}--> selected<!--{/if}-->">
購入履歴一覧</a></li>
<!--{if $smarty.const.OPTION_FAVORITE_PRODUCT == 1}-->
<li><a href="<!--{$smarty.const.TOP_URL}-->" class="<!--{if $tpl_mypageno == 'favorite'}--> selected<!--{/if}-->">
お気に入り一覧</a></li>
<!--{/if}-->
<li><a href="<!--{$smarty.const.TOP_URL}-->" class="<!--{if $tpl_mypageno == 'change'}--> selected<!--{/if}-->">
会員登録内容変更</a></li>
<li><a href="<!--{$smarty.const.TOP_URL}-->" class="<!--{if $tpl_mypageno == 'delivery'}--> selected<!--{/if}-->">
お届け先追加・変更</a></li>
<li><a href="<!--{$smarty.const.TOP_URL}-->" class="<!--{if $tpl_mypageno == 'refusal'}--> selected<!--{/if}-->">
退会手続き</a></li>
<!--{/if}-->
</ul>
<!--▼現在のポイント-->
<!--{if $point_disp !== false}-->
<div class="point_announce clearfix">
<p>ようこそ /
<span class="user_name"><!--{$CustomerName1|h}--> <!--{$CustomerName2|h}-->様</span>
<!--{if $smarty.const.USE_POINT !== false}-->
現在の所持ポイントは <span class="point st"><!--{$CustomerPoint|number_format|default:"0"|h}-->pt</span> です。
<!--{/if}-->
</p>
</div>
<!--{/if}-->
<!--▲現在のポイント-->
<!--{/strip}-->
</div>
<!--▲NAVI-->
最後にデータベースに以下のデータを追加すれば完了です。
SET @page_id = (SELECT page_id FROM dtb_pagelayout WHERE device_type_id = 10 ORDER BY page_id DESC LIMIT 1); INSERT INTO dtb_pagelayout (device_type_id, page_id, page_name, url, filename, header_chk, footer_chk, edit_flg, author, description, keyword, update_url, create_date, update_date, meta_robots) VALUES (10, (@page_id+1), 'お問い合わせ履歴', 'mypage/contact.php', 'mypage/contact', 1, 1, 2, NULL, NULL, NULL, NULL, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'noindex');
EC-CUBEってホント簡単に色々できますね。
コメントを頂いたので追記。
htmlフォルダに以下のファイルを作成する必要があるのをすっかり忘れていました。失礼しました。
html/mypage/contact.php
require_once '../require.php'; require_once CLASS_EX_REALDIR . 'page_extends/mypage/LC_Page_Mypage_Contact_Ex.php'; $objPage = new LC_Page_Mypage_Contact_Ex(); $objPage->init(); $objPage->process();

ありがとうございました。
この記事を参考にさせて頂きました。
ただ、直下のmypageディレクトリ内にcontact.phpを作成する手順が抜けていたので、四苦八苦してしまいました。
今後のここを見られた方の為にも可能であれば追記した方が良いかもしれませんね。
ご迷惑をお掛けしてすみません。
html/mypage/contact.phpを作成する手順が抜けてました。
追記しておきます。ご指摘ありがとうございます。