I've upload a php script I wrote that will output the logic behind a group availability calculation. It can be downloaded here CalculateOrionAvail.php
There are 5 config variable that need to be set at the start of the script to connect to your Orion database.
The script is in production at our organization running on a LAMP server using freetds as the MsSQL database interface. If ran on a windows box, I can probably assist in configuration.
I've also attached the script here.