function m_index()
 {
     $this->pageTitle = "メールマガジンお申し込み ";
     $default = $this->MailMagazine->create();
     //値セット
     if (!empty($this->data)) {
         $this->data['MailMagazine']['birthday'] = $this->data['MailMagazine']['birth01'] . '-' . $this->data['MailMagazine']['birth02'] . '-' . $this->data['MailMagazine']['birth03'];
         $this->data['MailMagazine']['no'] = 3;
         $this->data['MailMagazine']['mail_status'] = 1;
         $this->data['MailMagazine']['type'] = numType(env('HTTP_USER_AGENT'));
         $this->data['MailMagazine']['created'] = date("Y/m/d H:i:s");
         if (empty($this->data['MailMagazine']['sei']) || empty($this->data['MailMagazine']['mei'])) {
             $this->data['MailMagazine']['name'] = '';
         } else {
             $this->data['MailMagazine']['name'] = $this->data['MailMagazine']['sei'] . ' ' . $this->data['MailMagazine']['mei'];
         }
         if (empty($this->data['MailMagazine']['sei_furigana']) || empty($this->data['MailMagazine']['mei_furigana'])) {
             $this->data['MailMagazine']['furigana'] = '';
         } else {
             $this->data['MailMagazine']['furigana'] = $this->data['MailMagazine']['sei_furigana'] . ' ' . $this->data['MailMagazine']['mei_furigana'];
         }
     }
     $this->MailMagazine->set($this->data);
     //バリデート
     if (!empty($this->data)) {
         if (empty($this->data['MailMagazine']['sei']) || empty($this->data['MailMagazine']['mei'])) {
             $this->MailMagazine->invalidate('name', 'お名前は必須項目です。');
         }
         if (empty($this->data['MailMagazine']['sei_furigana']) || empty($this->data['MailMagazine']['mei_furigana'])) {
             $this->MailMagazine->invalidate('furigana', 'ふりがなは必須項目です。');
         }
     }
     if (!empty($this->data) && $this->MailMagazine->validates() && (empty($this->params['form']['submit_back']) && empty($this->params['form']['submit_back_x']) && empty($this->params['form']['submit_back_y"']))) {
         if (isset($this->data['MailMagazine']['conf']) && $this->MailMagazine->save($this->data)) {
             mb_language("japanese");
             $mail =& new Qdmail();
             $mail->kana(true);
             $mail->error_display = false;
             $mail->to('from@example.com', '');
             $mail->subject('メールマガジン申し込みがありました。');
             $mail->text($this->__setBodyAdmin($this->data['MailMagazine']));
             $mail->from('from@example.com', '');
             if (!$mail->send()) {
                 die("管理者にメールが送信できませんでした。" . $mail->errorRender());
             }
             $mail =& new Qdmail();
             $mail->kana(true);
             $mail->error_display = false;
             $mail->to($this->data['MailMagazine']['mail'], $this->data['MailMagazine']['name']);
             $mail->subject('メールマガジン申し込みを受付いたしました。');
             $mail->text($this->__setBodyUser($this->data['MailMagazine']));
             $mail->from('from@example.com', '');
             if (!$mail->send()) {
                 die("ユーザーにメールが送信できませんでした。" . $mail->errorRender());
             }
             $this->render('ending');
         } else {
             $this->set('mail_magazineData', h($this->data));
             $this->render('confirm');
         }
     }
 }
 function m_index()
 {
     if (empty($this->data['Experience']['reg_num'])) {
         $this->Experience->setValidation('not_reg_num');
     }
     $this->pageTitle = "体験入学お申し込み ";
     $default = $this->Experience->create();
     //値セット
     if (!empty($this->data)) {
         $this->data['Experience']['mail_status'] = 1;
         $this->data['Experience']['birthday'] = $this->data['Experience']['birth01'] . '-' . $this->data['Experience']['birth02'] . '-' . $this->data['Experience']['birth03'];
         $this->data['Experience']['no'] = 2;
         $this->data['Experience']['type'] = numType(env('HTTP_USER_AGENT'));
         $this->data['Experience']['created'] = date("Y/m/d H:i:s");
         if (empty($this->data['Experience']['sei']) || empty($this->data['Experience']['mei'])) {
             $this->data['Experience']['name'] = '';
         } else {
             $this->data['Experience']['name'] = $this->data['Experience']['sei'] . ' ' . $this->data['Experience']['mei'];
         }
         if (empty($this->data['Experience']['sei_furigana']) || empty($this->data['Experience']['mei_furigana'])) {
             $this->data['Experience']['furigana'] = '';
         } else {
             $this->data['Experience']['furigana'] = $this->data['Experience']['sei_furigana'] . ' ' . $this->data['Experience']['mei_furigana'];
         }
     }
     $this->Experience->set($this->data);
     //バリデート
     if (!empty($this->data)) {
         //参加希望日チェック
         if (empty($this->data['Experience']['schedule_id'])) {
             $this->Experience->invalidate('schedule_id', '参加希望日を選択してください。');
         }
         //オープンキャンパス入力チェック
         if (isset($this->data['Experience']['schedule_id']) && !empty($this->data['Experience']['schedule_id'])) {
             $scheduleData = $this->Schedule->find('first', array('conditions' => array('Schedule.id' => $this->data['Experience']['schedule_id']), 'recursive' => 3));
             //送迎バス入力チェック
             if ($scheduleData['Schedule']['bus'] != 5) {
                 if (!empty($this->data['Experience']['schedule_id']) && empty($this->data['Experience']['bus_' . $this->data['Experience']['schedule_id']])) {
                     $this->Experience->invalidate("bus", '送迎バス乗車地点を選択してください。');
                 } elseif (!$this->Experience->checkBusSelect($this->data['Experience']['bus_' . $this->data['Experience']['schedule_id']])) {
                     $this->Experience->invalidate("bus", '送迎バス乗車地点を正しく選択してください。');
                 }
             }
             $error = true;
             foreach ($scheduleData['Event'] as $k => $v) {
                 if (!empty($this->data['Experience']['event_' . $v['id']]) || !empty($this->data['Experience']['event_' . $v['id'] . '_child'])) {
                     $error = false;
                     $events[$v['id']][] = $v['name'];
                     $open_campuses = $this->data['Experience']['event_' . $v['id'] . '_child'];
                     foreach ($v['OpenCampus'] as $key => $campus) {
                         if (strlen(array_search($campus['id'], $open_campuses)) > 0) {
                             $events[$v['id']][] = $campus['name'];
                         }
                     }
                 }
             }
             if (!empty($scheduleData['Event']) && $error) {
                 $this->Experience->invalidate("event", '体験授業を選択してください。');
             }
         }
         if (empty($this->data['Experience']['sei']) || empty($this->data['Experience']['mei'])) {
             $this->Experience->invalidate('name', 'お名前は必須項目です。');
         }
         if (empty($this->data['Experience']['sei_furigana']) || empty($this->data['Experience']['mei_furigana'])) {
             $this->Experience->invalidate('furigana', 'ふりがなは必須項目です。');
         }
     }
     $this->Experience->set($this->data);
     if (!empty($this->data) && $this->Experience->validates() && (empty($this->params['form']['submit_back']) && empty($this->params['form']['submit_back_x']) && empty($this->params['form']['submit_back_y"']))) {
         $this->set('scheduleData', h($scheduleData));
         $this->data['Experience']['bus'] = $this->data['Experience']['bus_' . $this->data['Experience']['schedule_id']];
         $this->data['Experience']['event'] = serialize($events);
         $this->set('events', $events);
         if (isset($this->data['Experience']['conf']) && $this->Experience->save($this->data)) {
             mb_language("japanese");
             $mail =& new Qdmail();
             $mail->kana(true);
             $mail->error_display = false;
             $mail->to('from@example.com', '');
             $mail->subject('から体験入学申し込みがありました。');
             $mail->text($this->__setBodyAdmin($this->data['Experience'], $scheduleData));
             $mail->from('from@example.com', '');
             if (!$mail->send()) {
                 die("管理者にメールが送信できませんでした。" . $mail->errorRender());
             }
             $mail =& new Qdmail();
             $mail->kana(true);
             $mail->error_display = false;
             $mail->to($this->data['Experience']['mail'], $this->data['Experience']['name']);
             $mail->subject('体験入学の参加申込を受付いたしました。');
             $mail->text($this->__setBodyUser($this->data['Experience']));
             $mail->from('from@example.com', '');
             if (!$mail->send()) {
                 die("ユーザーにメールが送信できませんでした。" . $mail->errorRender());
             }
             $this->render('ending');
         } else {
             $this->set('experienceData', h($this->data));
             $this->render('confirm');
         }
         unset($scheduleData);
     } else {
         $schedulesData = $this->Schedule->find('all', array('conditions' => array('Schedule.status' => '1'), 'recursive' => 3));
         $this->set('schedulesData', h($schedulesData));
         unset($schedulesData);
     }
 }
 function m_index()
 {
     $this->pageTitle = "資料請求 ";
     $default = $this->Document->create();
     //値セット
     if (!empty($this->data)) {
         $this->data['Document']['mail_status'] = 1;
         $this->data['Document']['birthday'] = $this->data['Document']['birth01'] . '-' . $this->data['Document']['birth02'] . '-' . $this->data['Document']['birth03'];
         $this->data['Document']['no'] = 1;
         $this->data['Document']['type'] = numType(env('HTTP_USER_AGENT'));
         $this->data['Document']['created'] = date("Y/m/d H:i:s");
         if (empty($this->data['Document']['sei']) || empty($this->data['Document']['mei'])) {
             $this->data['Document']['name'] = '';
         } else {
             $this->data['Document']['name'] = $this->data['Document']['sei'] . ' ' . $this->data['Document']['mei'];
         }
         if (empty($this->data['Document']['sei_furigana']) || empty($this->data['Document']['mei_furigana'])) {
             $this->data['Document']['furigana'] = '';
         } else {
             $this->data['Document']['furigana'] = $this->data['Document']['sei_furigana'] . ' ' . $this->data['Document']['mei_furigana'];
         }
     }
     $this->Document->set($this->data);
     //バリデート
     if (!empty($this->data)) {
         if (empty($this->data['Document']['sei']) || empty($this->data['Document']['mei'])) {
             $this->Document->invalidate('name', 'お名前は必須項目です。');
         }
         if (empty($this->data['Document']['sei_furigana']) || empty($this->data['Document']['mei_furigana'])) {
             $this->Document->invalidate('furigana', 'ふりがなは必須項目です。');
         }
     }
     if (!empty($this->data) && $this->Document->validates() && (empty($this->params['form']['submit_back']) && empty($this->params['form']['submit_back_x']) && empty($this->params['form']['submit_back_y"']))) {
         if (isset($this->data['Document']['conf']) && $this->Document->save($this->data)) {
             mb_language("japanese");
             $mail =& new Qdmail();
             $mail->kana(true);
             $mail->error_display = false;
             $mail->to('from@example.com', '');
             $mail->subject('資料請求がありました。');
             $mail->text($this->__setBodyAdmin($this->data['Document']));
             $mail->from('from@example.com', '');
             if (!$mail->send()) {
                 die("管理者にメールが送信できませんでした。" . $mail->errorRender());
             }
             if (!empty($this->data['Document']['other'])) {
                 foreach ($this->data['Document']['other'] as $key => $name) {
                     $mail =& new Qdmail();
                     $mail->kana(true);
                     $mail->error_display = false;
                     list($to, $cc, $bcc) = schoolMailaddress($name);
                     $mail->to($to, $name);
                     if (!empty($cc)) {
                         $mail->cc($cc);
                     }
                     if (!empty($bcc)) {
                         $mail->bcc($bcc);
                     }
                     $mail->subject('資料請求がありました。');
                     $mail->text($this->__setBodyAdmin($this->data['Document']));
                     $mail->from('from@example.com', '');
                     if (!$mail->send()) {
                         die("管理者にメールが送信できませんでした。" . $mail->errorRender());
                     }
                 }
             }
             $mail =& new Qdmail();
             $mail->kana(true);
             $mail->error_display = false;
             $mail->to($this->data['Document']['mail'], $this->data['Document']['name']);
             $mail->subject('資料請求を受付いたしました。');
             $mail->text($this->__setBodyUser($this->data['Document']));
             $mail->from('from@example.com', '');
             if (!$mail->send()) {
                 die("ユーザーにメールが送信できませんでした。" . $mail->errorRender());
             }
             $this->render('ending');
         } else {
             $this->set('documentData', h($this->data));
             $this->render('confirm');
         }
     }
 }