コード例 #1
0
    function ct_tour_order_render_manage_page()
    {
        global $wpdb, $ct_options;
        if (!empty($_POST['save'])) {
            ct_tour_order_save_action();
            return;
        }
        $order_data = array();
        $tour_data = array();
        $service_data = array();
        if ('edit' == $_REQUEST['action']) {
            if (empty($_REQUEST['order_id'])) {
                echo "<h2>" . esc_html__("You attempted to edit an item that doesn't exist. Perhaps it was deleted?", "ct") . "</h2>";
                return;
            }
            $order_id = $_REQUEST['order_id'];
            $post_table_name = $wpdb->prefix . 'posts';
            $order = new CT_Hotel_Order($order_id);
            $order_data = $order->get_order_info();
            $tour_data = $order->get_tours();
            $service_data = $order->get_services();
            if (empty($order_data)) {
                echo "<h2>" . esc_html__("You attempted to edit an item that doesn't exist. Perhaps it was deleted?", "ct") . "</h2>";
                return;
            }
        }
        $default_order_data = ct_order_default_order_data();
        $order_data = array_replace($default_order_data, $order_data);
        $site_currency_symbol = ct_get_site_currency_symbol();
        ?>

		<div class="wrap">
			<?php 
        $page_title = 'edit' == $_REQUEST['action'] ? 'Edit Tour Order<a href="edit.php?post_type=tour&amp;page=tour_orders&amp;action=add" class="add-new-h2">Add New</a>' : 'Add New Tour Order';
        ?>
			<h2><?php 
        echo wp_kses_post($page_title);
        ?>
</h2>
			<?php 
        if (isset($_REQUEST['updated'])) {
            echo '<div id="message" class="updated below-h2"><p>Order saved</p></div>';
        }
        ?>
			<form method="post" id="order-form" onsubmit="return manage_order_validateForm();" data-message="<?php 
        echo esc_attr(esc_html__('Please select a tour', 'citytours'));
        ?>
">
				<input type="hidden" name="id" value="<?php 
        echo esc_attr($order_data['id']);
        ?>
">
				<div class="row postbox">
					<div class="one-half">
						<h3><?php 
        echo esc_html__('Order Detail', 'citytours');
        ?>
</h3>
						<table class="ct_admin_table ct_order_manage_table">
							<tr>
								<th><?php 
        echo esc_html__('Tour', 'citytours');
        ?>
</th>
								<td>
									<select name="post_id" id="post_id">
										<option></option>
										<?php 
        $args = array('post_type' => 'tour', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC');
        if (!current_user_can('manage_options')) {
            $args['author'] = get_current_user_id();
        }
        $tour_query = new WP_Query($args);
        if ($tour_query->have_posts()) {
            while ($tour_query->have_posts()) {
                $tour_query->the_post();
                $selected = '';
                $id = $tour_query->post->ID;
                if ($order_data['post_id'] == $id) {
                    $selected = ' selected ';
                }
                echo '<option ' . esc_attr($selected) . 'value="' . esc_attr($id) . '">' . wp_kses_post(get_the_title($id)) . '</option>';
            }
        }
        wp_reset_postdata();
        ?>
									</select>
								</td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Date', 'citytours');
        ?>
</th>
								<td><input type="text" name="date_from" id="date" value="<?php 
        echo esc_attr($order_data['date_from']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Total Adults', 'citytours');
        ?>
</th>
								<td><input type="number" name="total_adults" value="<?php 
        echo esc_attr($order_data['total_adults']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Total Children', 'citytours');
        ?>
</th>
								<td><input type="number" name="total_kids" value="<?php 
        echo esc_attr($order_data['total_kids']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Total Price', 'citytours');
        ?>
</th>
								<td><input type="text" name="total_price" value="<?php 
        echo esc_attr($order_data['total_price']);
        ?>
"> <?php 
        echo esc_html($site_currency_symbol);
        ?>
</td>
							</tr>
							<?php 
        if (ct_is_multi_currency()) {
            ?>
								<tr>
									<th><?php 
            echo esc_html__('User Currency', 'citytours');
            ?>
</th>
									<td>
										<select name="currency_code">
											<?php 
            foreach (array_filter($ct_options['site_currencies']) as $key => $content) {
                ?>
												<option value="<?php 
                echo esc_attr($key);
                ?>
" <?php 
                selected($key, $order_data['currency_code']);
                ?>
><?php 
                echo esc_html($key);
                ?>
</option>
											<?php 
            }
            ?>
										</select>
									</td>
								</tr>
								<tr>
									<th><?php 
            echo esc_html__('Exchange Rate', 'citytours');
            ?>
</th>
									<td><input type="text" name="exchange_rate" value="<?php 
            echo esc_attr($order_data['exchange_rate']);
            ?>
"></td>
								</tr>
								<tr>
									<th><?php 
            echo esc_html__('Total Price in User Currency', 'citytours');
            ?>
</th>
									<td><label> <?php 
            if (!empty($order_data['total_price']) && !empty($order_data['exchange_rate'])) {
                echo esc_html($order_data['total_price'] * $order_data['exchange_rate']) . esc_html(ct_get_currency_symbol($order_data['currency_code']));
            }
            ?>
</td>
								</tr>
							<?php 
        }
        ?>
							<tr>
								<th><?php 
        echo esc_html__('Deposit Amount', 'citytours');
        ?>
</th>
								<td><input type="text" name="deposit_price" value="<?php 
        echo esc_attr($order_data['deposit_price']);
        ?>
"> <?php 
        echo esc_html(ct_get_currency_symbol($order_data['currency_code']));
        ?>
</td>
							</tr>
							<?php 
        if ('add' == $_REQUEST['action'] || !empty($order_data['deposit_price']) && !($order_data['deposit_price'] == 0)) {
            ?>
								<tr>
									<th><?php 
            echo esc_html__('Deposit Paid', 'citytours');
            ?>
</th>
									<td>
										<select name="deposit_paid">
											<?php 
            $deposit_paid = array('1' => esc_html__('yes', 'citytours'), '0' => esc_html__('no', 'citytours'));
            ?>
											<?php 
            foreach ($deposit_paid as $key => $content) {
                ?>
												<option value="<?php 
                echo esc_attr($key);
                ?>
" <?php 
                selected($key, $order_data['deposit_paid']);
                ?>
><?php 
                echo esc_html($content);
                ?>
</option>
											<?php 
            }
            ?>
										</select>
									</td>
								</tr>
								<?php 
            if (!empty($order_data['deposit_paid'])) {
                $other_data = unserialize($order_data['other']);
                if (!empty($other_data['pp_transaction_id'])) {
                    ?>
									<tr>
										<th><?php 
                    echo esc_html__('Paypal Payment Transaction ID', 'citytours');
                    ?>
</th>
										<td><label><?php 
                    echo esc_html($other_data['pp_transaction_id']);
                    ?>
</label></td>
									</tr>
								<?php 
                }
            }
            ?>
							<?php 
        } else {
            ?>
								<input type="hidden" name="deposit_paid" value="1">
							<?php 
        }
        ?>
							<tr>
								<th><?php 
        echo esc_html__('Status', 'citytours');
        ?>
</th>
								<td>
									<select name="status">
										<?php 
        $statuses = array('new' => esc_html__('New', 'citytours'), 'confirmed' => esc_html__('Confirmed', 'citytours'), 'cancelled' => esc_html__('Cancelled', 'citytours'), 'pending' => esc_html__('Pending', 'citytours'));
        if (!isset($order_data['status'])) {
            $order_data['status'] = 'new';
        }
        ?>
										<?php 
        foreach ($statuses as $key => $content) {
            ?>
											<option value="<?php 
            echo esc_attr($key);
            ?>
" <?php 
            selected($key, $order_data['status']);
            ?>
><?php 
            echo esc_html($content);
            ?>
</option>
										<?php 
        }
        ?>
									</select>
								</td>
							</tr>
						</table>
					</div>
					<div class="one-half">
						<h3><?php 
        echo esc_html__('Customer Infomation', 'citytours');
        ?>
</h3>
						<table  class="ct_admin_table ct_order_manage_table">
							<tr>
								<th><?php 
        echo esc_html__('First Name', 'citytours');
        ?>
</th>
								<td><input type="text" name="first_name" value="<?php 
        echo esc_attr($order_data['first_name']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Last Name', 'citytours');
        ?>
</th>
								<td><input type="text" name="last_name" value="<?php 
        echo esc_attr($order_data['last_name']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Email', 'citytours');
        ?>
</th>
								<td><input type="email" name="email" value="<?php 
        echo esc_attr($order_data['email']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Phone', 'citytours');
        ?>
</th>
								<td><input type="text" name="phone" value="<?php 
        echo esc_attr($order_data['phone']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Street line 1', 'citytours');
        ?>
</th>
								<td><input type="text" name="address1" value="<?php 
        echo esc_attr($order_data['address1']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Street line 2', 'citytours');
        ?>
</th>
								<td><input type="text" name="address2" value="<?php 
        echo esc_attr($order_data['address2']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('City', 'citytours');
        ?>
</th>
								<td><input type="text" name="city" value="<?php 
        echo esc_attr($order_data['city']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('State', 'citytours');
        ?>
</th>
								<td><input type="text" name="state" value="<?php 
        echo esc_attr($order_data['state']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Postal Code', 'citytours');
        ?>
</th>
								<td><input type="text" name="zip" value="<?php 
        echo esc_attr($order_data['zip']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Country', 'citytours');
        ?>
</th>
								<td><input type="text" name="country" value="<?php 
        echo esc_attr($order_data['country']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Special Requirements', 'citytours');
        ?>
</th>
								<td><textarea name="special_requirements"><?php 
        echo esc_textarea(stripslashes($order_data['special_requirements']));
        ?>
</textarea></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Booking No', 'citytours');
        ?>
</th>
								<td><input type="text" name="booking_no" value="<?php 
        echo esc_attr($order_data['booking_no']);
        ?>
"></td>
							</tr>
							<tr>
								<th><?php 
        echo esc_html__('Pin Code', 'citytours');
        ?>
</th>
								<td><input type="text" name="pin_code" value="<?php 
        echo esc_attr($order_data['pin_code']);
        ?>
"></td>
							</tr>
						</table>
					</div>
				</div>
				<input type="hidden" name="tour_booking_id" value="<?php 
        echo esc_attr(empty($tour_data) || empty($tour_data['id']) ? '' : $tour_data['id']);
        ?>
">
				<div class="row postbox ct-order-services">
					<h3><?php 
        echo esc_html__('Order Services Detail', 'citytours');
        ?>
</h3>
					<div class="services-wrapper">
						<table class="services-table"><tbody class="clone-wrapper">
						<tr class="rwmb-field">
							<th><?php 
        echo esc_html__('Title', 'citytours');
        ?>
</th>
							<th><?php 
        echo esc_html__('Qty', 'citytours');
        ?>
</th>
							<th><?php 
        echo esc_html__('Total Price', 'citytours');
        ?>
</th>
							<th>&nbsp;</th>
						</tr>

						<?php 
        if (empty($service_data)) {
            ?>
							<tr class="clone-field">
								<td>
									<input type="hidden" name="service_booking_id[0]" value="">
									<select name="service_id[0]" class="service_id_select">
									<?php 
            echo ct_get_service_list($order_data['post_id']);
            ?>
									</select>
								</td>
								<td><input type="text" name="service_qty[0]"></td>
								<td><input type="text" name="service_price[0]"></td>
								<td><a href="#" class="rwmb-button button remove-clone" style="display: none;">-</a></td>
							</tr>
						<?php 
        } else {
            ?>
							<?php 
            foreach ($service_data as $key => $service) {
                ?>
								<tr class="clone-field">
									<td>
										<input type="hidden" name="service_booking_id[<?php 
                echo esc_attr($key);
                ?>
]" value="<?php 
                echo esc_attr($service['id']);
                ?>
">
										<select name="service_id[<?php 
                echo esc_attr($key);
                ?>
]" class="service_id_select">
										<?php 
                echo ct_get_service_list($order_data['post_id'], $service['add_service_id']);
                ?>
										</select>
									</td>
									<td><input type="text" name="service_qty[<?php 
                echo esc_attr($key);
                ?>
]" value="<?php 
                echo esc_attr($service['qty']);
                ?>
"></td>
									<td><input type="text" name="service_price[<?php 
                echo esc_attr($key);
                ?>
]" value="<?php 
                echo esc_attr($service['total_price']);
                ?>
"></td>
									<td><a href="#" class="rwmb-button button remove-clone">-</a></td>
								</tr>
							<?php 
            }
            ?>
						<?php 
        }
        ?>
						<tr><td colspan="5"><a href="#" class="rwmb-button button-primary add-clone">+</a></td></tr>
						</tbody></table>
					</div>
				</div>
				<input type="submit" class="button-primary button_save_order" name="save" value="Save order">
				<a href="edit.php?post_type=tour&amp;page=tour_orders" class="button-secondary">Cancel</a>
				<?php 
        wp_nonce_field('ct_manage_orders', 'order_save');
        ?>
			</form>
		</div>
		<?php 
        if (!empty($ct_options['vld_credit_card']) && !empty($ct_options['cc_off_charge']) && !empty($order_data['other'])) {
            $cc_fields = array('cc_type' => 'CREDIT CARD TYPE', 'cc_holder_name' => 'CARD HOLDER NAME', 'cc_number' => 'CARD NUMBER', 'cc_cid' => 'CARD IDENTIFICATION NUMBER', 'cc_exp_year' => 'EXPIRATION YEAR', 'cc_exp_month' => 'EXPIRATION MONTH');
            $cc_infos = unserialize($order_data['other']);
            echo '<style>.cc_table{background:#fff;margin-top:30px;}.cc_table td{padding:10px;}.cc_table,.cc_table tr,.cc_table td{border:1px solid #000; border-collapse: collapse;}</style>';
            echo '<div style="clear:both"></div><h3>Credit Card Info</h3><table class="cc_table"><tbody>';
            foreach ($cc_fields as $key => $label) {
                if (!empty($cc_infos[$key])) {
                    echo '<tr><td><label>' . $label . '</label></td><td>' . $cc_infos[$key] . '</td></tr>';
                }
            }
            echo '</tbody></table>';
        }
    }
コード例 #2
0
                    echo ' - ' . date_i18n(ct_site_date_format(), strtotime($order_info['date_from']));
                }
                ?>
</td>
											<td class="text-right"><?php 
                echo ct_price($tour_data['total_price']);
                ?>
</td>
										</tr>
									<?php 
            }
        }
        ?>

								<?php 
        $order_services = $order->get_services();
        if (!empty($order_services)) {
            ?>
								<?php 
            foreach ($order_services as $order_service) {
                ?>
								<?php 
                $service_data = ct_get_add_service($order_service['add_service_id']);
                ?>
								<tr>
									<td class=""><?php 
                echo esc_html($order_service['add_service_id']);
                ?>
</td>
									<td class="text-center"><?php 
                echo esc_html($service_data->title);