 <?php  if(priv($_SESSION['role'],'view','servicesoperator',$connect)!=1){exit(); }?>
 <div>
    <ul class="breadcrumb">
        <li>
            <a href="index.php">Home</a>
        </li>
        <li>
            <a href="index.php?page=operatorServices"> 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 On Operators</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','servicesoperator',$connect)==1)
				 if($_REQUEST['opt']==do_up){
					if($_REQUEST['ServicesOperator_name']==''
	|| $_REQUEST['ServicesOperator_APIServiceID']==''
	|| $_REQUEST['ServicesOperator_APIpassword']==''
	|| $_REQUEST['ServicesOperator_ShortCode']==''
	|| $_REQUEST['Services_PushContentAPI']==0
	|| $_REQUEST['ServicesOperator_operatorID']==0
	){
		
		echo("<div style='color:red'> Please Fill All Parameters </div>");
		}else{
 

 $services_query="update servicesoperator
set 
ServicesOperator_name='".post($connect,$_REQUEST['ServicesOperator_name'])."',
ServicesOperator_APIServiceID='".post($connect,$_REQUEST['ServicesOperator_APIServiceID'])."',
ServicesOperator_APIpassword='".post($connect,$_REQUEST['ServicesOperator_APIpassword'])."', 
ServicesOperator_ShortCode='".post($connect,$_REQUEST['ServicesOperator_ShortCode'])."',
 ServicesOperator_pushContent='".post($connect,$_REQUEST['Services_PushContentAPI'])."',
 ServicesOperator_operatorID='".post($connect,$_REQUEST['ServicesOperator_operatorID'])."'
 ,ServicesOperator_servicesID='".post($connect,$_REQUEST['ServicesOperator_servicesID'])."'
  ,ServicesOperator_link='".post($connect,$_REQUEST['ServicesOperator_link'])."'
 where ServicesOperator_id='".post($connect,$_REQUEST['id'])."'
 
 
 ";
 //echo($services_query);
 
 
 $situation=mysqli_query($connect,$services_query);
 if($situation){ echo("<div>Services Added SucessFully</div>");}
}}
				 ?>
                 
                 
                
                 
                 
                 
                 
                 <?php  
				 if(priv($_SESSION['role'],'up','servicesoperator',$connect)==1)
				 if($_REQUEST['opt']==up){
					 
					 $Services_q="select * from servicesoperator where ServicesOperator_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['ServicesOperator_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="ServicesOperator_name" id="ServicesOperator_name" class="form-control" placeholder="ServicesOperator_name" value="<?php echo($Services_row['ServicesOperator_name']); ?>" /></div>
 
<div class="col-md-2">API ID</div>
<div class="col-md-4"><input type="text" name="ServicesOperator_APIServiceID" id="ServicesOperator_APIServiceID" class="form-control" placeholder="Services id" value="<?php echo($Services_row['ServicesOperator_APIServiceID']); ?>" /></div>
</div>
</div>

<div class="form-group">
<div class="row ">
<div class="col-md-2">API Password</div>
<div class="col-md-4"><input type="text" name="ServicesOperator_APIpassword" id="ServicesOperator_APIpassword" class="form-control" placeholder="Services Password" value="<?php echo($Services_row['ServicesOperator_APIpassword']); ?>"/></div>
 
<div class="col-md-2">ShortCode</div>
<div class="col-md-4"><input type="text" name="ServicesOperator_ShortCode" id="ServicesOperator_ShortCode" class="form-control" placeholder="ShortCode"  value="<?php echo($Services_row['ServicesOperator_ShortCode']); ?>" /></div>
</div>
</div>


<div class="form-group">
<div class="row ">
<div class="col-md-2">Services_PushContentAPI</div>
<div class="col-md-4">
<select name="Services_PushContentAPI" class="form-control" data-rel="chosen">
<option value="0">select Connection Type</option>
<option value="1" <?php if($Services_row['ServicesOperator_pushContent']==1){?> selected<?php } ?>>API</option>
<option value="2" <?php if($Services_row['ServicesOperator_pushContent']==2){?> selected<?php } ?>>SMPP</option>
</select>



</div>
 
<div class="col-md-2">Services_operator</div>
<div class="col-md-4"> 

<select name="ServicesOperator_operatorID" class="form-control" data-rel="chosen">
<option value="0">select operator</option>
<?php $seloperator=mysqli_query($connect,"select * from operator");


while($rowProv=mysqli_fetch_array($seloperator)){
	?>
	<option value="<?php echo($rowProv['Operator_id']); ?>" <?php if($Services_row['ServicesOperator_operatorID']==$rowProv['Operator_id']){?> selected<?php } ?>><?php echo($rowProv['Operator_name']); ?></option>
	<?php
	
	}
 ?>
</select>


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



<div class="form-group">
<div class="row ">
<div class="col-md-2">Services_operator</div>
<div class="col-md-4"> 

<select name="ServicesOperator_servicesID" class="form-control" data-rel="chosen">
<option value="0">select Services</option>
<?php $seloperator=mysqli_query($connect,"select * from services");


while($rowProv=mysqli_fetch_array($seloperator)){
	?>
	<option value="<?php echo($rowProv['Services_id']); ?>" <?php if($Services_row['ServicesOperator_servicesID']==$rowProv['Services_id']){?> selected<?php } ?>><?php echo($rowProv['Services_name']); ?></option>
	<?php
	
	}
 ?>
</select>


</div>


<div class="col-md-2">Logo</div>
<div class="col-md-4"> 
 
  <input type="file" name="ServicesOperator_logo" id="ServicesOperator_logo">
</div>



</div>
</div>




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

<div class="col-md-2">Link</div>
<div class="col-md-4"> 
 
  <input type="text" name="ServicesOperator_link" id="ServicesOperator_link"  value="<?php echo($Services_row['ServicesOperator_link']); ?>">
</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','servicesoperator',$connect)==1)
			if($_REQUEST['opt']==do_add)
{
	
	if($_REQUEST['ServicesOperator_name']==''
//	|| $_REQUEST['ServicesOperator_APIServiceID']==''
	//|| $_REQUEST['ServicesOperator_APIpassword']==''
	//|| $_REQUEST['ServicesOperator_ShortCode']==''
	|| $_REQUEST['Services_PushContentAPI']==0
	|| $_REQUEST['ServicesOperator_operatorID']==0
	|| $_REQUEST['ServicesOperator_servicesID']==0
	){
		
		echo("<div style='color:red'> Please Fill All Parameters </div>");
		}else{
 

 $services_query="insert into servicesoperator
set 
ServicesOperator_name='".post($connect,$_REQUEST['ServicesOperator_name'])."',
ServicesOperator_APIServiceID='".post($connect,$_REQUEST['ServicesOperator_APIServiceID'])."',
ServicesOperator_APIpassword='".post($connect,$_REQUEST['ServicesOperator_APIpassword'])."', 
ServicesOperator_ShortCode='".post($connect,$_REQUEST['ServicesOperator_ShortCode'])."',
 ServicesOperator_pushContent='".post($connect,$_REQUEST['Services_PushContentAPI'])."',
 ServicesOperator_operatorID='".post($connect,$_REQUEST['ServicesOperator_operatorID'])."'
 ,ServicesOperator_servicesID='".post($connect,$_REQUEST['ServicesOperator_servicesID'])."'
  ,ServicesOperator_link='".post($connect,$_REQUEST['ServicesOperator_link'])."'
 ";
 
 
 
 $situation=mysqli_query($connect,$services_query);
 if($situation){ echo("<div>Services Added SucessFully</div>");}
}}
			
			
			
				 ?>
                
                
                
                   <?php 
				   if(priv($_SESSION['role'],'add','servicesoperator',$connect)==1)
				   if($_REQUEST['opt']==add)
				   { 
				   ?>
                   
                   
                   
                   
                   
                   
                  <fieldset>
<legend>Add New service</legend>      
                   
                   
                   
                   
                   
                   
                   
                       <form method="post" enctype="multipart/form-data"  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="ServicesOperator_name" id="ServicesOperator_name" class="form-control" placeholder="ServicesOperator_name" /></div>
 
<div class="col-md-2">Services Servicesid</div>
<div class="col-md-4"><input type="text" name="ServicesOperator_APIServiceID" id="ServicesOperator_APIServiceID" class="form-control" placeholder="Services id" /></div>
</div>
</div>

<div class="form-group">
<div class="row ">
<div class="col-md-2">Services Password</div>
<div class="col-md-4"><input type="text" name="ServicesOperator_APIpassword" id="ServicesOperator_APIpassword" class="form-control" placeholder="Services Password" /></div>
 
<div class="col-md-2">ShortCode</div>
<div class="col-md-4"><input type="text" name="ServicesOperator_ShortCode" id="ServicesOperator_ShortCode" class="form-control" placeholder="ShortCode" /></div>
</div>
</div>


<div class="form-group">
<div class="row ">
<div class="col-md-2">Services_PushContentAPI</div>
<div class="col-md-4">
<select name="Services_PushContentAPI" class="form-control" data-rel="chosen">
<option value="0">select Connection Type</option>
<option value="1">API</option>
<option value="2">SMPP</option>
</select>



</div>
 
<div class="col-md-2">Services_operator</div>
<div class="col-md-4"> 

<select name="ServicesOperator_operatorID" class="form-control" data-rel="chosen">
<option value="0">select operator</option>
<?php $seloperator=mysqli_query($connect,"select * from operator");

while($rowProv=mysqli_fetch_array($seloperator)){
	?>
	<option value="<?php echo($rowProv['Operator_id']); ?>"><?php echo($rowProv['Operator_name']); ?></option>
	<?php
	
	}
 ?>
</select>


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



 



<div class="form-group">
<div class="row ">
<div class="col-md-2">Services_operator</div>
<div class="col-md-4"> 

<select name="ServicesOperator_servicesID" class="form-control" data-rel="chosen">
<option value="0">select Services</option>
<?php $selservices=mysqli_query($connect,"select * from services")  ;


while($rowservi=mysqli_fetch_array($selservices)){
	?>
	<option value="<?php echo($rowservi['Services_id']); ?>" ><?php echo($rowservi['Services_name']); ?></option>
	<?php
	
	}
 ?>
</select>


</div>

<div class="col-md-2">Logo</div>
<div class="col-md-4"> 
 
  <input type="file" name="ServicesOperator_logo" id="ServicesOperator_logo">
</div>




</div>
</div>



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

<div class="col-md-2">Link</div>
<div class="col-md-4"> 
 
  <input type="text" name="ServicesOperator_link" id="ServicesOperator_link">
</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=operatorServices">
<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="ServicesOperator_nameSearch" id="ServicesOperator_nameSearch" class="form-control" placeholder="ServicesOperator_name" value="<?php echo($_REQUEST['ServicesOperator_nameSearch']); ?>" /></div>
 
<div class="col-md-2">operator</div>
<div class="col-md-4">

<select name="ServicesOperator_operatorID" class="form-control" data-rel="chosen">
<option value="0">select operator</option>
<?php $seloperator=mysqli_query($connect,"select * from operator");

while($rowProv=mysqli_fetch_array($seloperator)){
	?>
	<option value="<?php echo($rowProv['Operator_id']); ?>"
    <?php  if($_REQUEST['ServicesOperator_operatorID']==$rowProv['Operator_id']){?> selected<?php } ?>
    ><?php echo($rowProv['Operator_name']); ?></option>
	<?php
	
	}
 ?>
</select>


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

<div class="form-group">
<div class="row ">
<div class="col-md-2">Services </div>
<div class="col-md-4"> 

<select name="ServicesOperator_servicesID" class="form-control" data-rel="chosen">
<option value="0">select Services</option>
<?php $seloperator=mysqli_query($connect,"select * from services");


while($rowProv=mysqli_fetch_array($seloperator)){
	?>
	<option value="<?php echo($rowProv['Services_id']); ?>" <?php if($_REQUEST['ServicesOperator_servicesID']==$rowProv['Services_id']){?> selected<?php } ?>><?php echo($rowProv['Services_name']); ?></option>
	<?php
	
	}
 ?>
</select>


</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','servicesoperator',$connect)==1) { ?>
                         <a href="index.php?page=operatorServices&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>Service name </td>
                             <td>service ID</td>
                             <td align="center" valign="middle">password</td>
                             <td align="center" valign="middle">Short Code</td>
                             <td align="center" valign="middle">API </td>
                             <td align="center" valign="middle">Push Type</td>
                             <td align="center" valign="middle">Link</td>
                             <td align="center" valign="middle">operator</td>
                             <td align="center" valign="middle">update </td>
                           </tr>
                           <?php  
						   
						
			 
			 $query_Services="select * from operator inner join 
servicesoperator on ServicesOperator_operatorID=Operator_id
inner join services on Services_id=ServicesOperator_servicesID
where 1=1

" ;
if($_REQUEST['ServicesOperator_operatorID']!=0){
$query_Services=$query_Services." and Operator_id='".$_REQUEST['ServicesOperator_operatorID']."'";
	 
	}
	if($_REQUEST['ServicesOperator_servicesID']!=0){
$query_Services=$query_Services." and ServicesOperator_servicesID='".$_REQUEST['ServicesOperator_servicesID']."'";
	 
	}
if($_REQUEST['ServicesOperator_nameSearch']!=''){
	$query_Services=$query_Services." and ServicesOperator_name like '%".$_REQUEST['ServicesOperator_nameSearch']."%'";
	 
	}
	
	
 	//echo($query_Services);
		 
			 $Services_res=mysqli_query($connect,$query_Services ."order by Services_id");
			
			 if($Services_res){
				 while($row=mysqli_fetch_assoc($Services_res))
				 {
				
			  ?>
						
                           <tr>
                             <td><?php echo($row['Services_name']); ?></td>
                          <td><?php echo($row['ServicesOperator_name']); ?></td>
                             <td><?php echo($row['ServicesOperator_APIServiceID']); ?></td>
                             <td align="center" valign="middle"><?php echo($row['ServicesOperator_APIpassword']); ?></td>
                             <td align="center" valign="middle"><?php echo($row['ServicesOperator_ShortCode']); ?></td>
                             <td align="center" valign="middle"><?php echo($row['ServicesOperator_APILink']); ?></td>
                             <td align="center" valign="middle">
                             
                             <?php switch($row['ServicesOperator_pushContent']){
								 case 1:
								 echo("API");
								 break;
								  case 2:
								 echo("SMPP");
								 break;
								 
								 } ?>
                             
                             
                             </td>
                             <td align="center" valign="middle"><?php echo($row['ServicesOperator_link']); ?></td>
                             <td align="center" valign="middle"><?php echo($row['Operator_name']); ?></td>
                             <td align="center" valign="middle">
                             
                              <?php    if(priv($_SESSION['role'],'up','servicesoperator',$connect)==1) { ?><a href="index.php?page=operatorServices&opt=up&id=<?php  echo($row['ServicesOperator_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>