function get_training_module_data(course_id,module_id){
    ClearDivText();
   const formdata = new FormData();
   formdata.append("course_id", course_id);
   formdata.append("module_id", module_id);

   $.ajax({
      type:'POST',
     // enctype: 'multipart/form-data',
      url:window.location.origin+"/trainingportal/Automotive/get_module_data_by_trainingid_moduleid_segmentid",
      data: formdata,
      contentType: false,
      processData: false,
      success:function(data){
        var res=JSON.parse(data);
            $("#training_id").val(res[0].training_id);
            $("#trainer_id").val(res[0].trainer_id);
            $("#training_name").val(res[0].training_name);
            $("#module_id").val(res[0].id);
            $("#module_name").val(res[0].module_name);
            $("#segment_id").val(res[0].segment_id);
            $("#segment_name").val(res[0].segment_name);
            $("#team_lead_id").val(res[0].approvel_data[0].segment_leader_id);
            $("#bu_id").val(res[0].approvel_data[0].bu_head_id);
            $("#co_seg_head_id").val(res[0].approvel_data[0].co_segment_head_id);
            $("#seg_head_id").val(res[0].approvel_data[0].segment_head_id);
            $("#seg_president_id").val(res[0].approvel_data[0].president_id);
            
             $("#PopupTitle").html(res[0].training_name);
             $("#targate").html(res[0].module_target);
             $("#trainees").html(res[0].module_trainees);
             $("#trainer").html(res[0].module_trainer);
            var content_res=res[0].model_content;
            var content_data="";
            for(var count=0;count < content_res.length;count++){
                var ct=count+1;
                content_data += ct+". "+content_res[count].name+" <br>";
            }
             $("#trainingContent").html(content_data);
      }
   });
  
    $('#training_module_model').modal('show');
  
  }


function applyCourse(){

    const formdata = new FormData();
    formdata.append("training_name", $("#training_name").val());
    formdata.append("training_id", $("#training_id").val());
    formdata.append("trainer_id", $("#trainer_id").val());
    formdata.append("training_mode", "offline");
    formdata.append("module_id", $("#module_id").val());
    formdata.append("module_name", $("#module_name").val());
    formdata.append("segment_id",  $("#segment_id").val());
    formdata.append("segment_name",  $("#segment_name").val());
    formdata.append("team_lead_id", $("#team_lead_id").val());
    formdata.append("bu_id",  $("#bu_id").val());
    formdata.append("co_seg_head_id", $("#co_seg_head_id").val());
    formdata.append("seg_head_id",  $("#seg_head_id").val());
    formdata.append("seg_president_id", $("#seg_president_id").val());
 
    $.ajax({
       type:'POST',
      // enctype: 'multipart/form-data',
       url:window.location.origin+"/trainingportal/Automotive/apply_training_automotive",
       data: formdata,
       contentType: false,
       processData: false,
       success:function(data){
    //    $('#training_module_model').modal('show');
       }
    });


}

  function ClearDivText(){
    $("#PopupTitle").html("");
    $("#targate").html("");
    $("#trainees").html("");
    $("#trainer").html("");
    $("#trainingContent").html("");
  }

  function showModal_training_module() {
    $('#training_module_model').modal('show');
  }
  
  
  function closeModal_training_module() {
    $('#training_module_model').modal('hide');
  }