Your IP : 216.73.216.48


Current Path : /hdd/hdd11/www/vlevski/enter/zk/
Upload File :
Current File : /hdd/hdd11/www/vlevski/enter/zk/index.php

<?php
	session_start();
	if (($_SESSION["acc"]==6) || ($_SESSION["acc"]==9))
	{
		$tnr=$_SESSION["tname"];
		$tn=explode(" ", $_SESSION["tname"]);
		$tfn=mb_substr($tn[0], 0, 1);
		$tln=mb_substr($tn[1], 0, 1);
		$uin="".$tfn."".$tln."";
	}
	else
	{
		header("location: /");
	}
	include("../conn.php");
	if (isset($_POST["adt"]))
	{
		$adt=$_POST["adt"];
		$adt=str_replace("  ", " ", $adt);
		$adt=str_replace("  ", " ", $adt);
		$adt=str_replace("  ", " ", $adt);
		$adt=str_replace("  ", " ", $adt);
		$adt=str_replace("  ", " ", $adt);
		$adt=str_replace("__ ", "__", $adt);
		$adt=str_replace("__ ", "__", $adt);
		$adt=str_replace("__ ", "__", $adt);
		$adt=str_replace("__ ", "__", $adt);
		$adt=str_replace("__ ", "__", $adt);
		$adt=str_replace(" __", "__", $adt);
		$adt=str_replace(" __", "__", $adt);
		$adt=str_replace(" __", "__", $adt);
		$adt=str_replace(" __", "__", $adt);
		$adt=str_replace(" __", "__", $adt);
		$allt=$adt;
		$adt=explode("__", $adt);
		$tm=time();
		$sql=mysqli_query($db, "INSERT INTO `doczk` (`i`, `n`, `d`, `a`, `f`, `t`, `m`) VALUES (NULL, '".$adt[2]."', '".$tm."', '".$adt[0]."', '".$adt[1]."', '".$allt."', '1');");
	}
	if (isset($_POST["edt"]))
	{
		$edt=$_POST["edt"];
		$edt=str_replace("  ", " ", $edt);
		$edt=str_replace("  ", " ", $edt);
		$edt=str_replace("  ", " ", $edt);
		$edt=str_replace("  ", " ", $edt);
		$edt=str_replace("  ", " ", $edt);
		$edt=str_replace("__ ", "__", $edt);
		$edt=str_replace("__ ", "__", $edt);
		$edt=str_replace("__ ", "__", $edt);
		$edt=str_replace("__ ", "__", $edt);
		$edt=str_replace("__ ", "__", $edt);
		$edt=str_replace(" __", "__", $edt);
		$edt=str_replace(" __", "__", $edt);
		$edt=str_replace(" __", "__", $edt);
		$edt=str_replace(" __", "__", $edt);
		$edt=str_replace(" __", "__", $edt);
		$allt=$edt;
		$edt=explode("__", $edt);
		$tm=time();
		$ne=mysqli_query($db, "SELECT `m` FROM `doczk` WHERE `n`='".$edt[2]."' ORDER by `m` DESC LIMIT 1");
		while ($res=mysqli_fetch_row($ne))
		{
			$fn=$res[0];
		}
		$fn++;
		$sql=mysqli_query($db, "INSERT INTO `doczk` (`i`, `n`, `d`, `a`, `f`, `t`, `m`) VALUES (NULL, '".$edt[2]."', '".$tm."', '".$edt[0]."', '".$edt[1]."', '".$allt."', '".$fn."');");
	}
	if (isset($_POST["delt"]))
	{
		$delt=$_POST["delt"];
		$fd=mysqli_query($db, "SELECT * FROM `doczk` WHERE `i`='".$delt."' LIMIT 1");
		while ($res=mysqli_fetch_row($fd))
		{
			$n=$res[1];
			$a=$res[3];
		}
		$sql=mysqli_query($db, "UPDATE `doczk` SET `m`='0' WHERE `n`='".$n."';");		
	}
	date_default_timezone_set("Europe/Sofia");
	$cd=date("d.m.Y", time());
