<?php 

    // session_start();

// include('../../../Ulices/validadores/validarSession.php');
include('../StoGlobal/include/conexion.php');
include('../StoGlobal/include/conexion1.php');
// include('../Stoglobal/include/conexion2.php');
include('../StoGlobal/include/conexion3.php');

$continente=$_POST['estado'];



      date_default_timezone_set('America/Santiago');
      $fechasa=date("Y-m-d");

      
// ADD New Cliente
if($continente==1 ){

  echo $cadena="
    </br>
    <div><h3>Ingresar - Nuevo Cliente</h3></div>
    </br>

    <div class='d-flex'>
      <div class='form-floating col-md-6 mt-3 m-auto'  id='fecha_inicio' >
          <input type='date' id='fecha_inicio' name='fecha_inicio' class='form-control date' value='$fechasa'>
          <label for='floatingSelectGrid'>Fecha Inicio Contacto</label>
      </div> 
    </div>

    <div class='d-flex'>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='rut_empresa'>
        <input type='text' class='form-control text-left' id='rut_empresa' name='rut_empresa' placeholder='1' required>
        <label for='rut_empresa'>Rut Empresa</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='rut_personal'>
        <input type='text' class='form-control text-left' id='rut_personal' name='rut_personal' placeholder='1' required>
        <label for='rut_personal'>Rut Personal</label>
      </div>

    </div>

    <div class='d-flex'>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='nombre_apellido'>
        <input type='text' class='form-control text-left' id='nombre_apellido' name='nombre_apellido' placeholder='1' required>
        <label for='nombre_apellido'>Nombres y Apellidos</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='cargo'>
        <input type='text' class='form-control text-left' id='cargo' name='cargo' placeholder='1' required>
        <label for='cargo'>Cargo</label>
      </div>

    </div>

    <div class='d-flex'>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='razon_social'>
        <input type='text' class='form-control text-left' id='razon_social' name='razon_social' placeholder='1' required>
        <label for='razon_social'>Razón Social</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='correo'>
        <input type='text' class='form-control text-left' id='correo' name='correo' placeholder='1' required>
        <label for='correo'>Correo</label>
      </div>

    </div>
    
    <div class='d-flex'>
      <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='detalle'>
        <textarea class='form-control' placeholder='1' name='detalle' id='detalle' required></textarea>
        <label for='detalle'>Detalle de la empresa</label>
      </div>
    </div>
    <div class='d-flex'>
      <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='comentarios'>
        <textarea class='form-control' placeholder='1' name='comentarios' id='comentarios' required></textarea>
        <label for='comentarios'>Comentario Adicional</label>
      </div>
    </div>
    ";
}



