function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     // Publisher Filter
     $allPublishers = $this->getAllPublishers();
     $interface->assign('publisherFilter', $allPublishers);
     $selectedPublisherFilter = null;
     if (isset($_REQUEST['publisherFilter'])) {
         $selectedPublisherFilter = $_REQUEST['publisherFilter'];
     } else {
         $selectedPublisherFilter = array();
     }
     $interface->assign('selectedPublisherFilter', $selectedPublisherFilter);
     $publishers = empty($selectedPublisherFilter) ? $allPublishers : $selectedPublisherFilter;
     $interface->assign('publishers', $publishers);
     // Status Filter
     $allStatuses = $this->getStatuses();
     $interface->assign('statusFilter', $allStatuses);
     $selectedStatusFilter = null;
     if (isset($_REQUEST['statusFilter'])) {
         $selectedStatusFilter = $_REQUEST['statusFilter'];
     } else {
         $selectedStatusFilter = array();
     }
     $interface->assign('selectedStatusFilter', $selectedStatusFilter);
     $statuses = empty($selectedStatusFilter) ? $allStatuses : $selectedStatusFilter;
     $interface->assign('statuses', $statuses);
     // Date range filter (default to 1 hour ago)
     $startDate = new DateTime();
     $startDate->modify("-1 hour");
     if (isset($_REQUEST['startDate']) && strlen($_REQUEST['startDate']) > 0) {
         $startDate = DateTime::createFromFormat('m/d/Y', $_REQUEST['startDate']);
         $startDate->setTime(0, 0, 0);
     }
     $interface->assign('startDate', $startDate->format('m/d/Y'));
     $endDate = isset($_REQUEST['endDate']) && strlen($_REQUEST['endDate']) > 0 ? DateTime::createFromFormat('m/d/Y', $_REQUEST['endDate']) : new DateTime();
     $interface->assign('endDate', $endDate->format('m/d/Y'));
     //Set the end date to the end of the day
     $endDate->setTime(24, 0, 0);
     // create a SQL clause to filter by selected publishers
     $publisherRestriction = null;
     if (isset($_REQUEST['publisherFilter'])) {
         $publishersToShow = array();
         foreach ($_REQUEST['publisherFilter'] as $item) {
             $publishersToShow[] = "'" . mysql_escape_string(strip_tags($item)) . "'";
         }
         if (!empty($publishersToShow)) {
             $publisherRestriction = "publisher IN (" . implode(",", $publishersToShow) . ") ";
         }
     }
     // create a SQL clause to filter by selected statuses
     $statusRestriction = null;
     if (isset($_REQUEST['statusFilter'])) {
         $statusesToShow = array();
         foreach ($_REQUEST['statusFilter'] as $item) {
             $statusesToShow[] = "'" . mysql_escape_string(strip_tags($item)) . "'";
         }
         if (!empty($statusesToShow)) {
             $statusRestriction = "status IN (" . implode(",", $statusesToShow) . ") ";
         }
     }
     // Packaging ID filter
     $packagingIdsToShow = array();
     $packagingIdsRestriction = null;
     if (isset($_REQUEST['packagingIds'])) {
         $packagingIds = explode(',', $_REQUEST['packagingIds']);
         foreach ($packagingIds as $id) {
             if (is_numeric($id)) {
                 $packagingIdsToShow[] = mysql_escape_string(strip_tags($id));
             }
         }
         if (!empty($packagingIdsToShow)) {
             $packagingIdsRestriction = "packagingId IN (" . implode(",", $packagingIdsToShow) . ") ";
         }
         $interface->assign('packagingIds', implode(",", $packagingIdsToShow));
     }
     $importDetails = new EContentImportDetailsEntry();
     $importDetails->whereAdd('dateFound >= ' . $startDate->getTimestamp() . ' AND dateFound < ' . $endDate->getTimestamp());
     if ($publisherRestriction) {
         $importDetails->whereAdd($publisherRestriction);
     }
     if ($statusRestriction) {
         $importDetails->whereAdd($statusRestriction);
     }
     if ($packagingIdsRestriction) {
         $importDetails->whereAdd($packagingIdsRestriction);
     }
     //Check to see if we are exporting to Excel
     if (isset($_REQUEST['exportToExcel'])) {
         $importDetails->find();
         $records = array();
         while ($importDetails->fetch()) {
             $records[] = clone $importDetails;
         }
         $this->exportToExcel($records);
     }
     // Number of row per page
     $perPage = 20;
     $datagrid =& new Structures_DataGrid($perPage);
     $datagrid->setDefaultSort(array('filename' => 'ASC'));
     $datagrid->bind($importDetails);
     $datagrid->addColumn(new Structures_DataGrid_Column('File Name', 'filename', 'filename', null, null, array($this, 'printFileNameAsLinkToDetails')));
     $datagrid->addColumn(new Structures_DataGrid_Column('Publisher', 'publisher', 'publisher'));
     $datagrid->addColumn(new Structures_DataGrid_Column('Date Found', 'dateFound', 'dateFound', null, null, array($this, 'printDateFound')));
     $datagrid->addColumn(new Structures_DataGrid_Column('Packaging ID', 'packagingId', 'packagingId'));
     $datagrid->addColumn(new Structures_DataGrid_Column('Status', 'status', 'status'));
     $datagrid->addColumn(new Structures_DataGrid_Column('Details', 'details', 'details', null, null, array($this, 'printLinkToDetails')));
     $interface->assign('importDetailsTable', $datagrid->getOutput());
     // create pager
     $params = array();
     if (isset($_REQUEST['startDate']) && strlen($_REQUEST['startDate']) > 0) {
         $params['startDate'] = $startDate->format('m/d/Y');
     }
     if (isset($_REQUEST['endDate']) && strlen($_REQUEST['endDate']) > 0) {
         $params['endDate'] = $endDate->format('m/d/Y');
     }
     if (!empty($selectedPublisherFilter)) {
         $params['publisherFilter'] = $selectedPublisherFilter;
     }
     if (!empty($selectedStatusFilter)) {
         $params['statusFilter'] = $selectedStatusFilter;
     }
     if (!empty($packagingIdsToShow)) {
         $params['packagingIds'] = implode(',', $packagingIdsToShow);
     }
     $options = array('totalItems' => $datagrid->getRecordCount(), 'fileName' => $configArray['Site']['path'] . '/EContent/EContentImportDetails?' . http_build_query($params) . '&page=%d', 'perPage' => $perPage);
     $pager = new VuFindPager($options);
     $interface->assign('pageLinks', $pager->getLinks());
     $interface->setTemplate('eContentImportDetails.tpl');
     $interface->setPageTitle('eContent Import Details');
     $interface->display('layout.tpl');
 }
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     // Publisher Filter
     $allPublishers = $this->getAllPublishers();
     $interface->assign('publisherFilter', $allPublishers);
     $selectedPublisherFilter = null;
     if (isset($_REQUEST['publisherFilter'])) {
         $selectedPublisherFilter = $_REQUEST['publisherFilter'];
     } else {
         $selectedPublisherFilter = array();
     }
     $interface->assign('selectedPublisherFilter', $selectedPublisherFilter);
     $publishers = empty($selectedPublisherFilter) ? $allPublishers : $selectedPublisherFilter;
     $interface->assign('publishers', $publishers);
     // Date range filter
     $period = isset($_REQUEST['period']) ? $_REQUEST['period'] : 'week';
     if ($period == 'week') {
         $periodLength = new DateInterval("P1W");
     } elseif ($period == 'day') {
         $periodLength = new DateInterval("P1D");
     } elseif ($period == 'month') {
         $periodLength = new DateInterval("P1M");
     } elseif ($period == 'year') {
         $periodLength = new DateInterval("P1Y");
     }
     $interface->assign('period', $period);
     $endDate = isset($_REQUEST['endDate']) && strlen($_REQUEST['endDate']) > 0 ? DateTime::createFromFormat('m/d/Y', $_REQUEST['endDate']) : new DateTime();
     $interface->assign('endDate', $endDate->format('m/d/Y'));
     if (isset($_REQUEST['startDate']) && strlen($_REQUEST['startDate']) > 0) {
         $startDate = DateTime::createFromFormat('m/d/Y', $_REQUEST['startDate']);
     } else {
         if ($period == 'day') {
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 7 days");
         } elseif ($period == 'week') {
             //Get the sunday after this
             $endDate->setISODate($endDate->format('Y'), $endDate->format("W"), 0);
             $endDate->modify("+7 days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 28 days");
         } elseif ($period == 'month') {
             $endDate->modify("+1 month");
             $numDays = $endDate->format("d");
             $endDate->modify(" -{$numDays} days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 6 months");
         } elseif ($period == 'year') {
             $endDate->modify("+1 year");
             $numDays = $endDate->format("m");
             $endDate->modify(" -{$numDays} months");
             $numDays = $endDate->format("d");
             $endDate->modify(" -{$numDays} days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 2 years");
         }
     }
     $interface->assign('startDate', $startDate->format('m/d/Y'));
     //Set the end date to the end of the day
     $endDate->setTime(24, 0, 0);
     $startDate->setTime(0, 0, 0);
     //Create the periods that are being represented
     $periods = array();
     $periodEnd = clone $endDate;
     while ($periodEnd >= $startDate) {
         array_unshift($periods, clone $periodEnd);
         $periodEnd->sub($periodLength);
     }
     // create a SQL clause to filter by selected publishers
     $publisherRestriction = null;
     if (isset($_REQUEST['publisherFilter'])) {
         $publishersToShow = array();
         foreach ($_REQUEST['publisherFilter'] as $item) {
             $publishersToShow[] = "'" . mysql_escape_string(strip_tags($item)) . "'";
         }
         if (!empty($publishersToShow)) {
             $publisherRestriction = "publisher IN (" . implode(",", $publishersToShow) . ") ";
         }
     }
     //Load data for each period
     $periodDataByPublisher = array();
     $periodDataByStatus = array();
     for ($i = 0; $i < count($periods) - 1; $i++) {
         $periodStart = clone $periods[$i];
         //$periodStart->setTime(0,0,0);
         $periodEnd = clone $periods[$i + 1];
         //$periodStart->setTime(23, 59, 59);
         $periodDataByPublisher[$periodStart->getTimestamp()] = array();
         $periodDataByStatus[$periodStart->getTimestamp()] = array();
         //Determine how many files were imported by publisher
         $importDetails = new EContentImportDetailsEntry();
         $importDetails->selectAdd();
         $importDetails->selectAdd('COUNT(id) as numberOfFiles, publisher');
         $importDetails->whereAdd('dateFound >= ' . $periodStart->getTimestamp() . ' AND dateFound < ' . $periodEnd->getTimestamp());
         if ($publisherRestriction) {
             $importDetails->whereAdd($publisherRestriction);
         }
         $importDetails->groupBy('publisher');
         $importDetails->orderBy('publisher');
         $importDetails->find();
         while ($importDetails->fetch()) {
             $periodDataByPublisher[$periodStart->getTimestamp()][$importDetails->publisher] = $importDetails->numberOfFiles;
         }
         //Determine how many files were imported by status
         $importDetails = new EContentImportDetailsEntry();
         $importDetails->selectAdd();
         $importDetails->selectAdd('COUNT(id) as numberOfFiles, status');
         $importDetails->whereAdd('dateFound >= ' . $periodStart->getTimestamp() . ' AND dateFound < ' . $periodEnd->getTimestamp());
         if ($publisherRestriction) {
             $importDetails->whereAdd($publisherRestriction);
         }
         $importDetails->groupBy('status');
         $importDetails->orderBy('status');
         $importDetails->find();
         while ($importDetails->fetch()) {
             $periodDataByStatus[$periodStart->getTimestamp()][$importDetails->status] = $importDetails->numberOfFiles;
         }
     }
     $interface->assign('periodDataByPublisher', $periodDataByPublisher);
     $interface->assign('periodDataByStatus', $periodDataByStatus);
     //Get a list of all of the statuses that will be shown
     $statusesUntranslated = $this->getStatuses();
     $statuses = array();
     foreach ($statusesUntranslated as $status) {
         $statuses[$status] = translate($status);
     }
     $interface->assign('statuses', $statuses);
     //Check to see if we are exporting to Excel
     if (isset($_REQUEST['exportToExcel'])) {
         $this->exportToExcel($periodDataByPublisher, $publishers, $periodDataByStatus, $statuses);
     } else {
         //Generate the graphs
         $this->generateGraphByPublisher($periodDataByPublisher, $periods, $publishers);
         $this->generateGraphByStatus($periodDataByStatus, $periods, $statuses);
     }
     $interface->setTemplate('eContentImportSummary.tpl');
     $interface->setPageTitle('eContent Import Summary Report');
     $interface->display('layout.tpl');
 }
示例#3
0
 function getEContentImportDetails()
 {
     global $interface;
     $id = $_REQUEST['id'];
     require_once ROOT_DIR . '/sys/eContent/EContentImportDetailsEntry.php';
     $logEntry = new EContentImportDetailsEntry();
     $logEntry->id = $id;
     if ($logEntry->find(true)) {
         $interface->assign('logEntry', $logEntry);
         return $interface->fetch('EContent/eContentImportDetailsEntry.tpl');
     } else {
         return "We could not find a import log entry with that id.";
     }
 }