Admin_PortalController::portletModificationStatisticsAction PHP Метод

portletModificationStatisticsAction() публичный Метод

    public function portletModificationStatisticsAction()
    {
        $db = \Pimcore\Db::get();
        $days = 31;
        $startDate = mktime(23, 59, 59, date("m"), date("d"), date("Y"));
        $currentDate = $startDate;
        $data = [];
        for ($i = 0; $i < $days; $i++) {
            // documents
            $end = $startDate - $i * 86400;
            $start = $end - 86399;
            $o = $db->fetchOne("SELECT COUNT(*) AS count FROM objects WHERE o_modificationDate > " . $start . " AND o_modificationDate < " . $end);
            $a = $db->fetchOne("SELECT COUNT(*) AS count FROM assets WHERE modificationDate > " . $start . " AND modificationDate < " . $end);
            $d = $db->fetchOne("SELECT COUNT(*) AS count FROM documents WHERE modificationDate > " . $start . " AND modificationDate < " . $end);
            $date = new \DateTime();
            $date->setTimestamp($start);
            $data[] = ["timestamp" => $start, "datetext" => $date->format("Y-m-d"), "objects" => (int) $o, "documents" => (int) $d, "assets" => (int) $a];
        }
        $data = array_reverse($data);
        $this->_helper->json(["data" => $data]);
    }