// ADD Producto Bodega StoGlobal
if($continente==2 ){

    $query = "select MAX(cod_producto) as 'cod_producto' from sto_bodega ";
    $stmt = $DBcon->prepare( $query );
    $stmt->execute();
    
    if($stmt->rowCount() > 0) {
        while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
            extract($row);
                $UltimoCod_Producto=$cod_producto;
                $ProxCod_producto=$UltimoCod_Producto+1;
        }
    }

  echo $cadena="
  </br>
  <div><h3>Ingresar Productos Bodega</h3></div>
  </br>

  <div class='d-flex'>
  <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='detalle'>
    <h5>Último Código Ingresado: $UltimoCod_Producto </h5>
  </div>
  </div>

  <div class='d-flex'>

      <div class='form-floating col-md-10 mt-3 m-auto  text-left' >
          <select name='folio_factura' id='folio_factura'  class='form-select' required>
            <option value=''>Selecciona una Factura</option>
    ";
      
             
                  
                  $query1 = "SELECT * FROM `sto_dte_compra` where `comp_tipo_estado`=1 ";
                  $stmt1 = $DBcon->prepare( $query1 );
                  $stmt1->execute();  

                  if($stmt1->rowCount() > 0) {
                      while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)) {
                          extract($row1);  

                          echo "<option value='".$comp_folio."'>".$comp_folio." </option>";
                      }
                  }

    echo $cadena="

          </select>
          <label for='floatingSelectGrid'>Asociar Folio Factura</label>
      </div>

  </div>


  ";


  ?>
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>

    <script type="text/javascript" src="../../js/sweetalert2.js"></script>
    <script type="text/javascript" src="../../js/sweetalert2.min.js"></script>
    <link rel="stylesheet" href="../../css/sweetalert2.css" type="text/css">
    <link rel="stylesheet" href="../../css/sweetalert2.min.css" type="text/css">
    <script src="../../js/jquery-2.1.4.min.js"></script>
    <script src="js/linea_it.js"></script>
    <script type="text/javascript" src="https://znd7pgylblorbdefs-sii.siteintercept.qualtrics.com/SIE/?Q_ZID=ZN_d7pgyLBlORbDEfs"></script>


    <?php 
      
        $fila_1=$ProxCod_producto+1;
        // $filas_0=$fila_1;
    
    ?>

    <script>

    $(".formattedNumberField").on('keyup', function(){
        this.value = this.value.replace(/[^\d]/g, "");
      });

        var myTable = document.querySelector("table"); 
        function agregarFila(){ 

              // var is = 1;
          
              var i = $("#ContadorCeldas").val();
              var ia = $("#Count_codID").val();
              var row = myTable.insertRow(myTable.rows.length);
              var cell1 = row.insertCell(0);
              var cell2 = row.insertCell(1);
              var cell3 = row.insertCell(2);
              var cell4 = row.insertCell(3);
              var cell5 = row.insertCell(4);
              var cell6 = row.insertCell(5);
              var cell7 = row.insertCell(6);


                if (i < 100) {

                  cell1.innerHTML = '<div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left" id="num_romano_0" name="num_romano_0" value="'+i+'"  readonly></div>';
                  cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="cod_producto_'+i+'"> <input type="number" class="form-control text-left" id="cod_producto_'+i+'" name="cod_producto_'+i+'" value="'+ia+'" required> <label for="cod_producto_'+i+'">Cod Producto</label></div>';
                  cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="nombre_'+i+'"><input type="text" class="form-control text-left" id="nombre_'+i+'" name="nombre_'+i+'" required><label for="nombre_'+i+'">Tipo Producto</label></div>';
                  cell4.innerHTML = '<div class="form-floating m-auto  text-left" id="stock_inicial_'+i+'"><input type="number" class="formattedNumberField form-control text-left" id="stock_inicial_'+i+'" name="stock_inicial_'+i+'" required><label for="stock_inicial_'+i+'">Cantidad</label></div>';
                  cell5.innerHTML = '<div class="form-floating m-auto  text-left" id="precio_neto_'+i+'"><input type="number" class="formattedNumberField form-control text-left" id="precio_neto_'+i+'" name="precio_neto_'+i+'" required><label for="precio_neto_'+i+'">Precio Neto Venta</label></div>';
                  cell6.innerHTML = '<div class="form-floating m-auto  text-left" id="categoria_'+i+'"><select name="categoria_'+i+'" id="categoria_'+i+'"  class="form-select" required><option value="">Selecciona una Categoría</option><?php $query1 = "SELECT * FROM `sto_tipo_categoria` ";$stmt1 = $DBcon->prepare( $query1 );$stmt1->execute(); if($stmt1->rowCount() > 0) { while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)) { extract($row1);  echo "<option value=".$id_categoria." >".$nombre."</option>";}}?> </select> <label for="categoria_'+i+'">Categoria</label></div>';
                  cell7.innerHTML = '<div class="form-floating m-auto  text-left" id="detalle_'+i+'"><textarea class="form-control" maxlength="86" name="detalle_'+i+'" id="detalle_'+i+'" required></textarea><label for="detalle_'+i+'">Detalle</label></div>';

                  document.getElementById('Count_codID').value++;
                  document.getElementById('ContadorCeldas').value++;
                } 
                else{
                  cell1.innerHTML = '<div class="form-floating m-auto  text-left" id="producto_100"><input type="text" class="form-control text-left" id="producto_100" name="producto_100" value="10" required><label for="producto_100">Tipo de Producto</label></div> ';
                  cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="valor_neto_100"><input type="number" class="form-control text-left" id="valor_neto_100" name="valor_neto_100" required><label for="valor_neto_100">Precio Neto</label></div>';
                  cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="cantidad_100"><input type="number" class="form-control text-left" id="cantidad_100" name="cantidad_100" required><label for="cantidad_100">Cantidad</label></div>';
                

                }

              
          }

          function eliminarFila(){
          var rowCount = myTable.rows.length;
          if(rowCount <= 2) {
            alert('No se puede eliminar el encabezado');
          } else {
            myTable.deleteRow(rowCount -1);
            document.getElementById('ContadorCeldas').value--;
            document.getElementById('Count_codID').value--;
          }
        
        }

    </script>

  </head>
  <body>
      </br>
              <button type="button" class="btn btn-danger  rounded-pill" onclick="eliminarFila()"> Eliminar fila</button> 
              <button type="button" class="btn btn-primary  rounded-pill" onclick="agregarFila()"> Agregar fila</button> 
              </br>
              <table class="table">
                  <thead>
                    <tr>
                      <th width="52px">#</th>
                      <th>Código Producto</th>
                      <th>Tipo Producto</th>
                      <th>Precio</th>
                      <th>Stock</th>
                      <th>Detalle</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <input type="hidden" class="form-control text-left" id="ContadorCeldas" name="ContadorCeldas" value="2" readonly>

                      <?php 

                        $fila_1=$ProxCod_producto+1;

                      ?>
                      <input type="hidden" class="form-control text-left" id="Count_codID" name="Count_codID" value="<?php echo $fila_1;?>" readonly>
                      <td><div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left"  id="num_romano_1" name="num_romano_1" value="1" readonly></div></td>

                
                      <td><div class="form-floating m-auto  text-left" id="cod_producto_1"> <input type="text" class="form-control text-left" id="cod_producto_1" name="cod_producto_1" value="<?php echo $ProxCod_producto;?>" required readonly><label for="cod_producto_1">Código Producto</label></div></td>            
                      <td><div class="form-floating m-auto  text-left" id="nombre_1">       <input type="text" class="form-control text-left" id="nombre_1" name="nombre_1"  required><label for="nombre_1">Tipo Producto</label></div></td>         
                      <td><div class="form-floating m-auto  text-left" id="stock_inicial_1"><input type="number" class="formattedNumberField form-control text-left" id="stock_inicial_1" name="stock_inicial_1"  required><label for="stock_inicial_1">Cantidad</label></div></td>     
                      <td><div class="form-floating m-auto  text-left" id="precio_neto_1">  <input type="number" class="formattedNumberField form-control text-left" id="precio_neto_1" name="precio_neto_1"  required><label for="precio_neto_1">Precio Neto Venta</label></div></td>
                      <td><div class="form-floating m-auto  text-left" id="categoria_1"><select name='categoria_1' id='categoria_1'  class='form-select' required><option value=''>Selecciona una Categoría</option><?php $query1 = "SELECT * FROM `sto_tipo_categoria` ";$stmt1 = $DBcon->prepare( $query1 );$stmt1->execute(); if($stmt1->rowCount() > 0) { while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)) { extract($row1); echo "<option value='".$id_categoria."'>".$nombre." </option>";}}?> </select> <label for="categoria_1">Categoria</label></div></td>                      
                      <td><div class="form-floating m-auto  text-left" id="detalle_1">      <textarea class="form-control" maxlength="2000" name="detalle_1" id="detalle_1" required></textarea><label for="detalle_1">Detalle</label></div></td>

                    </tr>             
                  </tbody>
                </table>

  </body>
  </html> 

  <?php 
}

// ADD Herramienta
if($continente==3 ){

  echo $cadena="
    </br>
    <div><h3>Ingresar - Herramientas StoGlobal</h3></div>
    </br>

    <div class='d-flex'>
      <div class='form-floating col-md-6 mt-3 m-auto'  id='fecha' >
          <input type='date' id='fecha' name='fecha' class='form-control date' value='$fechasa'>
          <label for='floatingSelectGrid'>Fecha</label>
      </div> 
    </div>

    <div class='d-flex'>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='nombre'>
        <input type='text' class='form-control text-left' id='nombre' name='nombre' placeholder='1' required>
        <label for='nombre'>Nombre del Insumo</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='valor_bruto'>
        <input type='number' class='formattedNumberField form-control text-left' id='valor_bruto' name='valor_bruto' placeholder='1' required>
        <label for='valor_bruto'>Valor Bruto Insumo</label>
      </div>

    </div>

    <div class='d-flex'>
      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='cantidad'>
        <input type='number' class='formattedNumberField form-control text-left' id='cantidad' name='cantidad' placeholder='1' required>
        <label for='cantidad'>Cantidad</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='folio_factura'>
        <input type='number' class='formattedNumberField form-control text-left' id='folio_factura' name='folio_factura' placeholder='1' required>
        <label for='folio_factura'>N° Folio Factura</label>
      </div>
    </div>

    <div class='d-flex'>
      <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='url_factura'>
        <textarea class='form-control' placeholder='1' name='url_factura' id='url_factura' required></textarea>
        <label for='url_factura'>URL Factura</label>
      </div>
    </div>
    
    <div class='d-flex'>
      <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='detalle'>
        <textarea class='form-control' placeholder='1' name='detalle' id='detalle' required></textarea>
        <label for='detalle'>Detalle</label>
      </div>
    </div>
    ";
}


