<?php
session_start();
require_once('class.admin.php');
include_once('session.php');

$reg_user = new USER();

if (!isset($_SESSION['email'])) {

  header("Location: login.php");

  exit();
}

$account = $reg_user->runQuery("SELECT * FROM account");
$account->execute();
$stmt = $reg_user->runQuery("SELECT * FROM account");
$stmt->execute();

$mail = $_SESSION['email'];

$stmt = $reg_user->runQuery("SELECT * FROM account WHERE uname=:uname");

$stmt->execute(array(":uname" => $_SESSION['uname']));

$row = $stmt->fetch(PDO::FETCH_ASSOC);

$email = $row['email'];
$fname = $row['fname'];
$lname = $row['lname'];

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

  $sender_name = trim($_POST['sender_name']);
  $sender_name = strip_tags($sender_name);
  $sender_name = htmlspecialchars($sender_name);

  $reci_name = trim($_POST['reci_name']);
  $reci_name = strip_tags($reci_name);
  $reci_name = htmlspecialchars($reci_name);

  $subject = trim($_POST['subject']);
  $subject = strip_tags($subject);
  $subject = htmlspecialchars($subject);

  $msg = trim($_POST['msg']);
  $msg = strip_tags($msg);
  $msg = htmlspecialchars($msg);

  $readd = $reg_user->runQuery("SELECT * FROM account WHERE email = '$mail'");
  $readd->execute();
  $shows = $readd->fetch(PDO::FETCH_ASSOC);



  if ($reg_user->message($sender_name, $reci_name, $subject, $msg)) {
    $id = $reg_user->lasdID();

    $stmt = $reg_user->runQuery("SELECT * FROM bank_settings WHERE id = '1'");
    $stmt->execute();
    $row = $stmt->fetch(PDO::FETCH_ASSOC);


    $bank_name  = $row["bank_name"];
    $bank_address  = $row["bank_address"];
    $bank_domain  = $row["bank_domain"];

    $messag = "
			
		<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  <title>[SUBJECT]</title>
  <style type='text/css'>
  body {
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   margin:0 !important;
   width: 100% !important;
   -webkit-text-size-adjust: 100% !important;
   -ms-text-size-adjust: 100% !important;
   -webkit-font-smoothing: antialiased !important;
 }
 .tableContent img {
   border: 0 !important;
   display: block !important;
   outline: none !important;
 }
 a{
  color:#382F2E;
}

p, h1{
  color:#382F2E;
  margin:0;
}

div,p,ul,h1{
  margin:0;
}
p{
font-size:13px;
color:#99A1A6;
line-height:19px;
}
h2,h1{
color:#444444;
font-weight:normal;
font-size: 22px;
margin:0;
}
a.link2{
padding:15px;
font-size:13px;
text-decoration:none;
background:#2D94DF;
color:#ffffff;
border-radius:6px;
-moz-border-radius:6px;
-webkit-border-radius:6px;
}
.bgBody{
background: #f6f6f6;
}
.bgItem{
background: #2C94E0;
}

@media only screen and (max-width:480px)
		
{
		
table[class='MainContainer'], td[class='cell'] 
	{
		width: 100% !important;
		height:auto !important; 
	}
td[class='specbundle'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		
	}
	td[class='specbundle1'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		
	}	
td[class='specbundle2'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
	}
	td[class='specbundle3'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
		padding-bottom:20px !important;
	}
	td[class='specbundle4'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		text-align:center !important;
		
	}
		
td[class='spechide'] 
	{
		display:none !important;
	}
	    img[class='banner'] 
	{
	          width: 100% !important;
	          height: auto !important;
	}
		td[class='left_pad'] 
	{
			padding-left:15px !important;
			padding-right:15px !important;
	}
		 
}
	
@media only screen and (max-width:540px) 

{
		
table[class='MainContainer'], td[class='cell'] 
	{
		width: 100% !important;
		height:auto !important; 
	}
td[class='specbundle'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		
	}
	td[class='specbundle1'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		
	}		
td[class='specbundle2'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
	}
	td[class='specbundle3'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
		padding-bottom:20px !important;
	}
	td[class='specbundle4'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		text-align:center !important;
		
	}
		
td[class='spechide'] 
	{
		display:none !important;
	}
	    img[class='banner'] 
	{
	          width: 100% !important;
	          height: auto !important;
	}
		td[class='left_pad'] 
	{
			padding-left:15px !important;
			padding-right:15px !important;
	}
		
	.font{
		font-size:15px !important;
		line-height:19px !important;
		
		}
}

</style>

<script type='colorScheme' class='swatch active'>
  {
    'name':'Default',
    'bgBody':'f6f6f6',
    'link':'ffffff',
    'color':'99A1A6',
    'bgItem':'2C94E0',
    'title':'444444'
  }
</script>

</head>
<body paddingwidth='0' paddingheight='0' bgcolor='#d1d3d4'  style=' margin-left:5px; margin-right:5px; margin-bottom:0px; margin-top:0px;padding-top: 0; padding-bottom: 0; background-repeat: repeat; width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;' offset='0' toppadding='0' leftpadding='0'>
  <table width='100%' border='0' cellspacing='0' cellpadding='0' class='tableContent bgBody' align='center'  style='font-family:Helvetica, Arial,serif;'>
  
    <!-- =============================== Header ====================================== -->

  <tr>
    <td class='movableContentContainer' >
    	<div class='movableContent' style='border: 0px; padding-top: 0px; position: relative;'>
        	<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>
                   <tr><td height='25'  colspan='3'></td></tr>

                    <tr>
                      <td valign='top'  colspan='3'>
                        <table width='600' border='0' bgcolor='transparent' cellspacing='0' cellpadding='0' align='center' valign='top' class='MainContainer'>
                          <tr>
                            <td align='left' valign='middle' width='100%'>
                              <div class='contentEditableContainer contentImageEditable'>
                                <div class='contentEditable' >
                                  <center><img src='$bank_domain/account/dashboard/icon/email.png' alt='' data-default='placeholder'></center>
								  <b style='font-size:1.5em; color:#fff;'></b>
                                </div>
                              </div>
                            </td>

                            
                          </tr>
                        </table>
                      </td>
                    </tr>
          </table>
      </div>
        <div class='movableContent' style='border: 0px; padding-top: 0px; position: relative;'> </div>
        
        
        
      <div class='movableContent' style='border: 0px; padding-top: 0px; position: relative;'>
        	<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>
                  <tr>
                    <td>
                      <table width='600' border='0' cellspacing='0' cellpadding='0' align='center' valign='top' class='MainContainer'>
                        <tr>
                          <td>
                            <table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>

                              <tr>
                                <td valign='top' align='center'>
                                  <div class='contentEditableContainer contentTextEditable'>
                                    <div class='contentEditable' >
       <br >                             <h1 style='font-size:20px;font-weight:normal;color:#0076b6;line-height:19px;'>Dear $fname $lname,</h1> <br >
 <p style='font-size:15px;color:#0076b6;line-height:19px;'>This is a support ticket from the $sender_name</p><br>	
                                     <p style='font-size:15px;color:#050505;line-height:19px;'>$msg</p>
                                    </div>
                                  </div>
                                </td>
                              </tr>

                              <tr><td height='28'>&nbsp;</td></tr>
                              
                              <tr>
                                <td valign='top' align='center'>
                                  <div class='contentEditableContainer contentTextEditable'>
                                    <div class='contentEditable' >
                                      <p style=' font-weight:bold;font-size:13px;line-height: 30px;'>$bank_name.</p>
                                    </div>
    <br>                           <div class='contentEditableContainer contentTextEditable'>
                                    <div class='contentEditable' > <br /> 
This email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please delete all copies and notify the sender immediately. You may wish to refer to the incorporation details of AlphaEdge Commercial Bank, AlphaEdge Commercial Bank and their subsidiaries at $bank_domain. Please refer to $bank_domain for AlphaEdge Commercial Bank’s Privacy Policy.<br /><br />
                                      </p>
                                      <p style='#F00; font-size:13px;line-height: 15px;'> $bank_address. </p>
                                    </div>
                                  </div>                               </div>
                                  <div class='contentEditableContainer contentTextEditable'>
                                    <div class='contentEditable' >
                                      <p style='color:#A8B0B6; font-size:13px;line-height: 15px;'>&nbsp;</p>
                                    </div>
                                  </div>
                                  <div class='contentEditableContainer contentTextEditable'>
                                  </div>
                                  <div class='contentEditableContainer contentTextEditable'>
                                    
                                  </div>
                                </td>
                              </tr>

                              <tr><td height='28'>&nbsp;</td></tr>
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>
        </div>
    </td>
  </tr>
</table>


  </body>
  </html>


";



    $subject = "[SUPPORT TICKET] - AlphaEdge Commercial Bank";

    $reg_user->send_mail($email, $messag, $subject);














    $msg = "
					<div class='alert alert-success'>
						<button class='close' data-dismiss='alert'>&times;</button>
						<strong>Message Sent!</strong>.
                     
			  		</div>
					";
  } else {
    echo "Sorry, Message was not sent";
  }
}

