<?php
	header('Content-Type: text/html; charset=utf-8');
	$path="../../";
	include("../../map.php");
	include("../../scripts.php");
	include("../../secure.php");
	$sql=mysqli_query($conn, "select * from genel where ne='gorev' and id=".$_GET["id"].""); $rs=mysqli_fetch_assoc($sql);
	$jsi = json_decode($rs["n17"], true);
	$jsm = json_decode($rs["n18"], true);
	$sql2=mysqli_query($conn, "select * from t5 where id=".$rs["t11"].""); $rs5=mysqli_fetch_assoc($sql2);
	$ut1=$rs5["t1"];
	$ut2=$rs5["t2"];
	$ut4=$rs5["t4"];
	//findDirectoryPath("deppo")
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $rs["t1"];?></title>
</head>
<body>
    <div class="qmodal">
        <div class="qmodal-content">
            <!-- Header with Action Buttons -->
            <div class="qmodal-header">
				<div class="header-title">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="<?php echo $weburl?>" target="_blank"><i class="fa fa-home"></i></a></li>
                            <li class="breadcrumb-item"><a href="#"><?php echo $tasks[0]?></a></li>
                            <li class="breadcrumb-item active" aria-current="page"><?php echo $rs["t1"];?></li>
                        </ol>
                    </nav>
                </div>
                <button type="button" class="btn btn-warning" onclick="AjaxKaydet('','');"><i class="fas fa-save"></i> Kaydet</button>
				<button type="button" class="btn btn-success mfrm" style="color:white;" onclick="location.href='#tab-resim'" data-toggle="modal" data-target="#myModal" data-url="../upload/upload_image.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"]; ?>"><strong><i class="fa fa-cloud-upload" aria-hidden="true"></i><span class="mdn"> <?php echo $sdil[75]; //Resim Ekle?></span></strong></button>
				<button type="button" class="btn btn-danger mfrm" style="color:white;" onclick="location.href='#tab-video'" data-toggle="modal" data-target="#myModal" data-url="../video/video_add.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"]; ?>"><strong><i class="fa fa-plus" aria-hidden="true"></i><span class="mdn"> <?php echo $sdil[76]; //Video Ekle?></strong></span></button>
				<button type="button" class="btn btn-warning mfrm" style="color:white;" onclick="location.href='#tab-dosya'" data-toggle="modal" data-target="#myModal" data-url="../upload/upload_file.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"]; ?>"><strong><i class="fa fa-cloud-upload" aria-hidden="true"></i><span class="mdn"> <?php echo $sdil[77]; //Dosya Ekle?></span></strong></button>
				<button type="button" class="btn btn-info" style="color:white;" target="_blank" href="../print/print_task.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>"><strong><i class="fa fa-print" aria-hidden="true"></i><span class="mdn"> Yazdır</span></strong></button>
            </div>
			<form class="form" action="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&durum=kaydet" id="asave" name="aform" method="post">
            <!-- Left Tab Menu -->
            <div class="v8-columns">
						<div class="v8-col200pxL-left">
							<ul class="v8-side-tabs v8-js-tabs v8-same-height">
								<li><a href="#tab-kayit"><i class="fa fa-file" aria-hidden="true"></i><span> <?php echo $tasks[0]?> <?php echo $sdil[207]; //Detay?></span></a></li>
							<!--
								<?php if($g9==2){?>
									<li><a href="#tab-extra"><i class="fa fa-list-ul" aria-hidden="true"></i><span> <?php echo $tasks[0]?> İçerik</span></a></li>
								<?php }?>
							-->
							<li><a href="#tab-aciklama"><i class="fa fa-file" aria-hidden="true"></i><span> <?php echo $sdil[207]; //Detay?></span></a></li>
							<li><a href="#tab-resim"><i class="fa fa-file-image-o" aria-hidden="true"></i><span> <?php echo $sdil[209]; //Resimler?></span></a></li>
							<li><a href="#tab-video"><i class="fa fa-file-video-o" aria-hidden="true"></i><span> <?php echo $sdil[210]; //Videolar?></span></a></li>
							<li><a href="#tab-dosya"><i class="fa fa-file-archive-o" aria-hidden="true"></i><span> <?php echo $sdil[211]; //Dosyalar?></span></a></li>
							<li><a href="#tab-logs" onclick="ifocus('#uni');"><i class="fa fa-list" aria-hidden="true"></i><span> <?php echo $sdil[80].$sdil[68]; //Kullanıcı Notlar?></span></a></li>
							<li class="ddn"><a href="#" onclick="show('switchs')"><i class="fa fa-chevron-right" aria-hidden="true"></i></a></li>
						</ul>
						<div id="switchs">
							<div class="v3-alert v3-alert-warning ddn">
								<i class="fas fa-arrow-right" onclick="hide('switchs')"></i>
							</div>
							
							<fieldset class="side-by-side">
								<legend><?php echo translate("İşlem Sorumlusu")?> <span style="font-size:8px; color:#ccc;">(s19)</span></legend>
								<select name="s19" data-placeholder="Seçiniz" style="width:99%;" data-plugin-selecttwo="" class="form-control populate" tabindex="8" id="s19">
									<option value="0">Admin</option>
									<?php $sql=mysqli_query($conn, "select * from t5"); while($rsm=mysqli_fetch_assoc($sql)){?>
										<option value="<?php echo $rsm["id"];?>" t1="<?php echo $rsm["t1"];?>" t2="<?php echo V3d($rsm["t2"]);?>" t3="<?php echo $rsm["t4"];?>" t4="<?php echo $rsm["t6"];?>" style="color:#6699FF" <?php if ($rsm["id"]==$rs["s19"]) {?>Selected<?php }?>><?php echo $rsm["t1"];?></option>
									<?php }?>
								</select>
							</fieldset>
							<fieldset class="side-by-side">
								<legend><?php echo $tasks[0]?> <?php echo $sdil[168]; //Tip?> <span style="font-size:8px; color:#ccc;">(t2)</span></legend>
								<input type="text" list="lt2" name="t2" value="<?php echo $rs["t2"];?>" style="" class="form-control">
								<datalist id="lt2" style="display:none;">
									<?php $sqlt=mysqli_query($conn, "select Distinct t2 FROM t1 where ne='gorev'"); while($tip=mysqli_fetch_assoc($sqlt)){?>
										<option value="<?php echo $tip["t2"];?>"><?php echo $tip["t2"];?></option>
									<?php }?>
								</datalist>
							</fieldset>
							<fieldset class="grey-bg">
								<legend><?php echo translate("Görevin Durumu");?> <span style="font-size:8px; color:#ccc;">(s13)</span></legend>
								<select name="s13" data-placeholder="Seçiniz" style="width:99%;" class="form-control" tabindex="8" id="s13">
									<option value="0" <?php if ($rs["s13"]==0) {?>Selected<?php }?>>Beklemede</option>
									<option value="1" <?php if ($rs["s13"]==1) {?>Selected<?php }?>>Üzerinde Çalışılıyor</option>
									<option value="2" <?php if ($rs["s13"]==2) {?>Selected<?php }?>>Tamamlandı</option>
									<option value="3" <?php if ($rs["s13"]==3) {?>Selected<?php }?>>Arşiv</option>
								</select>
							</fieldset>
						</div>
					</div>
					<div class="v8-col200pxL-right"  ts1="<?php echo dtarih($rs["ts1"],"gg.ka.yy time");?>" ts2="<?php echo dtarih($rs["ts2"],"gg.ka.yy time");?>" ts3="<?php echo dtarih($rs["ts3"],"gg.ka.yy time");?>">
						<div id="tab-kayit" class="v8-tabs-content">
							<div class="v3-row">
								<fieldset class="grey-bg v3-col-md-12">
									<legend><?php echo $tasks[0]?> <span style="font-size:8px; color:#ccc;">(t1)</span></legend>
									<input type="text" name="t1" id="simple-" value="<?php echo $rs["t1"]?>" onfocus="if(this.value == '<?php echo $rs["t1"]?>') { this.value = ''} "  onblur="if(this.value == '') { this.value='<?php echo $rs["t1"]?>'; }" placeholder="<?php echo $rs["t1"]?>" class="form-control">
								</fieldset>
								<fieldset class=" v3-col-md-4" style="">
								<legend><?php echo translate("Görev Verilen"); $t11Sx = explode(',',$rs["t11"]);?> <span style="font-size:8px; color:#ccc;">(t11)</span></legend>
								<select name="t11[]" data-placeholder="Seçiniz" class="form-control chosen-select" multiple>
									<option value="0">Admin</option>
									<?php $sql=mysqli_query($conn, "select * from t5"); while($rsm=mysqli_fetch_assoc($sql)){?>
										<option value="<?php echo $rsm["id"];?>" title="<?php echo $rsm["t1"];?>" alt="<?php echo $rsm["t1"];?>" style="color:#6699FF" <?php foreach($t11Sx as $t11s){if($t11s==$rsm["id"]){echo "selected";}}?>><?php echo $rsm["t1"];?></option>
									<?php }?>
								</select>
									<a class="cp btn btn-warning fa fa-plus fr p5 mp5" style="position:absolute;right: 0px; top: -25px; z-index: 99;" onclick="toggle('#addClient');toggle('#chooseClient')"></a>
									<div id="addClient" style="display:none;position: absolute; margin-top: -38px; background: white; width: 95%;">
									<div class="row">
										<div class="col-md-4">
											<input type="text" name="ut1" class="form-control"  value="" placeholder="Ad Soyad">
										</div>
										<div class="col-md-4">
											<input type="text" name="ut2" class="form-control"  value="" placeholder="Email">
										</div>
										<div class="col-md-4">
											<input type="text" name="ut4" class="form-control"  value="" placeholder="Gsm" data-plugin-masked-input="" data-input-mask="<?php echo $module["pmask"];?>">
										</div>
									</div>
								</div>
							</fieldset>
								<fieldset class=" v3-col-md-4" style="">
									<legend><i class="fa fa-play"></i> <?php echo translate("Başlama Tarihi / Saat"); //Tarih?> <span style="font-size:8px; color:#ccc;">(t9/t8)</span></legend>
									<div class="row">
										<div class="col-md-8">
											<input type="date" name="ts1" value="<?php if($rs["t9"]==""){echo date('Y-m-d');}else{echo $rs["t9"];}?>" title="Tarih-1" class="form-control with-tip" />
										</div>
										<div class="col-md-4">
											<input type="time" name="t8" value="<?php if($rs["t8"]==""){echo date('H:i');}else{echo $rs["t8"];}?>" class="form-control with-tip" />
										</div>
									</div>
								</fieldset>
								<fieldset class=" v3-col-md-4" style="">
									<legend><i class="fa fa-play"></i> <?php echo translate("Bitiş Tarihi / Saat"); //Tarih?> <span style="font-size:8px; color:#ccc;">(t0)</span></legend>
									<div class="row">
										<div class="col-md-8">
											<input type="date" name="ts2" value="<?php if($rs["t10"]==""){echo date('Y-m-d');}else{echo $rs["t10"];}?>" title="Tarih-2" class="form-control with-tip" />
										</div>
										<div class="col-md-4">
											<!--<input type="time" name="t8" value="<?php if($rs["t8"]==""){echo date('H:i');}else{echo $rs["t8"];}?>" class="form-control with-tip" />-->
										</div>
									</div>
								</fieldset>
								<div class="v3-col-md-12" id="inputs" style="padding: 0px;">
									<img src="../../assets/img/loading.gif">
									<a class="v3-btn v3-btn-xs v3-btn-default sam" style="" target="_blank" href="?ne=ayarlar&islem=inputs&nedir=<?php echo $_GET["ne"]?>&kid=<?php echo $_GET["id"]?>"><i class="fa fa-wrench" aria-hidden="true"></i></a>
								</div>
								<script type="text/JavaScript" language="JavaScript">
									jQuery(document).ready(function () { loadFunction('../ajax/ajax_inputs.php','#inputs'); });
								</script>
							</div>
						</div>
					<div id="tab-aciklama" class="v8-tabs-content" style="">
						<fieldset>
							<legend><?php echo $tasks[0]?> <span style="font-size:8px; color:#ccc;">(n1)</span></legend>
							<textarea name="n1" class="rte" id="rte" style="width:100%; height:auto;" placeholder="<?php echo $tasks[0]?> Detay"><?php echo $rs["n1"]?></textarea>
						</fieldset>
						<fieldset>
							<legend><?php echo $tasks[0]?> Sonuç <span style="font-size:8px; color:#ccc;">(n2)</span></legend>
							<textarea name="n2" class="rte2" id="rte2" style="width:100%; height:auto;" placeholder="<?php echo $tasks[0]?> Sonuç"><?php echo $rs["n2"]?></textarea>
						</fieldset>
					</div>
				</form>
					<div id="tab-logs" class="v8-tabs-content" style="display: flow-root;">
						<?php include("../public/log_user.php");?>
					</div>
					<div id="tab-resim" class="v8-tabs-content" style="min-height:500px">
						<fieldset class="v3-row">
							<legend><?php echo $sdil[209]; //Resimler?></legend>
							<script type="text/JavaScript" language="JavaScript">
								jQuery(document).ready(function () {
									loadFunction('../ajax/ajax_medya.php','#mresim', 'resim'); });
								document.write("<div id=\"mresim\"></div>");
							</script>
						</fieldset>
					</div>
					<div id="tab-video" class="v8-tabs-content" style="min-height:500px">
						<fieldset class="v3-row">
							<legend><?php echo $sdil[210]; //Videolar?></legend>
							<script type="text/JavaScript" language="JavaScript">
								jQuery(document).ready(function () {
									loadFunction('../ajax/ajax_medya.php','#mvideo', 'video');
								});
								document.write("<div id=\"mvideo\"></div>");
							</script>
						</fieldset>
					</div>
					<div id="tab-dosya" class="v8-tabs-content" style="min-height:500px">
						<fieldset class="v3-row">
							<legend><?php echo $sdil[211]; //Dosyalar?></legend>
							<script type="text/JavaScript" language="JavaScript">
								jQuery(document).ready(function () {
									loadFunction('../ajax/ajax_medya.php','#mdosya', 'dosya');});
								document.write("<div id=\"mdosya\"></div>");
							</script>
						</fieldset>
					</div>
				</div>
			</div>
                 </div>
            </div>
