pictcode / app / Controller / TopController.php @ 304d523f
履歴 | 表示 | アノテート | ダウンロード (4.646 KB)
1 | 3bf0e002 | admin | <?php
|
---|---|---|---|
2 | /**
|
||
3 | * Static content controller.
|
||
4 | *
|
||
5 | * This file will render views from views/pages/
|
||
6 | *
|
||
7 | * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||
8 | * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
9 | *
|
||
10 | * Licensed under The MIT License
|
||
11 | * For full copyright and license information, please see the LICENSE.txt
|
||
12 | * Redistributions of files must retain the above copyright notice.
|
||
13 | *
|
||
14 | * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
15 | * @link http://cakephp.org CakePHP(tm) Project
|
||
16 | * @package app.Controller
|
||
17 | * @since CakePHP(tm) v 0.2.9
|
||
18 | * @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||
19 | */
|
||
20 | |||
21 | App::uses('AppController', 'Controller'); |
||
22 | 33ddd711 | admin | App::uses('CakeEmail', 'Network/Email'); |
23 | 3bf0e002 | admin | |
24 | /**
|
||
25 | * Static content controller
|
||
26 | *
|
||
27 | * Override this controller by placing a copy in controllers directory of an application
|
||
28 | *
|
||
29 | * @package app.Controller
|
||
30 | * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
|
||
31 | */
|
||
32 | class TopController extends AppController { |
||
33 | |||
34 | /**
|
||
35 | * This controller does not use a model
|
||
36 | *
|
||
37 | * @var array
|
||
38 | */
|
||
39 | var $name = 'top'; |
||
40 | b3a58ce1 | hasse | public $uses = array('ContactValidate','Zipcode'); |
41 | 1711ffed | shiwa | public $layout = 'procedure'; |
42 | 3bf0e002 | admin | |
43 | 5ec4ad9d | admin | function beforeFilter(){ |
44 | $this->Auth->allow(); |
||
45 | } |
||
46 | 3bf0e002 | admin | /**
|
47 | * index
|
||
48 | */
|
||
49 | public function index() { |
||
50 | 304d523f | hasse | if($this->Auth->user('status')==1){ |
51 | 787484d2 | hasse | $this->redirect('/users/login_top'); |
52 | } |
||
53 | 3bf0e002 | admin | } |
54 | c69e6898 | admin | /**
|
55 | * privacy_policy
|
||
56 | */
|
||
57 | 1711ffed | shiwa | public function privacy() { |
58 | c69e6898 | admin | } |
59 | /**
|
||
60 | 1711ffed | shiwa | * terms
|
61 | c69e6898 | admin | */
|
62 | 1711ffed | shiwa | public function terms() { |
63 | c69e6898 | admin | } |
64 | /**
|
||
65 | 1711ffed | shiwa | * about us
|
66 | c69e6898 | admin | */
|
67 | 1711ffed | shiwa | public function aboutus() { |
68 | c69e6898 | admin | } |
69 | /**
|
||
70 | * company
|
||
71 | */
|
||
72 | public function company() { |
||
73 | } |
||
74 | /**
|
||
75 | b3a58ce1 | hasse | * mypage
|
76 | */
|
||
77 | public function mypage() { |
||
78 | } |
||
79 | /**
|
||
80 | * howto
|
||
81 | */
|
||
82 | public function howto() { |
||
83 | } |
||
84 | /**
|
||
85 | 2df93201 | shiwa | * Withdrawal (Check)
|
86 | 001918d1 | shiwa | */
|
87 | public function withdraw_check() { |
||
88 | } |
||
89 | /**
|
||
90 | 2df93201 | shiwa | * Withdrawal (Complete)
|
91 | 001918d1 | shiwa | */
|
92 | public function withdraw_comp() { |
||
93 | } |
||
94 | /**
|
||
95 | 2df93201 | shiwa | * Access Error
|
96 | */
|
||
97 | public function error() { |
||
98 | } |
||
99 | /**
|
||
100 | * Address Error
|
||
101 | */
|
||
102 | 05c0cc17 | shiwa | public function error404() { |
103 | 2df93201 | shiwa | } |
104 | /**
|
||
105 | c69e6898 | admin | * contact
|
106 | */
|
||
107 | public function contact() { |
||
108 | 33ddd711 | admin | if($this->request->is('post') || $this->request->is('put')){ |
109 | $this->ContactValidate->set($this->request->data); |
||
110 | if($this->ContactValidate->validates()){ |
||
111 | $this->Session->write('contact',$this->request->data); |
||
112 | $this->redirect(array('action'=>'contact_confirm')); |
||
113 | }else{
|
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | /**
|
||
118 | * contact_confirm
|
||
119 | */
|
||
120 | public function contact_confirm() { |
||
121 | if($this->Session->read('contact')){ |
||
122 | $this->set('contact',$this->Session->read('contact')); |
||
123 | }else{
|
||
124 | $this->redirect(array('action'=>'contact')); |
||
125 | } |
||
126 | } |
||
127 | /**
|
||
128 | * contact_complete
|
||
129 | */
|
||
130 | public function contact_complete() { |
||
131 | 0a142321 | hasse | |
132 | $postcode=null; |
||
133 | $address=null; |
||
134 | $tel=null; |
||
135 | 33ddd711 | admin | $this->set('contact',$this->Session->read('contact')); |
136 | $name = $this->Session->read('contact.ContactValidate.name'); |
||
137 | b3a58ce1 | hasse | $mail = $this->Session->read('contact.ContactValidate.email'); |
138 | 33ddd711 | admin | $comment = $this->Session->read('contact.ContactValidate.comment'); |
139 | 0a142321 | hasse | if($this->Session->read('contact.ContactValidate.postcode')!= null){ |
140 | $postcode = $this->Session->read('contact.ContactValidate.postcode'); |
||
141 | } |
||
142 | if(($this->Session->read('contact.ContactValidate.prefecture'))!= null||($this->Session->read('contact.ContactValidate.address')!= null)){ |
||
143 | $address = $this->Session->read('contact.ContactValidate.prefecture').$this->Session->read('contact.ContactValidate.address'); |
||
144 | } |
||
145 | if($this->Session->read('contact.ContactValidate.tel')!= null){ |
||
146 | $tel = $this->Session->read('contact.ContactValidate.tel'); |
||
147 | } |
||
148 | 33ddd711 | admin | $Email = new CakeEmail(); |
149 | $Email->charset('ISO-2022-JP'); |
||
150 | $Email->emailFormat('text'); |
||
151 | $Email->template('user_contact'); |
||
152 | 0a142321 | hasse | $Email->viewVars(array('name'=>$name,'comment'=>$comment,'mail'=>$mail,'postcode'=>$postcode,'address'=>$address,'tel'=>$tel)); |
153 | 8fa10255 | hasse | $Email->from( MAIL_FROM ); |
154 | b3a58ce1 | hasse | $Email->to($mail); |
155 | 16e57cae | hasse | $Email->subject('【PictCode】お問い合わせいただき、ありがとうございます。'); |
156 | 33ddd711 | admin | $Email->send();
|
157 | c69e6898 | admin | } |
158 | b3a58ce1 | hasse | |
159 | |||
160 | /**
|
||
161 | *郵便番号から住所を自動入力する*
|
||
162 | *
|
||
163 | * View/add.ctp
|
||
164 | */
|
||
165 | public function zipsearch() { |
||
166 | App::import('Model','ConnectionManager'); |
||
167 | $db =ConnectionManager::getDataSource('default'); |
||
168 | |||
169 | //Users/zipsearch.ctpを自動で見に行くのを防止
|
||
170 | $this->autoRender = false; |
||
171 | |||
172 | //リクエストがajaxメソッドで送られてきた場合
|
||
173 | if($this->request->is('ajax')) { |
||
174 | |||
175 | //formのパラメータ取得
|
||
176 | $post = $this->request->data['ContactValidate']['postcode']; |
||
177 | 304d523f | hasse | if(mb_strlen($post)>2){ |
178 | $result = $db->query('select * from zipcodes where postcode like "'.$post.'%" limit 1'); |
||
179 | |||
180 | // データをjsonに変換して出力
|
||
181 | echo json_encode($result); |
||
182 | } |
||
183 | b3a58ce1 | hasse | |
184 | } |
||
185 | } |
||
186 | |||
187 | 3bf0e002 | admin | } |