pictcode / app / Controller / TopController.php @ d932d503
履歴 | 表示 | アノテート | ダウンロード (3.973 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 | } | ||
| 51 | c69e6898 | admin | /**
 | 
| 52 |  * privacy_policy
 | ||
| 53 |  */
 | ||
| 54 | 1711ffed | shiwa | public function privacy() { | 
| 55 | c69e6898 | admin | } | 
| 56 | /**
 | ||
| 57 | 1711ffed | shiwa |  * terms
 | 
| 58 | c69e6898 | admin |  */
 | 
| 59 | 1711ffed | shiwa | public function terms() { | 
| 60 | c69e6898 | admin | } | 
| 61 | /**
 | ||
| 62 | 1711ffed | shiwa |  * about us
 | 
| 63 | c69e6898 | admin |  */
 | 
| 64 | 1711ffed | shiwa | public function aboutus() { | 
| 65 | c69e6898 | admin | } | 
| 66 | /**
 | ||
| 67 |  * company
 | ||
| 68 |  */
 | ||
| 69 | public function company() { | ||
| 70 | } | ||
| 71 | /**
 | ||
| 72 | b3a58ce1 | hasse |  *        mypage 
 | 
| 73 |  */
 | ||
| 74 | public function mypage() { | ||
| 75 | } | ||
| 76 | /**
 | ||
| 77 |  *        howto 
 | ||
| 78 |  */
 | ||
| 79 | public function howto() { | ||
| 80 | } | ||
| 81 | /**
 | ||
| 82 | 2df93201 | shiwa |  *        Withdrawal (Check)
 | 
| 83 | 001918d1 | shiwa |  */
 | 
| 84 | public function withdraw_check() { | ||
| 85 | } | ||
| 86 | /**
 | ||
| 87 | 2df93201 | shiwa |  *        Withdrawal (Complete) 
 | 
| 88 | 001918d1 | shiwa |  */
 | 
| 89 | public function withdraw_comp() { | ||
| 90 | } | ||
| 91 | /**
 | ||
| 92 | 2df93201 | shiwa |  *        Access Error 
 | 
| 93 |  */
 | ||
| 94 | public function error() { | ||
| 95 | } | ||
| 96 | /**
 | ||
| 97 |  *        Address Error
 | ||
| 98 |  */
 | ||
| 99 | 05c0cc17 | shiwa | public function error404() { | 
| 100 | 2df93201 | shiwa | } | 
| 101 | /**
 | ||
| 102 | c69e6898 | admin |  * contact
 | 
| 103 |  */
 | ||
| 104 | public function contact() { | ||
| 105 | 33ddd711 | admin | if($this->request->is('post') || $this->request->is('put')){ | 
| 106 | $this->ContactValidate->set($this->request->data); | ||
| 107 | if($this->ContactValidate->validates()){ | ||
| 108 | $this->Session->write('contact',$this->request->data); | ||
| 109 | $this->redirect(array('action'=>'contact_confirm')); | ||
| 110 |                         }else{
 | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
| 114 | /**
 | ||
| 115 |  * contact_confirm
 | ||
| 116 |  */
 | ||
| 117 | public function contact_confirm() { | ||
| 118 | if($this->Session->read('contact')){ | ||
| 119 | $this->set('contact',$this->Session->read('contact')); | ||
| 120 |                 }else{
 | ||
| 121 | $this->redirect(array('action'=>'contact')); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | /**
 | ||
| 125 |  * contact_complete
 | ||
| 126 |  */
 | ||
| 127 | public function contact_complete() { | ||
| 128 | $this->set('contact',$this->Session->read('contact')); | ||
| 129 | $name = $this->Session->read('contact.ContactValidate.name'); | ||
| 130 | b3a58ce1 | hasse | $mail = $this->Session->read('contact.ContactValidate.email'); | 
| 131 | 33ddd711 | admin | $comment = $this->Session->read('contact.ContactValidate.comment'); | 
| 132 | $Email = new CakeEmail(); | ||
| 133 | $Email->charset('ISO-2022-JP'); | ||
| 134 | $Email->emailFormat('text'); | ||
| 135 | $Email->template('user_contact'); | ||
| 136 | $Email->viewVars(array('name'=>$name,'comment'=>$comment)); | ||
| 137 | 8fa10255 | hasse | $Email->from( MAIL_FROM ); | 
| 138 | b3a58ce1 | hasse | $Email->to($mail); | 
| 139 | 16e57cae | hasse | $Email->subject('【PictCode】お問い合わせいただき、ありがとうございます。'); | 
| 140 | 33ddd711 | admin |                 $Email->send();
 | 
| 141 | c69e6898 | admin | } | 
| 142 | b3a58ce1 | hasse | |
| 143 | |||
| 144 | /**
 | ||
| 145 |  *郵便番号から住所を自動入力する* 
 | ||
| 146 |  *
 | ||
| 147 |  * View/add.ctp
 | ||
| 148 |  */
 | ||
| 149 | public function zipsearch() { | ||
| 150 | App::import('Model','ConnectionManager'); | ||
| 151 | $db =ConnectionManager::getDataSource('default'); | ||
| 152 | |||
| 153 |                 //Users/zipsearch.ctpを自動で見に行くのを防止
 | ||
| 154 | $this->autoRender = false; | ||
| 155 | |||
| 156 |                 //リクエストがajaxメソッドで送られてきた場合
 | ||
| 157 | if($this->request->is('ajax')) { | ||
| 158 | |||
| 159 |                     //formのパラメータ取得
 | ||
| 160 | $post = $this->request->data['ContactValidate']['postcode']; | ||
| 161 |                    // var_dump($post);
 | ||
| 162 |                    // exit;
 | ||
| 163 |                         // $options = array(
 | ||
| 164 |                         // 'conditions'=>array(
 | ||
| 165 |                         //         'postcode like' => $post.'%' ,
 | ||
| 166 |                         // )
 | ||
| 167 |                 // );
 | ||
| 168 | $result = $db->query('select * from zipcodes where postcode like "'.$post.'%" limit 1'); | ||
| 169 | |||
| 170 |                 // データをjsonに変換して出力
 | ||
| 171 | echo json_encode($result); | ||
| 172 | |||
| 173 | } | ||
| 174 | } | ||
| 175 | |||
| 176 | 3bf0e002 | admin | } |