commit 33ddd7119d88e46185033790949c351071651a80
Author: admin <admin@www1334uf.sakura.ne.jp>
Date:   Fri Feb 12 18:15:17 2016 +0900

    機能追加 #658
    【ユーザー画面】問い合わせロジックの実装

diff --git a/app/Controller/AppController.php b/app/Controller/AppController.php
index 7de1d46..15b9d76 100644
--- a/app/Controller/AppController.php
+++ b/app/Controller/AppController.php
@@ -40,6 +40,7 @@ class AppController extends Controller {
 
 	public $components = array(
 		'DebugKit.Toolbar',
+		'Session',
 		/*
 		'Auth' => array(
 			'flash' => array(
diff --git a/app/Controller/TopController.php b/app/Controller/TopController.php
index 4e03455..98db7e1 100644
--- a/app/Controller/TopController.php
+++ b/app/Controller/TopController.php
@@ -19,6 +19,7 @@
  */
 
 App::uses('AppController', 'Controller');
+App::uses('CakeEmail', 'Network/Email');
 
 /**
  * Static content controller
@@ -36,7 +37,7 @@ class TopController extends AppController {
  * @var array
  */
 	var $name = 'top';
-	public $uses = array();
+	public $uses = array('ContactValidate');
 	public $layout = 'top';
 
 /**
@@ -68,5 +69,41 @@ class TopController extends AppController {
  * contact
  */
 	public function contact() {
+		if($this->request->is('post') || $this->request->is('put')){
+			$this->ContactValidate->set($this->request->data);
+			if($this->ContactValidate->validates()){
+				$this->Session->write('contact',$this->request->data);
+				$this->redirect(array('action'=>'contact_confirm'));
+			}else{
+			}
+		}
+	}
+/**
+ * contact_confirm
+ */
+	public function contact_confirm() {
+		if($this->Session->read('contact')){
+			$this->set('contact',$this->Session->read('contact'));
+		}else{
+			$this->redirect(array('action'=>'contact'));
+		}
+	}
+/**
+ * contact_complete
+ */
+	public function contact_complete() {
+		$this->set('contact',$this->Session->read('contact'));
+		$name = $this->Session->read('contact.ContactValidate.name');
+		$mail = $this->Session->read('contact.ContactValidate.mail');
+		$comment = $this->Session->read('contact.ContactValidate.comment');
+		$Email = new CakeEmail();
+		$Email->charset('ISO-2022-JP');
+		$Email->emailFormat('text');
+		$Email->template('user_contact');
+		$Email->viewVars(array('name'=>$name,'comment'=>$comment));
+		$Email->from($mail);
+		$Email->to('yano@i-hearts.jp');
+		$Email->subject('[PICT CODE]問い合わせ');
+		$Email->send();
 	}
 }
diff --git a/app/Model/ContactValidate.php b/app/Model/ContactValidate.php
new file mode 100644
index 0000000..5a9d29d
--- /dev/null
+++ b/app/Model/ContactValidate.php
@@ -0,0 +1,56 @@
+<?php
+App::uses('AppModel', 'Model');
+/**
+ * ContactValidate Model
+ *
+ */
+class ContactValidate extends AppModel {
+
+	public $useTable = false;
+	var $name = 'ContactValidate';
+
+	public $_schema = array(
+		'name' => array(
+			'type' => 'string',
+			'length' => 128,
+		),
+		'mail' => array(
+			'type' => 'string',
+			'length' => 255,
+		),
+		'comment' => array(
+			'type' => 'string',
+			'length' => 255,
+		),
+	);
+
+/**
+ * Validation rules
+ * 
+ * @var array
+ */
+	public $validate = array(
+		'name' => array(
+			'notblank' => array(
+				'rule' => array('notBlank'),
+				'message' => '入力されていません',
+			),
+		),
+		'mail' => array(
+			'notblank' => array(
+				'rule' => array('notBlank'),
+				'message' => '入力されていません',
+			),
+			'isEmail' => array(
+				'rule' => 'Email',
+				'message' => '入力形式が正しくありません',
+			),
+		),
+		'comment' => array(
+			'notblank' => array(
+				'rule' => array('notblank'),
+				'message' => '入力されていません',
+			),
+		),
+	);
+}
diff --git a/app/View/Emails/text/user_contact.ctp b/app/View/Emails/text/user_contact.ctp
new file mode 100644
index 0000000..7f13c51
--- /dev/null
+++ b/app/View/Emails/text/user_contact.ctp
@@ -0,0 +1,16 @@
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+このメールは、PICT CODE から配信されています
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+以下の内容で、お客様よりお問い合わせがありました。
+
+お名前：<?php echo $name;?>
+
+お問い合わせ内容：
+
+<?php echo $comment;?>
+
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+PICT CODE カスタマーサポートセンター
+メールでのお問い合わせ： info@itkids.com
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
diff --git a/app/View/Layouts/Emails/text/default.ctp b/app/View/Layouts/Emails/text/default.ctp
index 5396158..cdec028 100644
--- a/app/View/Layouts/Emails/text/default.ctp
+++ b/app/View/Layouts/Emails/text/default.ctp
@@ -16,4 +16,3 @@
 ?>
 <?php echo $this->fetch('content'); ?>
 
-This email was sent using the CakePHP Framework, http://cakephp.org.
diff --git a/app/View/top/contact.ctp b/app/View/top/contact.ctp
index e3a359a..41b008f 100644
--- a/app/View/top/contact.ctp
+++ b/app/View/top/contact.ctp
@@ -9,4 +9,23 @@
 </div>
 </div>
 </header>
+<div class="contact form">
+<?php echo $this->Form->create('ContactValidate',array(
+	'inputDefaults' => array(
+		'div' => 'form-group',
+		'wrapInput' => false,
+		'class' => 'form-control'
+	),
+	'class' => 'well')); ?>
+<fieldset>
+	<legend><?php echo __('お問い合わせ'); ?></legend>
+<?php
+	echo $this->Form->input('name',array('label'=>'お名前'));
+	echo $this->Form->input('mail',array('label'=>'メールアドレス'));
+	echo $this->Form->input('comment',array('type'=>'textarea','label'=>'問い合わせ内容'));
+?>
+<?php echo $this->Form->submit('送信する',array('class'=>'btn btn-info')); ?>
+<?php echo $this->Form->end(); ?>
+</div>
+
 <?php echo $this->element('footer');?>
diff --git a/app/View/top/contact_complete.ctp b/app/View/top/contact_complete.ctp
new file mode 100644
index 0000000..b814d8c
--- /dev/null
+++ b/app/View/top/contact_complete.ctp
@@ -0,0 +1,16 @@
+<header>
+<div class="container">
+<div class="row">
+<div class="col-lg-12">
+<div class="intro-text">
+<span class="name">お問い合わせ</span>
+</div>
+</div>
+</div>
+</div>
+</header>
+<div class="contact form">
+<p>送信しました</p>
+</div>
+
+<?php echo $this->element('footer');?>
diff --git a/app/View/top/contact_confirm.ctp b/app/View/top/contact_confirm.ctp
new file mode 100644
index 0000000..0d0ba78
--- /dev/null
+++ b/app/View/top/contact_confirm.ctp
@@ -0,0 +1,31 @@
+<header>
+<div class="container">
+<div class="row">
+<div class="col-lg-12">
+<div class="intro-text">
+<span class="name">お問い合わせ</span>
+</div>
+</div>
+</div>
+</div>
+</header>
+<div class="container">
+	<div>
+		<label>お名前</label>
+		<p><?php echo $contact['ContactValidate']['name'];?></p>
+	</div>
+	<div>
+		<label>Eメールアドレス</label>
+		<p><?php echo $contact['ContactValidate']['mail'];?></p>
+	</div>
+	<div>
+		<label>問い合わせ内容</label>
+		<p><?php echo $contact['ContactValidate']['comment'];?></p>
+	</div>
+	<div>
+		<a href="javascript:history.back();" class="btn btn-danger">戻る</a>
+		<a href="/top/contact_complete" class="btn btn-info">送信する</a>
+	</div>
+</div>
+
+<?php echo $this->element('footer');?>
