 <?php  if(priv($_SESSION['role'],'view','Services',$connect)!=1){exit(); }?>
 <div>
    <ul class="breadcrumb">
        <li>
            <a href="index.php">Home</a>
        </li>
        <li>
            <a href="index.php?page=Services"> Add Services</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> Services</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(priv($_SESSION['role'],'up','Services',$connect)==1)
				 if($_REQUEST['opt']==do_up){
					if($_REQUEST['Services_name']==''
 
	){
		
		echo("<div style='color:red'> Please Fill All Parameters </div>");
		}else{
 

 $Services_query="update services
set 
Services_name='".post($connect,$_REQUEST['Services_name'])."'
 ,compnayId='".post($connect,$_REQUEST['compnayId'])."'
 where Services_id='".post($connect,$_REQUEST['id'])."'
 
 
 ";
 
 
 
 $situation=mysqli_query($connect,$Services_query);
 if($situation){ echo("<div>Services Added SucessFully</div>");}
}
go("index.php?page=Services");
}
				 ?>
                 
                 
                
                 
                 
                 
                 
                 <?php  
				  if(priv($_SESSION['role'],'up','Services',$connect)==1)
				 if($_REQUEST['opt']==up){
					 
					 $Services_q="select * from services where Services_id=".post($connect,$_REQUEST['id']);
					$Services_res=mysqli_query($connect,$Services_q);
					if($Services_res){
						$Services_row=mysqli_fetch_assoc($Services_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($Services_row['Services_id']); ?>" />
<div class="form-group">
<div class="row ">
<div class="col-md-2">Service Name </div>
<div class="col-md-4"><input type="text" name="Services_name" id="Services_name" class="form-control" placeholder="Services_name" value="<?php echo($Services_row['Services_name']); ?>" /></div>
<div class="col-md-2">Compnay </div>
<div class="col-md-4"><?php  Select("compnayId",$connect,"Please Select Company"," select * from Company",$Services_row['compnayId']); ?></div>

</div>
</div>



 

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

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

</form>
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
              


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






<br>
<br>   
                 
                 
                 
                 
              </fieldset>   
                 
                 
                 
                  <?php  
				 	}
				 ?>
                 
                 
                 
                
                 <!-----      end update Services       -->
                 
                
               <!-----       add Services       -->
                
                <?php 
				 if(priv($_SESSION['role'],'add','Services',$connect)==1)
			if($_REQUEST['opt']==do_add)
{
	
	if($_REQUEST['Services_name']==''
 
	){
		
		echo("<div style='color:red'> Please Fill All Parameters </div>");
		}else{
 

 $Services_query="insert into services
set 
Services_name='".post($connect,$_REQUEST['Services_name'])."'
 ,compnayId='".post($connect,$_REQUEST['compnayId'])."'
 ";
 
 
 
 $situation=mysqli_query($connect,$Services_query);
 if($situation){ echo("<div>Services Added SucessFully</div>");}
}

go("index.php?page=Services");

}
			
			
			
				 ?>
                
                
                
                   <?php 
				    if(priv($_SESSION['role'],'add','Services',$connect)==1)
				   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-2">Service Name </div>
<div class="col-md-4"><input type="text" name="Services_name" id="Services_name" class="form-control" placeholder="Services_name" /></div>

<div class="col-md-2">Compnay </div>
<div class="col-md-4"><?php  Select("compnayId",$connect,"Please Select Company"," select * from Company",$rowProjects['compnayId']); ?></div>


</div>
</div>


 

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

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

</form>







    </fieldset>












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






<br>
<br>

 <!-----      end  add Services       -->
                       
                       <?php } ?>
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                      
                  <fieldset>
<legend>Search</legend>
                       
                       
                       <form method="post"  class="login_form"  action="index.php?page=Services">
<input type="hidden" name="optsearch" value="1" />
 
<div class="form-group">
<div class="row ">
<div class="col-md-2">Name</div>
<div class="col-md-4"><input type="text" name="Services_nameSearch" id="Services_nameSearch" class="form-control" placeholder="Services_name" value="<?php echo($_REQUEST['Services_nameSearch']); ?>" /></div>
<div class="col-md-2">Compnay </div>
<div class="col-md-4"><?php  Select("compnayId",$connect,"Please Select Company"," select * from Company",$rowProjects['compnayId']); ?></div>


</div>
</div>

 
  

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

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

</form>
                       
                       
                       
                       
                      
            </fieldset>           
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       
                       <div class="row">
                       <div class="col-md-12">
                         <?php  if(priv($_SESSION['role'],'add','Services',$connect)==1){?>
                         <a href="index.php?page=Services&opt=add" ><i class="glyphicon glyphicon-plus icon-white"></i> Add new Services</a><br>
<?php  }  ?>
                         <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>Company</td>
                             <td align="center" valign="middle">update </td>
                           </tr>
                           <?php  
						   
						
			 
			 $query_Services="select * from services
 inner join Company on Company_id=compnayId
where 1=1

" ; 
if($_REQUEST['Services_nameSearch']!=''){
	$query_Services=$query_Services." and Services_name like '%".$_REQUEST['Services_nameSearch']."%'";
	 
	}
	
	if($_REQUEST['compnayId']!=0){
	$query_Services=$query_Services." and compnayId like '%".$_REQUEST['Services_nameSearch']."%'";
	 
	}
 
		 
			 $Services_res=mysqli_query($connect,$query_Services);
			
			 if($Services_res){
				 while($row=mysqli_fetch_assoc($Services_res))
				 {
				
			  ?>
						
                           <tr>
                             <td><?php echo($row['Services_name']); ?></td>
                             <td><?php echo($row['Company_name']); ?></td>
                             <td align="center" valign="middle">
                              <?php  if(priv($_SESSION['role'],'up','Services',$connect)==1){?>
                             <a href="index.php?page=Services&opt=up&id=<?php  echo($row['Services_id']); ?>"  > 
                              <i class="glyphicon glyphicon-edit icon-white"></i> Update</a>
                              
                              <?php //  <i class="glyphicon glyphicon-trash icon-white"></i> Delete
                               ?>
                               
                               </a> <?php } ?>
                              </td>
                           </tr>
                           
                           
                           <?php  }}?>
                        
                  </table>
                  <br />


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