2024-10-16 19:18:52 +05:30
< ? php
include 'includes/config/config.php' ;
include 'email_sender.php' ;
error_log ( " _____________________REFERRAL START_______________________ " );
$appointment_id = $_POST [ 'appointment_id' ];
if ( $appointment_id != null && $appointment_id != '' ) {
// $appointment_id = 425;
$emailmsg = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'REFERRAL_EMAIL_MSG' );
$root = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'APP_ROOT' );
// $patientBasicData = "Emp Name , Emp Code , Age , Contact Number , Depart , Employee name ,";
echo $PatientBasicDetailsSql = " SELECT p.patient_name , p.emp_code , p.dob , p.primary_phone , d.dept_name , des.designation_name , ec.employer_contractor_name FROM patient_master p INNER JOIN employee_appointment ea ON p.id = ea.emp_id INNER JOIN employer_contractor ec ON p.employer_contractor_id = ec.id INNER JOIN department d ON p.dept_id = d.dept_id INNER JOIN designation des ON p.designation_id = des.designation_id WHERE ea.appointment_id = $appointment_id " ;
error_log ( " PatientBasicDetailsSql : " . $PatientBasicDetailsSql );
$PatientBasicDetailsRes = mysqli_query ( $conn , $PatientBasicDetailsSql );
$RowpatientQuery = mysqli_fetch_assoc ( $PatientBasicDetailsRes );
$patientBasicData = " <strong>Name of Patient :</strong> " . $RowpatientQuery [ 'patient_name' ] . " <strong>Age :</strong> " . calculateAge ( $RowpatientQuery [ 'dob' ]) . " <br><br><strong>Employee Code :</strong> " . $RowpatientQuery [ 'emp_code' ] . " <br><br><strong> Contact Number :</strong> " . $RowpatientQuery [ 'primary_phone' ] . " <br><br><strong>Department :</strong> " . $RowpatientQuery [ 'dept_name' ] . " <br><br><strong>Employer name :</strong> " . $RowpatientQuery [ 'employer_contractor_name' ] . " <br><br><strong>Designation :</strong> " . $RowpatientQuery [ 'designation_name' ];
$messageBody = <<< HTML
<! DOCTYPE html >
< html lang = " en " >
< head >
< meta charset = " UTF-8 " >
< meta name = " viewport " content = " width=device-width, initial-scale=1.0 " >
< title > Referral Email </ title >
< style >
/* Add your styles here */
body {
font - family : Arial , sans - serif ;
background - color : #f4f4f4;
margin : 0 ;
padding : 0 ;
}
. container {
background - color : #fff;
}
h1 , p {
margin - bottom : 20 px ;
}
a {
color : #007bff;
text - decoration : none ;
font - weight : bold ;
}
</ style >
</ head >
< body >
< div class = " container " >
< h1 > Referral </ h1 >
< p > Hello , </ p >
< p > { $patientBasicData } </ p >
< p > { $emailmsg } </ p >
< p > Click < a href = " { $root } /referral_latter_pdf.php?appointment_id= { $appointment_id } " > here </ a > to visit view certificate </ p >
< p > Thank you ! </ p >
</ div >
</ body >
</ html >
HTML ;
echo $messageBody ;
$to = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'REFERRAL_EMAIL_TO' );
$cc = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'REFERRAL_EMAIL_CC' );
$from = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'email_sender' );
$host = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'email_host' );
$user = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'email_username' );
$pass = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'email_password' );
$port = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'email_port' );
$auth = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'SMTP_AUTH' );
$SMTPSecure = getFieldFromTable ( 'value' , 'config' , 'key_name' , 'SMTPSecure' );
2024-11-28 10:28:59 +05:30
$subject = " " ;
$remarks = " " ;
2024-10-16 19:18:52 +05:30
error_log ( 'User ' . $user );
error_log ( 'Pass ' . $pass );
error_log ( 'Host ' . $host );
error_log ( 'Port ' . $port );
error_log ( 'Auth ' . $auth );
2024-11-28 10:28:59 +05:30
// if(send_mail($to, $cc, $subject, $messageBody, $remarks, $from, $host, $auth, $user, $pass, $port, $SMTPSecure) == "Message has been sent"){
2024-10-16 19:18:52 +05:30
2024-11-28 10:28:59 +05:30
// }
// $Insertreferral_emailSql = "INSERT INTO `referral_email`(`emp_code` , `appointment_id` , `email`) VALUES ('{$RowpatientQuery['emp_code']}', '{$appointment_id}' , '{$to}');";
2024-10-16 19:18:52 +05:30
2024-11-28 10:28:59 +05:30
// mysqli_query($conn, $Insertreferral_emailSql);
2024-10-16 19:18:52 +05:30
}
error_log ( " _____________________REFERRAL END_______________________ " );