<?php

use TourOperatorPro\Factory as FactoryAlias;
use TourOperatorPro\Html\ToolBar;
use TourOperatorPro\Html\TourOperatorProHtmlWooPanel as TourOperatorProHtmlWooPanelAlias;
use TourOperatorPro\Utilities\Utility as UtilityAlias;
use TourOperatorProAdminWooPanel\app\Html\HtmlBackend;
use TourOperatorPro\Language\Text;

$doc = FactoryAlias::getDocument();
TourOperatorProHtmlWooPanelAlias::load_jquery_library('icheck');
ToolBar::setTitle("List Currencies");
TourOperatorProHtmlWooPanelAlias::load_jquery_library('datatables');
?>
<?php ?>
    <form action="<?php echo(UtilityAlias::getBackendWooPanelGoToLink("currencies.form")) ?>" name="admin_woopanel-form" method="post">

        <div class="view-list-currencies">
            <div class="supported_currencies">
                <button type="button" class="btn btn-info btn-lg btn-show-modal" data-toggle="modal" data-target="#myModal">View
                    Currencies
                </button>
                <div class="modal fade" id="myModal" role="dialog">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close close-x" data-dismiss="modal">&times;</button>
                                <h4 class="modal-title"><?php esc_html_e('List Currencies','touroperatorpro') ?></h4>
                                <strong style="color: #ff0000"><?php esc_html_e('based on','touroperatorpro') ?> <?php echo($this->list_currencies_api['base']) ?>
                                    rate</strong>
                            </div>
                            <div class="modal-body">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th><?php esc_html_e('Code Currencies','touroperatorpro') ?></th>
                                        <th><?php esc_html_e('Rates','touroperatorpro') ?></th>
                                    </tr>
                                    </thead>
                                    <?php foreach ($this->list_currencies_api['rates'] as $key => $value) { ?>
                                        <tbody>
                                        <tr>
                                            <td><?php echo($key) ?></td>
                                            <td><?php echo($value) ?></td>
                                        </tr>
                                        </tbody>
                                    <?php } ?>
                                </table>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default btn-close-currency" data-dismiss="modal">Close</button>
                            </div>
                        </div>

                    </div>
                </div>

            </div>
            <table id="example" class="display table" style="width: 100%">
                <thead>
                <tr>
                    <th class="col-md-2"><?php esc_html_e('Index', 'touroperatorpro'); ?></th>
                    <th class="col-md-2"><?php esc_html_e('Name', 'touroperatorpro'); ?></th>
                    <th class="col-md-2"><?php esc_html_e('Code', 'touroperatorpro'); ?></th>
                    <th class="col-md-2"><?php esc_html_e('Symbol', 'touroperatorpro'); ?></th>
                    <th class="col-md-2"><?php esc_html_e('Rate', 'touroperatorpro'); ?></th>
                    <th class="col-md-2"></th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($this->list as $item) { ?>
                    <tr>
                        <td class="sorting_1 col-md-2"
                            style="width: 19%"><?php echo(HtmlBackend::render_checkbox($item->id)) ?></td>
                        <td class="customer-name col-md-2"><?php echo($item->name); ?> </td>
                        <td class="customer-code col-md-2"><?php echo($item->code); ?></td>
                        <td class="customer-symbol col-md-2"><?php echo($item->symbol); ?></td>
                        <td>
                            <?php foreach ($this->list_currencies_api['rates'] as $key => $value) {
                                if ($item->code == $key) { ?>
                                    <?php echo($value); ?>
                                <?php }?>
                            <?php } ?>
                        </td>

                        <td class="customer-action col-md-2">
                            <a href="<?php echo(UtilityAlias::getBackendWooPanelGoToLink("currencies.form", array('id' => $item->id))) ?>"
                               class="btn-edit" title="<?php esc_attr_e('Edit', 'touroperatorpro') ?>"><i
                                        class="fas fa-edit"></i> </a>
                        </td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
        </div>
        <input type="hidden" name="task" value="currency.save">
    </form>
<?php
$doc->addLessStyleSheet('admin_woopanel/app/assets/less/view_list_currencies.less');
$doc->addScriptApplySelector('.view-list-currencies', 'view_list_currencies', array(
), "admin_woopanel/app/assets/js/view_list_currencies.js");
?>