<?php
//-------------------------------------- include main function main files and library -----------------------------
include('mail/PHPMailerAutoload.php');
// define("app_name", "Truck Around", true);
// define("fromName", "Truck Around", true);
// define("app_logo", "http://youngdecadeprojects.biz/2018/truck_around/admin/placeholder/logo.png", true);
// define("app_bg", "http://youngdecadeprojects.biz/2018/truck_around/admin/placeholder/logo.png", true);

function mailSend($email, $fromName, $subject, $mailBody)
{

  //print_r($email);
  // print_r($fromName);
  // print_r($subject);
  // print_r($mailBody);
  //exit;
    include('config.php');
    //-------------------------------- php mail functions ---------------------------------------
    $mail = new PHPMailer;

    $mail->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    );

    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = $mail_host;  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = $mail_username;                 // SMTP username
    $mail->Password = $mail_password;                           // SMTP password
    $mail->SMTPSecure = $mail_SMTPSecure;                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = $mail_port;                                       // TCP port to connect to
    $mail->From = $mail_from;
    $mail->FromName = $fromName;
    $mail->addAddress($email);   // Add a recipient

    $mail->isHTML(true);   // Add a recipient


    $mail->Subject = $subject;
    $mail->Body    = $mailBody;

    //-------------------------------------- check mail response send or not in proper ----------------------------
    if ($mail->send()) {
        $mailResponse = 'yes';
    } else {
        $mailResponse = 'no';
    }
    return $mailResponse;



    // ==================================
    //Always set content-type when sending HTML email
    // $headers = "MIME-Version: 1.0" . "\r\n";
    // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    // // More headers
    // $headers .= 'From: <test_email@youngdecadeprojects.biz>' . "\r\n";

    // $response = mail($email,$subject,$mailBody,$headers);
    // if($response==1) {
    // $mailResponse = 'yes';
    // }
    // else {
    // $mailResponse = 'no';
    // }
    // return $mailResponse;
    // ==================================

} //-------------------- mailsend function closed 


/*$email = 'aishwarya.youngdecade@gmail.com';
$fromName = 'Test Email';
$subject = 'Subject ';
$guid='12345';
$mailBody = 'hello Aishwarya';
echo $mailResponse = mailSend($email, $fromName, $subject, $mailBody); 

*/ // Forgor password mail body

//-------------------------------------- forgot password mail body -----------------------------------------
function mailBodyForgotPasswordData($postData)
{
    $year =date('Y');
    $body="";
    $body .= '<!DOCTYPE html>
        <head>
            <meta name="viewport" content="width=device-width, initial-scale=1" />
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Welcome to ' . $postData['app_name'] . '</title>
        </head>
    
        <body style="margin: 0;	padding: 0; background-color:#000000; font-size:13px; color:#444; font-family:Arial, Helvetica, sans-serif;	padding-top:70px; padding-bottom:70px;">
            <table  cellspacing="0" cellpadding="0" align="center" width="768" class="outer-tbl" style="margin:0 auto;">
            <tr>
                <td class="pad-l-r-b" style="background-color:#FFFFFF; padding:0 70px 40px;">
                    <table cellpadding="0" cellspacing="0" class="full-wid">
            
                    </table>
    
                <table cellpadding="0" cellspacing="0"  style="width:100%; background-color:#FFFFFF; border-radius:4px;box-shadow:0 0 20px #ccc;margin-top:40px">
            <tr>
            <td>
                <table border="0" style="margin:0; width:100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="logo" style="padding:40px 0 30px 0; background-color:#3906A5; text-align:center; border-bottom:1px solid #E1E1E1">
                            <img src="' . $postData['app_logo'] . '" alt="" width="25%"  height="18%"  style=" padding:5px">
                            <h1 style="color:white;">Forgot Your Password</h1>
                        </td>
                    </tr>
                    <tr><td></td></tr>	
                    <tr>
                        <td class="content" style="padding:40px 40px;">
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                            Hello ' . ucwords($postData['name']) . '</p>
            
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">' . $postData['mailContent'] . '</p>
            
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                            Regards,                  	
                            </p>
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                            ' . $postData['app_name'] . '            	
                            </p>
                        </td>
                    </tr>
                    <tr>              	
                        <td  style="background:#3906A5; padding-bottom:60px;">
                            <table style="width:100%" border="0" cellspacing="0" cellpadding="0" class="full-wid" align="center">
                            <tr>
                                <td>	 
                                    <div style="margin:0 auto; text-align:center; padding:0 100px" class="foot-items">
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#fbfbfb; margin-top:40px; line-height:20px;">
                                        &#169; '.$year.'  ' . $postData['app_name'] . ' |  All right Reserved
                                        </p>
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#fbfbfb; line-height:20px; margin-bottom:40px;">
                                        Disclaimers can be made up out of statements covering different legal aspects. Below are some sample disclaimer statements that can be used for each aspect independently.
                                        </p>
                                    </div>
                                </td>
                            </tr>
                        
                </table>
                </td>
            </tr>              
    </table>
    </td>
    </tr>        
    </table>
    </td>
    </tr>   
    </table>
    </body>
    </html>';
    return $body;
}

