<?php
namespace WpBookingEventAdmin\app\Html;

use WpBookingEvent\Factory;

class HtmlBackend
{
    public static function render_checkbox($value="",$key="item"){
        ob_start();
        include __DIR__.DS."/hmtl/checkbox.php";
        $content=ob_get_clean();
        return $content;
    }
    public static function render_check_all($key="item"){
        ob_start();
        $content=ob_get_clean();
        return $content;
    }
/*    public static function review_star($rating_service, $rating_staff, $rating_ambience){
        $max_star = 5;
        $item = null;
        $tour_rating=($item->rating_service + $item->rating_staff  + $item->rating_ambience)/3;
        while ($tour_rating > $max_star) {
            $tour_rating = $tour_rating - $max_star;
        }

        $star = $tour_rating % 10;
        $non_star = ($max_star - $tour_rating) % 10;
        $half_star = ceil($max_star-$star-$non_star);
        $i = 1;
        return  $i;
    }*/

    public static function render_price($price,$format="$")
    {
        ob_start();
        include __DIR__.DS."/hmtl/price.php";
        $content=ob_get_clean();
        return $content;
    }
    public static function render_date($date,$format="m/d/Y"){
        $date=Factory::getDate($date);
        ob_start();
        include __DIR__.DS."/hmtl/date.php";
        $content=ob_get_clean();
        return $content;
    }
    public static function function_get_view()
    {
        $file_xml_path_app = WPBOOKINGEVENT_ADMIN_PATH . "/app/views.xml";
        $xml = simplexml_load_file($file_xml_path_app);
        $list_menu_by_xml = [];
        $index = 21;
        foreach ($xml->view as $view) {
            $list_menu_by_xml[] = (object)[
                'id' => (string)$view->attributes()['id'],
                'menu_slug' => (string)$view->attributes()['menu_slug'],
                'label' => (string)$view->attributes()['label'],
                'page_title' => (string)$view->attributes()['page_title'],
                'capability' => (string)$view->attributes()['capability'],
                'icon' => (string)$view->attributes()['icon'],
                'is_system' => (boolean)$view->attributes()['is_system'],
            ];
            $index++;
        }
        return $list_menu_by_xml;
    }

}