<?php
    $helper = $block->getHelper();
    $currencySymbol = $helper->getCurrentCurrencySymbol();
    $_productCollection = $helper->getLoadedProduct();
    $quotedProductsData = $helper->getQuotedProductInfo($_productCollection);
    $showCart = (int)$helper->getConfigAddToCart();
    $showPrice = (int)$helper->getConfigShowPrice();
?>
<div style="display:none" id="mt-qs-ask-data">
    <form id="quotesystem_quote_add_cat" method="post" action="<?= $escaper->escapeHtml($block->getUrl(
        'quotesystem/buyerquote/savequote',
        ['_secure' => $block->getIsSecure()]
))?>">
        <input type="hidden" name="product_name" value="" />
        <input type="hidden" name="product" value=""/>
        <input type="hidden" name="current_url" value="" />
        <div class="fieldset" >
            <div>
                <label for="quote_qty"><?= /* @noEscape */ __("Quantity"); ?> :</label>
                <input type="text" id="quote_qty" name="quote_qty" class="quote_qty" 
                data-validate="{required:true,'validate-greater-than-zero':true, 'validate-number':true}"/>
                <span class="mt-qs-min-qty"></span>
            </div>
            <div>
                <label for="quote_price"><?= /* @noEscape */ __("Price per Item")."(".$currencySymbol.")"; ?> :</label>
                <input type="text" id="quote_price" name="quote_price" class="quote_price" 
                data-validate="{required:true,'validate-greater-than-zero':true, 'validate-number':true}"/>
            </div>
            <div>
                <label for="quote_description"><?= /* @noEscape */ __("Description"); ?> :</label>
                <textarea id="quote_description" name="quote_description" class="quote_description" 
                data-validate="{required:true}"></textarea>
            </div>
            <div class="mt-file-field-container">
                <label class="label mt-file-label mt-quote-primary-btn">
                    <?= /* @noEscape */ __('Add Attachment(s)') ?>
                    <input type="file"
                        name="files"
                        class="mt-file-field"
                        id="mt-file-field"
                        data-url="<?= $escaper->escapeUrl($block->getUrl(
                            'quotesystem/buyerquote/fileUpload',
                            ['_secure' => $block->getRequest()->isSecure()]
                        )) ?>" multiple="multiple"/>
                </label>
            </div>
        </div>
    </form>
</div>
<a class="proceed-to-checkout button primary" style="display:none">
    <?= /* @noEscape */ __('Login') ?>
</a>
<script id="mt-file-field-template" type="text/x-magento-template">
    <div class="mt-uploaded-file">
        <span class="mt-uploaded-file-style mt-quote-primary-btn"><%- data.extension %></span>
        <span class="mt-uploaded-file-name"><%- data.name %></span>
        <input type="hidden" name="attachments[]" value="<%- data.file %>" class="mt-uploaded-file-value"/>
        <span class="mt-uploaded-file-del"></span>
    </div>
</script>
<script id="mt-file-field-uploader-template" type="text/x-magento-template">
    <div id="<%- data.id %>" class="mt-uploaded-file-row">
        <img src="<?= $escaper->escapeUrl($block->getViewFileUrl('Magetop_Quotesystem/images/ajax-loader-big.gif'))?>"/>
    </div>
</script>

    <?php

    $formData = [
    'quoteProductData'  =>  $quotedProductsData,
    'productitems'      => '.product-items li',
    'loginurl'          => $block->getUrl('customer/account/login'),
    'popoverbackgroundhtml' =>  '#mt-qs-ask-data',
    'popoverClass'          =>  '.popover',
    'popOverclose'          =>  '.popover_close',
    'categorySubmitButton'  =>  '.submit_button',
    'maxWidth'              =>  \Magento\Framework\File\Uploader::MAX_IMAGE_WIDTH,
    'maxHeight'             =>  \Magento\Framework\File\Uploader::MAX_IMAGE_HEIGHT,
    'fileDeleteUrl'            =>  $block->getUrl(
        'quotesystem/buyerquote/fileDelete',
        ['_secure' => $block->getRequest()->isSecure()]
    ),
    'stockStatus'          => true,
    'showCart'          => $showCart,
    'showPrice'         => $showPrice
    ];
    $serializedFormData = $block->getJsonHelper()->jsonEncode($formData);
    // phpcs:disable ?>
<script type="text/x-magento-init">
    {
        "*": {
            "MtQuotesystem": <?= /* @noEscape */ $serializedFormData; ?>
        }
    }
</script>
<?php // phpcs:enable ?>