diff --git a/appinfo/routes.php b/appinfo/routes.php
index e39ec25614eaf7383e294de8bc1d42729cdd2910..265e3845a618be9e75f18f4f4f5e77b054357f28 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -18,7 +18,6 @@ return [
         ['name' => 'page#agent_list', 'url' => '/agent_list', 'verb' => 'GET'],
         ['name' => 'page#agent_csv', 'url' => '/agent_csv', 'verb' => 'GET'],
         ['name' => 'page#archive_list', 'url' => '/archive_list', 'verb' => 'GET'],
-        ['name' => 'page#archive_list_action', 'url' => '/archive_list_action', 'verb' => 'POST'],
         ['name' => 'page#archive_action', 'url' => '/archive_action', 'verb' => 'POST'],
         ['name' => 'page#user_list', 'url' => '/user_list', 'verb' => ['GET', 'POST']],
     ]
diff --git a/js/script.js b/js/script.js
index 122977c5b35ef43dfcfada7c5a408c12ac3a106a..ef87b4e8abfcdf48e51ca1875eecf6d2b6a60b08 100644
--- a/js/script.js
+++ b/js/script.js
@@ -93,17 +93,25 @@ jQuery(document).ready(function(){
             'style': 'multi',
             'selector': 'input[name="archive_select[]"]'
         },
-        'dom': 'Bfrtip',
+        'dom': 'Blfrtip',
         'buttons': [
-             {
-                 'id': 'btn_create',
-                 'text': 'Créer archive',
-                 'action': function() {
-                     //jQuery('#archive_list').DataTable().rows().select();
-                     jQuery('#demmatpayslip_archive_action').val('create');
-                     jQuery('#demmatpayslip_archive_action_form').submit();
-                 }
-             },
+            {
+                'id': 'btn_create',
+                'text': 'Créer archive',
+                'action': function() {
+                    //jQuery('#archive_list').DataTable().rows().select();
+                    jQuery('#demmatpayslip_archive_action').val('create');
+                    jQuery('#demmatpayslip_archive_action_form').submit();
+                }
+            },
+            {
+                'id': 'btn_delete',
+                'text': 'Ne pas archiver',
+                'action': function() {
+                    jQuery('#demmatpayslip_archive_action').val('delete');
+                    jQuery('#demmatpayslip_archive_action_form').submit();
+                }
+            }
         // 'selectAll',
         // 'selectNone',
         ]
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 3133714ebc2ca04931405e83c96333f0b7f4ae97..61dbeaca4fa303c48816871c057ff65a475f3903 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -182,15 +182,21 @@ class PageController extends Controller {
     /**
      * Assign params for archive list
      *
-     * @return  array   Params for template
+     * @param   int         $archived               [=-1] for all, 0 for not archived and 1 for archived
+     * @return  array       Params for template
      */
-    private function _assignArchiveList() {
+    private function _assignArchiveList($archived) {
+        $paramList = array(
+            'archived' => $archived
+        );
+
         // get archive list
         $dematpayslipArchiveMapper = new DematpayslipArchiveMapper(\OC::$server->getDatabaseConnection());
 
         return array(
-            'dematpayslipArchiveList' => $dematpayslipArchiveMapper->findAll(),
-            'msgList'                 => $this->_msgList
+            'dematpayslipArchiveList' => $dematpayslipArchiveMapper->findAllArchived($archived),
+            'msgList'                 => $this->_msgList,
+            'paramList'               => $paramList
         );
     }
 
@@ -1316,7 +1322,7 @@ class PageController extends Controller {
                     }
 
                     // Phase - decoupage des pages du fichier PDF
-                    if ($this->_process->getHasError()>0)   $this->_processFailOnFirstError=true;
+                    if ($this->_process->getHasError()>0)   $this->_processFailOnFirstError = true;
                     if ($this->_processFailOnFirstError===false || $this->_process->getHasError()<=0) {
                         $this->_logCsvLine('## ' . $this->l->t('Début de découpage des pages du fichier PDF.') . ' ##', self::LOG_DEBUG);
 
@@ -1444,7 +1450,9 @@ class PageController extends Controller {
                 $this->_process->setProcessing(1);
                 $this->_process->setPhase(2);
                 $this->_process->setPhaseStartTime($phaseStartTime);
-                $this->_process->setPhaseStepNum(0);
+                if (!($retry > 0)) {
+                    $this->_process->setPhaseStepNum(0);
+                }
                 $this->_process->setMustTerminate(1);
                 $this->_process->setHasError(0);
                 $this->_process->setErrorCode(0);
@@ -1662,25 +1670,59 @@ class PageController extends Controller {
                                             $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum);
                                         }
 
-                                        // TODO : check if file path not already archived (not have a pastell document Id)
-                                        // insert new file to archive
+                                        // check if file path not already archived (not have a pastell document Id)
                                         $pdfPayslipFile = Filesystem::getFileInfo($pdfPayslipFilePath);
-                                        $dematpayslipArchive = new DematpayslipArchive();
-                                        $dematpayslipArchive->setIdFile($pdfPayslipFile->getId());
-                                        $dematpayslipArchive->setIdUser('');
-                                        $dematpayslipArchive->setFilePath($pdfPayslipFile->getPath());
-                                        $dematpayslipArchive->setDematpayslipIdUser(0);
-                                        $dematpayslipArchive->setSiret($siret);
-                                        $dematpayslipArchive->setMatricule($matricule);
-                                        $dematpayslipArchive->setYear($year);
-                                        $dematpayslipArchive->setMonth($month);
-                                        $dematpayslipArchive->setLastname($lastname);
-                                        $dematpayslipArchive->setFirstname($firstname);
-                                        $dematpayslipArchive->setStartDate($startDate);
-                                        $dematpayslipArchive->setEndDate($endDate);
-                                        $dematpayslipArchive->setEditionDate($editionDate);
-                                        $dematpayslipArchive->setImportTime($phaseStartDateTime->getTimestamp());
-                                        $dematpayslipArchiveMapper->insert($dematpayslipArchive);
+                                        $dematpayslipArchiveExistList = $dematpayslipArchiveMapper->findAllByFilePath($pdfPayslipFile->getPath());
+                                        if (empty($dematpayslipArchiveExistList)) {
+                                            // insert new file to archive
+                                            $dematpayslipArchive = new DematpayslipArchive();
+                                            $dematpayslipArchive->setIdFile($pdfPayslipFile->getId());
+                                            $dematpayslipArchive->setIdUser('');
+                                            $dematpayslipArchive->setFilePath($pdfPayslipFile->getPath());
+                                            $dematpayslipArchive->setDematpayslipIdUser(0);
+                                            $dematpayslipArchive->setSiret($siret);
+                                            $dematpayslipArchive->setMatricule($matricule);
+                                            $dematpayslipArchive->setYear($year);
+                                            $dematpayslipArchive->setMonth($month);
+                                            $dematpayslipArchive->setLastname($lastname);
+                                            $dematpayslipArchive->setFirstname($firstname);
+                                            $dematpayslipArchive->setStartDate($startDate);
+                                            $dematpayslipArchive->setEndDate($endDate);
+                                            $dematpayslipArchive->setEditionDate($editionDate);
+                                            $dematpayslipArchive->setImportTime($phaseStartDateTime->getTimestamp());
+                                            $dematpayslipArchiveMapper->insert($dematpayslipArchive);
+                                        } else {
+                                            if (count($dematpayslipArchiveExistList) > 1) {
+                                                $errorMsg = $this->l->t('Plusieurs bulletins de paie ayant pour chemin "' . $pdfPayslipFile->getPath() . '" existent déjà.');
+                                                $this->_logCsvLine($errorMsg, self::LOG_ERROR, $siret, $matricule, $fullname, $zipCity, $startDate, $endDate, $email);
+                                                $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum);
+                                            } else {
+                                                // only one payslip was found
+                                                $dematpayslipArchiveExist = $dematpayslipArchiveExistList[0];
+
+                                                if (!empty($dematpayslipArchiveExist->getPastellIdDocument())) {
+                                                    $errorMsg = $this->l->t('Ce bulletin de paie ayant pour chemin "' . $pdfPayslipFile->c() . '" est déjà en cours d\'archivage.');
+                                                    $this->_logCsvLine($errorMsg, self::LOG_ERROR, $siret, $matricule, $fullname, $zipCity, $startDate, $endDate, $email);
+                                                    $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum);
+                                                } else {
+                                                    // update file to archive
+                                                    $dematpayslipArchiveExist->setIdFile($pdfPayslipFile->getId());
+                                                    $dematpayslipArchiveExist->setIdUser('');
+                                                    $dematpayslipArchiveExist->setDematpayslipIdUser(0);
+                                                    $dematpayslipArchiveExist->setSiret($siret);
+                                                    $dematpayslipArchiveExist->setMatricule($matricule);
+                                                    $dematpayslipArchiveExist->setYear($year);
+                                                    $dematpayslipArchiveExist->setMonth($month);
+                                                    $dematpayslipArchiveExist->setLastname($lastname);
+                                                    $dematpayslipArchiveExist->setFirstname($firstname);
+                                                    $dematpayslipArchiveExist->setStartDate($startDate);
+                                                    $dematpayslipArchiveExist->setEndDate($endDate);
+                                                    $dematpayslipArchiveExist->setEditionDate($editionDate);
+                                                    $dematpayslipArchiveExist->setImportTime($phaseStartDateTime->getTimestamp());
+                                                    $dematpayslipArchiveMapper->update($dematpayslipArchiveExist);
+                                                }
+                                            }
+                                        }
 
                                         $csvCheckLineNum++;
                                         continue;
@@ -1837,25 +1879,59 @@ class PageController extends Controller {
                                                     }
                                                 }
 
-                                                // TODO : check if file path not already archived (not have a pastell document Id)
-                                                // insert new file to archive
+                                                // check if file path not already archived (not have a pastell document Id)
                                                 $pdfPayslipFile = Filesystem::getFileInfo($pdfPayslipFilePath);
-                                                $dematpayslipArchive = new DematpayslipArchive();
-                                                $dematpayslipArchive->setIdFile($pdfPayslipFile->getId());
-                                                $dematpayslipArchive->setIdUser($dematpayslipUser->getUserId());
-                                                $dematpayslipArchive->setFilePath($pdfPayslipFile->getPath());
-                                                $dematpayslipArchive->setDematpayslipIdUser($dematpayslipUser->getId());
-                                                $dematpayslipArchive->setSiret($siret);
-                                                $dematpayslipArchive->setMatricule($matricule);
-                                                $dematpayslipArchive->setYear($year);
-                                                $dematpayslipArchive->setMonth($month);
-                                                $dematpayslipArchive->setLastname($lastname);
-                                                $dematpayslipArchive->setFirstname($firstname);
-                                                $dematpayslipArchive->setStartDate($startDate);
-                                                $dematpayslipArchive->setEndDate($endDate);
-                                                $dematpayslipArchive->setEditionDate($editionDate);
-                                                $dematpayslipArchive->setImportTime($phaseStartDateTime->getTimestamp());
-                                                $dematpayslipArchiveMapper->insert($dematpayslipArchive);
+                                                $dematpayslipArchiveExistList = $dematpayslipArchiveMapper->findAllByFilePath($pdfPayslipFile->getPath());
+                                                if (empty($dematpayslipArchiveExistList)) {
+                                                    // insert new file to archive
+                                                    $dematpayslipArchive = new DematpayslipArchive();
+                                                    $dematpayslipArchive->setIdFile($pdfPayslipFile->getId());
+                                                    $dematpayslipArchive->setIdUser($dematpayslipUser->getUserId());
+                                                    $dematpayslipArchive->setFilePath($pdfPayslipFile->getPath());
+                                                    $dematpayslipArchive->setDematpayslipIdUser($dematpayslipUser->getId());
+                                                    $dematpayslipArchive->setSiret($siret);
+                                                    $dematpayslipArchive->setMatricule($matricule);
+                                                    $dematpayslipArchive->setYear($year);
+                                                    $dematpayslipArchive->setMonth($month);
+                                                    $dematpayslipArchive->setLastname($lastname);
+                                                    $dematpayslipArchive->setFirstname($firstname);
+                                                    $dematpayslipArchive->setStartDate($startDate);
+                                                    $dematpayslipArchive->setEndDate($endDate);
+                                                    $dematpayslipArchive->setEditionDate($editionDate);
+                                                    $dematpayslipArchive->setImportTime($phaseStartDateTime->getTimestamp());
+                                                    $dematpayslipArchiveMapper->insert($dematpayslipArchive);
+                                                } else {
+                                                    if (count($dematpayslipArchiveExistList) > 1) {
+                                                        $errorMsg = $this->l->t('Plusieurs bulletins de paie ayant pour chemin "' . $pdfPayslipFile->getPath() . '" existent déjà.');
+                                                        $this->_logCsvLine($errorMsg, self::LOG_ERROR, $siret, $matricule, $fullname, $zipCity, $startDate, $endDate, $email);
+                                                        $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum);
+                                                    } else {
+                                                        // only one payslip was found
+                                                        $dematpayslipArchiveExist = $dematpayslipArchiveExistList[0];
+
+                                                        if (!empty($dematpayslipArchiveExist->getPastellIdDocument())) {
+                                                            $errorMsg = $this->l->t('Ce bulletin de paie ayant pour chemin "' . $pdfPayslipFile->getPath() . '" est déjà en cours d\'archivage.');
+                                                            $this->_logCsvLine($errorMsg, self::LOG_ERROR, $siret, $matricule, $fullname, $zipCity, $startDate, $endDate, $email);
+                                                            $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum);
+                                                        } else {
+                                                            // update file to archive
+                                                            $dematpayslipArchiveExist->setIdFile($pdfPayslipFile->getId());
+                                                            $dematpayslipArchiveExist->setIdUser($dematpayslipUser->getUserId());
+                                                            $dematpayslipArchiveExist->setDematpayslipIdUser($dematpayslipUser->getId());
+                                                            $dematpayslipArchiveExist->setSiret($siret);
+                                                            $dematpayslipArchiveExist->setMatricule($matricule);
+                                                            $dematpayslipArchiveExist->setYear($year);
+                                                            $dematpayslipArchiveExist->setMonth($month);
+                                                            $dematpayslipArchiveExist->setLastname($lastname);
+                                                            $dematpayslipArchiveExist->setFirstname($firstname);
+                                                            $dematpayslipArchiveExist->setStartDate($startDate);
+                                                            $dematpayslipArchiveExist->setEndDate($endDate);
+                                                            $dematpayslipArchiveExist->setEditionDate($editionDate);
+                                                            $dematpayslipArchiveExist->setImportTime($phaseStartDateTime->getTimestamp());
+                                                            $dematpayslipArchiveMapper->update($dematpayslipArchiveExist);
+                                                        }
+                                                    }
+                                                }
                                             } else {
                                                 $errorMsg = $this->l->t('L\'utilisateur "' . $userFindByEmailId . '" n\'a pas de dossier SIRET-MATRICULE associé [siret="' . $siret . '", matricule="' . $matricule . '", email="' . $email . '"].');
                                                 $this->_logCsvLine($errorMsg, self::LOG_ERROR, $siret, $matricule, $fullname, $zipCity, $startDate, $endDate, $email);
@@ -2161,155 +2237,12 @@ class PageController extends Controller {
         if ($this->userId === $this->_dematpayslipConfigList['user_id']) {
             $this->_initDematFolders();
 
-            return new TemplateResponse('dematpayslip', 'archive_list', $this->_assignArchiveList());
-        } else {
-            return $this->shares();
-        }
-    }
-
-    /**
-     * Archive list generate
-     *
-     * @NoAdminRequired
-     * @NoCSRFRequired
-     *
-     * @return  TemplateResponse
-     * @throws  \OC\User\NoUserException
-     */
-    public function archiveListAction() {
-        // verifier l'utilisateur
-        if ($this->userId === $this->_dematpayslipConfigList['user_id']) {
-            $this->_initDematFolders();
-
-            $action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
-
-//            if ($action == 'refresh') {
-//                // refresh new payslip files to archive
-//                $dematpayslipArchiveMapper = new DematpayslipArchiveMapper(\OC::$server->getDatabaseConnection());
-//
-//                // payslip list to archive
-//                $payslipDirPath  = $this->_dematpayslipConfigList['payslip_dir'];
-//                $payslipFileList = $this->_findAllFiles($payslipDirPath);
-//                if (!empty($payslipFileList)) {
-//                    foreach ($payslipFileList as $payslipFile) {
-//                        $idFile             = $payslipFile->getId();
-//                        $idUser             = '';
-//                        $dematpayslipIdUser = 0;
-//                        $siret              = '';
-//                        $matricule          = '';
-//                        $year               = '';
-//                        $month              = '';
-//                        $lastname           = '';
-//                        $firstname          = '';
-//                        $startDate          = '';
-//                        $endDate            = '';
-//
-//                        // get file information (ex : files/Bulletins/SIRET-MATRICULE/YEAR/START-DATE_END-DATE.pdf)
-//                        $pathArr = explode('files' . DIRECTORY_SEPARATOR, $payslipFile->getInternalPath());
-//                        if (count($pathArr) > 1) {
-//                            $path = $pathArr[1];
-//                            $payslipDirArr = explode(DIRECTORY_SEPARATOR, $path);
-//                            if (count($payslipDirArr) > 1) {
-//                                $siretMatriculeArr = explode('-', $payslipDirArr[1]);
-//                                if (count($siretMatriculeArr) > 1) {
-//                                    $siret     = $siretMatriculeArr[0];
-//                                    $matricule = $siretMatriculeArr[1];
-//
-//                                    $dematpayslipUserList = $this->_dematpayslipUserMapper->findAllBySiretAndMatricule($siret, $matricule);
-//                                    if (count($dematpayslipUserList) === 1) {
-//                                        $dematpayslipUser   = $dematpayslipUserList[0];
-//                                        $idUser             = $dematpayslipUser->getUserId();
-//                                        $dematpayslipIdUser = $dematpayslipUser->getId();
-//                                        $lastname           = $dematpayslipUser->getLastname();
-//                                        $firstname          = $dematpayslipUser->getFirstname();
-//
-//                                        if (empty($lastname) && empty($firstname)) {
-//                                            $agentUser = \OC::$server->getUserManager()->get($idUser);
-//                                            $agentDisplayNameArr = explode(' ', $agentUser->getDisplayName(), 2);
-//                                            if (count($agentDisplayNameArr) > 1) {
-//                                                $lastname  = $agentDisplayNameArr[0];
-//                                                $firstname = $agentDisplayNameArr[1];
-//                                            }
-//                                        }
-//                                    }
-//                                }
-//                            }
-//
-//                            $payslipFileName = explode('.', $payslipFile->getName());
-//                            $payslipPeriodArr = explode('_', $payslipFileName[0]);
-//                            if (count($payslipPeriodArr) > 1) {
-//                                $startDate = $payslipPeriodArr[0];
-//                                $endDate   = $payslipPeriodArr[1];
-//                                //setlocale(LC_TIME, 'fr_FR');
-//                                $startTime = strtotime($startDate);
-//                                //$startDateTime = new \DateTime();
-//                                //$startDateTime->setTimezone(\OC::$server->getDateTimeZone());
-//                                //$startDateTime->setTimestamp($startTime);
-//                                //$year  = $startDateTime->format('Y');
-//                                //$month = strtolower($startDateTime->format('F'));
-//                                $year  = strftime('%Y', $startTime);
-//                                $month = strtolower(strftime('%B', $startTime));
-//                            }
-//                        }
-//
-//                        // check parameters
-//                        if (!($idFile > 0)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Id de fichier" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (!($dematpayslipIdUser > 0)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Id utilisateur" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($siret)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Siret" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($matricule)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Matricule" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($year)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Année" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($month)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Mois" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($lastname)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Nom" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($firstname)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Prénom" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($startDate)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Date de début" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//                        if (empty($endDate)) {
-//                            $this->_msgList['error'][] = $this->l->t('Le champ "Date de fin" n\'a pas été retrouvé dans le fichier "' . $payslipFile->getInternalPath() . '".');
-//                        }
-//
-//                        if (count($this->_msgList['error']) <= 0) {
-//                            $dematpayslipArchiveList = $dematpayslipArchiveMapper->findAllByIdFile($idFile);
-//                            if (empty($dematpayslipArchiveList)) {
-//                                // insert new file to archive
-//                                $dematpayslipArchive = new DematpayslipArchive();
-//                                $dematpayslipArchive->setIdFile($idFile);
-//                                $dematpayslipArchive->setIdUser($idUser);
-//                                $dematpayslipArchive->setDematpayslipIdUser($dematpayslipIdUser);
-//                                $dematpayslipArchive->setSiret($siret);
-//                                $dematpayslipArchive->setMatricule($matricule);
-//                                $dematpayslipArchive->setYear($year);
-//                                $dematpayslipArchive->setMonth($month);
-//                                $dematpayslipArchive->setLastname($lastname);
-//                                $dematpayslipArchive->setFirstname($firstname);
-//                                $dematpayslipArchive->setStartDate($startDate);
-//                                $dematpayslipArchive->setEndDate($endDate);
-//                                $dematpayslipArchiveMapper->insert($dematpayslipArchive);
-//                            }
-//                        } else {
-//                            break;
-//                        }
-//                    }
-//                }
-//            }
+            $archived = filter_input(INPUT_GET, 'archived', FILTER_SANITIZE_NUMBER_INT);
+            if ($archived === null) {
+                $archived = -1;
+            }
 
-            return new TemplateResponse('dematpayslip', 'archive_list', $this->_assignArchiveList());
+            return new TemplateResponse('dematpayslip', 'archive_list', $this->_assignArchiveList($archived));
         } else {
             return $this->shares();
         }
@@ -2329,14 +2262,18 @@ class PageController extends Controller {
         if ($this->userId === $this->_dematpayslipConfigList['user_id']) {
             $this->_initDematFolders();
 
-            $action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
+            $archived = filter_input(INPUT_POST, 'archived', FILTER_SANITIZE_NUMBER_INT);
+            if ($archived === null) {
+                $archived = -1;
+            }
 
-            if ($action == 'create') {
-                $archiveSelectIdList = filter_input(INPUT_POST, 'archive_select', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
+            $action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
+            $archiveSelectIdList = filter_input(INPUT_POST, 'archive_select', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
 
-                if (!empty($archiveSelectIdList)) {
-                    $dematpayslipArchiveMapper = new DematpayslipArchiveMapper(\OC::$server->getDatabaseConnection());
+            if (!empty($archiveSelectIdList)) {
+                $dematpayslipArchiveMapper = new DematpayslipArchiveMapper(\OC::$server->getDatabaseConnection());
 
+                if ($action == 'create') {
                     foreach ($archiveSelectIdList as $archiveSelectId) {
                         $dematpayslipArchive = $dematpayslipArchiveMapper->find(intval($archiveSelectId));
                         if (!empty($dematpayslipArchive)) {
@@ -2349,9 +2286,9 @@ class PageController extends Controller {
                             }
 
                             // Pastell API config
-                            $pastellConfigFlowId     = $this->config->getAppValue($this->appName, 'pastell_config_flow' . $archiveFlowNum . '_id', '');
+                            $pastellConfigFlowId = $this->config->getAppValue($this->appName, 'pastell_config_flow' . $archiveFlowNum . '_id', '');
                             $pastellConfigFlowMapper = new PastellConfigFlowMapper(\OC::$server->getDatabaseConnection());
-                            $pastellConfigFlow       = $pastellConfigFlowMapper->find($pastellConfigFlowId);
+                            $pastellConfigFlow = $pastellConfigFlowMapper->find($pastellConfigFlowId);
 
                             try {
                                 // Pastell API connection
@@ -2386,10 +2323,10 @@ class PageController extends Controller {
                                 }
                                 if ($dematpayslipArchive->getPastellLastAction() == 'modification') {
                                     // send document file
-                                    $fileId      = $dematpayslipArchive->getIdFile();
-                                    $filePath    = Filesystem::getPath($fileId);
-                                    $file        = Filesystem::getFileInfo($filePath);
-                                    $fileName    = $file->getName();
+                                    $fileId = $dematpayslipArchive->getIdFile();
+                                    $filePath = Filesystem::getPath($fileId);
+                                    $file = Filesystem::getFileInfo($filePath);
+                                    $fileName = $file->getName();
                                     $fileContent = 'TEST';
                                     //$fileContent = Filesystem::file_get_contents($filePath);
                                     $responseData = $pastellAPI->postEntityDocumentFile($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), 'document', 0, $fileName, $fileContent);
@@ -2412,12 +2349,12 @@ class PageController extends Controller {
                                 if ($dematpayslipArchive->getPastellLastAction() == 'preparation-suppression-automatique') {
                                     // create "sae_config" JSON file and send it
                                     $saeConfigArr = array(
-                                        'matricule'         => $dematpayslipArchive->getMatricule(),
-                                        'mois'              => $dematpayslipArchive->getMonth(),
-                                        'annee'             => $dematpayslipArchive->getYear(),
-                                        'nom'               => $dematpayslipArchive->getLastname(),
-                                        'prenom'            => $dematpayslipArchive->getFirstname(),
-                                        'date_edition'      => $dematpayslipArchive->getEditionDate(),
+                                        'matricule' => $dematpayslipArchive->getMatricule(),
+                                        'mois' => $dematpayslipArchive->getMonth(),
+                                        'annee' => $dematpayslipArchive->getYear(),
+                                        'nom' => $dematpayslipArchive->getLastname(),
+                                        'prenom' => $dematpayslipArchive->getFirstname(),
+                                        'date_edition' => $dematpayslipArchive->getEditionDate(),
                                         'periode_2_de_paie' => $dematpayslipArchive->getEndDate(),
                                         'periode_1_de_paie' => $dematpayslipArchive->getStartDate(),
                                     );
@@ -2439,10 +2376,21 @@ class PageController extends Controller {
                             }
                         }
                     }
+                } elseif ($action == 'delete') {
+                    foreach ($archiveSelectIdList as $archiveSelectId) {
+                        $dematpayslipArchive = $dematpayslipArchiveMapper->find(intval($archiveSelectId));
+                        if (!empty($dematpayslipArchive)) {
+                            if (!empty($dematpayslipArchive->getPastellIdDocument())) {
+                                $this->_msgList['error'][] = $this->l->t('Impossible de supprimer le bulletin de paie "' . $dematpayslipArchive->getFilePath() . '" en cours d\'archivage.');;
+                            } else {
+                                $dematpayslipArchiveMapper->delete($dematpayslipArchive);
+                            }
+                        }
+                    }
                 }
             }
 
-            return new TemplateResponse('dematpayslip', 'archive_list', $this->_assignArchiveList());
+            return new TemplateResponse('dematpayslip', 'archive_list', $this->_assignArchiveList($archived));
         } else {
             return $this->shares();
         }
diff --git a/lib/Db/DematpayslipArchiveMapper.php b/lib/Db/DematpayslipArchiveMapper.php
index ced7f3327798b9723391f48c77972c020e9cacae..e050e090b8976f64ac8b03f97440a317d385e3d2 100644
--- a/lib/Db/DematpayslipArchiveMapper.php
+++ b/lib/Db/DematpayslipArchiveMapper.php
@@ -34,6 +34,40 @@ class DematpayslipArchiveMapper extends QBMapper {
         return $this->findEntities($qb);
     }
 
+    public function findAllByFilePath(string $filePath) {
+        $qb = $this->db->getQueryBuilder();
+
+        $qb->select('*')
+            ->from($this->getTableName())
+            ->where(
+                $qb->expr()->eq('file_path', $qb->createNamedParameter($filePath))
+            );
+
+        return $this->findEntities($qb);
+    }
+
+    public function findAllArchived(int $archived) {
+        $qb = $this->db->getQueryBuilder();
+
+        $qb->select('*');
+        $qb->from($this->getTableName());
+        $qb->where(
+            $qb->expr()->eq('disabled', $qb->createNamedParameter(0))
+        );
+
+        if ($archived == 1) {
+            $qb->where(
+                $qb->expr()->isNotNull('pastell_id_document')
+            );
+        } elseif ($archived == 0) {
+            $qb->where(
+                $qb->expr()->isNull('pastell_id_document')
+            );
+        }
+
+        return $this->findEntities($qb);
+    }
+
     public function findAll() {
         $qb = $this->db->getQueryBuilder();
 
diff --git a/templates/content/archive_list.php b/templates/content/archive_list.php
index cfe207b39736fb831044dd613bee0237bb2cd942..12034d121455151757c6d78e3a1bf32c912a4fe6 100644
--- a/templates/content/archive_list.php
+++ b/templates/content/archive_list.php
@@ -2,6 +2,7 @@
     // assigned
     $dematpayslipArchiveList = (isset($_['dematpayslipArchiveList']) ? $_['dematpayslipArchiveList'] : array());
     $msgList                 = (isset($_['msgList']) ? $_['msgList'] : array());
+    $paramList               = (isset($_['paramList']) ? $_['paramList'] : array());
 
     // alert messages
     $htmlAlert = '';
@@ -48,18 +49,11 @@
         <h2><?php p($l->t('Liste des archives')); ?>&nbsp</h2>
         <br />
 
-<!--        <form action="--><?php //echo \OC\URLGenerator::linkToRoute('dematpayslip.page.archive_list_action'); ?><!--" name="demmatpayslip_archive_list_action_form" method="post">-->
-<!--            <input type="hidden" name="requesttoken" value="--><?php //p($_['requesttoken']); ?><!--">-->
-<!--            <input type="hidden" name="action" value="refresh" />-->
-<!--            <div>-->
-<!--                <button type="submit" class="btn btn-default">--><?php //p($l->t('Actualiser')); ?><!--</button>-->
-<!--            </div>-->
-<!--        </form>-->
-<!--        <br />-->
-<!--        <br />-->
-
         <form action="<?php echo \OC\URLGenerator::linkToRoute('dematpayslip.page.archive_action'); ?>" id="demmatpayslip_archive_action_form" name="demmatpayslip_archive_action_form" method="post">
             <input type="hidden" id="demmatpayslip_archive_action" name="action" value="" />
+            <?php foreach ($paramList as $paramName => $paramValue) { ?>
+                <input type="hidden" name="<?php print $paramName; ?>" value="<?php print $paramValue; ?>" />
+            <?php } ?>
             <div class="table-responsive">
                 <table class="table table-bordered" id="archive_list">
                     <thead class="thead-dark">
@@ -82,7 +76,7 @@
                         <?php foreach ($dematpayslipArchiveList as $dematpayslipArchive) { ?>
                             <tr>
                                 <td><input type="checkbox" class="archive_select" id="archive_select_<?php print $dematpayslipArchive->getId(); ?>" name="archive_select[]" value="<?php print $dematpayslipArchive->getId(); ?>" style="cursor: pointer;" /></td>
-                                <td><?php print $dematpayslipArchive->getFilePath(); ?></td>
+                                <td><a href="<?php echo \OC\URLGenerator::linkToRoute('files.view.index', ['fileid' => $dematpayslipArchive->getIdFile()]); ?>" title="<?php p($l->t('Voir')); ?>"><?php print $dematpayslipArchive->getFilePath(); ?></a></td>
                                 <td><?php print $dematpayslipArchive->getSiret(); ?></td>
                                 <td><?php print $dematpayslipArchive->getMatricule(); ?></td>
                                 <td><?php print $dematpayslipArchive->getLastname(); ?></td>
diff --git a/templates/navigation/index.php b/templates/navigation/index.php
index de8c06222801168e3c19a6800a6cce13a401c69d..cd408ae9bfefe56882735bebd324a8713fafb590 100644
--- a/templates/navigation/index.php
+++ b/templates/navigation/index.php
@@ -2,4 +2,10 @@
 	<li><a href="<?php echo \OC\URLGenerator::linkToRoute('dematpayslip.page.index'); ?>">Dématérialisation</a></li>
     <li><a href="<?php echo \OC\URLGenerator::linkToRoute('dematpayslip.page.agent_list'); ?>">Liste des agents</a></li>
     <li><a href="<?php echo \OC\URLGenerator::linkToRoute('dematpayslip.page.archive_list'); ?>">Liste des archives</a></li>
+    <li>
+        <ul>
+            <li><a href="<?php echo \OC\URLGenerator::linkToRoute('dematpayslip.page.archive_list', ['archived' => 0]); ?>">A traiter</a></li>
+            <li><a href="<?php echo \OC\URLGenerator::linkToRoute('dematpayslip.page.archive_list', ['archived' => 1]); ?>">Traitées</a></li>
+        </ul>
+    </li>
 </ul>