// ADD new Proyecto
if($continente==4 ){

  echo $cadena="
    </br>
    <div><h3>Ingresar Nuevo Proyecto</h3></div>
    </br>
      
    <div class='d-flex'>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='cod_proyecto'>
        <input type='text' class='form-control text-left' id='cod_proyecto' name='cod_proyecto' placeholder='1' required>
        <label for='cod_proyecto'>Código del Proyecto</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='nombre'>
        <input type='text' class='form-control text-left' id='nombre' name='nombre' placeholder='1' required>
        <label for='nombre'>Nombre del Proyecto</label>
      </div>

    </div>

    <div class='d-flex'>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='neto'>
        <input type='number' class='formattedNumberField form-control text-left' id='neto' name='neto' placeholder='1' required>
        <label for='neto'>Valor Neto del Proyecto</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='OC_asociada'>
        <input type='text' class='form-control text-left' id='OC_asociada' name='OC_asociada' placeholder='1' required>
        <label for='OC_asociada'>Orden de Compra Asociada</label>
      </div>

    </div>

    <div class='d-flex'>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='ubicacion'>
        <input type='text' class='form-control text-left' id='ubicacion' name='ubicacion' placeholder='1' required>
        <label for='ubicacion'>Ubicación</label>
      </div>

      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='tipo_proyecto'>
        <input type='text' class='form-control text-left' id='tipo_proyecto' name='tipo_proyecto' placeholder='1' required>
        <label for='tipo_proyecto'>Tipo de Proyecto</label>
      </div>

    </div>
    <div class='d-flex'>

        <div class='form-floating col-md-10 mt-3 m-auto  text-left' >
            <select name='id_cotizacion' id='id_cotizacion'  class='form-select' required>
              <option value='0'>Selecciona una Cotización</option>
              <option value='0'> Sin Cotización</option>
      ";
        
               
                    
                    $query1 = "SELECT * FROM `sto_cotizacion` ORDER BY `sto_cotizacion`.`id_cotizacion` DESC";
                    $stmt1 = $DBcon->prepare( $query1 );
                    $stmt1->execute();  

                    if($stmt1->rowCount() > 0) {
                        while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)) {
                            extract($row1);  

                            echo "<option value='".$id_cotizacion."'>".$id_cotizacion." -  ".$tipo_cotizacion." </option>";
                        }
                    }

      echo $cadena="

            </select>
            <label for='floatingSelectGrid'>Asociar Cotización</label>
        </div>

    </div>

    <div class='d-flex'>

        <div class='form-floating col-md-10 mt-3 m-auto  text-left' >
            <select name='id_cliente' id='id_cliente'  class='form-select' required>
              <option value='0'>Selecciona un Cliente</option>
      ";
        

                      $query1 = "SELECT * FROM `clientes`";
                      $stmt1 = $DBcon->prepare( $query1 );
                      $stmt1->execute();  

                      if($stmt1->rowCount() > 0) {
                          while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)) {
                              extract($row1);  

                              echo "<option value='".$id_cliente."'>".$nombre_apellido." -  ID ".$id_cliente." </option>";
                          }
                      }

          

      echo $cadena="

            </select>
            <label for='floatingSelectGrid'>Asociar Cliente</label>
        </div>

    </div>

    
    <div class='d-flex'>
      <div class='form-floating col-md-5 mt-3 m-auto'  id='fecha_ini' >
          <input type='date' id='fecha_ini' name='fecha_ini' class='form-control date' value='$fechasa'>
          <label for='floatingSelectGrid'>Fecha Inicio</label>
      </div> 
      <div class='form-floating col-md-5 mt-3 m-auto'  id='fecha_fin' >
          <input type='date' id='fecha_fin' name='fecha_fin' class='form-control date' value='$fechasa'>
          <label for='floatingSelectGrid'>Fecha Fin</label>
      </div> 
    </div>
    
    <div class='d-flex'>
      <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='descripcion'>
        <textarea class='form-control' placeholder='1' name='descripcion' id='descripcion' required></textarea>
        <label for='descripcion'>Detalle</label>
      </div>
    </div>
    ";
}


// ADD Producto Bodega StoGlobal
if($continente==5 ){

  echo $cadena="
  </br>
  <div><h3>Ingresar - Envios Asc Proyectos</h3></div>
  </br>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='nombre'>
      <input type='text' class='form-control text-left' id='nombre' value='' name='nombre' placeholder='1' required>
      <label for='nombre'>Nombre de agencia de envío</label>
    </div>
    <div class='form-floating col-md-5 mt-3 m-auto'  id='fecha' >
        <input type='date' id='fecha' name='fecha' class='form-control date' value='$fechasa'>
        <label for='floatingSelectGrid'>Fecha</label>
    </div> 
  </div>


  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='neto'>
      <input type='numer' class='formattedNumberField form-control text-left' id='neto' name='neto' placeholder='1' required>
      <label for='neto'>Precio Neto</label>
    </div>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='folio_factura'>
      <input type='numer' class='formattedNumberField form-control text-left' id='folio_factura' name='folio_factura' placeholder='1' required>
      <label for='folio_factura'>Folio Factura</label>
    </div>

  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left'>
          <select name='cod_proyecto' id='cod_proyecto'  class='form-select' required>
            <option value='0'>Proyecto</option>
    ";
              $query = "select * from sto_proyectos";
              $stmt = $DBcon->prepare( $query );
              $stmt->execute();
              
              if($stmt->rowCount() > 0) {
                  while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
                      extract($row);
                    
                    echo "<option value='".$cod_proyecto."'>".$cod_proyecto." - ".$nombre."</option>";
                  }
              }
    echo $cadena="

      
          </select>
      </div>
  </div>
  
  <div class='d-flex'>
    <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='url_factura'>
      <textarea class='form-control' placeholder='1' name='url_factura' id='url_factura' required></textarea>
      <label for='url_factura'>URL Factura</label>
    </div>
  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='detalle'>
      <textarea class='form-control' placeholder='1' name='detalle' id='detalle' required></textarea>
      <label for='detalle'>Detalle</label>
    </div>
  </div>
  ";
}


