Unverified Commit 6a493ff4 authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/14312 : add count with max results on default view

parent 143e2c27
Pipeline #8792 failed with stage
......@@ -322,8 +322,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');
......@@ -356,31 +378,32 @@ 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];
}
/**
* 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 count($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false)
{
list($queryString, $queryParams) = $this->getQueryStringAndParams($originatorOrgRegNumber, $filePlanPosition, $archiveUnit);
$count = $this->sdoFactory->count('recordsManagement/archive', $queryString, $queryParams);
return $archives;
return $count;
}
/**
* Get archive metadata
* @param string $archiveId The archive identifier
*
*
* @return recordsManagement/archive The archive metadata
*/
public function getMetadata($archiveId, $checkAccess = true)
......
......@@ -146,6 +146,17 @@ interface archivesInterface
*/
public function readList($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false);
/**
* Get archives Count withotu 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/count
*/
public function readCount($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false);
/*
MODIFY ARCHIVES
*/
......
......@@ -183,11 +183,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 = [];
......@@ -211,6 +212,7 @@ class welcome
}
$this->json->archives = $archives;
$this->json->countWithoutLimit = $count;
return $this->json->save();
}
......
......@@ -19,8 +19,10 @@ interface appInterface
* @param string $originatorOrgRegNumber The organization registration number
* @param string $filePlanPosition The file plan position
* @param boolean $archiveUnit List the archive unit
*
*
* @uses recordsManagement/archives/readList
* @uses recordsManagement/archives/readCount
*
* @return recordsManagement/welcome/folderContents
*/
public function readFolder($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment