<?php
  require "login/dbconf.php";
  $conn = mysqli_connect($host,$user,$password,$db_name);

  $mysqli = new mysqli($host, $user, $password, $db_name);

  $mysqli->set_charset("utf8");

  if(mysqli_connect_errno()){
      die("Conexão falhou: ".mysqli_connect_errno());
  }

  $usr = $_SESSION['username'];

  $sql = "SELECT * FROM myblob WHERE user = '$usr'";

  $result = mysqli_query($conn,$sql);

  echo '<div style="display: flex; flex-wrap: wrap; justify-content:space-between; align-items:strech; flex-direction: column;">';
  
  while($linha = mysqli_fetch_assoc($result)){
    $items[] = $linha;
  }

  $items = array_reverse($items, true);

  foreach($items as $row){

    echo "<div class='rounded' style='background-color: white; border: 2px solid #0779e4; border-radius: 35px !important; margin-bottom: 10px; padding:20px; width: 100%'>";
    $autores = "";
    if($row['user'] == $_SESSION['username']){

      echo "<h1 style='font-size: 19px'>".$row['nome_artigo']."</h1>";
      
      for($i = 1; $i <= 15; $i++){        
        
        $autores .= $row['autor'.$i].", ";
        
        
      }
      $autores = rtrim($autores,", ");      
      echo "<p>Autores: ".$autores."</p>";
      echo '
        <h1 style="font-size: 17px;">Status do pagamento</h1>
        <div id="steps">
          

          <div class="step done" data-desc="Aguardando pagamento">1</div>

          <div class="step done" data-desc="Pagamento Aprovado">2</div>
          
        </div>
      ';
      echo '
      <h1 style="font-size: 17px;">Status da publicação</h1>
      <div id="steps">        

        <div class="step done" data-desc="Em conferência">1</div>

        <div class="step done" data-desc="Em edição">1</div>

        <div class="step active" data-desc="Publicado">2</div>
        
      </div>
    ';

      echo "<div display: flex; flex-direction: row !important;><form style='margin: 0; width: 40%;' action='pagamento/paginapagamento.php' method='POST'>
            
            <input type='hidden' name='idArt' value=".$row['id']."></input>
            <button type='submit' class='btn btn-primary'>Pagar</button>
          </form></br>
          <form style='margin: 0; width: 40%;' action='alterarform.php' method='POST'><td style='border: 2px solid #fff; padding: 15px;	border-collapse: collapse;'>
            <input type='hidden' name='idArt' value=".$row['id']."></input>
            <button type='submit' class='btn btn-primary'>Alterar</button>
          </form></div>";
      echo "</div>";   
    } 
    
  }

  echo "</div>";

  mysqli_close($conn);
?>
