<?php
/**
 * Webkul Software.
 *
 * @category   Webkul
 * @package    Webkul_Agorae
 * @author     Webkul Software Private Limited
 * @copyright  Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license    https://store.webkul.com/license.html
 */
// @codingStandardsIgnoreFile

/**
 * Followers list display to seller
 *
 * @var $block \Webkul\Agorae\Block\ShopFollowerList
 */
?>
<div class="wk-mp-design">
    <fieldset class="fieldset info wk-mp-fieldset">
        <legend class="legend">
            <span><?php /* @escapeNotVerified */ echo __('Shop Followers') ?></span>
            <button class="button wk-mp-btn sendmail" title="<?php /* @escapeNotVerified */ echo __('Send Email to Followers') ?>" >
                <span><span><?php /* @escapeNotVerified */ echo __('Send Email to Followers') ?></span></span>
            </button>
        </legend>
        <div class="grid">
            <div class="hor-scroll">
                <form action="<?php /* @escapeNotVerified */ echo $block->getCurrentSiteUrl()?>" method="get" id="form-productlist-filter"  name="formFavouriteSellerFilter" data-mage-init='{"validation":{}}'>
                    <table cellspacing="0" class="border wk-mp-list-table">
                        <thead>
                            <tr id="wk-mp-tr-heading">
                                <th><span><?php /* @escapeNotVerified */ echo __('Follower Name') ?></span></th>
                                <th><?php /* @escapeNotVerified */ echo __('Date') ?></th>
                                <th><span>&nbsp;</span></th>
                            </tr>
                        </thead>
                        <tbody class="wk-mp-body">
                            <tr>
                                <td>
                                    <input type="text" class="input-text" name="s" placeholder='<?php /* @escapeNotVerified */ echo __('search by customer name') ?>' value="<?php /* @escapeNotVerified */ echo $block->getFilterParam() ?>"/>
                                </td>
                                <td>
                                    <span class="wk-mp-td-span">
                                        <?php /* @escapeNotVerified */ echo __('From: ') ?>
                                        <input name="from_date" id="from-date" class="input-text" value="<?php /* @escapeNotVerified */ echo $block->filterDateFromParam()?>" />
                                    </span>                             
                                    <span class="wk-mp-td-span">
                                        <?php /* @escapeNotVerified */ echo __('To: ') ?>
                                        <input name="to_date" id="to-date" class="input-text" value="<?php /* @escapeNotVerified */ echo $block->filterDateToParam()?>" />
                                    </span>
                                </td>
                                <td>
                                    <button class="button" title="Save" type="submit">
                                        <span><span><span><?php /* @escapeNotVerified */ echo __('Submit') ?></span></span></span>
                                    </button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
                <?php if ($block->getFollowerList() && count($block->getFollowerList())): ?>
                    <form action="<?php /* @escapeNotVerified */ echo $block->getUrl('agorae/shopfollower/massdelete', ['_secure' => $this->getRequest()->isSecure()]) ?>" method="post" id="form-shopfollower-massdelete" name="formShopFollowerMassDelete" data-mage-init='{"validation":{}}'>
                        <?php /* @escapeNotVerified */ echo $block->getBlockHtml('formkey')?>
                        <button class="button" title="<?php /* @escapeNotVerified */ echo __('Delete Customers') ?>" type="submit" style="float: left;padding: 5px 10px;"  id="mass-delete-butn">
                            <span><span><span><?php /* @escapeNotVerified */ echo __('Delete Customers') ?></span></span></span>
                        </button>
                        <table cellspacing="0" class="border wk-mp-list-table wk-mp-list-container-table">
                            <thead>
                                <tr class="wk-content">
                                    <th class="wk-check-first-td">
                                        <span>
                                            <input type="checkbox" name="mpselecctall" value="all" id="mpselecctall"/>
                                        </span>
                                    </th>
                                    <th>
                                        <span class="label pro-status">
                                            <?php /* @escapeNotVerified */ echo __('Customer Name')?>
                                        </span>
                                    </th>
                                    <th>
                                        <span class="label pro-status">
                                            <?php /* @escapeNotVerified */ echo __('Liked Date')?>
                                        </span>
                                    </th>
                                    <th>
                                        <span class="label">
                                            <?php /* @escapeNotVerified */ echo __('Action')?>
                                        </span>
                                    </th>                       
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                $i = 0;
                                foreach($block->getFollowerList() as $customer){
                                    $i++;
                                    ?>
                                    <tr class="wk-row-view <?php /* @escapeNotVerified */ echo $class = ($i == count($block->getFollowerList()))? 'wk-last_tr':''?>">
                                        <td class="wk-check-first-td">
                                            <span>
                                                <input type="checkbox" name="customer_mass_delete[]" class="mpcheckbox" value="<?php /* @escapeNotVerified */ echo $customer->getCustomerId(); ?>"/>
                                            </span>
                                        </td>
                                        <td>        
                                            <span class="label pro-status">
                                                <?php /* @escapeNotVerified */ echo $block->getCustomerName($customer->getCustomerId())?>
                                            </span>
                                        </td>
                                        <td>        
                                            <span class="label pro-status">
                                                <?php /* @escapeNotVerified */ echo $customer->getLikedAt()?>
                                            </span>
                                        </td>
                                        <td>
                                            <span class="label wk-action">
                                                <img src="<?php /* @escapeNotVerified */ echo $this->getViewFileUrl('Webkul_Marketplace::images/icon-trash.png'); ?>" alt="<?php echo __('Delete')?>" title="<?php /* @escapeNotVerified */ echo __('Delete')?>" class="mp-delete" data-url="<?php /* @escapeNotVerified */ echo $block->getUrl('agorae/shopfollower/delete/', ['id'=>$customer->getCustomerId(), '_secure' => $this->getRequest()->isSecure()]) ?>"/>
                                            </span> 
                                        </td>                       
                                    </tr>
                                    <?php
                                }?>
                            </tbody>
                        </table>
                    </form>                     
                <?php else: ?>
                    <div class="wk-emptymsg">
                        <?php /* @escapeNotVerified */ echo __('No Follower Available') ?>
                    </div>
                <?php endif ?>                  
            </div>
        </div>
        <?php if ($block->getPagerHtml()): ?>
            <div class="order-products-toolbar toolbar bottom"><?php /* @escapeNotVerified */ echo $block->getPagerHtml(); ?></div>
        <?php endif ?>  
    </fieldset> 
