<?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">
<?php
	$i=0;$stocks = explode('+',cevirr($eta_stocks)); $total=count($stocks); 
	echo "Total ".$total." Products ".$sayfa." > ".$slmt;
	$results = array();
	foreach($stocks as $stock){$i++;
		$stock2=explode(',',$stock);
		$results[] = array('code' => $stock2[0], 'barcode' => $stock2[1], 'title' => $stock2[2], 'stock' => $stock2[3]);
	}
	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="".$rsl["n4"].",".$stock2[0].",".$stock2[2]."";
			$Rs = mysql_query("update ".$_SESSION['lang']." set s5='".$stock2[3]."', pb1='".$pb1."', ts2=now() where id=".$rsl["id"]."");
		?>
			<tr class="<?php if(mysql_num_rows($sql)==0){echo "alert alert-warning";}?>">
				<td><?php echo $rsl["id"]?></td>
				<td><?php echo $rsl["t4"]?></td>
				<td><?php echo $stock2[0]?></td>
				<td><a href="https://google.com/search?q=<?php echo $stock2[1]?>" target="_blank"><?php echo $stock2[1]?></a></td>
				<td><?php echo $stock2[2]?></td>
				<td><?php if(mysql_num_rows($sql)>0){?><?php echo $pb1?> TL<?php }?></td>
				<td><?php echo $stock2[3]?></td>
			</tr>
		<?php }?>
	<?php }?>
</table>