public function easy_booking_generate_css($data)
 {
     $plugin_dir = plugin_dir_path(WCEB_PLUGIN_FILE);
     // Shorten code, save 1 call
     $php_files = array('default' => realpath($plugin_dir . 'assets/css/dev/default.css.php'), 'classic' => realpath($plugin_dir . 'assets/css/dev/classic.css.php'));
     $blog_id = '';
     if (function_exists('is_multisite') && is_multisite()) {
         $blog_id = '.' . get_current_blog_id();
     }
     $css_files = array('default' => realpath($plugin_dir . 'assets/css/default' . $blog_id . '.min.css'), 'classic' => realpath($plugin_dir . 'assets/css/classic' . $blog_id . '.min.css'));
     if ($php_files) {
         foreach ($php_files as $theme => $php_file) {
             ob_start();
             // Capture all output (output buffering)
             require $php_file;
             // Generate CSS
             $css = ob_get_clean();
             // Get generated CSS (output buffering)
             $minified_css = WCEB()->easy_booking_minify_css($css);
             // Minify CSS
             if (file_exists($css_files[$theme])) {
                 if (is_writable($css_files[$theme])) {
                     file_put_contents($css_files[$theme], $minified_css);
                 }
                 // Save it
             } else {
                 $file = fopen($plugin_dir . 'assets/css/' . $theme . $blog_id . '.min.css', 'a+');
                 fwrite($file, $minified_css);
                 fclose($file);
             }
         }
     }
 }
 public function easy_booking_get_booked_items_from_orders()
 {
     $args = array('post_type' => 'shop_order', 'post_status' => apply_filters('easy_booking_get_order_statuses', array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-refunded')), 'posts_per_page' => -1);
     $query_orders = new WP_Query($args);
     $products = array();
     foreach ($query_orders->posts as $post) {
         $order_id = $post->ID;
         $order = new WC_Order($order_id);
         $items = $order->get_items();
         if ($items) {
             foreach ($items as $item_id => $item) {
                 $product_id = $item['product_id'];
                 $variation_id = $item['variation_id'];
                 $product = $order->get_product_from_item($item);
                 $is_bookable = WCEB()->easy_booking_is_bookable($product_id, $variation_id);
                 if (isset($is_bookable) && $is_bookable === 'yes' && !empty($product->id)) {
                     if (isset($item['ebs_start_format']) && isset($item['ebs_end_format'])) {
                         $id = empty($variation_id) || $variation_id === '0' ? $product_id : $variation_id;
                         $start = $item['ebs_start_format'];
                         $end = $item['ebs_end_format'];
                         $quantity = intval($item['qty']);
                         $refunded_qty = $order->get_qty_refunded_for_item($item_id);
                         if ($refunded_qty > 0) {
                             $quantity = $quantity - $refunded_qty;
                         }
                         if ($quantity <= 0) {
                             continue;
                         }
                         $products[] = apply_filters('easy_booking_booked_reports', array('product_id' => $id, 'order_id' => $order_id, 'start' => $start, 'end' => $end, 'qty' => $quantity));
                     }
                 }
             }
         }
     }
     $booked = array();
     if ($products) {
         foreach ($products as $booked_product) {
             $product_id = $booked_product['product_id'];
             $start = $booked_product['start'];
             $end = $booked_product['end'];
             $quantity = intval($booked_product['qty']);
             unset($booked_product['product_id']);
             $booked[$product_id][] = $booked_product;
         }
     }
     return array_filter($booked);
 }
    public function easy_booking_reports_content()
    {
        $booked_dates = WCEB()->easy_booking_get_booked_items_from_orders();
        ksort($booked_dates);
        if ($booked_dates) {
            ?>

			<div id="poststuff" class="wc-metaboxes-wrapper">

				<div class="wc-metaboxes woocommerce-reports-wide">

				<?php 
            foreach ($booked_dates as $product_id => $booking_data) {
                ?>

					<?php 
                $product = wc_get_product($product_id);
                $product_name = $product->get_title();
                ?>
					<div class="wc-metabox closed">
						<h3 style="cursor: pointer;"><?php 
                echo '#' . $product_id . ' - ' . $product_name;
                ?>
							<?php 
                // Get variation data
                if ($product->is_type('variation')) {
                    $list_attributes = array();
                    $attributes = $product->get_variation_attributes();
                    foreach ($attributes as $name => $attribute) {
                        $list_attributes[] = wc_attribute_label(str_replace('attribute_', '', $name)) . ': <strong>' . $attribute . '</strong>';
                    }
                    echo '<div class="description">' . implode(', ', $list_attributes) . '</div>';
                }
                ?>
							
						</h3>
						<div class="wc-metabox-content">
							<table class="wp-list-table widefat fixed striped">

								<?php 
                $cols = apply_filters('easy_booking_reports_cols', array('order_id' => array('id' => 'order_id', 'label' => __('Order ID', 'easy_booking')), 'start_date' => array('id' => 'start_date', 'label' => __('Start Date', 'easy_booking')), 'end_date' => array('id' => 'end_date', 'label' => __('End Date', 'easy_booking')), 'qty' => array('id' => 'qty', 'label' => __('Quantity booked', 'easy_booking'))));
                ?>
								<thead>
									<tr>
										<?php 
                foreach ($cols as $col) {
                    ?>
											<th scope="col" id="<?php 
                    echo $col['id'];
                    ?>
"><?php 
                    echo $col['label'];
                    ?>
</th>
										<?php 
                }
                ?>
									</tr>
								</thead>
								<tfoot>
									<tr>
										<?php 
                foreach ($cols as $col) {
                    ?>
											<th scope="col" id="<?php 
                    echo $col['id'];
                    ?>
"><?php 
                    echo $col['label'];
                    ?>
</th>
										<?php 
                }
                ?>
									</tr>
								</tfoot>
									<tbody>

										<?php 
                foreach ($booking_data as $data) {
                    ?>

											<?php 
                    $start_time = strtotime($data['start']);
                    $data['start'] = date('j M, Y', $start_time);
                    $end_time = strtotime($data['end']);
                    $data['end'] = date('j M, Y', $end_time);
                    ?>

											<tr>
												<?php 
                    foreach ($data as $name => $value) {
                        ?>
													<td class="<?php 
                        echo $name;
                        ?>
" style="padding: 7px;"><?php 
                        esc_html_e($value);
                        ?>
</td>
												<?php 
                    }
                    ?>
											</tr>

										<?php 
                }
                ?>

									</tbody>
							</table>
						</div>
					</div>

				<?php 
            }
            ?>

				</div>

			</div>

		<?php 
        }
    }