diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 87d39fc66..f90450d76 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -971,7 +971,13 @@ $(document).ready(function() { default: $options = []; foreach($values as $v=>$c) { - $option = array($v, $v); + switch($attrdef->getType()) { + case SeedDMS_Core_AttributeDefinition::type_date: + $option = array($v, getReadableDate($v)); + break; + default: + $option = array($v, $v); + } if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname])) $option[] = true; else @@ -1052,7 +1058,16 @@ $(document).ready(function() { echo ''; } } else { - $oldvalue = is_array($allparams['attributes'][$facetname]) ? implode(',', $allparams['attributes'][$facetname]) : $allparams['attributes'][$facetname]; + if(is_array($allparams['attributes'][$facetname])) { + switch($attrdef->getType()) { + case SeedDMS_Core_AttributeDefinition::type_date: + array_walk($allparams['attributes'][$facetname], function(&$v, $k){$v=getReadableDate($v);}); + break; + } + $oldvalue = implode(',', $allparams['attributes'][$facetname]); + } else { + $oldvalue = $allparams['attributes'][$facetname]; + } unset($allparams['attributes'][$facetname]); $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); $menuitems[] = array('label'=>' '.$dispname.' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); @@ -1065,18 +1080,22 @@ $(document).ready(function() { $allparams = $request->query->all(); if(isset($allparams[$facetname])) { $oldvalue = is_array($allparams[$facetname]) ? implode(',', $allparams[$facetname]) : $allparams[$facetname]; + switch($facetname) { + case 'status': + $oldtransval = getOverallStatusText($oldvalue); + break; + default: + $oldtransval = $oldvalue; + } unset($allparams[$facetname]); $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); - $menuitems[] = array('label'=>' '.getMLText($facetname).' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); + $menuitems[] = array('label'=>' '.getMLText($facetname).' = '.$oldtransval, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); echo ''; } } } if($menuitems) { -// ob_start(); self::showNavigationListWithBadges($menuitems); -// $content = ob_get_clean(); -// $this->printAccordion(getMLText('current_filter'), $content, true); } } echo "

"; @@ -1102,7 +1121,7 @@ $(document).ready(function() { if(empty($allparams['attributes'][$facetname]['from']) && empty($allparams['attributes'][$facetname]['to'])) { $tt = array_keys($values); $content = '
'; - $content .= ' from '; + $content .= ' from '; $content .= ''; $content .= ' to '; $content .= ''; @@ -1112,13 +1131,34 @@ $(document).ready(function() { } } break; + case SeedDMS_Core_AttributeDefinition::type_date: + if($values && (count($values) > 1 || reset($values) < $total)) { + if(empty($allparams['attributes'][$facetname]['from']) && empty($allparams['attributes'][$facetname]['to'])) { + $tt = array_keys($values); + $content = '
'; + $content .= ' from '; + $content .= $this->getDateChooser('', "attributes[".$facetname."][from]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt))); + $content .= ' to '; + $content .= $this->getDateChooser('', "attributes[".$facetname."][to]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt))); + $content .= ''; + $content .= '
'; + $this->printAccordion($dispname, $content); + } + } + break; default: /* See below on an explaination for the if statement */ if($values && (count($values) > 1 || reset($values) < $total)) { $menuitems = array(); arsort($values); foreach($values as $v=>$c) { - $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c); + switch($attrdef->getType()) { + case SeedDMS_Core_AttributeDefinition::type_date: + $menuitems[] = array('label'=>getReadableDate($v), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c); + break; + default: + $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c); + } } ob_start(); self::showNavigationListWithBadges($menuitems); @@ -1136,8 +1176,16 @@ $(document).ready(function() { if($values && (count($values) > 1 || reset($values) < $total)) { $menuitems = array(); arsort($values); - foreach($values as $v=>$c) { - $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c); + switch($facetname) { + case 'status': + foreach($values as $v=>$c) { + $menuitems[] = array('label'=>getOverallStatusText($v), 'link'=>$newrequest->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c); + } + break; + default: + foreach($values as $v=>$c) { + $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c); + } } ob_start(); self::showNavigationListWithBadges($menuitems);