<?php 
require_once('xconn.php');
session_start();
 
  if(!isset($_SESSION['d_usuario'])){
    header('Location: index.php');
    exit;
  }else{
    $iUsuario = $_SESSION['c_usuario'];
  }

  if ($conn ->connect_error) {
  die("Connection failed: " . $conn ->connect_error);
  }

  if(isset($_POST['btn_estadocivil'])){
   
  $estadocivil = $_POST['txt_estadocivil'];
   
  $sql = "INSERT INTO `t_catalogoestadocivil`(`d_nombre`) VALUES ('$estadocivil')";

    if ($conn->query($sql) === TRUE) {
      echo'<script type="text/javascript">
          alert("Opcion Agregada");
          </script>';
    } else {
      echo'<script type="text/javascript">
          alert("Error:  $sql <br> $conn->error");
          </script>';
    }
   
  }

  if(isset($_POST['btn_genero'])){
   
    $genero = $_POST['txt_genero'];
     
    $sql = "INSERT INTO `t_catalogogenero`(`d_genero`) VALUES ('$genero')";

      if ($conn->query($sql) === TRUE) {
        echo'<script type="text/javascript">
            alert("Opcion Agregada");
            </script>';
      } else {
        echo'<script type="text/javascript">
            alert("Error:  $sql <br> $conn->error");
            </script>';
      }
  }

  if(isset($_POST['btn_vivienda'])){
   
    $tipovivienda = $_POST['txt_vivienda'];
     
    $sql = "INSERT INTO `t_catalogotipovivienda`(`d_tipovivienda`) VALUES ('$tipovivienda')";

      if ($conn->query($sql) === TRUE) {
        echo'<script type="text/javascript">
            alert("Opcion Agregada");
            </script>';
      } else {
        echo'<script type="text/javascript">
            alert("Error: vivienda $sql <br> $conn->error");
            </script>';
      }
  }

  if(isset($_POST['btn_actividad'])){
   
    $tipoactividad = $_POST['txt_actividad'];
     
    $sql = "INSERT INTO `t_catalogotipoactividad`(`d_tipoactividad`) VALUES ('$tipoactividad')";

      if ($conn->query($sql) === TRUE) {
        echo'<script type="text/javascript">
            alert("Opcion Agregada");
            </script>';
      } else {
        echo'<script type="text/javascript">
            alert("Error:  actividad $sql <br> $conn->error");
            </script>';
      }
  }

  if(isset($_POST['btn_producto'])){
   
    $producto = $_POST['txt_producto'];
     
    $sql = "INSERT INTO `t_catalogoproducto`(`d_producto`) VALUES ('$producto')";

      if ($conn->query($sql) === TRUE) {
        echo'<script type="text/javascript">
            alert("Opcion Agregada");
            </script>';
      } else {
        echo'<script type="text/javascript">
            alert("Error:  producto $sql <br> $conn->error");
            </script>';
      }
  }

  if(isset($_POST['btn_plaza'])){
   
    $plaza = $_POST['txt_plaza'];
     
    $sql = "INSERT INTO `t_catalogoplaza`(`d_plaza`) VALUES ('$plaza')";

      if ($conn->query($sql) === TRUE) {
        echo'<script type="text/javascript">
            alert("Opcion Agregada");
            </script>';
      } else {
        echo'<script type="text/javascript">
            alert("Error:  plaza $sql <br> $conn->error");
            </script>';
      }
  }

  if(isset($_POST['btn_bancos'])){
   
    $bancos = $_POST['txt_bancos'];
     
    $sql = "INSERT INTO `t_catalogobancos`(`d_banco`) VALUES ('$bancos')";

      if ($conn->query($sql) === TRUE) {
        echo'<script type="text/javascript">
            alert("Opcion Agregada");
            </script>';
      } else {
        echo'<script type="text/javascript">
            alert("Error:  bancos $sql <br> $conn->error");
            </script>';
      }
  }


?>
<html>
<head>
  <title>Diaso | Brokers</title>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <!--     Fonts and icons     -->
  <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
  <!-- Material Kit CSS -->
  <link href="assets/css/material-dashboard.css?v=2.1.2" rel="stylesheet" />

</head>

