<?php
/** @var \Magetop\Advancepreview\Helper\Data $preivewHelper */
$preivewHelper = $this->helper('Magetop\Advancepreview\Helper\Data');
//echo get_class($preivewHelper);
$industryOptions = $preivewHelper->getOpdSetting('advancepreview/register_setting/industry_value');
//echo $industryOptions;
$industryOptions = $industryOptions != '' ? explode(',',$industryOptions) : [];
$allStores = $preivewHelper->getAllStore();
$bigTypefileds = [
    'company_name'=>'Company name',
    'industry'=>'Industry',
    'street'=>'Street',
    'number'=>'House number',
    'postcode'=>'Postcode',
    'city'=>'City',
    'country'=>'Country',
    'phone'=>'Phone',
    'is_reseller'=>'Is reseller?',
    'taxvat'=>'Sales tax / VAT number',
    'preferred_language'=>'Preferred language'
];
/*$agencyTypefileds = [
    'company_name '=>'Company name ',
    'custom_industry'=>'Industry',
    'custom_street'=>'Street',
    'custom_number'=>'Home number',
    'custom_postcode'=>'Postcode',
    'custom_city'=>'City',
    'custom_country'=>'Country',
    'custom_phone'=>'Phone',
    'custom_preferred_language'=>'Preferred language',
    'custom_sales_tax'=>'Sales tax / VAT number',
];*/
?>

<div class="" id="custom-fields-big" style="display: none;">
    <legend class="custom-legend"><span><?php echo __('Company information') ?></span></legend>
    <?php foreach ($bigTypefileds as $key => $bigTypefiled) : ?>
        <div class="mgt-custom-additnation-filed" id="mgt-custom-additnation-filed-<?php echo $key; ?>">
            <label class="label" for="custom-<?php echo $key; ?>">
                <span><?= $block->escapeHtml(__($bigTypefiled)) ?><span class="mand">*</span></span>
            </label>
            <div class="control">
                <?php if($key == 'industry') : ?>
                <select id="custom-<?php echo $key; ?>" name="custom[custom_<?php echo $key; ?>]" data-validate="{required:true}">
                    <?php if(count($industryOptions)) : ?>
                        <option value=""><?php echo __('Select') ?></option>
                        <?php foreach ($industryOptions as $industryOption) : ?>
                            <?php $vIndustryOption = str_replace(' ','',$industryOption) ?>
                            <option value="<?php echo $vIndustryOption ?>"><?php echo __($industryOption) ?></option>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </select>
                <?php elseif($key == 'preferred_language') : ?>
                    <select id="custom-<?php echo $key; ?>" name="custom[custom_<?php echo $key; ?>]" data-validate="{required:true}">
                        <option value=""><?php echo __('Select') ?></option>
                        <?php if(count($allStores)) : ?>
                            <?php foreach ($allStores as $allStore) : ?>
                                <option value="<?php echo $allStore['store_code'] ?>"><?php echo $allStore['store_name']  ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                <?php elseif($key == 'is_reseller') : ?>
                    <label class="switch">
                        <input type="checkbox" id="txt-register-is-seller" name="custom[custom_<?php echo $key; ?>]" value="1">
                        <span class="slider round"></span>
                    </label>
                <?php else:  ?>
                    <?php $typeInput = in_array($key,array('phone','postcode')) ? 'number' : 'text'; ?>
                    <?php if($key == 'taxvat') : ?>
                        <input type="<?php echo $typeInput; ?>" name="taxvat" id="custom-<?php echo $key; ?>" value="" title="<?= $block->escapeHtmlAttr(__($bigTypefiled)) ?>" class="input-text" data-validate="{required:true}" autocomplete="off" maxlength="30">
                    <?php else : ?>
                        <input type="<?php echo $typeInput; ?>" name="custom[custom_<?php echo $key; ?>]" id="custom-<?php echo $key; ?>" value="" title="<?= $block->escapeHtmlAttr(__($bigTypefiled)) ?>" class="input-text" data-validate="{required:true}">
                    <?php endif; ?>
                <?php endif; ?>
            </div>
            <?php if($key == 'is_reseller'){ ?>
                <p class="reseller_notify" style="display: none">Myfitmix will verify your registration as reseller. We will inform you about the result in short</p>
                <script>
                    require(['jquery', 'jquery/ui'], function($){
                        $('#txt-register-is-seller').click(function(){
                            if($(this).is(":checked")){
                                $('.reseller_notify').show();
                                $('#shop-name').show();
                                $('#contact-number').show();
                    			$('#shopurl').show();
                                $('#wantvendor').attr('checked',true);
                            }else{
                                $('.reseller_notify').hide();
                                $('#shop-name').hide();
                                $('#contact-number').hide();
                    			$('#shopurl').hide();
                                $('#wantvendor').attr('checked',false);
                            }
                        });
                    });
                </script>
            <?php } ?>
        </div>
    <?php endforeach; ?>
</div>
<style>
    .switch {
        position: relative;
        display: inline-block;
        width: 60px;
        height: 34px;
    }

    .switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

    .slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #ccc;
        -webkit-transition: .4s;
        transition: .4s;
    }

    .slider:before {
        position: absolute;
        content: "";
        height: 26px;
        width: 26px;
        left: 4px;
        bottom: 4px;
        background-color: white;
        -webkit-transition: .4s;
        transition: .4s;
    }

    input:checked + .slider {
        background-color: #2196F3;
    }

    input:focus + .slider {
        box-shadow: 0 0 1px #2196F3;
    }

    input:checked + .slider:before {
        -webkit-transform: translateX(26px);
        -ms-transform: translateX(26px);
        transform: translateX(26px);
    }

    /* Rounded sliders */
    .slider.round {
        border-radius: 34px;
    }

    .slider.round:before {
        border-radius: 50%;
    }
    .mand{
        color: #e02b27;
        font-size: 1.2rem;
        margin: 0 0 0 6px;
    }
    #mgt-custom-additnation-filed-preferred_language{
        margin-bottom: 30px;
    }
    .field.choice.newsletter{
        margin-bottom: 12px;
    }
    .fieldset.create.account{
        padding-bottom: 75px !important;
    }
</style>