function mailBodyCreatePasswordData($postData)
{
    $year =date('Y');
    $body="";
    $body .= '<!DOCTYPE html>
        <head>
            <meta name="viewport" content="width=device-width, initial-scale=1" />
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Welcome to ' . $postData['app_name'] . '</title>
        </head>
    
        <body style="margin: 0; padding: 0; background-color:#000000; font-size:13px; color:#444; font-family:Arial, Helvetica, sans-serif; padding-top:70px; padding-bottom:70px;">
            <table  cellspacing="0" cellpadding="0" align="center" width="768" class="outer-tbl" style="margin:0 auto;">
            <tr>
                <td class="pad-l-r-b" style="background-color:#FFFFFF; padding:0 70px 40px;">
                    <table cellpadding="0" cellspacing="0" class="full-wid">
            
                    </table>
    
                <table cellpadding="0" cellspacing="0"  style="width:100%; background-color:#FFFFFF; border-radius:4px;box-shadow:0 0 20px #ccc;margin-top:40px">
            <tr>
            <td>
                <table border="0" style="margin:0; width:100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="logo" style="padding:40px 0 30px 0; background-color:#3906A5; text-align:center; border-bottom:1px solid #E1E1E1">
                            <img src="' . $postData['app_logo'] . '" alt="" width="25%"  height="18%"  style=" padding:5px">
                            <h1 style="color:white;">Create Your Password</h1>
                        </td>
                    </tr>
                    <tr><td></td></tr>  
                    <tr>
                        <td class="content" style="padding:40px 40px;">
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                            Hello ' . ucwords($postData['name']) . '</p>
            
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">' . $postData['mailContent'] . '</p>

                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                        Login URL: ' . $postData['app_url'] . '</p>
        
            
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                            Regards,                    
                            </p>
                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                            ' . $postData['app_name'] . '               
                            </p>
                        </td>
                    </tr>
                    <tr>                
                        <td  style="background:#3906A5; padding-bottom:60px;">
                            <table style="width:100%" border="0" cellspacing="0" cellpadding="0" class="full-wid" align="center">
                            <tr>
                                <td>     
                                    <div style="margin:0 auto; text-align:center; padding:0 100px" class="foot-items">
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#fbfbfb; margin-top:40px; line-height:20px;">
                                        &#169; '.$year.'  ' . $postData['app_name'] . ' |  All right Reserved
                                        </p>
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#fbfbfb; line-height:20px; margin-bottom:40px;">
                                        Disclaimers can be made up out of statements covering different legal aspects. Below are some sample disclaimer statements that can be used for each aspect independently.
                                        </p>
                                    </div>
                                </td>
                            </tr>
                        
                </table>
                </td>
            </tr>              
    </table>
    </td>
    </tr>        
    </table>
    </td>
    </tr>   
    </table>
    </body>
    </html>';
    return $body;
}

// Function for Order Book 


