「お問い合わせ」の項目に「回答希望」を追加するが適用されている場合は、
↓こちらをご覧ください。
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,
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['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_Detail.php
■data/class/pages/admin/customer/LC_Page_Admin_Customer_Contact.php
(4)
■data/Smarty/templates/admin/customer/contact.tpl
■data/Smarty/templates/admin/customer/contact_detail.tpl
(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; }