Unverified Commit b0cf9317 authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/14312 : add count display on search page and home

parent b445dc17
Pipeline #8849 failed with stages
......@@ -89,6 +89,155 @@ trait archiveAccessTrait
$archives = [];
list($searchClasses, $archiveArgs) = $this->getClassesAndArchiveArgsForSearch(
$archiveId,
$profileReference,
$status,
$archiveName,
$agreementReference,
$archiveExpired,
$finalDisposition,
$originatorOrgRegNumber,
$originatorOwnerOrgId,
$originatorArchiveId,
$originatingDate,
$filePlanPosition,
$hasParent,
$partialRetentionRule,
$retentionRuleCode,
$depositStartDate,
$depositEndDate,
$originatingStartDate,
$originatingEndDate,
$archiverArchiveId,
$processingStatus
);
foreach ($searchClasses as $descriptionClass => $descriptionController) {
$archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess, $maxResults));
}
return $archives;
}
/**
* Count archives by profile / dates / agreement
*
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param string $processingStatus
* @param bool $checkAccess
* @param integer $maxResults
*
* @return integer $count Count of archives from search
*/
public function count(
$archiveId = null,
$profileReference = null,
$status = null,
$archiveName = null,
$agreementReference = null,
$archiveExpired = null,
$finalDisposition = null,
$originatorOrgRegNumber = null,
$originatorOwnerOrgId = null,
$originatorArchiveId = null,
$originatingDate = null,
$filePlanPosition = null,
$hasParent = null,
$description = null,
$text = null,
$partialRetentionRule = null,
$retentionRuleCode = null,
$depositStartDate = null,
$depositEndDate = null,
$originatingStartDate = null,
$originatingEndDate = null,
$archiverArchiveId = null,
$processingStatus = null,
$checkAccess = true,
$maxResults = null
) {
$accountController = \laabs::newController('auth/userAccount');
$accountController->isAuthorized('user');
$archives = [];
list($searchClasses, $archiveArgs) = $this->getClassesAndArchiveArgsForSearch(
$archiveId,
$profileReference,
$status,
$archiveName,
$agreementReference,
$archiveExpired,
$finalDisposition,
$originatorOrgRegNumber,
$originatorOwnerOrgId,
$originatorArchiveId,
$originatingDate,
$filePlanPosition,
$hasParent,
$partialRetentionRule,
$retentionRuleCode,
$depositStartDate,
$depositEndDate,
$originatingStartDate,
$originatingEndDate,
$archiverArchiveId,
$processingStatus
);
$count = 0;
foreach ($searchClasses as $descriptionClass => $descriptionController) {
$count += $descriptionController->count($description, $text, $archiveArgs, $checkAccess, $maxResults);
}
return $count;
}
protected function getClassesAndArchiveArgsForSearch(
$archiveId = null,
$profileReference = null,
$status = null,
$archiveName = null,
$agreementReference = null,
$archiveExpired = null,
$finalDisposition = null,
$originatorOrgRegNumber = null,
$originatorOwnerOrgId = null,
$originatorArchiveId = null,
$originatingDate = null,
$filePlanPosition = null,
$hasParent = null,
$partialRetentionRule = null,
$retentionRuleCode = null,
$depositStartDate = null,
$depositEndDate = null,
$originatingStartDate = null,
$originatingEndDate = null,
$archiverArchiveId = null,
$processingStatus = null
) {
$archiveArgs = [
'archiveId' => $archiveId,
'profileReference' => $profileReference,
......@@ -135,11 +284,8 @@ trait archiveAccessTrait
$searchClasses['recordsManagement/description'] = $this->useDescriptionController('recordsManagement/description');
}
}
foreach ($searchClasses as $descriptionClass => $descriptionController) {
$archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess, $maxResults));
}
return $archives;
return [$searchClasses, $archiveArgs];
}
/**
......@@ -246,7 +392,6 @@ trait archiveAccessTrait
} elseif ($originatingStartDate) {
$queryParams['originatingStartDate'] = $originatingStartDate;
$queryParts['originatingDate'] = "originatingDate >= :originatingStartDate";
} elseif ($originatingEndDate) {
$queryParams['originatingEndDate'] = $originatingEndDate;
$queryParts['originatingDate'] = "originatingDate <= :originatingEndDate";
......@@ -259,7 +404,6 @@ trait archiveAccessTrait
} elseif ($depositStartDate) {
$queryParams['depositStartDate'] = $depositStartDate;
$queryParts['depositDate'] = "depositDate >= :depositStartDate";
} elseif ($depositEndDate) {
$queryParams['depositEndDate'] = $depositEndDate;
$queryParts['depositDate'] = "depositDate <= :depositEndDate";
......@@ -321,8 +465,30 @@ trait archiveAccessTrait
*/
public function index($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false)
{
$queryParts = array();
$queryParams = array();
list($queryString, $queryParams) = $this->getQueryStringAndParams($originatorOrgRegNumber, $filePlanPosition, $archiveUnit);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
$archives = $this->sdoFactory->find(
'recordsManagement/archive',
$queryString,
$queryParams,
false,
false,
$maxResults
);
foreach ($archives as $archive) {
if (!empty($archive->disposalDate) && $archive->disposalDate <= \laabs::newDate()) {
$archive->disposable = true;
}
}
return $archives;
}
protected function getQueryStringAndParams($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false)
{
$queryParts = [];
$queryParams = [];
$currentDate = \laabs::newDate();
$currentDateString = $currentDate->format('Y-m-d');
......@@ -355,31 +521,33 @@ trait archiveAccessTrait
if ($accessRuleAssert) {
$queryParts[] = $accessRuleAssert;
}
$queryString = \laabs\implode(' AND ', $queryParts);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
$archives = $this->sdoFactory->find(
'recordsManagement/archive',
$queryString,
$queryParams,
false,
false,
$maxResults
);
foreach ($archives as $archive) {
if (!empty($archive->disposalDate) && $archive->disposalDate <= \laabs::newDate()) {
$archive->disposable = true;
}
}
return [$queryString, $queryParams];
}
return $archives;
/**
* Get archives count
*
* @param string $originatorOrgRegNumber The organization registration number
* @param string $filePlanPosition The file plan position
* @param boolean $archiveUnit List the archive unit
*
* @return integer $count
*/
public function countList($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false)
{
list($queryString, $queryParams) = $this->getQueryStringAndParams($originatorOrgRegNumber, $filePlanPosition, $archiveUnit);
$count = $this->sdoFactory->count('recordsManagement/archive', $queryString, $queryParams);
return $count;
}
/**
* Get archive metadata
* @param string $archiveId The archive identifier
*
*
* @return recordsManagement/archive The archive metadata
*/
public function getMetadata($archiveId, $checkAccess = true)
......@@ -514,7 +682,7 @@ trait archiveAccessTrait
* @param string $resId The resource identifier
* @param bool $checkAccess Check access for originator or archiver. if false, caller MUST control access before or after
* @param bool $embedded Generate a binary content or a link
*
*
* @return digitalResource/digitalResource Archive resource contents
*/
public function consultation($archiveId, $resId, $checkAccess = true, $isCommunication = false, $embedded = true)
......@@ -634,7 +802,7 @@ trait archiveAccessTrait
$response = \laabs::kernel()->response;
$response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"');
return $digitalResource->getHandler();
}
......
......@@ -136,6 +136,25 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip
*/
public function search($description = null, $text = null, array $archiveArgs = [], $checkAccess = true, $maxResults = null)
{
list($queryString, $queryParams) = $this->getQueryStringAndParams($description, $text, $archiveArgs, $checkAccess);
$archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams, false, false, $maxResults);
foreach ($archiveUnits as $archiveUnit) {
if (!empty($archiveUnit->description)) {
$archiveUnit->descriptionObject = json_decode($archiveUnit->description);
}
}
return $archiveUnits;
}
protected function getQueryStringAndParams(
$description = null,
$text = null,
array $archiveArgs = [],
$checkAccess = true
) {
$queryParams = [];
$queryParts = ['(description!=null and text!=null)'];
......@@ -204,22 +223,34 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip
$queryString = \laabs\implode(' and ', $queryParts);
$archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams, false, false, $maxResults);
return [$queryString, $queryParams];
}
foreach ($archiveUnits as $archiveUnit) {
if (!empty($archiveUnit->description)) {
$archiveUnit->descriptionObject = json_decode($archiveUnit->description);
}
}
/**
* Count the description objects
*
* @param string $description The search args on description object
* @param string $text The search args on text
* @param array $archiveArgs The search args on archive std properties
* @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data
*
* @return integer $count Research count
*/
public function count($description = null, $text = null, array $archiveArgs = [], $checkAccess = true)
{
list($queryString, $queryParams) = $this->getQueryStringAndParams($description, $text, $archiveArgs, $checkAccess);
return $archiveUnits;
$count = $this->sdoFactory->count('recordsManagement/archiveUnit', $queryString, $queryParams);
return $count;
}
/**
* Update the description
* @param mixed $description The description object
* @param string $archiveId The archive identifier
*
*
* @return bool The result of the operation
*/
public function update($archive)
......
......@@ -158,6 +158,19 @@ class log implements archiveDescriptionInterface
return $archives;
}
/**
* Count log objects
* @param string $description The search args on description object
* @param string $text The search args on text
* @param array $args The search args on archive std properties
*
* @return object Array of description objects
*/
public function count($description = null, $text = null, array $args = [], $checkAccess = null, $maxResults = null)
{
return count($this->search($description, $text, $args, $checkAccess, $maxResults = null));
}
/**
* Retrieve a journal by evenement date
* @param string $type The journal type
......
......@@ -85,6 +85,62 @@ interface archivesInterface
$maxResults = null
);
/**
* Count archives by profile / dates / agreement
*
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param integer $maxResults
*
* @action recordsManagement/archive/count
*
*/
public function readCount(
$archiveId = null,
$profileReference = null,
$status = null,
$archiveName = null,
$agreementReference = null,
$archiveExpired = null,
$finalDisposition = null,
$originatorOrgRegNumber = null,
$originatorOwnerOrgId = null,
$originatorArchiveId = null,
$originatingDate = null,
$filePlanPosition = null,
$hasParent = null,
$description = null,
$text = null,
$partialRetentionRule = null,
$retentionRuleCode = null,
$depositStartDate = null,
$depositEndDate = null,
$originatingStartDate = null,
$originatingEndDate = null,
$archiverArchiveId = null,
$maxResults = null
);
/**
* Search archives by profile / dates / agreement
* @param string $archiveId
......@@ -146,6 +202,17 @@ interface archivesInterface
*/
public function readList($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false);
/**
* Get archives Count without limit
*
* @param string $originatorOrgRegNumber The organization registration number
* @param string $filePlanPosition The file plan position
* @param boolean $archiveUnit List the archive unit
*
* @action recordsManagement/archive/countList
*/
public function readCountList($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false);
/*
MODIFY ARCHIVES
*/
......
......@@ -94,7 +94,10 @@ class archive
$deleteDescription = (bool) \laabs::configuration("recordsManagement")['deleteDescription'];
}
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
$maxResults = null;
if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])) {
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
}
$this->view->setSource("maxResults", $maxResults);
$this->view->setSource("retentionRules", $retentionRules);
......@@ -115,11 +118,12 @@ class archive
/**
* get archives with information
* @param array $archives Array of archive object
* @param array $archives Array of archive object
* @param integer $count Count of archive object without limit
*
* @return string
*/
public function search($archives)
public function search($archives, $count)
{
$this->view->addContentFile("recordsManagement/archive/resultList.html");
......@@ -244,6 +248,7 @@ class archive
$this->view->setSource('hasReachMaxResults', $hasReachMaxResults);
$this->view->setSource('maxResults', \laabs::configuration('presentation.maarchRM')['maxResults']);
$this->view->setSource('totalResultsWithoutLimit', $count);
$this->view->setSource("accessRules", $accessRules);
$this->view->setSource("retentionRules", $retentionRules);
$this->view->setSource('archive', $archives);
......@@ -351,7 +356,6 @@ class archive
$this->view->setSource("acceptArchiveWithoutProfile", $archive->acceptArchiveWithoutProfile);
$this->view->setSource("acceptUserIndex", $archive->acceptUserIndex);
$this->view->translate();
$this->view->merge();
return $this->view->saveHtml();
......@@ -1411,6 +1415,7 @@ class archive
}
}
}
return $ownerOriginatorOrgs;
}
}
......@@ -112,11 +112,18 @@ class welcome
$depositPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveDeposit/deposit");
$maxResults = null;
if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])) {
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
}
$this->view->setSource("userArchivalProfiles", $this->userArchivalProfiles);
$this->view->setSource("depositPrivilege", $depositPrivilege);
$this->view->setSource("syncImportPrivilege", $syncImportPrivilege);
$this->view->setSource("asyncImportPrivilege", $asyncImportPrivilege);
$this->view->setSource("filePlanPrivileges", $filePlanPrivileges);
$this->view->setSource("maxResults", $maxResults);
$this->view->setSource('retentionRules', $retentionRules);
$this->view->setSource('user', $user);
......@@ -184,11 +191,12 @@ class welcome
/**
* Show a folder content
* @param array $archives
* @param array $archives
* @param integer $count Archives count without limit
*
* @return string
*/
public function folderContents($archives)
public function folderContents($archives, $count)
{
$organizations = \laabs::callService('organization/organization/readIndex');
$orgsName = [];
......@@ -212,6 +220,7 @@ class welcome
}
$this->json->archives = $archives;
$this->json->countWithoutLimit = $count;
return $this->json->save();
}
......
......@@ -612,6 +612,9 @@ msgstr "archive(s) sélectionnée(s)"
msgid "Result"
msgstr "Résultat"
msgid "archive(s) on"
msgstr "archive(s) sur"
msgid "Select all"
msgstr "Tous"
......@@ -762,7 +765,7 @@ msgid "%1$s destruction(s) can not be canceled."
msgstr "%1$s destruction(s) ne sont pas annulée(s)."
msgid "%1$s resource(s) can\'t be deleted."
msgstr "la ressource %1$s ne peut pas être supprimée."
msgstr "la ressource %1$s ne peut pas être supprimée."
msgid "%1$s resource(s) deleted."
msgstr "%1$s ressource(s) supprimée(s)"
......@@ -1104,6 +1107,10 @@ msgstr "Cliquer pour modifier '%1$s'"
msgid "* At least one field must be filled in."
msgstr "* Au moins un champ doit être renseigné."
msgid "Your query returns too much results, only first results are displayed."
msgstr "Le nombre de résultats retournés est trop important. Veuillez affiner votre recherche."
msgid "Export to "
msgstr "Exporter en "
......
......@@ -9,7 +9,7 @@
</ol>
</div>
<div id="folderContents" class="folderContents hide">
<div id="fodlerToolbar" class="row">
<div id="folderToolbar" class="row">
<h4 class="pull-left col-md-4 lockedFolder hide">
<i class="text-danger fa fa-lock" style="font-size: 30px"/>
</h4>
......@@ -230,7 +230,7 @@
type : "GET",
dataType : 'json',
success : function (response) {
ArchiveFolderList.buildResultList(response.archives);
ArchiveFolderList.buildResultList(response.archives, null, false, response.countWithoutLimit);
if (locked || disabled) {
ArchiveFolderList.folderPanel.find('.addChildrenArchive').remove();