if ($clinic === end($clinics)) {
             $userQuery .= $clinic->get('clinicID');
         } else {
             $userQuery .= $clinic->get('clinicID') . ", ";
         }
     }
     $userQuery .= ")) AND Inactive = 0 AND UserID NOT IN (:user)";
     //echo $userQuery . '<br />';
     $db = $user->get('dbh');
     $stmt = $db->prepare($userQuery);
     $stmt->execute(array('user' => $userID));
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $users[] = $row;
     }
     foreach ($users as $key => $user) {
         $u = new \OnlineOrders\User($user['UserID']);
         $userClinics = array();
         foreach ($u->getClinics() as $clinic) {
             $userClinics[] = array('ID' => $clinic->get('clinicID'), 'Name' => $clinic->get('clinicInfo')['CompanyName']);
         }
         $jsonClinics = json_encode($userClinics);
         $editLink = '<a href="#" class="editLink" id="editLink' . $key . '" data-clinics="' . htmlentities($jsonClinics, ENT_QUOTES, 'UTF-8') . '"><i class="fa fa-edit fa-fw"></i></a>';
         $firstName = '<span id="firstName' . $key . '">' . $user['FName'] . '</span>';
         $lastName = '<span id="lastName' . $key . '">' . $user['LName'] . '</span>';
         $email = '<span id="email' . $key . '">' . $user['UserID'] . '</span>';
         $userTableArray[] = array('Edit' => $editLink, 'E-Mail' => $email, 'First Name' => $firstName, 'Last Name' => $lastName);
     }
     $userObj = json_encode($userTableArray);
     echo $userObj;
 } else {
     echo 'You are not supposed to be here.';
function countPatientsByUser($userID, $startDate = NULL, $endDate = NULL)
{
    if ($startDate === NULL) {
        $startDate = '2000-01-01';
    }
    if ($endDate === NULL) {
        $endDate = date("Y-m-d");
    }
    $patientCount = 0;
    $user = new \OnlineOrders\User($userID);
    $clinics = $user->getClinics();
    $db = getDBConn(getCurrentUser());
    foreach ($clinics as $clinic) {
        $query1 = $db->prepare("SELECT COUNT(*) FROM (SELECT DISTINCT PatientNum FROM vwClinicAdmissions WHERE ClinicID = :clinicID AND (AdmissionDate BETWEEN CONVERT(DATETIME, :startDate, 102) AND CONVERT(DATETIME, :endDate, 102)) AND (PatientNum IS NOT NULL)) AS temp");
        $query1->execute(array('clinicID' => $clinic['ID'], 'startDate' => $startDate, 'endDate' => $endDate));
        $patientCount = $patientCount + $query1->fetchColumn();
    }
    return $patientCount;
}
* Renders the view to reset a user's password
*
**/
$app->get('/login/resetPassword/', function () use($app) {
    $app->view->setData(array('pageTitle' => 'Password Reset', 'bodyClass' => 'account'));
    $app->render('passwordReset.php');
});
/**
*
* Resets the user's password and returns confirmation
*
**/
$app->get('/login/resetPassword/:userID/', function ($userID) use($app) {
    $password = randomPassword();
    try {
        $user = new \OnlineOrders\User($userID);
        $user->changePassword($password, TRUE);
        $results = sendResetEmail($password, $userID);
        $app->view->setData(array('pageTitle' => 'Advanced Tissue Client Portal Login', 'referrer' => 'resetPassword', 'persistentEmail' => $userID));
        $app->render('loginForm.php');
    } catch (Exception $e) {
        echo $e->getMessage();
    }
});
/**
*
* Register New Account View
*
**/
$app->get('/login/newRegistration/', function () use($app) {
    $app->view->setData(array('pageTitle' => 'New Account Registration', 'bodyClass' => 'account'));