<!-- -*- mode: html; tab-width: 4; coding: utf-8; -*- -->
<style type="text/css">
<!--
.column-name {
  width: 20%;
}
dl {
  margin: 0;
}
dt {
  margin: 0.8ex 0 0 0;
}
dd {
  margin: 0 0 0.2ex 4ex;
}
-->
</style>
<?php
if ($mode == 'input') {
	$op_type = 'add';
	$op_name = '新規追加';
	$op_confirm = 'confirm';
} else {  // $mode == 'editinput'
	$op_type = 'edit';
	$op_name = '編集';
	$op_confirm = 'editconfirm';
}

$this_script_name = $_SERVER['SCRIPT_NAME'];
if (isset($_REQUEST['page'])) {
	$this_page = $_REQUEST['page'];
} else {
	$this_page = '';
}
?>
<div class="wrap">
  <h2><?= $op_name ?> - 予約内容入力</h2>
<?php
if (count($nn4_event_last_err_msg) > 0) {
?>
  <div id="message" class="error-message"><p><?= nl2br(esc_html(implode("\n", $nn4_event_last_err_msg))) ?></p></div>
<?php
}
?>
  <form id="posts-filter" action="<?= $this_script_name ?>?page=<?= $this_page ?>" method="post">
	<input type="hidden" name="mode" value="<?= $op_confirm ?>" />
<?php
if ($op_type == 'edit') {
?>
	<input type="hidden" name="entry_post_id" value="<?= $entry_post_id ?>" />
<?php
}
?>
	<input type="hidden" name="chktoken" value="<?= $chktoken ?>" />
<?php
if ($op_type == 'edit') {
?>
	<div class="alignleft actions" style="margin-top: 20px">
	  予約編集機能は準備中です。
	</div>
<?
} else {
?>
	<div class="alignleft actions" style="margin-bottom: 20px">
	  <input type="submit" value="確認画面へ" class="button-primary" />
	</div>
<?php
}
?>
<?php
$alternate = '';
function get_alternate()
{
	global $alternate;

	$alternate = $alternate ? '' : ' alternate';
	return $alternate;
}
?>
	<table class="wp-list-table widefat fixed posts">
	  <thead>
		<tr>
		  <th id="name" class="manage-column column-name" style="" scope="col"><span>項目名</span></th>
		  <th id="value" class="manage-column column-value" style="" scope="col"><span>値</span></th>
		</tr>
	  </thead>
	  <tbody id="the-list">
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">イベント名</th>
		  <td class="post-name page-name column-name">No.<?= esc_html($nn4_event_info['ch_serial']) ?>　<a href="<?= get_permalink($nn4_event_info['ap_aux']['post_id']) ?>" target="_blank"><?= esc_html($nn4_event_info['name']) ?></a><input type="hidden" name="entry_event_id" value="<?= $entry_event_id ?>" /></td>
		</tr>
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">会場</th>
		  <td class="post-name page-name column-name"><?= esc_html($nn4_event_info['facility_name']) ?><?= nl2br(esc_html($nn4_event_info['venue_detail'])) ?></td>
		</tr>
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">お名前 <span style="font-size: 90%; color: #f00;">※必須</span></th>
		  <td class="post-name page-name column-name"><input type="text" name="entry_name" size="40" value="<?= esc_attr($entry_name) ?>" autocomplete="off" /></td>
		</tr><?php /*
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">メールアドレス<?php if ($user_requirements == 1) { ?> <span style="font-size: 90%; color: #f00;">※必須</span><?php } ?></th>
		  <td class="post-email page-email column-email"><input type="text" name="entry_email" size="20" value="<?= esc_attr($entry_email) ?>" autocomplete="off" /></td>
		</tr> */ ?>
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">電話番号<?php if ($user_requirements == 2) { ?> <span style="font-size: 90%; color: #f00;">※必須</span><?php } ?></th>
		  <td class="post-email page-email column-email"><input type="text" name="entry_tel" value="<?= esc_attr($entry_tel) ?>" autocomplete="off" size="20" ></td>
		</tr>
