mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-29 04:57:20 +00:00
move excel export into view
This commit is contained in:
parent
8c77b0734c
commit
8d8f3e51fb
|
@ -360,7 +360,7 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
|
|||
$pageNumber = (int) $_GET["pg"];
|
||||
}
|
||||
elseif (!strcasecmp($_GET["pg"], "all")) {
|
||||
// $limit = 0;
|
||||
$pageNumber = "all";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,65 +393,25 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
|
|||
}
|
||||
}
|
||||
}
|
||||
if(isset($_GET['export']) && $_GET['export']) {
|
||||
include("../inc/inc.ClassDownloadMgr.php");
|
||||
$downmgr = new SeedDMS_Download_Mgr();
|
||||
foreach($entries as $entry) {
|
||||
if(get_class($entry) == $dms->getClassname('document')) {
|
||||
$downmgr->addItem($entry->getLatestContent());
|
||||
}
|
||||
}
|
||||
$filename = tempnam('/tmp', '');
|
||||
if(isset($_GET['includecontent']) && $_GET['includecontent']) {
|
||||
$downmgr->createArchive($filename);
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Content-Length: " . filesize($filename));
|
||||
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\"");
|
||||
header("Content-Type: application/zip");
|
||||
header("Cache-Control: must-revalidate");
|
||||
} else {
|
||||
$downmgr->createToc($filename);
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Content-Length: " . filesize($filename));
|
||||
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".xls\"");
|
||||
header("Content-Type: application/vnd.ms-excel");
|
||||
header("Cache-Control: must-revalidate");
|
||||
}
|
||||
|
||||
readfile($filename);
|
||||
unlink($filename);
|
||||
exit;
|
||||
}
|
||||
|
||||
$totalPages = (int) (count($entries)/$limit);
|
||||
if(count($entries)%$limit)
|
||||
$totalPages++;
|
||||
if (!isset($_GET["pg"]) || strcasecmp($_GET["pg"], "all"))
|
||||
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
||||
// }}}
|
||||
}
|
||||
|
||||
// -------------- Output results --------------------------------------------
|
||||
|
||||
if(count($entries) == 1) {
|
||||
$entry = $entries[0];
|
||||
if(get_class($entry) == $dms->getClassname('document')) {
|
||||
header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID());
|
||||
exit;
|
||||
} elseif(get_class($entry) == $dms->getClassname('folder')) {
|
||||
header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID());
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
|
||||
if($view) {
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
|
||||
if($view) {
|
||||
$view->setParam('accessobject', $accessop);
|
||||
$view->setParam('query', $query);
|
||||
$view->setParam('searchhits', $entries);
|
||||
$view->setParam('totalpages', $totalPages);
|
||||
$view->setParam('pagenumber', $pageNumber);
|
||||
$view->setParam('limit', $limit);
|
||||
$view->setParam('searchtime', $searchTime);
|
||||
$view->setParam('urlparams', $_GET);
|
||||
$view->setParam('cachedir', $settings->_cacheDir);
|
||||
|
@ -486,6 +446,5 @@ if(count($entries) == 1) {
|
|||
$view->setParam('timeout', $settings->_cmdTimeout);
|
||||
$view($_GET);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -62,12 +62,47 @@ $(document).ready( function() {
|
|||
$this->printDeleteDocumentButtonJs();
|
||||
} /* }}} */
|
||||
|
||||
function export() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$entries = $this->params['searchhits'];
|
||||
|
||||
include("../inc/inc.ClassDownloadMgr.php");
|
||||
$downmgr = new SeedDMS_Download_Mgr();
|
||||
foreach($entries as $entry) {
|
||||
if(get_class($entry) == $dms->getClassname('document')) {
|
||||
$extracols = $this->callHook('extraDownloadColumns', $entry);
|
||||
$downmgr->addItem($entry->getLatestContent(), $extracols);
|
||||
}
|
||||
}
|
||||
$filename = tempnam('/tmp', '');
|
||||
if(isset($_GET['includecontent']) && $_GET['includecontent']) {
|
||||
$downmgr->createArchive($filename);
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Content-Length: " . filesize($filename));
|
||||
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\"");
|
||||
header("Content-Type: application/zip");
|
||||
header("Cache-Control: must-revalidate");
|
||||
} else {
|
||||
$downmgr->createToc($filename);
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Content-Length: " . filesize($filename));
|
||||
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".xls\"");
|
||||
header("Content-Type: application/vnd.ms-excel");
|
||||
header("Cache-Control: must-revalidate");
|
||||
}
|
||||
|
||||
readfile($filename);
|
||||
unlink($filename);
|
||||
} /* }}} */
|
||||
|
||||
function show() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$fullsearch = $this->params['fullsearch'];
|
||||
$totaldocs = $this->params['totaldocs'];
|
||||
$totalfolders = $this->params['totalfolders'];
|
||||
$limit = $this->params['limit'];
|
||||
$attrdefs = $this->params['attrdefs'];
|
||||
$allCats = $this->params['allcategories'];
|
||||
$allUsers = $this->params['allusers'];
|
||||
|
@ -99,6 +134,20 @@ $(document).ready( function() {
|
|||
$previewconverters = $this->params['previewconverters'];
|
||||
$timeout = $this->params['timeout'];
|
||||
|
||||
if(count($entries) == 1) {
|
||||
$entry = $entries[0];
|
||||
if(get_class($entry) == $dms->getClassname('document')) {
|
||||
header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID());
|
||||
exit;
|
||||
} elseif(get_class($entry) == $dms->getClassname('folder')) {
|
||||
header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($pageNumber != 'all')
|
||||
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
||||
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
|
||||
|
||||
$this->htmlStartPage(getMLText("search_results"));
|
||||
|
@ -256,7 +305,7 @@ $(document).ready( function() {
|
|||
<td><?= getMLText('content') ?></td><td><label class="checkbox inline"><input id="includecontent" type="checkbox" name="includecontent" value="1"> <?php printMLText("include_content"); ?></label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td><td><a id="export" class="btn" href="<?= $_SERVER['REQUEST_URI']."&export=1" ?>"><i class="icon-download"></i> Export</a></td>
|
||||
<td></td><td><a id="export" class="btn" href="<?= $_SERVER['REQUEST_URI']."&action=export" ?>"><i class="icon-download"></i> Export</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user