EC-CUBE:「お問い合わせ管理機能」「返信機能」を追加する(「回答希望」が設定されている場合)

下記が設定されている場合
「お問い合わせ」の項目に「回答希望」を追加する

ここでの紹介は、
「お問い合わせ管理機能」「返信機能」を追加するに回答希望の欄を付け足すためのカスタマイズを含んでいます。

1 「お問い合わせ管理機能」作成のために、データベースにdtb_contactテーブルを作成する。下記SQLを実行する
——————————————-
CREATE TABLE dtb_contact(
contact_id serial NOT NULL,
name01 text,
name02 text,
zip01 text,
zip02 text,
pref integer,
addr01 text,
addr02 text,
tel01 text,
tel02 text,
tel03 text,
email text,
contents text,
kaitotel text,
kaitoemail text,
timezone text,
create_date timestamp,
del_flg integer DEFAULT 0,
customer_id integer,
status integer DEFAULT 0
);
——————————————-

2 データベースに登録する
■data/class/pages/contact/LC_Page_Contact.php

115行目あたり function actionメソッド内の「$this->arrForm = $objFormParam->getFormParamList();」の後に追加

 // ▼データベースに登録する
 $this->lfRegisterContactData();

class LC_Page_Contact extends LC_Page_Exクラス内の一番最後に追加

 function lfRegisterContactData(){
 $sqlval = array();//データベース登録用の配列を用意
 $objQuery = new SC_Query();//データベース操作クラスをインスタンス化
 //DB登録用の配列に値を代入
 $sqlval['name01']      = $this->arrForm['name01']['value'];      //お名前(姓)
 $sqlval['name02']      = $this->arrForm['name02']['value'];      //お名前(姓
 $sqlval['email']       = $this->arrForm['email']['value'];       //メールアドレス
 $sqlval['zip01']       = $this->arrForm['zip01']['value'];       //郵便番号上1
 $sqlval['zip02']       = $this->arrForm['zip02']['value'];       //郵便番号下2
 $sqlval['pref']        = $this->arrForm['pref']['value'];        //都道府県番号
 $sqlval['addr01']      = $this->arrForm['addr01']['value'];      //住所1
 $sqlval['addr02']      = $this->arrForm['addr02']['value'];      //住所2
 $sqlval['tel01']       = $this->arrForm['tel01']['value'];       //お電話番号1
 $sqlval['tel02']       = $this->arrForm['tel02']['value'];       //お電話番号2
 $sqlval['tel03']       = $this->arrForm['tel03']['value'];       //お電話番号3
 $sqlval['contents']    = $this->arrForm['contents']['value'];    //問い合わせ内容
 $sqlval['kaitotel']    = $this->arrForm['kaitotel']['value'];    //回答方法(電話)
 $sqlval['kaitoemail']    = $this->arrForm['kaitoemail']['value'];    //回答方法(メール)
 $sqlval['timezone']    = $this->arrForm['timezone']['value'];    //ご希望の時間帯
 $sqlval['create_date'] = $this->arrForm['create_date']['value']; //送信日時
 if(isset($this->arrData['customer_id']) && !empty($this->arrData['customer_id'])){
 // 会員番号が存在するのであれば、会員番号も登録
 $sqlval['customer_id'] = $this->arrData['customer_id'];     //会員番号
 }
 $objQuery->insert("dtb_contact",$sqlval);//問い合わせ内容を登録
 }

3 管理画面で表示・処理するページを新規作成

(1)
 ■html/admin/customer/contact.php
 ■html/admin/customer/contact_detail.php

(2)
 ■data/class_extends/page_extends/admin\customer/LC_Page_Admin_Customer_Contact_Ex.php
 ■data/class_extends/page_extends/admin\customer/LC_Page_Admin_Customer_Contact_Detail_Ex.php

(3)
 ■data/class/pages/admin/customer/LC_Page_Admin_Customer_Contact.php
 ■data/class/pages/admin/customer/LC_Page_Admin_Customer_Contact_Detail.php

(4)
 ■data/Smarty/templates/admin/customer/contact.tpl
