<?php $__env->startSection('content'); ?> 

	<style type="text/css">
		#installationForm .tab-content {
		    /*margin-top: 40px;*/
		}
		body {
		   font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
		   font-size: 14px;
		   line-height: 1.6;
		   color: #1e3948;
		   /*background-color: #f5f8fa; */
		}
	</style>
<script>
  function loadZoneNames()
  {
      var StateId=$('#States').val();
      // Get State Name
      $.ajax({
          type: "GET",
          url: "getZoneNames",
          data:"stateid="+StateId,
          dataType: "json",
          success: function(result){
               $('#Zones').children().remove();         
               $('#Zones').append($('<option>').text("Zone").attr('value', ""));
              $.each(result, function(id, value) {
                $('#Zones').append($('<option>').text(value.ZoneName).attr('value', value.ZoneID));
              });
            }
          });
  }

  function loadDistrictNames()
  {
      var StateId=$('#States').val();
      var ZoneId=$('#Zones').val();
      // Get State Name
      $.ajax({
          type: "GET",
          url: "getDistrictNames",
          data:"zoneid="+ZoneId,
          dataType: "json",
          success: function(result){
               $('#Districts').children().remove();         
               $('#Districts').append($('<option>').text("District").attr('value', ""));
               $.each(result, function(id, value) {
                  $('#Districts').append($('<option>').text(value.DistrictName).attr('value', value.DistrictID));
               });
            }
          });
  }

 function loadTehsilNames()
  {
      var DistrictId=$('#Districts').val();
      // Get State Name
      $.ajax({
          type: "GET",
          url: "getTehsilNames",
          data:"districtid="+DistrictId,
          dataType: "json",
          success: function(result){
               $('#Tehsils').children().remove();         
               $('#Tehsils').append($('<option>').text("Tehsil").attr('value', ""));
               $.each(result, function(id, value) {
                  $('#Tehsils').append($('<option>').text(value.TehsilName).attr('value', value.TehsilID));
               });
            }
       });
  }
  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 loadVillageNames()
  {
      var TehsilId=$('#Tehsils').val();
      // Get State Name
      $.ajax({
          type: "GET",
          url: "getVillageNames",
          data:"tehsilid="+TehsilId,
          dataType: "json",
          success: function(result){
               $('#Villages').children().remove();         
               $('#Villages').append($('<option>').text("Village").attr('value', ""));
               $.each(result, function(id, value) {
                  $('#Villages').append($('<option>').text(value.VillageName).attr('value', value.VillageID));
               });
            }
       });
  }

  function loadVillageName()
  {
      var CityId=$('#Villages').val();
      // Get State Name
      $.ajax({
          type: "GET",
          url: "getVillageNameById",
          data:"villageid="+CityId,
          dataType: "json",
          success: function(result){
              $.each(result, function(id, value) {
                  $("#Village").val(value.VillageName);
                });
              }
       });   
  }

  // Load City or Village if 
  function loadCityOrVillage()
  {
    if(document.getElementById("Ci").checked==true)  // City is Selected then Add 
    {
      // if City is checked
         var TehsilId=$('#Tehsils').val();
              // Get State Name
         $.ajax({
            type: "GET",
            url: "getCityNames",
            data:"tehsilid="+TehsilId,
            dataType: "json",
            success: function(result){
               $('#Citys').children().remove();         
               $('#Citys').append($('<option>').text("City").attr('value', ""));
               $.each(result, function(id, value) {
                  $('#Citys').append($('<option>').text(value.CityName).attr('value', value.CityID));
               });
              }
          });
    }
    else if(document.getElementById("Vi").checked==true)
    {
        var TehsilId=$('#Tehsils').val();
       // Get State Name
        $.ajax({
            type: "GET",
            url: "getVillageNames",
            data:"tehsilid="+TehsilId,
            dataType: "json",
            success: function(result){
                $('#Villages').children().remove();         
                $('#Villages').append($('<option>').text("Village").attr('value', ""));
                $.each(result, function(id, value) {
                    $('#Villages').append($('<option>').text(value.VillageName).attr('value', value.VillageID));
              });
            }
       });
    }
  }

 function showCity()
  {
            $("#VillageId").hide();
            $("#CityId").show();

            // Load Cities from Tehsil
             var TehsilId=$('#Tehsils').val();
              // Get State Name
              $.ajax({
                  type: "GET",
                  url: "getCityNames",
                  data:"tehsilid="+TehsilId,
                  dataType: "json",
                  success: function(result){
                       $('#Citys').children().remove();         
                       $('#Citys').append($('<option>').text("City").attr('value', ""));
                       $.each(result, function(id, value) {
                          $('#Citys').append($('<option>').text(value.CityName).attr('value', value.CityID));
                       });
                    }
               });
  }

  function showVillage()
  {
            $("#CityId").hide();
            $("#VillageId").show();
            var TehsilId=$('#Tehsils').val();
            // Get State Name
            $.ajax({
                type: "GET",
                url: "getVillageNames",
                data:"tehsilid="+TehsilId,
                dataType: "json",
                success: function(result){
                    $('#Villages').children().remove();         
                       $('#Villages').append($('<option>').text("Village").attr('value', ""));
                       $.each(result, function(id, value) {
                          $('#Villages').append($('<option>').text(value.VillageName).attr('value', value.VillageID));
                       });
                    }
             });
  }

 function showCity1()
  {
            $("#Village1").hide();
            $("#City1").show();
            // Load Cities from Tehsil
             var TehsilId=$('#Tehsil').val();
              // Get State Name
              $.ajax({
                  type: "GET",
                  url: "getCityNames",
                  data:"tehsilid="+TehsilId,
                  dataType: "json",
                  success: function(result){
                       $('#City').children().remove();         
                       $('#City').append($('<option>').text("City").attr('value', ""));
                       $.each(result, function(id, value) {
                          $('#City').append($('<option>').text(value.CityName).attr('value', value.CityID));
                       });
                    }
               });
  }

  function showVillage1()
  {
            $("#City1").hide();
            $("#Village1").show();

            var TehsilId=$('#Tehsil').val();
            // Get State Name
            $.ajax({
                type: "GET",
                url: "getVillageNames",
                data:"tehsilid="+TehsilId,
                dataType: "json",
                success: function(result){
                    $('#Village').children().remove();         
                       $('#Village').append($('<option>').text("Village").attr('value', ""));
                       $.each(result, function(id, value) {
                          $('#Village').append($('<option>').text(value.VillageName).attr('value', value.VillageID));
                       });
                    }
             });
  }

  function loadBooths()
  {
      var TehsilId=$('#Tehsil').val();
      // Get State Name
      var Village_Or_City_Id=0;

      //Check if is City or village
      var IsCity=0;
      if(document.getElementById("City").checked==true)
      {
        IsCity=1;
        Village_Or_City_Id=$("#CorV").val();
      }
      else if(document.getElementById("Village").checked==true)
      {
        IsCity=0;
        Village_Or_City_Id=$("#CorV").val();
      }

      $.ajax({
        type: "GET",
        url: "getBoothsNumbersById",
        data:"Village_Or_City_Id="+Village_Or_City_Id,
        dataType: "json",
        success: function(result){
          $('#Booth').children().remove();         
            $('#Booth').append($('<option>').text("बूथ").attr('value', ""));
          $.each(result, function(id, value) {
                $('#Booth').append($('<option>').text(value.BoothNumber).attr('value', value.BoothID));
          });
         }
        });
  }

 function loadAppUsers()
  {
      var BoothId=$('#Booth').val();
      $.ajax({
            type: "GET",
            url: "getAppsOfBooth",
            data:"BoothId="+BoothId,
            dataType: "json",
            success: function(result){
                $('#AppUserId').children().remove();         
                $('#AppUserId').append($('<option>').text("App Users ").attr('value', ""));
                $.each(result, function(id, value) {
                    $('#AppUserId').append($('<option>').text(value.Name +" | "+ value.MobileNumber ).attr('value', value.AppUserID));
              });
            }
       });
  }

  function loadBooth()
  {
      var TehsilId=$('#Tehsil').val();
      // Get State Name
      var Village_Or_City_Id=0;

      //Check if is City or village
      var IsCity=0;
      if(document.getElementById("City").checked==true)
      {
        IsCity=1;
        Village_Or_City_Id=$("#CorV").val();
      }
      else if(document.getElementById("Village").checked==true)
      {
        IsCity=0;
        Village_Or_City_Id=$("#CorV").val();
      }
  }

  function GetAllInfoOfAppUser()
  {
      var AppUserID=$('#AppUserId').val();

      $.ajax({
            type: "GET",
            url: "GetAllInfoOfAppUser",
            data:"AppUserId="+AppUserID,
            dataType: "json",
            beforeSend: function(){
             $("#loading").show();
           },
           complete: function(){
             $("#loading").hide();
           },
            success: function(result){
              //  Booth , Citys , Villages (Visible VillageId ,CityId ), Vi ,Ci , Tehsils , Districts,Zones,States             
                if(result.IsCity==0) // Load Villages
                {
                  //document.getElementById("Vi").checked=true;
                  //document.getElementById("Citys").innerHTML=result.SelectVillage_City_ID;
                  document.getElementById("Villages").innerHTML=result.SelectVillage_City_ID;
                  document.getElementById("Citys").innerHTML=""; 

                }
                else if(result.IsCity==1) // Load Cities
                {
                 // document.getElementById("Ci").checked=true;
                  document.getElementById("Citys").innerHTML=result.SelectVillage_City_ID;
                  document.getElementById("Villages").innerHTML="";
                }
                document.getElementById("Districts").innerHTML=result.SelectedDistrict;
                document.getElementById("Tehsils").innerHTML=result.SelectedTehsil;

                var tables = $.fn.dataTable.fnTables(true);
            }
       });
  }

  function selectAllVoters()
  {
    var oTable = $('#UnassignedVoters').dataTable();
    // Get the length
    var length=oTable.fnGetData().length;

    //var length=tables.fnGetData().length;
   // alert("Total Length of Table : "+length);

    if(document.getElementById("AssignAllVoter").checked==true) // Select All Voters to Assign
    {
      for (var i = 0; i < length; i++) {
         //alert($("#Assign_"+i).val() );
         if (typeof(document.getElementById("Assign_"+i)) != 'undefined' && document.getElementById("Assign_"+i) != null) 
         {
           document.getElementById("Assign_"+i).checked=true;
         }
      }
    }
    else if(document.getElementById("AssignAllVoter").checked==false) // Select All Voters to Assign
    {
     for (var i = 0; i < length; i++) {
       if (typeof(document.getElementById("Assign_"+i)) != 'undefined' && document.getElementById("Assign_"+i) != null) 
       {
          document.getElementById("Assign_"+i).checked=false;
        }
      }
    }
  }

  // here Unselect All voters from voters to assign table
  function UnselectAllToAssign(id)
  {
     //alert("In unselect Voters table 1 "+id);
      if(document.getElementById("Assign_"+id).checked==true)
      {
        document.getElementById("AssignAllVoter").checked=false;
      }
  }

  // Unselect All assigned Voters
 function UnselectAllAssigned(id)
  {
    //  alert("id"+id);
     var oTable = $('#AssignedVoters').dataTable();
    // Get the length
    var length=oTable.fnGetData().length;
    if(document.getElementById("Remove_"+id).checked==true)
    {

    }
    else
    {

    }
  }

