<?php
function lungime_text($x, $length){
  if(strlen($x)<=$length)  {
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
$qsrc = "SELECT * FROM `anunturi` WHERE `verificat` IS NULL AND `aprobat`=1";
$ressrc = $dbc->query($qsrc);
?>

<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-rest">
<?php include APP.'searchform.php'; ?>
<div class="w3-row w3-container w3-text-white" style="background-color:#117594;">
<h5 style="padding:5px;">Toate anunțurile (<?=$ca?>)</h5>
</div>
<div class="w3-row w3-margin-top">
<?php
while($rsrc = $ressrc->fetch_array()){
    
      $qsrcimg = "SELECT * FROM `imagini` WHERE `aid`=\"".$rsrc['aid']."\" LIMIT 1";
      $rsrcimg = $dbc->query($qsrcimg);
      $rsimg = $rsrcimg->fetch_assoc();
      
      $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rsrc['uid']}";
      $rgetuser = $dbc->query($qgetuser);
      $rowgetusr = $rgetuser->fetch_assoc();

?>

<a href="<?=PATH.$rsrc['seo']?>.html">
<div class="w3-col l3 m4 s12 w3-hover-light-gray w3-text-black w3-margin-bottom">
<div class="w3-col" style="width:96%;margin:1%;margin-bottom:0;">
<img src="<?=BASE_URL.'imagini/'.$rsimg['nume_fisier']?>" style="object-fit:cover;width:100%;height:150px;max-height:100%;" alt="<?php echo lungime_text($rsrc['titlu'], 36); ?>" title="<?php echo $rsrc['titlu']; ?>" loading="lazy" class="w3-card"/>
</div>
<div class="w3-col" style="width:96%;margin:1%;">
<h4 class="w3-card" style="font-size:16px;padding-left:4px;margin-bottom:0;">
<?php echo lungime_text($rsrc['titlu'], 20); ?></h4>
<div class="w3-row w3-green" style="margin-top:0;">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> <?php if($rsrc['pret'] > 0){echo '<strong>'.$rsrc['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

</div>

</div></a>

<!--<a href="/<?=$rsrc['seo']?>.html">
<div class="w3-half w3-card w3-hover-light-gray w3-margin-bottom">
<div class="w3-col w3-hide-small" style="width:26%;">
<img src="/imagini/<?=$rsimg['nume_fisier']?>" alt="<?=$rsrc['titlu']?>" style="width:120px;max-width:100%;height:120px;"/>
</div>
<div class="w3-col w3-hide-medium w3-hide-large" style="width:30%;">
<img src="/imagini/<?=$rsimg['nume_fisier']?>" alt="<?=$rsrc['titlu']?>" style="width:70px;max-width:100%;height:70px;"/>
</div>
<div class="w3-col w3-hide-small" style="width:74%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text($rsrc['titlu'], 40); ?></h5>
<div style="text-align: justify;padding-left:5px;padding-right:5px;">
<span><?php echo lungime_text($rsrc['descriere'], 90); ?></span></div>
<div class="w3-row w3-border-top w3-green">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rsrc['pret'] > 0){echo '<strong>'.$rsrc['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

<div class="w3-row w3-border-top">
<div class="w3-left" style="padding-left:5px;">
<i class="fa fa-map-marker"></i> <?php echo $rsrc['judet']; ?>
</div>
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-clock-o"></i> <?php echo date('d F Y, H:i', strtotime($rsrc['data_publicarii'])); ?>
</div>
</div>

</div>

<div class="w3-col w3-hide-medium w3-hide-large" style="width:70%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text($rsrc['titlu'], 20); ?>
</h5>
<span><?php echo lungime_text($rsrc['descriere'], 54); ?></span>
</div>

</div>
</a>-->
<?php } ?></div>
</div>
</div>