Commit f329a213 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

FEAT : manage originatingDate in deposit and search, manage user and org...

FEAT : manage originatingDate in deposit and search, manage user and org archival profiles in folder screen
parent 72fa25bb
......@@ -666,88 +666,6 @@ class archive
return $result;
}
/**
* Find archives
* @param string $q The query string
* @param string $profile The index
* @param int $limit The result limit
*
* @return array The fulltext result
*/
public function find($q = null, $profile = false, $limit = null)
{
$q = trim($q);
if ($q == null || empty($q)) {
throw new \bundle\recordsManagement\Exception\invalidParameterException("The query string is empty");
}
if ($limit < 1) {
$limit = null;
}
$archivalProfiles = \laabs::newController("recordsManagement/archivalProfile")->index(true);
$indexList = $descriptionClassList = [];
foreach ($archivalProfiles as $archivalProfile) {
if ($archivalProfile->descriptionClass == '') {
$indexList[] = $archivalProfile->reference;
} else {
$descriptionClassList[] = $archivalProfile->descriptionClass;
}
}
if ($profile) {
if (in_array($profile, $indexList)) {
$index = [$profile];
} elseif (in_array($profile, $descriptionClassList)) {
$descriptionClass = [$profile];
} else {
return [];
}
} else {
$index = $indexList;
$descriptionClass = $descriptionClassList;
}
$currentOrg = \laabs::getToken("ORGANIZATION");
if (!$currentOrg) {
return array();
}
$ftresults = [];
if (isset($currentOrg->orgRoleCodes) && is_array($currentOrg->orgRoleCodes)) {
$currentOrg->orgRoleCodes = \laabs\implode(" ", $currentOrg->orgRoleCodes);
}
if (count($index)) {
$fulltextQueryString = [];
$fulltextQueryString[] = $q;
if (isset($currentOrg->orgRoleCodes) && strpos($currentOrg->orgRoleCodes, "owner") == false) {
$orgRegNumbers = \laabs::newController("organization/userPosition")->listMyCurrentDescendantServices();
$fulltextQueryString[] = " and originatorOrgRegNumber:(".\laabs\implode(" || ", $orgRegNumbers).")";
}
$ft = \laabs::newService('dependency/fulltext/FulltextEngineInterface');
$ftresults = $ft->find(\laabs\implode(" ", $fulltextQueryString), $index, $limit);
}
if (count($descriptionClassList)) {
$descriptionClassArgs = preg_split("# and #", $q);
if (isset($currentOrg->orgRoleCodes) && strpos($currentOrg->orgRoleCodes, "owner") == false) {
$orgRegNumbers = \laabs::newController("organization/userPosition")->listMyCurrentDescendantServices();
$fulltextQueryString[] = " and originatorOrgRegNumber:(".\laabs\implode(" || ", $orgRegNumbers).")";
}
}
return $ftresults;
}
/**
* Count the archives for an organization
* @param string $orgRegNumber The organization registration number
......
......@@ -226,6 +226,17 @@ trait archiveAccessTrait
if (!empty($args['originatorOrgRegNumber'])) {
$queryParts[] = "originatorOrgRegNumber='".$args['originatorOrgRegNumber']."'";
}
if (!empty($args['originatorArchiveId'])) {
$queryParts[] = "originatorArchiveId='".$args['originatorArchiveId']."'";
}
if (!empty($args['originatingDate'])) {
if (!empty($args['originatingDate'][0])) {
$queryParts[] = "originatingDate>='".$args['originatingDate'][0]."'";
}
if (!empty($args['originatingDate'][1])) {
$queryParts[] = "originatingDate<='".$args['originatingDate'][1]."'";
}
}
if (!empty($args['depositorOrgRegNumber'])) {
$queryParts[] = "depositorOrgRegNumber='".$args['depositorOrgRegNumber']."'";
}
......
......@@ -37,6 +37,8 @@ trait archiveCommunicationTrait
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
......@@ -53,6 +55,8 @@ trait archiveCommunicationTrait
$archiveExpired = null,
$finalDisposition = null,
$originatorOrgRegNumber = null,
$originatorArchiveId = null,
$originatingDate = null,
$filePlanPosition = null,
$hasParent = null,
$description = null,
......@@ -69,6 +73,8 @@ trait archiveCommunicationTrait
'archiveExpired' => $archiveExpired,
'finalDisposition' => $finalDisposition,
'originatorOrgRegNumber' => $originatorOrgRegNumber,
'originatorArchiveId' => $originatorArchiveId,
'originatingDate' => $originatingDate,
'filePlanPosition' => $filePlanPosition,
'hasParent' => $hasParent,
];
......@@ -91,7 +97,6 @@ trait archiveCommunicationTrait
$searchClasses['recordsManagement/description'] = $this->useDescriptionController('recordsManagement/description');
}
}
foreach ($searchClasses as $descriptionClass => $descriptionController) {
$archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs));
}
......@@ -114,7 +119,7 @@ trait archiveCommunicationTrait
}
}
}
return $archives;
}
......
......@@ -57,6 +57,9 @@ class description
if (!empty($archive->originatorArchiveId)) {
$descriptionObject->text .= $archive->originatorArchiveId.' ';
}
if (!empty($archive->originatingDate)) {
$descriptionObject->text .= $archive->originatingDate.' ';
}
$descriptionObject->text .= $this->getText($archive->descriptionObject);
$descriptionObject->description = json_encode($archive->descriptionObject);
......@@ -215,7 +218,7 @@ class description
switch (true) {
case $comparison->right instanceof \core\Language\NumberOperand :
case $comparison->right instanceof \core\Language\RangeOperand
&& ( $comparison->right->from instanceof \core\Language\StringOperand
&& ( $comparison->right->from instanceof \core\Language\NumberOperand
|| $comparison->right->to instanceof \core\Language\NumberOperand ) :
$left = '('. $left.')::numeric';
break;
......
......@@ -40,6 +40,8 @@ interface archivesInterface
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
......@@ -57,6 +59,8 @@ interface archivesInterface
$archiveExpired = null,
$finalDisposition = null,
$originatorOrgRegNumber = null,
$originatorArchiveId = null,
$originatingDate = null,
$filePlanPosition = null,
$hasParent = null,
$description = null,
......@@ -262,7 +266,7 @@ interface archivesInterface
/**
* Move an archive into a folder
* @param string $archiveId the archive identifier
* @param string $folderId The folder identifier
* @param string $folderId The folder identifier
*
* @action recordsManagement/archiveFilePlanPosition/moveArchiveToFolder
*/
......
......@@ -31,6 +31,8 @@ class welcome
public $view;
public $json;
protected $userArchivalProfiles = [];
/**
* Constuctor of welcomePage html serializer
* @param \dependency\html\Document $view The view
......@@ -75,7 +77,6 @@ class welcome
$this->view->setSource("filePlan", $filePlan);
}
// Retention
$retentionRules = \laabs::callService('recordsManagement/retentionRule/readIndex');
for ($i = 0, $count = count($retentionRules); $i < $count; $i++) {
......@@ -83,40 +84,30 @@ class welcome
}
// archival profiles for search form
foreach ($this->userArchivalProfiles as $archivalProfile) {
/*if ($archivalProfile == "*") {
$currentOrganization->acceptArchiveWithoutProfile = true;
}
$archivalProfileController = \laabs::newController("recordsManagement/archivalProfile");
if (!empty($currentOrganization->registrationNumber)) {
$archivalProfiles = \laabs::callService('organization/userPosition/readDescendantprofiles');
foreach ($archivalProfiles as $archivalProfile) {
if ($archivalProfile == "*") {
continue;
}
$archivalProfileController->readDetail($archivalProfile);
$archivalProfile->searchFields = [];
foreach ($archivalProfile->archiveDescription as $archiveDescription) {
switch ($archiveDescription->descriptionField->type) {
case 'text':
case 'name':
case 'date':
case 'number':
case 'boolean':
$archivalProfile->searchFields[] = $archiveDescription->descriptionField;
}
$archivalProfileController->readDetail($archivalProfile);*/
$archivalProfile->searchFields = [];
foreach ($archivalProfile->archiveDescription as $archiveDescription) {
switch ($archiveDescription->descriptionField->type) {
case 'text':
case 'name':
case 'date':
case 'number':
case 'boolean':
$archivalProfile->searchFields[] = $archiveDescription->descriptionField;
}
}
}
$depositPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveDeposit/deposit");
$this->view->translate();
if (!empty($currentOrganization->registrationNumber)) {
$this->view->setSource("userArchivalProfiles", $archivalProfiles);
}
$this->view->setSource("userArchivalProfiles", $this->userArchivalProfiles);
$this->view->setSource("depositPrivilege", $depositPrivilege);
$this->view->setSource("filePlanPrivileges", $filePlanPrivileges);
......@@ -170,7 +161,7 @@ class welcome
$archive->depositDate = $archive->depositDate->format('Y-m-d H:i:s');
if ($archive->originatingDate) {
$archive->originatingDate = $archive->originatingDate->format('Y-m-d H:i:s');
$archive->originatingDate = $archive->originatingDate->format('Y-m-d');
}
// Retention
......@@ -251,6 +242,7 @@ class welcome
$this->view->setSource("displayableFormat", json_encode(\laabs::configuration('presentation.maarchRM')['displayableFormat']));
$this->view->merge();
}
return $this->view->saveHtml();
}
/**
......@@ -421,7 +413,6 @@ class welcome
/**
* Mark leaf for html merging
* @param object $tree The tree
*
*/
protected function markTreeLeaf($tree)
{
......@@ -443,7 +434,6 @@ class welcome
* Add owner organization name in folder path
* @param object $tree The tree
* @param string $ownerName The owner organizaiton name
*
*/
protected function updateFolderPath($tree, $ownerName)
{
......@@ -459,6 +449,17 @@ class welcome
{
$orgUnit->archivalProfiles = \laabs::callService('organization/organization/readOrgunitprofiles', $orgUnit->registrationNumber);
foreach ($orgUnit->archivalProfiles as $i => $archivalProfile) {
if ($archivalProfile == "*") {
$orgUnit->acceptArchiveWithoutProfile = true;
unset($orgUnit->archivalProfiles[$i]);
} else {
$this->userArchivalProfiles[$archivalProfile->reference] = $archivalProfile;
}
}
$orgUnit->archivalProfiles = array_values($orgUnit->archivalProfiles);
if (!empty($orgUnit->organization)) {
foreach ($orgUnit->organization as $subOrgUnit) {
$this->getOrgUnitArchivalProfiles($subOrgUnit);
......
......@@ -878,4 +878,4 @@ msgid "Zip container"
msgstr "Fichier conteneur"
msgid "Originating date"
msgstr "Date de prodution"
msgstr "Date"
......@@ -58,7 +58,7 @@
rowTemplate: $('#listTemplate > .archive'),
folderContents: $('#folderContentList'),
getfolderContents: function(orgRegNumber, folderId, path, description, archivalProfiles, locked) {
getfolderContents: function(orgRegNumber, folderId, path, description, archivalProfiles, locked, acceptArchivesWithoutProfiles) {
var url = "/folder?orgRegNumber="+orgRegNumber;
if (folderId) {
url = url + "&folderId="+folderId;
......@@ -90,8 +90,10 @@
}
})
this.getImportForm(orgRegNumber, folderId, archivalProfiles);
this.buildNewArchiveDropdownMenu();
this.getImportForm(orgRegNumber, folderId);
this.buildNewArchiveDropdownMenu(archivalProfiles, acceptArchivesWithoutProfiles);
$("#folderToolbarSearch").data("orgregnumber", orgRegNumber).data("folderid", folderId);
},
......@@ -193,17 +195,17 @@
})
},
getImportForm: function(orgRegNumber, folderId, archivalProfiles) {
getImportForm: function(orgRegNumber, folderId) {
$('#archiveForm [name="filePlanPosition"]').val(folderId);
$('#archiveForm [name="originatorOrgRegNumber"]').val(orgRegNumber);
if (archivalProfiles.length < 1) {
/*if (archivalProfiles.length < 1) {
$("#folderToolbarBtn .dropdown-menu").data("archivalprofiles", {});
$('#folderTab').click();
return;
}
$("#folderToolbarBtn .dropdown-menu").data("archivalprofiles", archivalProfiles);
$("#folderToolbarBtn .dropdown-menu").data("archivalprofiles", archivalProfiles);*/
},
......@@ -211,26 +213,33 @@
FilePlan.selectedNode.find('b:first').click();
},
buildNewArchiveDropdownMenu: function() {
var archivalProfiles = $("#folderToolbarBtn .dropdown-menu").data("archivalprofiles");
buildNewArchiveDropdownMenu: function(archivalProfiles, acceptArchivesWithoutProfiles) {
var dropdown = $("#folderToolbarBtn .dropdown-menu");
dropdown.children().remove();
if (!acceptArchivesWithoutProfiles && archivalProfiles.length == 0) {
$("#folderToolbarImport").attr('disabled', 'disabled');
return;
}
if (acceptArchivesWithoutProfiles) {
var a = $("<a/>")
.addClass("small newArchive")
.data("reference", '')
.attr('style', "cursor: pointer;")
.text($('#withoutProfile_text').html());
$("<li/>").append(a).appendTo(dropdown);
};
for (var i = 0; i < archivalProfiles.length; i++) {
if (archivalProfiles[i] == '*') {
var a = $("<a/>")
.addClass("small newArchive")
.data("reference", '')
.attr('style', "cursor: pointer;")
.text($('#withoutProfile_text').html());
} else {
var a = $("<a/>")
.addClass("userProfile small newArchive")
.data("reference", archivalProfiles[i].reference)
.data("json", archivalProfiles[i])
.attr('style', "cursor: pointer;")
.text(archivalProfiles[i].name);
}
var a = $("<a/>")
.addClass("userProfile small newArchive")
.data("reference", archivalProfiles[i].reference)
.data("json", archivalProfiles[i])
.attr('style', "cursor: pointer;")
.text(archivalProfiles[i].name);
$("<li/>").append(a).appendTo(dropdown);
}
......
......@@ -123,7 +123,8 @@
searchContext : function(uniqId, orgRegNumber, folderId, profiles) {
var panel = $("#" + uniqId + "Panel");
var nav = panel.find('.nav-tabs');
if (orgRegNumber) {
var path = $('#folderPath').text();
var description = $('#folderDescription').text();
......@@ -137,14 +138,12 @@
if (profiles!=null) {
nav.find('.profileTab').css('display', 'none');
$.each(profiles, function() {
console.log(this.name);
nav.find('.'+this.reference).css('display', '');
})
}
if ((profiles==null && nav.find('>li').length > 6) || profiles.length > 5) {
if ((profiles==null && nav.find('>li').length > 6) || (profiles!=null && profiles.length > 5)) {
nav.find('>.profileTab').css('display', 'none');
} else {
nav.find('.profileDropdown').css('display', 'none');
}
......
<li id="[?merge .orgId ?]" class="organization" data-path="[?merge .displayName ?]" data-orgregnumber="[?merge .registrationNumber ?]" data-archivalprofiles="[?merge .archivalProfiles.json() ?]">
<li id="[?merge .orgId ?]" class="organization"
data-path="[?merge .displayName ?]"
data-orgregnumber="[?merge .registrationNumber ?]"
data-archivalprofiles="[?merge .archivalProfiles.json() ?]"
data-acceptarchivewithoutprofile="[?merge .acceptArchiveWithoutProfile ?]">
<span class="orgNode node-default">
<i class="fa" data-default-icon="fa-square"/>
<b><?merge .displayName ?></b>
......
......@@ -105,15 +105,17 @@
if (e.hasClass('organization')) {
path = e.find('b:first').html();
profile = e.data('archivalprofiles');
acceptArchiveWithoutProfile = e.data('acceptarchivewithoutprofile');
} else {
folderId = e.attr('id');
path = e.data('path')
description = e.data('description')
profile = e.closest('.organization').data('archivalprofiles');
acceptArchiveWithoutProfile = e.closest('.organization').data('acceptarchivewithoutprofile');
locked = e.data('closed');
}
ArchiveFolderList.getfolderContents(orgRegNumber, folderId, path, description, profile, locked);
ArchiveFolderList.getfolderContents(orgRegNumber, folderId, path, description, profile, locked, acceptArchiveWithoutProfile);
$('#folderTab').click();
},
......
......@@ -43,8 +43,25 @@
</div>
<?merge userArchivalProfiles ?>
<div role="tabpanel" class="tab-pane fade" id="[?merge .reference ?]">
<form class="form-horizontal">
<br/>
<br/>
<!--form class="form-horizontal" data-archiveProperties>
<div class="form-group col-md-6">
<label class="col-md-6 control-label text-primary"><small>Originator archive identifier</small></label>
<div class="col-md-6">
<input type="text" class="form-control input-sm" id="searchOriginatorArchiveId" name="originatorArchiveId" />
</div>
</div>
<div class="form-group col-md-12">
<label class="col-md-3 control-label text-primary"><small>Originating date</small></label>
<div class="input-group input-group-sm input-daterange col-md-4">
<input type="text" data-range='start' id="searchFromOriginatingDate" class="form-control input-sm datePicker col-md-6" name="originatingDate" />
<span class="input-group-addon xsmall"><i class=" fa fa-arrow-right"></i></span>
<input type="text" data-range='end' id="searchToOriginatingDate" class="form-control input-sm datePicker col-md-6" name="originatingDate" />
</div>
<div class="col-md-5"> </div>
</div>
</form-->
<form class="form-horizontal" data-descriptionFields>
<?merge .searchFields ?>
<div>
<?merge .type.ifeq('name') ?>
......
......@@ -54,6 +54,8 @@ FulltextSearch = {
profileReference : "",
filePlanPosition : "",
orgRegNumber : "",
originatingDate : [],
originatorArchiveId : "",
};
var searchPanel = btn.closest("[data-search-panel]");
......@@ -68,7 +70,7 @@ FulltextSearch = {
var selectedProfile = searchPanel.find('[data-search-tab] > .active > a').data('index');
query.profileReference = selectedProfile;
var searchFields = searchPanel.find('[data-search-tabContent] > .active').find('form input, form select');
var searchFields = searchPanel.find('[data-search-tabContent] > .active').find('form[data-descriptionFields] input, form[data-description] select');
searchFields.each(function() {
var value = $(this).val();
......@@ -147,15 +149,15 @@ FulltextSearch = {
query.description = arr.join(' && ');
if (query.text == '' && query.description == "") {
// searchPanel.find("[data-search-result]").css('display', 'none');
return;
}
searchPanel.find("[data-search-result]").css('display', '');
query.filePlanPosition = searchPanel.data("context-folderid");
query.originatorOrgRegNumber = searchPanel.data("context-orgregnumber");
query.originatorArchiveId = $('#searchOriginatorArchiveId').val();
if (query.text == '' && query.description == "" && query.originatorArchiveId == '') {
return;
}
searchPanel.find("[data-search-result]").css('display', '');
ajax(btn,{
type : 'GET',
......
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