<?php
/*$qimg = "SELECT * FROM `imagini` WHERE `aid`='{$row['aid']}' LIMIT 1";
$rimg = $dbc->query($qimg);
while($rowimg = $rimg->fetch_assoc()){
    $poza = $rowimg['nume_fisier'];
}*/
$qusr = "SELECT * FROM `utilizatori` WHERE `uid`='{$row['uid']}' LIMIT 1";
$rusr = $dbc->query($qusr);
while($rowusr = $rusr->fetch_assoc()){
    $usruid       = $rowusr['uid'];
    $usremail     = $rowusr['email'];
    $usrprenume   = $rowusr['prenume'];
    $usrnume      = $rowusr['nume'];
    $usrmobil     = $rowusr['mobil'];
    $usrmoneda    = $rowusr['moneda'];
}

$getusermail = explode("@", $usremail);
$eusername = $getusermail[0];

?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-container w3-indigo">
<h3><?=$row['titlu']?></h3>
</div>

<div class="w3-container w3-card">

<div class="w3-half w3-margin-top w3-margin-bottom">
<img src="<?php echo BASE_URL.PATH.'imagini/'.$poza?>" alt="<?=$row['titlu']?>" style="width:100%;max-width:100%;"/>
</div>

<div class="w3-half w3-margin-top w3-margin-bottom">

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

<div class="w3-row w3-border-bottom">
<div class="w3-right">
Anunt adaugat de <strong><?php if($usrprenume){echo $usrprenume;}else{echo 'user-'.$eusername.'-adydev-'.$usruid;} ?></strong>
</div></div>

<div class="w3-row w3-border-bottom">
<div class="w3-center w3-margin">
<h4>Preț: <?=$row['pret']?> <?=$usrmoneda?></h4>
</div></div>

<div class="w3-row w3-right">
<div class="w3-margin">
 
<button class="w3-button w3-blue w3-hover-indigo w3-padding-small" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=<?php echo 'https://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; ?>&amp;src=sdkpreparse', 'Share This', 'menubar=no,toolbar=no,resizable=no,scrollbars=no, width=600,height=455');">
<i class="fa fa-facebook w3-large"></i> Facebook</button>

<button class="w3-button w3-aqua w3-hover-blue w3-padding-small" onclick="window.open('https://twitter.com/intent/tweet?text=<?=$row['titlu']?>+<?php echo 'https://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; ?>', 'Publică un tweet pe twitter', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,width=600,height=455');">
<i class="fa fa-twitter w3-large"></i> Twitter</button>

<button class="w3-button w3-green w3-hover-teal w3-padding-small" onclick="window.open('https://api.whatsapp.com/send?text=Am găsit o pagină care te interesa pe <?=BASE_NAME?>, despre: ***<?=$row['titlu']?>***, să arunci o privire când ai timp.', 'Trimite pagina pe WhatsApp', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,width=600,height=455');">
<i class="fa fa-whatsapp w3-large"></i> WhatsApp</button>

<button class="w3-button w3-blue w3-hover-indigo w3-padding-small" onclick="window.open('contact.html?trimitere=1&text=Am găsit o pagină care te interesa pe <?=BASE_NAME?>, despre: ***<?=$row['titlu']?>***, să arunci o privire când ai timp.', 'Trimite E-mail unui prieten', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,width=600,height=455');">
<i class="fa fa-envelope-o w3-large"></i> E-mail</button>

</div></div>

<div class="w3-map">
<iframe src="https://maps.google.com/maps?q=<?php echo $row['judet']; ?>&t=&z=8&ie=UTF8&iwloc=&output=embed" width="600" height="285" frameborder="0" style="width:100%;border:0;" allowfullscreen=""></iframe>
</div>

<div class="w3-bar w3-div-bottom">
<a class="w3-button w3-bar-item w3-blue w3-hover-indigo w3-hide-large" style="width:40%;">Sună</a>
<a href="#mesaj" class="w3-button w3-bar-item w3-blue w3-hover-indigo w3-hide-small w3-hide-medium" style="width:40%;">Mesaj</a>
<?php if($usrmobil == true){ ?>
<a href="https://api.whatsapp.com/send?phone=<?=$usrmobil?>&text=Vă contactez de pe <?=BASE_NAME?>, în legătură cu anunțul: ***<?=$row['titlu']?>*** și vreau să i-au legătura cu dvs. Mulțumesc!" target="_blank" class="w3-button w3-bar-item w3-green w3-hover-teal" style="width:60%;"><i class="fa fa-whatsapp"></i> WhatsApp</a>
<?php }else{ ?>
<a class="w3-button w3-bar-item w3-red w3-hover-red" style="width:60%;"><i class="fa fa-ban"></i> Fără telefon</a>
<?php } ?>
</div>

</div>

<p class="w3-padding w3-border-bottom"><i class="fa fa-tags"></i>
<?php
$tags = explode(',', $row['etichete']);

foreach ($tags as $tag) {
    $tag = trim($tag);
    echo '<a class="w3-button w3-padding-small" href="' . BASE_URL . 'eticheta-' . $tag . '.html" style="text-decoration:none;">' . $tag . '</a>';
}
?>
</p>

<div class="w3-row w3-border-bottom">
<p style="white-space: pre-line;"><?=$row['descriere']?></p>
<p class="w3-right" style="margin-right:5px;">Vizualizări: <?=$row['vizualizari']?></p>
</div>

<div class="w3-row w3-margin-top" id="mesaj">
<h4>Contactează vânzătorul</h4>
<?php if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire'.$pagext)) {
if($usrmobil == true){   
?>
<h5>Telefon: <i class="fa fa-phone"></i> <?=$usrmobil?></h5>
<?php } ?>
<label>Trimite un mesaj vanzatorului</label>

<form action="" method="post">
<textarea class="w3-input w3-border w3-round" title="Mesajul tau..." name="mesaj"></textarea>
<div class="w3-center w3-margin">
<button type="submit" class="w3-button w3-blue w3-hover-black"><i class="fa fa-envelope-o"></i> Trimite</button>
</div>
</form>
<?php } else{ if($usrmobil == true){ ?>
<h5>Telefon: <i class="fa fa-phone"></i> <?php
function mascareNumarTelefon($numar){    
    $masc_numar =  substr($numar, 0, 2) . '- <a onclick="document.getElementById(\'acces\').style.display=\'block\'" class="w3-button w3-green w3-padding-small">autentificare</a>';    
    return $masc_numar;}
echo mascareNumarTelefon($usrmobil);
}
?></h5>  
<label>Trimite un mesaj vanzatorului</label>
<textarea class="w3-input w3-border w3-round" title="Mesajul tau..." disabled="">Trebuie să fi autentificat pentru a transmite un mesaj...</textarea>
<div class="w3-center w3-margin">
<a onclick="document.getElementById('acces').style.display='block'" class="w3-button w3-green w3-hover-black" style="text-decoration:none;">Autentificare</a>
<?php } ?>
</div>

</div>

</div>



</div></div>