file_put_contents($folder . '/device-brands.html', $generate->getHtml());
echo '.';
/*
 * detected - deviceTypes
 */
$sql = "\n    SELECT\n        resDeviceType as name,\n        uaId,\n    \tuaString,\n        COUNT(1) `detectionCount`\n    FROM result\n    JOIN userAgent\n        ON uaId = userAgent_id\n    WHERE\n        provider_id IN('" . implode('\', \'', $proIds) . "')\n        AND resDeviceType IS NOT NULL\n    GROUP BY resDeviceType\n";
$result = $conn->fetchAll($sql);
$generate = new SimpleList($entityManager);
$generate->setTitle('Detected device types');
$generate->setElements($result);
file_put_contents($folder . '/device-types.html', $generate->getHtml());
echo '.';
/*
 * detected - botNames
 */
$sql = "\n    SELECT\n        resBotName as name,\n        uaId,\n    \tuaString,\n        COUNT(1) `detectionCount`\n    FROM result\n    JOIN userAgent\n        ON uaId = userAgent_id\n    WHERE\n        provider_id IN('" . implode('\', \'', $proIds) . "')\n        AND resBotName IS NOT NULL\n    GROUP BY resBotName\n";
$result = $conn->fetchAll($sql);
$generate = new SimpleList($entityManager);
$generate->setTitle('Detected bot names');
$generate->setElements($result);
file_put_contents($folder . '/bot-names.html', $generate->getHtml());
echo '.';
/*
 * detected - botTypes
 */
$sql = "\n    SELECT\n        resBotType as name,\n        uaId,\n    \tuaString,\n        COUNT(1) `detectionCount`\n    FROM result\n    JOIN userAgent\n        ON uaId = userAgent_id\n    WHERE\n        provider_id IN('" . implode('\', \'', $proIds) . "')\n        AND resBotType IS NOT NULL\n    GROUP BY resBotType\n";
$result = $conn->fetchAll($sql);
$generate = new SimpleList($entityManager);
$generate->setTitle('Detected bot types');
$generate->setElements($result);
file_put_contents($folder . '/bot-types.html', $generate->getHtml());
        $generate = new SimpleList();
        $generate->setTitle('No device type found - ' . $provider->name . ' <small>' . $provider->version . '</small>');
        $generate->setElements($result);
        file_put_contents($folder . '/device-types.html', $generate->getHtml());
    }
    /*
     * botNames
     */
    if ($provider->canDetectBotName === true) {
        echo '.';
        $sql = "\n            SELECT\n            \tresBotName as name,\n            \tuaId,\n            \tuaString,\n            \t(\n            \t\tSELECT\n            \t\t\tCOUNT(1)\n            \t\tFROM result as res2\n                    WHERE\n            \t\t\tres2.userAgent_id = uaId\n                        AND res2.resBotName IS NOT NULL\n            \t\t\tAND res2.provider_id != '" . $provider->id . "'\n                ) as `detectionCount`\n            FROM result\n            JOIN userAgent\n            \tON uaId = userAgent_id\n            WHERE\n            \tprovider_id = '" . $provider->id . "'\n                AND resResultFound = 1\n                AND resBotIsBot IS NOT NULL\n                AND resBotName IS NULL\n        ";
        $result = $conn->fetchAll($sql);
        $generate = new SimpleList();
        $generate->setTitle('No bot name found - ' . $provider->name . ' <small>' . $provider->version . '</small>');
        $generate->setElements($result);
        file_put_contents($folder . '/bot-names.html', $generate->getHtml());
    }
    /*
     * botTypes
     */
    if ($provider->canDetectBotType === true) {
        echo '.';
        $sql = "\n            SELECT\n            \tresBotType as name,\n            \tuaId,\n            \tuaString,\n            \t(\n            \t\tSELECT\n            \t\t\tCOUNT(1)\n            \t\tFROM result as res2\n                    WHERE\n            \t\t\tres2.userAgent_id = uaId\n                        AND res2.resBotType IS NOT NULL\n            \t\t\tAND res2.provider_id != '" . $provider->id . "'\n                ) as `detectionCount`\n            FROM result\n            JOIN userAgent\n            \tON uaId = userAgent_id\n            WHERE\n            \tprovider_id = '" . $provider->id . "'\n                AND resResultFound = 1\n                AND resBotIsBot IS NOT NULL\n                AND resBotType IS NULL\n        ";
        $result = $conn->fetchAll($sql);
        $generate = new SimpleList();
        $generate->setTitle('No bot type found - ' . $provider->name . ' <small>' . $provider->version . '</small>');
        $generate->setElements($result);
        file_put_contents($folder . '/bot-types.html', $generate->getHtml());
    }
    echo PHP_EOL;
}