Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By mayowa
#830462
Hi Teams

Good morning
please i want to trigger script on how to send notification to a users two weeks before the expiry date of the vehicle expiry date fill in the form and one week notification script before the expiry date and another script to notify the users on the expiry date

thanks
By ayodelebamgboye
#830550
you can try this
// Get the current date
$currentDate = date('Y-m-d');

// Get the expiry date for vehicles that will expire in two weeks
$twoWeeksExpiryDate = date('Y-m-d', strtotime('+2 weeks'));

// Get the expiry date for vehicles that will expire in one week
$oneWeekExpiryDate = date('Y-m-d', strtotime('+1 week'));

// Get the expiry date for vehicles that will expire today
$expiryDate = $currentDate;

// Get a list of vehicles that will expire in two weeks
$twoWeeksExpiryVehicles = executeQuery("SELECT * FROM vehicles WHERE expiry_date = '{$twoWeeksExpiryDate}'");

// Get a list of vehicles that will expire in one week
$oneWeekExpiryVehicles = executeQuery("SELECT * FROM vehicles WHERE expiry_date = '{$oneWeekExpiryDate}'");

// Get a list of vehicles that will expire today
$expiryVehicles = executeQuery("SELECT * FROM vehicles WHERE expiry_date = '{$expiryDate}'");

// Send notifications for vehicles that will expire in two weeks
foreach ($twoWeeksExpiryVehicles as $vehicle) {
$message = "Hello {$vehicle['user_name']},\n\nYour vehicle with the registration number {$vehicle['registration_number']} will expire in two weeks on {$vehicle['expiry_date']}. Please renew your vehicle registration before the expiry date.\n\nThank you.";
PMFSendMessage(@@APPLICATION, 'admin@example.com', $vehicle['user_email'], '', '', 'Vehicle Expiry Notification', $message);
}

// Send notifications for vehicles that will expire in one week
foreach ($oneWeekExpiryVehicles as $vehicle) {
$message = "Hello {$vehicle['user_name']},\n\nYour vehicle with the registration number {$vehicle['registration_number']} will expire in one week on {$vehicle['expiry_date']}. Please renew your vehicle registration before the expiry date.\n\nThank you.";
PMFSendMessage(@@APPLICATION, 'admin@example.com', $vehicle['user_email'], '', '', 'Vehicle Expiry Notification', $message);
}

// Send notifications for vehicles that will expire today
foreach ($expiryVehicles as $vehicle) {
$message = "Hello {$vehicle['user_name']},\n\nYour vehicle with the registration number {$vehicle['registration_number']} will expire today on {$vehicle['expiry_date']}. Please renew your vehicle registration as soon as possible.\n\nThank you.";
PMFSendMessage(@@APPLICATION, 'admin@example.com', $vehicle['user_email'], '', '', 'Vehicle Expiry Notification', $message);
}
Replace vehicles with the actual name of your database table that contains the vehicle expiry date and user information.

Finally, you can schedule this script to run on a daily basis using a cron job

A Dream11 clone script is a pre-made software solu[…]

A stake clone script is a pre-designed, error-free[…]

The Aviator casino game script clone script replic[…]

The ZED RUN Clone Script by Dappsfirm replicates t[…]