</div>
<div class="ask-que email_wrapper">
    <div id="wk-mp-ask-data">
        <div class="modals-wrapper">
            <aside tabindex="0" data-type="popup" data-role="modal" class="modal-popup modal-slide _inner-scroll wk-mp-model-popup">
                <div tabindex="0" data-role="focusable-start"></div>
                <div data-role="focusable-scope" class="modal-inner-wrap">
                    <header class="modal-header">
                        <h4 class="modal-title"><?php /* @escapeNotVerified */ echo __('Send Email to all Followers') ?></h4>
                        <button type="button" data-role="closeBtn" class="action-close wk-close">
                            <span>Close</span>
                        </button>
                        <span  class="wk-clear" ></span>
                    </header>
                    <form id="email-form" method="post" action="#" class="fieldset">
                        <div class="modal-body form-list field required">
                            <label class="label"><?php /* @escapeNotVerified */ echo __('Subject') ?> :</label>
                            <input type="text" name="subject" class="wk-contact_input_fields subject required-entry"/>
                            <label class="label"><?php /* @escapeNotVerified */ echo __('Message') ?> :</label>
                            <textarea id="messagetextarea"  name="message" class="message wk-contact_input_fields required-entry"></textarea>
                            <script>
                                require([
                                    'jquery',
                                    'mage/adminhtml/wysiwyg/tiny_mce/setup'
                                ], function(jQuery){

                                    var config = '',editor;

                                        jQuery.extend(
                                        config,
                                        {
                                            settings: {
                                                theme_advanced_buttons1 : 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
                                                'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code',
                                                theme_advanced_buttons2: null,
                                                theme_advanced_buttons3: null,
                                                theme_advanced_buttons4: null,
                                                theme_advanced_statusbar_location: null
                                            },
                                            files_browser_window_url: false
                                        }
                                    );

                                    editor = new tinyMceWysiwygSetup(
                                        'messagetextarea',
                                        config
                                    );
                                    editor.turnOn();

                                    jQuery('#messagetextarea')
                                        .addClass('wysiwyg-editor')
                                        .data(
                                            'wysiwygEditor',
                                            editor
                                        );
                                    });
                            </script>
                            <input type="hidden" name="seller-id" value="<?php echo $block->getCurrentCustomerId();?>"/>
                        </div>
                        <div class="modal-footer">
                            <span class="error"></span>
                            <span class="errormail"></span>
                            <input type="reset" value="<?php /* @escapeNotVerified */ echo __('Reset') ?>" id="resetbtn" class="wk-btn wk-btn_default"/>
                            <input type="submit" value="<?php /* @escapeNotVerified */ echo __('Submit') ?>" id="send-mail-button" class="wk-btn wk-btn-primary clickask"/>
                            <span class="wk-clear"></span>
                        </div>
                    </form>        
                </div>
                <div tabindex="0" data-role="focusable-end"></div>
            </aside>
        </div>
    </div>
</div>
<?php

    $formData = [
        'sendMailSelector'      => '.sendmail',
        'emailWrapperSelector'  => '.email_wrapper',
        'wkEmailDataContainer'  => '#wk-mp-ask-data',
        'formCloseSelector'     => '.wk-close',
        'resetButtonSelector'   => '#resetbtn',
        'sendMailButtonSelector'=> '#send-mail-button',
        'subjectInputSelector'  => '.subject',
        'messageFieldSelector'  =>  '.message',
        'emailFormSelector'     => '#email-form',
        'sendUrl'               => $block->getUrl('agorae/shopfollower/sendmailtofollowers')
    ];
$serializedData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData);
?>
<script type="text/x-magento-init">
    {
        "*": {
            "shopFollowerList": <?php echo $serializedData; ?>
        }
    }
</script>