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

  <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><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>
				  </li>
                  <li ><a><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><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><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 class="active"><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>
	
          <!-- /top tiles -->
		 
		  <div class="x_title">
                    <h2> <b>Topup History: Detailed Summary </b> </h2>
                    <div class="clearfix"></div>
                  </div>
		 
				 <h2>
					  <a href="creditassignment.php"> <button type="submit" class="btn btn-success " name="sendairtime">Back To Credit Assignment History </button> </a> 
					</h2>
					
				<div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
					<div class="x_title">
                   <form method="POST" data-parsley-validate class="form-horizontal form-label-left" style="font-size: 14px;" action="">
					
						Sort By: <b style="padding:10px;"> Dates: &nbsp; From: &nbsp;&nbsp; <input type="date" name="frm" /> &nbsp;&nbsp; To: <input type="date" name="to"/> </b> <br/>
					             <br/><b style="margin-left:110px;"> Group:  &nbsp;&nbsp;  <select name="grp" style="padding:5px;" >
						                             <option value="">--Select Group--</option>
                                                         <?php 
						                                    $grps = mysql_query("select * from airtime_groups where customer_id = '$session_id' order by group_id ");
	                                                          while($record = mysql_fetch_array($grps)){
		                                                           echo '<option value="'.$record['group_id'].'">'.$record['name'].'</option>';
	                                                             }
						                                ?>   
                                                 </select>
						                      </b>  <br/>
					         <br/> <b style="margin-left:100px;"> Contact:  &nbsp;&nbsp; <input type="text" name="phone" placeholder="Phone Number" />  </b> <br/>
					            
					           <br/> <button style="margin-left:200px;" type="submit" class="btn btn-primary" name="getreports">Generate Report </button> 
				   </form>
					
						<div class="clearfix"></div>
					</div>
					
					<?php
						
						if(isset($_POST['getreports'])){
							
							$frm = $_POST['frm'];
							$to = $_POST['to'];
							$grp = $_POST['grp'];
							$phne = $_POST['phone'];
							$check = 0;
							
							if(  !empty($grp) || $grp != "--Select Group--" && empty($frm) && empty($to) && empty($phne)  ){
								$gid = $_POST['grp'];
								$check = 1;
								
									$s2 = mysql_query("select * from airtime_groups where group_id = '$gid' ");
									$rw = mysql_fetch_array($s2);
									$nme = $rw['name'];
								$num = 0;
								$s = mysql_query("select airtime_sending_records.r_id, airtime_sending_records.airtime_sent, airtime_sending_records.recipient, airtime_sending_records.date_sent, airtime_sending_records.status, airtime_contacts.fname, airtime_contacts.contact, airtime_groups.name from airtime_sending_records inner join airtime_contacts on airtime_sending_records.recipient = airtime_contacts.contact inner join airtime_groups on airtime_contacts.group_id = airtime_groups.group_id where airtime_sending_records.customer_id = '$session_id' and airtime_contacts.group_id = '$gid' ");
								
									if(mysql_num_rows($s) > 0 ){
										$stat = "";
										?>
									<div class="x_title">	
										<h2 style="font-weight: bold;"><span><b style="color: #f49e42;">Airtime Sent To <?php echo $rw['name']; ?> Group </b></span></h2>
										<div class="dropdown pull-right">
											<button class="btn btn-default dropdown-toggle " type="button" data-toggle="dropdown">Tools <span class="caret"></span></button>
											<ul class="dropdown-menu">
												<li class="active"><a target="_blank" href="pdf/groupreport.php?id=<?php echo $gid; ?>&nm=<?php echo $nme; ?>">Export PDF</a></li>
												<li ><a href="excelreports/groupreport.php?id=<?php echo $gid; ?>&nm=<?php echo $nme; ?>" title="Export to Excel" >Export Excel</a></li>
											
											</ul>
										</div>
										<div class="clearfix"></div>
									</div>
                                 
									<div class="x_content">
										<table id="datatable" class="table table-striped table-bordered" >
											<thead>
												<tr>
												   <th>No.</th>
													<th>Name</th>
													<th>Contact</th>
													<th>Airtime Sent</th>
													<th>Date Sent</th>
													<th>Status</th>
													<th>Action</th>
												</tr>
											</thead>
										<tbody>
										<?php
										while($dt=mysql_fetch_array($s)){
											$id=$dt['r_id'];
											$num++;
											
											if($dt['status'] == 1){
												$stat = "Success";
											}else{
												$stat = "Failed";
											}
										
											echo "<tr>";
											echo '<td>'.$num. '</td>';	
											echo '<td>'.$dt['fname'].'</td>';
											echo '<td>'.$dt['recipient']. '</td>';
											echo '<td>'.$dt['airtime_sent']. '</td>';
											echo '<td>'.$dt['date_sent']. '</td>';
											echo '<td>'.$stat. '</td>';	
											?>
											<td>
												<a rel="tooltip" title="Delete Record" id="<?php echo $id  ?>" href="#deletedata<?php echo $id  ?>" data-toggle="modal" > <i class='fa fa-trash'></i> </a> 
												<?php include('delete_record.php'); ?>
											</td>
											<?php
											}
									
										?>
											</tbody>
										</table>
									</div>
										<?php
									}else{
										echo '<b style="font-weight: bold; font-size: 20px; color: #f49e42;"> Oooops! No Records Found. </b>';
									}
							
							}
							elseif( !empty($phne) && empty($frm) && empty($to) && empty($grp) || $grp == "--Select Group--"  ){
								$phne = $_POST['phone'];
								$num = 0;
								
								$getmemberrecords = mysql_query("select * from airtime_sending_records where recipient = '$phne' order by date_sent DESC ");
								if(mysql_num_rows($getmemberrecords) > 0){
										$stat = "";
										
									$mdata = mysql_query("select * from airtime_contacts where customer_id = '$session_id' and contact = '$phne' ");
									$rwdt = mysql_fetch_array($mdata);
											?>
									<div class="x_title">	
										<h2 style="font-weight: bold;"><span><b style="color: #f49e42;">Airtime Sent To <?php echo $rwdt['fname']." - ".$phne; ?>  </b></span></h2>
										<div class="dropdown pull-right">
											<button class="btn btn-default dropdown-toggle " type="button" data-toggle="dropdown">Tools <span class="caret"></span></button>
											<ul class="dropdown-menu">
												<li class="active"><a target="_blank" href="pdf/user_report.php?no=<?php echo $phne; ?>&nm=<?php echo $rwdt['fname']; ?>">Export PDF</a></li>
												<li ><a href="excelreports/user_report.php?no=<?php echo $phne; ?>&nm=<?php echo $rwdt['fname']; ?>" title="Export to Excel" >Export Excel</a></li>
											</ul>
										</div>
										<div class="clearfix"></div>
									</div>
                                 
									<div class="x_content">
										<table id="datatable" class="table table-striped table-bordered" >
											<thead>
												<tr>
												   <th>No.</th>
												   <th>Date</th>
													<th>Airtime Sent</th>
													<th>Status</th>
													<th>Action</th>
												</tr>
											</thead>
										<tbody>
										<?php
										while($dt=mysql_fetch_array($getmemberrecords)){
										$id=$dt['r_id'];
										$num++;
											
										if($dt['status'] == 1){
											$stat = "Success";
										}else{
											$stat = "Failed";
										}	
										
										
											echo "<tr>";
											echo '<td>'.$num. '</td>';	
											echo '<td>'.$dt['date_sent']. '</td>';
											echo '<td>'.$dt['airtime_sent']. '</td>';
											echo '<td>'.$stat. '</td>';	
											?>
											<td>
												<a rel="tooltip" title="Delete Record" id="<?php echo $id  ?>" href="#deletedata<?php echo $id  ?>" data-toggle="modal" > <i class='fa fa-trash'></i> </a> 
												<?php include('delete_record.php'); ?>
											</td>
											<?php
										}
										?>
										</tbody>
										</table>
									</div>
								<?php
								}else{
									echo '<b style="font-weight: bold; font-size: 20px; color: #f49e42;"> Oooops! No Records Found. </b>';
								}
							}
							elseif( !empty($frm) && !empty($to) && empty($phne) && empty($grp) || $grp == "--Select Group--"  ){
								
									$frm = $_POST['frm'];
									$to = $_POST['to'];
									// echo $frm." - ".$to;
								$num = 0;
								$s = mysql_query("select airtime_sending_records.*, airtime_contacts.fname, airtime_contacts.contact, airtime_contacts.group_id, airtime_groups.name from airtime_sending_records inner join airtime_contacts on airtime_sending_records.recipient = airtime_contacts.contact inner join airtime_groups on airtime_contacts.group_id = airtime_groups.group_id where airtime_sending_records.customer_id = '$session_id' and ( airtime_sending_records.date_sent BETWEEN CAST('$frm' AS DATE) and CAST('$to' AS DATE) ) ");
									
								if(mysql_num_rows($s) > 0){
											?>
									<div class="x_title">	
										<h2 style="font-weight: bold;"><span><b style="color: #f49e42;">Airtime Sent Between <?php echo $frm." and ".$to; ?> </b></span></h2>
										<div class="dropdown pull-right">
											<button class="btn btn-default dropdown-toggle " type="button" data-toggle="dropdown">Tools <span class="caret"></span></button>
											<ul class="dropdown-menu">
												<li class="active"><a target="_blank" href="pdf/datedreport.php?fr=<?php echo $frm; ?>&to=<?php echo $to; ?>">Export PDF</a></li>
												<li ><a  href="excelreports/datedreport.php?fr=<?php echo $frm; ?>&to=<?php echo $to; ?>" title="Export to Excel" >Export Excel</a></li>
										
											</ul>
										</div>
										<div class="clearfix"></div>
									</div>
                                 
									<div class="x_content">
										<table id="datatable" class="table table-striped table-bordered" >
											<thead>
												<tr>
												   <th>No.</th>
													<th>Name</th>
													<th>Contact</th>
													<th>Group</th>
													<th>Airtime Sent</th>
													<th>Date Sent</th>
													<th>Status</th>
													<th>Action</th>
												</tr>
											</thead>
										<tbody>
										<?php
										while($dt=mysql_fetch_array($s)){
											$id = $dt['r_id'];
											$num++;
											
											if($dt['status'] == 1){
												$stat = "Success";
											}else{
												$stat = "Failed";
											}
										
											echo "<tr>";
											echo '<td>'.$num. '</td>';	
											echo '<td>'.$dt['fname'].'</td>';
											echo '<td>'.$dt['recipient']. '</td>';
											echo '<td>'.$dt['name']. '</td>';
											echo '<td>'.$dt['airtime_sent']. '</td>';
											echo '<td>'.$dt['date_sent']. '</td>';
											echo '<td>'.$stat. '</td>';	
											?>
											<td>
												<a rel="tooltip" title="Delete Record" id="<?php echo $id  ?>" href="#deletedata<?php echo $id  ?>" data-toggle="modal" > <i class='fa fa-trash'></i> </a> 
												<?php include('delete_record.php'); ?>
											</td>
											<?php
											}
									
										?>
											</tbody>
										</table>
									</div>
										<?php
								}else{
									echo '<b style="font-weight: bold; font-size: 20px; color: #f49e42;"> Oooops! No Records Found. </b>';
								}
								
							}
							elseif( !empty($frm) && !empty($to) && !empty($phne) && empty($grp) || $grp == "--Select Group--"  ){
									$frm = $_POST['frm'];
									$to = $_POST['to'];
									$phne = $_POST['phone'];
									$num = 0;
										
								$getrecordsx = mysql_query("select * from airtime_sending_records where customer_id = '$session_id' and (date_sent BETWEEN CAST('$frm' AS DATE) and CAST('$to' AS DATE) ) and recipient = '$phne' ");
								if(mysql_num_rows($getrecordsx) > 0){
										$stat = "";
										
									$mdatax = mysql_query("select * from airtime_contacts where customer_id = '$session_id' and contact = '$phne' ");
									$rwd = mysql_fetch_array($mdatax);	
									?>
									<div class="x_title">	
										<h2 style="font-weight: bold;"><span><b style="color: #f49e42;">Airtime Sent To <?php echo $rwd['fname']." - ".$phne."  :"." "." Between ".$frm." and ".$to; ?>  </b></span></h2>
										<div class="dropdown pull-right">
											<button class="btn btn-default dropdown-toggle " type="button" data-toggle="dropdown">Tools <span class="caret"></span></button>
											<ul class="dropdown-menu">
												<li class="active"><a target="_blank" href="pdf/user_dated_report.php?no=<?php echo $phne; ?>&nm=<?php echo $rwd['fname']; ?>&fr=<?php echo $frm; ?>&to=<?php echo $to; ?>">Export PDF</a></li>
												<li ><a href="excelreports/user_dated_report.php?no=<?php echo $phne; ?>&nm=<?php echo $rwd['fname']; ?>&fr=<?php echo $frm; ?>&to=<?php echo $to; ?>" title="Export to Excel" >Export Excel</a></li>
											</ul>
										</div>
										<div class="clearfix"></div>
									</div>
                                 
									<div class="x_content">
										<table id="datatable" class="table table-striped table-bordered" >
											<thead>
												<tr>
												   <th>No.</th>
												   <th>Date</th>
													<th>Airtime Sent</th>
													<th>Status</th>
													<th>Action</th>
												</tr>
											</thead>
										<tbody>
										<?php
										while($dt=mysql_fetch_array($getrecordsx)){
										$id=$dt['r_id'];
										$num++;
											
										if($dt['status'] == 1){
											$stat = "Success";
										}else{
											$stat = "Failed";
										}	
										
										
											echo "<tr>";
											echo '<td>'.$num. '</td>';	
											echo '<td>'.$dt['date_sent']. '</td>';
											echo '<td>'.$dt['airtime_sent']. '</td>';
											echo '<td>'.$stat. '</td>';	
											?>
											<td>
												<a rel="tooltip" title="Delete Record" id="<?php echo $id  ?>" href="#deletedata<?php echo $id  ?>" data-toggle="modal" > <i class='fa fa-trash'></i> </a> 
												<?php include('delete_record.php'); ?>
											</td>
											<?php
										}
										?>
										</tbody>
										</table>
									</div>
									
									<?php
								}else{
									echo '<b style="font-weight: bold; font-size: 20px; color: #f49e42;"> Oooops! No Records Found. </b>';
								}
								
							}
							elseif( !empty($grp) || $grp != "--Select Group--" && !empty($frm) && !empty($to) && empty($phne) ){
								$frm = $_POST['frm'];
								$to = $_POST['to'];
								$gid = $_POST['grp'];
								
								$sxx = mysql_query("select * from airtime_groups where group_id = '$gid' ");
								$rwz = mysql_fetch_array($sxx);
								$num = 0;
								
								$sp = mysql_query("select airtime_sending_records.*, airtime_contacts.fname, airtime_contacts.contact, airtime_groups.name from airtime_sending_records inner join airtime_contacts on airtime_sending_records.recipient = airtime_contacts.contact inner join airtime_groups on airtime_contacts.group_id = airtime_groups.group_id where airtime_sending_records.customer_id = '$session_id' and ( airtime_sending_records.date_sent BETWEEN CAST('$frm' AS DATE) and CAST('$to' AS DATE) ) and airtime_contacts.group_id = '$gid' ");
								
									if(mysql_num_rows($sp) > 0 ){
										$stat = "";
										?>
									<div class="x_title">	
										<h2 style="font-weight: bold;"><span><b style="color: #f49e42;">Airtime Sent To <?php echo $rwz['name'].": Between ".$frm." and ".$to; ?></b></span></h2>
										<div class="dropdown pull-right">
											<button class="btn btn-default dropdown-toggle " type="button" data-toggle="dropdown">Tools <span class="caret"></span></button>
											<ul class="dropdown-menu">
												<li class="active"><a target="_blank" href="pdf/asreport.php">Export PDF</a></li>
												<li ><a href="excel/exporte.php" title="Export to Excel" >Export Excel</a></li>
												<li ><a href="excel/expcsv.php"> Export CSV</a></li>
											</ul>
										</div>
										<div class="clearfix"></div>
									</div>
                                 
									<div class="x_content">
										<table id="datatable" class="table table-striped table-bordered" >
											<thead>
												<tr>
												   <th>No.</th>
													<th>Name</th>
													<th>Contact</th>
													<th>Airtime Sent</th>
													<th>Date Sent</th>
													<th>Status</th>
													<th>Action</th>
												</tr>
											</thead>
										<tbody>
										<?php
										while($dt=mysql_fetch_array($sp)){
											$id=$dt['r_id'];
											$num++;
											
											if($dt['status'] == 1){
												$stat = "Success";
											}else{
												$stat = "Failed";
											}
										
											echo "<tr>";
											echo '<td>'.$num. '</td>';	
											echo '<td>'.$dt['fname'].'</td>';
											echo '<td>'.$dt['recipient']. '</td>';
											echo '<td>'.$dt['airtime_sent']. '</td>';
											echo '<td>'.$dt['date_sent']. '</td>';
											echo '<td>'.$stat. '</td>';	
											?>
											<td>
												<a rel="tooltip" title="Delete Record" id="<?php echo $id  ?>" href="#deletedata<?php echo $id  ?>" data-toggle="modal" > <i class='fa fa-trash'></i> </a> 
												<?php include('delete_record.php'); ?>
											</td>
											<?php
											}
									
										?>
											</tbody>
										</table>
									</div>
									<?php	
									}else{
										echo '<b style="font-weight: bold; font-size: 20px; color: #f49e42;"> Oooops! No Records Found. </b>';
									}
							}
							
							else{
							   echo '<b style="font-weight: bold; font-size: 20px; color: #f49e42;"> Sorry! Unknown Selection. Please try again. </b>';
							}
						 
						
						}else{
							?>
							<div class="x_title">	
								<h2 style="font-weight: bold;"><span><b style="color: #f49e42;">Condensed Account Top-up Summary </b></span></h2>
								<div class="dropdown pull-right">
									<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Tools <span class="caret"></span></button>
										<ul class="dropdown-menu">
											<li class="active"><a target="_blank" href="pdf/condensedreport.php">Export PDF</a></li>
											<li ><a href="excelreports/exportexcel.php"> Export Excel</a></li>
										</ul>
								</div>
								<div class="clearfix"></div>
							</div>
							
							 <div class="x_content">
								<table id="datatable" class="table table-striped table-bordered" >
									<thead>
										<tr>
											<th>No.</th>
											<th>Group</th>
											<th>Total No. of Contacts</th>
											<th>Total Airtime  Sent (Ksh.)</th>
										</tr>
									</thead>
								<tbody>
								<?php
									$num = 0;
								$getdata = mysql_query("select * from airtime_groups where customer_id = '$session_id' ");
									while($rw=mysql_fetch_array($getdata)){
										$gid = $rw['group_id'];
										
										$getconts = mysql_query("select * from airtime_contacts where group_id = '$gid' and customer_id = '$session_id' ");
										$numtotal = mysql_num_rows($getconts);
										$getrw=mysql_fetch_array($getconts);
											$phne = $getrw['contact'];
												$num++;
										
										$gettotal = mysql_query("select SUM(airtime_sent) AS value_sum from airtime_sending_records inner join airtime_contacts on airtime_sending_records.recipient = airtime_contacts.contact where airtime_contacts.group_id = '$gid' ");
											$row = mysql_fetch_array($gettotal); 
											$sum = $row['value_sum'];
											
											echo "<tr>";
											echo '<td>' .$num. '</td>';
											echo '<td>' .$rw['name']. '</td>';
											echo '<td>'.$numtotal. '</td>';
											echo '<td>' .$sum.'</td>';
									}
					  
								?>  
								</tbody>
							</table>
						</div>
							
							<?php
						}
					
					?>
				  
                </div>
				</div>
		  </div>
		  
		  </div>
		  
		  </div>
	</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>
	
	  <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>
	
	    <script src="vendors/select2/dist/js/select2.full.min.js"></script>
	   
	
		  <!-- Datatables -->
	 <script>
      $(document).ready(function() {
        var handleDataTableButtons = function() {
          if ($("#datatable-buttons").length) {
            $("#datatable-buttons").DataTable({
              dom: "Bfrtip",
              buttons: [
                {
                  extend: "copy",
                  className: "btn-sm"
                },
                {
                  extend: "csv",
                  className: "btn-sm"
                },
                {
                  extend: "excel",
                  className: "btn-sm"
                },
                {
                  extend: "pdfHtml5",
                  className: "btn-sm"
                },
                {
                  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>	
	
    <!-- Select2 -->
    <script>
      $(document).ready(function() {
        $(".select2_single").select2({
          placeholder: "Select a state",
          allowClear: true
        });
        $(".select2_group").select2({});
        $(".select2_multiple").select2({
       placeholder: "Chose Contacts to topup",
          allowClear: true
        });
      });
    </script> 
	</body>