function mailBodyApprove($postData)
{ 
     $year =date('Y');
    $body ='';
    $body .= '<!DOCTYPE html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Welcome to ' . $postData['app_name'] . '</title>
    </head>

    <body style="margin: 0;	padding: 0; background-color:#040f46; font-size:13px; color:#444; font-family:Arial, Helvetica, sans-serif;	padding-top:70px; padding-bottom:70px;">
        <table  cellspacing="0" cellpadding="0" align="center" width="768" class="outer-tbl" style="margin:0 auto;">
        <tr>
            <td class="pad-l-r-b" style="background-color:#FFFFFF; padding:0 70px 40px;">
                <table cellpadding="0" cellspacing="0" class="full-wid">
        
                </table>

            <table cellpadding="0" cellspacing="0"  style="width:100%; background-color:#FFFFFF; border-radius:4px;box-shadow:0 0 20px #ccc;margin-top:40px">
        <tr>
        <td>
            <table border="0" style="margin:0; width:100%" cellpadding="0" cellspacing="0">
                <tr style="background:#3906A5;">
                    <td class="logo" style="padding:40px 0 30px 0; text-align:center; border-bottom:1px solid #000000">
                        <img src="' . $postData['app_logo'] . '" alt="" width="25%"  height="18%" style=" padding:5px">
                        
                    </td>
                </tr>
                <tr><td></td></tr>	
                <tr>
                    <td class="content" style="padding:40px 40px;">
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                        Hello ' . ucwords($postData['name']) . '</p>
        
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">' . $postData['mailContent'] . '</p>
        
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                        Regards,                  	
                        </p>
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                       ' . $postData['app_name'] . '            	
                        </p>
                    </td>
                </tr>
                <tr>              	
                    <td  style="background:#3906A5; padding-bottom:60px;">
                        <table style="width:100%" border="0" cellspacing="0" cellpadding="0" class="full-wid" align="center">
                        <tr>
                            <td>	 
                                <div style="margin:0 auto; text-align:center; padding:0 100px" class="foot-items">
                                    <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#fffcfc; margin-top:40px; line-height:20px;">
                                    &#169; '.$year.'  ' . $postData['app_name'] . '  |  All right Reserved
                                    </p>
                                    <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#fffcfc; line-height:20px; margin-bottom:40px;">
                                    Disclaimers can be made up out of statements covering different legal aspects. Below are some sample disclaimer statements that can be used for each aspect independently.
                                    </p>
                                </div>
                            </td>
                        </tr>
            </table>
            </td>
        </tr>              
</table>
</td>
</tr>        
</table>
</td>
</tr>   
</table>
</body>
</html>';
    return $body;
}


function mailBodyContactUs($postData)
{       $year =date('Y');
       $body ='';    
       $body .= '<!DOCTYPE html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Welcome to '.$postData['app_name'].'</title>
    </head>

    <body style="margin: 0; padding: 0; background-color:#ECEFF1; font-size:13px; color:#444; font-family:Arial, Helvetica, sans-serif; padding-top:70px; padding-bottom:70px;">
        <table  cellspacing="0" cellpadding="0" align="center" width="768" class="outer-tbl" style="margin:0 auto;">
            <tr>
                <td class="pad-l-r-b" style="background-color:#ECEFF1; padding:0 70px 40px;">
                    <table cellpadding="0" cellspacing="0" class="full-wid">
                    
                    </table>
                    
                    <table cellpadding="0" cellspacing="0"  style="width:100%; background-color:#FFFFFF; border-radius:4px; 
                    box-shadow:0 0 20px #ccc;">
                        <tr>
                            <td>
                                <table border="0" style="margin:0; width:100%" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td class="logo" style="padding:40px 0 30px 0; text-align:center; border-bottom:1px solid #E1E1E1;background-color:#3906A5">
                                            <img src="'.$postData['app_logo'].'" alt="" width="25%"  height="18%" style=" padding:5px">
                                            <h1 style="color:white">'.$postData['mail_title'].'</h1>
                                        </td>
                                    </tr>
                                    <tr><td></td></tr>      
                                    <tr>
                                        <td class="content" style="padding:40px 40px;">
                                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                                                Hello '.ucwords($postData['name']).'</p>

                                               
                                            
                                                <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                                                '.$postData['message'].'</p>
                                                
                                        
                                            <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333333; margin-top:0">
                                                '.$postData['app_name'].'                       
                                            </p>
                                        </td>
                                    </tr>

                                     <td  style="background:#3906A5; padding-bottom:60px;">
                            <table style="width:100%" border="0" cellspacing="0" cellpadding="0" class="full-wid" align="center">
                            <tr>
                                <td>     
                                    <div style="margin:0 auto; text-align:center; padding:0 100px" class="foot-items">
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#fbfbfb; margin-top:40px; line-height:20px;">
                                        &#169; '.$year.'  ' . $postData['app_name'] . ' |  All right Reserved
                                        </p>
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#fbfbfb; line-height:20px; margin-bottom:40px;">
                                        Disclaimers can be made up out of statements covering different legal aspects. Below are some sample disclaimer statements that can be used for each aspect independently.
                                        </p>
                                    </div>
                                </td>
                            </tr>
                                                  
                                </table>
                            </td>
                        </tr>        
                    </table>
                </td>
            </tr>          
        </table>
    </body>
</html>';
        return $body;
    }


