<?php  
$path="../../../";
include("../../../map.php");
include("../../../scripts.php");
function cevirr($metin){
	$metin = str_replace("Ý", "I", $metin);
	$metin = str_replace("Ü", "U", $metin);
	$metin = str_replace("Ö", "O", $metin);
	$metin = str_replace("Ç", "C", $metin);
	$metin = str_replace("Ð", "G", $metin);
	$metin = str_replace("ý", "i", $metin);
	$metin = str_replace("þ", "s", $metin);
	$metin = str_replace("Þ", "S", $metin);
	$metin = str_replace("ð", "g", $metin);
	return $metin;
}
$eta_stocks = file_get_contents('https://siparis.idakozmetik.com/eta_api.asp');
?>
<table class="table">
			<tr class="">
				<td style="width:5%;">ID</td>
<?php if($mobile==""){?>
				<td style="width:15%;">Eta_Kod</td>
<?php }?>
				<td style="width:15%;">Barkod</td>
				<td>Ad</td>
				<td style="width:10%;">Fiyat</td>
				<td style="width:5%;">Stok</td>
			</tr>
<?php
	$i=0;$stocks = explode('+',cevirr($eta_stocks)); $total=count($stocks); 
	$results = array();
	foreach($stocks as $stock){$i++;
		$stock2=explode(',',$stock);
		$results[] = array('code' => $stock2[0], 'barcode' => $stock2[1], 'title' => $stock2[2], 'stock' => $stock2[3], 'fiyat' => $stock2[4]);
	}
	foreach($stocks as $stock){$i++;
		$stock2 = explode(',',$stock);
		if(is_numeric($stock2[1]) and $stock2[3]>=0){
			if($stock2[3]>=1){ $s5=$stock2[3]; }else{ $s5=0; }
			$sql = mysql_query("SELECT * FROM ".$_SESSION['lang']." where ne='kayit' and t5<>'' and  t5='".$stock2[1]."'"); $rsl=mysql_fetch_array($sql);
			$jsi = json_decode($rsl["n17"],true);
			$pb2=round($rsl["pb1"]*1.20);
			$pb1=str_replace(",","",number_format(($stock2[4]*1.18),2));
			$n4="".$stock2[0].",".$stock2[2]."";
			$Rs = mysql_query("update ".$_SESSION['lang']." set pb1='".$pb1."', s5='".$stock2[3]."' where id=".$rsl["id"]."");
		?>
			<tr <?php if(mysql_num_rows($sql)==0 and $stock2[3]>0){echo "class=\"alert alert-info\"  title=\"Eklenmemis veya Coklu Barkod\"";}elseif(mysql_num_rows($sql)>0 and $rsl["s13"]==1 and $stock2[3]<=0){echo "class=\"alert alert-danger\"  title=\"Stokta Yok veya Tedarik Edilemiyor.\"";}elseif(mysql_num_rows($sql)>0 and $rsl["s13"]==1 and $stock2[3]<=3){echo "class=\"alert alert-warning\" title=\"Yetersiz Stok\"";}elseif(mysql_num_rows($sql)>0 and $rsl["s13"]==1 and $stock2[3]>0){echo "class=\"alert alert-success\"  title=\"Sorunsuz\"";}elseif(mysql_num_rows($sql)>0 and $rsl["s13"]<>1){echo "class=\"alert alert-default\"  title=\"Pasif\"";}?>" style="<?php if(mysql_num_rows($sql)==0 and $stock2[3]<=0){echo "display:none;";}?>" <?php if(mysql_num_rows($sql)>0){?>onmouseover="show('<?php echo $i?>');"  onmouseout="hide('<?php echo $i?>');"<?php }?>>
				<td>
					<?php echo $rsl["id"]?>
					<img src="<?php echo medya($rsl["id"],1,"resim","t1","", $weburl)?>" style="position: absolute; height: 150px; display: block; margin-top: 7px; border: solid 1px red; display:none;" id="<?php echo $i?>">
				</td>
<?php if($mobile==""){?>
				<td><?php echo $stock2[0]?></td>
<?php }?>
				<td><a href="https://google.com/search?q=<?php echo $stock2[1]?>" target="_blank"><?php echo $stock2[1]?></a> <a href="https://merchant.hepsiburada.com/#ProductListing/search/<?php echo $stock2[1]?>"  target="_blank">H</a></td>
				<td><a href="https://google.com/search?q=<?php echo $stock2[2]?>" target="_blank"><?php echo $stock2[2]?></a> <?php if(mysql_num_rows($sql)>0 and $rsl["s13"]<>1 and $stock2[3]<=0){?><i class="fa fa-minus-circle" title="Tedarik edilemiyor."></i><?php }?></td>
				<td><?php echo $pb1;?></td>
				<td><?php echo $stock2[3]?></td>
			</tr>
		<?php }?>
	<?php }?>
</table>