// TO Remove Voters 
  
  function removeAllVoters() //from Voters to remove table
  {
    var oTable = $('#AssignedVoters').dataTable();
    // Get the length
    var length=oTable.fnGetData().length;

    //var length=tables.fnGetData().length;
    // alert("Total Length of Table : "+length);

    if(document.getElementById("RemoveAllVoter").checked==true) // Select All Voters to Assign
    {
      for (var i = 0; i < length; i++) {
         //alert($("#Assign_"+i).val() );
         if (typeof(document.getElementById("Remove_"+i)) != 'undefined' && document.getElementById("Remove_"+i) != null) 
         {
           document.getElementById("Remove_"+i).checked=true;
         }
      }
    }
    else if(document.getElementById("RemoveAllVoter").checked==false) // Select All Voters to Assign
    {
     for (var i = 0; i < length; i++) {
       if (typeof(document.getElementById("Remove_"+i)) != 'undefined' && document.getElementById("Remove_"+i) != null) 
       {
          document.getElementById("Remove_"+i).checked=false;
       }
      }
    }
  }

  function AssignVoters()
  {
    $("#loading").show();
    var AppUserId=$("#AppUserId").val();
    var Voters=[];
    var AccessLevel=$("#AccessLevel").val();
    var Confirm=confirm(" निवडलेल्या कार्यकर्त्याला निवडलेले मतदार नक्की जोडायचे का? ");
    if(Confirm==true)
    {
      if(document.getElementById("AssignAllVoter").checked==true)
      {
          // Get All Voters from table and
          var oTable = $('#UnassignedVoters').dataTable();
          // Get the length
          var length=oTable.fnGetData().length;
         // alert("Length : "+length);
          var j=0;
          for (var i = 0; i < length; i++) {
           if (typeof(document.getElementById("Assign_"+i)) != 'undefined' && document.getElementById("Assign_"+i) != null)
           {
              if($("#Assign_"+i).val()!=null)
              {
                Voters[j]=$("#Assign_"+i).val();
                j++;
              }
           }
         }
         if(Voters.length>0)
         {
            $.ajax({
              dataType: "json",
              type: "GET",
              url: "AssignVoters?AppUserId="+AppUserId+"&Voters="+JSON.stringify(Voters),
              beforeSend: function(){
               $("#loading").show();
              },
              initComplete: function() { $('#loading').hide(); },
              success: function(result){
                  document.getElementById("success").innerHTML=result.SuccessfullyAssigned;
                  document.getElementById("notsaved").innerHTML=result.Cancelled;
                  document.getElementById("AlreadySaved").innerHTML=result.AlreadyAssigned;
                  document.getElementById("AssignAllVoter").checked=false;
                  document.getElementById("RemoveAllVoter").checked=false;
                  $("#loading").hide();
                  ShowVoters();
              }
          });
        }
        else
        {
           alert(" कृपया मतदार निवडा ");
           $("#loading").hide();
        }
      }
      else if(document.getElementById("AssignAllVoter").checked==false){
        // Get Only Checked Voters
       // Get All Voters from table and
          var oTable = $('#UnassignedVoters').dataTable();
          // Get the length
          var length=oTable.fnGetData().length;
        //   alert("Length : "+length);
          var j=0;
          for (var i = 0; i < length; i++) {
           if (typeof(document.getElementById("Assign_"+i)) != 'undefined' && document.getElementById("Assign_"+i) != null)
           {
              if(document.getElementById("Assign_"+i).checked==true)
              {
                Voters[j]=$("#Assign_"+i).val();              
                j++;
              }
            // alert($("#Assign_"+i).val());
           }
         }
         if(Voters.length>0)
         { 
          $.ajax({
            dataType: "json",
            type: "GET",
            url: "AssignVoters?AppUserId="+AppUserId+"&Voters="+JSON.stringify(Voters),
            beforeSend: function(){
             $("#loading").show();
            },
            initComplete: function() { $('#loading').hide(); },
            success: function(result){
                  $("#loading").hide();
                  document.getElementById("success").innerHTML=result.SuccessfullyAssigned;
                  document.getElementById("notsaved").innerHTML=result.Cancelled;
                  document.getElementById("AlreadySaved").innerHTML=result.AlreadyAssigned;
                  document.getElementById("AssignAllVoter").checked=false;
                  document.getElementById("RemoveAllVoter").checked=false;                  
                  ShowVoters();
                }
          });
        }
        else
        {
          alert(" कृपया मतदार निवडा ");
          $("#loading").hide();
        }
      }
    }
  }

  function RemoveVoters()
  {
    $("#loading").show();
    var AppUserId=$("#AppUserId").val();
    var Voters=[];
    var Confirm=confirm("निवडलेल्या कार्यकर्त्याचे निवडलेले मतदार नक्की काढायचे का?");
    if(Confirm==true)
    {
       if(document.getElementById("RemoveAllVoter").checked==true)
        {
            // Get All Voters from table and
           // alert("Alert : "+AppUserId);
            var oTable = $('#AssignedVoters').dataTable();
            // Get the length
            var length=oTable.fnGetData().length;
            //   alert("Length : "+length);
            var j=0;
            for (var i = 0; i < length; i++) {
             if (typeof(document.getElementById("Remove_"+i)) != 'undefined' && document.getElementById("Remove_"+i) != null)
             {
                if($("#Remove_"+i).val()!=null)
                {
                  Voters[j]=$("#Remove_"+i).val();
                  j++;
                }
             }
           }
         if(Voters.length>0)
         {
            $.ajax({
               dataType: "json",
              type: "GET",
              url: "RemoveVoters?AppUserId="+AppUserId+"&Voters="+JSON.stringify(Voters),
              beforeSend: function(){
                $("#loading").show();
              },
              initComplete: function() { $('#loading').hide(); },
              success: function(result){

                    document.getElementById("success").innerHTML=result.DeletedCount;
                    document.getElementById("notsaved").innerHTML=result.NotDeletedCount;
                    document.getElementById("AlreadySaved").innerHTML="";
                    document.getElementById("AssignAllVoter").checked=false;
                    document.getElementById("RemoveAllVoter").checked=false;
                    ShowVoters();
                    $("#loading").show();

                  }
            });
          }
          else
          {
             alert(" कृपया मतदार निवडा ");
             $("#loading").hide();
          }
        }
        else if(document.getElementById("RemoveAllVoter").checked==false){
            // Get Only Checked Voters
            // Get All Voters from table and
            var oTable = $('#AssignedVoters').dataTable();
            // Get the length
            var length=oTable.fnGetData().length;
            //   alert("Length : "+length);
            var j=0;
            for (var i = 0; i < length; i++) {
             if (typeof(document.getElementById("Remove_"+i)) != 'undefined' && document.getElementById("Remove_"+i) != null) 
             {
                if(document.getElementById("Remove_"+i).checked==true)
                {
                  Voters[j]=$("#Remove_"+i).val();  
                  j++;
                }
              //alert($("#Assign_"+i).val());
             }
           }
           if(Voters.length>0)
           {
            $.ajax({
              dataType: "json",
              type: "GET",
              url: "RemoveVoters?AppUserId="+AppUserId+"&Voters="+JSON.stringify(Voters),
              beforeSend: function(){
                $("#loading").show();
              },
              initComplete: function() { $('#loading').hide(); },
              success: function(result){
                    document.getElementById("success").innerHTML=result.DeletedCount;
                    document.getElementById("notsaved").innerHTML=result.NotDeletedCount;
                    document.getElementById("AlreadySaved").innerHTML="";
                    document.getElementById("AssignAllVoter").checked=false;
                    document.getElementById("RemoveAllVoter").checked=false;
                    ShowVoters();
                    $("#loading").hide();
               }
            });
          }
          else
          {
             alert(" कृपया मतदार निवडा ");
             $("#loading").hide();
          }
        }  
    }
  }

  function ShowVoters()
  {
      $("#loading").show();
      var AppUserID=$("#AppUserId").val();
      var BoothID=$("#Booth").val();
      var IsCity=-1;
      var FirstName=$("#FirstName").val();
      var LastName=$("#LastName").val();
      var MiddleName=$("#MiddleName").val();
      document.getElementById("AssignAllVoter").checked=false;
      document.getElementById("RemoveAllVoter").checked=false;
      if(document.getElementById("City").checked==true)
      {
        IsCity=1;
      }
      else if(document.getElementById("Village").checked==true)
      {
        IsCity=0;
      }
      var CityOrVillageID=$("#CorV").val();
      var DistrictID=$("#District").val();
      var TehsilID=$("#Tehsil").val();
      if(AppUserID!="")
      {
      tables = $.fn.dataTable.fnTables(true);
        $(tables).each(function () {
          $('#AssignedVoters').dataTable().fnDestroy();
        });

        $('#AssignedVoters').DataTable({
           "bProcessing": true,
           responsive: true,
           "lengthMenu": [[10, 25, 50,100, 500], [10, 25, 50,100, 500]],
           "sAjaxSource": "GetAllContactsByAppUser?AppUserId="+AppUserID+"&BoothId="+BoothID+"&IsCity="+IsCity+"&CityOrVillageID="+CityOrVillageID+"&DistrictID="+DistrictID+"&TehsilID="+TehsilID,//result.AssignedVoters,
           beforeSend: function(){
             $("#loading").show();
           },
           initComplete: function() { $('#loading').hide(); },
           "aoColumns": [
               { "mData": "Remove"},           
               { "mData": "MarathiName" },
               { "mData": "Address" },
               { "mData": "Sex"},
               { "mData": "EditVoter"},
               { "mData": "View"}
              ]
           });

        if(document.getElementById("ShowAppContact").checked==true) // 
        {
            tables = $.fn.dataTable.fnTables(true);
            $(tables).each(function () {
                $('#UnassignedVoters').dataTable().fnDestroy();
            });

            $('#UnassignedVoters').DataTable({
             "bProcessing": true,
             responsive: true,
             "lengthMenu": [[10, 25, 50,100,500], [10, 25, 50,100, 500]],
             "sAjaxSource": "GetAllContactsNotAssignedToAppUsers?AppUserId="+AppUserID+"&BoothId="+BoothID+"&IsCity="+IsCity+"&CityOrVillageID="+CityOrVillageID+"&DistrictID="+DistrictID+"&TehsilID="+TehsilID+"&WithOtherApp=1&FirstName="+FirstName+"&MiddleName="+MiddleName+"&LastName="+LastName,//result.AssignedVoters,
             beforeSend: function(){
               $("#loading").show();
             },
             initComplete: function() { $('#loading').hide(); },
             "aoColumns": [
                { "mData": "Assign"},           
                { "mData": "MarathiName" },
                { "mData": "Address" },
                { "mData": "Sex"},
                { "mData": "EditVoter"},
                { "mData": "View"}
               ]
            });
        }
        else if(document.getElementById("ShowAppContact").checked==false)
        {
            // Contacts Not Assigned to Appusers
             tables = $.fn.dataTable.fnTables(true);
             $(tables).each(function () {
               $('#UnassignedVoters').dataTable().fnDestroy();
            });

            $('#UnassignedVoters').DataTable({
             "bProcessing": true,
              responsive: true,
              "lengthMenu": [[10, 25, 50,100,500], [10, 25, 50,100, 500]],
              "sAjaxSource": "GetAllContactsNotAssignedToAppUsers?AppUserId="+AppUserID+"&BoothId="+BoothID+"&IsCity="+IsCity+"&CityOrVillageID="+CityOrVillageID+"&DistrictID="+DistrictID+"&TehsilID="+TehsilID+"&WithOtherApp=0"+"&FirstName="+FirstName+"&MiddleName="+MiddleName+"&LastName="+LastName,//result.AssignedVoters,
              beforeSend: function(){
               $("#loading").show();
              },
              initComplete: function() { $('#loading').hide(); },
              "aoColumns": [
                   { "mData": "Assign"},               
                   { "mData": "MarathiName" },
                   { "mData": "Address" },
                   { "mData": "Sex"},
                     { "mData": "EditVoter"},
                   { "mData": "View"}
                  ]
              });
            $("#AssignVoterss").removeAttr("disabled");
            $("#RemoveVoterss").removeAttr("disabled");
        }
      }
      else
      {
        $("#loading").hide();
        alert("कार्यकर्ता निवडा");
      }
  }

  function loadContactsOfAllAppUsers()
  {
      $("#loading").show();
      var IsLoadForAll=$("#ShowAppContact").val();
      var AppUserID=$("#AppUserId").val();
      var BoothID=$("#Booth").val();
      var IsCity=-1;
      var FirstName=$("#FirstName").val();
      var LastName=$("#LastName").val();
      var MiddleName=$("#MiddleName").val();

      document.getElementById("AssignAllVoter").checked=false;
      document.getElementById("RemoveAllVoter").checked=false;

      if(document.getElementById("City").checked==true)
      {
        IsCity=1;
      }
      else if(document.getElementById("Village").checked==true)
      {
        IsCity=0;
      }
      var CityOrVillageID=$("#CorV").val();
      var DistrictID=$("#District").val();
      var TehsilID=$("#Tehsil").val();

      if(AppUserID!="")
      {
       if(document.getElementById("ShowAppContact").checked==true)
        {
          tables = $.fn.dataTable.fnTables(true);
          $(tables).each(function () {
              $('#UnassignedVoters').dataTable().fnDestroy();
          });

          $('#UnassignedVoters').DataTable({
          "bProcessing": true,
           responsive: true,
           "lengthMenu": [[10, 25, 50,100, 500], [10, 25, 50,100, 500]],
           "sAjaxSource": "GetAllContactsNotAssignedToAppUsers?AppUserId="+AppUserID+"&BoothId="+BoothID+"&IsCity="+IsCity+"&CityOrVillageID="+CityOrVillageID+"&DistrictID="+DistrictID+"&TehsilID="+TehsilID+"&WithOtherApp=1&FirstName="+FirstName+"&MiddleName="+MiddleName+"&LastName="+LastName,//result.AssignedVoters,
           beforeSend: function(){
             $("#loading").show();
           },
           initComplete: function() { $('#loading').hide(); },
           "aoColumns": [
              { "mData": "Assign"},           
              { "mData": "MarathiName" },
              { "mData": "Address" },
              { "mData": "Sex"},
                { "mData": "EditVoter"},
              { "mData": "View"}
             ]
          });
        }
        else if(document.getElementById("ShowAppContact").checked==false)
        {
           $("#loading").show();
           tables = $.fn.dataTable.fnTables(true);
           $(tables).each(function () {
                $('#UnassignedVoters').dataTable().fnDestroy();
           });

            $('#UnassignedVoters').DataTable({
            "bProcessing": true,
             responsive: true,
             "lengthMenu": [[10, 25, 50,100, 500], [10, 25, 50,100, 500]],
             "sAjaxSource": "GetAllContactsNotAssignedToAppUsers?AppUserId="+AppUserID+"&BoothId="+BoothID+"&IsCity="+IsCity+"&CityOrVillageID="+CityOrVillageID+"&DistrictID="+DistrictID+"&TehsilID="+TehsilID+"&WithOtherApp=0&FirstName="+FirstName+"&MiddleName="+MiddleName+"&LastName="+LastName,//result.AssignedVoters,
             beforeSend: function(){
               $("#loading").show();
             },
             initComplete: function() { $('#loading').hide(); },
             "aoColumns": [
                { "mData": "Assign"},           
                { "mData": "MarathiName" },
                { "mData": "Address" },
                { "mData": "Sex"},
                  { "mData": "EditVoter"},
                { "mData": "View"}
               ]
            });
             $("#loading").hide();
        }
      }
      else
      {
        $("#loading").hide();
        // Please Select App User to Continue...
        alert("Please Select App User to Continue...");
      }
  }
