<div class="popup" id="popupCall">
	<div class="popup-container">
		<span class="icon icon-close"></span>
		<a href="#" class="logo-container"><img src="<?php echo(themosis_assets()); ?>/images/logo.png"/></a>

		<?php echo(Form::open(null, 'post', false, [
			'nonce' => '_token',
			'nonce_action'  => 'add-support-ticket',
			'id' => 'support-ticket'
		])); ?>		<?php echo(Form::hidden('action', 'add-support-ticket')); ?>
		<p><?php echo(__('Excellent! Enter your phone number and we will call you during the day.', THEMOSIS_TEXTDOMAIN)); ?></p>

		<?php
		$model = new TicketThemeModel();
		$themes = $model->selectBox();
		$phoneData = [
			'minlength' => 6,
			'maxlength' => 16,
//			'required' => 'required',
		];

        $string = file_get_contents(get_template_directory()."/resources/assets/js/country.json");
        $json_a = json_decode($string, true);

        foreach ($json_a as $country_name => $country_a) {

            $country_iso = strtolower($country_a['iso2']);
            $country_code = strtolower($country_a['code']);

                $geoIp = geoip_detect2_get_info_from_ip(get_ip_address());

                if(strtolower($geoIp->country->isoCode) == 'ru') {
                    $phoneData += [
                        'placeholder'    => '+7(___)___-__-__',
                        'data-inputmask' => "'mask': '+7(999)999-99-99'",
                    ];
                }

                if(strtolower($geoIp->country->isoCode) == $country_iso) {
                    $phoneData += [
                        'placeholder'    => '+'.$country_code.' ',
                        'data-inputmask' => "'mask': '+'.$country_code.''"
                    ];
                }
        }

		?>
		<div class="form-row">
			<?php echo(Form::select('theme', [
				$themes
			])); ?>		</div>
		<div class="form-row">
			<?php echo(Form::text('phone', null, $phoneData)); ?>
			<?php echo(Form::submit('add', __('I am waiting for a call', THEMOSIS_TEXTDOMAIN), ['class' => 'button button-blue'])); ?>		</div>
		<?php echo(Form::close()); ?>
		<br />
		<div class="response"></div>
	</div>
</div>