Update for BeWellWell my account en media_upload
This commit is contained in:
@@ -93,6 +93,77 @@ function send_mail($to, $subject, $message, $attachment, $attachment_name){
|
||||
|
||||
}
|
||||
|
||||
function sendIcsCalendar($appointment, $to, $subject = 'Appointment Confirmation') {
|
||||
|
||||
include_once dirname(__FILE__,2).'/settings/config_redirector.php';
|
||||
|
||||
// Create unique identifier for the event
|
||||
$uid = md5(uniqid(rand(), true)) . '@' . $_SERVER['HTTP_HOST'];
|
||||
|
||||
// Format times for ICS
|
||||
$start_time = date('Ymd\THis\Z', strtotime($appointment['starttime']));
|
||||
$end_time = date('Ymd\THis\Z', strtotime($appointment['endtime']));
|
||||
$now = date('Ymd\THis\Z');
|
||||
|
||||
// Get appointment details with defaults
|
||||
$description = isset($appointment['description']) ? $appointment['description'] : 'Your appointment has been confirmed.';
|
||||
$location = isset($appointment['location']) ? $appointment['location'] : 'TBD';
|
||||
$summary = isset($appointment['title']) ? $appointment['title'] : $subject;
|
||||
|
||||
// Create ICS content
|
||||
$ics_content = "BEGIN:VCALENDAR\r\n";
|
||||
$ics_content .= "VERSION:2.0\r\n";
|
||||
$ics_content .= "PRODID:-//AssetMgt//AppointmentSystem//EN\r\n";
|
||||
$ics_content .= "CALSCALE:GREGORIAN\r\n";
|
||||
$ics_content .= "METHOD:REQUEST\r\n";
|
||||
$ics_content .= "BEGIN:VEVENT\r\n";
|
||||
$ics_content .= "DTSTART:" . $start_time . "\r\n";
|
||||
$ics_content .= "DTEND:" . $end_time . "\r\n";
|
||||
$ics_content .= "DTSTAMP:" . $now . "\r\n";
|
||||
$ics_content .= "UID:" . $uid . "\r\n";
|
||||
$ics_content .= "CREATED:" . $now . "\r\n";
|
||||
$ics_content .= "DESCRIPTION:" . $description . "\r\n";
|
||||
$ics_content .= "LAST-MODIFIED:" . $now . "\r\n";
|
||||
$ics_content .= "LOCATION:" . $location . "\r\n";
|
||||
$ics_content .= "SEQUENCE:0\r\n";
|
||||
$ics_content .= "STATUS:CONFIRMED\r\n";
|
||||
$ics_content .= "SUMMARY:" . $summary . "\r\n";
|
||||
$ics_content .= "TRANSP:OPAQUE\r\n";
|
||||
$ics_content .= "END:VEVENT\r\n";
|
||||
$ics_content .= "END:VCALENDAR\r\n";
|
||||
|
||||
// Use PHPMailer for ICS calendar invitation
|
||||
$mail = new PHPMailer();
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->isSMTP();
|
||||
$mail->Host = email_host_name;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = email;
|
||||
$mail->Password = email_outgoing_pw;
|
||||
$mail->SMTPSecure = email_outgoing_security;
|
||||
$mail->Port = email_outgoing_port;
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
$mail->setFrom(email, mail_from);
|
||||
$mail->addAddress($to);
|
||||
$mail->addReplyTo(email_reply_to);
|
||||
|
||||
// PRIMARY METHOD: Set as content type (preferred)
|
||||
$mail->ContentType = 'text/calendar; method=REQUEST; charset=UTF-8';
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $ics_content;
|
||||
|
||||
// ALTERNATIVE: Also add as attachment for fallback
|
||||
$mail->addStringAttachment($ics_content, 'appointment.ics', 'base64', 'text/calendar');
|
||||
|
||||
if (!$mail->send()) {
|
||||
$tab = array('error' => 'Mailer Error: ' . $mail->ErrorInfo);
|
||||
debuglog(json_encode($tab));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// Global functions
|
||||
//------------------------------------------
|
||||
@@ -4372,7 +4443,7 @@ function generateDealerInformation($token){
|
||||
);
|
||||
|
||||
if (isset($response[$key]) && (empty($response[$key]) || $response[$key] == '')) {
|
||||
$new_content['rowID'] = encodeUuid($response['rowID']);
|
||||
$new_content['rowID'] = $response['rowID'];
|
||||
$new_content[$key] = $generated_content[$key];
|
||||
}
|
||||
}
|
||||
@@ -4494,4 +4565,39 @@ function processPostContent(array $post_content): array
|
||||
}
|
||||
|
||||
return $post_content;
|
||||
}
|
||||
|
||||
function checkAndInsertIdentityDealer($pdo, $identityUserkey) {
|
||||
try {
|
||||
$stmt = $pdo->prepare('SELECT id, email FROM identity WHERE userkey = ?');
|
||||
$stmt->execute([$identityUserkey]);
|
||||
$identity = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$identity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare('SELECT rowID FROM dealers WHERE email = ?');
|
||||
$stmt->execute([$identity['email']]);
|
||||
$dealer = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$dealer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$checkStmt = $pdo->prepare('SELECT COUNT(*) as count FROM identity_dealers WHERE dealer_id = ? AND identity_id = ?');
|
||||
$checkStmt->execute([$dealer['rowID'], $identity['id']]);
|
||||
$result = $checkStmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result['count'] == 0) {
|
||||
$insertStmt = $pdo->prepare('INSERT INTO identity_dealers (dealer_id, identity_id) VALUES (?, ?)');
|
||||
return $insertStmt->execute([$dealer['rowID'], $identity['id']]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log('Database error in checkAndInsertIdentityDealer: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user