Beispiel #1
0
    /**
     * オプションの確認フォーム出力
     *
     */
    private function _outconfirm_option()
    {
        ?>
		<tr>
			<td class="option-confirm-header" colspan="2"><?php 
        echo apply_filters('booking_form_option_title', 'オプション注文', 'confirm');
        ?>
</td>
		</tr>
		<?php 
        foreach ($this->booking['options'] as $option) {
            ?>
<tr id="confirmation-<?php 
            echo $option->keyname;
            ?>
">
			<th class="option-confirm-label"><?php 
            echo apply_filters("option_confirm_label", $option->getLabel(), array('name' => $option->keyname));
            ?>
</th>
			<td class="option-confirm-value">
				<?php 
            echo apply_filters("option_confirm_text", nl2br(esc_html($option->getText())), array('name' => $option->keyname));
            ?>
				<span class="option-confirm-note"> <?php 
            echo apply_filters("option_confirm_note", $option->getNote(), array('name' => $option->keyname));
            ?>
</span>

				<?php 
            switch ($option->getType()) {
                case 'number':
                case 'text':
                case 'radio':
                case 'select':
                case 'textarea':
                    ?>
						<input type="hidden" name="booking[options][<?php 
                    echo $option->keyname;
                    ?>
]" value="<?php 
                    echo esc_html($option->getValue());
                    ?>
" />
						<?php 
                    break;
                case 'check':
                    foreach ($option->field as $fieldname => $fieldlabel) {
                        ?>
							<input type="hidden" name="booking[options][<?php 
                        echo $option->keyname;
                        ?>
][<?php 
                        echo $fieldname;
                        ?>
]" value="<?php 
                        echo $option->isChecked($fieldname) ? '1' : '0';
                        ?>
" />
						<?php 
                    }
                    break;
                case 'date':
                    $odate = new MTS_WPDate();
                    echo $odate->set_time($option->getValue())->date_form_hidden("booking[options][{$option->keyname}]");
                    break;
                case 'time':
                    $otime = new MTS_WPTime($option->getValue());
                    echo $otime->time_form_hidden("booking[options][{$option->keyname}]");
                    break;
                default:
                    break;
            }
            ?>
</td>
		</tr><?php 
        }
        return;
    }
    /**
     * 新規予約登録 予約品目の選択
     *
     */
    private function _select_article_page()
    {
        // 予約品目
        $articles = MTSSB_Article::get_all_articles();
        // 日付フォームオブジェクト生成、初期日付をセット
        $odate = new MTS_WPDate();
        $odate->set_date(date_i18n('Y-n-j'));
        $article_id = key($articles);
        ?>
	<div class="wrap">

		<?php 
        screen_icon('edit');
        ?>
		<h2><?php 
        _e('Add Booking', $this->domain);
        ?>
</h2>
		<?php 
        if (!empty($this->message)) {
            ?>
			<div class="<?php 
            echo $this->errflg ? 'error' : 'updated';
            ?>
"><p><strong><?php 
            echo $this->message;
            ?>
</strong></p></div>
		<?php 
        }
        ?>

		<h3><?php 
        _e('Select article', $this->domain);
        ?>
</h3>
		<form id="select-article" method="get" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
">
			<input type="hidden" name="page" value="<?php 
        echo self::PAGE_NAME;
        ?>
" />

			<table class="form-table" style="width: 100%">
				<tr class="form-field">
					<th>
						<?php 
        _e('Booking Date', $this->domain);
        ?>
					</th>
					<td>
						<?php 
        echo $odate->date_form('booking_new', 'bd');
        ?>
					</td>
				</tr>
				<tr class="form-field">
					<th>
						<?php 
        _e('Booking Event', $this->domain);
        ?>
					</th>
					<td>
						<select id="booking-article" class="booking-select-article" name="article_id">
							<?php 
        foreach ($articles as $aid => $article) {
            echo "<option value=\"{$aid}\">{$article['name']}</option>\n";
        }
        ?>
						</select>
						<select id="booking-time" class="booking-select-time" name="timetable">
							<?php 
        if (empty($articles[$article_id]['timetable'])) {
            echo '<option value="">' . __('Nothing', $this->domain) . "</option>\n";
        } else {
            foreach ($articles[$article_id]['timetable'] as $time) {
                echo "<option value=\"{$time}\">" . date('H:i', $time) . "</option>\n";
            }
        }
        ?>
						</select>
						<span id="loader-img" style="display:none"><img src="<?php 
        echo $this->plugin_url . 'image/ajax-loader.gif';
        ?>
" alt="Loading" /></span>
						<input type="hidden" id="ajax-nonce" value="<?php 
        echo wp_create_nonce('mtssb_get_timetable');
        ?>
">
					</td>
				</tr>
			</table>

			<p><input class="button-secondary" type="submit" value="<?php 
        _e('Add booking', $this->domain);
        ?>
" /></P>
		</form>
	</div>

    <?php 
    }