<body>
  <div class="wrapper ">
    <div class="sidebar" data-color="azure" data-background-color="black">
      <!--
      Tip 1: You can change the color of the sidebar using: data-color="purple | azure | green | orange | danger"

      Tip 2: you can also add an image using data-image tag
  -->
      <div class="logo">
        <a href="https://diaso.com.mx/" class="simple-text logo-mini">
          Brokers -
          Diaso
        </a>
        <img src="img/logo.png" width="200" height="100"/>
      </div>
      <div class="sidebar-wrapper">
        <ul class="nav">
          <li class="nav-item">
            <a class="nav-link" href="dashboard.php">
              <i class="material-icons">dashboard</i>
              <p>Dashboard</p>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="clientes.php">
              <i class="material-icons">dashboard</i>
              <p>Clientes</p>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="solicitudes.php">
              <i class="material-icons">dashboard</i>
              <p>Solicitudes</p>
            </a>
          </li>
          <li class="nav-item active">
            <a class="nav-link" href="catalogos.php">
              <i class="material-icons">dashboard</i>
              <p>Catalogos</p>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="users.php">
              <i class="material-icons">dashboard</i>
              <p>Usuarios</p>
            </a>
          </li>
          
          <li class="nav-item active-pro ">
              <p>Disponible en: Web & Movil</p>
          </li>
          <!-- your sidebar here -->
        </ul>
      </div>
    </div>
    <div class="main-panel">
      <!-- Navbar -->
      <nav class="navbar navbar-expand-lg navbar-transparent navbar-absolute fixed-top ">
        <div class="container-fluid">
          <div class="navbar-wrapper">
            <a class="navbar-brand" href="javascript:;">Catalogos</a>
          </div>
          <button class="navbar-toggler" type="button" data-toggle="collapse" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
            <span class="sr-only">Toggle navigation</span>
            <span class="navbar-toggler-icon icon-bar"></span>
            <span class="navbar-toggler-icon icon-bar"></span>
            <span class="navbar-toggler-icon icon-bar"></span>
          </button>
          <div class="collapse navbar-collapse justify-content-end">
            <ul class="navbar-nav">
              <li class="nav-item">
                <a class="nav-link" href="javascript:;">
                  <i class="material-icons">notifications</i> Notificaciones
                </a>
              </li>
              <li class="nav-item dropdown">
                <a class="nav-link" href="javascript:;" id="navbarDropdownProfile" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <i class="material-icons">person</i>Hola <?php echo', ' . $_SESSION['d_usuario'] . '.'; ?>
                  <p class="d-lg-none d-md-block">
                    Hola, <?php 'Edgar Mejia'; ?>
                  </p>
                </a>
                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownProfile">
                  <a class="dropdown-item" href="profile.php">Perfil</a>
                  <a class="dropdown-item" href="configuration.php">Configuracion</a>
                  <div class="dropdown-divider"></div>
                  <a class="dropdown-item" href="xlogout.php">Salir</a>
                </div>
              </li>
              <!-- your navbar here -->
            </ul>
          </div>
        </div>
      </nav>
      
      <!-- End Navbar -->
      <div class="content">
        <div class="container-fluid">
          <div class="col-lg-12 col-md-12">
              <div class="card">
                <div class="card-header card-header-tabs card-header-primary">
                  <div class="nav-tabs-navigation">
                    <div class="nav-tabs-wrapper">
                      <span class="nav-tabs-title">Alta de Catalogos</span>
                      <ul class="nav nav-tabs" data-tabs="tabs">
                        <li class="nav-item">
                          <a class="nav-link active" href="#estadocivil" data-toggle="tab">
                            <i class="material-icons">view_list</i> Estado Civil
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#genero" data-toggle="tab">
                            <i class="material-icons">view_list</i> Genero
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#vivienda" data-toggle="tab">
                            <i class="material-icons">view_list</i> Vivienda
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#actividad" data-toggle="tab">
                            <i class="material-icons">view_list</i> Actividad
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#producto" data-toggle="tab">
                            <i class="material-icons">view_list</i> Producto
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#plaza" data-toggle="tab">
                            <i class="material-icons">view_list</i> Plaza
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#bancos" data-toggle="tab">
                            <i class="material-icons">view_list</i> Bancos
                            <div class="ripple-container"></div>
                          </a>
                        </li>
                      </ul>
                    </div>
                  </div>
                </div>
                <div class="card-body">
                  <div class="tab-content">
                    <div class="tab-pane active" id="estadocivil">
                      <form method="post" id="festadocivil" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                        <div class="row">
                          <div class="col-md-3"></div>
                          <div class="col-md-6">
                            <label class="bmd-label-floating">Nombre</label>
                            <input type="text" name="txt_estadocivil" maxlength="20" class="form-control"><br>
                            <input type="submit" name="btn_estadocivil" value="Agregar al Catalogo" class="btn btn-primary pull-right"><br>
                            <div class="card-body">
                              <div class="table-responsive">
                                <table class="table">
                                  <thead class=" text-primary">
                                    <th>
                                      Nombre
                                    </th>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $result2 = mysqli_query($conn,"SELECT d_nombre FROM t_catalogoestadocivil");
                                      while ($valores = mysqli_fetch_array($result2)) {
                                        echo '<tr>';
                                        echo '<td>' .$valores['d_nombre']. '</td>';
                                        echo '</tr>';
                                      }
                                          
                                    ?>
                                    
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-3"></div>
                        </div>
                      </form>
                    </div>
                    <div class="tab-pane" id="genero">
                      <form method="post" id="fgenero" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                        <div class="row">
                          <div class="col-md-3"></div>
                          <div class="col-md-6">
                            <label class="bmd-label-floating">Genero</label>
                            <input type="text" name="txt_genero" maxlength="20" class="form-control"><br>
                            <input type="submit" name="btn_genero" value="Agregar al Catalogo" class="btn btn-primary pull-right"><br>

                            <div class="card-body">
                              <div class="table-responsive">
                                <table class="table">
                                  <thead class=" text-primary">
                                    <th>
                                      Nombre
                                    </th>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $result2 = mysqli_query($conn,"SELECT d_genero FROM t_catalogogenero");
                                      while ($valores = mysqli_fetch_array($result2)) {
                                        echo '<tr>';
                                        echo '<td>' .$valores['d_genero']. '</td>';
                                        echo '</tr>';
                                      }
                                          
                                    ?>
                                    
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-3"></div>
                        </div>
                      </form>
                    </div>
                    <div class="tab-pane" id="vivienda">
                      <form method="post" id="fvivienda" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                        <div class="row">
                          <div class="col-md-3"></div>
                          <div class="col-md-6">
                            <label class="bmd-label-floating">Tipo de Vivienda</label>
                            <input type="text" name="txt_vivienda" maxlength="20" class="form-control"><br>
                            <input type="submit" name="btn_vivienda" value="Agregar al Catalogo" class="btn btn-primary pull-right"><br>

                            <div class="card-body">
                              <div class="table-responsive">
                                <table class="table">
                                  <thead class=" text-primary">
                                    <th>
                                      Nombre
                                    </th>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $result2 = mysqli_query($conn,"SELECT d_tipovivienda FROM t_catalogotipovivienda");
                                      while ($valores = mysqli_fetch_array($result2)) {
                                        echo '<tr>';
                                        echo '<td>' .$valores['d_tipovivienda']. '</td>';
                                        echo '</tr>';
                                      }
                                          
                                    ?>
                                    
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-3"></div>
                        </div>
                      </form>
                    </div>
                    <div class="tab-pane" id="actividad">
                      <form method="post" id="factividad" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                        <div class="row">
                          <div class="col-md-3"></div>
                          <div class="col-md-6">
                            <label class="bmd-label-floating">Tipo de Actividad</label>
                            <input type="text" name="txt_actividad" maxlength="20" class="form-control"><br>
                            <input type="submit" name="btn_actividad" value="Agregar al Catalogo" class="btn btn-primary pull-right"><br>

                            <div class="card-body">
                              <div class="table-responsive">
                                <table class="table">
                                  <thead class=" text-primary">
                                    <th>
                                      Nombre
                                    </th>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $result2 = mysqli_query($conn,"SELECT d_tipoactividad FROM t_catalogotipoactividad");
                                      while ($valores = mysqli_fetch_array($result2)) {
                                        echo '<tr>';
                                        echo '<td>' .$valores['d_tipoactividad']. '</td>';
                                        echo '</tr>';
                                      }
                                          
                                    ?>
                                    
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-3"></div>
                        </div>
                      </form>
                    </div>
                    <div class="tab-pane" id="producto">
                      <form method="post" id="fproducto" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                        <div class="row">
                          <div class="col-md-3"></div>
                          <div class="col-md-6">
                            <label class="bmd-label-floating">Producto</label>
                            <input type="text" name="txt_producto" maxlength="20" class="form-control"><br>
                            <input type="submit" name="btn_producto" value="Agregar al Catalogo" class="btn btn-primary pull-right"><br>

                            <div class="card-body">
                              <div class="table-responsive">
                                <table class="table">
                                  <thead class=" text-primary">
                                    <th>
                                      Nombre
                                    </th>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $result2 = mysqli_query($conn,"SELECT d_producto FROM t_catalogoproducto");
                                      while ($valores = mysqli_fetch_array($result2)) {
                                        echo '<tr>';
                                        echo '<td>' .$valores['d_producto']. '</td>';
                                        echo '</tr>';
                                      }
                                          
                                    ?>
                                    
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-3"></div>
                        </div>
                      </form>
                    </div>
                    <div class="tab-pane" id="plaza">
                      <form method="post" id="fplaza" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                        <div class="row">
                          <div class="col-md-3"></div>
                          <div class="col-md-6">
                            <label class="bmd-label-floating">Plaza</label>
                            <input type="text" name="txt_plaza" maxlength="20" class="form-control"><br>
                            <input type="submit" name="btn_plaza" value="Agregar al Catalogo" class="btn btn-primary pull-right"><br>

                            <div class="card-body">
                              <div class="table-responsive">
                                <table class="table">
                                  <thead class=" text-primary">
                                    <th>
                                      Nombre
                                    </th>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $result2 = mysqli_query($conn,"SELECT d_plaza FROM t_catalogoplaza");
                                      while ($valores = mysqli_fetch_array($result2)) {
                                        echo '<tr>';
                                        echo '<td>' .$valores['d_plaza']. '</td>';
                                        echo '</tr>';
                                      }
                                          
                                    ?>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-3"></div>
                        </div>
                      </form>
                    </div>
                    <div class="tab-pane" id="bancos">
                      <form method="post" id="fbancos" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                        <div class="row">
                          <div class="col-md-3"></div>
                          <div class="col-md-6">
                            <label class="bmd-label-floating">Bancos</label>
                            <input type="text" name="txt_bancos" maxlength="20" class="form-control"><br>
                            <input type="submit" name="btn_bancos" value="Agregar al Catalogo" class="btn btn-primary pull-right"><br>

                            <div class="card-body">
                              <div class="table-responsive">
                                <table class="table">
                                  <thead class=" text-primary">
                                    <th>
                                      Nombre
                                    </th>
                                  </thead>
                                  <tbody>
                                    <?php
                                      $result2 = mysqli_query($conn,"SELECT d_banco FROM t_catalogobancos");
                                      while ($valores = mysqli_fetch_array($result2)) {
                                        echo '<tr>';
                                        echo '<td>' .$valores['d_banco']. '</td>';
                                        echo '</tr>';
                                      }
                                          
                                    ?>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                          <div class="col-md-3"></div>
                        </div>
                      </form>
                    </div>
                  </div>
                </div>
              </div>
            </div>
        </div>
      </div>
      <footer class="footer">
        <div class="container-fluid">
          <nav class="float-left">
            <ul>
              <li>
                <a href="https://diaso.com.mx/">
                  Brokers
                </a>
              </li>
            </ul>
          </nav>
          <div class="copyright float-right">
            &copy;
            <script>
              document.write(new Date().getFullYear())
            </script>, Diaso.
            <a href="xlogout.php" class="btn btn-primary btn-round">Salir</a>
          </div>
          <!-- your footer here -->
        </div>
      </footer>
    </div>
  </div>

  <script src="assets/js/core/jquery.min.js"></script>
  <script src="assets/js/core/popper.min.js"></script>
  <script src="assets/js/core/bootstrap-material-design.min.js"></script>
  <script src="assets/js/plugins/perfect-scrollbar.jquery.min.js"></script>


</body>
</html>