diff --git a/lib/LMSManagers/LMSDocumentManager.php b/lib/LMSManagers/LMSDocumentManager.php index 1b33cfc4c0..2dc7c81230 100644 --- a/lib/LMSManagers/LMSDocumentManager.php +++ b/lib/LMSManagers/LMSDocumentManager.php @@ -132,6 +132,7 @@ public function GetDocumentList(array $params) $to = $params['to'] ?? 0; $status = $params['status'] ?? -1; $archived = $params['archived'] ?? -1; + $attachments = $params['attachments'] ?? -1; $limit = $params['limit'] ?? null; $offset = $params['offset'] ?? null; $count = isset($params['count']) && $params['count']; @@ -317,13 +318,19 @@ public function GetDocumentList(array $params) if (empty($list)) { $list = array(); } else { - foreach ($list as &$document) { - $document['attachments'] = $this->db->GetAll('SELECT id, filename, md5sum, contenttype, type, type AS main, cdate + foreach ($list as $key => $document) { + $list[$key]['attachments'] = $this->db->GetAll('SELECT id, filename, md5sum, contenttype, type, type AS main, cdate FROM documentattachments WHERE docid = ? ORDER BY type DESC, filename', array($document['docid'])); if (!empty($document['reference'])) { - $document['reference'] = $this->db->GetRow('SELECT id, type, fullnumber, cdate FROM documents + $list[$key]['reference'] = $this->db->GetRow('SELECT id, type, fullnumber, cdate FROM documents WHERE id = ?', array($document['reference'])); } + if ($attachments != -1) { + $attachments_count = sizeof($list[$key]['attachments']); + if (($attachments == 1 && $attachments_count < 2) || ($attachments == 0 && $attachments_count > 1)) { + unset($list[$key]); + } + } } unset($document); } diff --git a/lib/locale/pl_PL/strings.php b/lib/locale/pl_PL/strings.php index b0b03e720d..61f78b0c88 100644 --- a/lib/locale/pl_PL/strings.php +++ b/lib/locale/pl_PL/strings.php @@ -4761,6 +4761,8 @@ $_LANG['Your browser does not support the video element.'] = 'Twoja przeglądarka nie obsługuje elementu video.'; $_LANG['more document attachments'] = 'więcej załączników dokumentu'; +$_LANG['Document attachments'] = 'Załączniki dokumentów'; +$_LANG['Condition for the existence of document attachments'] = 'Warunek istnienia załączników dokumentu'; $_LANG['New files:'] = 'Nowe pliki:'; $_LANG['New files'] = 'Nowe pliki'; $_LANG['Attached files:'] = 'Załączone pliki:'; diff --git a/modules/documentlist.php b/modules/documentlist.php index ec7447af24..7c79e32f57 100644 --- a/modules/documentlist.php +++ b/modules/documentlist.php @@ -125,10 +125,18 @@ } elseif (!isset($filter['archived'])) { $filter['archived'] = -1; } + + if (isset($_GET['attachments'])) { + $filter['attachments'] = $_GET['attachments']; + } elseif (!isset($filter['attachments'])) { + $filter['attachments'] = -1; + } + } else { $filter = array( 'status' => -1, 'archived' => -1, + 'attachments' => -1, ); $SMARTY->clearAssign('persistent_filter'); $SESSION->saveFilter($filter); diff --git a/templates/default/document/documentlist.html b/templates/default/document/documentlist.html index 26b24b8aa4..6f7a355c97 100644 --- a/templates/default/document/documentlist.html +++ b/templates/default/document/documentlist.html @@ -199,6 +199,14 @@