<?php
	require_once('source/session.php');
	require_once('source/error.php');
	require_once('source/dbconfig.php');
	require_once('source/function.php');
	
	if($_GET['msg'] == "refered"){
		$msg = "<h5 class='alert alert-success'>Refered successfully</h5>";
	}else if($_GET['msg'] == "failed"){
		$msg = "<h5 class='alert alert-warning'>Something went wrong, please try again</h5>";
	}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>Orrahwallet</title>
  <!-- Bootstrap core CSS-->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom fonts for this template-->
  <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <!-- Page level plugin CSS-->
  <link href="vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
  <!-- Custom styles for this template-->
  <link href="css/sb-admin.css" rel="stylesheet">
  <link href="css/user_profile.css" rel="stylesheet">
  
  <!-- select-->
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  
</head>

<body class="fixed-nav sticky-footer bg-dark" id="page-top">
  <!-- Navigation-->
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
  
<?php
            	
            	$rows = sql($DBH, "SELECT * FROM tbl_admin where status = ?", 
            	array("Active"), "rows");							
            	foreach($rows as $row)
            	{
            		$admin_name 		= $row['username'];
            	}
		
      if (isset($_SESSION['SESS_HASH_ADMIN'])) {
		$user_true 			 = "<img class='user one' src='profile_pic/$profile_pic' width='200px'><a class='navbar-brand' href='index.php' style='font-weight: bold; color: gold'> $fullname</a>";
		
}
		echo "$user_true ";
?>
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav navbar-sidenav" id="exampleAccordion">
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Dashboard">
          <a class="nav-link" href="main.php">
            <i class="fa fa-fw fa-dashboard fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Dashboard</span>
          </a>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Charts">
          <a class="nav-link" href="participants.php">
            <i class="fa fa-fw fa-user-o fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Participants' List</span>
          </a>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Charts">
          <a class="nav-link" href="moderators.php">
            <i class="fa fa-fw fa-user-o fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Moderators' List</span>
          </a>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Menu Levels">
          <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#collapseMulti" data-parent="#exampleAccordion">
            <i class="fa fa-fw fa-money fa-spin" style="color: blue"></i>
            <span class="nav-link-text" style="color: yellow">Dispute</span>
          </a>
          <ul class="sidenav-second-level collapse" id="collapseMulti">
            <li>
              <a style="color: white" href="pending.php">Pending</a>
            </li>
            <li>
              <a style="color: white" href="resolved.php">Resolved</a>
            </li>
           </ul>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Tables">
          <a class="nav-link" href="notice.php">
            <i class="fa fa-fw fa-money fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Notification</span>
          </a>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Tables">
          <a class="nav-link" href="post_ebooks.php">
            <i class="fa fa-fw fa-money fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Post Materials (PM)</span>
          </a>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Tables">
          <a class="nav-link" href="acc_settings.php">
            <i class="fa fa-fw fa-money fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Settings</span>
          </a>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto">
        <li class="nav-item">
          <a class="nav-link" data-toggle="modal" data-target="#exampleModal" style="color: yellow">
            <i class="fa fa-fw fa-sign-out"></i>Logout</a>
        </li>
      </ul>
    </div>
  </nav>
            <?php
				$rows = sql($DBH, "SELECT * FROM tbl_user where hash = ?", array($SESS_HASH_USER), "rows");							
                foreach($rows as $row)
                {	
					$profile_pic	   = $row['profile_pic'];
					$fullname 		   = $row['fullname'];
					$email 			   = $row['email'];
					$password 		   = $row['password'];
					$bitcoin_wallet    = $row['bitcoin_wallet'];
					$bank_name 		   = $row['bank_name'];
					$account_name 	   = $row['account_name'];
					$account_number    = $row['account_number'];
					$phone 			   = $row['phone'];
					$country 		   = $row['country'];
					$state 		   = $row['state'];
					$city 		   = $row['city'];
					$registration_date = $row['registration_date'];
					$registration_date = $row['registration_date'];
					$email_verified    = $row['email_verified'];
					$hash    		   = $row['hash'];
				}
				if($email_verified == "true")
				{
					$email_box = "<input style='border: 1px solid #00b300 !important' class='w3-input w3-border' type='email' title='Verified Email'
					value='$email' readonly disabled>";
				}
				else
				{
					$email_box = "<input style='border: 1px solid #ff0000 !important' class='w3-input w3-border' type='email' title='Un-Verified Email'
                    value='$email' name='email' autocomplete='off' disabled>";
				}
			?>
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumbs-->
      <ol class="breadcrumb" style="background: gold">
        <li class="breadcrumb-item">
          <a href="index.php" style="color: black; font-weight: bold">Dashboard</a>
        </li>
        <li class="breadcrumb-item active" style="color: black">Resolved Issues</li>
      </ol>
      <div class="row">
        <div class="col-lg-12">
          <!-- Example Bar Chart Card-->
      <ol class="breadcrumb"style="background: #3498db">
                                    <h6 align="center"><strong>PENDING DISPUTE</strong></h6>
                                    </ol>

              <?php
                  if($_GET['msg'] == "reply")
				  {
					  echo "<div class='alert alert-success'>
								The<strong> mail </strong> has been sent successfully.
							</div>";
				  }
                  if($_GET['msg'] == "failed")
				  {
					  echo "<div class='alert alert-danger'>
								<strong>Email </strong> sending failed, please try again thanks.
							</div>";
				  }
			  ?>

              <div class="table-responsive">
                <table class="table table-bordered table-inverse table-striped nomargin">
                  <thead>
                    <tr>
                      <th>S.No</th>
                      <th>Token</th>
                      <th>Issue Details</th>
                      <th>Reply</th>
                      <th>Support Status</th>
                    </tr>
                  </thead>
                  <tbody>
