<?php  
if($_SESSION['role']!=1){ 
exit("You dont have permisiion to access this page ");}
?>
 <div>
    <ul class="breadcrumb">
        <li>
            <a href="index.php">Home</a>
        </li>
        <li>
            <a href="index.php?page=affiliates"> Add af</a>
        </li>
    </ul>
</div>

<div class="row">
        <div class="box col-md-12">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <h2><i class=" glyphicon glyphicon-th-list"></i> af</h2>

                    <div class="box-icon">
                        <a href="#" class="btn btn-setting btn-round btn-default"><i
                                class="glyphicon glyphicon-cog"></i></a>
                        <a href="#" class="btn btn-minimize btn-round btn-default"><i
                                class="glyphicon glyphicon-chevron-up"></i></a>
                        <a href="#" class="btn btn-close btn-round btn-default"><i
                                class="glyphicon glyphicon-remove"></i></a>
                    </div>
                </div>
                <div class="box-content">
                
                <br />

                
              
                 
                  <?php  
				 if($_REQUEST['opt']==do_up){
					if($_REQUEST['affiliates_name']==''
 
	){
		
		echo("<div style='color:red'> Please Fill All Parameters </div>");
		}else{
 

 $affiliates_query="update affiliates
set 
affiliates_name='".post($connect,$_REQUEST['affiliates_name'])."'
 
 where affiliates_id='".post($connect,$_REQUEST['id'])."'
 
 
 ";
 
 
 
 $situation=mysqli_query($connect,$affiliates_query);
 if($situation){ echo("<div>af Added SucessFully</div>");}
}}
				 ?>
                 
                 
                
                 
                 
                 
                 
                 <?php  
				 if($_REQUEST['opt']==up){
					 
					 $affiliates_q="select * from affiliates where affiliates_id=".post($connect,$_REQUEST['id']);
					$affiliates_res=mysqli_query($connect,$affiliates_q);
					if($affiliates_res){
						$affiliates_row=mysqli_fetch_assoc($affiliates_res);
					
					 }
				 ?>
                 
                         
                   
                  <fieldset>
<legend>Update  service</legend>      
                   
                 
                 
                 <form method="post"  class="login_form" >
<input type="hidden" name="opt" value="do_up" />
<input type="hidden" name="id" value="<?php echo($affiliates_row['affiliates_id']); ?>" />
<div class="form-group">
<div class="row ">
<div class="col-md-5">Service Name </div>
<div class="col-md-4"><input type="text" name="affiliates_name" id="affiliates_name" class="form-control" placeholder="affiliates_name" value="<?php echo($affiliates_row['affiliates_name']); ?>" /></div>
</div>
</div>



 

<div class="form-group">
<div class="row ">

<div class="col-md-12"><input type="submit" name="update_affiliates" value="update affiliates" class="action-button"  style="width:120px"/></div>
</div>
</div>

</form>
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
              


                       <br>
<br>
<br>
<br>






<br>
<br>   
                 
                 
                 
                 
              </fieldset>   
                 
                 
                 
                  <?php  
				 	}
				 ?>
                 
                 
                 
                
                 <!-----      end update affiliates       -->
                 
                
               <!-----       add affiliates       -->
                
                <?php 
				
			if($_REQUEST['opt']==do_add)
{
	
	if($_REQUEST['affiliates_name']==''
 
	){
		
		echo("<div style='color:red'> Please Fill All Parameters </div>");
		}else{
 

 $affiliates_query="insert into affiliates
set 
affiliates_name='".post($connect,$_REQUEST['affiliates_name'])."'
 ";
 
 
 
 $situation=mysqli_query($connect,$affiliates_query);
 if($situation){ echo("<div>affiliates Added SucessFully</div>");}
}}
			
			
			
				 ?>
                
                
                
                   <?php 
				   if($_REQUEST['opt']==add)
				   { 
				   ?>
                   
                   
                   
                   
                   
                   
                  <fieldset>
<legend>Add New service</legend>      
                   
                   
                   
                   
                   
                   
                   
                       <form method="post"  class="login_form" >
<input type="hidden" name="opt" value="do_add" />
<div class="form-group">
<div class="row ">
<div class="col-md-5">Service Name </div>
<div class="col-md-4"><input type="text" name="affiliates_name" id="affiliates_name" class="form-control" placeholder="affiliates_name" /></div>
</div>
</div>


 

<div class="form-group">
<div class="row ">

<div class="col-md-12"><input type="submit" name="Add_affiliates" value="Add affiliates" class="action-button"  style="width:120px"/></div>
</div>
</div>

</form>







    </fieldset>












                       <br>
<br>
<br>
<br>






<br>
<br>

 <!-----      end  add affiliates       -->
                       
                       <?php } ?>
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                      
                  <fieldset>
<legend>Search</legend>
                       
                       
                       <form method="post"  class="login_form"  action="index.php?page=affiliates">
<input type="hidden" name="optsearch" value="1" />
 
<div class="form-group">
<div class="row ">
<div class="col-md-5">Name</div>
<div class="col-md-4"><input type="text" name="affiliates_nameSearch" id="affiliates_nameSearch" class="form-control" placeholder="affiliates_name" value="<?php echo($_REQUEST['affiliates_nameSearch']); ?>" /></div>
</div>
</div>

 
  

<div class="form-group">
<div class="row ">

<div class="col-md-12"><input type="submit" name="update_affiliates" value="Search affiliates" class="action-button"  style="width:120px"/></div>
</div>
</div>

</form>
                       
                       
                       
                       
                      
            </fieldset>           
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       <div class="row">
                       <div class="col-md-12">
                         <a href="index.php?page=affiliates&opt=add" ><i class="glyphicon glyphicon-plus icon-white"></i> Add new affiliates</a><br>

                         <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                                         
                         
                         
                           <tr>
                             <td>Service name </td>
                             <td align="center" valign="middle">update </td>
                           </tr>
                           <?php  
						   
						
			 
			 $query_affiliates="select * from affiliates
 
where 1=1

" ; 
if($_REQUEST['affiliates_nameSearch']!=''){
	$query_affiliates=$query_affiliates." and affiliates_name like '%".$_REQUEST['affiliates_nameSearch']."%'";
	 
	}
	
	
 
		 
			 $affiliates_res=mysqli_query($connect,$query_affiliates);
			
			 if($affiliates_res){
				 while($row=mysqli_fetch_assoc($affiliates_res))
				 {
				
			  ?>
						
                           <tr>
                             <td><?php echo($row['affiliates_name']); ?></td>
                             <td align="center" valign="middle"><a href="index.php?page=affiliates&opt=up&id=<?php  echo($row['affiliates_id']); ?>"  > 
                              <i class="glyphicon glyphicon-edit icon-white"></i> Update</a>
                              
                              <?php //  <i class="glyphicon glyphicon-trash icon-white"></i> Delete
                               ?>
                               
                               </a>
                              </td>
                           </tr>
                           
                           
                           <?php  }}?>
                        
                  </table>
                  <br />


                 
                  </div></div>
                   
                </div>
            </div>
        </div>