diff --git a/rest/index.php b/rest/index.php
index d17f1f4fe..0a2bf162f 100755
--- a/rest/index.php
+++ b/rest/index.php
@@ -87,6 +87,7 @@ $app->put('/attachments/{id}/unsign', \SignatureBook\controllers\SignatureBookCo
 $app->post('/attachments/{id}/mailing', \Attachment\controllers\AttachmentController::class . ':getMailingById');
 $app->get('/attachmentsInformations', \Attachment\controllers\AttachmentController::class . ':getByChrono');
 $app->get('/attachmentsTypes', \Attachment\controllers\AttachmentController::class . ':getAttachmentsTypes');
+$app->post('/reconcil', \Attachment\controllers\AttachmentController::class . ':reconcil');
 
 //AutoComplete
 $app->get('/autocomplete/users', \SrcCore\controllers\AutoCompleteController::class . ':getUsers');
maarch@dccourrier-test:/var/www/html/MaarchCourrier$ [20.03.9]git diff
diff --git a/rest/index.php b/rest/index.php
index d17f1f4fe..0a2bf162f 100755
--- a/rest/index.php
+++ b/rest/index.php
@@ -87,6 +87,7 @@ $app->put('/attachments/{id}/unsign', \SignatureBook\controllers\SignatureBookCo
 $app->post('/attachments/{id}/mailing', \Attachment\controllers\AttachmentController::class . ':getMailingById');
 $app->get('/attachmentsInformations', \Attachment\controllers\AttachmentController::class . ':getByChrono');
 $app->get('/attachmentsTypes', \Attachment\controllers\AttachmentController::class . ':getAttachmentsTypes');
+$app->post('/reconcil', \Attachment\controllers\AttachmentController::class . ':reconcil');
 
 //AutoComplete
 $app->get('/autocomplete/users', \SrcCore\controllers\AutoCompleteController::class . ':getUsers');
diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php
index fd5216f1e..e3c24f364 100755
--- a/src/app/attachment/controllers/AttachmentController.php
+++ b/src/app/attachment/controllers/AttachmentController.php
@@ -84,6 +84,71 @@ class AttachmentController
         return $response->withJson(['id' => $id]);
     }
 
+    public function reconcil(Request $request, Response $response)
+    {
+        $body = $request->getParsedBody();
+
+        $control = AttachmentController::controlReconcil(['body' => $body]);
+        if (!empty($control['errors'])) {
+            return $response->withStatus(400)->withJson(['errors' => $control['errors']]);
+        }
+
+        if (!empty($body['chrono'])) {
+            $originAttachment = AttachmentModel::get([
+                'select'    => ['res_id', 'res_id_master', 'title'],
+                'where'     => ['identifier = ? and attachment_type = ?'],
+                'data'      => [$body['chrono'], 'response_project'],
+                'orderBy'   => ['res_id DESC']
+            ]);
+        }
+
+        if (empty($originAttachment[0]['res_id']) || empty($originAttachment[0]['res_id_master'])) {
+            return $response->withStatus(400)->withJson(['errors' => '[AttachmentController create] no origin found for reconcil']);
+        }
+
+        $body['type'] = 'signed_response';
+        $body['status'] = 'A_TRA';
+        $body['originId'] = $originAttachment[0]['res_id'];
+        $body['resIdMaster'] = $originAttachment[0]['res_id_master'];
+        $body['title'] = $originAttachment[0]['title'];
+
+        $id = StoreController::storeAttachment($body);
+        if (empty($id) || !empty($id['errors'])) {
+            return $response->withStatus(500)->withJson(['errors' => '[AttachmentController create] ' . $id['errors']]);
+        }
+
+        AttachmentModel::update(['set' => ['status' => 'SIGN'], 'where' => ['res_id = ?'], 'data' => [$body['originId']]]);
+
+        ConvertPdfController::convert([
+            'resId'     => $id,
+            'collId'    => 'attachments_coll'
+        ]);
+
+        $customId = CoreConfigModel::getCustomId();
+        $customId = empty($customId) ? 'null' : $customId;
+        exec("php src/app/convert/scripts/FullTextScript.php --customId {$customId} --resId {$id} --collId attachments_coll --userId {$GLOBALS['id']} > /dev/null &");
+
+        HistoryController::add([
+            'tableName' => 'res_attachments',
+            'recordId'  => $id,
+            'eventType' => 'ADD',
+            'info'      => _ATTACHMENT_ADDED,
+            'moduleId'  => 'attachment',
+            'eventId'   => 'attachmentAdd'
+        ]);
+
+        HistoryController::add([
+            'tableName' => 'res_letterbox',
+            'recordId'  => $body['resIdMaster'],
+            'eventType' => 'ADD',
+            'info'      => _ATTACHMENT_ADDED . " : {$body['title']}",
+            'moduleId'  => 'attachment',
+            'eventId'   => 'attachmentAdd'
+        ]);
+
+        return $response->withJson(['id' => $id]);
+    }
+
     public function getById(Request $request, Response $response, array $args)
     {
         $attachment = AttachmentModel::getById([
@@ -895,6 +960,27 @@ class AttachmentController
 
         return true;
     }
+    private static function controlReconcil(array $args)
+    {
+        $body = $args['body'];
+
+        if (empty($body)) {
+            return ['errors' => 'Body is not set or empty'];
+        } elseif (!Validator::notEmpty()->validate($body['encodedFile'])) {
+            return ['errors' => 'Body encodedFile is empty'];
+        } elseif (!Validator::stringType()->notEmpty()->validate($body['format'])) {
+            return ['errors' => 'Body format is empty or not a string'];
+        } elseif (!Validator::stringType()->notEmpty()->validate($body['chrono'])) {
+            return ['errors' => 'Body chrono is empty or not a string'];
+        }
+
+        $control = AttachmentController::controlFileData(['body' => $body]);
+        if (!empty($control['errors'])) {
+            return ['errors' => $control['errors']];
+        }
+
+        return true;
+    }
 
     private static function controlFileData(array $args)
     {
diff --git a/src/app/contentManagement/controllers/MergeController.php b/src/app/contentManagement/controllers/MergeController.php
index 323cfbf22..68a6240d8 100644
--- a/src/app/contentManagement/controllers/MergeController.php
+++ b/src/app/contentManagement/controllers/MergeController.php
@@ -33,7 +33,7 @@ use User\models\UserModel;
 
 include_once('vendor/tinybutstrong/opentbs/tbs_plugin_opentbs.php');
 include_once('vendor/rafikhaceb/pi-barcode/pi_barcode.php');
-
+require_once('apps/maarch_entreprise/tools/phpqrcode/qrlib.php');
 
 class MergeController
 {
@@ -348,7 +348,7 @@ class MergeController
 
     public static function mergeChronoDocument(array $args)
     {
-        ValidatorModel::stringType($args, ['path', 'content', 'chrono', 'type']);
+        ValidatorModel::stringType($args, ['path', 'content', 'chrono', 'type', 'resIdMaster', 'resId']);
 
         $tbs = new \clsTinyButStrong();
         $tbs->NoErr = true;
@@ -363,15 +363,19 @@ class MergeController
             $args['path'] = null;
         }
 
-        $barcodeFile = CoreConfigModel::getTmpPath() . mt_rand() ."_{$args['userId']}_barcode.png";
-        $generator = new \PiBarCode();
+        $barcodeFile = CoreConfigModel::getTmpPath() . mt_rand() ."_{$args['resIdMaster']}_barcode.png";
+        /*$generator = new \PiBarCode();
         $generator->setCode($args['chrono']);
         $generator->setType('C128');
         $generator->setSize(30, 50);
         $generator->setText($args['chrono']);
         $generator->hideCodeType();
         $generator->setFiletype('PNG');
-        $generator->writeBarcodeFile($barcodeFile);
+        $generator->writeBarcodeFile($barcodeFile);*/
+
+        $data = 'MAARCH_' . $args['chrono'];
+        //$data = 'MAARCH_' . $args['resIdMaster'] . '_' . $args['chrono'];
+        \QRcode::png($data, $barcodeFile, QR_ECLEVEL_L, 10);
 
         if (!empty($args['path'])) {
             if ($extension == 'odt') {
diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php
index 4c5010708..a35f02903 100755
--- a/src/app/resource/controllers/StoreController.php
+++ b/src/app/resource/controllers/StoreController.php
@@ -103,7 +103,8 @@ class StoreController
                     $uniqueId = CoreConfigModel::uniqueId();
                     $tmpFilename = "storeTmp_{$GLOBALS['id']}_{$uniqueId}.{$args['format']}";
                     file_put_contents($tmpPath . $tmpFilename, $fileContent);
-                    $fileContent = MergeController::mergeChronoDocument(['chrono' => $data['identifier'], 'path' => $tmpPath . $tmpFilename, 'type' => 'attachment']);
+                    //print_r($data);
+                    $fileContent = MergeController::mergeChronoDocument(['resIdMaster' => (string) $data['res_id_master'], 'chrono' => $data['identifier'], 'path' => $tmpPath . $tmpFilename, 'type' => 'attachment']);
                     $fileContent = base64_decode($fileContent['encodedDocument']);
                     unlink($tmpPath . $tmpFilename);
                 }
