<?php
namespace WpBookingProAdmin\app\Html;

use WpBookingPro\Factory;
use WpBookingPro\Utilities\Utility;
use WpBookingProAdmin\app\helpers\AdminHelper;

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 render_price($price)
    {
        $appConfig = Factory::getAppConfig();
        $default_currency = $appConfig->get('default_currency','');
        $current_currency = isset($_SESSION['currency'])?$_SESSION['currency']: $default_currency;
        $format = AdminHelper::getFormatCurrentCurrency();
        $rate = AdminHelper::getExchangeRate($current_currency);
        $price = round($rate * $price, 2);
        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 = WPBOOKINGPRO_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;
    }

}