?><!DOCTYPE HTML>
<html lang="bg">
	<head>
		<meta charset="utf-8" />
		<title>Заповедна книга</title>
		<link rel="shortcut icon" type="image/png" href="/assets/images/site/enter.png" />
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
		<link rel="stylesheet" href="/assets/css/select2.min.css" />
		<link rel="stylesheet" href="/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="/assets/css/datepicker.css" />
		<script src="/assets/js/jquery.min.js"></script>
		<script src="/assets/js/form.min.js"></script>
		<script src="/assets/js/select.min.js"></script>
		<script src="/assets/js/popper.min.js"></script>
		<script src="/assets/js/bootstrap.min.js"></script>
		<script src="/assets/js/bootstrap-datepicker.js"></script>
		<script src="/assets/js/jquery.dataTables.min.js"></script>
		<script src="/assets/js/dataTables.bootstrap4.min.js"></script>
		<script src="/assets/fa6/js/all.min.js" defer></script>
		<script>
			delid=0;
			function uplf(id,n)
			{
				$("#fnm").val(id);
				$("#mupl").modal("show");
				$("#muplt").html("<i class=\"fas fa-paperclip\"></i> Добавяне на файл към зап. №"+n+"");
			}
			function ade()
			{
				$("#madd").modal("show");
			}
			function dl(id,n)
			{
				delid=id;
				$("#mdel").modal("show");
				$("#mdelt").html("<i class=\"fas fa-trash\"></i> Изтривате ли зап. №"+n+"?");
			}
			function dln()
			{
				if (delid!=0)
				{
					$("#delt").val(delid);
					$("#delfrm").submit();
				}
			}
			function s(id, n)
			{
				$("#msf").modal("show");
				$("#msft").html("<i class=\"fas fa-file-pdf\"></i> Преглед на файла към зап. №"+n+"");
				$("#ise").html("<object id=\"isfo"+id+"\" name=\"isfo"+id+"\" data=\"./s.php?i="+id+"#view=FitH&toolbar=0\" type=\"application/pdf\" style=\"position: relative; width: 100%; min-height: "+ah+"px; height: "+ah+"px; boder: none;\"></object>");
				$("#isf").html("<button type=\"button\" class=\"btn btn-success\" style=\"font-size: 20px; font-weight: bold; font-style: italic;\" onclick=\"window.open('./s.php?i="+id+"#view=FitH', '_blank'); return true;\"><i class=\"fas fa-external-link-alt\"></i> Отвори в нов прозорец</button>");
			}
			function entrs(event)
			{
				if ((event.keyCode==13) || (event.keyCode==13 && event.shiftKey))
				{
					event.preventDefault();
					return false;
				}
			}
			function svr()
			{
				var i=1;
				var dt="<?php print("".$uin."__".$tnr.""); ?>";
				var n="";
				var err=0;
				while (i<=4)
				{
					eval('n=$("#v'+i+'").val().trim();');
					if (n=="")
					{
						err=1;
					}
					dt+="__"+n;
					i++;
				}
				n=$("#v5").html().trim();
				dt+="__"+n;
				if (n=="")
				{
					err=1;
				}
				if (err==1)
				{
					$("#mfill").modal("show");
				}
				else
				{
					$("#adt").val(dt);
					$("#addnew").submit();
				}
			}
			function sv()
			{
				var id=$("#v1").val().trim();
				$.ajax({url: "./e.php", type: "POST", data:{"id": ""+id+""}, success: function(data) { if (data!="ERR") { setTimeout(function() { svr(); }, 100); } else { $("#mtkn").modal("show"); } } });
			}
			function sve()
			{
				var i=1;
				var dt="<?php print("".$uin."__".$tnr.""); ?>";
				var n="";
				var err=0;
				while (i<=4)
				{
					eval('n=$("#e'+i+'").val().trim();');
					if (n=="")
					{
						err=1;
					}
					dt+="__"+n;
					i++;
				}
				n=$("#e5").text().trim();
				dt+="__"+n;
				if (n=="")
				{
					err=1;
				}
				if (err==1)
				{
					$("#mfill").modal("show");
				}
				else
				{
					$("#edt").val(dt);
					$("#ednew").submit();
				}
			}
			function edt(d)
			{
				$("#med").modal("show");
				var f=d.split("__");
				$("#e1").val(f[2]);
				$("#d1").html(f[2]);
				$("#e2").val(f[3]);
				$("#e3").val(f[4]);
				$("#e3").trigger("change");
				$("#e4").val(f[5]);
				$("#e5").html(f[6]);
			}
			function ed(id)
			{
				$.ajax({url: "./r.php", type: "POST", data:{"id": ""+id+""}, success: function(data) { if (data!="ERR") { setTimeout(function() { edt(data); }, 100); } else { uplerr(); } } });
			}
			function uplok()
			{
				$("#mww").modal("hide");
				window.open("./", "_self");
			}
			function uplerr()
			{
				$("#merr").modal("show");
				$("#merrb").html("Нещо се обърка!<br />Презаредете страницата<br />и опитайте отново!");
			}
			function uplem()
			{
				$("#merr").modal("show");
				$("#merrb").html("Файлът е празен!<br />Презаредете страницата<br />и опитайте отново!");
			}
			var fSize=25000000;
			function chr()
			{
				var err=0;
				var upl=document.getElementById("upf").value;
				if (upl=="")
				{
					$("#merr").modal("show");
					$("#merrb").html("Не сте избрали файл!<br />Презаредете страницата<br />и опитайте отново!");
					err++;
				}
				else if (fSize>=25000000)
				{
					$("#merr").modal("show");
					$("#merrb").html("Файлът не може да е по-голям от 25МB!<br />Презаредете страницата<br />и опитайте отново!");
					err++;
				}
				else if (fSize==0)
				{
					$("#merr").modal("show");
					$("#merrb").html("Файлът е празен!<br />Презаредете страницата<br />и опитайте отново!");
					err++;
				}
				if (err==0)
				{
					$("#mww").modal("show");
					setTimeout(function(){ $("#frm").submit(); }, 1500);
				}
			}
			function s(id, n)
			{
				$("#msf").modal("show");
				$("#msft").html("<i class=\"fas fa-file-pdf\"></i> Преглед на файла към зап. №"+n+"");
				$("#ise").html("<object id=\"isfo"+id+"\" name=\"isfo"+id+"\" data=\"./s.php?i="+id+"#view=FitH&toolbar=0\" type=\"application/pdf\" style=\"position: relative; width: 100%; min-height: "+ah+"px; height: "+ah+"px; boder: none;\"></object>");
				$("#isf").html("<button type=\"button\" class=\"btn btn-success\" style=\"font-size: 20px; font-weight: bold; font-style: italic;\" onclick=\"window.open('./s.php?i="+id+"#view=FitH', '_blank'); return true;\"><i class=\"fas fa-external-link-alt\"></i> Отвори в нов прозорец</button>");
			}
			function chu()
			{
				$("#mupl").modal("hide");
				setTimeout(function(){ chr(); }, 500);
			}
			function uploadFill()
			{
				fSize=document.getElementById("upf").files[0].size;
				var upl=$("#upf").val();
				upl=upl.replace("C:\\fakepath\\","");
				$("#chf").val(upl);
			}
			$(document).ready(function()
			{
				$("#ttbl").DataTable({ "order": [[ 0, "desc" ]], searching: false, paging: false, info: false });
				$("#srch").on("keyup", function()
				{
					var value=$(this).val().toLowerCase();
					$("#stbl tr").filter(function()
					{
						$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
					}).css("display", "none");
				});
				$("#v3").select2({ width: "100%", dropdownParent: $("#madd") });
				$("#v2").datepicker();
				$("#e3").select2({ width: "100%", dropdownParent: $("#med") });
				$("#e2").datepicker();
				$('#frm').submit(function(e)
				{
					if($('#upf').val())
					{
						e.preventDefault();
						$(this).ajaxSubmit(
						{
							target: "#uplret",
							beforeSubmit: function()
							{
								$("#progress-bar").width("0px");
							},
							uploadProgress: function (event, position, total, percentComplete)
							{
								wdth=Math.round(percentComplete/100*269);
								$("#status-p").html(percentComplete+"%");
								$("#progress-bar").width(wdth + "px");
								$("#progress-bar").html("");
							},
							success:function ()
							{
							},
							resetForm: true
						});
						return false; 
					}
				});
			});
			ah=window.screen.availHeight;
			ah-=440;
		</script>
		<style>
			html, body
			{
				background-color: #112233;
			}
			strong
			{
				font-weight: bold;
				color: #DDDDDD;
				font-size: 25px;
			}
			a, div, input
			{
				font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
			}
			th
			{
				cursor: pointer;
			}
			a.dropdown-item
			{
				color: #DDDDDD!important;
			}
			a.dropdown-item:hover
			{
				color: #FFFFFF!important;
				background-color: transparent!important;
			}
			.dropdown .dropdown-menu
			{
				-webkit-transition: all 0.5s;
				-moz-transition: all 0.5s;
				-ms-transition: all 0.5s;
				-o-transition: all 0.5s;
				transition: all 0.5s;
				max-height: 0;
				display: block;
				overflow: hidden;
				opacity: 0;
			}
			.dropdown.show .dropdown-menu
			{
				max-height: 300px;
				opacity: 1;
			}
			.select2-search, .select2-search input, .select2-results, .select2-container--default .select2-selection--single, .select2-selection__rendered
			{
				background-color: #112233!important;
				color: #999911!important;
				font-weight: bold!important;
				min-height: 35px!important;
				line-height: 35px!important;
				font-size: 25px!important;
			}
			.datepicker
			{
				z-index: 1600!important;
				background-color: #112233!important;
				color: #999911!important;
				border: none;
			}
			::-webkit-scrollbar
			{
				width: 10px;
			}
			::-webkit-scrollbar-track
			{
				background-color: #116633;
			}
			::-webkit-scrollbar-thumb
			{
				background-color: #BBBB33;
				border-radius: 5px;
			}
		</style>
	</head>
	<body>
		<iframe id="frms" name="frms" src="about:blank" style="position: absolute; top: 0px; left: 0px; border: none; frameborder: none; width: 0px; height: 0px; overflow: hidden; z-index: 1;"></iframe>
		<div style="position: fixed; top: 150px;" class="modal fade" id="msf" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="swf" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 95%;">	
				<div class="modal-dialog modal-lg" style="width: 95%;">
					<div class="modal-content">
						<div class="modal-header">
							<h5 class="modal-title" style="font-weight: bold; color: #112233; font-size: 30px;" id="msft">
							</h5>
							<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
								<span aria-hidden="true" style="color: #112233;">&times;</span>
							</button>
						</div>
						<script>
							document.write("<div class=\"modal-body\" style=\"min-height: "+ah+"px; font-size: 30px; font-weight: bold; overflow-y: auto;\">");
							document.write("<div id=\"ise\" style=\"position: relative; width: 100%; min-height: "+ah+"px; height: "+ah+"px; boder: none;\"></div>");
						</script>
						</div>
						<div id="isf" class="modal-footer">
						</div>
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 150px;" class="modal fade" id="merr" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="merr" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="margin-top: 110px; width: 95%;">
				<div class="modal-content" style="background-color: #FFFF44;">
					<div class="modal-header">
						<h5 style="font-size: 30px; font-weight: bold;" class="modal-title" id="merrt">
							<i class="fas fa-info-circle"></i> Грешка...
						</h5>
						<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
							<span aria-hidden="true" style="color: #112233;">&times;</span>
						</button>
					</div>
					<div id="merrb" style="text-align: center; font-size: 28px; font-weight: bold;" class="modal-body">
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 150px;" class="modal fade" id="mww" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="mwe" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="margin-top: 110px; width: 95%;">
				<div style="font-size: 30px; font-weight: bold;" class="modal-content" style="background-color: #FFFF44;">
					<div class="modal-header">
						<h5 class="modal-title" id="mwwt">
							<i class="fas fa-file-pdf"></i> Вашият файл се качва...
						</h5>
					</div>
					<div class="modal-body">
						<div id="mwwb" style="text-align: center; font-size: 28px; font-weight: bold;" class="modal-body">
							Моля, изчакайте...
							<br />
						</div>
						<hr />
						<center>
							<div style="position: relative; margin: 0 auto; width: 280px; height: 25px; border: none; text-align: left;">
								<div style="position: absolute; top: 0px; left: 5px; width: 180px; text-align: left; font-style: italic; font-size: 18px; z-index: 1000;">
									Статус:
								</div>
								<div id="status-p" style="position: absolute; top: 0px; left: 190px; width: 85px; text-align: right; font-weight: bold; font-size: 18px; z-index: 1000;">
									0%
								</div>
							</div>
							<div style="position: relative; margin: 0 auto; width: 280px; border-radius: 3px; height: 20px; border: 1px solid #000000; text-align: left;"><div id="progress-bar" style="margin: 5px; border-radius: 2px; background-color: #000099; height: 10px; color: #FFFFFF; width: 0px; -webkit-transition: width 0.3s; -moz-transition: width 0.3s; transition: width 0.3s;"></div>
						</center>
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 150px;" class="modal fade" id="mupl" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="mupl" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 95%;">	
				<div class="modal-dialog modal-lg" style="width: 95%;">
					<div class="modal-content">
						<div class="modal-header">
							<h5 class="modal-title" style="font-weight: bold; color: #112233; font-size: 30px;" id="muplt">
							</h5>
							<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
								<span aria-hidden="true" style="color: #112233;">&times;</span>
							</button>
						</div>
						<script>
							document.write("<div class=\"modal-body\" style=\"max-height: "+ah+"px; font-size: 30px; font-weight: bold; overflow-y: auto;\">");
						</script>
							<form id="frm" action="./upload.php" target="frms" enctype="multipart/form-data" name="frm" method="POST">
								<div id="uplret" style="position: absolute; top: 0px; left: 0px; width: 0px; height: 0px; overflow: hidden; z-index: 1000;"></div>
								<center>Моля, изберете PDF с размер до 25MB:</center>
								<br />
								<div class="input-group">
									<label style="font-size: 27px;" class="col-xs-6 col-md-4 form-control-lg form-control btn-primary">
										<i class="fas fa-file-pdf"></i> Изберете... <input id="upf" name="upf" type="file" accept="application/pdf" style="display: none;" onchange="uploadFill(); return true;" />
									</label>
									<input id="chf" style="font-size: 27px;" background-color: #112233; color: #DDDDDD;" class="col-xs-12 col-md-8 form-control-lg form-control" type="text" readonly="" />
								</div>
								<br />
								<br />
								<input type="hidden" id="fnm" name="fnm" value="">
								<button type="button" class="form-control-lg form-control btn-dark" onclick="chu(); return true;"><i class="fas fa-paperclip"></i>&nbsp;&nbsp;Качи в сървъра</button>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 200px;" class="modal fade" id="mdel" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="mdel" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 95%;">	
				<div class="modal-dialog modal-lg" style="width: 95%;">
					<div class="modal-content" style="background-image: linear-gradient(to right, rgba(255,17,17,0.85), rgba(255,17,17,1))!important;">
						<div class="modal-header">
							<h5 class="modal-title" style="font-weight: bold; color: #112233; font-size: 30px;" id="mdelt">
							</h5>
							<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
								<span aria-hidden="true" style="color: #112233;">&times;</span>
							</button>
						</div>
						<script>
							document.write("<div class=\"modal-body\" style=\"max-height: "+ah+"px; overflow-y: auto;\">");
						</script>
							<div class="row">
								<div class="col-12" style="text-align: center; margin-bottom: 10px; margin-top: 10px;">
									<strong><i>ВНИМАНИЕ:</i> Това ще изтрие
									<br />и всички направени редакции!</strong>
								</div>
							</div>
							<div class="row">
								<div class="col-6" style="margin-bottom: 20px; font-size: 25px; font-weight: bold; color: #DDDDDD; text-align: center;">
									<a style="font-size: 30px; width: 100px; text-align: left;" href="javascript:void(0);" onclick="dln();" class="btn btn-danger"><i class="fas fa-trash"></i> ДА</a>
								</div>
								<div class="col-6" style="margin-bottom: 20px; font-size: 25px; font-weight: bold; color: #DDDDDD; text-align: center;">
									<a style="font-size: 30px; width: 100px; text-align: left;" href="javascript:void(0);" class="btn btn-warning" data-dismiss="modal"><i class="fas fa-times-circle"></i> НЕ</a>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 0px;" class="modal fade" id="madd" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="madd" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 95%;">
				<div class="modal-content" style="background-image: linear-gradient(to right, rgba(17,102,51,0.85), rgba(17,102,51,1))!important;">
					<div class="modal-header">
						<h5 class="modal-title" style="font-weight: bold; color: #BBBB33; font-size: 30px;" id="maddt">
							<i class="fas fa-file-signature"></i> Добави в заповедната книга
						</h5>
						<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
							<span aria-hidden="true" style="color: #BBBB33;">&times;</span>
						</button>
					</div>
					<script>
						document.write("<div class=\"modal-body\" style=\"max-height: "+ah+"px; overflow-y: auto;\">");
					</script>
						<div class="container-fluid">
							<div class="row">
								<div class="col-7">
									<strong>Заповеден номер:</strong>
								</div>
								<div style="text-align: right;" class="col-5">
									<input type="text" placeholder="Цяло число. Например 2" id="v1" name="v1" class="form-control-lg form-control" style="background-color: #112233; color: #999911; font-size: 25px; font-weight: bold; height: 45px; line-height: 45px; margin: 0px; padding: 0px;" oninput="this.value=this.value.replace(/[^0-9]/g, '').replace(/(\..*)\./g	, '$1');" />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-7">
									<strong>Дата:</strong>
								</div>
								<div style="text-align: right;" class="col-5">
									<input type="text" placeholder="Моля, изберете дата" id="v2" name="v2" class="form-control-lg form-control datepicker" readonly="readonly" style="background-color: #112233; color: #999911; font-size: 25px; font-weight: bold; height: 45px; line-height: 45px; margin: 0px; padding: 0px;" />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<strong>Номенклатура:</strong>
								</div>
							</div>
							<div class="row">
								<div class="col-11">
									<select id="v3" name="v3" title="Моля, изберете номенклатура" class="form-control-lg form-control" style="background-color: #112233; color: #DDDDDD; font-weight: bold; height: 45px; line-height: 45px; margin: 0px; padding: 0px;">
										<option value="">Моля, изберете номенклатура</option>
										<?php
											$nq=mysqli_query($db, "SELECT * FROM `docnom` WHERE `z`='1' ORDER by `d` ASC");
											while ($res=mysqli_fetch_row($nq))
											{
												print("<option value=\"".$res[1]."\">".$res[2]." - ".$res[1]."</option>");
											}
										?>
									</select>
								</div>
								<div style="text-align: right;" class="col-1">
									<button disabled type="button" class="btn btn-warning" style="max-width: 45px; max-height: 45px; font-size: 15px; font-weight: bold; font-style: italic;"><i class="fas fa-plus-square"></i></button>
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<strong>Основание за издаване:</strong>
									<br />
									<input type="text" placeholder="Моля, въведете основание за издаване" id="v4" name="v4" class="form-control-lg form-control" style="background-color: #112233; color: #999911; font-size: 25px; font-weight: bold; height: 45px; line-height: 45px; margin: 0px; padding: 0px;" />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<strong>Относно:</strong>
									<br />
									<div id="v5" name="v5" style="background-color: #112233; color: #999911; font-size: 35px; font-weight: bold; height: 135px; line-height: 45px; margin: 0px; padding: 0px; overflow-y: auto;" contenteditable="true" onkeypress="entrs(event);"></div>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-warning" style="z-index: 2000; font-size: 20px; font-weight: bold; font-style: italic;" onclick="sv(); return true;"><i class="fas fa-save"></i> Запиши</button>
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 0px;" class="modal fade" id="med" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="med" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 95%;">
				<div class="modal-content" style="background-image: linear-gradient(to right, rgba(17,102,51,0.85), rgba(17,102,51,1))!important;">
					<div class="modal-header">
						<h5 class="modal-title" style="font-weight: bold; color: #BBBB33; font-size: 30px;" id="medt">
							<i class="fas fa-file-signature"></i> Редакция в заповедната книга
						</h5>
						<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
							<span aria-hidden="true" style="color: #BBBB33;">&times;</span>
						</button>
					</div>
					<script>
						document.write("<div class=\"modal-body\" style=\"max-height: "+ah+"px; overflow-y: auto;\">");
					</script>
						<div class="container-fluid">
							<div class="row">
								<div class="col-7">
									<strong>Номер:</strong>
								</div>
								<div style="text-align: right;" class="col-5">
									<strong><div id="d1"></div></strong><input type="hidden" id="e1" name="e1" />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-7">
									<strong>Дата:</strong>
								</div>
								<div style="text-align: right;" class="col-5">
									<input type="text" placeholder="Моля, изберете дата" id="e2" name="e2" class="form-control-lg form-control datepicker" readonly="readonly" style="background-color: #112233; color: #999911; font-size: 25px; font-weight: bold; height: 45px; line-height: 45px; margin: 0px; padding: 0px;" />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<strong>Номенклатура:</strong>
								</div>
							</div>
							<div class="row">
								<div class="col-11">
									<select id="e3" name="e3" title="Моля, изберете вид на контрола" class="form-control-lg form-control" style="background-color: #112233; color: #DDDDDD; font-weight: bold; height: 45px; line-height: 45px; margin: 0px; padding: 0px;">
										<option value="">Моля, изберете номенклатура</option>
										<?php
											$nq=mysqli_query($db, "SELECT * FROM `docnom` WHERE `z`='1' ORDER by `d` ASC");
											while ($res=mysqli_fetch_row($nq))
											{
												print("<option value=\"".$res[1]."\">".$res[2]." - ".$res[1]."</option>");
											}
										?>
									</select>
								</div>
								<div style="text-align: right;" class="col-1">
									<button disabled type="button" class="btn btn-warning" style="max-width: 45px; max-height: 45px; font-size: 15px; font-weight: bold; font-style: italic;"><i class="fas fa-plus-square"></i></button>
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<strong>Основание за издаване:</strong>
									<br />
									<input type="text" placeholder="Моля, въведете основание за издаване" id="e4" name="e4" class="form-control-lg form-control" style="background-color: #112233; color: #999911; font-size: 25px; font-weight: bold; height: 45px; line-height: 45px; margin: 0px; padding: 0px;" />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<hr />
								</div>
							</div>
							<div class="row">
								<div class="col-12">
									<strong>Относно:</strong>
									<br />
									<div id="e5" name="e5" style="background-color: #112233; color: #999911; font-size: 35px; font-weight: bold; height: 135px; line-height: 45px; margin: 0px; padding: 0px; overflow-y: auto;" contenteditable="true" onkeypress="entrs(event);"></div>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-warning" style="font-size: 20px; font-weight: bold; font-style: italic;" onclick="sve(); return true;"><i class="fas fa-save"></i> Запиши</button>
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 200px;" class="modal fade" id="mtkn" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="mtkn" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 95%;">	
				<div class="modal-dialog modal-lg" style="width: 95%;">
					<div class="modal-content" style="background-image: linear-gradient(to right, rgba(255,255,17,0.85), rgba(255,255,17,1))!important;">
						<div class="modal-header">
							<h5 class="modal-title" style="font-weight: bold; color: #112233; font-size: 30px;" id="mtknt">
								<i class="fas fa-info-circle"></i> Зает заповеден номер
							</h5>
							<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
								<span aria-hidden="true" style="color: #112233;">&times;</span>
							</button>
						</div>
						<script>
							document.write("<div class=\"modal-body\" style=\"max-height: "+ah+"px; overflow-y: auto;\">");
						</script>
							<span style="font-size: 25px;">Този заповеден номер вече е зает. Възможно е това да се е случило докато сте въвеждали и номерът да е издаден на друг служител.<br />Моля, напишете следващия номер или направете корекция, ако без да искате сте дублирали номер и след това натиснете на бутона &quot;Запиши&quot;!</span>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div style="position: fixed; top: 200px;" class="modal fade" id="mfill" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="mfill" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 95%;">	
				<div class="modal-dialog modal-lg" style="width: 95%;">
					<div class="modal-content" style="background-image: linear-gradient(to right, rgba(255,255,17,0.85), rgba(255,255,17,1))!important;">
						<div class="modal-header">
							<h5 class="modal-title" style="font-weight: bold; color: #112233; font-size: 30px;" id="mfillt">
								<i class="fas fa-info-circle"></i> Непълни данни
							</h5>
							<button type="button" style="font-size: 45px;" class="close" data-dismiss="modal" aria-label="Затвори">
								<span aria-hidden="true" style="color: #112233;">&times;</span>
							</button>
						</div>
						<script>
							document.write("<div class=\"modal-body\" style=\"max-height: "+ah+"px; overflow-y: auto;\">");
						</script>
							<span style="font-size: 25px;">Не сте попълнили всички полета!<br />Направете го и след това натиснете бутона &quot;Запиши&quot;!</span>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php
			include("../menuin.php");
		?>
		<form id="addnew" name="addnew" action="./" method="post">
			<input id="adt" name="adt" type="hidden" />
		</form>
		<form id="ednew" name="ednew" action="./" method="post">
			<input id="edt" name="edt" type="hidden" />
		</form>
		<form id="delfrm" name="delfrm" action="./" method="post">
			<input id="delt" name="delt" type="hidden" />
		</form>
		<form id="ssel" name="ssel">
			<div style="margin-top: 55px;" class="container-fluid">
				<div class="row">
					<div class="col-1" style="margin-bottom: 20px; font-size: 25px; font-weight: bold; color: #DDDDDD;">
						<img src="/assets/images/site/enter.png" style="height: 100px; border: none;" alt="" />
					</div>
					<div class="col-5" style="margin-bottom: 20px; font-size: 60px; font-weight: bold; color: #DDDDDD;">
						<span class="d-sm-none d-md-inline">&quot;В. Левски&quot;</span>
					</div>
					<div class="col-6" style="margin-bottom: 20px; font-size: 60px; font-weight: bold; color: #DDDDDD; text-align: right; padding-right: 30px; border-radius: 15px; background-image: linear-gradient(to right, rgba(51,51,255,0), rgba(51,51,255,1))!important;">
						<i class="fas fa-file-signature"></i> <span class="d-sm-none d-md-inline">Зап. книга</span>
					</div>
				</div>
				<div class="row">
					<div class="col-7" style="margin-bottom: 20px; font-size: 25px; font-weight: bold; color: #DDDDDD;">
						<input style="color: #CCCCCC; background-color: #112233; font-size: 30px;" class="form-control form-control-lg" id="srch" type="text" placeholder="Въведете тук за бързо търсене" />
					</div>
					<div class="col-5" style="margin-bottom: 20px; font-size: 25px; font-weight: bold; color: #DDDDDD;">
						<button id="genb" onclick="ade(); return true;" style="font-size: 35px; width: 95%; height: 70px;" type="button" class="btn btn-success"><i class="fas fa-file-import"></i> <span class="d-sm-none d-md-inline">Създай</span></button>
					</div>
				</div>
				<div class="row">
					<div class="col-12" style="margin-bottom: 20px; font-size: 25px; font-weight: bold; color: #DDDDDD;">
						<table id="ttbl" style="width: 1250px; min-width: 1250px; max-width: 1250px; margin: 0 auto;" class="table table-bordered table-striped table-dark">
							<thead>
								<tr>
									<th style="vertical-align: middle; text-align: center; max-width: 80px; min-width: 80px; width: 80px;">№</th>
									<th style="vertical-align: middle; text-align: center; max-width: 120px; min-width: 120px; width: 120px;">Дата</th>
									<th style="vertical-align: middle; text-align: center; max-width: 100px; min-width: 100px; width: 100px;">НМ</th>
									<th style="vertical-align: middle; text-align: center; max-width: 330px; min-width: 330px; width: 330px;">Основание за издаване</th>
									<th style="vertical-align: middle; text-align: center; max-width: 450px; min-width: 450px; width: 450px;">Относно</th>
									<th style="vertical-align: middle; text-align: center; max-width: 150px; min-width: 150px; width: 150px;">Действия</th>
								</tr>
							</thead>
							<tbody id="stbl">
								<?php
									$oldn=0;
									$dq=mysqli_query($db, "SELECT * FROM `doczk` WHERE `m`>'0' ORDER BY `n` DESC, `m` DESC;");
									while($res=mysqli_fetch_row($dq))
									{
										$d=explode("__", $res[5]);
										$n=$d[2];
										$dt=$d[3];
										$nm=$d[4];
										$td=$d[5];
										$cr=$d[6];
										if ($n!=$oldn)
										{
											print("<tr>");
											print("<td style=\"text-align: center;\">".$n."</td>");
											print("<td style=\"text-align: center;\">".$dt."<br />");
											$ih=0;
											$ihq=mysqli_query($db, "SELECT * FROM `doczk` WHERE `n`='".$n."' AND `m`>'0';");
											{
												while($resh=mysqli_fetch_row($ihq))
												{
													$ih++;
												}
											}
											if ($ih>1)
											{
												print("<button disabled style=\"width: 35px; font-size: 20px; padding: 0;\" type=\"button\" onclick=\"h('".$res[1]."'); return true;\" class=\"btn btn-primary\"><i class=\"fas fa-history\"></i></button> (".$ih.")");
											}
											print("</td>");
											print("<td style=\"text-align: center;\">".$nm."</td>");
											print("<td style=\"text-align: center;\">".$td."</td>");
											print("<td>".$cr."</td>");
											print("<td style=\"text-align: center;\">");
											$fex="id".$res[0]."";
											$fex=sha1($fex);
											$fexe="./up/".$fex.".pdf";
											if (file_exists($fexe))
											{
												print("<button style=\"width: 35px; font-size: 20px; padding: 0;\" type=\"button\" onclick=\"s('".$fex."', '".$res[1]."'); return true;\" class=\"btn btn-primary\"><i class=\"fas fa-eye\"></i></button>");
											}
											else
											{
												print("<button style=\"width: 35px; font-size: 20px; padding: 0;\" type=\"button\" onclick=\"uplf('".$res[0]."','".$res[1]."'); return true;\" class=\"btn btn-primary\"><i class=\"fas fa-paperclip\"></i></button>");
											}
											print("&nbsp;");
											print("<button style=\"width: 35px; font-size: 20px; padding: 0;\" type=\"button\" onclick=\"ed('".$res[0]."'); return true;\" class=\"btn btn-warning\"><i class=\"fas fa-pencil-alt\"></i></button>");
											print("&nbsp;");
											print("<button style=\"width: 35px; font-size: 20px; padding: 0;\" type=\"button\" onclick=\"dl('".$res[0]."','".$res[1]."'); return true;\" class=\"btn btn-danger\"><i class=\"fas fa-trash\"></i></button>");
											print("</td>");
											print("</tr>");
										}
										$oldn=$n;
									}
								?>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</form>
	</body>
</html>