<?php
	$path="../../"; include("../../map.php");
	include("../../scripts.php");
	$dpath="../../";
 ?>
<div style="width:100%;">
	<table class="table" style="font-size: 13px;">
		<thead>
			<tr class="mdn">
				<th class="w6 mw6" style="text-align:center;">ID</th>
				<th> <span class="column-sort"> <a href="#" title="Sort up" class="sort-up"></a> <a href="#" title="Sort down" class="sort-down"></a> </span> <?php echo $sdil[143]; //Sipariş No?> </th>
				<th class="w15 mw10 tar"><?php echo $t25s[0]; //Müşteri?></th>
				<th class="w8 mw10 tar"><?php echo $sdil[144]; //Tutar?></th>
				<th class="w5 mw10 tac"><?php echo $sdil[222]; //Ödeme Şekli?></th>
				<th class="w10 mw15 tac" scope="col"><?php echo $sdil[115]; //Tarih/Saat?></th>
				<th class="w5 mw10"></th>
				<th class="w10 mw10"><?php echo $sdil[213]; //İşlemler?></th>
			</tr>
		</thead>
		<tbody>
			<?php
			if($_GET["s4"]==""){
				$sqlorder = mysqli_query($conn, "select * from eticaret where ne='siparis' and (s1=".$_GET["id"]." or s19=".$_GET["id"].") order by id desc");
			}else{
				$sqlorder = mysqli_query($conn, "select * from eticaret where ne='siparis' and s4=".$_GET["s4"]." and (s1=".$_GET["id"]." or s19=".$_GET["id"].") order by id desc");	
			}
			while($siparis=mysqli_fetch_assoc($sqlorder)){
				include("../ecommerce/ecommerce_order_calc.php");
				if($siparis["s1"]<>""){
					$sqlm = mysqli_query($conn, "select * from t5 where id=".$siparis["s1"]." order by id desc"); $rsm=mysqli_fetch_assoc($sqlm); $jsci=json_decode($rsm["n17"],true);
				}
				?>
				<tr id="tr_<?php echo $siparis["id"]?>" data-id="<?php echo $siparis["id"];?>" class="alert alert-<?php if($siparis["s4"]=="0"){echo "warning";}elseif($siparis["s4"]=="1"){echo "success";}elseif($siparis["s4"]=="2"){echo "danger";}elseif($siparis["s4"]=="3"){echo "info";}elseif($siparis["s4"]=="4"){echo "default";}?>">
					<td class="th table-check-cell mfrm" style="cursor:pointer;" data-toggle="modal" data-target="#myModal" data-url="<?php echo $weburl?>/crmplus/modules/print/print_order.php?mode=modal&id=<?php echo $siparis["id"];?>" data-title="Yazdır">
						<span class=""><?php echo i2a($siparis["id"],5)?></span>
					</td>
					<td class="">
						<span class="fl mdn"><b><?php echo $siparis["t4"];?></b></span>
						<?php if($siparis["t6"]<>""){?>
							<br><span class="badge bg-warning mdn"><?php echo $siparis["t9"]?></span>
						<?php }?>
						<?php if($jsob["browser"]<>1 and $jsob["desktop"]<>1){?>
							<i class="fl fas fa-fire text-danger mdn" style="margin-left:10px;"></i>
						<?php }?>
						<?php foreach($images as $image){?>
							<img src="<?php echo $image;?>" style="height: 45px; width: 45px; border-radius: 50%; float: right; margin-left: -28px; border: 1px solid;">
						<?php }?>
					</td>
					<td class="mdn tar cp" onclick="location.href='?islem=duye&ne=uye&id=<?php echo $rsm["id"]?>'"><?php if($rsm["t13"]<>""){echo "<i class=\"fas fa-medal\"></i>";}?> <?php echo $rsm["t1"];?><?php if(mysqli_num_rows($sqlb)>0 and $siparis["s19"]<>0){echo "<br>#".$rsb["id"]." ".$rsb["t1"];}?>
					<?php echo "<br><span style=\"font-size:11px;\">".kisalt($jsci["ifirma"],3)."</span>";?>
					</td>
					<td class="tar mw27">
						<form action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=teklif" method="post">
							<input class="" type="text" name="t2" value="<?php echo wprice($gtoplam)?>" style="width:70px; border:0px; text-align:right;"> <?php echo $ikpb;?>
						</form>
					</td>
					<td class="mdn tac"><?php if($siparis["t5"]<>""){ echo $siparis["t5"]; }else{echo "...";}?><br /><?php echo ihb($siparis["t3"]);?></td>
					<td class="mdn tac"><?php echo dtarih($siparis["ts1"],"gg ka  time");?><br /><?php echo dtarih($siparis["ts2"],"gg ka  time");?></td>
					<td class="mdn tac">
						<a id="del1_<?php echo $siparis["id"];?>" data-href="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&s1=<?php echo $siparis["s1"];?>&sno=<?php echo $siparis["t4"];?>&durum=sil&s4=2" class="btn btn-danger mbtn  cp btn-delete-row" title="Kaldır" style="display:none;"><i class="fa fa-times"></i></a>
						<?php if(($siparis["s4"]==2 and $_SESSION["y2"]>2) or ($siparis["s4"]==2 and $_SESSION["kim"]=="Admin") ){?>
							<a id="del0_<?php echo $siparis["id"];?>" data-href="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&s1=<?php echo $siparis["s1"];?>&sno=<?php echo $siparis["t4"];?>&durum=sil&s4=2" class="btn btn-danger mbtn  cp btn-delete-row" title="Kaldır" style=""><i class="fa fa-times"></i></a>
						<?php }else{?>
							<a id="view_<?php echo $siparis["id"];?>" data-toggle="modal" data-target="#myModal" data-url="<?php echo $weburl?>/crmplus/modules/print/print_order.php?mode=modal&id=<?php echo $siparis["id"];?>" data-title="Yazdır" class="btn btn-warning mfrm" title="Detay"><i class="fa fa-eye"></i></a>
						<?php }?>
					</td>
					<td class="table-actions mw27">
					<form id="o<?php echo $siparis["id"];?>" style="">
						<select class="form-control" id="s<?php echo $siparis["id"];?>" onchange="AjaxPResult(this.value,'o<?php echo $siparis["id"];?>','','');" style="padding: 0px;">
							<option data-bg="alert-warning" data-status="0" value="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=onay&s4=0&ototal=<?php echo wprice($gtoplam)?>" <?php if($siparis["s4"]==0){echo "Selected";}?>><i class="fa fa-pause" aria-hidden="true"></i> <?php echo translate("+#Onay Bekliyor")?></option>
							<option data-bg="alert-success" data-status="1" value="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=onay&s4=1&ototal=<?php echo wprice($gtoplam)?>" <?php if($siparis["s4"]==1){echo "Selected";}?>><i class="fa fa-check" aria-hidden="true"></i> <?php echo translate("+#Onaylandı")?></option>
							<?php if($f3>1){?>
							<option data-bg="alert-info" data-status="3" value="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=onay&s4=3&ototal=<?php echo wprice($gtoplam)?>" <?php if($siparis["s4"]==3){echo "Selected";}?>><i class="fa fa-truck" aria-hidden="true"></i> <?php echo translate("+#Sevkiyatta")?></option>
							<?php }?>
							<option data-bg="alert-default" data-status="4" value="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=onay&s4=4&ototal=<?php echo wprice($gtoplam)?>" <?php if($siparis["s4"]==4){echo "Selected";}?>><i class="fa fa-check" aria-hidden="true"></i> <?php echo translate("+#Teslim Edildi")?></option>
							<option data-bg="alert-danger" data-status="2" value="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=onay&s4=2&ototal=<?php echo wprice($gtoplam)?>" <?php if($siparis["s4"]==2){echo "Selected";}?>><i class="fa fa-ban" aria-hidden="true"></i> <?php echo translate("+#İptal")?></option>
							<?php if($module["order_return"]>1){?>
							<option data-bg="alert-danger" data-status="5" value="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=onay&s4=5&ototal=<?php echo wprice($gtoplam)?>" <?php if($siparis["s4"]==5){echo "Selected";}?>><i class="fa fa-ban" aria-hidden="true"></i> <?php echo translate("+#İade")?></option>
							<?php }?>
							<?php if(translate("+#order_extra")<>""){?>
							<option data-bg="alert-default" data-status="6" value="modules/ecommerce/ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $siparis["id"];?>&durum=onay&s4=6&ototal=<?php echo wprice($gtoplam)?>" <?php if($siparis["s4"]==6){echo "Selected";}?>><i class="fa fa-life-ring" aria-hidden="true"></i> <?php echo translate("#order_extra")?></option>
							<?php }?>	
						</select>
					</form>
					</td>
				</tr>
				<script>
					jQuery('#s<?php echo $siparis["id"];?>').on('change', function() {
						notice('CrmPlus+','<?php echo trim($sdil[212])?>','fa fa-check-square-o','success');
						var bg = jQuery(this).find(':selected').data('bg');
						var status = jQuery(this).find(':selected').data('status');
						jQuery("#tr_<?php echo $siparis["id"];?>").removeClass();
						jQuery("#tr_<?php echo $siparis["id"];?>").addClass(bg);
						<?php if(($_SESSION["y2"]>2) or ($_SESSION["kim"]=="Admin") ){?>
							if(status==2){
								jQuery("#del1_<?php echo $siparis["id"];?>").fadeIn();
								jQuery("#view_<?php echo $siparis["id"];?>").fadeOut();
							}else{
								jQuery("#view_<?php echo $siparis["id"];?>").fadeIn();
								jQuery("#del1_<?php echo $siparis["id"];?>").fadeOut();
								jQuery("#del0_<?php echo $siparis["id"];?>").fadeOut();
							}
						<?php }?>
					});
				</script>
			<?php $total=0; $stutar=""; $ototal=$ototal+$gtoplam;}?>
		</tbody>
	</table>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>