
@extends('layouts.admin')
@section('pageTitle', 'Vega Soft')
@section('page-content')

<div id="form-div">
<input type="hidden" id="hidden_status" value="0">
<input type="hidden" id="row_id" value="0">


<div class="page-header form-header" >
  <h3 class="page-title text-white"> Question</h3>
    <nav aria-label="breadcrumb">
      <ol class="breadcrumb">
      
        <li class="breadcrumb-item text-white  icon-md " aria-current="page"><i class="icon-list slide1"></i> </li>
      </ol>
    </nav>
    

    <input type="hidden" id="table_settings_field" branch_id="" branch_name=""  column_heading="<?= $rows->column_heading;?>" column_width="<?= $rows->column_width;?>" column_alighn="<?= $rows->column_alighn;?>"  column_conversion="<?= $rows->column_conversion;?>" settings_row_id="<?= $id;?>" sp_date_picker="<?= $rows->sp_date_picker;?>"  header_from_date="<?=date('d-m-Y', strtotime('-7 days')); ?>"   header_till_date="<?=date('d-m-Y'); ?>"  sp_sort="<?= $rows->menu_id; ?>"   >
    @if ($rows->sedp != "")
  @foreach(explode(',', $rows->sedp) as  $z=>$info) 
     @if ($info == "1" && $z==1)
       <input type="hidden" class="additional_btns" btn_text="Edit" btn_click_function="call_edit_modal" btn_class="btn btn-success btn-sm btn-dtbl" col_width="30" >
     @endif 
     @if ($info == "1" && $z==2)
        <input type="hidden" class="additional_btns" btn_text="Remove" btn_click_function="call_remove_modal" btn_class="btn btn-danger btn-sm btn-dtbl" col_width="40"  >
     @endif 
     @if ($info == "1" && $z==3)
          <input type="hidden" class="additional_btns" btn_text="Print" btn_click_function="call_print_function2" btn_class="btn btn-info btn-sm btn-dtbl" col_width="40"  >
     @endif
  @endforeach
@endif
</div>
<div class="card">
    <div class="card-body">
    	<form class="forms-sample" autocomplete="off">


<div class="col-lg-12">
<div class="row">

<div class="col-lg-6" style="height:200px;border:1px solid black">

<div class="form-group">
    <label for="formGroupExampleInput">Main Question</label>
    <input type="text" class="form-control" id="mq" placeholder="Example input">
  </div>
  <div class="template-demo">
                        
                        <button id="save_btn" type="button" onclick="save_form(1);" class="btn btn-success btn-icon-text save_btn btn-sm" >
                               <i class="icon-doc btn-icon-prepend"></i> Submit </button>
                       
   
   
                         <button type="reset" class="btn btn-danger btn-icon-text reset_btn btn-sm"  >
                               <i class="icon-reload btn-icon-prepend"></i> Reset </button>
                               <input type="hidden" id="row_id" value="0">
                             </div>

</div>
<div class="col-lg-6" style="height:200px;border:1px solid black">

<div class="form-group">
    <label for="formGroupExampleInput">Select Main</label>
    <select name="" id="smq"  class="form-select custom-select">

    @foreach($mqs as $al)
<option value="{{$al->qst_id}}"> {{$al->question}}</option>

    @endforeach


    </select>
  </div>


  <div class="form-group">
    <label for="formGroupExampleInput">Sub Question</label>
    <input type="text" class="form-control" id="sq" placeholder="Example input">
  </div>

  <div class="template-demo">
                        
                        <button id="save_btn" type="button" onclick="save_form(2);" class="btn btn-success btn-icon-text save_btn btn-sm" >
                               <i class="icon-doc btn-icon-prepend"></i> Submit </button>
                           
                     
   
   
                         <button type="reset" class="btn btn-danger btn-icon-text reset_btn btn-sm"  >
                               <i class="icon-reload btn-icon-prepend"></i> Reset </button>
                               <input type="hidden" id="row_id" value="0">
                             </div>
</div>

</div>

<div class="row">

<div class="col-lg-6" style="height:200px;border:1px solid black;">




<div class="form-group">
    <label for="formGroupExampleInput">Select Sub</label>
    <select name="" id="sbq_id"  class="form-select custom-select">

    @foreach($sbs as $al)
<option value="{{$al->qst_id}}"> {{$al->question}}</option>

    @endforeach


    </select>
  </div>

<div class="form-group">
    <label for="formGroupExampleInput">Third Sub Question</label>
    <input type="text" class="form-control" id="tsbq" placeholder="Example input">
  </div>

  <div class="template-demo">
                        
                        <button id="save_btn" type="button" onclick="save_form(3);" class="btn btn-success btn-icon-text save_btn btn-sm" >
                               <i class="icon-doc btn-icon-prepend"></i> Submit </button>
                           

   
   
                         <button type="reset" class="btn btn-danger btn-icon-text reset_btn btn-sm"  >
                               <i class="icon-reload btn-icon-prepend"></i> Reset </button>
                               <input type="hidden" id="row_id" value="0">
                             </div>
</div>


</div>





</div>



                   
                    </form>
    </div>
</div>
</div>

<div id="table-div">
<div class="page-header form-header" >
  <h3 class="page-title text-white">  Customer List </h3>
    <nav aria-label="breadcrumb">
      <ol class="breadcrumb">
      
        <li class="breadcrumb-item text-white  icon-md " aria-current="page"><i class="icon-plus slide2"></i> </li>
      </ol>
    </nav>
</div>

  

<div class="card">
  


    <div class="col-lg-12 col-sm-12 col-md-12" id="table_result">
                                            
                                            </div>


    
    
</div>
</div>





<script type="text/javascript">







function save_form(arg) {
  arr='';
  
  if(arg==1){
    arr={
              'cid':"0",
              'hidden_status':"0",
              'row_id':"0",

              'mq':$.trim($('#mq').val()),
              'type':arg,
              

              'added_by':"{{ Session::get('user_id')}}",
              'CID':"{{ Session::get('CID')}}",
};
  }


else if(arg==2){






  arr={
              'cid':"0",
              'hidden_status':"0",
              'row_id':"0",

              'smq':$.trim($('#smq').val()),
              'sq':$.trim($('#sq').val()),
              'type':arg,
              

              'added_by':"{{ Session::get('user_id')}}",
              'CID':"0",
};



}

  else{
    arr={
              'cid':"0",
              'hidden_status':"0",
              'row_id':"0",

              'sbq_id':$.trim($('#sbq_id').val()),
              'tsbq':$.trim($('#tsbq').val()),
              'type':arg,
              

              'added_by':"{{ Session::get('user_id')}}",
              'CID':"{{ Session::get('CID')}}",
};
  }
  







           $.ajax({
          url: "/store_data",
          type: "POST",
          data:{
             '_token': "{{ csrf_token() }}",
              json_data: JSON.stringify(arr),
              url1:'op_ser_questions.php'
             
          },
          success:function(response){
            
            console.log(response);
            if (response) {
              alert(response['msg']);
            
               $('.add_main_modal').modal('hide');
               fetch_view_table();
            }else{

            }
          },
          error: function(response) {
          }
         });
  }

</script>
@endsection