get category, mimetype and facets from view

This commit is contained in:
Uwe Steinmann 2020-09-14 09:34:39 +02:00
parent 3191fa9310
commit 0979d2bd54

View File

@ -80,7 +80,9 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
$enablefullsearch = $this->params['enablefullsearch'];
$enableclipboard = $this->params['enableclipboard'];
$attributes = $this->params['attributes'];
$category = $this->params['category'];
$categories = $this->params['categories'];
$mimetype = $this->params['mimetype'];
$owner = $this->params['owner'];
$startfolder = $this->params['startfolder'];
$startdate = $this->params['startdate'];
@ -93,6 +95,7 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
$this->query = $this->params['query'];
$orderby = $this->params['orderby'];
$entries = $this->params['searchhits'];
$facets = $this->params['facets'];
$totalpages = $this->params['totalpages'];
$pageNumber = $this->params['pagenumber'];
$searchTime = $this->params['searchtime'];
@ -155,13 +158,16 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
<tr>
<td><?php printMLText("owner");?>:</td>
<td>
<select class="chzn-select" name="ownerid" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<?php
$ownerids = array_map(function($n) {return $n->getId();}, $owner);
?>
<select class="chzn-select" name="owner[]" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<option value=""></option>
<?php
foreach ($allUsers as $userObj) {
if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin()))
continue;
print "<option value=\"".$userObj->getID()."\" ".(($owner && $userObj->getID() == $owner->getID()) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n";
print "<option value=\"".$userObj->getLogin()."\" ".(in_array($userObj->getId(), $ownerids) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n";
}
?>
</select>
@ -237,7 +243,7 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
}
}
}
if($categories)
if($category)
$openfilterdlg = true;
if($status)
$openfilterdlg = true;
@ -257,7 +263,7 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
<tr>
<td><?php printMLText("category");?>:</td>
<td>
<select class="chzn-select" name="categoryids[]" multiple="multiple" data-placeholder="<?php printMLText('select_category'); ?>" data-no_results_text="<?php printMLText('unknown_document_category'); ?>">
<select class="chzn-select" name="category[]" multiple="multiple" data-placeholder="<?php printMLText('select_category'); ?>" data-no_results_text="<?php printMLText('unknown_document_category'); ?>">
<!--
<option value="-1"><?php printMLText("all_categories");?>
-->
@ -266,7 +272,7 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
foreach($categories as $tmpcat)
$tmpcatids[] = $tmpcat->getID();
foreach ($allCats as $catObj) {
print "<option value=\"".$catObj->getID()."\" ".(in_array($catObj->getID(), $tmpcatids) ? "selected" : "").">" . htmlspecialchars($catObj->getName()) . "\n";
print "<option value=\"".$catObj->getName()."\" ".(in_array($catObj->getID(), $tmpcatids) ? "selected" : "").">" . htmlspecialchars($catObj->getName()) . "\n";
}
?>
</select>
@ -397,21 +403,24 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
-->
</td>
</tr>
<?php if(!isset($facets['owner'])) { ?>
<tr>
<td><?php printMLText("owner");?>:</td>
<td>
<select class="chzn-select" name="ownerid" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<select class="chzn-select" name="owner[]" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<option value=""></option>
<?php
foreach ($allUsers as $userObj) {
if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin()))
continue;
print "<option value=\"".$userObj->getID()."\" ".(($owner && $userObj->getID() == $owner->getID()) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n";
print "<option value=\"".$userObj->getLogin()."\" ".(in_array($userObj->getLogin(), $owner) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n";
}
?>
</select>
</td>
</tr>
<?php } ?>
<?php if(!isset($facets['category'])) { ?>
<tr>
<td><?php printMLText("category_filter");?>:</td>
<td>
@ -430,6 +439,54 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style {
</select>
</td>
</tr>
<?php } ?>
<tr>
<td><?php printMLText("status");?>:</td>
<td>
<?php if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { ?>
<?php if($workflowmode == 'traditional') { ?>
<label class="checkbox" for='pendingReview'><input type="checkbox" id="pendingReview" name="pendingReview" value="1" <?php echo in_array(S_DRAFT_REV, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_DRAFT_REV);?></label>
<?php } ?>
<label class="checkbox" for='pendingApproval'><input type="checkbox" id="pendingApproval" name="pendingApproval" value="1" <?php echo in_array(S_DRAFT_APP, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_DRAFT_APP);?></label>
<?php } elseif($workflowmode == 'advanced') { ?>
<label class="checkbox" for='inWorkflow'><input type="checkbox" id="inWorkflow" name="inWorkflow" value="1" <?php echo in_array(S_IN_WORKFLOW, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_IN_WORKFLOW);?></label>
<?php } ?>
<label class="checkbox" for='released'><input type="checkbox" id="released" name="released" value="1" <?php echo in_array(S_RELEASED, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_RELEASED);?></label>
<label class="checkbox" for='rejected'><input type="checkbox" id="rejected" name="rejected" value="1" <?php echo in_array(S_REJECTED, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_REJECTED);?></label>
<label class="checkbox" for='obsolete'><input type="checkbox" id="obsolete" name="obsolete" value="1" <?php echo in_array(S_OBSOLETE, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_OBSOLETE);?></label>
<label class="checkbox" for='expired'><input type="checkbox" id="expired" name="expired" value="1" <?php echo in_array(S_EXPIRED, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_EXPIRED);?></label>
</td>
</tr>
<?php if($facets) {
foreach($facets as $facetname=>$values) {
?>
<tr>
<td><?= getMLText($facetname);?>:</td>
<td>
<?php
$options = array();
foreach($values as $v=>$c) {
$option = array($v, $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true;
$options[] = $option;
}
$this->formField(
null,
array(
'element'=>'select',
'id'=>$facetname,
'name'=>$facetname."[]",
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_'.$facetname))),
'options'=>$options,
'multiple'=>true
)
);
?>
</td>
</tr>
<?php }} ?>
<tr>
<td></td><td><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td>
</tr>