MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b2680/childrendccom.domain.com/client_access/
File Upload :
Current < : /hermes/sb_web/b2680/childrendccom.domain.com/client_access/customer_complaint.php

<?php
session_start();
include("../includes/database.php");
include("../functions/functions.php");

// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

// Load Composer's autoloader
require "PHPMailer/vendor/autoload.php";

if(!$_SESSION["customer_email"]){
	header("location: ../checkout.php?error=Please-Provide-Your-Login-Details-Thanks.");
}else{

$user_a = @$_SESSION["customer_email"];

$user_ip_a = getIp();

$get_user_a = "select * from customers where customer_email = '$user_a' AND customer_ip = '$user_ip_a'";
$run_user_a = mysqli_query($con, $get_user_a);
$row_a = mysqli_fetch_array($run_user_a);
$count_user = mysqli_num_rows($run_user_a);
	
$cust_id = $row_a["customer_id"];
$cust_name_a = $row_a["customer_name"];
$cust_email_a = $row_a["customer_email"];
$cust_gender_a = $row_a["customer_gender"];
$cust_image_a = $row_a["customer_image"];

?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Customer Complain | <?php echo $comp_title; ?></title>

<?php include("includes/head.php"); ?>
<style>
.ticket-group{
	padding: 10px;
	margin: 10px;
	background: #f3f3f3;
	border-radius: 10px;
}
textarea{
	height: 180px;
	resize: none;
	overflow-y: scroll;
}
</style>
</head> 
<body class="cbp-spmenu-push">
<div class="main-content">
	
	<!--left-fixed -navigation-->
	<div class=" sidebar" role="navigation">
		<div class="navbar-collapse">
			<?php include("includes/menu.php"); ?>
		</div>
	</div>
	<!--left-fixed -navigation-->
	
	<!-- header-starts -->
		<?php include("includes/header.php"); ?>
	<!-- //header-ends -->
	
	<!-- main content start-->
	<div id="page-wrapper">
		<div class="main-page">
		
			<div class="grid_3 grid_5 widget-shadow">
				<h3 class="hdg">Customer Complain</h3>
				
				<div>
					
					<form action="" method="POST">
						<table class="table table-striped">
							<tr>
								<td>
									<input type="text" placeholder="Complain Title Goes Here" class="input-control" name="ticket_title" required />
									<input type="hidden" name="ticket_number" />
								</td>
							</tr>
							<tr>
								<td>
									<textarea name="ticket_body" class="input-control" placeholder="Complain Goes Here" required></textarea>
								</td>
							</tr>
							<tr>
								<td>
									<input type="submit" name="submit_ticket" class="btn btn-primary" value="Submit Complain" />
								</td>
							</tr>
						</table>
					</form><hr />
					<?php
						
						if(isset($_POST['submit_ticket'])){

							$ticket_number = mysqli_real_escape_string($con, $_POST["ticket_number"]);
							$ticket_title = mysqli_real_escape_string($con, $_POST["ticket_title"]);
							$ticket_body = mysqli_real_escape_string($con, $_POST["ticket_body"]);
							
							$ticket_no = mt_rand();
							$ticket_status = "Open";
							
							$mail = new PHPMailer(true);
							$mail->isSMTP();
							$mail->Host       = 'mail.zetongifts.com';
							$mail->SMTPAuth   = true;
							$mail->Username   = 'developer@zetongifts.com';
							$mail->Password   = 'MbszOo^C0c$A';
							$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
							$mail->Port       = 587;

							$mail->setFrom($cust_email_a, $cust_name_a);
							$mail->addAddress("info@zetongifts.com", "Complaint - Customer Complaint");
							$mail->addBCC("zetongifts@gmail.com", "Complaint - Customer Complaint");
							$mail->addReplyTo("info@zetongifts.com", "Zeton Giftshop");
							$mail->isHTML(true);
							
							if($ticket_number != ""){
								exit();
							}else{
								
								if($ticket_body == ""){
									echo "<script>alert('Please Fill In All Fields!')</script>";
									echo "<script>window.open('customer_care.php','_self')</script>";
									exit();
								}else{
									
									// Content
									$mail->Subject = "Complaint - Customer Complaint";
									$mail->Body    = "
										<html>
											<head>
												<style>
													h2, h4, h5, p{
														margin-bottom: 10px;
													}
												</style>
											</head>
											<body>
												<h4>New Ticket from the Website - Zeton Giftshop</h4>
												<p>Customer Name: $cust_name_a</p>
												<p>Customer Email: $cust_email_a</p>
												<p>Ticket Title: $ticket_title</p>
												<p>Ticket Number: #$ticket_no</p>
												<p>Ticket Message: $ticket_body</p>
											</body>
										</html>
									";
									//send mail ends
									
									if(!$mail->send()){
										echo $mail->ErrorInfo;
									}else{
										$ticket_query = "insert into ticket (customer_id, ticket_no, ticket_title, ticket_message, customer_name, customer_email, ticket_status, ticket_date) values ('$cust_id','$ticket_no','$ticket_title','$ticket_body','$cust_name_a','$cust_email_a','$ticket_status',NOW())";
										$run_ticket = mysqli_query($con, $ticket_query);
										
										if($run_ticket){
											echo "<script>alert('A Ticket Has Been Opened For Your Request. We Will Revert Shortly!')</script>";
											echo "<script>window.open('customer_care.php','_self')</script>";
											exit();
										}
									}
								}
							}
						}
					
					?>
					
				</div>
				
				<div>
					
					<?php
			
						include("../includes/database.php");
						
						$per_page = 10;

						if(isset($_GET['page'])){
							$page = preg_replace('#[^0-9]#', '', $_GET['page']);
						}else{
							$page = 1;
						}

						$start_from = ($page - 1) * $per_page;
						
						$fetch_query = "select * from ticket where customer_id = '$cust_id' AND customer_email = '$cust_email_a' ORDER BY 1 DESC LIMIT $start_from, $per_page";
						$run_fetch = mysqli_query($con, $fetch_query);
						$fetch_count = mysqli_num_rows($run_fetch);
						
						if($fetch_count == 0){
							
						}else{
							
							while($row_fetch = mysqli_fetch_array($run_fetch)){
								
								$fetch_ticket_id = $row_fetch["ticket_id"];
								$fetch_ticket_title = $row_fetch["ticket_title"];
								$fetch_ticket_no = $row_fetch["ticket_no"];
								$fetch_ticket_status = $row_fetch["ticket_status"];
								$fetch_ticket_date = $row_fetch["ticket_date"];
								
								$fetch_ticket_id = base64_encode($fetch_ticket_id);
							
					?>
					
					<div style='padding: 10px; border: 1px solid #ccc;'>
						<a href="single_ticket.php?ticket_id=<?php echo $fetch_ticket_id; ?>"><h4><?php echo $fetch_ticket_title; ?> - #<?php echo $fetch_ticket_no; ?></h4> <span>Click To View Conversation</span></a><hr />
						<p>Ticket Status: <?php echo $fetch_ticket_status; ?> | Date: <?php echo $fetch_ticket_date; ?></p>
					</div><br />
					
					<?php }} ?>
					
				</div>
				
				<div class="well">
					<center><?php include("customer_care_pagination.php"); ?></center>
				</div>
				
			</div>
			
			<div class="clearfix"> </div>
		</div>
	</div>
	<!--footer-->
	<?php include("includes/footer.php"); ?>
	<!--//footer-->
</div>

</body>
</html>
<?php } ?>