fix searching for documents in inbox

This commit is contained in:
Uwe Steinmann 2023-10-11 16:36:06 +02:00
parent 3fe6f6df3c
commit fa97180c55

View File

@ -940,17 +940,25 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
$facets = $searchresult['facets']; $facets = $searchresult['facets'];
// $logger->log(var_export($facets, true), PEAR_LOG_DEBUG); // $logger->log(var_export($facets, true), PEAR_LOG_DEBUG);
} }
}
$data = array( $data['documents_total'] = $searchresult['count'];
'documents_total'=>$searchresult['count'],
'document_inbox'=>0, $inboxtags = [];
); if(!empty($settings->_extensions['paperless']['inboxtags']) && $inboxtags = explode(',', $settings->_extensions['paperless']['inboxtags'])) {
$inboxtags = []; foreach($inboxtags as $inboxtagid) {
if(!empty($settings->_extensions['paperless']['inboxtags']) && $inboxtags = explode(',', $settings->_extensions['paperless']['inboxtags'])) { $cats = [];
foreach($inboxtags as $inboxtagid) if($inboxtag = $dms->getDocumentCategory((int) $inboxtagid)) {
if($inboxtag = $dms->getDocumentCategory((int) $inboxtagid)) $cats[] = $inboxtag->getName();
$data['document_inbox'] += (int) $facets['category'][$inboxtag->getName()]; }
if($cats) {
$searchresult = $lucenesearch->search('', array('record_type'=>['document'], 'status'=>[2], 'user'=>[$userobj->getLogin()], 'category'=>$cats, 'startFolder'=>$startfolder, 'rootFolder'=>$startfolder), array('limit'=>1), array(), array('no_facets'=>true));
if($searchresult === false) {
return $response->withStatus(500);
}
$data['documents_inbox'] = $searchresult['count'];
}
}
}
} }
return $response->withJson($data, 200); return $response->withJson($data, 200);