<?php
	$rows = sql($DBH, "SELECT * FROM tbl_support WHERE department = ? ORDER BY id DESC", array("fakepop"), "rows");							
	foreach($rows as $row)
	{	
		$support_id 		 = $row['id'];
		$support_user_hash 	 = $row['user_hash'];
		$support_token	 	 = $row['token'];
		$support_photo   	 = $row['photo'];
		$support_department  = $row['department'];
		$support_message   	 = $row['message'];
		$support_date_time 	 = $row['date_time'];
		$support_status 	 = $row['status'];

			$rows2 = sql($DBH, "SELECT * FROM tbl_user where hash = ?", array($support_user_hash), "rows");							
			foreach($rows2 as $row2)
			{	
				$user_profile_pic 	 = $row2['profile_pic'];
				$user_fullname 	 	 = $row2['fullname'];
				$user_bitcoin_wallet = $row2['bitcoin_wallet'];
				$user_bank_name 	 = $row2['bank_name'];
				$user_account_name 	 = $row2['account_name'];
				$user_account_number = $row2['account_number'];
				$user_email 		 = $row2['email'];
				$user_phone 		 = $row2['phone'];
				$user_country 		 = $row2['country'];
			}
			
			if($support_status == "Pending")
			{
				$color 		  = "style='background-color:#fdcc51'";
				$supp_photo	  = "<a href='support/$support_photo' target='_blank'>
									<img width='170px' src='support/$support_photo'>
								</button>";
				$status		  = "<button class='btn btn-danger btn-sm btn-block'>Issue Pending!</button>";
				$status_link  = "<a href='settings.php?approve_support=$support_id'>
									<button class='btn btn-primary btn-sm btn-block'>Click Here<br><strong>If Issue Solved</strong></button>
								</a>";
			}
			else if($support_status == "Solved")
			{
				$color 		  = "style='background-color: #9ed566'";
				$supp_photo	  = "<a href='support/$support_photo' target='_blank'>
									<img width='170px' src='support/$support_photo'>
								</button>";
				$status		  = "<button class='btn btn-success btn-sm btn-block'>Issue Solved</button>";
				$status_link  = "<a href='settings.php?approve_support=$support_id'>
									<button class='btn btn-primary btn-sm btn-block'>Click Here<br> To Roll Back</button>
								</a>";
			}
			echo "<tr $color>
						  <td>0$support_id</td>
						  <td>
						  	  $user_fullname<br>
						  	  $support_token
							  $user_email<br>
						  </td>
						  <td>
						  	  $support_message<br> 
							  $support_date_time<br>
						  </td>
						  <td>
							  <form method='post' action='support_reply.php' enctype='multipart/form-data'>
								  <input type='hidden' name='support_email' value='$user_email'>
 								  <textarea style='resize:vertical' class='form-control' name='support_reply' placeholder='Reply to $user_fullname' required=''></textarea>
								  <input class='btn btn-success btn-sm btn-block' type='submit' name='reply' value='Reply'>
							  </form>
						  </td>
						  <td width='200px'>
						  		$supp_photo<br>
								$status<br>
								$status_link
						  </td>
				  </tr>";
	}
?>    
                  </tbody>
                </table>
                              </div>
          </div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
    <footer class="sticky-footer" style="background: gold">
      <div class="container">
        <div class="text-center">
          <small><strong>Copyright © Reserved! Orrahwall Developement Theme.</strong></small>
        </div>
      </div>
    </footer>
    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fa fa-angle-up"></i>
    </a>
    <!-- Logout Modal-->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="Sign_in.php">Logout</a>
          </div>
        </div>
      </div>
    </div>
    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    <!-- Page level plugin JavaScript-->
    <script src="vendor/chart.js/Chart.min.js"></script>
    <script src="vendor/datatables/jquery.dataTables.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>
    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin.min.js"></script>
    <!-- Custom scripts for this page-->
    <script src="js/sb-admin-datatables.min.js"></script>
    <script src="js/sb-admin-charts.min.js"></script>
  </div>
</body>

</html>
