Commit 1e9698eb authored by Prosper De Laure's avatar Prosper De Laure
Browse files

Bug : The profile are loaded on children archives

parent adb350ed
......@@ -185,7 +185,7 @@ trait archiveEntryTrait
private function extractArchiveUnit($filename)
{
$archivalProfileReference = strtok($filename, " ");
$archiveName = substr($archivalProfileReference, strlen($archivalProfileReference) + 1);
$archiveName = substr($filename, strlen($archivalProfileReference)+1);
$archive = \laabs::newInstance("recordsManagement/archive");
$archive->archiveName = $archiveName;
......@@ -357,7 +357,12 @@ trait archiveEntryTrait
*/
public function completeArchivalProfileCodes($archive)
{
$archive->archivalProfileReference = $this->currentArchivalProfile->reference;
if ($archive->archivalProfileReference == "") {
$archive->archivalProfileReference = $this->currentArchivalProfile->reference;
} else {
$this->useArchivalProfile($archive->archivalProfileReference);
}
if (!empty($this->currentArchivalProfile->retentionRuleCode)) {
$archive->retentionRuleCode = $this->currentArchivalProfile->retentionRuleCode;
......@@ -497,7 +502,6 @@ trait archiveEntryTrait
}
$nbArchiveObjects = count($archive->contents);
try {
$archive->status = 'preserved';
......@@ -510,13 +514,14 @@ trait archiveEntryTrait
if (!empty($archive->digitalResources)) {
$this->storeResources($archive);
}
$this->storeDescriptiveMetadata($archive);
for ($i = 0; $i < $nbArchiveObjects; $i++) {
$archive->contents[$i]->parentArchiveId = $archive->archiveId;
$archive->contents[$i]->originatorOwnerOrgId = $archive->originatorOwnerOrgId;
/*
$archive->contents[$i]->archivalProfileReference = $archive->archivalProfileReference;
*/
if ($archive->contents[$i]->originatorOrgRegNumber != $archive->originatorOrgRegNumber) {
$archive->contents[$i]->parentOriginatorOrgRegNumber = $archive->originatorOrgRegNumber;
}
......
......@@ -270,14 +270,10 @@ class welcome
*/
protected function getDescription($archive)
{
if (!isset($archive->descriptionObject)) {
return;
}
$archivalProfile = null;
if (!empty($archive->archivalProfileReference)) {
$archivalProfile = \laabs::callService('recordsManagement/archivalProfile/readByreference_reference_', $archive->archivalProfileReference);
$archive->archivalProfileName = $archivalProfile->name;
}
......@@ -293,54 +289,57 @@ class welcome
}
}
foreach ($archive->descriptionObject as $name => $value) {
$label = $type = $archivalProfileField = null;
if ($archivalProfile) {
foreach ($archivalProfile->archiveDescription as $archiveDescription) {
if ($archiveDescription->fieldName == $name) {
$label = $archiveDescription->descriptionField->label;
$archivalProfileField = true;
$type = $archiveDescription->descriptionField->type;
if (isset($archive->descriptionObject)) {
foreach ($archive->descriptionObject as $name => $value) {
$label = $type = $archivalProfileField = null;
if ($archivalProfile) {
foreach ($archivalProfile->archiveDescription as $archiveDescription) {
if ($archiveDescription->fieldName == $name) {
$label = $archiveDescription->descriptionField->label;
$archivalProfileField = true;
$type = $archiveDescription->descriptionField->type;
}
}
}
}
if (empty($label)) {
$label = $this->view->translator->getText($name, false, "recordsManagement/archive");
}
if (empty($label)) {
$label = $this->view->translator->getText($name, false, "recordsManagement/archive");
}
if (empty($type) && $value != "") {
$type = 'text';
switch (gettype($value)) {
case 'boolean':
$type = 'boolean';
break;
case 'integer':
case 'double':
$type = 'number';
break;
case 'string':
if (preg_match("#\d{4}\-\d{2}\-\d{2}#", $value)) {
$type = 'date';
}
break;
if (empty($type) && $value != "") {
$type = 'text';
switch (gettype($value)) {
case 'boolean':
$type = 'boolean';
break;
case 'integer':
case 'double':
$type = 'number';
break;
case 'string':
if (preg_match("#\d{4}\-\d{2}\-\d{2}#", $value)) {
$type = 'date';
}
break;
}
}
}
if ($archivalProfileField) {
$descriptionHtml .= '<tr class="archivalProfileField">';
} else {
$descriptionHtml .= '<tr>';
if ($archivalProfileField) {
$descriptionHtml .= '<tr class="archivalProfileField">';
} else {
$descriptionHtml .= '<tr>';
}
$descriptionHtml .= '<th title="'.$label.'" name="'.$name.'" data-type="'.$type.'">'.$label.'</th>';
$descriptionHtml .= '<td title="'.$value.'">'.$value.'</td>';
$descriptionHtml .= '</tr>';
}
$descriptionHtml .= '<th title="'.$label.'" name="'.$name.'" data-type="'.$type.'">'.$label.'</th>';
$descriptionHtml .= '<td title="'.$value.'">'.$value.'</td>';
$descriptionHtml .= '</tr>';
$descriptionHtml .= '</table>';
}
$descriptionHtml .= '</table>';
}
if ($descriptionHtml) {
......
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