Notice: ABPro's Stripe payment processor uses the Legacy Checkout and is not SCA compatible. read more..

How-To

Admin notification on Timeout


This code modification will send an email to Admin when bookings timeout.

 

Note:

Every time a booking screen is opened, ABPro checks to see if any bookings are pending and need to being set to Timeout.
This is done with a single line of SQL and has no effect on the time it takes to open a booking screen.

The modification below will additionally send an email to admin if any bookings are being timed out, as such the time to load the booking screen will increase if an email needs to be sent. The email is only sent if bookings are being timed out, so the delay on opening the booking screen will only happen occasionally.

 

Edit file: \components\com_rsappt_pro3\functions2.php

Around line 988 look for the function purgeStalePayPalBookings($minutes_to_stale)

The function starts like this..

 

New code to insert at location shown above..

    $database = JFactory::getDBO();

// HOW-TO code STARTS here
$sql = "SELECT id_requests FROM #__sv_apptpro3_requests ".
    " WHERE request_status = 'pending' ".
    " AND DATE_ADD(created, INTERVAL ".$minutes_to_stale." MINUTE) < NOW()";
try{
    $database->setQuery($sql);
    $purge_ids = $database->loadColumn();
} catch (RuntimeException $e) {
    logIt($e->getMessage(), "functions2", "", "");
    echo JText::_('RS1_SQL_ERROR');
    exit;
}

if(count($purge_ids) > 0 ){
    $str_ids = implode(",", $purge_ids);
    echo $str_ids;
    $sql = 'SELECT * FROM #__sv_apptpro3_config';
    try{
        $database->setQuery($sql);
        $apptpro_config = NULL;
        $apptpro_config = $database -> loadObject();
    } catch (RuntimeException $e) {
        logIt($e->getMessage(), "purgeStalePayPalBookings", "", "");
        echo JText::_('RS1_SQL_ERROR');
        exit;
    }
    $mailer = JFactory::getMailer();
    try{
        $mailer->setSender(array($apptpro_config->mailFROM,null));
    }
    catch (Exception $e){
        logIt("Error on setting email FROM address: ".$e->getMessage(), "purgeStalePayPalBookings", "", "");
        return false;
    }
    $mailer->addRecipient($apptpro_config->mailTO);
    $mailer->setSubject('Booking(s) timed out');
    $mailer->setBody("Booking(s) set to status Timeout: ". $str_ids);
    $send = $mailer->Send();
    if ( $send !== true ) {
        logIt('Error sending email: '.$e->getMessage(), "purgeStalePayPalBookings", "", "");
    }
}
// HOW-TO code ENDS here

    $sql = "UPDATE #__sv_apptpro3_requests SET request_status = 'timeout' ".

 

 The email sent to Admin will contain the booking ids that were set to Timeout..