get total number of hits, some code formating

This commit is contained in:
Uwe Steinmann 2021-11-19 13:49:46 +01:00
parent f2dbe4c18b
commit a4bb363799

View File

@ -127,6 +127,7 @@ function typeahead() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
$fullsearch = $this->params['fullsearch']; $fullsearch = $this->params['fullsearch'];
$total = $this->params['total'];
$totaldocs = $this->params['totaldocs']; $totaldocs = $this->params['totaldocs'];
$totalfolders = $this->params['totalfolders']; $totalfolders = $this->params['totalfolders'];
$attrdefs = $this->params['attrdefs']; $attrdefs = $this->params['attrdefs'];
@ -139,6 +140,7 @@ function typeahead() { /* {{{ */
$enableclipboard = $this->params['enableclipboard']; $enableclipboard = $this->params['enableclipboard'];
$attributes = $this->params['attributes']; $attributes = $this->params['attributes'];
$categories = $this->params['categories']; $categories = $this->params['categories'];
$category = $this->params['category'];
$mimetype = $this->params['mimetype']; $mimetype = $this->params['mimetype'];
$owner = $this->params['owner']; $owner = $this->params['owner'];
$startfolder = $this->params['startfolder']; $startfolder = $this->params['startfolder'];
@ -152,6 +154,7 @@ function typeahead() { /* {{{ */
$expirationdate = $this->params['expirationdate']; $expirationdate = $this->params['expirationdate'];
$statusdate = $this->params['statusdate']; $statusdate = $this->params['statusdate'];
$status = $this->params['status']; $status = $this->params['status'];
$record_type = $this->params['recordtype'];
$this->query = $this->params['query']; $this->query = $this->params['query'];
$orderby = $this->params['orderby']; $orderby = $this->params['orderby'];
$entries = $this->params['searchhits']; $entries = $this->params['searchhits'];
@ -331,8 +334,8 @@ function typeahead() { /* {{{ */
$tmpcatids[] = $tmpcat->getID(); $tmpcatids[] = $tmpcat->getID();
$options = array(); $options = array();
$allcategories = $dms->getDocumentCategories(); $allcategories = $dms->getDocumentCategories();
foreach($allcategories as $category) { foreach($allcategories as $acategory) {
$options[] = array($category->getID(), $category->getName(), in_array($category->getId(), $tmpcatids)); $options[] = array($acategory->getID(), $acategory->getName(), in_array($acategory->getId(), $tmpcatids));
} }
$this->formField( $this->formField(
getMLText("categories"), getMLText("categories"),
@ -471,8 +474,8 @@ function typeahead() { /* {{{ */
$tmpcatids[] = $tmpcat->getID(); $tmpcatids[] = $tmpcat->getID();
$options = array(); $options = array();
$allcategories = $dms->getDocumentCategories(); $allcategories = $dms->getDocumentCategories();
foreach($allcategories as $category) { foreach($allcategories as $acategory) {
$options[] = array($category->getID(), $category->getName(), in_array($category->getId(), $tmpcatids)); $options[] = array($acategory->getID(), $acategory->getName(), in_array($acategory->getId(), $tmpcatids));
} }
$this->formField( $this->formField(
getMLText("category_filter"), getMLText("category_filter"),
@ -486,6 +489,7 @@ function typeahead() { /* {{{ */
) )
); );
} }
if(!isset($facets['status'])) {
$options = array(); $options = array();
if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') {
if($workflowmode == 'traditional') { if($workflowmode == 'traditional') {
@ -510,16 +514,49 @@ function typeahead() { /* {{{ */
'options'=>$options 'options'=>$options
) )
); );
}
if($facets) { if($facets) {
foreach($facets as $facetname=>$values) { foreach($facets as $facetname=>$values) {
$multiple = true;
// if(in_array($facetname, ['owner', 'status', 'mimetype']))
// $multiple = false;
$options = array(); $options = array();
if($facetname == 'owner') {
foreach($values as $v=>$c) {
$uu = $dms->getUserByLogin($v);
if($uu) {
$option = array($uu->getId(), $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($uu->getId(), ${$facetname}))
$option[] = true;
$options[] = $option;
}
}
} elseif($facetname == 'category') {
foreach($values as $v=>$c) {
$cat = $dms->getDocumentCategoryByName($v);
if($cat) {
$option = array($cat->getId(), $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($cat->getId(), ${$facetname}))
$option[] = true;
$options[] = $option;
}
}
} elseif($facetname == 'status') {
foreach($values as $v=>$c) {
$option = array($v, getOverallStatusText($v).' ('.$c.')');
if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true;
$options[] = $option;
}
} else {
foreach($values as $v=>$c) { foreach($values as $v=>$c) {
$option = array($v, $v.' ('.$c.')'); $option = array($v, $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($v, ${$facetname})) if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true; $option[] = true;
$options[] = $option; $options[] = $option;
} }
}
$this->formField( $this->formField(
getMLText($facetname), getMLText($facetname),
array( array(
@ -527,12 +564,12 @@ foreach($facets as $facetname=>$values) {
'id'=>$facetname, 'id'=>$facetname,
'name'=>$facetname."[]", 'name'=>$facetname."[]",
'class'=>'chzn-select', 'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_'.$facetname))), 'attributes'=>array(array('data-placeholder', getMLText('select_'.$facetname)), array('data-allow-clear', 'true')),
'options'=>$options, 'options'=>$options,
'multiple'=>true 'multiple'=>$multiple
) )
); );
} }
} }
$this->contentContainerEnd(); $this->contentContainerEnd();
$this->formSubmit("<i class=\"fa fa-search\"></i> ".getMLText('search')); $this->formSubmit("<i class=\"fa fa-search\"></i> ".getMLText('search'));
@ -562,7 +599,7 @@ foreach($facets as $facetname=>$values) {
} }
} }
*/ */
echo $this->infoMsg(getMLText("search_report", array("doccount" => $totaldocs, "foldercount" => $totalfolders, 'searchtime'=>$searchTime))); echo $this->infoMsg(getMLText("search_report", array("count"=>$total, "doccount" => $totaldocs, "foldercount" => $totalfolders, 'searchtime'=>$searchTime)));
$this->pageList($pageNumber, $totalpages, "../out/out.Search.php", $urlparams); $this->pageList($pageNumber, $totalpages, "../out/out.Search.php", $urlparams);
// $this->contentContainerStart(); // $this->contentContainerStart();