public function booking_page($booking_id) { $booking = $this->get_booking($booking_id); // データを読込んで編集データbookingタイプにする $this->booking = $this->array_merge_default($this->new_booking(), $booking); if ($booking) { $article = MTSSB_Article::get_the_article($this->booking['article_id']); $daytime = $this->booking['booking_time'] - $this->booking['booking_time'] % 86400; $datestr = date(__('F j, Y'), $daytime) . ' (' . __(date('D', $daytime)) . ')'; } // 予約条件パラメータのロード $count = $this->controls['count']; ?> <div class="wrap"> <div id="icon-edit" class="icon32"><br /></div> <h2><?php _e('Reservation Calendar > Day > Booking', $this->domain); ?> </h2> <?php if (!empty($booking)) { ?> <ul class="subsubsub"> <li><?php echo '<a href="?page=' . self::PAGE_NAME . "&year=" . date('Y', $daytime) . "&month=" . date('n', $daytime) . '&action=monthly">' . __('Reservation Calendar', $this->domain) . '</a>'; ?> | </li> <li><?php echo '<a href="?page=' . self::PAGE_NAME . "&dt={$daytime}\">" . __('Reservation Day', $this->domain) . '</a>'; ?> | </li> <li><?php echo '<a href="?page=' . MTS_Simple_Booking::PAGE_BOOKING . "&booking_id={$this->booking['booking_id']}&action=edit\">" . __('Edit') . '</a>'; ?> | </li> <li><?php echo sprintf("<a href=\"?page=%s&action=delete&booking_id=%d&nonce=%s\" onclick=\"return confirm('%s')\">%s</a>", self::PAGE_NAME, $this->booking['booking_id'], wp_create_nonce(self::PAGE_NAME . '_delete'), __('Do you really want to delete this booking?', $this->domain), __('Delete')); ?> </li> </ul> <div class="clear"> </div> <h3><?php echo $datestr; ?> </h3> <table class="form-table booking-detail"> <tr> <th><?php _e('Article Name', $this->domain); ?> </th> <td><?php echo $article['name']; ?> </td> </tr> <tr> <th><?php _e('Date Time', $this->domain); ?> </th> <td><?php echo $datestr . date(' H:i', $this->booking['booking_time']); ?> </td> </tr> <tr> <th><?php _e('Number', $this->domain); ?> </th> <td><?php echo $this->booking['number']; ?> </td> </tr> <tr> <th><?php _e('Name'); ?> </th> <td><?php echo empty($this->booking['client']['name']) ? __('No Name', $this->domain) : esc_html($this->booking['client']['name']); ?> </td> </tr> <tr> <th><?php _e('Furigana', $this->domain); ?> </th> <td><?php echo esc_html($this->booking['client']['furigana']); ?> </td> </tr> <tr> <th><?php _e('E-Mail', $this->domain); ?> </th> <td><?php echo esc_html($this->booking['client']['email']); ?> </td> </tr> <tr> <th><?php _e('Postcode', $this->domain); ?> </th> <td><?php echo esc_html($this->booking['client']['postcode']); ?> </td> </tr> <tr> <th><?php _e('Address', $this->domain); ?> </th> <td><?php echo esc_html($this->booking['client']['address1']) . '<br />' . esc_html($this->booking['client']['address2']); ?> </td> </tr> <tr> <th><?php _e('TEL', $this->domain); ?> </th> <td><?php echo esc_html($this->booking['client']['tel']); ?> </td> </tr> <tr> <th><?php _e('Number', $this->domain); ?> </th> <td><?php foreach ($count as $key => $val) { echo '<div class="number-person">' . __(ucwords($key), $this->domain) . '<br />' . $this->booking['client'][$key] . '</div>'; } ?> </td> </td> </tr> <tr> <th><?php _e('Message', $this->domain); ?> </th> <td><?php echo nl2br(esc_html($this->booking['note'])); ?> </td> </tr> <tr> <th><?php _e('Created', $this->domain); ?> </th> <td><?php echo $booking['created']; ?> </td> </tr> </table> <?php } else { ?> <?php _e('No Data', $this->domain); } ?> </div> <?php }
/** * 予約キャンセル実行のお知らせメール * */ public function remove_mail() { global $mts_simple_booking; $booking = $mts_simple_booking->oSubscription->getBooking(); $article = MTSSB_Article::get_the_article($booking['article_id']); $content = "予約キャンセルが実行されました。\n\n" . "[キャンセル日時] " . date_i18n('Y-m-d H:i:s') . "\n" . "[予約ID] {$booking['booking_id']}\n" . "[予約] {$booking['client']['name']} 様\n" . date_i18n('Y年n月j日 H:i ', $booking['booking_time']) . $article['name'] . "\n"; $subject = "【予約キャンセル】"; $subject = apply_filters('mtssb_mail_own_subject', $subject, 'cancel'); $send_to = $this->shop['email']; $mail_ret = true; if (!empty($send_to)) { $mail_ret = wp_mail($send_to, $subject, $content, $this->fromshop); } return $mail_ret; }
/** * 予約データの表示 * */ protected function _out_booking($booking) { // 表示ページのURL $page_url = get_permalink(); $this->booking = $booking; $client = $booking['client']; $this->article = MTSSB_Article::get_the_article($booking['article_id']); // キャンセルが有効か確認する $canceltime = $this->_check_cancel_limit(); ob_start(); ?> <div class="content-form"> <table> <tr> <th class="subscription-header"><form method="post" action="<?php echo $page_url; ?> "> <span class="subscription-title"> <?php echo apply_filters('booking_form_date', date('Y年n月j日 H:i', $booking['booking_time']), $booking['booking_time']); echo " {$this->article['name']}"; ?> </span> <?php if ($canceltime != 0) { echo '<span class="subscription-cancel">'; if (0 < $canceltime) { echo "<button id=\"subscription-cancel-button\" type=\"submit\" " . "onclick=\"return confirm('予約をキャンセルします。よろしいですか?')\">キャンセル</button>"; } else { echo apply_filters('subscription-cancel-limit-message', 'キャンセル受付終了'); } echo '</span>'; } ?> <input type="hidden" name="booking_id" value="<?php echo $booking['booking_id']; ?> " /> <input type="hidden" name="client_email" value="<?php echo $client['email']; ?> " /> <input type="hidden" name="nonce" value="<?php echo wp_create_nonce("{$this->domain}_" . self::PAGE_NAME); ?> " /> <input type="hidden" name="action" value="send" /> </form></th> </tr> <tr> <td><table> <tr> <th><?php echo apply_filters('booking_form_people_number', '予約人数', 'subscription'); ?> </th> <td> <?php foreach ($this->controls['count'] as $key => $val) { ?> <div class="input-number"<?php echo $val != 1 ? ' style="display:none"' : ''; ?> ><?php $title = apply_filters('booking_form_count_label', __(ucwords($key), $this->domain), 'subscription'); if ($title != '') { echo "{$title} "; } echo esc_html($client[$key]); echo apply_filters('booking_form_count_note', '', $key); ?> </div><?php } ?> </td> </tr> <?php // オプション先方指定の表示 if ($this->article['addition']->isOption() && $this->article['addition']->position == 0) { $this->_out_booking_option($booking); } // 連絡先の表示 $this->_out_booking_client($client); // オプション後方指定の表示 if ($this->article['addition']->isOption() && $this->article['addition']->position == 1) { $this->_out_booking_option($booking); } ?> <tr> <td colspan="2"><?php echo apply_filters('booking_form_message_title', 'ご連絡事項'); ?> </td> </tr> <tr> <th><?php echo apply_filters('booking_form_message_title_sub', '内容'); ?> </th> <td> <?php echo nl2br(esc_html($booking['note'])); ?> </td> </tr> <?php // 請求明細の表示 if ($this->charge['charge_list'] == 1) { $this->_out_booking_bill($this->article['addition']); } ?> </table></td> </tr> </table> </div> <?php return ob_get_clean(); }
/** * 予約リストからAJAXで予約確認処理実行 * */ protected function _confirm_booking($booking_id = 0) { // 予約データを取得する $booking = $this->get_booking($booking_id); if (!$booking) { return array('result' => false, 'message' => "{$booking_id} doesn't exist."); } $this->setBooking($booking); // 予約品目の取得 $article = MTSSB_Article::get_the_article($booking['article_id']); return array('result' => true, 'booking_id' => $booking_id, 'content' => $this->_out_booking($booking, $article), 'mailform' => $this->_out_mailform($booking, $article), 'tickimg' => '<img src="' . plugins_url('image/system-tick.png', __FILE__) . '">'); }
/** * 予約完了エレメントの出力 * */ protected function _out_completed($content) { $tracking = ''; // nonceコードと予約IDが渡されたか確認する if (isset($_GET['nonce']) && isset($_GET['bid'])) { // 予約データと予約品目を取得する $booking = $this->get_booking(intval($_GET['bid'])); if (isset($booking['article_id'])) { $article = MTSSB_Article::get_the_article($booking['article_id']); } // 有効でトラッキングが指定されていれば出力コードを生成する if (isset($article['addition']->tracking)) { if (wp_verify_nonce($_GET['nonce'], 'affiliate' . $booking['booking_id'])) { // 予約IDを生成する $reserve_id = apply_filters('mtssb_thanks_reserve_id', date('ymd', $booking['booking_time']) . substr("00{$booking['booking_id']}", -3)); // トラッキングコードに予約IDを埋め込む $tracking = str_replace('%RESERVE_ID%', $reserve_id, $article['addition']->tracking); } } } // booking-thanksページ if (is_page(MTS_Simple_Booking::PAGE_BOOKING_THANKS)) { return $content . $tracking; } ob_start(); ?> <div class="info-message booking-completed"> ご予約ありがとうございました。 </div> <?php return ob_get_clean() . $tracking; }
/** * 予約データの料金を計算し料金データを戻す * */ public function make_bill() { $article_id = $this->booking['article_id']; $article = MTSSB_Article::get_the_article($article_id); if (empty($article)) { return null; } // 施設情報の読み込み $shop = get_option($this->domain . '_premise'); $charge = get_option($this->domain . '_charge'); $client = $this->booking['client']; // 勘定書データの作成 $bill = new MTS_Bill(); $bill->article_name = $article['name']; $bill->customer_name = $client['name']; $bill->shop_name = $shop['name']; // 人数の設定 $bill->number->adult = $client['adult']; $bill->number->child = $client['child']; $bill->number->baby = $client['baby']; // 通貨単位 $bill->currency_code = $charge['currency_code']; // 基本料金 $bill->basic_charge = $article['price']->booking; // 単価 $bill->amount->adult = $article['price']->adult; $bill->amount->child = $article['price']->child; $bill->amount->baby = $article['price']->baby; // 消費税方式・税率 $bill->tax_type = isset($charge['tax_notation']) ? $charge['tax_notation'] : 0; $bill->tax = isset($charge['consumption_tax']) ? $charge['consumption_tax'] : 0; // オプション料金 (予約品目にオプション使用が設定されている場合) $option_items = array(); if ($article['addition']) { foreach ($this->booking['options'] as $oOption) { $val = $oOption->getValue(); // オプション入力値 $number = $bill->get_number($oOption->whose); // オプション料金対象 if (!empty($val) && $number != 0) { $label = $oOption->getLabel(); // 日本語オプションラベル名 $price = $oOption->getPrice(); // オプション単価 $option_item = array(); switch ($oOption->getType()) { case 'number': // 全員が指定された場合は入力数を注文数とする if ($oOption->whose == 'all') { $number = $val; // それ以外は人数と入力数を比較し小さい方を注文数とする } else { $number = $val < $number ? $val : $number; } if ($price != 0) { $option_items[] = array('name' => $label, 'number' => $number, 'price' => $price); } break; case 'text': if ($price != 0) { $option_items[] = array('name' => $label, 'number' => $number, 'price' => $price); } break; case 'radio': case 'select': $fields = $oOption->getField(); // 料金設定されている場合は明細に追加する if (!empty($fields[$val]['price'])) { $option_items[] = array('name' => $label . ' ' . $fields[$val]['label'], 'number' => $number, 'price' => $fields[$val]['price']); } break; case 'check': $checks = explode(',', $val); $fields = $oOption->getField(); // 選択肢が料金設定されている場合は明細に追加する foreach ($checks as $check) { if (array_key_exists($check, $fields) && !empty($fields[$check]['price'])) { $option_items[] = array('name' => $label . ' ' . $fields[$check]['label'], 'number' => $number, 'price' => $fields[$check]['price']); } } break; //case 'date': 日付オプションは料金計算対象外とする //case 'date': 日付オプションは料金計算対象外とする default: break; } } } } $bill->option_items = $option_items; return $bill; }
/** * 指定日付、予約品目の予約状況 */ public function booking_day_info($day_time, $article_id, $method) { $dayTime = $day_time - $day_time % 86400; // 指定日の予約数データを取得する $count = $this->get_reserved_day_count($dayTime); // 予約品目データを取得する $article = MTSSB_Article::get_the_article(intval($article_id)); // 対象年月のスケジュールを読込む $key_name = MTS_Simple_Booking::SCHEDULE_NAME . date_i18n('Ym', $dayTime); $schedule = get_post_meta($article_id, $key_name, true); $day = date_i18n('d', $dayTime); // 時間毎の予約数 $bookingTable = $this->_setCount($article_id, $article['restriction'], $article['timetable'], $dayTime, $count); // 保存の際のチェック用予約数データ要求 if ($method == 'data') { // 予約数の設定 return array('day_time' => $dayTime, 'booking_table' => $bookingTable, 'restriction' => $article['restriction'], 'max' => intval($article[$article['restriction']]), 'open' => isset($schedule[$day]['open']) ? intval($schedule[$day]['open']) : -1, 'delta' => isset($schedule[$day]['delta']) ? intval($schedule[$day]['delta']) : 0); } ob_start(); echo sprintf('<h3>%s</h3>', $article['name']); // 予約日 echo sprintf('<p><span class="booking-admin-header">予約日</span>:%s</p>', date_i18n('Y年n月j日 (D)', $dayTime)); // 受付数 echo sprintf('<p><span class="booking-admin-header">上限数</span>:%d</p>', $article[$article['restriction']]); // スケジュール echo '<p><span class="booking-admin-header">スケジュール</span>:'; if (isset($schedule[$day]['open'])) { echo sprintf('予約 [%s] 調整数 [%d] 注記 [%s]', $schedule[$day]['open'] ? '受付中' : '中止', $schedule[$day]['delta'], empty($schedule[$day]['note']) ? 'なし' : $schedule[$day]['note']); } else { echo '未設定です。'; } echo '</p>'; // 時間割予約済み数 echo '<table>'; echo '<tr><th class="booking-admin-time">時間</th><th class="booking-admin-count">予約数</th></tr>'; foreach ($bookingTable as $hour => $number) { echo sprintf('<tr><td>%s</td><td>%d</td></tr>', date('H:i', $hour), $number); } return ob_get_clean(); }
/** * 予約受付の日時、対象品目の確認 * */ protected function _booking_acceptance() { // 予約受付中か確認 if ($this->controls['available'] != 1) { $this->err_message = $this->_err_message('UNAVAILABLE'); return false; } // 予約受付期間内か確認 if ($this->thetime < $this->start_time || $this->max_time <= $this->thetime) { $this->err_message = $this->_err_message('OUT_OF_PERIOD'); return false; } // 予約スケジュールデータを取得する $key_name = MTS_Simple_Booking::SCHEDULE_NAME . date_i18n('Ym', $this->thetime); $schedule = get_post_meta($this->article_id, $key_name, true); // スケジュールが登録されており予約を受け付けているか確認する $day = date_i18n('d', $this->thetime); if (!empty($schedule[$day])) { $this->schedule = $schedule[$day]; if ($this->schedule['open'] != 1) { $this->err_message = $this->_err_message('UNACCEPTABLE_DAY'); return false; } } else { // スケジュールが登録されていない場合 $this->err_message = $this->_err_message('UNAVAILABLE'); return false; } // 予約品目データを取得する $this->article = MTSSB_Article::get_the_article($this->article_id); // 予約時間の確認 if (!in_array($this->thetime % 86400, $this->article['timetable'])) { $this->err_message = $this->_err_message('UNACCEPTABLE_TIME'); return false; } // オプション有無の処理セット(オプション利用指定かつオプションデータ有) if ($this->article['addition'] && !empty($this->option)) { $this->option_available = true; } return true; }
public function booking_page($booking_id) { global $mts_simple_booking; $this->booking = $booking = $this->get_booking($booking_id); // データを読込んで編集データbookingタイプにする //$this->booking = $this->array_merge_default($this->new_booking(), $booking); if ($booking) { $article = MTSSB_Article::get_the_article($booking['article_id']); $daytime = $booking['booking_time'] - $booking['booking_time'] % 86400; $datestr = date_i18n(__('F j, Y'), $daytime) . ' (' . __(date_i18n('D', $daytime)) . ')'; } // 予約条件パラメータのロード $count = $this->controls['count']; // 支払データのロード $charge = get_option($this->domain . '_charge'); if ($charge['charge_list']) { $bill = $this->make_bill(); $currency = ' ' . ($bill->currency_code == 'JPY' ? __('Yen', $this->domain) : __('US dollar', $this->domain)); } ?> <div class="wrap"> <div id="icon-edit" class="icon32"><br /></div> <h2><?php _e('Reservation Calendar > Day > Booking', $this->domain); ?> </h2> <?php if (!empty($booking)) { ?> <ul class="subsubsub"> <li><?php echo '<a href="?page=' . self::PAGE_NAME . "&year=" . date_i18n('Y', $daytime) . "&month=" . date_i18n('n', $daytime) . '&action=monthly">' . __('Reservation Calendar', $this->domain) . '</a>'; ?> | </li> <li><?php echo '<a href="?page=' . self::PAGE_NAME . "&dt={$daytime}\">" . __('Reservation Day', $this->domain) . '</a>'; ?> | </li> <li><?php echo '<a href="?page=' . MTS_Simple_Booking::PAGE_BOOKING . "&booking_id={$booking['booking_id']}&action=edit\">" . __('Edit') . '</a>'; ?> | </li> <li><?php echo sprintf("<a href=\"?page=%s&action=delete&booking_id=%d&nonce=%s\" onclick=\"return confirm('%s')\">%s</a>", self::PAGE_NAME, $booking['booking_id'], wp_create_nonce(self::PAGE_NAME . '_delete'), __('Do you really want to delete this booking?', $this->domain), __('Delete')); ?> </li> </ul> <div class="clear"> </div> <h3><?php echo $datestr; ?> </h3> <table class="form-table booking-detail"> <tr> <th><?php _e('Article Name', $this->domain); ?> </th> <td><?php echo $article['name']; ?> </td> </tr> <tr> <th><?php _e('Date Time', $this->domain); ?> </th> <td><?php echo $datestr . date_i18n(' H:i', $booking['booking_time']); ?> </td> </tr> <tr> <th><?php _e('Number', $this->domain); ?> </th> <td><?php echo $booking['number']; ?> </td> </tr> <tr> <th><?php _e('Options', $this->domain); ?> </th> <td><?php foreach ($booking['options'] as $option) { echo $option->getLabel() . ' : '; echo $option->type == 'textarea' ? nl2br(esc_textarea($option->getText())) : esc_html($option->getText()); echo '<br />'; } ?> </td> </tr> <tr> <th><?php _e('Company', $this->domain); ?> </th> <td><?php echo esc_html($booking['client']['company']); ?> </td> </tr> <tr> <th><?php _e('Name'); ?> </th> <td><?php echo empty($booking['client']['name']) ? __('No Name', $this->domain) : esc_html($booking['client']['name']); ?> </td> </tr> <tr> <th><?php _e('Furigana', $this->domain); ?> </th> <td><?php echo esc_html($booking['client']['furigana']); ?> </td> </tr> <?php if ($booking['client']['birthday']->isSetDate()) { ?> <tr> <th><?php _e('Birthday', $this->domain); ?> </th> <td><?php echo $booking['client']['birthday']->get_date('j'); ?> </td> </tr><?php } ?> <?php if (!empty($booking['client']['gender'])) { ?> <tr> <th><?php _e('Gender', $this->domain); ?> </th> <td><?php echo $booking['client']['gender'] == 'male' ? __('Male', $this->domain) : __('Female', $this->domain); ?> </td> </tr><?php } ?> <tr> <th><?php _e('E-Mail', $this->domain); ?> </th> <td><?php echo esc_html($booking['client']['email']); ?> </td> </tr> <tr> <th><?php _e('Postcode', $this->domain); ?> </th> <td><?php echo esc_html($booking['client']['postcode']); ?> </td> </tr> <tr> <th><?php _e('Address', $this->domain); ?> </th> <td><?php echo esc_html($booking['client']['address1']) . '<br />' . esc_html($booking['client']['address2']); ?> </td> </tr> <tr> <th><?php _e('TEL', $this->domain); ?> </th> <td><?php echo esc_html($booking['client']['tel']); ?> </td> </tr> <tr> <th><?php echo apply_filters('booking_form_newuse', __('Newuse', $this->domain), 'admin'); ?> </th> <td><?php echo empty($booking['client']['newuse']) ? '' : ($booking['client']['newuse'] == 1 ? apply_filters('booking_form_newuse_yes', __('Yes')) : apply_filters('booking_form_newuse_no', __('No'))); ?> </td> </tr> <tr> <th><?php _e('Number', $this->domain); ?> </th> <td><?php foreach ($count as $key => $val) { echo '<div class="number-person">' . apply_filters('booking_form_count_label', __(ucwords($key), $this->domain), 'calendar_admin') . '<br />' . $booking['client'][$key] . '</div>'; } ?> </td> </td> </tr> <tr> <th><?php _e('Message', $this->domain); ?> </th> <td><?php echo nl2br(esc_html($booking['note'])); ?> </td> </tr> <?php if ($charge['charge_list']) { ?> <tr> <th><?php _e('Bill', $this->domain); ?> </th> <td> <table> <tr> <th class="bill-th">明細</th> <td class="bill-td"> <table class="bill-details"> <?php // 予約料金の表示 if (0 < $bill->basic_charge) { $name = apply_filters('booking_form_charge_booking', $bill->article_name . ' 料金', 'calendar_admin'); $this->_out_bill_row($name, 1, $bill->basic_charge, $currency); } // 人数料金の表示 foreach (array('adult', 'child', 'baby') as $type) { if ($bill->number->{$type} != 0) { $name = apply_filters('booking_form_charge_count', $bill->article_name . ' ', 'calendar_admin') . apply_filters('booking_form_count_label', __(ucwords($type), $this->domain), 'calendar_admin'); $this->_out_bill_row($name, $bill->number->{$type}, $bill->amount->{$type}, $currency); } } // オプション料金の表示 foreach ($bill->option_items as $item) { $this->_out_bill_row($item['name'], $item['number'], $item['price'], $currency); } ?> </table> </td> <tr> <?php if (0 < $charge['tax_notation']) { ?> <th class="bill-th">合計</th> <td class="bill-td"><div class="bill-total"><?php echo number_format($bill->get_total()) . $currency; ?> </div></td> </tr> <tr> <th class="bill-th"><?php echo $charge['tax_notation'] == 1 ? '内' : ''; ?> 消費税(<?php echo $bill->tax; ?> %)</th> <td class="bill-td"><div class="bill-tax"><?php echo number_format($bill->get_amount_tax($charge['tax_notation'] == 1)) . $currency; ?> </div></td> </tr> <tr><?php } ?> <th class="bill-th">総合計</th> <td class="bill-td"><div class="bill-total"><?php echo number_format($bill->get_total() + ($charge['tax_notation'] == 1 ? 0 : $bill->get_amount_tax())) . $currency; ?> </div></td> </tr> </table> </td> </tr> <tr> <th><?php _e('PayPal Transaction ID', $this->domain); ?> </th> <td><?php echo isset($booking['client']['transaction_id']) ? $booking['client']['transaction_id'] : ''; ?> </td> </tr><?php } ?> <tr> <th><?php _e('Created', $this->domain); ?> </th> <td><?php echo $booking['created']; ?> </td> </tr> <tr> <th><?php _e('User Agent', $this->domain); ?> </th> <td><?php echo isset($booking['client']['user_agent']) ? esc_html($booking['client']['user_agent']) : ''; ?> </td> </tr> <tr> <th><?php _e('Remote Address', $this->domain); ?> </th> <td><?php echo isset($booking['client']['remote_addr']) ? esc_html($booking['client']['remote_addr']) : ''; ?> </td> </tr> </table> <?php } else { ?> <?php _e('No Data', $this->domain); } ?> </div> <?php }