?>


<?php
include 'dbconnect.php';

$sql = "SELECT * FROM account ORDER BY id";
$sql1 = "SELECT * FROM ticket ";
$sql2 = "SELECT * FROM transfer";
$sql3 = "SELECT * FROM account WHERE verify ='N' ORDER BY id DESC LIMIT 200";


if ($result = mysqli_query($connection, $sql)) {
  // Return the number of rows in result set
  $rowcount = mysqli_num_rows($result);

  // Free result set
  mysqli_free_result($result);

  if ($result1 = mysqli_query($connection, $sql1)) {
    // Return the number of rows in result set
    $rowcount1 = mysqli_num_rows($result1);

    // Free result set
    mysqli_free_result($result1);

    if ($result2 = mysqli_query($connection, $sql2)) {
      // Return the number of rows in result set
      $rowcount2 = mysqli_num_rows($result2);

      // Free result set
      mysqli_free_result($result2);

      if ($result3 = mysqli_query($connection, $sql3)) {
        // Return the number of rows in result set
        $rowcount3 = mysqli_num_rows($result3);

        // Free result set
        mysqli_free_result($result3);
      }
    }
  }
}

mysqli_close($connection);
?>
<?php include 'headeradmin.php'; ?>


<!---begin of Mobile View Here   only from Domain Team-->