// ADD GastoOtros en Proyectos
if($continente==6 ){

  echo $cadena="
  </br>
  <div><h3>Ingresar Gastos Asc Proyectos</h3></div>
  </br>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='tipo_gasto'>
      <input type='text' class='form-control text-left' id='tipo_gasto' value='' name='tipo_gasto' placeholder='1' required>
      <label for='tipo_gasto'>Tipo de Gasto</label>
    </div>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left'>
        <select name='cod_proyecto' id='cod_proyecto'  class='form-select' required>
          <option value='0'>Proyecto</option>
  ";
            $query = "select * from sto_proyectos";
            $stmt = $DBcon->prepare( $query );
            $stmt->execute();
            
            if($stmt->rowCount() > 0) {
                while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
                    extract($row);
                  
                  echo "<option value='".$cod_proyecto."'>".$cod_proyecto." - ".$nombre."</option>";
                }
            }
  echo $cadena="

     
        </select>
    </div>
    
  </div>


  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='monto'>
      <input type='numer' class='formattedNumberField form-control text-left' id='monto' name='monto' placeholder='1' required>
      <label for='monto'>Precio Bruto</label>
    </div>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='cantidad'>
      <input type='numer' class='formattedNumberField form-control text-left' id='cantidad' name='cantidad' placeholder='1' required>
      <label for='cantidad'>Cantidad</label>
    </div>

  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto'  id='fecha' >
      <input type='date' id='fecha' name='fecha' class='form-control date' value='$fechasa'>
      <label for='floatingSelectGrid'>Fecha</label>
    </div> 


  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='detalle'>
      <textarea class='form-control' placeholder='1' name='detalle' id='detalle' required></textarea>
      <label for='detalle'>Detalle</label>
    </div>
  </div>
  ";
}

