リビジョン 33ddd711

差分を見る:

app/Controller/AppController.php
40 40

  
41 41
	public $components = array(
42 42
		'DebugKit.Toolbar',
43
		'Session',
43 44
		/*
44 45
		'Auth' => array(
45 46
			'flash' => array(
app/Controller/TopController.php
19 19
 */
20 20

  
21 21
App::uses('AppController', 'Controller');
22
App::uses('CakeEmail', 'Network/Email');
22 23

  
23 24
/**
24 25
 * Static content controller
......
36 37
 * @var array
37 38
 */
38 39
	var $name = 'top';
39
	public $uses = array();
40
	public $uses = array('ContactValidate');
40 41
	public $layout = 'top';
41 42

  
42 43
/**
......
68 69
 * contact
69 70
 */
70 71
	public function contact() {
72
		if($this->request->is('post') || $this->request->is('put')){
73
			$this->ContactValidate->set($this->request->data);
74
			if($this->ContactValidate->validates()){
75
				$this->Session->write('contact',$this->request->data);
76
				$this->redirect(array('action'=>'contact_confirm'));
77
			}else{
78
			}
79
		}
80
	}
81
/**
82
 * contact_confirm
83
 */
84
	public function contact_confirm() {
85
		if($this->Session->read('contact')){
86
			$this->set('contact',$this->Session->read('contact'));
87
		}else{
88
			$this->redirect(array('action'=>'contact'));
89
		}
90
	}
91
/**
92
 * contact_complete
93
 */
94
	public function contact_complete() {
95
		$this->set('contact',$this->Session->read('contact'));
96
		$name = $this->Session->read('contact.ContactValidate.name');
97
		$mail = $this->Session->read('contact.ContactValidate.mail');
98
		$comment = $this->Session->read('contact.ContactValidate.comment');
99
		$Email = new CakeEmail();
100
		$Email->charset('ISO-2022-JP');
101
		$Email->emailFormat('text');
102
		$Email->template('user_contact');
103
		$Email->viewVars(array('name'=>$name,'comment'=>$comment));
104
		$Email->from($mail);
105
		$Email->to('yano@i-hearts.jp');
106
		$Email->subject('[PICT CODE]問い合わせ');
107
		$Email->send();
71 108
	}
72 109
}
app/Model/ContactValidate.php
1
<?php
2
App::uses('AppModel', 'Model');
3
/**
4
 * ContactValidate Model
5
 *
6
 */
7
class ContactValidate extends AppModel {
8

  
9
	public $useTable = false;
10
	var $name = 'ContactValidate';
11

  
12
	public $_schema = array(
13
		'name' => array(
14
			'type' => 'string',
15
			'length' => 128,
16
		),
17
		'mail' => array(
18
			'type' => 'string',
19
			'length' => 255,
20
		),
21
		'comment' => array(
22
			'type' => 'string',
23
			'length' => 255,
24
		),
25
	);
26

  
27
/**
28
 * Validation rules
29
 * 
30
 * @var array
31
 */
32
	public $validate = array(
33
		'name' => array(
34
			'notblank' => array(
35
				'rule' => array('notBlank'),
36
				'message' => '入力されていません',
37
			),
38
		),
39
		'mail' => array(
40
			'notblank' => array(
41
				'rule' => array('notBlank'),
42
				'message' => '入力されていません',
43
			),
44
			'isEmail' => array(
45
				'rule' => 'Email',
46
				'message' => '入力形式が正しくありません',
47
			),
48
		),
49
		'comment' => array(
50
			'notblank' => array(
51
				'rule' => array('notblank'),
52
				'message' => '入力されていません',
53
			),
54
		),
55
	);
56
}
app/View/Emails/text/user_contact.ctp
1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2
このメールは、PICT CODE から配信されています
3
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4

  
5
以下の内容で、お客様よりお問い合わせがありました。
6

  
7
お名前:<?php echo $name;?>
8

  
9
お問い合わせ内容:
10

  
11
<?php echo $comment;?>
12

  
13
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
14
PICT CODE カスタマーサポートセンター
15
メールでのお問い合わせ: info@itkids.com
16
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
app/View/Layouts/Emails/text/default.ctp
16 16
?>
17 17
<?php echo $this->fetch('content'); ?>
18 18

  
19
This email was sent using the CakePHP Framework, http://cakephp.org.
app/View/top/contact.ctp
9 9
</div>
10 10
</div>
11 11
</header>
12
<div class="contact form">
13
<?php echo $this->Form->create('ContactValidate',array(
14
	'inputDefaults' => array(
15
		'div' => 'form-group',
16
		'wrapInput' => false,
17
		'class' => 'form-control'
18
	),
19
	'class' => 'well')); ?>
20
<fieldset>
21
	<legend><?php echo __('お問い合わせ'); ?></legend>
22
<?php
23
	echo $this->Form->input('name',array('label'=>'お名前'));
24
	echo $this->Form->input('mail',array('label'=>'メールアドレス'));
25
	echo $this->Form->input('comment',array('type'=>'textarea','label'=>'問い合わせ内容'));
26
?>
27
<?php echo $this->Form->submit('送信する',array('class'=>'btn btn-info')); ?>
28
<?php echo $this->Form->end(); ?>
29
</div>
30

  
12 31
<?php echo $this->element('footer');?>
app/View/top/contact_complete.ctp
1
<header>
2
<div class="container">
3
<div class="row">
4
<div class="col-lg-12">
5
<div class="intro-text">
6
<span class="name">お問い合わせ</span>
7
</div>
8
</div>
9
</div>
10
</div>
11
</header>
12
<div class="contact form">
13
<p>送信しました</p>
14
</div>
15

  
16
<?php echo $this->element('footer');?>
app/View/top/contact_confirm.ctp
1
<header>
2
<div class="container">
3
<div class="row">
4
<div class="col-lg-12">
5
<div class="intro-text">
6
<span class="name">お問い合わせ</span>
7
</div>
8
</div>
9
</div>
10
</div>
11
</header>
12
<div class="container">
13
	<div>
14
		<label>お名前</label>
15
		<p><?php echo $contact['ContactValidate']['name'];?></p>
16
	</div>
17
	<div>
18
		<label>Eメールアドレス</label>
19
		<p><?php echo $contact['ContactValidate']['mail'];?></p>
20
	</div>
21
	<div>
22
		<label>問い合わせ内容</label>
23
		<p><?php echo $contact['ContactValidate']['comment'];?></p>
24
	</div>
25
	<div>
26
		<a href="javascript:history.back();" class="btn btn-danger">戻る</a>
27
		<a href="/top/contact_complete" class="btn btn-info">送信する</a>
28
	</div>
29
</div>
30

  
31
<?php echo $this->element('footer');?>

他の形式にエクスポート: Unified diff