<?php

use WpBookingEvent\Factory;
use WpBookingEventAdmin\app\Html\HtmlBackend;
use WpBookingEvent\Utilities\Utility as UtilityAlias;

$item = $this->item;
$open_source=Factory::getOpenSource();
$product=$open_source->getEcommerce()->get_product($item->open_source_link_id);
?>
<div class="wrapper-service-item" data-category_id="<?php esc_html_e($item->category_id) ?>"
     data-id="<?php esc_html_e($item->id) ?>">
    <?php echo (HtmlBackend::render_checkbox($item->id)) ?>
    <div class="wrapper-service-content">
        <div class="row">
            <div class="col-md-4">
                <div class="service-item-content ">
                    <span class="name"><?php esc_html_e($item->name) ?></span>
                    <span class="link-product">
						<?php if ($item->open_source_link_id && $product) { ?>
                            <a target="_blank"
                               href="<?php esc_html_e(get_permalink($item->open_source_link_id))  ?>"><?php esc_html_e($product->get_name()); ?></a>
						<?php } else { ?>
							<?php esc_attr_e('No link open source item','wpbookingevent') ?>
						<?php } ?>
                    </span>
                </div>
            </div>
            <div class="col-md-2">
                <div class="img-box">
                    <div>
                        <img class="service-image" src="<?php echo(Factory::getRootUrlPlugin()) ?><?php esc_html_e($item->image) ?>" alt="service-image" />
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="block-item">
                    <span><?php esc_attr_e('Duration','wpbookingevent') ?>:</span>
                    <span class="duration"><?php printf("%s hours 30 minutes", floor($item->duration)); ?></span>
                </div>
            </div>
            <div class="col-md-3">
                <div class="block-item">
                    <span><?php esc_attr_e('Price','wpbookingevent') ?>:</span>
                    <span class="price"><?php echo(HtmlBackend::render_price($item->price)) ?></span>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="wrapper-button">
                    <a href="<?php echo(UtilityAlias::getBackendGoToLink("service.form",array('id'=>$item->id))) ?>" class="btn-edit" title="<?php esc_attr_e('Edit','wpbookingevent')?>"><i class="fas fa-edit"></i></a>
                    <a href="<?php echo(UtilityAlias::goToTaskByView("service","service.delete",array('id'=>$item->id))) ?>" class="btn-delete" title="<?php esc_attr_e('Delete','wpbookingevent')?>"><i class="fas fa-trash-alt"></i></a>
                </div>
            </div>
        </div>
    </div>
</div>
