Commit 53889420 authored by Guillaume Heurtier's avatar Guillaume Heurtier

FEAT #13606 TIME 3:00 migrate resource custom fields in templates

parent 9a5d83c7
<?php
use Contact\models\ContactCustomFieldListModel;
use CustomField\models\CustomFieldModel;
use Docserver\controllers\DocserverController;
use Docserver\models\DocserverModel;
use SrcCore\models\DatabaseModel;
......@@ -20,7 +21,7 @@ $DATA_TO_REPLACE = [
'res_letterbox.contact_lastname' => '[recipient.lastname]',
'res_letterbox.contact_society' => '[recipient.company]',
'res_letterbox.nature_id' => '[res_letterbox.custom_1]',
'res_letterbox.nature_id' => '[res_letterbox.customField_1]',
// Initiator
'res_letterbox.initiator_entity_id' => '[initiator.entity_id]',
......@@ -222,7 +223,7 @@ $DATA_TO_REPLACE = [
'notes.linktodoc' => '[res_letterbox.linktodoc]',
];
$customFields = [
$contactCustomFields = [
['oldId' => 'salutation_header', 'label' => 'Formule de politesse (Début)'],
['oldId' => 'salutation_footer', 'label' => 'Formule de politesse (Fin)'],
['oldId' => 'website', 'label' => 'Site internet'],
......@@ -231,6 +232,18 @@ $customFields = [
['oldId' => 'society_short', 'label' => 'Sigle de la structure'],
];
$resourceCustomFields = [
['id' => 'description', 'label' => 'Autres informations'],
['id' => 'external_reference', 'label' => 'Référence courrier expéditeur'],
['id' => 'reference_number', 'label' => 'N° recommandé'],
['id' => 'scan_date', 'label' => 'Date de scan'],
['id' => 'scan_user', 'label' => 'Utilisateur de scan'],
['id' => 'scan_location', 'label' => 'Lieu de scan'],
['id' => 'scan_wkstation', 'label' => 'Station de scan'],
['id' => 'scan_batch', 'label' => 'Batch de scan'],
['id' => 'scan_postmark', 'label' => 'Tampon de scan'],
];
chdir('../..');
$customs = scandir('custom');
......@@ -305,7 +318,7 @@ foreach ($customs as $custom) {
// END
foreach ($customFields as $customField) {
foreach ($contactCustomFields as $customField) {
$idNewCustomField = ContactCustomFieldListModel::get([
'select' => ['id'],
'where' => ['label = ?'],
......@@ -314,6 +327,15 @@ foreach ($customs as $custom) {
$DATA_TO_REPLACE["contact." . $customField['oldId']] = "[recipient.customField_{$idNewCustomField[0]['id']}]";
}
foreach ($resourceCustomFields as $customField) {
$idNewCustomField = CustomFieldModel::get([
'select' => ['id'],
'where' => ['label = ?'],
'data' => [$customField['label']]
]);
$DATA_TO_REPLACE["res_letterbox." . $customField['id']] = "[res_letterbox.customField_{$idNewCustomField[0]['id']}]";
}
$templates = TemplateModel::get([
'where' => ['template_target = ?', 'template_attachment_type = ?'],
'data' => ['indexingFile', 'all']
......
<?php
use Contact\models\ContactCustomFieldListModel;
use CustomField\models\CustomFieldModel;
use Docserver\controllers\DocserverController;
use Docserver\models\DocserverModel;
use SrcCore\models\CoreConfigModel;
......@@ -20,7 +21,7 @@ $DATA_TO_REPLACE = [
'res_letterbox.contact_lastname' => '[sender.lastname]',
'res_letterbox.contact_society' => '[sender.company]',
'res_letterbox.nature_id' => '[res_letterbox.custom_1]',
'res_letterbox.nature_id' => '[res_letterbox.customField_1]',
// Initiator
'res_letterbox.initiator_entity_id' => '[initiator.entity_id]',
......@@ -235,7 +236,7 @@ const DATA_CONTACT_ACKNOWLEDGEMENT_RECEIPT = [
'contact.email' => '[sender.email]',
];
$customFields = [
$contactCustomFields = [
['oldId' => 'salutation_header', 'label' => 'Formule de politesse (Début)'],
['oldId' => 'salutation_footer', 'label' => 'Formule de politesse (Fin)'],
['oldId' => 'website', 'label' => 'Site internet'],
......@@ -244,6 +245,18 @@ $customFields = [
['oldId' => 'society_short', 'label' => 'Sigle de la structure'],
];
$resourceCustomFields = [
['id' => 'description', 'label' => 'Autres informations'],
['id' => 'external_reference', 'label' => 'Référence courrier expéditeur'],
['id' => 'reference_number', 'label' => 'N° recommandé'],
['id' => 'scan_date', 'label' => 'Date de scan'],
['id' => 'scan_user', 'label' => 'Utilisateur de scan'],
['id' => 'scan_location', 'label' => 'Lieu de scan'],
['id' => 'scan_wkstation', 'label' => 'Station de scan'],
['id' => 'scan_batch', 'label' => 'Batch de scan'],
['id' => 'scan_postmark', 'label' => 'Tampon de scan'],
];
chdir('../..');
$customs = scandir('custom');
......@@ -256,7 +269,7 @@ foreach ($customs as $custom) {
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $custom]);
foreach ($customFields as $customField) {
foreach ($contactCustomFields as $customField) {
$idNewCustomField = ContactCustomFieldListModel::get([
'select' => ['id'],
'where' => ['label = ?'],
......@@ -265,6 +278,15 @@ foreach ($customs as $custom) {
$DATA_TO_REPLACE["contact." . $customField['oldId']] = "[recipient.customField_{$idNewCustomField[0]['id']}]";
}
foreach ($resourceCustomFields as $customField) {
$idNewCustomField = CustomFieldModel::get([
'select' => ['id'],
'where' => ['label = ?'],
'data' => [$customField['label']]
]);
$DATA_TO_REPLACE["res_letterbox." . $customField['id']] = "[res_letterbox.customField_{$idNewCustomField[0]['id']}]";
}
$migrated = 0;
$nonMigrated = 0;
......
Markdown is supported
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