<?php $__env->startSection('content'); ?> 
<script>
  function loadTehsil()
  {
      var DistrictId=$("#District").val();
      $.ajax({
          type: "GET",
          url: "getTehsilNames",
          data:"districtid="+DistrictId,
          dataType: "json",
          success: function(result){
               $('#Tehsil').children().remove();         
               $('#Tehsil').append($('<option>').text("तालुका").attr('value', ""));
               $.each(result, function(id, value) {
                  $('#Tehsil').append($('<option>').text(value.TehsilName).attr('value', value.TehsilID));
               });
            }
       });
  }

  function getCityOrVillages()
  {
      var IsCity=-1;
      if(document.getElementById("City").checked==true)
      {
        IsCity=1;
      }
      else if(document.getElementById("Village").checked==true)
      {
        IsCity=0;
      }
      var CityId=$('#CorV').val();
      var TehsilId=$('#Tehsil').val();
      // Load Cities or villages from 
       $.ajax({
            type: "GET",
            url: "loadAvailableCitiesOrVillages",
            data:"IsCity="+IsCity+"&Tehsil="+TehsilId,
            dataType: "json",
            success: function(result){
              if(IsCity==1)
              {
                $('#CorV').children().remove();         
                $('#CorV').append($('<option>').text(" शहर ").attr('value', ""));
                $.each(result, function(id, value) {
                    $('#CorV').append($('<option>').text(value.CityName).attr('value', value.CityID));
                });
              }
              else if(IsCity==0)
              {
                $('#CorV').children().remove();         
                $('#CorV').append($('<option>').text(" गाव ").attr('value', ""));
                $.each(result, function(id, value) {
                    $('#CorV').append($('<option>').text(value.VillageName).attr('value', value.VillageID));
                });
              }
            }
          });
  }

  function ShowAppUsers()
  {
      $("#loading").show();
    	var DistrictId=$("#District").val();
    	var TehsilID=$("#Tehsil").val();
    	var IsCity="";
    	if(document.getElementById("City").checked==true)
    	{
    		IsCity=1;
    	}
    	else if(document.getElementById("Village").checked==true)
    	{
    		IsCity=0;
    	}
    	var CityOrVillageName=$("#CorV").val();
    	var App_Status=$("#App_Status").val();
      if(DistrictId!="")
      {
		     var table = $('#AppUsers').DataTable();
          table.destroy();

          $('#AppUsers').DataTable({
             "responsive": true,
             "dataType": "json",
             dom: 'Blfrtip',
                buttons: [
                  'csvHtml5'
                ],
             "lengthMenu": [[10, 25, 50,100, 500], [10, 25, 50,100, 500]],
             "sAjaxSource": "APPReports?DistrictId="+DistrictId+"&TehsilID="+TehsilID+"&IsCity="+IsCity+"&CityOrVillageName="+CityOrVillageName+"&App_Status="+App_Status,
             initComplete: function() { $('#loading').hide(); },
             "aoColumns": [ 
	              { "mData": "AppUserID" },
                { "mData": "Name" },
                { "mData": "MobileNumber" },
                { "mData": "Email" },
                { "mData": "WhatsAppNumber" },
                { "mData": "Address" },
                { "mData": "DateOfBirth" },
                { "mData": "CastName"},
                { "mData": "BloodGroup"},                
                { "mData": "City_VillageName" },
                { "mData": "InUse" },
                { "mData": "Status"},
                { "mData": "DeactivationDate" },
                { "mData": "LastOTP"}
               ]
            });
        }
        else
        {
          alert("Please Select District");
        }
  }

  function selectAll()
  {
        var i=0;
        var table = $('#AppUsers').DataTable();
        if(document.getElementById("SelectALl").checked==true)
        {
          // Select All
         // alert(" Datatable Size : "+table.data().count());

          for (var i = 0; i < table.data().count(); i++) {
            if(document.getElementById("_"+i))
            {
              document.getElementById("_"+i).checked=true;
            }
          };
         $("#Img").hide();
        }
        else if(document.getElementById("SelectALl").checked==false)
        {
          // Unselect All
          for (var i = 0; i < table.data().count(); i++) {
            if(document.getElementById("_"+i))
            {
              document.getElementById("_"+i).checked=false;
            }
          };
           $("#Img").hide();
        }
  }

  function Unselect()
  {
    if(document.getElementById("SelectALl").checked==true)
    {
      document.getElementById("SelectALl").checked=false;
    }
  }