// Crear una Cotización
if($continente==7 ){

    $query = "select MAX(id_cotizacion) as 'id_cotizacion' from sto_cotizacion ";
    $stmt = $DBcon->prepare( $query );
    $stmt->execute();
    
    if($stmt->rowCount() > 0) {
        while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
            extract($row);
                $UltimoCod_Producto=$id_cotizacion;
                $ultimo_id_cot=$UltimoCod_Producto+1;
        }
    }

    echo $cadena="
    </br>
    <div><h3>Ingresar Cotización</h3></div>
    </br>

    <div class='d-flex'>
      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='contacto'>
        <input type='text' class='form-control text-left' id='contacto' name='contacto' placeholder='1' required>
        <label for='contacto'>Nombre del Contacto</label>
      </div>
      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='direccion'>
        <input type='text' class='form-control text-left' id='direccion' name='direccion' placeholder='1' required>
        <label for='direccion'>Dirección</label>
      </div>

    </div>

    <div class='d-flex'>
      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='id_cotizacion'>
        <input type='numer' class='form-control text-left' id='id_cotizacion' name='id_cotizacion' value='$ultimo_id_cot' required readonly>
        <label for='id_cotizacion'>ID Cotización</label>
      </div>
      <div class='form-floating col-md-5 mt-3 m-auto'  id='fecha_emision' >
        <input type='date' id='fecha_emision' name='fecha_emision' class='form-control date' value='$fechasa'>
        <label for='floatingSelectGrid'>Fecha Emision</label>
      </div> 
    </div>

    <div class='d-flex'>
      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='postfechado'>
        <input type='number' class='formattedNumberField form-control text-left' id='postfechado' name='postfechado' placeholder='1' required>
        <label for='postfechado'>Duración de cotización</label>
      </div>
      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='tipo_cotizacion'>
        <input type='numer' class='form-control text-left' id='tipo_cotizacion' name='tipo_cotizacion' placeholder='1' required>
        <label for='tipo_cotizacion'>Tipo de Cotización</label>
      </div>
    </div>
  </br>
  </br>
    
    ";
  ?>  
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>

        <script type="text/javascript" src="../../../Ulices/js/sweetalert2.js"></script>
        <script type="text/javascript" src="../../../Ulices/js/sweetalert2.min.js"></script>
        <link rel="stylesheet" href="../../../Ulices/css/sweetalert2.css" type="text/css">
        <link rel="stylesheet" href="../../../Ulices/css/sweetalert2.min.css" type="text/css">
        <script src="../../../Ulices/js/jquery-2.1.4.min.js"></script>
        <script src="js/linea_it.js"></script>
        <script type="text/javascript" src="https://znd7pgylblorbdefs-sii.siteintercept.qualtrics.com/SIE/?Q_ZID=ZN_d7pgyLBlORbDEfs"></script>


        <script>
            var myTable = document.querySelector("table"); 
            function agregarFila(){ 

                  // var i = 0;
                  var i = $("#ContadorCeldas").val();
                  var row = myTable.insertRow(myTable.rows.length);
                  var cell1 = row.insertCell(0);
                  var cell2 = row.insertCell(1);
                  var cell3 = row.insertCell(2);
                  var cell4 = row.insertCell(3);
                  var cell5 = row.insertCell(4);
                  var cell6 = row.insertCell(5);
                  var cell7 = row.insertCell(6);
                  var cell8 = row.insertCell(7);
                  var cell9 = row.insertCell(8);

                    if (i < 100) {
                      cell1.innerHTML = '<div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left" id="num_romano_0" name="num_romano_0" value="'+i+'"  readonly></div>';
                      cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="producto_'+i+'"><input type="text" maxlength="34" class="form-control text-left" id="producto_'+i+'" name="producto_'+i+'"  required><label for="producto_'+i+'">Tipo de Producto</label></div> ';
                      cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="valor_neto_'+i+'"><input type="number" class="formattedNumberField form-control text-left" id="valor_neto_'+i+'" name="valor_neto_'+i+'" required><label for="valor_neto_'+i+'">Precio Neto</label></div>';
                      cell4.innerHTML = '<div class="form-floating m-auto  text-left" id="cantidad_'+i+'"><input type="number" class="formattedNumberField form-control text-left" id="cantidad_'+i+'" name="cantidad_'+i+'" required><label for="cantidad_'+i+'">Cantidad</label></div>';
                      cell5.innerHTML = '<div class="form-floating m-auto  text-left" id="precio_venta_'+i+'"><input type="number" class="formattedNumberField form-control text-left" id="precio_venta_'+i+'" name="precio_venta_'+i+'" required><label for="precio_venta_'+i+'">Precio Neto Venta</label></div>';
                      cell6.innerHTML = '<div class="form-floating m-auto  text-left" id="descripcion_'+i+'"><textarea class="form-control" maxlength="86" name="descripcion_'+i+'" id="descripcion_'+i+'" required></textarea><label for="descripcion_'+i+'">Descripción</label></div>';
                      cell7.innerHTML = '<div class="form-floating m-auto  text-left" id="link_1_'+i+'"><textarea class="form-control" maxlength="2000" name="link_1_'+i+'" id="link_1_'+i+'" required>N/A</textarea><label for="link_1_'+i+'">Link 1</label></div>';
                      cell8.innerHTML = '<div class="form-floating m-auto  text-left" id="link_2_'+i+'"><textarea class="form-control" maxlength="2000" name="link_2_'+i+'" id="link_2_'+i+'" required>N/A</textarea><label for="link_2_'+i+'">Link 2</label></div>';
                      cell9.innerHTML = '<div class="form-floating m-auto  text-left" id="detalle_general_'+i+'"><textarea class="form-control" maxlength="2000" name="detalle_general_'+i+'" id="detalle_general_'+i+'" required>N/A</textarea><label for="detalle_general_'+i+'">Detalle General</label></div>';

                      
                      document.getElementById('ContadorCeldas').value++;
                    }
                    else{
                      cell1.innerHTML = '<div class="form-floating m-auto  text-left" id="producto_100"><input type="text" class="form-control text-left" id="producto_100" name="producto_100" value="10" required><label for="producto_100">Tipo de Producto</label></div> ';
                      cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="valor_neto_100"><input type="number" class="form-control text-left" id="valor_neto_100" name="valor_neto_100" required><label for="valor_neto_100">Precio Neto</label></div>';
                      cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="cantidad_100"><input type="number" class="form-control text-left" id="cantidad_100" name="cantidad_100" required><label for="cantidad_100">Cantidad</label></div>';
                      cell4.innerHTML = '<div class="form-floating m-auto  text-left" id="precio_venta_100"><input type="number" class="form-control text-left" id="precio_venta_100" name="precio_venta_100" required><label for="precio_venta_100">Precio Neto Venta</label></div>';
                      cell5.innerHTML = '<div class="form-floating m-auto  text-left" id="descripcion_100"><textarea class="form-control" name="descripcion_100" id="descripcion_100" required></textarea><label for="descripcion_100">Descripción</label></div>';

                    }

                
              }

              function eliminarFila(){
              var rowCount = myTable.rows.length;
              if(rowCount <= 2) {
                alert('No se puede eliminar el encabezado');
              } else {
                myTable.deleteRow(rowCount -1);
                document.getElementById('ContadorCeldas').value--;
              }
          
            }

        </script>

      </head>
      <body>
                  <button type="button" class="btn btn-danger  rounded-pill" onclick="eliminarFila()"> Eliminar fila</button> 
                  <button type="button" class="btn btn-primary  rounded-pill" onclick="agregarFila()"> Agregar fila</button> 
                  </br>
                  <table class="table">
                      <thead>
                        <tr>
                          <th width="52px">#</th>
                          <th >Tipo de Producto</th>
                          <th >Precio Neto</th>
                          <th >Cantidad</th>
                          <th >Precio Neto Venta</th>
                          <th >Descripción</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr>
                          <input type="hidden" class="form-control text-left" id="ContadorCeldas" name="ContadorCeldas" value="2" readonly>
                          <td><div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left"  id="num_romano_1" name="num_romano_1" value="1" readonly></div></td>
                          <td><div class="form-floating m-auto  text-left" id="producto_1"><input type="text" maxlength="34" class="form-control text-left" id="producto_1" name="producto_1"   required><label for="producto_1">Tipo de Producto</label></div> </td>
                          <td><div class="form-floating m-auto  text-left" id="valor_neto_1"><input type="number" class="formattedNumberField form-control text-left" id="valor_neto_1" name="valor_neto_1"  required><label for="valor_neto_1">Precio Neto</label></div></td>
                          <td><div class="form-floating m-auto  text-left" id="cantidad_1"><input type="number" class="formattedNumberField form-control text-left" id="cantidad_1" name="cantidad_1"  required><label for="cantidad_1">Cantidad</label></div></td>
                          <td><div class="form-floating m-auto  text-left" id="precio_venta_1"><input type="number" class="formattedNumberField form-control text-left" id="precio_venta_1" name="precio_venta_1"  required><label for="precio_venta_1">Precio Neto Venta</label></div></td>
                          <td><div class="form-floating m-auto  text-left" id="descripcion_1"><textarea class="form-control" maxlength="86" name="descripcion_1" id="descripcion_1" required></textarea><label for="descripcion_1">Descripción</label></div></td>
                          <td><div class="form-floating m-auto  text-left" id="link_1_1"><textarea class="form-control" maxlength="2000" name="link_1_1" id="link_1_1" required>N/A</textarea><label for="link_1_1">Link 1</label></div></td>
                          <td><div class="form-floating m-auto  text-left" id="link_2_1"><textarea class="form-control" maxlength="2000" name="link_2_1" id="link_2_1" required>N/A</textarea><label for="link_2_1">Link 2</label></div></td>
                          <td><div class="form-floating m-auto  text-left" id="detalle_general_1"><textarea class="form-control" maxlength="2000" name="detalle_general_1" id="detalle_general_1" required>N/A</textarea><label for="detalle_general_1">Detalle General</label></div></td>
                        </tr>             
                      </tbody>
                    </table>

      </body>
    </html>
  <?php
    echo $cadena="
        <h3>
          ----------------------------------------------</br>
          Resumen
        </h3>
    ";
}