「住所」と「操作」の間にセルを1つ追加する。

 <table class="list">
 <!--デーブルの横幅の指定-->
 <colgroup width="10%">
 <colgroup width="10%">
 <colgroup width="20%">
 <colgroup width="15%">
 <colgroup width="15%">
 <colgroup width="15%">
 <colgroup width="10%">
 <colgroup width="5%">
 <tr>
 <th rowspan="2">状況</th>
 <th>名前</th>
 <th rowspan="2">内容</th>
 <th>メールアドレス</th>
 <th rowspan="2">受信日時</th>
 <th rowspan="2">住所</th>
 <th>回答方法</th>
 <th rowspan="2">操作</th>
 </tr>
 <tr>
 <th>会員ID</th>
 <th>TEL</th>
 <th>時間帯</th>
 </tr>
 <!--問い合わせ件数分だけ表示する-->
 <!--{section name=cnt loop=$arrResults}-->
 <tr>
 <td rowspan="2">
 <a href   = "./contact_detail.php?contact_id=<!--{$arrResults[cnt].contact_id }-->">
 <!--{if $arrResults[cnt].status == 0}-->
 未読
 <!--{elseif $arrResults[cnt].status == 1}-->
 既読
 <!--{elseif $arrResults[cnt].status == 2}-->
 対応中
 <!--{elseif $arrResults[cnt].status == 3}-->
 対応済み
 <!--{/if}-->
 </a>
 </td>
 <td><!--{$arrResults[cnt].name01}--><!--{$arrResults[cnt].name02}--></td>
 <td rowspan="2"><!--{$arrResults[cnt].contents|truncate:60}--></td>
 <td><!--{$arrResults[cnt].email}--></td>
 <td rowspan="2"><!--{$arrResults[cnt].create_date}--></td>
 <!--{assign var=pref value=$arrResults[cnt].pref}-->
 <td rowspan="2">〒<!--{$arrResults[cnt].zip01}-->-<!--{$arrResults[cnt].zip02}--><br /><!--{$arrPref[$pref]}--><!--{$arrResults[cnt].addr01}--><!--{$arrResults[cnt].addr02}--></td>
 <td><!--{if $arrResults[cnt].kaitotel == 1}-->電話 <!--{/if}--><!--{if $arrResults[cnt].kaitoemail == 1}-->E-Mail<!--{/if}--></td>
 <td><a href = "./contact_reply.php?contact_id=<!--{$arrResults[cnt].contact_id }-->">返信</a></td>
 </tr>
 <tr>
 <td>
 <!--会員の問い合わせなら会員番号を表示する-->
 <!--{if $arrResults[cnt].customer_id  != NULL && $arrResults[cnt].customer_id != "" }-->
 <!--{$arrResults[cnt].customer_id}-->
 <!--{else}-->
 非会員
 <!--{/if}-->
 </td>
 <td><!--{$arrResults[cnt].tel01}-->-<!--{$arrResults[cnt].tel02}-->-<!--{$arrResults[cnt].tel03}--></td>
 <td><!--{if $arrResults[cnt].timezone == 1}-->午前(9:00~10:30)<!--{elseif $arrResults[cnt].timezone == 2}-->午前(10:30~12:00)<!--{elseif $arrResults[cnt].timezone == 3}-->お昼(12:00~13:00)<!--{elseif $arrResults[cnt].timezone == 4}-->午後(13:00~15:00)<!--{elseif $arrResults[cnt].timezone == 5}-->午後(15:00~17:00)<!--{elseif $arrResults[cnt].timezone == 6}-->特になし<!--{/if}--></td>
 <td><a href="./contact.php?contact_id=<!--{$arrResults[cnt].contact_id}-->" onclick="fnModeSubmit('delete', 'contact_id', <!--{$arrResults[cnt].contact_id }-->);return false;"><span class="icon_delete">削除</span></a></td>
 </tr>
 <!--{/section}-->
 </table>

 ■data/Smarty/templates/admin/customer/contact_detail.tpl

 <tr>
 <th>回答方法・時間帯</th>
 <td colspan = "3"><!--{if $list_data.kaitotel == 1}-->電話 <!--{/if}--><!--{if $list_data.kaitoemail == 1}-->E-Mail<!--{/if}--> ・ <!--{if $list_data.timezone == 1}-->午前(9:00~10:30)<!--{elseif $list_data.timezone == 2}-->午前(10:30~12:00)<!--{elseif $list_data.timezone == 3}-->お昼(12:00~13:00)<!--{elseif $list_data.timezone == 4}-->午後(13:00~15:00)<!--{elseif $list_data.timezone == 5}-->午後(15:00~17:00)<!--{elseif $list_data.timezone == 6}-->特になし<!--{/if}--></td>
 </tr>

(5)■data/Smarty/templates/admin/customer/subnavi.tplに追加

 <li<!--{if $tpl_subno == 'contact'}--> class="on"<!--{/if}--> id="navi-customer-customer"><a href="<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->customer/contact.php"><span>お問い合わせメール管理</span></a></li>

4 「返信機能」作成のために、データベースにdtb_contact_replyテーブルを作成する。下記SQLを実行する
——————————————-
CREATE TABLE dtb_contact_reply(
mail_id serial NOT NULL,
contact_id integer,
email text,
title text,
content text,
create_date timestamp,
del_flg integer DEFAULT 0
);
——————————————-

5 管理画面からお問い合わせに返信するページを作成する。

(1)
■html/admin/customer/contact_reply.php

(2)
■data/class_extends/page_extends/admin\customer/LC_Page_Admin_Customer_Contact_Reply_Ex.php

(3)
■data/class/pages/admin/customer/LC_Page_Admin_Customer_Contact_Reply.php
★本文には、「名字・名前 様」と表示されなければいけないところを「名字・名字 様」と表示される場合は、172行目あたりの2つめの「name01」を「name02」に変更します。

 $this->arrForm['content'] = $this->contact_data[0]['name01'] . $this->contact_data[0]['name02'] . '様'・・・・・

(4)
■data/Smarty/templates/admin/customer/contact_reply.tpl

▼上記の3で作成した下記ファイルに追加する
■data/Smarty/templates/admin/customer/contact.tpl
■data/Smarty/templates/admin/customer/contact_detail.tpl

6 「送信履歴」の「本文」の背景
本文が長く、テーブルのセルが広がると背景色が2色になって見づらいので修正する。

■data/Smarty/templates/admin/customer/contact_reply.tplの最下部

 <th>本文</th>
 ↓
 <th class="contact_reply">本文</th>

■html/user_data/packages/admin/css/admin_contents.css
127行目あたり
table.list th {
background: url(‘../img/contents/table_back.png’) repeat-x #b4b4b4;
text-align: center;
}
の下に、追加する。

 table.list th.contact_reply {
 background-color:#F4F5F5;
 }