</script>
  <div class="qv rc sm sp" style="margin-top:3%;">
        <div class="qw">
            <?php if(Session::has('Name')): ?>   
	            <span style="margin-left:70px;"> <strong> कार्यकर्ता रिपोर्ट्स  </strong> </span>
  		        <span style="margin-top:-7px;margin-left:55%;">Welcome, <?php echo e(Session::get('Name')); ?>

  	    	    <a href='dashboard' class='cg ts fx green' style="margin-left:80px;"> Go To Dashboard </a>
      		  <?php endif; ?>
        </div>
  </div>
  <form action="send-sms" method="GET">
  <div class="by amt" style="margin-top:-30px;">
    <div class="gc">
      <div class="gz">
        <div class="ca qo anx ">
          <div class="qf b aml" style="width:223%;margin-left:-60px;">
            <div class="col-lg-12" style="margin-left:-10px;">

              	<div class="col-lg-2">
                    <select id="District" name="District" onchange="loadTehsil()" class="form-control">
                      <option value=""> जिल्हा </option>
                      <?php foreach($Districts as $District): ?>
                         <?php if($SelectDistrict==$District->DistrictID ): ?>
                            <option value="<?php echo e($District->DistrictID); ?>" selected><?php echo e($District->DistrictName); ?></option>
                          <?php else: ?>
                           <option value="<?php echo e($District->DistrictID); ?>"><?php echo e($District->DistrictName); ?></option>
                           <?php endif; ?>
                      <?php endforeach; ?>
                    </select>
                </div>

                <div class="col-lg-2">
                    <select id="Tehsil" name="Tehsil" class="form-control">
                      <option value="">  तालुका </option>
                         <?php foreach($Tehsils as $Tehsil): ?>
                           <?php if($SelectedTehsil==$Tehsil->TehsilID ): ?>
                              <option value="<?php echo e($Tehsil->TehsilID); ?>" selected><?php echo e($Tehsil->TehsilName); ?></option>
                            <?php else: ?>
                              <option value="<?php echo e($Tehsil->TehsilID); ?>"><?php echo e($Tehsil->TehsilName); ?></option>
                            <?php endif; ?>
                         <?php endforeach; ?>
                    </select>
                </div>

                <div class="col-lg-2">
                   <div class="bv" data-example-id="" style="margin-top:5px;">
                      <?php if($IsCity==-1): ?>
                        <div class="ew ug ul">
                          <label>
                            <input type="radio" id="City" name="CityOrVillage" value="City" onclick="getCityOrVillages()">  
                            <span class="uh"></span>
                             शहर
                          </label>
                        </div>
                        <div class="ew ug ul">
                           <label>
                             <input type="radio" name="CityOrVillage" id="Village" value="Village" onclick="getCityOrVillages()"> 
                              <span class="uh"></span>
                                गाव
                             </label>
                        </div>
                      <?php elseif($IsCity==1): ?>
                        <div class="ew ug ul">
                          <label>
                            <input type="radio" id="City" name="CityOrVillage" value="City" onclick="getCityOrVillages()" checked>  
                            <span class="uh"></span>
                             शहर
                          </label>
                        </div>
                        <div class="ew ug ul">
                             <label>
                               <input type="radio" name="CityOrVillage" id="Village" value="Village" onclick="getCityOrVillages()"> 
                                <span class="uh"></span>
                                  गाव
                               </label>
                        </div>
                      <?php elseif($IsCity==0): ?>
                        <div class="ew ug ul">
                          <label>
                            <input type="radio" id="City" name="CityOrVillage" value="City" onclick="getCityOrVillages()" >  
                            <span class="uh"></span>
                             शहर
                          </label>
                        </div>
                        <div class="ew ug ul">
                           <label>
                             <input type="radio" name="CityOrVillage" id="Village" value="Village" onclick="getCityOrVillages()" checked> 
                              <span class="uh"></span>
                                गाव
                             </label>
                        </div>
                      <?php endif; ?>
                    </div>
                </div>

                <div class="col-lg-2">
                    <select id="CorV" name="CorV" class="form-control">
                      <option value=""> शहर / गाव </option>
                        <?php if($IsCity==1): ?>
                           <?php foreach($Cities_Villages as $City_Village): ?>
                             <?php if($SelectedCityOrVillage==$City_Village->CityID ): ?>
                                <option value="<?php echo e($City_Village->CityID); ?>" selected><?php echo e($City_Village->CityName); ?></option>
                              <?php else: ?>
                                <option value="<?php echo e($City_Village->CityID); ?>"><?php echo e($City_Village->CityName); ?></option>
                              <?php endif; ?>
                           <?php endforeach; ?>
                        <?php elseif($IsCity==0): ?>
                          <?php foreach($Cities_Villages as $City_Village): ?>
                             <?php if($SelectedCityOrVillage==$City_Village->VillageID ): ?>
                                <option value="<?php echo e($City_Village->VillageID); ?>" selected><?php echo e($City_Village->VillageName); ?></option>
                              <?php else: ?>
                                <option value="<?php echo e($City_Village->VillageID); ?>"><?php echo e($City_Village->VillageName); ?></option>
                              <?php endif; ?>
                           <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                </div>

  	            <div class="col-lg-2">
  	            	<select id="App_Status" name=="App_Status" class="form-control">
  	            		<option value=""> अॅप्लिकेशन युजरचे स्टेटस</option>
  	            		<option value="1"> अनब्लॉक </option>
  	            		<option value="0"> ब्लॉक </option>
  	            	</select>
  	            </div>
                <div class="col-lg-2">
                    <input type="button" value="दाखवा" onclick="ShowAppUsers()" class="cg fm"></input>
                </div>
                
            	</div>

          	<div class="col-lg-12" style="margin-top:2%;">
          	</div>
           <div class="row"  style="margin-left:12px;">
              <div class="col-lg-12">
                <div class="col-lg-5"></div>
                <div class="col-lg-2"> <img src="<?php echo asset('theme/assets/images/loader7.gif'); ?>" id="loading" name="loading">  </div>
                <div class="col-lg-5"></div>                
              </div>
            </div>
            &nbsp;<p/>
            <div class="row" style="margin-left:12px;">
                <!-- Datatable  -->
                <table id="AppUsers" class="table table-hover" ><!-- table-hover -->
                  <thead>
                    <tr>
                      <th> आयडी</th>
                      <th> नाव</th>
                      <th> मोबाईल नंबर </th>
                      <th> इमेल </th>
                      <th> व्हाटसअप नंबर </th>
                      <th> पत्ता </th>
                      <th> जन्मतारीख </th>
                      <th> जात </th>
                      <th> रक्तगट </th>  
                      <th> शहर / गाव </th>
                      <th> वापरात आहे? </th>
                      <th> ब्लॉक आहे का? </th>
                      <th> ब्लॉक केलेली तारीख </th>
                      <th> OTP </th>
                    </tr>
                  </thead>
                  <tbody>
                  </tbody>
                </table>
                <p/>
            </div>

          </div>
        </div>
      </div>
    </div>      
  </div>
</div>
</div>
</form>
<script>
   //$("#surnames").select2();
   $("#CorV").select2();
 //  $("#PrabhagOrWard").select2();
   $("#District").select2();
   $("#Tehsil").select2();
   $("#Booth").select2();
   $("#loading").hide();
   
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.sms', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>