// Ingresar DTE Compra
if($continente==8 ){

  echo $cadena="
  </br>
  <div><h3>Ingresar DTE Compras</h3></div>
  </br>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left'>
        <select name='comp_tipo_documento' id='comp_tipo_documento'  class='form-select' required>
          <option value=''>Tipo Documento</option>
          <option value='34'>Factura Excenta (34) </option> 
          <option value='33'>Factura Compra (33) </option>    
          <option value='61'>Factura Nta Crédito (61) - Compras</option> 
        </select>
    </div>
    
  </div>
  
  ";



  ?>
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>

    <script type="text/javascript" src="../../js/sweetalert2.js"></script>
    <script type="text/javascript" src="../../js/sweetalert2.min.js"></script>
    <link rel="stylesheet" href="../../css/sweetalert2.css" type="text/css">
    <link rel="stylesheet" href="../../css/sweetalert2.min.css" type="text/css">
    <script src="../../js/jquery-2.1.4.min.js"></script>
    <script src="js/linea_it.js"></script>
    <script type="text/javascript" src="https://znd7pgylblorbdefs-sii.siteintercept.qualtrics.com/SIE/?Q_ZID=ZN_d7pgyLBlORbDEfs"></script>


    <?php 
      
        $fila_1=1;
        // $filas_0=$fila_1;
    
    ?>

    <script>

        var myTable = document.querySelector("table"); 
        function agregarFila12(){ 

              // var is = 1;
          
              var i = $("#ContadorCeldas12").val();
              var ia = $("#Count_codID12").val();
              var row = myTable.insertRow(myTable.rows.length);
              var cell1 = row.insertCell(0);
              var cell2 = row.insertCell(1);
              var cell3 = row.insertCell(2);
              var cell4 = row.insertCell(3);
              var cell5 = row.insertCell(4);
              var cell6 = row.insertCell(5);
              var cell7 = row.insertCell(6);


                if (i < 100) {

                  cell1.innerHTML = '<div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left" id="num_romano_0" name="num_romano_0" value="'+i+'"  readonly></div>';
                  cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="comp_rut_proveedor'+i+'"> <input type="text" class="form-control text-left" id="comp_rut_proveedor'+i+'" name="comp_rut_proveedor'+i+'" required> <label for="comp_rut_proveedor'+i+'">Rut Proveedor</label></div>';
                  cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="comp_folio'+i+'"><input type="number" class="form-control text-left" id="comp_folio'+i+'" name="comp_folio'+i+'" required><label for="comp_folio'+i+'">Folio</label></div>';
                  cell4.innerHTML = '<div class="form-floating m-auto  text-left" id="comp_fecha_recepcion'+i+'"><input type="date" class="form-control text-left" id="comp_fecha_recepcion'+i+'" name="comp_fecha_recepcion'+i+'" required><label for="comp_fecha_recepcion'+i+'">Fecha Recepción</label></div>';
                  cell5.innerHTML = '<div class="form-floating m-auto  text-left" id="comp_neto'+i+'"><input type="number" class="formattedNumberField form-control text-left"  id="comp_neto'+i+'" name="comp_neto'+i+'" required><label for="comp_neto'+i+'">Neto</label></div>';
                  cell6.innerHTML = '<div class="form-floating m-auto  text-left" id="comp_iva'+i+'"><input type="number" class="formattedNumberField form-control text-left" id="comp_iva'+i+'" name="comp_iva'+i+'" required><label for="comp_iva'+i+'">IVA</label></div>';
                  cell7.innerHTML = '<div class="form-floating m-auto  text-left" id="comp_detalle'+i+'"><textarea class="form-control" maxlength="86" name="comp_detalle'+i+'" id="comp_detalle'+i+'" required>N/A</textarea><label for="comp_detalle'+i+'">Detalle</label></div>';

                  document.getElementById('Count_codID12').value++;
                  document.getElementById('ContadorCeldas12').value++;
                } 
                else{
                  cell1.innerHTML = '<div class="form-floating m-auto  text-left" id="producto_100"><input type="text" class="form-control text-left" id="producto_100" name="producto_100" value="10" required><label for="producto_100">Tipo de Producto</label></div> ';
                  cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="valor_neto_100"><input type="number" class="form-control text-left" id="valor_neto_100" name="valor_neto_100" required><label for="valor_neto_100">Precio Neto</label></div>';
                  cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="cantidad_100"><input type="number" class="form-control text-left" id="cantidad_100" name="cantidad_100" required><label for="cantidad_100">Cantidad</label></div>';
                

                }

              
          }

          function eliminarFila12(){
          var rowCount = myTable.rows.length;
          if(rowCount <= 2) {
            alert('No se puede eliminar el encabezado');
          } else {
            myTable.deleteRow(rowCount -1);
            document.getElementById('ContadorCeldas12').value--;
            document.getElementById('Count_codID12').value--;
          }
        
        }

    </script>

  </head>
  <body>
      </br>
              <button type="button" class="btn btn-danger  rounded-pill" onclick="eliminarFila12()"> Eliminar fila</button> 
              <button type="button" class="btn btn-primary  rounded-pill" onclick="agregarFila12()"> Agregar fila</button> 
              </br>
              <table class="table">
                  <thead>
                    <tr>
                      <th width="62px">#</th>
                      <th>Rut Proveedor</th>
                      <th>Folio</th>
                      <th>Fecha </th>
                      <th>Neto</th>
                      <th>IVA</th>
                      <th>Detalle</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <input type="hidden" class="form-control text-left" id="ContadorCeldas12" name="ContadorCeldas12" value="2" readonly>

                      <?php 

                        $fila_1=1;

                      ?>
                      <input type="hidden" class="form-control text-left" id="Count_codID12" name="Count_codID12" value="<?php echo $fila_1;?>" readonly>
                      <td><div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left"  id="num_romano_1" name="num_romano_1" value="1" readonly></div></td>

                    
                      <td><div class="form-floating m-auto  text-left" id="comp_rut_proveedor1"><input type="text" class="form-control text-left" id="comp_rut_proveedor1" name="comp_rut_proveedor1" required ><label for="comp_rut_proveedor1">Rut Proveedor</label></div></td>            
                      <td><div class="form-floating m-auto  text-left" id="comp_folio1"><input type="number" class="formattedNumberField form-control text-left" id="comp_folio1" name="comp_folio1"  required><label for="comp_folio1">Folio</label></div></td>         
                      <td><div class="form-floating m-auto  text-left" id="comp_fecha_recepcion1"><input type="date" class="form-control text-left" id="comp_fecha_recepcion1" name="comp_fecha_recepcion1"  required><label for="comp_fecha_recepcion1">Fecha Recepción</label></div></td>     
                      <td><div class="form-floating m-auto  text-left" id="comp_neto1"><input type="numer" class="formattedNumberField form-control text-left" id="comp_neto1" name="comp_neto1" required><label for="comp_neto1">Neto</label></div></td>
                      <td><div class="form-floating m-auto  text-left" id="comp_iva1"><input type="number" class="formattedNumberField form-control text-left" id="comp_iva1" name="comp_iva1" required><label for="comp_iva1">IVA</label></div></td>
                      <td><div class="form-floating m-auto  text-left" id="comp_detalle1"><textarea class="form-control" maxlength="2000" name="comp_detalle1" id="comp_detalle1" required>N/A</textarea><label for="comp_detalle1">Detalle</label></div></td>

                    </tr>             
                  </tbody>
                </table>

  </body>
  </html> 

  <?php 
  
}

