1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class BKAP_Resource_Details_Meta_Box {
public $id;
public $title;
public $context;
public $priority;
public $post_types;
private static $saved_meta_box = false;
public function __construct() {
$this->id = 'bkap-resource-data';
$this->title = __( 'Resource details', 'woocommerce-booking' );
$this->context = 'normal';
$this->priority = 'high';
$this->post_types = array( 'bkap_resource' );
add_action( 'save_post', array( $this, 'bkap_save_resources' ), 10, 2 );
wp_enqueue_style( 'bkap-booking', plugins_url( 'woocommerce-booking/css/booking.css' ) , '','1.0', false );
}
public function meta_box_inner( $post ) {
$post_id = $post->ID;
$resource = new BKAP_Product_Resource( $post_id );
?>
<div class="panel-wrap" id="bkap_resource_availability">
<div class="options_group">
<?php
woocommerce_wp_text_input( array(
'id' => '_bkap_booking_qty',
'label' => __( 'Available Quantity : ', 'woocommerce-booking' ),
'value' => max( $resource->get_resource_qty(), 1 ),
'type' => 'number',
'custom_attributes' => array(
'min' => '0',
'step' => '1',
),
'style' => 'width: 100px;',
'title' => __( 'The quantity of this resource available at any given time.', 'woocommerce-booking' )
) );
?>
</div>
<div class="options_group">
<table class="widefat">
<thead>
<tr>
<th><b><?php esc_html_e( 'Range type', 'woocommerce-booking' ); ?></b></th>
<th><b><?php esc_html_e( 'From', 'woocommerce-booking' ); ?></b></th>
<th></th>
<th><b><?php esc_html_e( 'To', 'woocommerce-booking' ); ?></b></th>
<th><b><?php esc_html_e( 'Bookable', 'woocommerce-booking' ); ?></b></th>
<th><b><?php esc_html_e( 'Priority', 'woocommerce-booking' ); ?></b></th>
<th class="remove" width="1%"> </th>
</tr>
</thead>
<tfoot>
<tr >
<th colspan="4" style="text-align: left;font-size: 11px;font-style: italic;">
<?php esc_html_e( 'Rules with lower priority numbers will override rules with a higher priority (e.g. 9 overrides 10 ).', 'woocommerce-booking' ); ?>
</th>
<th colspan="3" style="text-align: right;">
<a href="#" class="button button-primary bkap_add_row_resource" style="text-align: right;" data-row="<?php
ob_start();
include( 'html_resource_availability_table.php' );
$html = ob_get_clean();
echo esc_attr( $html );
?>"><?php esc_html_e( 'Add Range', 'woocommerce-booking' ); ?></a>
</th>
</tr>
</tfoot>
<tbody id="availability_rows">
<?php
$values = $resource->get_resource_availability();
if ( ! empty( $values ) && is_array( $values ) ) {
foreach ( $values as $availability ) {
include( 'html_resource_availability_table.php' );
}
}
?>
</tbody>
</table>
</div>
<?php
}
}
return new BKAP_Resource_Details_Meta_Box();
?>