<?php

require_once '../init.php';
require_once 'qdmail.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    validate_presence_of('email');
    validate_email_of('email');
    validate_presence_of('body');
    if (!(count($_ERROR) > 0)) {
        $body = fetch('inquiry.txt.php');
        qd_send_mail('text', MAIL_TO, 'コミュニケーション・ベースにお問い合わせが入りました', $body, MAIL_FROM);
        $_NOTICE = 'お問い合わせを承りました。';
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <title>お問い合わせ | コミュニケーション・ベース</title>
    <link rel="stylesheet" href="stylesheets/reset.css" type="text/css" />
    <link rel="stylesheet" href="stylesheets/base.css" type="text/css" />
    <script type="text/javascript" src="js/script.js"></script>
  </head>
  <body>
    <div id="header">
      <h1><a href="/">コミュニケーション・ベース</a></h1>
<? include 'menu.php' ?>
<?php

require_once '../init.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST' and params('submit') !== '戻る') {
    validate_presence_of('name');
    validate_presence_of('name_kana');
    validate_presence_of('email');
    validate_email_of('email');
    validate_presence_of('payment_method');
    $kindergarten_child = array('年少', '年中', '年長');
    $workshops_for_family = workshops_for_family();
    $individual_entriable = array('親子お絵かきワークショップ', 'ものがたりをつくろう');
    // キッズ受講者1、2について
    foreach (array(1, 2) as $i) {
        // 幼稚園児は
        if (in_array(params("kids_{$i}_class"), $kindergarten_child)) {
            // 午前ワークショップの選択禁止
            if (params("kids_{$i}_workshop_am")) {
                $_ERROR[] = "年少・年中・年長のキッズ受講者{$i}は午前のワークショップを受けることができません。";
            }
            // 親と同じ午後のワークショップ以外禁止
            if (params("kids_{$i}_workshop_pm") and params("kids_{$i}_workshop_pm") != params('workshop')) {
                $_ERROR[] = "キッズ受講者{$i}は親御様とご一緒のワークショップ以外に参加できません。";
            }
            // 小学生は
        } else {
            // 単独参加可能ワークショップ以外の場合は
            if (!in_array(params("kids_{$i}_workshop_pm"), $individual_entriable)) {
                // 親と同じ午後のワークショップ以外禁止
                if (params("kids_{$i}_workshop_pm") and params("kids_{$i}_workshop_pm") != params('workshop')) {
                    $_ERROR[] = "キッズ受講者{$i}は該当のワークショップでは親御様とご一緒でなければ参加できません。";