Dropdown does not load data from the database into the modal window

46 views Asked by At

I am using Chosen(Jquery) and in a Dropdown I am loading the data from the Database(SQL) the Dropdown is in a modal window, but when I open the modal window in full screen it does not load the data in the Dropdown but if I make the screen small(change the resolution) it shows the result in the Dropdown but it does not show the list of options and it also loses the styles of the library, maybe the library code is in conflict with Bootstrap?

enter image description here enter image description here

HTML

 <div class="row">

            <div class="col-md-6 col-sm-3 col-lg-5 form-group">
              <label class="col-form-label col-md-4 col-sm-2 label-align mr-n1" for="codix">De <i class="fa fa-user"></i></label>
              <datalist id="nombresb">
                @@BENEF@@
              </datalist>    
              <input type="text" id="buscab2"  class="form-control" placeholder="" list="nombresb">
            </div>

            <div class="col-md-6 col-sm-6 col-lg-5 form-group">
              <label class="col-form-label col-md-4 col-sm-2 label-align" for="descx">Para <i class="fa fa-users"></i></label>
              <select name="acompanantes" id="acompanantes2" multiple class="locales" data-placeholder="Para">
                <option value=""></option>
                {{empleado}}
              </select>
             
            </div>
        </div> 

PHP

function buscaMemoPorID(){

  $soloID = $_POST["idMemo"];

  $query = " SELECT TB_Memo.ID_Memo, TB_Memo.Fecha_Creacion, a.Nombres +' '+ a.Apellidos as Destinatarios, b.Nombres + ' ' + b.Apellidos as Remitente, TB_Memo.Asunto, TB_Memo.Contenido, TB_Memo.ID_TipoMemo, TB_Memo.ID_EstadoMemo, TB_Memo.Fecha_Envio, c.Descripcion, TB_Memo.ID_Memorandum, TB_Destinatario.ID_Empleado as Para
  from TB_Memo
  inner join TB_Destinatario on TB_Memo.ID_Memo = TB_Destinatario.ID_Memo
  inner join TB_Remitente on TB_Memo.ID_Memo = TB_Remitente.ID_Memo
  inner join [IHTT_RRHH].[dbo].[TB_Empleados] a on TB_Destinatario.ID_Empleado = a.ID_Empleado
  inner join [IHTT_RRHH].[dbo].[TB_Empleados] b on TB_Remitente.ID_Empleado = b.ID_Empleado
  left outer join [IHTT_MEMORANDUM].[dbo].[TB_EstadoDestinatario] c on TB_Memo.ID_EstadoDestinatario = c.ID_EstadoDestinatario
  Where TB_Memo.ID_Memo = $soloID";

  $p = array();
  $data = $this->select($query, $p );

  $datos[1]=count($data);
  $datos[0]=array();
  for($i=0; $i<count($data); $i++){
    $datos[0][$i] = array("ult" =>1, "num" =>$data[$i]["ID_Memo"], "nome"=>$data[$i]["ID_Memorandum"],"tipoMe" =>$data[$i]["ID_TipoMemo"], "estaMe" =>$data[$i]["ID_EstadoMemo"], "asunto" =>$data[$i]["Asunto"], "contenido" =>$data[$i]["Contenido"], "fechEn" =>$data[$i]["Fecha_Envio"], "fechCre" =>$data[$i]["Fecha_Creacion"], "De" =>$data[$i]["Remitente"], "Para" =>$data[$i]["Para"], "estado"=>$data[$i]["Descripcion"], "Destinatarios"=>$data[$i]["Destinatarios"]); 
  }
            
  echo json_encode($datos);

}

PHP

function empleado()
{
  $q = "SELECT [ID_Empleado]
  ,[Nombres]
  ,[Apellidos]
FROM [IHTT_RRHH].[dbo].[TB_Empleados]
WHERE ID_Estado = 1";
  $datos = $this->select($q, array());
  $opcion = "";
  for ($i = 0; $i < count($datos); $i++) {
    $opcion .= "<option  value='" .$datos[$i]["ID_Empleado"]. "'>" . utf8_encode($datos[$i]["Nombres"]) . " " . utf8_encode($datos[$i]["Apellidos"]) ."</option>
         ";
         
  }
  return $opcion;
}

JS

function cargaMemoEspecifico(idmemo){
  var cant = $("#mostrar").val();
  var form_data = new FormData();
  form_data.append("action","buscaMemoPorID");
  form_data.append("idMemo",idmemo); 
  $.ajax({
      url: 'api_con.php',
      dataType: 'json',
      cache: false,
      contentType: false,
      processData: false,
      data: form_data,                         
      type: 'post',
      success: function(data){      
          var area = data[0];
         
          if(data[1]>0  ){

              var detalle='';
              var cantidad=80;
              var total=0;
              var num=1;
             
              $("#acompanantes2").html("");
              for(i=0; i<area.length; i++){
              
                let datos = tinymce.get("mensaje2").setContent(area[i].contenido);

               $("#modalconsulta2").modal("show");   
                $("#buscab2").val(area[i].De);   
                $("#acompanantes2").append("<option value='" + area[i].Para + "'>" + area[i].Destinatarios + "</option>"); 
        
                $("#modal-asunto").val(area[i].asunto); 
                $("#modal-fecha").val(area[i].fechCre);
                $("#mensaje2").val(area[i].contenido);
                $("#idMemo").val(area[i].num);

   }
              

   $("#acompanantes2").trigger("chosen:updated");
                      
          } else {
              detalle +='<tr><td colspan="8">NO HAY DATOS EN ESTE MOMENTO.........</td></tr>';
          }
          
      }
   }).error(function(r){
      console.log("Error-->",r.responseText);
   });
}

0

There are 0 answers