<?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();
         $("#SendSMS").removeAttr("disabled");
         $("#SelectALl").removeAttr("disabled");
         var Types=$("#Type").val();
		     var table = $('#AppUsers').DataTable();
          table.destroy();

          $('#AppUsers').DataTable({
             "responsive": true,
             "dataType": "json",
             dom: 'Blfrtip',
                buttons: [
                  'csvHtml5'
                ],
             "lengthMenu": [[10, 25, 50,100, 500,2000], [10, 25, 50,100, 500,2000]],
             "sAjaxSource": "APPReports?DistrictId=14&TehsilID=53&IsCity=1&CityOrVillageName=1&App_Status=&Type="+Types,
             initComplete: function() { $('#loading').hide(); },
             "aoColumns": [ 
                { "mData": "SMS" },
	              { "mData": "AppUserID" },
                { "mData": "Name" },
                { "mData": "MobileNumber" },
                { "mData": "Email" },
                { "mData": "WhatsAppNumber" },
                { "mData": "Address" },
                { "mData": "DateOfBirth" },
                { "mData": "BloodGroup" },
                { "mData": "CastName" },
                { "mData": "Type" },
                { "mData": "TotalVoters" },
                { "mData": "EditApp" },
               ]
            });
  }

  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-android-app' 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="Type" name="Type" class="form-control">
                      <option value=""> कार्यकर्ता प्रकार </option>
                      <?php foreach($Types as $Type): ?>
                        <option value="<?php echo e($Type->Type); ?>"><?php echo e($Type->Type); ?></option>
                      <?php endforeach; ?>
                    </select>
                </div>              
                <div class="col-lg-2">
                    <input type="button" value="दाखवा" onclick="ShowAppUsers()" class="cg fm"></input>
                </div>
                <div class="col-lg-2">
                    <input type="submit" id="SendSMS" name="SendSMS" value=" संदेश पाठवा " class="cg fp"></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> <input type="checkbox" onclick="selectAll()" id="SelectALl" name="SelectALl" value="All"> </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>
                    </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();
    $("#SendSMS").attr("disabled", true);
    $("#SelectALl").attr("disabled",true);
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.sms', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>