</body>
<script src="../../assets/js/tabs.js"></script>
<?php echo $footer?>
</html>
<?php
	if($_POST["pb1"]<>""){$pb1=$_POST["pb1"];}else{$pb1=0;}
	if($_POST["s1"]<>""){$s1=$_POST["s1"];}else{$s1=0;}
if ($_GET["durum"]=="kaydet"){
	$sqlk=mysqli_query($conn, "select * from t5 where t4='".$_POST["ut4"]."'"); $rsk=mysqli_fetch_assoc($sqlk);
	if(mysqli_num_rows($sqlk)==0 and $_POST["ut4"]<>""){
		$sqli5 = $conn->query("insert into t5(t1, t2, ne, s1, s4, s5, s19, t3, t4, ts1) values ('".$_POST["ut1"]."', '".base64_encode($_POST["ut2"])."', 'uye', '0', '1', '0', '".$_SESSION["user_id"]."', '".base64_encode(generatePassword(8))."', '".$_POST["ut4"]."', now())");	
		$sql5=mysqli_query($conn, "select * from t5 order by id desc"); $rs5=mysqli_fetch_assoc($sql5);
		$pt11=$rs5["id"];
	}else{
		$pt11=$rsk["id"];
	}
	$iarr = array();
	foreach ($_POST as $key => $value){
		if(substr($key,0,1)=="i"){
			$iarr = $iarr + array( $key => $value);
		}
	}
	$rjsi = json_encode($iarr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	$marr = array();
	foreach ($_POST as $key => $value){
		if(substr($key,0,1)=="m"){
			$marr = $marr + array( $key => $value);
		}
	}
	$rjsm = json_encode($marr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	if(!empty($_POST["t11"])){$st11 = implode(',',$_POST["t11"]);}else{$st11="0";}
	if($_POST["ts2"]<>""){
		$ts3 = explode('-',$_POST["ts2"]);
		$s4=$ts3[2]; $s5=$ts3[1]; $s6=$ts3[0];
	}else{
		$s4=0; $s5=0; $s6=0;
	}
	if($st11<>"0"){$kt11=$st11;}else{$kt11=$pt11;}
		$n1 .= $_POST["n1"];
	if($_POST["ut2"]<>"" or $_POST["ut4"]<>""){
		$n1 .= "<br>".$_POST["ut2"]."<br>".$_POST["ut4"]."";
	}
	$Rs = mysqli_query($conn, "update genel set t1='".$_POST["t1"]."', t2='".$_POST["t2"]."', t4='".$_POST["t4"]."', pb1='".sprice($pb1)."', s1='".$s1."', s13='".$_POST["s13"]."', s4='".$s4."', s5='".$s5."', s6='".$s6."', t8='".$_POST["t8"]."', t9='".$_POST["ts1"]."', t10='".$_POST["ts2"]."', t11='".$kt11."', n1='".addslashes(stripslashes($_POST["n1"]))."', n2='".addslashes(stripslashes($_POST["n2"]))."', n17='".addslashes(stripslashes($rjsi))."', n18='".addslashes(stripslashes($rjsm))."', ts1=now() where id='".$_GET["id"]."'");
	if($st11<>$rs["t11"] or $_POST['n1']<>$rs["n1"]){
		for ($i = 0, $l = count($_POST['t11']); $i < $l; $i++) {
			$sqlm=mysqli_query($conn, "select * from t5 where id=".$_POST['t11'][$i].""); $rsm=mysqli_fetch_assoc($sqlm);
			$mesaj	= "
			<h3>".$_POST["t1"]."</h3>
			".translate("Sayın")." <b>".$rsm["t1"].";</b><br> ".translate("gorev_mtxt")."<hr><b>".$_POST["n1"]."</b><br><br>
			".$sdil[115]." : ".$_POST["ts1"]." - ".$_POST["ts2"]."
			";
			$malici	= base64_decode($rsm["t2"]);
		if($_POST['n1']<>$rs["n1"]){
			$konu		= translate("Görev Güncelleme");
		}else{
			$konu		= translate("Görev Tanımlama");
		}
			$path		= "../";
			$mesaj	= $design_top.$mesaj.$design_bottom;
			emailgonder($malici,$konu,$cc,$mesaj);
		}
	}
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok&status=".qv($konu)."",self,500,1);
}
?>