Beispiel #3
0
 /**
  * 予約データの読み込み
  *
  * @booking_id
  * @return $bookingタイプ
  */
 protected function get_booking($booking_id)
 {
     global $wpdb;
     $record = $wpdb->get_row($wpdb->prepare("\n\t\t\tSELECT * FROM {$this->tblBooking}\n\t\t\tWHERE booking_id=%d", intval($booking_id)), ARRAY_A);
     if (empty($record)) {
         return false;
     }
     $booked = $record;
     $booking = $this->new_booking($booked['booking_time'], $booked['article_id']);
     $booked['options'] = unserialize($record['options']);
     $booked['client'] = unserialize($record['client']);
     $birthday = new MTS_WPDate();
     if (isset($booked['client']['birthday'])) {
         $birthday->set_date($booked['client']['birthday']);
     }
     $booked['client']['birthday'] = $birthday;
     // オプションデータをオプションオブジェクトにセットする
     $booking = $this->array_merge_default($booking, $booked);
     return $booking;
 }
    /**
     * 予約データ入力フォーム postbox
     *
     */
    private function _postbox_booking()
    {
        $odate = new MTS_WPDate();
        ?>
	<div class="postbox">
		<h3><?php 
        _e('Booking Data', $this->domain);
        ?>
</h3>
		<div class="inside">
			<table class="form-table" style="width: 100%">
				<tr class="form-field">
					<th>
						<?php 
        _e('Booking Date', $this->domain);
        ?>
					</th>
					<td>
						<input type="hidden" name="booking[booking_id]" value="<?php 
        echo $this->booking['booking_id'];
        ?>
" />
						<?php 
        echo $odate->set_time($this->booking['booking_time'])->date_form('booking_time', 'booking');
        ?>
					</td>
				</tr>
				<tr class="form-field">
					<th>
						<?php 
        _e('Booking Event', $this->domain);
        ?>
					</th>
					<td>
						<select id="booking-article" class="booking-select-article" name="booking[article_id]">
							<?php 
        foreach ($this->articles as $article_id => $article) {
            echo "<option value=\"{$article_id}\"" . ($this->booking['article_id'] == $article_id ? ' selected="selected"' : '') . ">{$article['name']}</option>\n";
        }
        ?>
						</select>
						<select id="booking-time" class="booking-select-time" name="booking[timetable]">
							<?php 
        reset($this->articles);
        $article_id = empty($this->booking['article_id']) ? key($this->articles) : $this->booking['article_id'];
        $timetable = $this->booking['booking_time'] % 86400;
        //if (0 < $this->booking['booking_time']) {
        //	$timetable = $this->booking['booking_time']
        //	 - mktime(0, 0, 0, date('n', $this->booking['booking_time']), date('j', $this->booking['booking_time']), date('Y', $this->booking['booking_time']));
        //}
        if (empty($this->articles[$article_id]['timetable'])) {
            echo '<option value="">' . __('Nothing', $this->domain) . "</option>\n";
        } else {
            foreach ($this->articles[$article_id]['timetable'] as $time) {
                echo "<option value=\"{$time}\"" . ($timetable == $time ? ' selected="selected"' : '') . ">" . date('H:i', $time) . "</option>\n";
            }
        }
        ?>
						</select>
						<span id="loader-img" style="display:none"><img src="<?php 
        echo $this->plugin_url . 'image/ajax-loader.gif';
        ?>
" alt="Loading" /></span>
						<input type="hidden" id="ajax-nonce" value="<?php 
        echo wp_create_nonce($this->domain . '_ajax');
        ?>
" />
					</td>
				</tr>
				<tr>
					<th>
						<?php 
        _e('Attendance', $this->domain);
        ?>
					</th>
					<td>
						<input id="booking-attendance" class="small-text" type="text" name="booking[number]" value="<?php 
        echo $this->booking['number'];
        ?>
" /> 人
					</td>
				</tr>
			</table>
		</div>
	</div>

<?php 
    }