</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>
  <div class="by amt" style="margin-top:-20px;">
	  <div class="gc">
	    <div class="gz">
	      <div class="ca qo anx ">
	        <div class="qf b aml" style="width:223%;margin-left:-60px;" >
	          <div class="row">
	              <div class="col-lg-3"></div>
	                <div class="col-lg-6">
	                   <!-- Errors And Success Messages -->
  	                  <?php if(count($errors)>0): ?>
  	                    <div class="alert alert-danger">
  	                       <ul>
  	                          <?php foreach($errors->all() as $error): ?>
  	                          <li> <strong><font color="red" > <?php echo e($error); ?> </font> </strong></li>
  	                           <p/>
  	                          <?php endforeach; ?>
  	                       </ul>
  	                   </div>
  	                  <?php endif; ?>
	                   </p>
	                         <?php if(Session::has('success')): ?>
	                              <font color="green" > <?php echo e(Session::get('success')); ?> </font>
	                              <p/>
	                            <?php endif; ?>

	                            <?php if(Session::has('error')): ?>
	                              <font color="red" > <?php echo e(Session::get('error')); ?> </font>
	                              <p/>
	                            <?php endif; ?>
	                   </div>
	                  <div class="col-lg-3"></div>
	              </div>

	            <div class="row">
                <h5>  कार्यकता निवडा </h5>
	                <div class="col-lg-12">
                    <div class="col-lg-6">
                    <!--  Load Apps  -->
                      <select id="AppUserId" name="AppUserId" onchange="GetAllInfoOfAppUser();" class="form-control">
                        <option value="">  कार्यकता निवडा </option>
                         <?php foreach($AppUsers as $AppUser): ?>
                             <option value="<?php echo e($AppUser->AppUserID); ?>"><?php echo e($AppUser->Name); ?> | <?php echo e($AppUser->MobileNumber); ?>  </option>
                          <?php endforeach; ?>
                      </select>
                    </div>
                    <div class="col-lg-6">
                      गाव / शहर : <strong><span id="Citys">___________</span> <span id="Villages"></span></strong> &nbsp;&nbsp;&nbsp; तालुका : <strong><span id="Tehsils">__________</span></strong>  &nbsp;&nbsp;&nbsp; जिल्हा : <strong><span id="Districts">__________</span></strong>
                    </div>
                  </div>
              </div>
              <div class="row"style="margin-top:20px;">
               <h5> मतदार पत्ता निवडा </h5>
                <div class="col-lg-12">
                  <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" onchange="loadBooths();" 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="Booth" name="Booth" style="width:80%" class="form-control" >
                        <option value=""> बूथ </option>
                         <?php foreach($Booths as $Booth): ?>
                            <option value="<?php echo e($Booth->BoothID); ?>"><?php echo e($Booth->BoothNumber); ?></option>
                          <?php endforeach; ?>
                      </select>
                  </div>
                </div>
              </div>
               <div class="row"style="margin-top:20px;">
                <div class="col-lg-12">

                  <div class="col-lg-2"> 
                     <input type="text" name="LastName" id="LastName" placeholder=" आडनाव " class="form-control">
                  </div> 
                  <div class="col-lg-2"> 
                     <input type="text" name="FirstName" id="FirstName" placeholder="नाव" class="form-control">
                  </div>
                  <div class="col-lg-2"> 
                     <input type="text" name="MiddleName" id="MiddleName" placeholder=" वडिलांचे / पतीचे नाव" class="form-control">
                  </div> 
                  <div class="col-lg-2"> 
                     <input type="button" value="दाखवा" onclick="ShowVoters()" class="cg fm"></input>                    
                  </div>
                </div>
              </div>
              <!--  -->
              <div class="row" style="margin-top:20px;">
                <div class="col-lg-12" >
                  <div class="col-lg-4">
                      <font color='green'><span id="success"></span> </font><p/>
                      <font color='red'><span id="notsaved"></span> </font><p/>
                      <span id="AlreadySaved"></span>
                  </div>
                </div>
	            </div>
              <div>

              <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>
              <div class="row">
                <div class="col-lg-12" >
                  <input id="ShowAppContact" name="ShowAppContact" type="checkbox" onclick="loadContactsOfAllAppUsers()" >&nbsp;<strong>इतर कार्यकर्त्याला जोडलेले मतदार दाखवा</strong></input>
                </div>
              </div>

              <div class="row" style="margin-top:12px;">
                <div class="col-lg-2"></div>
                <div class="col-lg-2">
                  <div class="col-lg-12">
                    <button type="button" id="AssignVoterss" class="cg fp" onclick="AssignVoters()">Assign</button>
                  </div>
                </div>
                <div class="col-lg-4"></div>
                <div class="col-lg-2">
                  <div class="col-lg-12">
                    <button type="button" id="RemoveVoterss" class="cg fp" onclick="RemoveVoters()">Remove</button>
                  </div>
                </div>                
              </div>
             <div class="row">
                <div class="col-lg-12" >
                    <!-- Datatable 1 -->
                    <div class="col-lg-6" style="margin-top:12px">
                        <table id="UnassignedVoters" class="table table-striped table-bordered dt-responsive nowrap">
                          <thead>
                            <tr>
                            <th><input type="checkbox" name="AssignAllVoter" id="AssignAllVoter" onclick="selectAllVoters()" ></th>                              
                              <th> संपूर्ण नाव </th>
                              <th> पत्ता</th>
                              <th> लिंग </th>
                              <th> बदल करा  </th>
                              <th> View </th>
                            </tr>
                          </thead>
                          <tbody>
                          </tbody>
                        </table>
                        <p/>
                    </div>
                    <input type="hidden" id="IsCity">
                    <input type="hidden" id="AccessLevel">
                    <input type="hidden" id="SelectBoothId">
                    <input type="hidden" id="BoothNumber">

                    <!--  <div class="col-lg-1" style="margin-top:12px">       </div>-->

                    <div class="col-lg-6" style="margin-top:12px">
                      <div class="datatable">
                        <table id="AssignedVoters" class="table table-striped table-bordered dt-responsive nowrap">
                          <thead>
                            <tr>
                              <th><input type="checkbox" name="RemoveAllVoter" id="RemoveAllVoter" onclick="removeAllVoters()"></th>
                              <th> संपूर्ण नाव </th>
                              <th> पत्ता</th>
                              <th> लिंग </th>
                              <th> बदल करा  </th>
                              <th> View </th>
                            </tr>
                          </thead>
                          <tbody>
                          </tbody>
                        </table>
                      </div>
                    </div>
                </div>
              </div>
      		</div>
	      </div>
       </div>
      </div>
    </div>

    <script>
    $(document).ready(function() {
        $("#loading").hide();
         $("#CorV").select2();
       //  $("#PrabhagOrWard").select2();
         $("#District").select2();
         $("#Tehsil").select2();
         $("#Booth").select2();
          $("#AssignVoterss").attr("disabled", true);
           $("#RemoveVoterss").attr("disabled", true);
        $("#AppUserId").select2();
        //$("#Education").select2();

      /*    $('#UnassignedVoters').DataTable({
            "bProcessing": true,
            "aoColumns": [
              { "mData": "Name" },
              { "mData": "Address"},
              { "mData": "NewAddress" },
              { "mData": "Sex" }
            ]
          });

      $('#AssignedVoters').DataTable({
            "bProcessing": true,
            "aoColumns": [
              { "mData": "Name" },
              { "mData": "Address"},
              { "mData": "NewAddress" },
              { "mData": "Sex" }
            ]
          }); */
     });