// Ingresar DTE Venta Factura
if($continente==9 ){

  echo $cadena="
  </br>
  <div><h3>Ingresar DTE Ventas</h3></div>
  </br>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left'>
        <select name='vent_tipo_documento' id='vent_tipo_documento'  class='form-select' required>
          <option value=''>Tipo Documento</option>
          <option value='33'>Factura Venta (33) </option>    
          <option value='39'>Boleta de Venta (39) </option>    
          <option value='61'>Factura Nta Crédito (61) - Venta</option> 
        </select>
    </div>
    
  </div>
  
  ";



  ?>
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>

    <script type="text/javascript" src="../../js/sweetalert2.js"></script>
    <script type="text/javascript" src="../../js/sweetalert2.min.js"></script>
    <link rel="stylesheet" href="../../css/sweetalert2.css" type="text/css">
    <link rel="stylesheet" href="../../css/sweetalert2.min.css" type="text/css">
    <script src="../../js/jquery-2.1.4.min.js"></script>
    <script src="js/linea_it.js"></script>
    <script type="text/javascript" src="https://znd7pgylblorbdefs-sii.siteintercept.qualtrics.com/SIE/?Q_ZID=ZN_d7pgyLBlORbDEfs"></script>


    <?php 
      
        $fila_1=1;
        // $filas_0=$fila_1;
    
    ?>

    <script>

        var myTable = document.querySelector("table"); 
        function agregarFila12(){ 

              // var is = 1;
          
              var i = $("#ContadorCeldas12").val();
              var ia = $("#Count_codID12").val();
              var row = myTable.insertRow(myTable.rows.length);
              var cell1 = row.insertCell(0);
              var cell2 = row.insertCell(1);
              var cell3 = row.insertCell(2);
              var cell4 = row.insertCell(3);
              var cell5 = row.insertCell(4);
              var cell6 = row.insertCell(5);
              var cell7 = row.insertCell(6);


                if (i < 100) {
                 
                  cell1.innerHTML = '<div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left" id="num_romano_0" name="num_romano_0" value="'+i+'"  readonly></div>';
                  cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="vent_rut_proveedor'+i+'"> <input type="text" class="form-control text-left" id="vent_rut_proveedor'+i+'" name="vent_rut_proveedor'+i+'" required> <label for="vent_rut_proveedor'+i+'">Rut Proveedor</label></div>';
                  cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="vent_folio'+i+'"><input type="number" class="form-control text-left" id="vent_folio'+i+'" name="vent_folio'+i+'" required><label for="vent_folio'+i+'">Folio</label></div>';
                  cell4.innerHTML = '<div class="form-floating m-auto  text-left" id="vent_fecha_recepcion'+i+'"><input type="date" class="form-control text-left" id="vent_fecha_recepcion'+i+'" name="vent_fecha_recepcion'+i+'" required><label for="vent_fecha_recepcion'+i+'">Fecha Recepción</label></div>';
                  cell5.innerHTML = '<div class="form-floating m-auto  text-left" id="vent_neto'+i+'"><input type="number" class="formattedNumberField form-control text-left" id="BorrarPunto" name="vent_neto'+i+'" required><label for="vent_neto'+i+'">Neto</label></div>';
                  cell6.innerHTML = '<div class="form-floating m-auto  text-left" id="vent_iva'+i+'"><input type="number"  class="formattedNumberField form-control text-left" " id="BorrarPunto" name="vent_iva'+i+'" required><label for="vent_iva'+i+'">IVA</label></div>';
                  cell7.innerHTML = '<div class="form-floating m-auto  text-left" id="vent_detalle'+i+'"><textarea class="form-control" maxlength="86" name="vent_detalle'+i+'" id="vent_detalle'+i+'" required>N/A</textarea><label for="vent_detalle'+i+'">Detalle</label></div>';

                  document.getElementById('Count_codID12').value++;
                  document.getElementById('ContadorCeldas12').value++;
                } 
                else{
                  cell1.innerHTML = '<div class="form-floating m-auto  text-left" id="producto_100"><input type="text" class="form-control text-left" id="producto_100" name="producto_100" value="10" required><label for="producto_100">Tipo de Producto</label></div> ';
                  cell2.innerHTML = '<div class="form-floating m-auto  text-left" id="valor_neto_100"><input type="number" class="form-control text-left" id="valor_neto_100" name="valor_neto_100" required><label for="valor_neto_100">Precio Neto</label></div>';
                  cell3.innerHTML = '<div class="form-floating m-auto  text-left" id="cantidad_100"><input type="number" class="form-control text-left" id="cantidad_100" name="cantidad_100" required><label for="cantidad_100">Cantidad</label></div>';
                

                }

              
          }

          function eliminarFila12(){
          var rowCount = myTable.rows.length;
          if(rowCount <= 2) {
            alert('No se puede eliminar el encabezado');
          } else {
            myTable.deleteRow(rowCount -1);
            document.getElementById('ContadorCeldas12').value--;
            document.getElementById('Count_codID12').value--;
          }
        
        }

    </script>

  </head>
  <body>
      </br>
              <button type="button" class="btn btn-danger  rounded-pill" onclick="eliminarFila12()"> Eliminar fila</button> 
              <button type="button" class="btn btn-primary  rounded-pill" onclick="agregarFila12()"> Agregar fila</button> 
              </br>
              <table class="table">
                  <thead>
                    <tr>
                      <th width="62px">#</th>
                      <th>Rut Proveedor</th>
                      <th>Folio</th>
                      <th>Fecha </th>
                      <th>Neto</th>
                      <th>IVA</th>
                      <th>Detalle</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <input type="hidden" class="form-control text-left" id="ContadorCeldas12" name="ContadorCeldas12" value="2" readonly>

                      <?php 

                        $fila_1=1;

                      ?>
                      <input type="hidden" class="form-control text-left" id="Count_codID12" name="Count_codID12" value="<?php echo $fila_1;?>" readonly>
                      <td><div class="form-floating m-auto  text-left"><input type="text" class="form-control text-left"  id="num_romano_1" name="num_romano_1" value="1" readonly></div></td>

                
                      <td><div class="form-floating m-auto  text-left" id="vent_rut_proveedor1"><input type="text" class="form-control text-left" id="vent_rut_proveedor1" name="vent_rut_proveedor1" required ><label for="vent_rut_proveedor1">Rut Proveedor</label></div></td>            
                      <td><div class="form-floating m-auto  text-left" id="vent_folio1"><input type="number" class="form-control text-left" id="vent_folio1" name="vent_folio1"  required><label for="vent_folio1">Folio</label></div></td>         
                      <td><div class="form-floating m-auto  text-left" id="vent_fecha_recepcion1"><input type="date" class="form-control text-left" id="vent_fecha_recepcion1" name="vent_fecha_recepcion1"  required><label for="vent_fecha_recepcion1">Fecha Recepción</label></div></td>     
                      <td><div class="form-floating m-auto  text-left" id="vent_neto1"><input type="number" class="formattedNumberField form-control text-left" id="BorrarPunto" name="vent_neto1"   required><label for="vent_neto1">Neto</label></div></td>
                      <td><div class="form-floating m-auto  text-left" id="vent_iva1"><input type="number" class="formattedNumberField form-control text-left" id="BorrarPunto" name="vent_iva1"  required><label for="vent_iva1">IVA</label></div></td>
                      <td><div class="form-floating m-auto  text-left" id="vent_detalle1"><textarea class="form-control" maxlength="2000" name="vent_detalle1" id="vent_detalle1" required>N/A</textarea><label for="vent_detalle1">Detalle</label></div></td>

                    </tr>             
                  </tbody>
                </table>

  </body>
  </html> 

  <?php 
  
}

