Unverified Commit 02007f47 authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/14312 : add count on log search page

parent ac6b518a
Pipeline #8924 failed with stages
......@@ -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;
......@@ -113,20 +146,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;
}
/**
......@@ -203,7 +254,6 @@ class log implements archiveDescriptionInterface
return count($this->search($description, $text, $args, $checkAccess, $maxResults = null));
}
/**
* Retrieve a journal by evenement date
* @param string $type The journal type
......
......@@ -25,15 +25,16 @@ interface logInterface
{
/**
* 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 Max number of results to return
*
* @action recordsManagement/log/find
*/
public function readFind(
......@@ -44,7 +45,28 @@ 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
* @action recordsManagement/log/countFind
*/
public function countFind(
$archiveId = null,
$type = null,
$fromDate = null,
$toDate = null,
$processName = null,
$processId = null
);
/**
......
......@@ -54,16 +54,26 @@ 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 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,6 +89,14 @@ 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();
......
......@@ -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/readFind
* @uses recordsManagement/log/countFind
*
* @return recordsManagement/log/find
*/
public function readLogs();
......
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