function countOrdersByUser($userID, $startDate = NULL, $endDate = NULL)
{
    $user = new \OnlineOrders\User($userID);
    $clinics = $user->getClinics();
    $orderCount = 0;
    foreach ($clinics as $clinic) {
        $orders = getOrdersByClinic($clinic->get('clinicID'), $startDate, $endDate);
        //$orderCount = $orderCount + $orders.count();
        foreach ($orders as $order) {
            $orderCount++;
        }
    }
    return $orderCount;
}
  **/
 $app->get('/logout/', function () use($app) {
     $user = getCurrentUser();
     $user->logout();
     $app->redirect('/login/');
 });
 /**
  *
  * @AJAX Action - Builds array of order information for a specific clinic and returns JSON
  * string to be processed by Javascript in the browser
  *
  **/
 $app->get('/buildOrderTable/:id/:start/:end/', function ($clinicID, $startDate, $endDate) use($app) {
     $orderArray = array();
     $endDate = date('Y-m-d', strtotime($endDate . ' + 1 day'));
     $orders = getOrdersByClinic($clinicID, $startDate, $endDate);
     foreach ($orders as $order) {
         $dateString = $order['AdmissionDate'];
         $date = date('l M j, Y', strtotime($order['AdmissionDate']));
         $imageID = getCMIImageID($order['PatientNum'], $order['CMNDate']);
         if ($imageID) {
             $date = '<a href="/WebCMIViewer/CMIViewer.aspx?imageid=' . $imageID . '" target="blank">' . $date . '</a>';
         }
         //$patient = new \OnlineOrders\Patient($order['PatientID']);
         $newOrderLink = '<a href="/webOrders/new/' . $clinicID . '/' . $order['PatientID'] . '" title="Create New Order Based on This One"><i class="fa fa-edit fa-fw"></i></a>';
         $trackingLink = '<a data-toggle="modal" href="#trackingModal" class="trackingLink">' . $order['TrackingNum'] . '</a>';
         if ($order['Status'] == 'Canceled') {
             $status = 'Unable to Ship';
         } else {
             $status = $order['Status'];
         }