<? 
	ini_set('error_reporting', E_ALL);
	ini_set('display_errors', 1);
	ini_set('display_startup_errors', 1);

	require_once('./functions/crm_settings.php');
	include_once(ROOT . 'functions/func-install.php');
?>
<!--- <? echo $CRMname . ' ' . $CRMversion . ' | Developed by ' . $CRMgreater . ' | ' . $CRMphone . ' | ' . $CRMwebsite . ' | ' . $CRMemail; ?> --->
 
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>Установка WORKBox CRM</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta name="robots" content="noindex, nofollow" />
	<!--- / --->
	<link rel="stylesheet" href="/<? echo $folder; ?>/assets/css/bootstrap.css" />
	<link rel="stylesheet" href="/<? echo $folder; ?>/assets/css/bootstrap-theme.css" />
	<!--- / --->
	<link rel="stylesheet" href="/<? echo $folder; ?>/assets/css/jq.ui.css" />
	<link rel="stylesheet" href="/<? echo $folder; ?>/assets/css/jq.fullpage.css" />
	<link rel="stylesheet" href="/<? echo $folder; ?>/assets/css/jq.animate.css" />
	<!--- / --->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css" />
	<!--- / --->
	<link rel="stylesheet" href="/<? echo $folder; ?>/assets/css/style.css" />
	<link rel="stylesheet" href="/<? echo $folder; ?>/assets/css/style-wb-info.css" />
	<!--- / --->
	<link rel="icon" href="/<? echo $folder; ?>/favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="/<? echo $folder; ?>/favicon.ico" type="image/x-icon" />
	<link rel="apple-touch-icon" href="/<? echo $folder; ?>/assets/img/icon-ios-57.png"/>
	<link rel="apple-touch-icon" sizes="72x72" href="/<? echo $folder; ?>/assets/img/icon-ios-72.png"/>
	<link rel="apple-touch-icon" sizes="114x114" href="/<? echo $folder; ?>/assets/img/icon-ios-144.png"/>
	<!--- / --->
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jquery-3.6.0.js"></script>
	<style>
		body{
			background: #ffffff;
			background: -webkit-linear-gradient(0deg, #e4e4e4, #ffffff, #ffffff);
			background: -moz-linear-gradient(0deg, #e4e4e4, #ffffff, #ffffff);
			background: -o-linear-gradient(0deg, #e4e4e4, #ffffff, #ffffff);
			background: linear-gradient(0deg, #e4e4e4, #ffffff, #ffffff);
			background-attachment: fixed!important;
		}
	</style>
</head>
<body>
	<div class="loader"></div>
	<form name="crm-sn" class="form-horisontal" style="display: block;" method="post">
	<div id="fullpage">
		<div class="section page1 ">
			<div class="head_block wow fadeIn" data-wow-duration="1.0s" data-wow-delay="0.0s" data-wow-offset="0">
				<div class="wb_center">
					<h1 class="wb_name" style="background-image: url('/<? echo $folder; ?>/assets/img/text-bg.jpg');"><a title="Вернуться в интерфейс" href="/<? echo $folder; ?>/"><? echo $CRMname; ?></a></h1>
					<div class="wb_ver" style="left:602px;">Установка</div>
				</div>
			</div>
			<div style="text-align:center;">
				<a href="#info"><i class="fa fa-4x fa-angle-down wow bounce animated" data-wow-delay="800ms" data-wow-iteration="infinite" data-wow-duration="1s" style="visibility: visible; animation-duration: 1s; animation-delay: 800ms; animation-iteration-count: infinite; animation-name: bounce;color:#ddd;"></i></a>
			</div>
		</div>
		
		<div class="section page2 ">
			<h2 class="wow fadeInDown" data-wow-duration="1.0s" data-wow-delay="0.3s" data-wow-offset="0" style="visibility: visible; animation-duration: 1s; animation-delay: 0.3s; animation-name: fadeInDown;">Добро пожаловать</h2>
			<p class="text-center wow fadeInDown" style="margin-bottom:30px;">Вы уже пользовались WORKBox CRM?</p>
			
			<div class="container">
				<div class="row">
					<div class="col-lg-6 wow fadeInLeft" data-wow-duration="1.0s" data-wow-delay="0.0s" data-wow-offset="0">
						<div class="block_price"><h3><i class="fa fa-fw fa-user"></i> Текущий пользователь:</h3></div>
						<p>Если у вас ранее была зарегистрирована <?php echo $CRMname;?> вам необходимо только ввести <u>серийный номер</u> и <u>кодовое слово</u> полученные при регистрации и нажать кнопку "Запросить лицензию". Все данные загрузятся автоматически. В конце регистрации укажите <u>пароль администратора</u> и нажмите кнопку "Сохранить"</p>
					</div>
					<div class="col-lg-6 wow fadeInRight" data-wow-duration="1.0s" data-wow-delay="0.0s" data-wow-offset="0">
						<div class="block_price"><h3><i class="fa fa-fw fa-user-o"></i> Новый пользователь:</h3></div>
						<p>Если никогда ранее не пользовались <?php echo $CRMname;?> вам необходимо заполнить данные о себе и нажать кнопку "Запросить лицензию". Все данные загрузятся автоматически. В конце регистрации укажите <u>пароль администратора</u> и нажмите кнопку "Сохранить"</p>
					</div>
				</div>
			</div>
			<div style="text-align:center;padding-top:50px;">
				<a href="#hello"><i class="fa fa-4x fa-angle-down wow bounce animated" data-wow-delay="800ms" data-wow-iteration="infinite" data-wow-duration="1s" style="visibility: visible; animation-duration: 1s; animation-delay: 800ms; animation-iteration-count: infinite; animation-name: bounce;color:#ddd;"></i></a>
			</div>
		</div>
		
		<div class="section page3 ">
			<h2 class="wow fadeInDown" data-wow-duration="1.0s" data-wow-delay="0.3s" data-wow-offset="0" style="visibility: visible; animation-duration: 1s; animation-delay: 0.3s; animation-name: fadeInDown;">Давайте знакомиться!</h2>
			<p class="text-center wow fadeInDown" style="margin-bottom:30px;">Зарегистрируйте системы и получите лицензию WORKBox CRM на 100 лет</p>
			<div class="container">
				<div class="row">
					<div class="col-lg-12">
						<?
						if( isset( $_POST['SnSave'] ) ) {
							if(!preg_match("/[A-Z]{2}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}/i", $_POST['inputCRMsn'])){
								echo '<div id="result_check_sn" class="clr_high notice_fixed" style="margin-top:10px;display:block;">Ошибка! Неверный серийный номер</div>';
							}
						}
						?>
						<div id="result" class="notice_fixed" style="margin-top:0px;"></div>
					</div>
					<div class="col-lg-6 wow fadeInLeft" data-wow-duration="1.0s" data-wow-delay="0.0s" data-wow-offset="0">
					<div class="block_price"><h3><i class="fa fa-fw fa-vcard"></i> Заполните информацияю о себе:</h3></div>
						<div class="panel panel-default" <? if($nCRMusername == '' or $nCRMuserphone == '' or $nCRMuseremail == '') { ?>style="border-color:#e00000;"<? } ?>>
							<div class="panel-body">
								<div class="row">
									<div class="form-group col-lg-12">
										<div class="input-group input-group-lg">
											<span class="input-group-addon" title="<?=Dict::_('TXTUSERNAME')?>"><i class="fa fa-fw fa-user" aria-hidden="true"></i></span>
											<input type="text" onchange="userrule();" onkeyup="userrule();" onclick="userrule();" class="form-control" name="inputCRMuname" value="<? echo $nCRMusername; ?>" placeholder="<?=Dict::_('TXTUSERNAME')?>" autocomplete="disabled" />
										</div>
									</div>
									<div class="form-group col-lg-12">
										<div class="input-group input-group-lg">
											<span class="input-group-addon" title="<?=Dict::_('TXTUSERPHONE')?>"><i class="fa fa-fw fa-phone" aria-hidden="true"></i></span>
											<input type="text" class="form-control" name="inputCRMuphone" value="<? echo $nCRMuserphone; ?>" placeholder="<?=Dict::_('TXTUSERPHONE')?>"  />
										</div>
									</div>
									<div class="form-group col-lg-12" style="margin-bottom: 0px;">
										<div class="input-group input-group-lg">
											<span class="input-group-addon" title="<?=Dict::_('TXTUSERMAIL')?>"><i class="fa fa-fw fa-at" aria-hidden="true"></i></span>
											<input type="email" class="form-control" name="inputCRMumail" value="<? echo $nCRMuseremail; ?>" placeholder="<?=Dict::_('TXTUSERMAIL')?>"  />
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-lg-6 wow fadeInRight" data-wow-duration="1.0s" data-wow-delay="0.0s" data-wow-offset="0">
						<div class="block_price"><h3><i class="fa fa-fw fa-key"></i> Запросите данные лицензии:</h3></div>
						<div class="panel panel-default" <? if($nCRMsn == '') { ?>style="border-color:#e00000;"<? } ?> >
							<div class="panel-body">
								<div class="row">
									<div class="form-group col-lg-12">
										<div class="input-group input-group-lg">
											<span class="input-group-addon" title="<?=Dict::_('TTLCRMSN')?>"><i class="fa fa-fw fa-shield" aria-hidden="true"></i></span>
											<input type="text" class="form-control" style="text-align:center;" name="inputCRMsn" value="" placeholder="ХХ-ХХХХХ-ХХХХХ-ХХХХХ" minlength="20" maxlength="20" />
										</div>
									</div>
									<div class="form-group col-lg-12">
										<div class="input-group input-group-lg">
											<span class="input-group-addon" title="<?=Dict::_('TXTUSERWORD')?>"><i class="fa fa-fw fa-key" aria-hidden="true"></i></span>
											<input type="text" class="form-control" name="inputCRMword" value="" placeholder="<?=Dict::_('TXTUSERWORD')?>" autocomplete="disabled"  />
										</div>
									</div>
									<div class="form-group col-lg-12" style="margin-bottom: 0px;text-align:center;">
											<input type="hidden" name="inputCRMdate" value="" />
											<button class="btn btn-primary btn-lg" style="width:100%;" type="button" name="RequestSN">Запросить лицензию WORKBox CRM</button>
									</div>
									<div class="clear"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div style="text-align:center;padding-top:50px;">
				<a href="#rules"><i class="fa fa-4x fa-angle-down wow bounce animated" data-wow-delay="800ms" data-wow-iteration="infinite" data-wow-duration="1s" style="visibility: visible; animation-duration: 1s; animation-delay: 800ms; animation-iteration-count: infinite; animation-name: bounce;color:#ddd;"></i></a>
			</div>
		</div>
		
		<div class="section page4 ">
			<h2 class="wow fadeInDown" data-wow-duration="1.0s" data-wow-delay="0.3s" data-wow-offset="0" style="visibility: visible; animation-duration: 1s; animation-delay: 0.3s; animation-name: fadeInDown;">Условия использования</h2>
			<p class="text-center wow fadeInDown" style="margin-bottom:30px;">Пожалуйста ознакомьтесь с использованием Бесплатной CRM системы WORKBox</p>
			<div class="container wow fadeInDown" data-wow-duration="1.0s" data-wow-delay="0.0s" data-wow-offset="0">
				<div class="row">
					<div class="col-lg-12">
						<div class="panel panel-default">
							<div class="panel-body">
								<div class="form-group" style="margin-bottom: 0px;">
									<iframe src="/<? echo $folder; ?>/wb-rules.php" frameborder="0" width="100%" height="350px"></iframe>
									<input type="checkbox" value="accept" id="checkboxCRMrules" name="checkboxCRMrules" <? if($nCRMrules == 'accept'){ echo 'checked'; } ?> required /><label for="checkboxCRMrules"><?=Dict::_('TXTCRMRUL')?></label>
									<BR/>
									<input type="checkbox" value="accept" id="checkboxCRMrules1" name="checkboxCRMrules1" <? if($nCRMrules == 'accept'){ echo 'checked'; } ?> required /><label for="checkboxCRMrules1"><?=Dict::_('TXTCRMRUL2')?></label> 
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div style="text-align:center;padding-top:50px;">
				<a href="#end"><i class="fa fa-4x fa-angle-down wow bounce animated" data-wow-delay="800ms" data-wow-iteration="infinite" data-wow-duration="1s" style="visibility: visible; animation-duration: 1s; animation-delay: 800ms; animation-iteration-count: infinite; animation-name: bounce;color:#ddd;"></i></a>
			</div>
		</div>
		<div class="section page5 ">
			<h2 class="wow fadeInDown" data-wow-duration="1.0s" data-wow-delay="0.3s" data-wow-offset="0" style="visibility: visible; animation-duration: 1s; animation-delay: 0.3s; animation-name: fadeInDown;">Завершение</h2>
			<p class="text-center wow fadeInDown" style="margin-bottom:30px;">Ваш логин для входа: <b class="clr_vlow">admin</b>. Укажите пожалуйста свой пароль</p>
			<div class="container wow fadeInDown" data-wow-duration="1.0s" data-wow-delay="0.0s" data-wow-offset="0">
				<div class="row">
					<div class="col-lg-6 col-lg-offset-3">
						<div class="panel panel-default" <? if($nCRMusername == '' or $nCRMuserphone == '' or $nCRMuseremail == '') { ?>style="border-color:#e00000;"<? } ?>>
							<div class="panel-body">
								<div class="row">
									<div class="form-group col-lg-12" style="margin-bottom: 0px;">
										<div class="input-group input-group-lg">
											<span class="input-group-addon" title="<?=Dict::_('TXTADMINPASS')?>"><i class="fa fa-fw fa-lock" aria-hidden="true"></i></span>
											<input type="password" class="form-control" name="inputCRMadminPass" value="" placeholder="<?=Dict::_('TXTADMINPASS')?>" autocomplete="disabled" required />
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-lg-3 col-lg-offset-3">
						<button class="btn btn-success btn-lg" type="submit" name="ConfirmSetup" style="width:100%;" >Сохранить настройки</button>
					</div>
					<div class="col-lg-3">
						<button class="btn btn-default btn-lg" type="button" name="SaveLic" style="width:100%;" >Скачать данные в PDF</button>
					</div>
				</div>
			</div>
			<p class="text-center wow fadeInDown" style="margin-top:30px;">Уважаемый пользователь, если вы не настраивали электронную почту у вашего хостинг-провайдера<br/>уведомление о регистрации CRM системы может не прийти на ваш e-mail<br/><br/><span class="clr_high">Рекомендуем вам сохранить данные регистрации!</span></p>
		</div>
	</div>
	</form>
	<?
		require_once(ROOT . 'templates/modal-wind.php');
	?>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/bootstrap-filestyle.min.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/bootstrap-dropdown.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.ui.min.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.ui.touch.min.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.cookie.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.nicEdit.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.maskedinput.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.pickmeup.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.tablesorter.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.tablesorter.pager.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.tipTip.min.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.scroll-to.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.fullpage.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.wow.min.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.pdfmake.min.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/jq.vfs_fonts.js"></script>
	<script type="text/javascript" src="/<? echo $folder; ?>/assets/js/fx.js"></script>

	<script>
	$(document).ready(function() {
		new WOW().init();
		$('#fullpage').fullpage({
			anchors: ['home', 'info', 'hello', 'rules', 'end'],
			navigation: true,
			navigationPosition: 'right',
			navigationTooltips: ['В начало', 'Добро пожаловать', 'Знакомство', 'Условия использования', 'Завершение'],
			scrollBar:true,
			responsiveWidth: 1100
		});
		$('.notice').each(function(){
			$(this).fadeIn(700).css('right','0px');
			setTimeout( "$('.notice').fadeOut(700).css('right','-500px');" , 5000 );
		});
		$('.notice_er').each(function(){
			$(this).fadeIn(700).css('right','0px');
			setTimeout( "$('.notice_er').fadeOut(700).css('right','-500px');" , 10000 );
		});
	});
	</script>
	<script>
		function checksn(){
			var fd 		= new FormData();
			var snum 	= $("input[name=inputCRMsn]").val();
			var domain 	= document.location.hostname;
			var word 	= $("input[name=inputCRMword]").val();
			var name 	= $("input[name=inputCRMuname]").val();
			var phone 	= $("input[name=inputCRMuphone]").val();
			var email 	= $("input[name=inputCRMumail]").val();
			fd.append('sn', 	snum);
			fd.append('domain', domain);
			fd.append('word', 	word);
			fd.append('name', 	name);
			fd.append('phone', 	phone);
			fd.append('email', 	email);
			$.ajax({
				url: 'https://muststyle.ru/_workbox/wb_check_new.php',
				type: 'POST',                        
				data: fd,
				contentType: false,
				processData: false,
				beforeSend: function(){},
				success: function(response) {
					var result = JSON.parse(response);
					$("input[name=inputCRMuname]").val(result.user);
					$("input[name=inputCRMuphone]").val(result.phone);
					$("input[name=inputCRMumail]").val(result.email);
					$("input[name=inputCRMword]").val(result.word);
					$("input[name=inputCRMsn]").val(result.sn);
					$("input[name=inputCRMdate]").val(result.date);
					if(result.status == "ok"){
						$("#result").html(result.status_txt).fadeIn(800).css('color','#1da71d');
						$("input[name=inputCRMsn]").parent().children('.input-group-addon').css('color','rgba(63,163,63, 1.0)');
						$("button[name=RequestSN]").attr('class','btn btn-success btn-lg').html('Лицензия WORKBox CRM получена');
						$("input[name=inputCRMword], input[name=inputCRMuphone], input[name=inputCRMumail]").attr('readonly','readonly');
						userrule();
					} else {
						$("#result").html(result.status_txt).fadeIn(800).css('color','#e00000');
						$("input[name=inputCRMsn]").parent().children('.input-group-addon').css('color','#e00000');
						$("input[name=inputCRMsn]").removeAttr('readonly','');
					}
					
				},
				error: function(xhr) {
					
				}
			});
		}
		$('button[name=RequestSN]').click(function(){
			checksn();
		});
		$('button[name=SaveLic]').click(function(){
			var sn = $('input[name="inputCRMsn"]').val();
			var pass = $('input[name="inputCRMadminPass"]').val();
			var word = $('input[name="inputCRMword"]').val();
			
			var docDefinition = {
				pageSize: "A5",
				pageOrientation: "landscape",
				pageMargins: [ 40, 40, 40, 40 ],
				content: [
					{ text: "<?php echo $CRMnameFull;?>", style: "header" },
					{ text: "Поздравляем, Вы успешно зарегистрировали <?php echo $CRMnameFull;?>", style: "center", margin: [0, 20, 0, 5]},
					{ text: "Ссылка для входа: <?php echo $wb_url;?>", style: "link", margin: [0, 5, 0, 30]},
					{ columns: [
							{text: "Данные входа Администратора:", style: "text", margin: [0, 5, 0, 15]},
							{text: "Данные регистрации системы:", style: "text", margin: [0, 5, 0, 15]}
						]},
					{ columns: [
							{text: "Логин: admin", style: "text", margin: [0, 5, 0, 5]},
							{text: "Серийный номер: " + sn, style: "text", margin: [0, 5, 0, 5]}
						]},
					{ columns: [
							{text: "Пароль: " + pass, style: "text", margin: [0, 5, 0, 5]},
							{text: "Кодовое слово: " + word, style: "text", margin: [0, 5, 0, 5]}
						]},
					{ text: "Внимание! Никому не передавайте данные регистрации!", style: "warning", margin: [0, 30, 0, 5]},
					{ text: "https://muststyle.ru/workbox", style: "link", margin: [0, 30, 0, 0]}
				],
				styles: {
					header: {
						fontSize: 26,
						bold: true,
						alignment: "center"
					},
					bold: {
						bold: true,
					},
					center: {
						alignment: "center"
					},
					text: {
						alignment: "left"
					},
					warning: {
						color:"#e00000",
						bold: true,
						alignment: "center"
					},
					link: {
						color:"#337ab7",
						alignment: "center"
					}
				}
			}
			pdfMake.createPdf(docDefinition).download("WORKBox CRM Login.pdf");
		});
	</script>
    </body>
</html>