
 <div>
    <ul class="breadcrumb">
        <li>
            <a href="index.php">Home</a>
        </li>
        <li>
            <a href="index.php?page=message"> Add message</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> Message</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){
					 
			 
 

 $message_query="update TxtMessage
set 
 TxtMessage_messageStatus='1'
 where TxtMessage_id='".post($connect,$_REQUEST['id'])."'
 
 
 
 ";
 
 
 
 $situation=mysql_query($message_query);
 if($situation){ echo("<div>message Updated SucessFully</div>");}
} 
				 ?>
                 
                 
                
                 
                 
                 
                
                  
                
                <?php 
				
			if($_REQUEST['opt']==do_add)
{
	
	if($_REQUEST['TxtMessage_text']==''
	 
	){
		
		echo("<div style='color:red'> Please Fill All Parameters </div>");
		}else{
 

 $message_query="
 insert into TxtMessage set 
TxtMessage_date=now()
,TxtMessage_text='".post($connect,$_REQUEST['TxtMessage_text'])."'
,TxtMessage_servicesId='".$_SESSION['serviceID']."'
,TxtMessage_providerID='".$_SESSION['provider']."'
,TxtMessage_userAdd='".$_SESSION['userID']."'
 
  


";
 
// echo($message_query);
 
 $situation=mysql_query($message_query);
 if($situation){ echo("<div>message Added SucessFully</div>");}
}


//go("index.php?page=message");

}
			
			
			
				 ?>
                
                
                
                   <?php 
				   if($_REQUEST['opt']==add)
				   { 
				   ?>
                       <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">Message</div>
<div class="col-md-4">

<textarea name="TxtMessage_text" cols="50" rows="5" class="form-control" id="TxtMessage_text" dir="rtl" ></textarea>
 </div>
</div>
</div>

 

 


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

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

</form>
<br>
<br>

 <!-----      end  add message       -->
                       <br>
<br>
<br>
<br>
<br>

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

 
 <?php /*

<div class="form-group">
<div class="row ">
<div class="col-md-5">provider</div>
<div class="col-md-4">

<select name="Servicesid_provider" class="form-control" data-rel="chosen">
<option value="0">select Provider</option>
<?php $selProvider=mysql_query("select * from Provider");

while($rowProv=mysql_fetch_array($selProvider)){
	?>
	<option value="<?php echo($rowProv['Provider_id']); ?>"
    <?php  if($_REQUEST['Servicesid_provider']==$rowProv['Provider_id']){?> selected<?php } ?>
    ><?php echo($rowProv['Provider_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">
                         <a href="index.php?page=message&opt=add" ><i class="glyphicon glyphicon-plus icon-white"></i> Add new message</a><br>

                         <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                                         
                         
                         
                           <tr>
                             <td>Text </td>
                             <td>Date</td>
                             <td align="center" valign="middle">Status</td>
                             <td align="center" valign="middle">Service name</td>
                             <td align="center" valign="middle">Status</td>
                             <td align="center" valign="middle">Provider</td>
                             <td align="center" valign="middle">update </td>
                           </tr>
                           <?php  
						   
						   if($_SESSION['serviceID']!=0){
$query="	 and TxtMessage_servicesId='".$_SESSION['serviceID']."'  ";							   
							   }
							   
							   
				/*	if($_REQUEST['Servicesid_provider']!=0){
$query=$query." and Servicesid_provider='".$_REQUEST['Servicesid_provider']."'";
	 
	}*/
if($_REQUEST['TxtMessage_text']!=''){
	$query=$query." and TxtMessage_text like '%".$_REQUEST['TxtMessage_text']."%'";
	 
	}
	
		
			 
			 $query_message="
select * from TxtMessage
inner join Services
on Services_id=TxtMessage_servicesId
inner join Provider on Provider_id=TxtMessage_providerID
inner join Users on Users_id=TxtMessage_userAdd
where 1=1  
".$query." 
order by TxtMessage_id desc
" ;
		 
		 
		 
		 
		 
		 
			 $message_res=mysql_query($query_message);
			
			 if($message_res){
				 while($row=mysql_fetch_assoc($message_res))
				 {
				
			  ?>
						
                           <tr>
                             <td><?php echo($row['TxtMessage_text']); ?></td>
                             <td><?php echo($row['TxtMessage_date']); ?></td>
                             <td align="center" valign="middle"><?php echo($row['TxtMessage_messageStatus']); ?></td>
                             <td align="center" valign="middle"><?php echo($row['Services_name']); ?></td>
                             <td align="center" valign="middle"><?php 
							 
							 switch($row['TxtMessage_messageStatus']){
								 case 0:
								 echo("Ready");
								 break;
								  case 1:
								 echo("Sent");
								 break;
								 
								 
								 
								 }
							   ?></td>
                             <td align="center" valign="middle"><?php echo($row['Provider_name']); ?></td>
                             <td align="center" valign="middle">
                             
                             
                             
                             <?php  if($row['TxtMessage_messageStatus']==0){ ?>
                             
                             <a href="index.php?page=message&opt=do_up&id=<?php  echo($row['TxtMessage_id']); ?>"  onClick="return confirm('are You Sure ');" > 
                             
                           
                              <i class="glyphicon glyphicon-edit icon-white"></i> Approve and send 
                    
                              </a>
                              
                              
                               
                             <?php  }?>
                               
                               
                               
                               
                               
                              </td>
                           </tr>
                           
                           
                           <?php  }}?>
                        
                  </table>
                  <br />


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