<form method="POST" name="crm-settings" autocomplete="off" enctype="multipart/form-data" class="form-horisontal" style="display: block;">
	<div class="row">
		<div class="col-lg-4">
		
			<h3><?=Dict::_('TTLCRMGROUPS')?></h3>
			<div class="panel panel-default">
				<div class="panel-body" style="padding-bottom: 0px;">
					<div class="row">
						<div class="form-group col-lg-12">
							<input type="checkbox" name="inputCRMureg" value="on" id="inputCRMureg" /><label for="inputCRMureg"><?=Dict::_('TXTUREG1')?></label>
							<hr style="margin:20px 0 7px 0;"/>
						</div>
						<div class="form-group col-lg-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTGROUPS01')?>"><i class="fa fa-fw fa-user clr_high" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMgradm" value="<? echo $nCRMgradmin; ?>" placeholder="<?=Dict::_('TXTGROUPS1')?>" required />
							</div>
						</div>
						<div class="form-group col-lg-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTGROUPS02')?>"><i class="fa fa-fw fa-user clr_medium" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMgrman" value="<? echo $nCRMgrmanager; ?>" placeholder="<?=Dict::_('TXTGROUPS2')?>" required />
							</div>
						</div>
						<div class="form-group col-lg-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTGROUPS03')?>"><i class="fa fa-fw fa-user clr_vlow" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMgrusr" value="<? echo $nCRMgruser; ?>" placeholder="<?=Dict::_('TXTGROUPS3')?>" required />
							</div>
						</div>
						<div class="form-group col-lg-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTGROUPS04')?>"><i class="fa fa-fw fa-user clr_none" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMgrgue" value="<? echo $nCRMgrguest; ?>" placeholder="<?=Dict::_('TXTGROUPS4')?>" required />
							</div>
						</div>
					</div>
				</div>
			</div>
			
		</div>
		<div class="col-lg-4">
			
			<h3><?=Dict::_('TTLCRMLOAD')?></h3>
			<div class="panel panel-default">
				<div class="panel-body" style="padding-bottom: 0px;">
					<div class="row">
						<div class="form-group col-lg-12">
							<div class="row">
								<div class="form-group col-lg-12">
									<input type="checkbox" name="inputCRMload" value="on" id="inputCRMload" /><label for="inputCRMload"><?=Dict::_('TXTLOAD1')?></label>
									<hr style="margin:20px 0 7px 0;"/>
								</div>
								<div class="form-group col-lg-12  col-xs-12">
									<div class="input-group">
										<span class="input-group-addon" title="Макс. вес файла"><i class="fa fa-fw fa-cube" aria-hidden="true"></i></span>
										<input type="text" class="form-control" name="inputCRMfilesize" value="<? echo $nCRMfilesize; ?>" placeholder="вес файла, например, 20" required />
										<span class="input-group-addon">Мегабайт</span>
									</div>
									<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Максимальный вес загружаемого файла указывайте в мегабайтах, целым числом. Значение веса файла в настройках хостинга должно превышать значение в настройках WORKBox CRM.</small></p>
								</div>
								<div class="form-group col-lg-12  col-xs-12" style="margin-bottom: 0px;">
									<div class="input-group">
										<span class="input-group-addon" title="Допустимые форматы, через запятую, без пробелов"><i class="fa fa-fw fa-tag" aria-hidden="true"></i></span>
										<input type="text" class="form-control" name="inputCRMfiletype" value="<? echo $nCRMfiletype; ?>" placeholder="формат, например, jpg,pdf,doc,gif" required />
									</div>
									<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Расширения файлов допустимых для загрузки указывайте через запятую, без пробелов.</small></p>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

		</div>
		<div class="col-lg-4">

			<h3><?=Dict::_('TTLCRMDEALACC')?></h3>
			<div class="panel panel-default">
				<div class="panel-body">
					<div id="dealacc" style="width:100%;height:222px;overflow:auto;">
						<?
						$dom 		= new DOMDocument;
						$dom		->load($baseU);
						$xpath 		= new DOMXPath($dom);
						$guests 	= $xpath->query('/users/user[@group="guest"]');
						$users 		= $xpath->query('/users/user[@group="user"]');
						$managers 	= $xpath->query('/users/user[@group="manager"]');
						$admins 	= $xpath->query('/users/user[@group="admin"]');
						
						if($admins->length > 0){
							echo $nCRMgradmin.':<hr/>';
							foreach ($admins as $item) {
								$UserID 		= $item->getAttribute('id');
								$UserSurName 	= $item->getElementsByTagName("usersurname")->item(0)->nodeValue;
								$UserName 		= $item->getElementsByTagName("username")->item(0)->nodeValue;
								$UserLogin 		= $item->getAttribute('login');
								echo '<div><input type="checkbox" id="d-acc-'.$UserID.'" name="dealacc[]" value="'.$UserLogin.'"><label for="d-acc-'.$UserID.'">'.$UserName.' '.$UserSurName.'</label></div>';
							}
						}
						
						if($managers->length > 0){
							echo '<hr/>'.$nCRMgrmanager.':<hr/>';
							foreach ($managers as $item) {
								$UserID 		= $item->getAttribute('id');
								$UserSurName 	= $item->getElementsByTagName("usersurname")->item(0)->nodeValue;
								$UserName 		= $item->getElementsByTagName("username")->item(0)->nodeValue;
								$UserLogin 		= $item->getAttribute('login');
								echo '<div><input type="checkbox" id="d-acc-'.$UserID.'" name="dealacc[]" value="'.$UserLogin.'"><label for="d-acc-'.$UserID.'">'.$UserName.' '.$UserSurName.'</label></div>';
							}
						}
						
						if($users->length > 0){
							echo '<hr/>'.$nCRMgruser.':<hr/>';
							foreach ($users as $item) {
								$UserID 		= $item->getAttribute('id');
								$UserSurName 	= $item->getElementsByTagName("usersurname")->item(0)->nodeValue;
								$UserName 		= $item->getElementsByTagName("username")->item(0)->nodeValue;
								$UserLogin 		= $item->getAttribute('login');
								echo '<div><input type="checkbox" id="d-acc-'.$UserID.'" name="dealacc[]" value="'.$UserLogin.'"><label for="d-acc-'.$UserID.'">'.$UserName.' '.$UserSurName.'</label></div>';
							}
						}
						
						if($guests->length > 0){
							echo '<hr/>'.$nCRMgrguest.':<hr/>';
							foreach ($guests as $item) {
								$UserID 		= $item->getAttribute('id');
								$UserSurName 	= $item->getElementsByTagName("usersurname")->item(0)->nodeValue;
								$UserName 		= $item->getElementsByTagName("username")->item(0)->nodeValue;
								$UserLogin 		= $item->getAttribute('login');
								echo '<div><input type="checkbox" id="d-acc-'.$UserID.'" name="dealacc[]" value="'.$UserLogin.'"><label for="d-acc-'.$UserID.'">'.$UserName.' '.$UserSurName.'</label></div>';
							}
						}
						?>
					</div>
					<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Все выбранные из списка пользователи получат доступ к разделам "Сделки и предложения", "Платежи", "Статистика компании".</small></p>
				</div>
			</div>
			
		</div>
	</div>
	
	<div class="row">
		<div class="col-lg-4">
		
			<h3><?=Dict::_('TTLCRMDEALS')?></h3>
			<div class="panel panel-default">
				<div class="panel-body" style="padding-bottom: 0px;">
					<div class="row">
						<div class="form-group col-lg-12  col-xs-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('OFFERS')?>"><i class="fa fa-fw fa-file-text-o" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMoffer" value="<? echo $nCRMoffers; ?>" placeholder="<?=Dict::_('TXTDEALS2')?>" required />
							</div>
							<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Префикс номеров Коммерческих предложений</small></p>
							<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Пример: КП 2203151</small></p>
						</div>
						<div class="form-group col-lg-12  col-xs-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('DEALS')?>"><i class="fa fa-fw fa-briefcase" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMdeal" value="<? echo $nCRMdeals; ?>" placeholder="<?=Dict::_('TXTDEALS1')?>" required />
							</div>
							<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Префикс номеров Заключенных сделок</small></p>
							<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Пример: ТЗ 2202161</small></p>
						</div>
					</div>
				</div>
			</div>
			
		</div>
		<div class="col-lg-4">
		
			<h3><?=Dict::_('TTLCRMMAIL')?></h3>
			<div class="panel panel-default">
				<div class="panel-body" style="padding-bottom: 0px;">
					<div class="row">
						<div class="form-group col-lg-12">
							<input type="checkbox" name="inputCRMmailstat" value="on" id="inputCRMmailstat" /><label for="inputCRMmailstat"><?=Dict::_('TXTCRMMAIL05')?></label>
							<p style="line-height:15px;margin:5px 0 0;color:#999;"><small>Перед включением PHPmailer убедитесь что ваш хостинг-провайдер поддерживает данную возможность. При использовании собственного локального сервера включите PHPmailer и укажите данные для подключения к действующему почтовому ящику.</small></p>
							<hr style="margin:20px 0 5px 0;"/>
						</div>
						<div class="form-group col-lg-7">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTCRMMAIL01')?>"><i class="fa fa-fw fa-server" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMmailhost" value="<? echo $nCRMmailhost; ?>" placeholder="<?=Dict::_('TXTCRMMAIL01')?>" />
							</div>
						</div>
						<div class="form-group col-lg-5">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTCRMMAIL02')?>"><i class="fa fa-fw fa-sitemap" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMmailport" value="<? echo $nCRMmailport; ?>" placeholder="<?=Dict::_('TXTCRMMAIL02')?>" />
							</div>
						</div>
						<div class="form-group col-lg-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTCRMMAIL03')?>"><i class="fa fa-fw fa-user" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMmailname" value="<? echo $nCRMmailname; ?>" placeholder="<?=Dict::_('TXTCRMMAIL03')?>" />
							</div>
						</div>
						<div class="form-group col-lg-12">
							<div class="input-group">
								<span class="input-group-addon" title="<?=Dict::_('TXTCRMMAIL04')?>"><i class="fa fa-fw fa-unlock-alt" aria-hidden="true"></i></span>
								<input type="text" class="form-control" name="inputCRMmailpass" value="<? echo $nCRMmailpass; ?>" placeholder="<?=Dict::_('TXTCRMMAIL04')?>" />
							</div>
						</div>
					</div>
				</div>
			</div>
			
		</div>
		<div class="col-lg-4">

			<h3><?=Dict::_('TTLCRMTHEME')?></h3>
			<div class="panel panel-default">
				<div class="panel-body" style="padding-bottom: 0px;">
					<div class="row">
						<div class="form-group col-lg-12">
							<input type="checkbox" name="inputCRMutheme" value="on" id="inputCRMutheme" /><label for="inputCRMutheme"><?=Dict::_('TXTUDESIGN')?></label>
							<hr style="margin:20px 0 5px 0;"/>
						</div>
						<div class="form-group col-lg-12">
							<input type="radio" name="inputCRMtheme" value="light" id="inputCRMtheme1" /><label for="inputCRMtheme1"><?=Dict::_('TXTDESIGN1')?></label>
						</div>
						<div class="form-group col-lg-12">
							<input type="radio" name="inputCRMtheme" value="dark" id="inputCRMtheme2" /><label for="inputCRMtheme2"><?=Dict::_('TXTDESIGN2')?></label>
							<hr style="margin:20px 0 5px 0;"/>
						</div>
						<div class="form-group col-lg-12">
							<input type="radio" name="inputCRMview" value="standart" id="inputCRMview1" /><label for="inputCRMview1"><?=Dict::_('TXTVIEW1')?></label>
						</div>
						<div class="form-group col-lg-12">
							<input type="radio" name="inputCRMview" value="widescreen" id="inputCRMview2" /><label for="inputCRMview2"><?=Dict::_('TXTVIEW2')?></label>
						</div>
					</div>
				</div>
			</div>
			
		</div>
	</div>
	
	<hr style="margin:10px 0 30px 0;"/>
	
	<div class="row">
		<div class="col-lg-4">
			<div class="input-group input-group-lg" style="width:auto;margin:0px 0px 20px 0px;">
				<span class="input-group-addon"><i class="fa fa-fw fa-save" aria-hidden="true"></i></span>
				<div class="input-group-btn" style="width:100%;"><button class="btn btn-lg btn-block btn-success" type="submit" name="SettingsSave" style="height:46px;"><?=Dict::_('SAVE')?></button></div>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript">
	$(document).ready(function() {
		var dealacc = "<?php echo $nCRMdealaccess; ?>";
		var accarr 	= dealacc.split(",");
		$.each(accarr,function(index,value){
			$('#dealacc input[value="'+value+'"]').attr("checked", "checked");
		});
		$('input[name="inputCRMmailstat"]').click(function(){
			if($('input[name="inputCRMmailstat"]').is(':checked')){
				$('input[name="inputCRMmailhost"]').attr('required', 'required');
				$('input[name="inputCRMmailport"]').attr('required', 'required');
				$('input[name="inputCRMmailname"]').attr('required', 'required');
				$('input[name="inputCRMmailpass"]').attr('required', 'required');
			} else {
				$('input[name="inputCRMmailhost"]').removeAttr('required');
				$('input[name="inputCRMmailport"]').removeAttr('required');
				$('input[name="inputCRMmailname"]').removeAttr('required');
				$('input[name="inputCRMmailpass"]').removeAttr('required');
			}
		});
		<?php if($nCRMureg == 'on'){ ?>
		$('#inputCRMureg').attr("checked", "checked");
		<?php } ?>
		<?php if($nCRMloadfile == 'on'){ ?>
		$('#inputCRMload').attr("checked", "checked");
		<?php } ?>
		<?php if($nCRMutheme == 'on'){ ?>
		$('#inputCRMutheme').attr("checked", "checked");
		<?php } ?>
		<?php if($nCRMmailstat == 'on'){ ?>
		$('#inputCRMmailstat').attr("checked", "checked");
		<?php } ?>
		$('input[name="inputCRMview"][value="<?php echo $nCRMdesignview; ?>"]').prop('checked', true);
		$('input[name="inputCRMtheme"][value="<?php echo $nCRMdesigntheme; ?>"]').prop('checked', true);
	});
</script>