  <?php
session_start();
if(isset($_SESSION['SESS_ADMINLOGGEDIN']) == FALSE) {
    header("Location: " . $config_basedir."access");
}
require_once("achieved/config.php");
require_once("achieved/db.php");
require_once("achieved/functions.php");
require ("header.php");
?>

<?php
require_once("achieved/config.php");
require_once("achieved/db.php");
require_once("achieved/db2.php");

	$query=$conn->query("select * from settings  ORDER BY id DESC LIMIT 1");
			while($row=$query->fetch()){
			
				$title=$row['title'];
				$id=$row['id'];
				$welc_head=$row['welc_head'];
			    $welc_msg=$row['welc_msg'];
				$url=$row['url'];
				$ceo=$row['ceo'];
				$domain=$row['domain'];
				$domain_name=$row['domain_name'];
				$phone=$row['phone'];
				$country=$row['country'];
				$state=$row['state'];
				$city=$row['city'];
				$email=$row['email'];
				$email2=$row['email2'];
				$copyright=$row['copyright'];
				$contact_email=$row['contact_email'];
					$developa=$row['developa'];
				
				
				$sell_rate=$row['sell_rate'];
				$buy_rate=$row['buy_rate'];
					$tr_rate=$row['tr_rate'];
						$wid_rate=$row['wid_rate'];
				
				
				$GHS=$row['GHS'];
				$USD=$row['USD'];
				$EUR=$row['EUR'];
				$NGN=$row['NGN'];
				$CAD=$row['CAD'];
				$GBP=$row['GBP'];
				$ZAR=$row['ZAR'];
				
				
					$reg_clients=$row['reg_clients'];
			$btc_sold=$row['btc_sold'];
			$btc_bought=$row['btc_bought'];
			
			
			 $news_head=$row['news_head'];
		   	$news_msg=$row['news_msg'];
				
				
				$about_head=$row['about_head'];
				$about_msg=$row['about_msg'];
				
					$service1=$row['service1'];
						$service2=$row['service2'];
							$service3=$row['service3'];	
							







?>
<?php }?>
 <?php

$orderssql = "SELECT * FROM logins WHERE id ='$email'";
    $ordersres = mysql_query($orderssql);
    $numrows = mysql_num_rows($ordersres);