<?php include 'menu.php'; ?>

<!---End of Mobile View Here   only from Domain Team-->


<div class="container-fluid mt--7">
  <!-- Table -->
  <div class="row">
    <div class="col">
      <div class="card shadow">
        <div class="card-header border-0">
          <h3 class="mb-0"><a href="" class="btn btn-danger">CUSTOMER SUPPORT</a></h3>
          <?php if (isset($msg)) echo $msg;  ?>
        </div>







        <form class="form-group" method="POST">
          <div class="modal-header">

            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Compose Message</h4>
          </div>
          <select class="form-control primary" name="sender_name">
            <option class="form-control">Sender</option>
            <option class="form-control" style="background-color:#000" value="Customer Care">Customer Care</option>
            <option class="form-control" style="background-color:#000" value="Account Officer">Account Officer</option>
            <option class="form-control" style="background-color:#000" value="Service Department">Service Department</option>
          </select>
          <select class="form-control primary" name="reci_name">
            <option class="form-control">To</option>
            <?php while ($show = $account->fetch(PDO::FETCH_ASSOC)) { ?>
              <option class="form-control" style="background-color:#000" value="<?php echo $show['uname']; ?>"><?php echo $show['fname']; ?> <?php echo $show['lname']; ?></option>
            <?php } ?>
          </select>
          <div class=" form-control">
            <input type="text" class="form-control input-transparent" name="subject" placeholder="Subject...">
          </div>
          <div class="p-relative">
            <div class="message-options">
              <img src="img/icon/tile-actions.png" alt="">
            </div>
            <textarea class="message-editor form-control" name="msg" placeholder="Message..."></textarea>
          </div>
          <div class="modal-footer m-0">
            <button class="btn" data-dismiss="modal">Cancel</button>
            <button class="btn" type="subit" name="message">Send</button>
          </div>
        </form>








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

  <?php include 'foot.php'; ?>