

  <div class="page-title">
              <div class="title_left" style="margin-left:0px;">
                <h3> Find All Your Contacts </h3> </div>
            </div>
            <div class="row">
			
   <!---- table starts here -->
   
       
	<a href="viewcontacts.php">  <button class=" pull-left " style="margin-left:20px;" ><i class="fa fa-th"> </i> </button> </a>
	     <button class="btn btn-primary pull-right" data-toggle="modal" data-target="#myModal" > Add New Contacts </button> 
	<!-- Modal -->

               <!-- add contact form -->
			  <?php include("addcontactsform.php"); ?>
			 
	
	     

    <!-- edd contact form model -->
	
			<!-- <a href="" class="btn btn-primary"> Add New Contacts </a> </div>   -->

              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2> My Contacts List </h2>
                    
                     <div class="dropdown pull-right">
                        <a class="btn btn-danger btn-sm" href="delete_my_contacts.php" onClick="return confirm('Are you sure you want to delete all your Contacts?');"><i class="fa fa-trash"></i> Delete All Contacts</a>
						<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/contactsreport.php">Export PDF</a></li>
								<li><a href="excelreports/excelcontacts.php"> Export Excel</a></li>
								<li><a href="excel/contactscsv.php"> Export CSV</a></li>
							</ul>
					</div>
					
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
	
                    
                    <table id="datatable-buttons" class="table table-striped table-bordered">
                      <thead>
                        <tr>
                          <th>Name</th>
                          <th>Contact</th>
                          <th>Group</th>
                          <th>Actions</th>
                        </tr>
                      </thead>
                      <tbody>
                      <?php
					  //get number of contacts
					  $row=mysql_fetch_array(mysql_query("select count(*) as number_of_contacts from airtime_contacts where customer_id='$session_id'"));
					  $number_of_contacts=$row['number_of_contacts'];
					  //set page size
					  $page_size=100;
					  //create page links using zebra pagination
					  require_once 'Zebra_Pagination.php';
					  $pagination= new Zebra_Pagination();
					  $pagination->records_per_page($page_size);
					  $pagination->records($number_of_contacts);
					  
					  $offset=($pagination->get_page() - 1) * $page_size;
					  $sql = "select c.contact_id,c.fname,c.contact,g.name as group_name from airtime_contacts c left join airtime_groups g on c.group_id = g.group_id";
					  $sql .= " ";
					  $sql .= "where c.customer_id = '$session_id' order by c.fname limit $offset,$page_size";
					  $result = mysql_query($sql);
					   while($row = mysql_fetch_array($result)) {
						   $id= $row['contact_id'];
						   $Fname = $row['fname'];
						   $pne = $row['contact'];
						   $em = $row['email'];
						   $grp = $gname = is_null($row['group_name']) ? 'Not Allocated' : $row['group_name'];
                       echo "<tr>";
				        echo '<td> <b>' . $row['fname'] . '</b></td>';
                        echo '<td> <b>' . $row['contact'] . '</b></td>';
				       echo '<td> <b style="color:green;">' .$grp. '</b></td>';
					   ?>
					   <td>  
						<a rel="tooltip" title="Edit Contact" id="<?php echo $id ?>" href="#editcontact<?php echo $id ?>" data-toggle="modal"  >
								<i class='fa fa-edit'></i> </a> 
					     <?php include('edit_contact.php'); ?>
						 <a rel="tooltip" title="Delete Contact" id="<?php echo $id ?>" href="#deletecontact<?php echo $id ?>" data-toggle="modal">
								<i class='fa fa-trash'></i> </a> 
					     <?php include('delete_contact.php'); ?>
					                   
						</td>
					   <?php
				
				       }  
                       echo "</table>";
					  
					  ?>  
                       
                       
                        
                      </tbody>
                    </table>
                    <div>
                    <?php $pagination->render(); ?> 
                    </div>
                  </div>
                </div>
              </div>
			   
			   <!--- table ends here -->
            </div>
          
        <!-- /page content -->

      
     
