
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Saliq SMS Platform</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="css/bootstrap.min.css">
   <link rel="stylesheet" href="css/datepicker.css">
   <link rel="stylesheet"href="xcss/custom.css">
   <link rel="stylesheet" href="css/footerstyle.css">
  <script src="js/jquery.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
   <script src="js/bootstrap-datepicker.js"></script>
    <script  src="js/jquery.printElement.js"></script>
    <script  src="js/myfucntions.js"></script>
    <style>
    .container-fluid {
        background-image: url("img/bg.jpg") !important;
        background-color: #cccccc !important;
    }
    </style>
</head>
<body>
    <?php
    include 'panel.php';
    include 'login.php';
    include 'newcontact.php';
    include 'editcontacts.php';
    include 'additems.php';
    include 'payment.php';
    ?>
    <script>
$(document).ready(function(){
  get_instatus();
  get_Wardlist();
  check_balance();
  get_contactlist();

  function check_balance(){
      var jaxData="globeVar=26";
       $.ajax({
  	        type:"POST",url:"check_bal.php",data:jaxData
  	        ,cache:false,
  	        success:function(response){
              var resp=jQuery.parseJSON(response);
              var status=resp.status;
              var balance=resp.balance;
              if(status=='success'){
              $("#balance").html("Balance: "+balance);

              }else{
                $("#balance").html("Balance: "+0.00);
              }

  	            }

  	        });//end of ajax call

  }


  function get_instatus(){
    var loggedin=false;
      var jaxData="globeVar=1";
       $.ajax({
  	        type:"POST",url:"checklogin.php",data:jaxData
  	        ,cache:false,
  	        success:function(response){
            //  alert(response);
              var resp=jQuery.parseJSON(response);
              var status=resp.status;
              if(status=='success'){
                loggedin=true;
                $("#content_zone").show();
                $("#loginrow").hide();

              }else{
                $("#content_zone").hide();
                $("#loginrow").show();
              }
  	            }
  	        });//end of ajax call

  }

  function get_Wardlist(){
      var jaxData="globeVar=0";
       $.ajax({
  	        type:"POST",url:"wardlist.php",data:jaxData
  	        ,cache:false,
  	        success:function(response){
  		        //alert(response);
                          // alert(response);
      $("#wardlist").html(response);
      $("#target").html(response);

  	            }

  	        });//end of ajax call

  }

  function get_contactlist(){
      var jaxData="globeVar=0";
       $.ajax({
  	        type:"POST",url:"contactlist.php",data:jaxData
  	        ,cache:false,
  	        success:function(response){
  		        //alert(response);
                          // alert(response);
      $("#contacttable").html(response);
      //$("#target").html(response);

  	            }

  	        });//end of ajax call

  }

$("#target").change(function(){
  var wardname=$('#target :selected').text();
  $("#wardname").val(wardname);
});

  $("#addcontact").click(function(){
    $("#new-alert").html('');
     //alert("Clicked");
     var contactname=$("#contactname").val();
     var telephone=$("#telephone").val();
     var wardname=$("#wardname").val();
      var mydata="contactname="+contactname+"&telephone="+telephone+"&wardname="+wardname;
     //alert(mydata);
       $.ajax({
    type:"POST",url:"savecontact.php",data:mydata
    ,cache:false,
    beforeSend:function(){
      $("#addcontact").html('<span id="spinoff" class="glyphicon"></span>Loading....');
$("#spinoff").addClass("glyphicon-refresh glyphicon-refresh-animate");
//$("#viewclass").disable(true);

      },
    success:function(response){
    //  alert(response);
                  var resp=jQuery.parseJSON(response);
                  var status=resp.status;
                  var msg=resp.mesaage;
                  if(status=='success'){
                    $("#contactname").val('');
                      $("#telephone").val('');
                      $("#wardname").val('');

                  }else{
                      document.getElementById("new-alert").innerHTML="<div class='alert alert-danger'><strong>Failed!</strong> Login Failed.Invalid UserName and or Password."+msg+"</div>";
                  }
        },
        complete:function(){
                  //alert(rep);
          $("#addcontact").html("Add Contact");
          $("#spinoff").removeClass("glyphicon-refresh glyphicon-refresh-animate");
          //$("#viewclass").disable(false);
          }

    });//end of ajax call
  });


  $("#sendsms").click(function(){
    $("#sms-alert").html('');
     //alert("Clicked");
     var smstext=$("#smstext").val();
     var group=$("#wardlist").val();
  alert(smstext);
      var mydata="message="+smstext+"&group="+group;
     alert(mydata);
       $.ajax({
    type:"POST",url:"sendsms.php",data:mydata
    ,cache:false,
    beforeSend:function(){
      $("#sendsms").html('<span id="spinoff" class="glyphicon"></span>Loading....');
$("#spinoff").addClass("glyphicon-refresh glyphicon-refresh-animate");
//$("#viewclass").disable(true);

      },
    success:function(response){
    // alert(response);
     document.getElementById("sms-alert").innerHTML="<div class='alert alert-success'><strong>Failed!</strong> Smses Successfully Delivered</div>";
     $("#smstext").val('');
     $("#wardlist").val('');

                /*  var resp=jQuery.parseJSON(response);
                  var status=resp.status;
                  var msg=resp.mesaage;
                  if(status=='success'){
                    $("#contactname").val('');
                      $("#telephone").val('');
                      $("#wardname").val('');

                  }else{
                      document.getElementById("new-alert").innerHTML="<div class='alert alert-danger'><strong>Failed!</strong> Login Failed.Invalid UserName and or Password."+msg+"</div>";
                  } */
        },
        complete:function(){
                  //alert(rep);
          $("#sendsms").html("Send SMS");
          $("#spinoff").removeClass("glyphicon-refresh glyphicon-refresh-animate");
          //$("#viewclass").disable(false);
          }

    });//end of ajax call
  });



});
    </script>
</body>
</html>
