<?php
session_start();
include('../conexion.php');
include('../include/sesiones.php');





$email = $_POST['email'];
$password = $_POST['password'];

$sql = mysqli_query($con, "SELECT * FROM cliente WHERE clie_correo='" . $email . "' AND clie_clave='" . $password . "' and empresa='$emp_id' ")
  or die(mysqli_error($con));
if ($row = mysqli_fetch_array($sql)) {
  $_SESSION['clie_id'] = $row["clie_id"];

  if (isset($_POST['voy'])) {
    echo '<center><img src="../img/a.gif" style="height:100px"> CARGANDO...</center>';
    echo '<meta http-equiv="refresh" content="2;url=cart.php?modal=si">';
  } else if (isset($_POST['art_id'])) {

    $clie_id = $_SESSION['clie_id'];
    $art_id = $_POST['art_id'];

    $sqll = mysqli_query($con, "SELECT * FROM cotizacion_detalle_deseo WHERE cotd_art_id='$art_id' and clie_id='$clie_id'");
    if ($roww = mysqli_fetch_array($sqll)) {
      echo '
        <div class="fixedContainer">
          <center><img src="../img/error.png">El articulo ya se esta agregado.</center>
        </div>';
    } else {
      $registros = mysqli_query($con, "INSERT into cotizacion_detalle_deseo (cotd_art_id,clie_id) VALUES  ('$art_id','$clie_id')") or die(mysqli_error($con));
      //echo '<meta http-equiv="refresh" content="2;url=index.php">';
      echo '<div class="fixedContainer">
          <center><img src="../img/deseo.png">Se agrego a deseos.</center>
        </div>';
    }

?>

    <script>
      $(document).ready(function() {
        setTimeout(function() {
          $(".fixedContainer").fadeOut(1000);
        }, 1000);
      });
    </script>
    <style>
      .fixedContainer {
        background-color: #ffff;
        position: fixed;
        padding: 2em;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 10000;
        border-radius: 5px;
        ;
      }
    </style>
    <script>
      window.history.back();
    </script>
  <?php
  } else if (isset($_POST['voy_deseo'])) {
    echo '<center><img src="img/cargar.gif"> CARGANDO...</center>';
    echo '<meta http-equiv="refresh" content="2;url=deseos.php">';
  } else {
    echo '<center><img src="img/cargar.gif"> CARGANDO...</center>';
    echo '<script>setTimeout(function(){ window.location.reload(); }, 2000);</script>';

  }
} else {
  echo ' 
<div class="alert alert-danger alert-dismissible" role="alert">
Su contraseña y/o correo son incorrectos.
</div>'; ?>


<?php } ?>