function mailBodyChangePassword($postData)
{ 
     $year =date('Y');
    $body ='';
    $body .= '<!DOCTYPE html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Welcome to ' . $postData['app_name'] . '</title>
    </head>

    <body style="margin: 0; padding: 0; background-color:#040f46; font-size:13px; color:#444; font-family:Arial, Helvetica, sans-serif; padding-top:70px; padding-bottom:70px;">
        <table  cellspacing="0" cellpadding="0" align="center" width="768" class="outer-tbl" style="margin:0 auto;">
        <tr>
            <td class="pad-l-r-b" style="background-color:#FFFFFF; padding:0 70px 40px;">
                <table cellpadding="0" cellspacing="0" class="full-wid">
        
                </table>

            <table cellpadding="0" cellspacing="0"  style="width:100%; background-color:#FFFFFF; border-radius:4px;box-shadow:0 0 20px #ccc;margin-top:40px">
        <tr>
        <td>
            <table border="0" style="margin:0; width:100%" cellpadding="0" cellspacing="0">
                <tr style="background:#3906A5;">
                    <td class="logo" style="padding:40px 0 30px 0; text-align:center; border-bottom:1px solid #000000">
                        <img src="' . $postData['app_logo'] . '" alt="" width="25%"  height="18%" style=" padding:5px">
                        
                    </td>
                </tr>
                <tr><td></td></tr>  
                <tr>
                    <td class="content" style="padding:40px 40px;">
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                        Hello ' . ucwords($postData['name']) . '</p>
        
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">' . $postData['mailContent'] . '</p>

                         <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                        New Password : ' . $postData['password'] . '</p>

                         <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                        Login URL: ' . $postData['app_url'] . '</p>
        
        
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                        Regards,                    
                        </p>
                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#060b48; margin-top:0">
                       ' . $postData['app_name'] . '                
                        </p>
                    </td>
                </tr>
                <tr>                
                    <td  style="background:#3906A5; padding-bottom:60px;">
                        <table style="width:100%" border="0" cellspacing="0" cellpadding="0" class="full-wid" align="center">
                        <tr>
                            <td>     
                                <div style="margin:0 auto; text-align:center; padding:0 100px" class="foot-items">
                                    <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#fffcfc; margin-top:40px; line-height:20px;">
                                    &#169; '.$year.'  ' . $postData['app_name'] . '  |  All right Reserved
                                    </p>
                                    <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#fffcfc; line-height:20px; margin-bottom:40px;">
                                    Disclaimers can be made up out of statements covering different legal aspects. Below are some sample disclaimer statements that can be used for each aspect independently.
                                    </p>
                                </div>
                            </td>
                        </tr>
            </table>
            </td>
        </tr>              
</table>
</td>
</tr>        
</table>
</td>
</tr>   
</table>
</body>
</html>';
    return $body;
}
