<?php
session_start();
include("connectdb.php");

if ($_SESSION["useremail"]==""){
    
    header("location:index.php");
}
include_once"header.php";

$produit=$pdo->prepare('SELECT COUNT(*) AS nbr1 FROM tbl_product');
$produit->execute(array());
while ($produits=$produit->fetch()) {
  $nbr1=$produits['nbr1'];
}

$vente=$pdo->prepare('SELECT COUNT(*) AS nbr2 FROM tbl_invoice');
$vente->execute(array());
while ($ventes=$vente->fetch()) {
  $nbr2=$ventes['nbr2'];
}

$rupture=$pdo->prepare('SELECT COUNT(*) AS nbr3 FROM tbl_product WHERE pstock <= seuil_faible');
$rupture->execute(array());
while ($ruptures=$rupture->fetch()) {
  $nbr3=$ruptures['nbr3'];
}

$sel=$pdo->prepare('SELECT * FROM param');
$sel->execute(array());
while ($sels=$sel->fetch()) {
  $_SESSION['raison_sociale']=$sels['raison_sociale'];
  $_SESSION['adresse']=$sels['adresse'];
  $_SESSION['tel']=$sels['tel'];
  $_SESSION['format']=$sels['format'];
}


?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Tableau de bord</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="logout.php">Déconnexion</a></li>
              <li class="breadcrumb-item active"><a href="changepassword.php">Modifier mon mot de passe</a></li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <div class="content">
      <div class="container-fluid">
        <div class="row">

          <div class="col-lg-4">
            <div class="card" style="width: 18rem;">
              <a href="productlist.php" >
              <div class="card-body">
                <h5 class="card-title">Nombre de produits disponibles</h5>
                <p class="card-text text-center"><?php echo $nbr1; ?></p>
              </div>
              </a>
            </div>
          </div>

          <div class="col-lg-4">
            <div class="card" style="width: 18rem;">
              <a href="orderlist.php" >
              <div class="card-body">
                <h5 class="card-title">Nombre de ventes réalisées</h5>
                <p class="card-text text-center"><?php echo $nbr2; ?></p>
              </div>
              </a>
            </div>
          </div>

          <div class="col-lg-4">
            <div class="card" style="width: 18rem;">
              <a href="rupture.php" >
              <div class="card-body">
                <h5 class="card-title">Nombre de produits en rupture</h5>
                <p class="card-text text-center"><?php echo $nbr3; ?></p>
              </div>
              </a>
            </div>
          </div>

          </div>
          <!-- /.col-md-6 -->
         
          <!-- /.col-md-6 -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content -->
  
  <!-- /.content-wrapper -->

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
    <div class="p-3">
      <h5>Title</h5>
      <p>Sidebar content</p>
    </div>
  </aside>
  <!-- /.control-sidebar -->

 <?php
include_once"footer.php";


?>