 <?php

require ("header.php");

?>


<?php
// Assuming you have a PDO connection set up in $pdo
if (isset($_GET['del']) && is_numeric($_GET['del'])) {
    // Sanitize and validate the 'del' parameter
    $validid = pf_validate_number($_GET['del'], "redirect", $config_basedir);
    
    // Prepare the DELETE query with PDO
    $stmt = $pdo->prepare("DELETE FROM message WHERE id = :id");
    $stmt->bindParam(':id', $validid, PDO::PARAM_INT);
    
    // Execute the query
    if ($stmt->execute()) {
        $delete = 2; // Successfully deleted
        // Optionally, redirect or show a success message
    } else {
        $delete = 1; // Error in deletion
    }
}
?>

	  
	  
	  
    
 
 <!---begin of Mobile View Here   only from Digital Forest Team-->
 
     
   
   
  				
  <script>
    $(document).ready(function() {
      $('#mybutton').hide().delay(5000).fadeIn(2200);
});
    </script> 

 <style>
input[type=text2] {
  width: 60%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
} 

input[type=text], select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}

input[type=number], date{
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}


input[type=submit] {
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

input[type=submit]:hover {
  background-color: #45a049;
}

.container {
  border-radius: 5px;
  background-color: ;
  padding: 20px;
}
</style>
						
				

					
<br><br>
 
 
 <div class="container-fluid py-4">
 
  <div class="row">
        <div class="col-12">
          <div class="card my-4">
            <div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
              <div class="bg-gradient-primary shadow-primary border-radius-lg pt-4 pb-3">
                <h4 class="text-white text-capitalize ps-3"><img src="icon/ibft.png" height="40" width="40" > OPEN SUPPORT TICKET</h4> 
              </div>
            </div>
            <div class="card-body px-0 pb-2"> 
                
                
                
                
                      <div class="row">
        <div class="col-md-7 mt-4">
          <div class="card"> 
            <div class="card-body pt-4 p-3">
              <p style="color:darkgreen;">Dont keep Mute, Write us anytime</p>  
          
            		    <div class="container">  
           
                    <?php
// Assuming $pdo is your PDO database connection

// Fetch the settings from the database
$stmt = $pdo->prepare("SELECT * FROM settings ORDER BY id DESC");
$stmt->execute();
$settings = $stmt->fetch(PDO::FETCH_ASSOC);

// Generate a unique Ticket ID
$ticket_id = rand(10000000000000, 100000000000000);

// Get the current date and time
$current_date = date("jS F Y g.iA");
?>

<form method="post" action="" class="form-horizontal">
    
    <?php if (isset($success_msg)) {
        echo $success_msg;
    } ?>

    <input class="form-control" type="hidden" name="acc_no" value="<?php echo htmlspecialchars($acc_no); ?>" readonly/>
    
    <div class="row">
        <div class="col-md-12">
            <div class="form-group app-label">
                <input name="name" type="text" class="form-control" value="<?php echo htmlspecialchars($firstname . ' ' . $lastname); ?>" readonly/>
            </div>
        </div>

        <div class="col-md-6">
            <div class="form-group app-label">
                <input name="email" type="email" class="form-control" value="<?php echo htmlspecialchars($email); ?>" readonly/>
            </div>
        </div>

        <div class="col-md-6">
            <div class="form-group app-label">
                <input name="phone" type="text" class="form-control" value="<?php echo htmlspecialchars($phone); ?>" readonly/>
            </div>
        </div>

        <div class="col-md-12">
            <div class="form-group app-label">
                <input name="title" type="text" class="form-control" placeholder="Subject *" value=""/>
            </div>
        </div>

        <div class="col-md-12">
            <div class="form-group app-label">
                <input required name="msg" type="text" class="form-control" placeholder="Enter your message here**********" value=""/>
            </div>
        </div>
    </div>

    <div class="col-md-12">
        <div class="form-group app-label">
            <label for="edit_personal_email" class="control-label">Ticket ID</label>
            <input name="ticket_id" type="number" class="form-control" value="<?php echo $ticket_id; ?>" readonly/>
        </div>
    </div>

    <input type="hidden" class="form-control" name="date" value="<?php echo $current_date; ?>" readonly/><br>

    <!-- Settings Information Hidden Inputs -->
    <input type="hidden" class="form-control" name="cname" value="<?php echo htmlspecialchars($settings['domain_name']); ?>"/>
    <input type="hidden" class="form-control" name="cemail" value="<?php echo htmlspecialchars($settings['email2']); ?>"/>
    <input type="hidden" class="form-control" name="cphone" value="<?php echo htmlspecialchars($settings['phone']); ?>"/>
    <input type="hidden" class="form-control" name="caddress" value="<?php echo htmlspecialchars($settings['address']); ?>"/>

    <div class="row">
        <div class="col-sm-12">
            <input type="submit" name="action_msg" class="submitBnt btn btn-primary w-100" value="Send Message"/>
        </div>
    </div>
</form>


	  
	  
                         
        
            </div>
            </div>
          </div>
        </div>
      
      
      
      
      
        <div class="col-md-5 mt-4">
          <div class="card h-100 mb-4">
           <div class="card-header pb-0 px-3">
  <div class="row">
    <div class="col-md-6" align="right">
      BANK MESSAGES - INBOX : ( 
        <?php
        // Assuming $pdo is your PDO database connection
        $stmt = $pdo->prepare("SELECT COUNT(id) FROM message WHERE log_id = :log_id AND status = '1'");
        $stmt->bindParam(':log_id', $id, PDO::PARAM_INT);
        $stmt->execute();
        $sql = $stmt->fetch(PDO::FETCH_ASSOC);
        echo $sql['COUNT(id)'];
        ?>
      )
    </div>
  </div>
</div>

           
           
        <div class="card-body pt-4 p-3"> 
        <?php
 $orderssql = "SELECT * from message WHERE log_id='$id'
 ORDER BY id ASC LIMIT 10";
    $ordersres = mysql_query($orderssql);
    $numrows = mysql_num_rows($ordersres);

   
  
 	
     if(isset($delete)){
         echo " <center>  <span style='color:red'>successfully deleted mail from inbox<br><br>
         <div class='loader'></div>
         <meta http-equiv='refresh' content='5 url=ticket.php'/>
         </div></center>";
     }
    
     
      while($row = mysql_fetch_assoc($ordersres))
     {
         
       	if($row['status'] == 1)
         {
         
          echo "
                                <div class='d-flex flex-row comment-row m-t-0'>
                                <div class='p-2'>";
                                    
                                    
                                    
                                    echo "
      <img  src='../" . $row['P_location'] . "' class='rounded-circle' alt='" . $row['username'] . "'  style='width:50px;height:50px' >
      ";
                                    
                                    
                                    
                                   echo" </div>
                                   
                                   
                                    <div class='comment-text w-100'>
                                        <h6 class='font-medium'>". $row['name']."</h6>
                                        <span class='m-b-15 d-block'>".substr($row['msg'],-0,10)." . . . . . . .,</span>
                                        
                                        <div class='comment-footer'>
                                            
                                            <span class='btn btn-success btn-sm float-right'>". $row['date']."</span> 
                                           
                                         
                                             <a type='button' class='btn btn-info btn-sm'  href='reply_inbox.php?id=" . $row['id'] . "'>View</a>
                                           
                                           
                                           
                                            <a type='button' class='btn btn-danger btn-sm' href='ticket.php?del=" . $row['id'] . "'>Delete</a>
                                        
                                        </div>
                                    </div>
                                </div><br>";                
                                
     }
     }
     ?>
               
        </div>
        
         <!--<iframe frameborder="0" scrolling="auto" height="100%" width="100%" allowtransparency="true" marginwidth="0" marginheight="0" src="https://sslfxrates.investing.com/index_exchange.php?params&inner-border-color=%23CBCBCB&border-color=%23cbcbcb&bg1=%23F6F6F6&bg2=%23ffffff&inner-text-color=%23000000&currency-name-color=%23000000&header-text-color=%23FFFFFF&force_lang=72" align="center"></iframe><br /><div style="width:540px"></div>-->
        
        
        
          </div>
        </div>
      </div>
                
                
      
                          
		    
		    </div>
 
                 
              
              <br><br>
            </div>
          </div>
        </div><br><br>
      </div>
 
 
 
 </div>
 

				
				
				
				
 
		    
		   
	
	
	<?php require ("footer.php") ?>