if (isset($_POST['title'])) {


 $cname = mysql_real_escape_string($_POST['cname']);
    $cemail = mysql_real_escape_string($_POST['cemail']);
    $cphone = mysql_real_escape_string($_POST['cphone']);
    $caddress = mysql_real_escape_string($_POST['caddress']);
     $copyright = mysql_real_escape_string($_POST['copyright']);
    
    $email = mysql_real_escape_string($_POST['email']);
    
    $emailB = mysql_real_escape_string($_POST['emailB']);
   
   
      $title = mysql_real_escape_string($_POST['title']);
   $ticket_id = mysql_real_escape_string($_POST['ticket_id']);
   
    $msg = mysql_real_escape_string($_POST['msg']);
   
    $id = mysql_real_escape_string($_POST['id']);
    $date = mysql_real_escape_string($_POST['date']);
   
   
   
  $addresssql = mysql_query("INSERT INTO `message` (`log_id`,  `title`, `name`, `date`, `msg`,  `email`, `acc_no`, `phone`, `ticket_id`,  `status`) 
  VALUES ('$id', '$title',  '$cname', '$date', '$msg', '$cemail', '$acc_no',  '$cphone', '$ticket_id',   1 )");
            echo mysql_error();
           $success="
        
       <center> <div class='warning' style='margin-bottom:50px;'>
       <div class='loader'></div>
        <meta http-equiv='refresh' content='5; url=' />
       Please wait......</div></center>";
    }
   


  //   =============TO==USER=================  
       
   $email = mysql_real_escape_string($_POST['email']);
   if (isset($email))
       {
            $to = $email;
            $subject = $title;
       
       $body ='
         <p> You have a new message from '.$cname.'.</p>
    
    <center><img id="logo" class="img-responsive" src="'.$url.'/img/LOGO.png" width="100%" height="100%" alt="logo"></center>
       
       TITLE: '.$title.'<br>

       PHONE: '.$cphone.'<br>
       
       EMAIL: '.$cemail.'<br>
       
       MESSAGE: '.$msg.'<br>
       
     
      
       ';
        
        $header = "From:". $cemail."\r\n";
       
        $header .= "MIME-Version: 1.0\r\n";
       
        $header .= "Content-Type: text/html; charset=UTF-8\r\n";
       
        if(@mail($to, $subject, $body, $header)){

}
}


 $emailB = mysql_real_escape_string($_POST['emailB']);
 if (isset($emailB))
       {
            $to = $emailB;
            $subject = $title;
       
        $body ='
         <p> You have a new message from '.$cname.'.</p>
    
    <center><img id="logo" class="img-responsive" src="'.$url.'/img/LOGO.png" width="100%" height="100%" alt="logo"></center>
       
       TITLE: '.$title.'<br>

       PHONE: '.$cphone.'<br>
       
       EMAIL: '.$emailB.'<br>
       
       MESSAGE: '.$msg.'<br>
       
     
      
       ';
        
        
        $header = "From:". $cemail."\r\n";
       
        $header .= "MIME-Version: 1.0\r\n";
       
        $header .= "Content-Type: text/html; charset=UTF-8\r\n";
       
        if(@mail($to, $subject, $body, $header)){

}
}

    ?> 




<!--===========================================-->

   
   	

 <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="page-breadcrumb">
                <div class="row">
                    <div class="col-12 d-flex no-block align-items-center">
                        <h4 class="page-title">SEND DIRECT EMAIL</h4>
                        <div class="ml-auto text-right">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="index.php">HOME</a></li>
                                    <!--<li class="breadcrumb-item active" aria-current="page" href="settings.php">New Message</li>-->
                                </ol>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            
            
           <?php 
if(isset($success)){
    echo $success;
}
?>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-md-6">
                        <div class="card">
                            
                                
                  
                 
        
          <form action="" class="reservation-form mb-0 bg-silver-deep p-30" method="post" onsubmit="FormSubmit(this);">
              
             
               <label>TITLE</label> &nbsp;
              <input type="text" class="form-control" name="title" id="details"  placeholder=""><br>
              
              
              
              
              <!-- <label>Type Email</label> &nbsp;-->
              <!--<input type="email" class="form-control" name="email" id="details"  placeholder="Enter your desire email"><br>-->
              
              
             <label>EMAIL ADDRESS</label> &nbsp;

<select name="email" onchange="DropDownChanged(this);">
    <option value=''>Select Email</option>           
                  <?php 
                  $orderssql = "SELECT * from logins  ORDER BY id ASC LIMIT 2,1000";
    $ordersres = mysql_query($orderssql);
    $numrows = mysql_num_rows($ordersres);

    while($row = mysql_fetch_assoc($ordersres))
     {
         echo
         
          "<option value='". $row['email']."' class='form-control'> ". $row['email']."  </option> ";
     }
     ?>
    <option value="" class='form-control'>Other..</option>
</select>
<input type="text" class="form-control" name="emailB" style="display: none;" />

                      
         <br>
                            
                      
 <input class="form-control border-primary"
                           type="hidden"
                           name="date" 
     value="<?php
echo(date("jS F Y g.iA"));
?>" readonly>

    

               <label>NOTE</label> &nbsp;
              <textarea type="text" class="form-control" name="msg" id="editor1" ></textarea><br>
              
             <script>
   CKEDITOR.replace( 'editor1' );
  </script> 
       
       
       
       
       
       
           <?php
  $orderssql = "SELECT * from settings  ORDER BY id DESC";
    $ordersres = mysql_query($orderssql);
    $numrows = mysql_num_rows($ordersres);
   

 while($row = mysql_fetch_assoc($ordersres))
     {


echo"<input type='hidden' class='form-control' name='cname' id='details'  value='".$row['domain_name']."'>

<input type='hidden' class='form-control' name='cemail' id='details'  value='".$row['email2']."'>

<input type='hidden' class='form-control' name='cphone' id='details'  value='".$row['phone']."'>

<input type='hidden' class='form-control' name='caddress' id='details'  value='".$row['address']."'>

<input type='hidden' class='form-control' name='copyright' id='details'  value='".$row['copyright']."'>
      
      
       
";

}
?>  
         
     
     
     
      <div class="col-md-12">
<div class="form-group app-label">
  <label for="edit_personal_email" class="control-label">Ticket ID</label>
                   <?php
$ticket_id = rand(10000000000000,100000000000000);
?>
 <input name="ticket_id" type="number" class="form-control"  value="<?php echo $ticket_id; ?>"readonly>  
 </div></div>         
              
            <button type="submit" name="action" class="btn btn-success" 
            >SEND MESSAGE</button>

            </form>
                            
                                </div>
                            </div>                
                                               
                           
                           
                           
                           
                           
                           
                           
                           
                             
                             
                            </div>
                        </div>
                       
                       
                       
                       
                       
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            
            
            
            </div>
           
           
          
           
           <?php require ("footer.php")?>