<?php
if (isset($nn4_event_info['participate_cond'])
    and $nn4_event_info['participate_cond'] != '') {
?>
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">参加条件確認 <span style="font-size: 90%; color: #f00;">※必須</span></th>
		  <td class="post-participant page-participant column-participant">
			<div><input type="checkbox" id="entry-participate-cond-ok" name="entry_participate_cond_ok" value="1"<?php if ($entry_participate_cond_ok == 1) { ?> checked<?php } ?> style="margin: 0 4px -1px 0; width: 16px; height: 16px;" autocomplete="off" /><label for="entry-participate-cond-ok">参加条件は：</label></div>
			  <div style="margin-left: 30px; font-weight: bold;"><label for="entry-participate-cond-ok"><?= nl2br(esc_html($nn4_event_info['participate_cond'])) ?></label></div>
			<div style="margin-left: 20px;"><label for="entry-participate-cond-ok">です。</label></div>
			<div style="font-size: 90%">※申込者に確認のうえ、チェックマークを入れてください。</div>
		  </td>
		</tr>
<?php
}
?>
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">参加人数 <span style="font-size: 90%; color: #f00;">※必須</span></th>
		  <td class="post-name page-name column-name"><?php
if (isset($nn4_event_info['date'])) {
	// 参加人数の単位
	if (isset($nn4_event_info['participant_unit']) && $nn4_event_info['participant_unit'] != '') {
		$participant_unit = $nn4_event_info['participant_unit'];
	} else {
		$participant_unit = '名';
	}
?>
			<dl><?php
	for ($i = 0; $i < count($nn4_event_info['date']); $i++) {
		for ($j = 0; $j < count($nn4_event_info['date'][$i]['time']); $j++) {
?>
			  <dt><?= nn4_dateformat_converter($nn4_event_info['date'][$i]['from'], 'Y年n月j日') ?>(<?= $nn4_arr_wday[nn4_dateformat_converter($nn4_event_info['date'][$i]['from'], 'w')] ?>)<?php
			if (isset($nn4_event_info['date'][$i]['time'][$j]['from'])) {
?> <?= esc_html($nn4_event_info['date'][$i]['time'][$j]['from']) ?>〜<?= esc_html($nn4_event_info['date'][$i]['time'][$j]['to']) ?><?php
			}
?></dt><?php
			for ($k = 0; $k < count($arr_target_name); $k++) {
?>
			  <dd><?= esc_html($arr_target_name[$k]); ?> <input type="text" name="entry_num_participant[<?= $i ?>][<?= $j ?>][<?= $k ?>]" size="5" placeholder="数値" style="text-align: right;" value="<?= esc_attr($entry_num_participant[$i][$j][$k]) ?>" autocomplete="off" /> <?= esc_html($participant_unit) ?><?php
				if (is_numeric($arr_remain[$k])) {
?> (残り <?= number_format($arr_remain[$k]) ?> <?= $participant_unit ?>)<?php
				}
?>
			  </dd><?php
			}
		}
	}
?>
			</dl><?php
	if (isset($remain_all) && is_numeric($remain_all)) {
?>
			残り <?= number_format($remain_all) ?> <?= $participant_unit ?><?php
	}
} else {
?><span style="font-weight: bold;">開催日時未定</span><?php
}
?>
		  </td>
		</tr>
<?php
if (isset($nn4_event_info['additional_question'])) {
	foreach ($nn4_event_info['additional_question'] as $additional_question) {
		if (preg_match('/^(.+)\((\d+)\)$/', $additional_question['data_type'], $matches)) {
			$data_type = $matches[1];
			$size = $matches[2];
		} else {
			$data_type = 'string';
			$size = 40;
		}
?>
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column"><?= esc_html($additional_question['title']) ?><?php
		if ($additional_question['flg_required']) {
?> <span style="font-size: 90%; color: #f00;">※必須</span><?php
		}
?></th>
		  <td class="post-note page-note column-note"><?= $additional_question['prefix'] ?> <?php
		if ($data_type == 'numeric') {
?><input type="text" name="entry_additional_question[<?= $additional_question['name'] ?>]" size="<?= $size ?>" value="<?= esc_attr($entry_additional_question[$additional_question['name']]) ?>" placeholder="数値" style="text-align: right;" /> <?= $additional_question['postfix'] ?><?php
		}
?>
		  </td>
		</tr>
<?php
	}
}
?>
		<tr class="post type-post status-draft format-standard hentry category-1<?= get_alternate() ?> iedit level-0">
		  <th class="manage-column">備考</th>
		  <td class="post-note page-note column-note"><textarea name="entry_note" cols="40" autocomplete="off" style="height: 200px; resize: none;"><?= esc_html($entry_note) ?></textarea></td>
		</tr>
	  </tbody>
	</table>
<?php
if ($op_type == 'edit') {
?>
	<div class="alignleft actions" style="margin-bottom: 20px">
	  予約編集機能は準備中です。
	</div>
<?
} else {
?>
	<div class="alignleft actions" style="margin-top: 20px">
	  <input type="submit" value="確認画面へ" class="button-primary" />
	</div>
<?php
}
?>
  </form>
</div>
