<?
if(isset($_GET['edit'])) {
	$dom = new DOMDocument;
	$dom->load(ROOT . 'crmdata/database/notebooks/notebook-' . $LoginCheck . '.xml');
	$xpath = new DOMXPath($dom);
	$notes = $xpath->query('/notes/note[@id="'.$_GET['edit'].'"]');
	foreach ($notes as $note) {
		$NoteId 		= $note->getAttribute('id');
		$NoteName		= $note->getElementsByTagName("notename")->item(0)->nodeValue;
		$NoteDescr		= $note->getElementsByTagName("notedescr")->item(0)->nodeValue;
	}
}
?>
<div class="col-lg-12 col-md-12 col-sm-12">
	<form method="POST" name="form_user" id="formedit" enctype="multipart/form-data">
		<div class="row" style="margin-top:15px;">
			<div class="col-lg-9 col-xs-8">
				<h1><a href="javascript: ;" onclick="history.go(-2)"><i class="fa fa-fw fa-angle-double-left" aria-hidden="true" title="Вернуться к списку"></i></a> 
				<?php if(isset($_GET['new-note'])) {?>Добавление <span class="hidden-xs">заметки</span><?php } ?>
				<?php if(isset($_GET['edit'])) {?>Редактирование <span class="hidden-xs">заметки</span><?php } ?>
				</h1>
			</div>
			<div class="col-lg-3 col-xs-4">
				<div class="btn-group btn-fixed" style="float:right;">
					<?php if(isset($_GET['new-note'])) {?>
					<button type="submit" name="NoteAdd" class="btn btn-md btn-info" style="color:#fff;"><span class="hidden-lg hidden-md hidden-sm"><i class="fa fa-fw fa-plus" aria-hidden="true"></i></span><span class="hidden-xs">Добавить</span></button>
					<?php } ?>
					<?php if(isset($_GET['edit'])) {?>
					<a href="/<?php echo $folder; ?>/notes/?view=<?php echo $NoteId; ?>" class="btn btn-md btn-default"><span class="hidden-lg hidden-md hidden-sm"><i class="fa fa-fw fa-eye" aria-hidden="true"></i></span><span class="hidden-xs">Просмотр</span></a>
					<button type="submit" name="NoteEdit" class="btn btn-md btn-info" style="color:#fff;"><span class="hidden-lg hidden-md hidden-sm"><i class="fa fa-fw fa-save" aria-hidden="true"></i></span><span class="hidden-xs">Сохранить</span></button>
					<?php } ?>
				</div>
			</div>	
		</div>
		<div class="row" style="margin-top:0px;">
			<div class="form-group col-lg-12">
				<div class="input-group">
					<span class="input-group-addon" title="Название заметки"><i class="fa fa-fw fa-file-text-o" aria-hidden="true"></i></span>
					<input type="text" class="form-control" name="inputName" placeholder="Название заметки" value="<?php if(isset($NoteName)){echo $NoteName;} ?>" maxlength="150" required>
				</div>
				<input type="text" class="hidden" name="inputId" value="<?php echo $NoteId; ?>">
			</div>
			<div class="form-group col-lg-12 editor-form" style="width: 100%!important;">
				<textarea class="form-control " name="inputComment" id="inputComment" rows="10" cols="80" placeholder="Текст заметки"><?php if(isset($NoteDescr)){echo $NoteDescr;} ?></textarea>
			</div>
		</div>
	</form>
</div>
<?php if(isset($_GET['edit'])) {?>
	<script type="text/javascript">
		$(document).ready(function() {
			$('form[name=form_user] select[name=selectGroup]').val('<?php echo $Group;?>');
		});
	</script>
<?php } ?>