<?php 
include 'config.php'; 

include '../mailer/vendor/autoload.php';

use PHPMailer\PHPMailer\PHPMailer;

require_once "../mailer/PHPMailer.php";
require_once "../mailer/SMTP.php";
require_once "../mailer/Exception.php";

function sendMail($email, $subject, $body){
	global $sitemail, $sitename,$siteurl, $host, $mail_username, $mail_password;

    $message = '<div> 
      <img src="'.$siteurl.'/wp-content/themes/ledger-v2/public/images/logo1.png" width="380" height="90">
      <hr>
      '.$body.'
      <hr>
      <b>Thank You!</b>
      <p><b>Regards '.$sitename.' Team</b></p>
    </div>';

    $mail = new PHPMailer();
    //SMTP Settings (use default cpanel email account)
    $mail->isSMTP();
    $mail->Host = $host; 
    $mail->SMTPAuth = true;
    $mail->Username = $mail_username; // Default cpanel email account
    $mail->Password = $mail_password; // Default cpanel email password
    $mail->Port = 465; // 587
    $mail->SMTPSecure = "ssl"; // tls
    //Email Settings
    $mail->isHTML(true);
    $mail->setFrom($mail_username, $sitename); // Email address/ Bank bane shown to reciever
    $mail->addAddress($email);
    $mail->AddReplyTo($mail_username, $sitename); // Email address/ Bank bane shown to reciever
    $mail->Subject = $subject;
    $mail->MsgHTML($message);
    $send = $mail->Send();
    return $send;
}

function customAlert($case, $content){
    switch ($case) {
      case 'success':
        $mesg =  '<script type="text/javascript">
          $(document).ready(function() {
              swal("Success", "'.$content.'", "success")    
          });
        </script>';
        break;

        case 'error':
          $mesg = '<script type="text/javascript">
              $(document).ready(function() {
                  sweetAlert("Error", "'.$content.'", "error")    
              });
          </script>'; 
        break;
      default:
        break;
    }
  return $mesg;
}

  
function text_input($data) {
  global $link;
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  $data = mysqli_real_escape_string($link,$data);
  return $data;
}
	
function pageRedirect($sec, $route){
  $c = "<meta http-equiv='refresh' Content='".$sec."; url=".$route." ' />";
  return $c;
}

?>