Last active
March 2, 2016 00:14
-
-
Save itacts/386a51911438828572a6 to your computer and use it in GitHub Desktop.
reserve_form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('C5_EXECUTE') or die(_("Access Denied.")); | |
//メールタイトル | |
$subject = '予約メール'; | |
//メール内容 | |
$body = sprintf(" | |
<<自動返信メール>> | |
※ このメールは 予約自動返信メールになります。 | |
内容につきましては 確認でき次第 改めてメールにて | |
連絡をさせていただきますので 今 しばらくお待ちください。 | |
---------------------------------------------------------- | |
お名前:%s 様 | |
メールアドレス:%s | |
郵便番号:%s | |
住所:%s | |
連絡先TEL:%s | |
体験希望日:%s | |
到着予定時間:%s | |
体験人数:%s 名 | |
メッセージ:%s | |
---------------------------------------------------------- | |
ご意見・ご要望・ご質問等 御座いましたら下記まで、お問い合わせ下さい。 | |
■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■ | |
お店の名前 | |
〒お店の住所 | |
TEL:(111)-111-1111 | |
FAX:(222)-222-222 | |
URL: http://www.hogehoge.com | |
E-Mail:hoge@hogehoge.com | |
■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■ | |
", $r_name, $r_email,$r_post,$r_address,$r_tel | |
,$r_date,$r_time,$r_people,$r_message); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('C5_EXECUTE') or die("Access Denied."); | |
//フォームヘルパー | |
$form = Core::make('helper/form'); | |
//日時・時刻 カレンダー・時間選択ウィジェット | |
$dtt = Core::make('helper/form/date_time'); | |
//時間 | |
$time=array( | |
'時間未定(後日連絡)' => '時間未定(後日連絡)' , | |
'9:00-10:00 a.m' => '9:00-10:00 a.m', | |
'10:00-11:00 a.m' => '10:00-11:00 a.m', | |
'1:00-12:00 a.m' => '11:00-12:00 a.m', | |
'12:00-1:00 p.m' => '12:00-1:00 p.m', | |
'1:00-2:00 p.m' => '1:00-2:00 p.m', | |
'2:00-3:00 p.m' => '2:00-3:00 p.m', | |
'3:00-4:00 p.m' => '3:00-4:00 p.m', | |
); | |
// エラーメッセージの表示 | |
if (isset($errorArray) && is_array($errorArray) && count($errorArray) > 0) { | |
?> | |
<div style="border:1px solid red"> | |
<?php foreach ($errorArray as $e){ | |
?> | |
<p style="color:red"> | |
<?php echo $e?> | |
</p> | |
<?php | |
} | |
?> | |
</div> | |
<?php } | |
// お礼メッセージの表示 | |
if (isset($response)) { | |
echo $response; } | |
?> | |
<section id="contact"> | |
<form method ="post" action="<?php echo $this->action('reserve_form_submit')?>"> | |
<dl> | |
<dt>お名前:<span>※必須</span></dt> | |
<dd><?php echo $form->text('r_name')?></dd> | |
<dt>メールアドレス:<span>※必須</span></dt> | |
<dd><?php echo $form->text('r_email')?></dd> | |
<dt>〒:</dt> | |
<dd><?php echo $form->text('r_post')?></dd> | |
<dt>ご住所:</dt> | |
<dd><?php echo $form->text('r_address')?></dd> | |
<dt>連絡先TEL:</dt> | |
<dd><?php echo $form->text('r_tel')?></dd> | |
<dt>体験希望日:<span>※必須</span></dt> | |
<dd><?=$dtt->date('r_date', $dtt->translate('r_date'), true)?></dd> | |
<dt>到着予定時間:<span>※必須</span></dt> | |
<dd> <?=$form->select('r_time', $time, '時間未定(後日連絡)')?></dd> | |
<dt>体験人数:<span>※必須</span></dt> | |
<dd><?php echo $form->text('r_people')?></dd> | |
<dt>メッセージ:</dt> | |
<dd><?php echo $form->textarea('r_message')?></dd> | |
</dl> | |
<?php echo $form->submit('submit','送信'); ?> | |
</form> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Block\ExternalForm\Form\Controller; | |
use Concrete\Core\Controller\AbstractController; | |
use Page; | |
use User; | |
use UserInfo; | |
use Core; | |
defined('C5_EXECUTE') or die("Access Denied."); | |
class ReserveForm extends AbstractController | |
{ | |
public function view() | |
{ | |
$this->requireAsset('css', 'jquery/ui'); | |
$this->requireAsset('javascript', 'jquery/ui'); | |
} | |
public function action_reserve_form_submit() | |
{ | |
//お店のアドレス | |
$shopmail="hoge@hogehoge.com"; | |
$sitename="お店の名前; | |
// validation/form ヘルパーを呼び出し | |
$val =Core::make('helper/validation/form'); | |
// postデータをバリデーションに登録 | |
$val->setData($this->post()); | |
// 必須項目ルールの追加 | |
$val->addRequired('r_name', '名前を入力してください。'); | |
$val->addRequired('r_people', '体験人数を入力してください。'); | |
$val->addRequired('r_email', 'メールアドレスを入力してください。'); | |
// メールアドレスの検証 | |
$val->addRequiredEmail('r_email', '有効なメールアドレスを入力してください。'); | |
// テスト実行 | |
if (!$val->test()) { | |
// テストに通らなかった場合はビューにエラーを渡す | |
$errorArray = $val->getError()->getList(); | |
$this->set('errorArray', $errorArray); | |
} else { | |
// テストに通った場合の処理 | |
$mh = Core::make('helper/mail'); | |
// FROMアドレスの設定 | |
$mh->from($shopmail); | |
// Toアドレスの設定 | |
$mh->to($this->post('r_email')); | |
// 管理者ユーザー情報を取得 | |
$adminUserInfo = UserInfo::getByID(USER_SUPER_ID); | |
if (is_object($adminUserInfo)) { | |
// 管理者メールアドレスをBCCに設定 | |
$mh->bcc($adminUserInfo->getUserEmail()); | |
// お店のアドレスへ確認メール BCCに設定 | |
$mh->bcc($shopmail); | |
} | |
// メール変数を設定 | |
$mh->addParameter('r_name', $this->post('r_name')); //お名前 | |
$mh->addParameter('r_email', $this->post('r_email')); //メールアドレス | |
$mh->addParameter('r_post', $this->post('r_post')); //郵便番号 | |
$mh->addParameter('r_address', $this->post('r_address')); //ご住所 | |
$mh->addParameter('r_tel', $this->post('r_tel')); //連絡先TEL | |
$mh->addParameter('r_date', $this->post('r_date')); //体験希望日 | |
$mh->addParameter('r_time', $this->post('r_time')); //到着予定時間 | |
$mh->addParameter('r_people', $this->post('r_people')); //体験人数 | |
$mh->addParameter('r_message', $this->post('r_message')); //メッセージ | |
// メールテンプレートを設定 | |
$mh->load('reserve_form_complete'); | |
// メール送信 | |
$mh->sendMail(); | |
// メール送信後の処理(確認ページへ移動) | |
$nh = Core::make('helper/navigation'); //ナビヘルパー | |
$page = Page::getCurrentPage(); //ページ情報所得 | |
$parent = Page::getByID($page->getCollectionParentID()); //親ページ情報所得 | |
$parentLink = $nh->getCollectionURL($parent); //親ページのURL所得 | |
header("Location: $parentLink/reservation-check/"); //確認ページへ移動 | |
exit ; | |
// メール送信後の処理(フォームにメッセージを表示) | |
//$this->set('response', 'ご予約ありがとうございました。 | |
//内容確認自動返信メールをお送りしました。'); | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment