Verified Commit a4cd13d8 authored by Damien's avatar Damien

FEAT #11422 TIME 0:30 Export fileplans

parent 6ee53316
......@@ -43,5 +43,5 @@ foreach ($customs as $custom) {
fclose($file);
}
printf("Export Affaires (CUSTOM {$custom}) : " . $migrated . " Affaires exportée(s) dans le fichier cases_{$custom}.csv\n");
printf("Export Affaires (CUSTOM {$custom}) : " . $migrated . " Affaire(s) exportée(s) dans le fichier cases_{$custom}.csv\n");
}
<?php
require '../../vendor/autoload.php';
chdir('../..');
$customs = scandir('custom');
foreach ($customs as $custom) {
if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
continue;
}
$migrated = 0;
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $custom]);
$fileplans = \SrcCore\models\DatabaseModel::select([
'select' => ['*'],
'table' => ['fp_fileplan'],
'where' => ['user_id is null']
]);
if (!empty($fileplans)) {
$file = fopen("migration/19.12/fileplans_{$custom}.csv", 'w+');
$csvHead = ['Identifiant plan', 'Libellé plan', 'Identifiant position', 'Libellé position', 'Identifiant courrier', 'Sujet courrier'];
fputcsv($file, $csvHead, ',');
foreach ($fileplans as $fileplan) {
$csvContent = [];
$positions = \SrcCore\models\DatabaseModel::select([
'select' => ['*'],
'table' => ['fp_fileplan_positions'],
'where' => ['fileplan_id = ?'],
'data' => [$fileplan['fileplan_id']]
]);
foreach ($positions as $position) {
$resources = \SrcCore\models\DatabaseModel::select([
'select' => ['res_letterbox.res_id', 'res_letterbox.subject'],
'table' => ['fp_res_fileplan_positions, res_letterbox'],
'where' => ['fp_res_fileplan_positions.res_id = res_letterbox.res_id', 'position_id = ?'],
'data' => [$position['position_id']]
]);
foreach ($resources as $resource) {
$csvContent = [$fileplan['fileplan_id'], $fileplan['fileplan_label'], $position['position_id'], $position['position_label'], $resource['res_id'], $resource['subject']];
fputcsv($file, $csvContent, ',');
}
}
if (!empty($csvContent)) {
++$migrated;
}
}
fclose($file);
}
printf("Export Plans de Classements (CUSTOM {$custom}) : " . $migrated . " Plan(s) de classement public exportée(s) dans le fichier fileplans_{$custom}.csv\n");
}
......@@ -7,3 +7,4 @@ php ./migrateIndexing.php
php ./migrateServicesEntities.php
php ./migrateMenuEntities.php
php ./exportCases.php
php ./exportFileplans.php
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