<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
<?php include APP.'searchform.php'; ?>

 <!--<div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-margin-bottom">   
   <img title="Harta României" alt="Harta României" class="img-responsive" width="50%" src="/asset/svg/ro.svg"/>
   <div id="mapdata"></div>
   </div>
 </div>
 
 <div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-indigo w3-margin-bottom">
   <h3>Anunțuri Promovate</h3>
   </div>
 </div> -->
 
 <div class="w3-row-padding">
   <div class="w3-half w3-padding">
   <h3 class="w3-container w3-indigo w3-card" style="padding-bottom:5px;">Ultimele anunțuri</h3>
<?php
function lungime_text($x, $length){
  if(strlen($x)<=$length)  {
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
   $qlast5 = "SELECT * FROM `anunturi` WHERE `verificat` IS NULL ORDER BY `data_publicarii` DESC LIMIT 5";
   $rlast5 = $dbc->query($qlast5);
   while($rowlast5 = $rlast5->fetch_assoc()){
       $qgetimage = "SELECT * FROM `imagini` WHERE `aid`={$rowlast5['aid']}";
       $rgetimage = $dbc->query($qgetimage);
       $rowgetimg = $rgetimage->fetch_assoc();
       
       $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rowlast5['uid']}";
       $rgetuser = $dbc->query($qgetuser);
       $rowgetusr = $rgetuser->fetch_assoc();         
?>
<a href="/<?=$rowlast5['seo']?>.html">
<div class="w3-row w3-hover-light-gray w3-text-black w3-card w3-margin-bottom">
<div class="w3-col w3-hide-small" style="width:26%;">
<img src="<?=BASE_URL.PATH.'imagini/'.$rowgetimg['nume_fisier']?>" style="width:100px;height:100px;" alt="" class="w3-margin"/>
</div>
<div class="w3-col w3-hide-medium w3-hide-large" style="width:30%;">
<img src="<?=BASE_URL.PATH.'imagini/'.$rowgetimg['nume_fisier']?>" style="width:70px;height:70px;" alt=""/>
</div>
<div class="w3-col w3-hide-small" style="width:74%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text($rowlast5['titlu'], 36); ?></h5>
<div style="text-align: justify;padding-left:5px;padding-right:5px;">
<span><?php echo lungime_text($rowlast5['descriere'], 90); ?></span></div>
<div class="w3-row w3-border-top w3-blue">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rowlast5['pret'] > 0){echo '<strong>'.$rowlast5['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 $rowlast5['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($rowlast5['data_publicarii'])); ?>
</div>
</div>

</div>

<div class="w3-col w3-hide-medium w3-hide-large" style="width:70%;">
<h6 class="w3-border-bottom">
<?php echo lungime_text($rowlast5['titlu'], 22); ?>
</h6>
<span><?php echo lungime_text($rowlast5['descriere'], 42); ?></span>
</div>
</div></a>
<?php } ?>
   </div>
   
   <div class="w3-half w3-padding">
   <h3 class="w3-container w3-indigo" style="padding-bottom:5px;">Cele mai populare</h3>
<?php
function lungime_text2($x, $length){
  if(strlen($x)<=$length){
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
   $qlast5 = "SELECT * FROM `anunturi` WHERE `verificat` IS NULL ORDER BY `vizualizari` DESC LIMIT 5";
   $rlast5 = $dbc->query($qlast5);
   while($rowlast5 = $rlast5->fetch_assoc()){
       $qgetimage = "SELECT * FROM `imagini` WHERE `aid`={$rowlast5['aid']}";
       $rgetimage = $dbc->query($qgetimage);
       $rowgetimg = $rgetimage->fetch_assoc();
       
       $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rowlast5['uid']}";
       $rgetuser = $dbc->query($qgetuser);
       $rowgetusr = $rgetuser->fetch_assoc();         
?>
<a href="<?=PATH.$rowlast5['seo']?>.html">
<div class="w3-row w3-hover-light-gray w3-text-black w3-card w3-margin-bottom">
<div class="w3-col w3-hide-small" style="width:26%;">
<img src="<?=BASE_URL.PATH'imagini/'.$rowgetimg['nume_fisier']?>" style="width:100px;height:100px;" alt="" class="w3-margin"/>
</div>
<div class="w3-col w3-hide-medium w3-hide-large" style="width:30%;">
<img src="<?=BASE_URL.PATH'imagini/'.$rowgetimg['nume_fisier']?>" style="width:70px;height:70px;" alt=""/>
</div>
<div class="w3-col w3-hide-small" style="width:74%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text2($rowlast5['titlu'], 36); ?></h5>
<div style="text-align: justify;padding-left:5px;padding-right:5px;">
<span><?php echo lungime_text2($rowlast5['descriere'], 90); ?></span></div>
<div class="w3-row w3-border-top w3-blue">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rowlast5['pret'] > 0){echo '<strong>'.$rowlast5['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 $rowlast5['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($rowlast5['data_publicarii'])); ?>
</div>
</div>

</div>

<div class="w3-col w3-hide-medium w3-hide-large" style="width:70%;">
<h6 class="w3-border-bottom">
<?php echo lungime_text2($rowlast5['titlu'], 22); ?>
</h6>
<span><?php echo lungime_text2($rowlast5['descriere'], 42); ?></span>
</div>
</div></a>
<?php } ?>
   </div>
 </div>

</div></div>