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

fix/14312 : add count on log search page

parent 069def71
Pipeline #8910 failed with stage
......@@ -53,14 +53,15 @@ class log implements archiveDescriptionInterface
/**
* Get a search result
* @param string $archiveId The archive identifier
* @param string $type The type
* @param date $fromDate The date
* @param date $toDate The date
* @param string $processName The process name
* @param string $processId The process identifier
* @param string $sortBy The process identifier
* @param int $numberOfResult The process identifier
*
* @param string $archiveId The archive identifier
* @param string $type The type
* @param date $fromDate The date
* @param date $toDate The date
* @param string $processName The process name
* @param string $processId The process identifier
* @param string $sortBy The process identifier
* @param integer $maxResults The process identifier
*
* @return array Array of logs
*/
......@@ -72,12 +73,44 @@ class log implements archiveDescriptionInterface
$processName = null,
$processId = null,
$sortBy = ">fromDate",
$numberOfResult = null
$maxResults = null
) {
$queryParts = array();
$queryParams = array();
list($queryParams, $queryString) = $this->queryBuilder($archiveId, $type, $fromDate, $toDate, $processName, $processId);
//$queryParts[] = $this->auth->getUserAccessRule('recordsManagement/log');
$logs = $this->sdoFactory->find(
"recordsManagement/log",
$queryString,
$queryParams,
$sortBy,
0,
$maxResults
);
return $logs;
}
/**
* Create query for search
*
* @param string $archiveId The archive identifier
* @param string $type The type
* @param date $fromDate The date
* @param date $toDate The date
* @param string $processName The process name
* @param string $processId The process identifier
*
* @return
*/
protected function queryBuilder(
$archiveId = null,
$type = null,
$fromDate = null,
$toDate = null,
$processName = null,
$processId = null
) {
$queryParts = [];
$queryParams = [];
if ($archiveId) {
$queryParams['archiveId'] = $archiveId;
......@@ -114,20 +147,38 @@ class log implements archiveDescriptionInterface
$queryString = implode(' AND ', $queryParts);
if (!$numberOfResult) {
$numberOfResult = \laabs::configuration('presentation.maarchRM')['maxResults'];
}
return [$queryParams, $queryString];
}
$logs = $this->sdoFactory->find(
/**
* Count search results
*
* @param string $archiveId The archive identifier
* @param string $type The type
* @param date $fromDate The date
* @param date $toDate The date
* @param string $processName The process name
* @param string $processId The process identifier
*
* @return integer
*/
public function countFind(
$archiveId = null,
$type = null,
$fromDate = null,
$toDate = null,
$processName = null,
$processId = null
) {
list($queryParams, $queryString) = $this->queryBuilder($archiveId, $type, $fromDate, $toDate, $processName, $processId);
$count = $this->sdoFactory->count(
"recordsManagement/log",
$queryString,
$queryParams,
$sortBy,
0,
$numberOfResult
$queryParams
);
return $logs;
return $count;
}
/**
......@@ -295,7 +346,7 @@ class log implements archiveDescriptionInterface
/**
* Get the last usable journal
* @param string $type The type of journal
* @param string $ownerOrgRegNumber The journal owner organization registration number
* @param string $ownerOrgRegNumber The journal owner organization registration number
*
* @return recordsManagement/log The journal object
*/
......@@ -306,7 +357,7 @@ class log implements archiveDescriptionInterface
} else {
$query = "type='$type' AND ownerOrgRegNumber = null";
}
$journals = $this->sdoFactory->find('recordsManagement/log', $query, [], ">toDate", 0, 1);
if (empty($journals)) {
......@@ -412,7 +463,7 @@ class log implements archiveDescriptionInterface
// Create timestamp resource
$timestampResource = $digitalResourceController->createFromFile($timestampFileName);
$digitalResourceController->getHash($timestampResource, "SHA256");
$logMessage = ["message" => "Timestamp file generated"];
\laabs::notify(\bundle\audit\AUDIT_ENTRY_OUTPUT, $logMessage);
......
......@@ -22,7 +22,7 @@ namespace bundle\recordsManagement;
* Standard interface for log archive description class
*/
interface logInterface
{
{
/**
* Get a search result
* @param string $archiveId The archive identifier
......@@ -32,7 +32,7 @@ interface logInterface
* @param string $processName The process name
* @param string $processId The process identifier
* @param string $sortBy The process identifier
* @param int $numberOfResult The process identifier
* @param int $maxResults The process identifier
* @action recordsManagement/log/find
*/
......@@ -44,9 +44,34 @@ interface logInterface
$processName = null,
$processId = null,
$sortBy = ">fromDate",
$numberOfResult = null
$maxResults = null
);
/**
* Count search results
*
* @param string $archiveId The archive identifier
* @param string $type The type
* @param date $fromDate The date
* @param date $toDate The date
* @param string $processName The process name
* @param string $processId The process identifier
* @param string $sortBy The process identifier
* @param int $maxResults The process identifier
* @action recordsManagement/log/countFind
*/
public function countFind(
$archiveId = null,
$type = null,
$fromDate = null,
$toDate = null,
$processName = null,
$processId = null,
$sortBy = ">fromDate",
$maxResults = null
);
/**
* Deposit a log file
* @param string $journalFileName The name of the journal to deposit
......
......@@ -54,16 +54,25 @@ class log
$this->view->addContentFile('recordsManagement/log/searchForm.html');
$this->view->translate();
$maxResults = null;
if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])) {
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
}
$this->view->setSource("maxResults", $maxResults);
$this->view->translate();
$this->view->merge();
return $this->view->saveHtml();
}
/**
* Show result log search
* @param array $logs The arry of object
* @param integer $totalResults Max number of total results from query
*
* @return string
*/
public function find($logs)
public function find($logs, $totalResults)
{
$this->view->addContentFile('recordsManagement/log/result.html');
$this->view->translate();
......@@ -79,13 +88,20 @@ class log
$log->resId = \laabs::callService('recordsManagement/archives/readArchivecontents_archive_', (string) $log->archiveId)->digitalResources[0]->resId;
}
$hasReachMaxResults = false;
if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])
&& $totalResults >= \laabs::configuration('presentation.maarchRM')['maxResults']) {
$hasReachMaxResults = true;
}
$this->view->setSource('hasReachMaxResults', $hasReachMaxResults);
$this->view->setSource('totalResults', $totalResults);
$this->view->setSource("logs", $logs);
$this->view->merge();
return $this->view->saveHtml();
}
/**
*
*/
......
......@@ -65,3 +65,5 @@ msgstr "La vérification d'intégrité du journal a échoué."
msgid "The journal is integrity is valid."
msgstr "Le journal est intègre."
msgid "result(s) on"
msgstr "résultat(s) sur"
......@@ -20,7 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="panel panel-primary">
<div class="panel-heading clearfix">
<div class="pull-left">
<?merge hasReachMaxResults.not() ?>
<h4><?merge logs.count() ?> result(s)</h4>
<?merge hasReachMaxResults ?>
<h4><?merge logs.count() ?> result(s) on <?merge totalResults ?> total</h4>
</div>
</div>
<div class="panel-body" style="padding: 0;">
......@@ -56,4 +59,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
......@@ -37,6 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
<div id="collapseOne" class="well panel-collapse collapse in" style="margin-bottom: 0px">
<form id="searchForm" class="form-horizontal">
<input type="hidden" id="maxResults" value="[?merge maxResults ?]">
<div class="row">
<div class="col-md-6">
<div class="form-group">
......@@ -124,7 +125,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
fromDate : $("#searchForm #fromDate").data('datepicker').getFormattedDate('yyyy-mm-dd'),
toDate : $("#searchForm #toDate").data('datepicker').getFormattedDate('yyyy-mm-dd'),
processId : $("#searchForm #processId").val(),
processName : $("#searchForm #processName").val()
processName : $("#searchForm #processName").val(),
maxResults: $('#maxResults').val()
}
ajax($(this), {
......@@ -138,10 +140,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
$('#archiveList').append(response);
}
});
});
});
$("#contain").on("click",'[data-form-reset]', function () {
$("#searchForm").find('input').val('');
$("#searchForm").find('input[type=text], input[type=number], input[type=date], select').val('');
$("#type").prop('selectedIndex', 0);
$('#archiveList').html('');
});
......
......@@ -31,8 +31,10 @@ interface searchLogArchiveInterface
public function readLogSearch();
/**
* @return recordsManagement/log/find
* @uses recordsManagement/log/find
* @uses recordsManagement/log/countFind
*
* @return recordsManagement/log/find
*/
public function readLogs();
......@@ -71,4 +73,4 @@ interface searchLogArchiveInterface
* @uses recordsManagement/archive/readConsultation_archiveId_Digitalresource_resId_
*/
public function readRecordsmanagementContents_archiveId__resId_();
}
\ No newline at end of file
}
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