</script>

<style>
.pagination {
  display: inline-block;
  padding-left: 0;
  margin-top: 1rem;
  margin-bottom: 1rem;
  border-radius: .25rem;
}

.page-item {
  display: inline;
}

.page-item:first-child .page-link {
  margin-left: 0;
  border-top-left-radius: .25rem;
  border-bottom-left-radius: .25rem;
}

.page-item:last-child .page-link {
  border-top-right-radius: .25rem;
  border-bottom-right-radius: .25rem;
}

.page-item.active .page-link, .page-item.active .page-link:focus, .page-item.active .page-link:hover {
  z-index: 2;
  color: #fff;
  cursor: default;
  background-color: #0275d8;
  border-color: #0275d8;
}

.page-item.disabled .page-link, .page-item.disabled .page-link:focus, .page-item.disabled .page-link:hover {
  color: #818a91;
  cursor: not-allowed;
  background-color: #fff;
  border-color: #ddd;
}

.page-link {
  position: relative;
  float: left;
  padding: .5rem .75rem;
  margin-left: -1px;
  line-height: 1.5;
  color: #0275d8;
  text-decoration: none;
  background-color: #fff;
  border: 1px solid #ddd;
}

.page-link:focus, .page-link:hover {
  color: #014c8c;
  background-color: #eceeef;
  border-color: #ddd;
}

.pagination-lg .page-link {
  padding: .75rem 1.5rem;
  font-size: 1.25rem;
  line-height: 1.333333;
}

.pagination-lg .page-item:first-child .page-link {
  border-top-left-radius: .3rem;
  border-bottom-left-radius: .3rem;
}

.pagination-lg .page-item:last-child .page-link {
  border-top-right-radius: .3rem;
  border-bottom-right-radius: .3rem;
}

.pagination-sm .page-link {
  padding: .275rem .75rem;
  font-size: .875rem;
  line-height: 1.5;
}

.pagination-sm .page-item:first-child .page-link {
  border-top-left-radius: .2rem;
  border-bottom-left-radius: .2rem;
}

.pagination-sm .page-item:last-child .page-link {
  border-top-right-radius: .2rem;
  border-bottom-right-radius: .2rem;
}

 .pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}
 .pagination>li{display:inline}
 .pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.42857143;color:#337ab7;text-decoration:none;background-color:#fff;border:1px solid #ddd}
 .pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-top-left-radius:4px;border-bottom-left-radius:4px}
 .pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}
 .pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{color:#23527c;background-color:#eee;border-color:#ddd}
 .pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{z-index:2;color:#fff;cursor:default;background-color:#337ab7;border-color:#337ab7}.pagination>.disabled>a,.pagination>.disabled>a:focus,.pagination>.disabled>a:hover,.pagination>.disabled>span,.pagination>.disabled>span:focus,.pagination>.disabled>span:hover{color:#777;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-top-left-radius:6px;border-bottom-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-top-left-radius:3px;border-bottom-left-radius:3px}
 .pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}

</style>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.votermainview', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>