<?php

function send_welcome_email($user)
{
    $msg = "<p style='text-align:center;'><img style='max-width:200px; max-height:150px;' src='".asset("assets/img/logo.png")."'/> </p> <br></br><hr>".
    "<h4> <b> Congratulations </b>,". $user->fullnames(). "<br><br>
    You have successfully registered for <b> " . academy_program()->theme. " </b>
           <br> <br>
           You will receive a mail from us prior to the start of the class which 
           will have all information you need including the class links.
                <br><hr>
                Thank you for signing up ! <hr> <br> <br>".
                app_name()." team </h4>";
    $subject = app_name(). " Registration successful !";
    send_email( $user->email, $user->fullnames(), $subject, $msg );
}

function send_program_details_email($user)
{
    $msg = "<p style='text-align:center;'><img style='max-width:200px; max-height:150px;' src='".asset("assets/img/logo.png")."'/> </p> <br></br><hr>".
    "<h3> <b> Hi, ". $user->fullnames(). "</b><br><br>
          <b> " . academy_program()->theme. " is set to begin soon, I know you are excited ! </b>
           <br> <br>
          <b> Click on the Join Link to access the class. </b>
            <br> ".
           " <p> Class Period: ". academy_program()->starts_in ."</p> ".
           " <p> Join Link: ". academy_program()->slack_link ."</p> ".
           " <p> Class Time: ". academy_program()->class_time . "</p> 
           
           <br><br>
           <p> All other information will be shared during the class </p>
           ".     
                "<br><br><hr>
                Best regards! <hr> <br> <br>".
                app_name()." team </h3>";
    $subject = app_name(). " Class Details !";
    send_email( $user->email, $user->fullnames(), $subject, $msg );
}

function send_login_email($login = '')
{
    $ip_info = user_ip_details();
    //if( $login->ip_info ) $ip_info = json_decode( $login->ip_info );
    try{
        $msg = "<h4> You recently logged into your account with Ip address:".$ip_info->ip_address. "</h4> <br><br>".
               "<p> Log in Details:</p> <hr>".
               "<p> Continent: $ip_info->continent </p>".
               "<p> Country: $ip_info->country </p>".
               "<p> Approx. State: $ip_info->state </p>".
               "<p> Approx. City: $ip_info->city </p>".
               "<p> Date: date('y-m-d h:i:s') </p>";
        $subject = "Account Login !";
        send_email( current_user()->email, current_user()->fullnames(), $subject, $msg );
    }
    catch( Exception $err ){}
} 

function send_reset_password_email( $user, $password = "", $reset_link = "")
{ 
    $msg =      "<h4> Hi, ". $user->fullnames(). "<br><br> 
                 You have made a request to change your password, please click on the link below to change your password !.
                 
                 <br> <br>
                 <b>NB:</b> After you click on the link, your new login default password will be <b> ".$password." </b>
                 <br>
                 This Link will expire in 60 minutes !
                 <br>
                <hr>
                <a href='$reset_link'> Click here </a> <hr> or copy and paste the link below in a browser ! <br> <br>".
                $reset_link. "<hr> <br><br>"
                .app_name()." team </h4>";

    $subject = "Password Reset ! ";
    send_email( $user->email, $user->fullnames(), $subject, $msg );
}