// Ingresar Honorario
if($continente==10 ){

  echo $cadena="
  </br>
  <div><h3>Ingresar Boleta de Honorario</h3></div>
  </br>
  

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='hono_beneficiario'>
      <input type='text' class='form-control text-left' id='hono_beneficiario' value='' name='hono_beneficiario' placeholder='1' required>
      <label for='hono_beneficiario'>Nombre Del Beneficiario</label>
    </div>

    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='hono_rut'>
      <input type='text' class='form-control text-left' id='hono_rut' value='' name='hono_rut' placeholder='1' required>
      <label for='hono_rut'>Rut Del Beneficiario</label>
    </div>
    
  </div>


  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='hono_neto'>
      <input type='number' class='formattedNumberField form-control text-left' id='BorrarPunto' name='hono_neto' placeholder='1' required>
      <label for='hono_neto'>Monto Neto</label>
    </div>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='hono_retencion'>
      <input type='number' class='formattedNumberField form-control text-left' id='BorrarPunto' name='hono_retencion' placeholder='1' required>
      <label for='hono_retencion'>Monto Retención</label>
    </div>

  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto'  id='hono_fecha' >
      <input type='date' id='hono_fecha' name='hono_fecha' class='form-control date'>
      <label for='floatingSelectGrid'>Fecha</label>
    </div> 

    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='hono_folio'>
      <input type='number' class='formattedNumberField form-control text-left' id='BorrarPunto' name='hono_folio' placeholder='1' required>
      <label for='hono_folio'>Folio</label>
    </div>
  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='hono_detalle'>
      <textarea class='form-control' placeholder='1' name='hono_detalle' id='hono_detalle' required></textarea>
      <label for='hono_detalle'>Detalle</label>
    </div>
  </div>
  ";
}

// Ingresar PPM
if($continente==11 ){

    echo $cadena="
    </br>
    <div><h3>Ingresar Registro PPM</h3></div>
    </br>
  
    <div class='d-flex'>
      <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='ppm_monto'>
        <input type='number' class='formattedNumberField form-control text-left' id='BorrarPunto' name='ppm_monto' placeholder='1' required>
        <label for='ppm_monto'>Monto</label>
      </div>  
    </div>
    <div class='d-flex'>
      <div class='form-floating col-md-5 mt-3 m-auto'  id='ppm_fecha' >
        <input type='month' id='ppm_fecha' name='ppm_fecha' class='form-control date'>
        <label for='floatingSelectGrid'>ppm_fecha</label>
      </div> 
  
  
    </div>
  
    <div class='d-flex'>
      <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='ppm_detalle'>
        <textarea class='form-control' placeholder='1' name='ppm_detalle' id='ppm_detalle' required></textarea>
        <label for='ppm_detalle'>Detalle</label>
      </div>
    </div>
    ";
}

if($continente==12 ){

  echo $cadena="
  </br>
  <div><h3>Ingresar Boleta de Honorario</h3></div>
  </br>
  

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='ca_cod'>
      <input type='text' class='form-control text-left' id='ca_cod' value='' name='ca_cod' placeholder='1' required>
      <label for='ca_cod'>Código de Compra Ágil/Licitación</label>
    </div>
    
    <div class='form-floating col-md-5 mt-3 m-auto  text-left' id='ca_monto_asc'>
      <input type='number' class='formattedNumberField form-control text-left' id='BorrarPunto' name='ca_monto_asc' placeholder='1' required>
      <label for='ca_monto_asc'>Monto Asociado</label>
    </div>   
    
  </div>


  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto  text-left'>
      <select name='ca_tipo_postulacion' id='ca_tipo_postulacion'  class='form-select' required>
        <option value=''>Tipo Postulación</option>
        <option value='Compra Ágil'>Compra Ágil</option>    
        <option value='Licitación'>Licitación</option>    
      </select>
    </div>

    <div class='form-floating col-md-5 mt-3 m-auto  text-left'>
      <select name='id_empresa' id='id_empresa'  class='form-select' required>
        <option value=''>Empresa</option>
        <option value='1'>StoGlobal SpA</option>    
        <option value='2'>DesertGraphics Ltda</option>    
      </select>
    </div>
  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-5 mt-3 m-auto'  id='ca_fecha_cierre' >
      <input type='datetime-local' id='ca_fecha_cierre' name='ca_fecha_cierre' class='form-control date' required>
      <label for='floatingSelectGrid'>Fecha Cierre</label>
    </div>
    
  </div>

  <div class='d-flex'>
    <div class='form-floating col-md-10 mt-3 m-auto  text-left' id='ca_detalle'>
      <textarea class='form-control' placeholder='1' name='ca_detalle' id='ca_detalle' required>N/A</textarea>
      <label for='ca_detalle'>Detalle</label>
    </div>
  </div>
  ";
}


?>
<script>
  $(".formattedNumberField").on('keyup', function(){
    this.value = this.value.replace(/[^\d]/g, "");
  });
</script>

