diff --git a/admin/themes/default/items/search-form.php b/admin/themes/default/items/search-form.php
index c092e8607c..d5546d3ab4 100755
--- a/admin/themes/default/items/search-form.php
+++ b/admin/themes/default/items/search-form.php
@@ -132,9 +132,9 @@
formSelect(
- 'collection',
+ 'collection[]',
@$_REQUEST['collection'],
- array('id' => 'collection-search'),
+ array('id' => 'collection-search', 'multiple' => true),
get_table_options('Collection', null, array('include_no_collection' => true))
);
?>
@@ -148,10 +148,10 @@
formSelect(
- 'type',
+ 'type[]',
@$_REQUEST['type'],
- array('id' => 'item-type-search'),
- get_table_options('ItemType')
+ array('id' => 'item-type-search', 'multiple' => true),
+ get_table_options('ItemType', null, array('include_no_item_type' => true))
);
?>
diff --git a/application/models/Table/Item.php b/application/models/Table/Item.php
index c7c6383ad2..0a62cfede8 100644
--- a/application/models/Table/Item.php
+++ b/application/models/Table/Item.php
@@ -197,10 +197,11 @@ public function filterByCollection($select, $collections)
if (is_numeric($collection)) {
return (int) $collection;
}
- return;
+ return '';
}, $collections);
- $hasEmpty = in_array(null, $collectionIds);
+ // strict check to skip placeholder (empty string)
+ $hasEmpty = in_array(null, $collectionIds, true);
$collectionIds = array_filter($collectionIds);
if (!empty($collectionIds)) {
$select->joinLeft(
@@ -245,10 +246,11 @@ public function filterByItemType($select, $types)
if (is_string($type)) {
return $type;
}
- return;
+ return '';
}, $types);
- $hasEmpty = in_array(null, $typeIdsOrNames);
+ // strict check to skip placeholder (empty string)
+ $hasEmpty = in_array(null, $typeIdsOrNames, true);
$typeIdsOrNames = array_filter($typeIdsOrNames);
if ($typeIdsOrNames) {
$select->joinLeft(array(
diff --git a/application/models/Table/ItemType.php b/application/models/Table/ItemType.php
index 128c425047..14aa25f812 100644
--- a/application/models/Table/ItemType.php
+++ b/application/models/Table/ItemType.php
@@ -22,4 +22,14 @@ public function findByName($itemTypeName)
$select->where($this->_name . '.name = ?', $itemTypeName);
return $this->fetchObject($select);
}
+
+ public function findPairsForSelectForm(array $options = array())
+ {
+ $pairs = parent::findPairsForSelectForm($options);
+
+ if (isset($options['include_no_item_type']) && $options['include_no_item_type']) {
+ $pairs = array(__('No Item Type')) + $pairs;
+ }
+ return $pairs;
+ }
}
diff --git a/application/views/helpers/ItemSearchFilters.php b/application/views/helpers/ItemSearchFilters.php
index 78ea811a8d..496a2bbca6 100644
--- a/application/views/helpers/ItemSearchFilters.php
+++ b/application/views/helpers/ItemSearchFilters.php
@@ -38,22 +38,39 @@ public function itemSearchFilters(array $params = null)
switch ($key) {
case 'type':
$filter = 'Item Type';
- $itemType = $db->getTable('ItemType')->find($value);
- if ($itemType) {
- $displayValue = $itemType->name;
+ $value = (array) $value;
+ $displayValues = array();
+ $noIndex = array_search('0', $value, true);
+ if ($noIndex !== false) {
+ $displayValues[] = __('No Item Type');
+ unset($value[$noIndex]);
}
+ if (!empty($value)) {
+ $itemTypes = $db->getTable('ItemType')->findBy(array('id' => $value));
+ if ($itemTypes) {
+ $displayValues[] = implode(', ', pluck('name', $itemTypes));
+ }
+ }
+ $displayValue = implode(', ', $displayValues);
break;
case 'collection':
- if ($value === '0') {
- $displayValue = __('No Collection');
- break;
+ $value = (array) $value;
+ $displayValues = array();
+ $noIndex = array_search('0', $value, true);
+ if ($noIndex !== false) {
+ $displayValues[] = __('No Collection');
+ unset($value[$noIndex]);
}
-
- $collection = $db->getTable('Collection')->find($value);
- if ($collection) {
- $displayValue = metadata($collection, 'display_title', array('no_escape' => true));
+ if (!empty($value)) {
+ $collections = $db->getTable('Collection')->findBy(array('id' => $value));
+ if ($collections) {
+ $displayValues[] = implode(', ', array_map(function($collection) {
+ return metadata($collection, 'display_title', array('no_escape' => true));
+ }, $collections));
+ }
}
+ $displayValue = implode(', ', $displayValues);
break;
case 'user':
diff --git a/application/views/scripts/items/search-form.php b/application/views/scripts/items/search-form.php
index 985c396fab..8b0f024e67 100755
--- a/application/views/scripts/items/search-form.php
+++ b/application/views/scripts/items/search-form.php
@@ -121,9 +121,9 @@