Qr codes created in the last week
Total qr code created
where("id_owner", $_SESSION['user_id']); $db->orWhere ("id_owner", NULL, 'IS'); } $numQrcode_dynamic = $db->getValue("dynamic_qrcodes", "count(*)"); //Get Static qr code rows if(!$is_full_visibility) { $db->where("id_owner", $_SESSION['user_id']); $db->orWhere ("id_owner", NULL, 'IS'); } $numQrcode_static = $db->getValue("static_qrcodes", "count(*)"); $total = $numQrcode_dynamic + $numQrcode_static; //Get Total scan if(!$is_full_visibility) { $db->where("id_owner", $_SESSION['user_id']); $db->orWhere ("id_owner", NULL, 'IS'); } $numScan = $db->getOne("dynamic_qrcodes", "sum(scan) as numScan"); /* 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 if(!$is_full_visibility) $createdQrcode_dynamic = $db->query("select `created_at`, `scan` from " . DATABASE_PREFIX . "dynamic_qrcodes where `created_at` > curdate()-7 AND (`id_owner`= " . $_SESSION['user_id'] . " OR `id_owner` IS NULL);"); else $createdQrcode_dynamic = $db->query("select `created_at`, `scan` from ".DATABASE_PREFIX."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 if(!$is_full_visibility) $createdQrcode_static = $db->query("select `created_at` from " . DATABASE_PREFIX . "static_qrcodes where `created_at` > curdate()-7 AND (`id_owner`=" . $_SESSION['user_id'] . " OR `id_owner` IS NULL);"); else $createdQrcode_static = $db->query("select `created_at` from ".DATABASE_PREFIX."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; } } ?>
Total qr code created