<?php  include("homeheader.php");?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap -->
    <link href="vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="vendors/iCheck/skins/flat/green.css" rel="stylesheet">
    <!-- Datatables -->
    <link href="vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
    <link href="vendors/datatables.net-buttons-bs/css/buttons.bootstrap.min.css" rel="stylesheet">
    <link href="vendors/datatables.net-fixedheader-bs/css/fixedHeader.bootstrap.min.css" rel="stylesheet">
    <link href="vendors/datatables.net-responsive-bs/css/responsive.bootstrap.min.css" rel="stylesheet">
    <link href="vendors/datatables.net-scroller-bs/css/scroller.bootstrap.min.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="css/custom.css" rel="stylesheet">
  </head>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
            <!--div class="navbar nav_title" style="border: 0;">
              <a href="index.html" class="site_title">
			  <div class="profile_pic" style="margin-top:-10px;">
					<img src="images/mlogo.png" alt="" class="img-circle profile_img" />
				</div>
			  <!--i class="fa fa-paw"></i--> <!--span>Instant Airtime </span></a>
            </div-->

            <div class="clearfix"></div>

			
            <!-- menu profile quick info -->
            <div class="profile">
              <div class="profile_pic">
			  			     <?php 
			  if($img == ""){
				  ?>
				   <img src="profileimages/noimage.gif" alt="..." class="img-circle profile_img">
				  <?php
			  }else{
				?>
				 <img src="<?php echo $photo ?>" alt="..." class="img-circle profile_img" width="40px;" height="60px;">
            <?php				
			  }
			  ?>
              </div>
             <div class="profile_info">

                <span>Welcome,</span>
			<h2> <?php $fname = $dat['fname']; $lname = $dat['lname']; $comp = $dat['company'];  if(empty($comp)){ echo ucwords($fname." ".$lname); }else{ echo ucwords($comp); }  ?> </h2>
             <!--   <h2>John Doe</h2> -->
              </div>
            </div>
            <!-- /menu profile quick info -->

            <br />

            <!-- sidebar menu -->
            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
              <div class="menu_section">
			  <br/>
                <h3>General</h3>
                <ul class="nav side-menu">
                  <li ><a  href="homepage.php" ><i class="fa fa-home"></i>  Home <span class="fa fa-chevron-right"></span></a> </li>
                  <li><a href="#"><i class="fa fa-building"></i> My Contacts <span class="fa fa-chevron-down"></span></a> 
				 <ul class="nav child_menu">
					    <li><a  href="addcontact.php" ><i class="fa fa-user-plus"></i>Add New Contact<span class="fa fa-chevron-right"></span></a> </li>
						<li><a  href="addnewcontact.php" ><i class="fa fa-eye"></i>View Contacts<span class="fa fa-chevron-right"></span></a> 
						<!--ul class="nav child_menu">
						 <li><a  href="addnewcontact.php" ><i class="fa fa-bug"></i>List<span class="fa fa-chevron-right"></span></a> </li>
						<li><a  href="viewcontacts.php" ><i class="fa fa-bug"></i>Grid<span class="fa fa-chevron-right"></span></a> </li>
						</ul-->
						</li>
					   </ul>
				  </li>
                  <li class="active"><a href="#"><i class="fa fa-users"></i> Groups <span class="fa fa-chevron-down"></span></a> 
				        <ul class="nav child_menu">
					   <li><a  href="creategroup.php" ><i class="fa fa-paw"></i>Create Group<span class="fa fa-chevron-right"></span></a> </li>
						<li ><a  href="viewgroups.php" ><i class="fa fa-eye"></i>View Groups<span class="fa fa-chevron-right"></span></a> </li>
					   </ul>
				  </li>
                  <li><a href="#"><i class="fa fa-table"></i> Topup <span class="fa fa-chevron-down"></span></a>  
				   <ul class="nav child_menu">
             			<li><a  href="sendtogroup.php" ><i class="fa fa-cloud-download"></i>Top-up Group Contacts<span class="fa fa-chevron-right"></span></a> </li>
						<li><a  href="selectcontacttosend.php" ><i class="fa fa-building"></i>Select Contact(s)<span class="fa fa-chevron-right"></span></a> </li>
						 <li><a  href="sendtome.php"  ><i class="fa fa-mobile"></i> Top-up My Line<span class="fa fa-chevron-right"></span></a> </li>
						 <li><a href="autosend-airtime.php" ><i class="fa fa-recycle"></i> Auto-Send Airtime <span class="fa fa-chevron-right"></span></a> </li>
					   </ul>
					  				  
				  </li>
                  
				   <li><a href="#"><i class="fa fa-gg"></i> Billing <span class="fa fa-chevron-down"></span></a> 
				   <ul class="nav child_menu">
                     <li><a  href="purchasetome.php" ><i class="fa fa-server"></i> Top-up My Account<span class="fa fa-chevron-right"></span></a> </li>
					   </ul>
				  </li>
				   <li><a><i class="fa fa-bar-chart-o"></i> History <span class="fa fa-chevron-down"></span></a>  
				      <!--  <ul class="nav side-menu"> -->
					   <ul class="nav child_menu">
					    <li><a  href="creditassignment.php" ><i class="fa fa-bars"></i>Credit Assignment<span class="fa fa-chevron-right"></span></a> </li>
						
					   </ul>
				   </li>
                </ul>
              </div>

            </div>
			 </div>
        </div>
		
		<?php
        include("topmenubar.php");

         ?>
		 
		 
		 <!-- page content -->
        <div class="right_col" role="main">
		  <!-- /top navigation -->
		     <div class="row">
          <!-- top tiles -->
          <div class="row tile_count">
            <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
              <p>  </p>
            </div>
            
          </div>
		  </div>
          <!-- /top tiles -->
		 
			 <div class="page-title">
              <div class="title_left" style="margin-left:0px;">
                <h3> Manage Your Groups </h3> </div>
				
            </div>	
				<a href="creategroup.php">  <button class="btn btn-primary pull-left" > Create Group </button> </a>	
              <br/>				
             <hr/>
			 <div class="row">
			 
			 
			  <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Groups List  </h2>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    
                 <table id="datatable-buttons" class="table table-striped table-bordered">
                      <thead>
                        <tr>
						
                          <th>Group Name</th>
                          <th>No. of Contacts</th>
						  <th>Actions</th>
                        </tr>
                      </thead>
                      <tbody>
					  <?php 
						$i = mysqli_query($con,"select * from airtime_groups where customer_id  = '$session_id'") or die (mysqli_error());
						while ($u = mysqli_fetch_array($i))
						{
							$idss = $u['group_id'];
							$names = $u['name'];
							$cs = $u['customer_id'];
							$n = mysqli_query($con,"select * from airtime_contacts where group_id = '$idss' and customer_id = '$cs'") or die (mysqli_error());
							$nums = mysqli_num_rows($n);
						
					  ?>
                        <td><?php echo $names ?></td>
                        <td><?php  echo $nums ?> &nbsp;&nbsp;
						   <a rel="tooltip" title="View Contacts"  href="selectedgrp.php?g_id=<?php echo $idss ?>" ><i class='fa fa-eye fa-lg'></i>  </a>
						    <!-- view contacts model -->
                             <?php include('groupcontacts.php'); ?>
						</td>
						
                        <td>  
								<a rel="tooltip" title="Edit Group" id="<?php echo $idss ?>" href="#edit<?php echo $idss ?>" data-toggle="modal" >
								<i class='fa fa-edit fa-lg'></i> </a> 
					     <?php include('edit_group.php'); ?>
						 <a rel="tooltip" title="Delete Group" id="<?php echo $idss  ?>" href="#delete<?php echo $idss  ?>" data-toggle="modal" >
								<i class='fa fa-trash'></i> </a> 
					     <?php include('delete_group.php'); ?>
					                   
						</td>
						
						
                     <!---   -->
                      </tbody>
					  <?php } ?>
                    </table>
                  </div>
                </div>
              </div>
			  
			  
			   <!--- table ends here -->
            </div>
		  
		 <?php // include("groups.php"); ?>
		  
		  
		  
		  
		  
		  
		  </div>
		  
		  
		          <!-- /page content. End of main -->

     <?php include("footerlinks.php"); ?>

		  
		   <script src="vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="vendors/nprogress/nprogress.js"></script>
    <!-- Chart.js -->
    <script src="vendors/Chart.js/dist/Chart.min.js"></script>
    <!-- gauge.js -->
    <script src="vendors/bernii/gauge.js/dist/gauge.min.js"></script>
    <!-- bootstrap-progressbar -->
    <script src="vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
    <!-- iCheck -->
    <script src="vendors/iCheck/icheck.min.js"></script>
    <!-- Skycons -->
    <script src="vendors/skycons/skycons.js"></script>
    <!-- Flot -->
    <script src="vendors/Flot/jquery.flot.js"></script>
    <script src="vendors/Flot/jquery.flot.pie.js"></script>
    <script src="vendors/Flot/jquery.flot.time.js"></script>
    <script src="vendors/Flot/jquery.flot.stack.js"></script>
    <script src="vendors/Flot/jquery.flot.resize.js"></script>
    <!-- Flot plugins -->
    <script src="js/flot/jquery.flot.orderBars.js"></script>
    <script src="js/flot/date.js"></script>
    <script src="js/flot/jquery.flot.spline.js"></script>
    <script src="js/flot/curvedLines.js"></script>
    <!-- jVectorMap -->
    <script src="js/maps/jquery-jvectormap-2.0.3.min.js"></script>
    <!-- bootstrap-daterangepicker -->
    <script src="js/moment/moment.min.js"></script>
    <script src="js/datepicker/daterangepicker.js"></script>
	
		    <!-- Datatables -->
    <script src="vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="vendors/datatables.net-scroller/js/datatables.scroller.min.js"></script>
    <script src="vendors/jszip/dist/jszip.min.js"></script>
    <script src="vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="vendors/pdfmake/build/vfs_fonts.js"></script>

    <!-- Custom Theme Scripts -->
    <!--script src="js/custom.js"></script-->

    <!-- Datatables -->
    <script>
      $(document).ready(function() {
        var handleDataTableButtons = function() {
          if ($("#datatable-buttons").length) {
            $("#datatable-buttons").DataTable({
              dom: "Bfrtip",
              buttons: [
               
                {
                  extend: "print",
                  className: "btn-sm"
                },
              ],
              responsive: true
            });
          }
        };

        TableManageButtons = function() {
          "use strict";
          return {
            init: function() {
              handleDataTableButtons();
            }
          };
        }();

        $('#datatable').dataTable();
        $('#datatable-keytable').DataTable({
          keys: true
        });

        $('#datatable-responsive').DataTable();

        $('#datatable-scroller').DataTable({
          ajax: "js/datatables/json/scroller-demo.json",
          deferRender: true,
          scrollY: 380,
          scrollCollapse: true,
          scroller: true
        });

        var table = $('#datatable-fixed-header').DataTable({
          fixedHeader: true
        });

        TableManageButtons.init();
      });
    </script>
    <!-- /Datatables -->

	</body>
</html>	
	