* @copyright Copyright (c) 2020-2021 * @license https://opensource.org/licenses/MIT MIT License * @link https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code * @version 1.0 */ session_start(); require_once './config/config.php'; require_once 'includes/auth_validate.php'; //Get DB instance. function is defined in config.php $db = getDbInstance(); //Get Dynamic qr code rows $numQrcode_dynamic = $db->getValue ("dynamic_qrcodes", "count(*)"); //Get Static qr code rows $numQrcode_static = $db->getValue ("static_qrcodes", "count(*)"); $total = $numQrcode_dynamic + $numQrcode_static; //Get Total scan $numScan = $db->query("SELECT sum(scan) FROM dynamic_qrcodes"); /* CREATED CHART *///I initialize the variables that will contain the daily values to 0 otherwise in the foreach loop they will be reset every time //Get the number of DYNAMIC qr code created in 7 days and total scan $createdQrcode_dynamic = $db->query("select `created_at`, `scan` from dynamic_qrcodes where `created_at` > curdate()-7;"); $dynamic_today = $dynamic_oneday = $dynamic_twoday = $dynamic_threeday = $dynamic_fourday = $dynamic_fiveday = $dynamic_sixday = 0; $scan_today = $scan_oneday = $scan_twoday = $scan_threeday = $scan_fourday = $scan_fiveday = $scan_sixday = 0; foreach ($createdQrcode_dynamic as $row) { switch (substr($row['created_at'],0,10)){ case date("Y-m-d",mktime(0,0,0,date('m'),date('d'),date('Y'))): $dynamic_today++; $scan_today = $scan_today + $row['scan']; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-1,date('Y'))): $dynamic_oneday++; $scan_oneday = $scan_oneday + $row['scan']; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-2,date('Y'))): $dynamic_twoday++; $scan_twoday = $scan_twoday + $row['scan']; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-3,date('Y'))): $dynamic_threeday++; $scan_threeday = $scan_threeday + $row['scan']; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-4,date('Y'))): $dynamic_fourday++; $scan_fourday = $scan_fourday + $row['scan']; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-5,date('Y'))): $dynamic_fiveday++; $scan_fiveday = $scan_fiveday + $row['scan']; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-6,date('Y'))): $dynamic_sixday++; $scan_sixday = $scan_sixday + $row['scan']; break; //I increase the daily variable and update the variable of the number of scans for a given day } } /* SCAN CHART */ //Get the number of STATIC qr code created in 7 days $createdQrcode_static = $db->query("select `created_at` from static_qrcodes where `created_at` > curdate()-7;"); $static_today = $static_oneday = $static_twoday = $static_threeday = $static_fourday = $static_fiveday = $static_sixday = 0; foreach ($createdQrcode_static as $row) { switch (substr($row['created_at'],0,10)){ case date("Y-m-d",mktime(0,0,0,date('m'),date('d'),date('Y'))): $static_today++; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-1,date('Y'))): $static_oneday++; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-2,date('Y'))): $static_twoday++; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-3,date('Y'))): $static_threeday++; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-4,date('Y'))): $static_fourday++; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-5,date('Y'))): $static_fiveday++; break; case date("Y-m-d",mktime(0,0,0,date('m'),date('d')-6,date('Y'))): $static_sixday++; break; } } ?> PHP Qr Code Generator v1.0

Dashboard

Total qr codes
Dynamic Qr codes
Static QR codes
Total Scans

Qr codes created in the last week

Total qr code created

Dynamic Static

Scan Graph