From 1f48b9658cd37a8932ab66bf6ae9c7c76d7b9d6d Mon Sep 17 00:00:00 2001 From: VESSILLER <lvessiller@open-dsi.fr> Date: Mon, 8 Jun 2020 17:39:07 +0200 Subject: [PATCH] NEW ajout bouton "tout archiver" et d'un etat avec date du changement d'etat --- js/script.js | 67 +++-- lib/Controller/PageController.php | 267 +++++++++++------- lib/Db/DematpayslipArchive.php | 30 +- lib/Db/DematpayslipArchiveMapper.php | 11 +- ...hp => Version020000Date20200608040000.php} | 9 +- templates/content/archive_list.php | 2 +- 6 files changed, 243 insertions(+), 143 deletions(-) rename lib/Migration/{Version020000Date20200603030000.php => Version020000Date20200608040000.php} (94%) diff --git a/js/script.js b/js/script.js index c59603c..4a3141f 100644 --- a/js/script.js +++ b/js/script.js @@ -52,6 +52,46 @@ jQuery(document).ready(function(){ }); jQuery(document).ready(function(){ + let paramArchived = parseInt(jQuery('#param_archived').val()); + + let buttons = []; + if (paramArchived === -1 || paramArchived === 0) { + buttons.push({ + 'id': 'btn_create', + 'text': 'Archiver', + 'action': function() { + jQuery('#demmatpayslip_archive_action').val('create'); + jQuery('#demmatpayslip_archive_action_form').submit(); + } + }); + buttons.push({ + 'id': 'btn_create_all', + 'text': 'Tout archiver', + 'action': function() { + jQuery('#demmatpayslip_archive_action').val('create_all'); + jQuery('#demmatpayslip_archive_action_form').submit(); + } + }); + buttons.push({ + 'id': 'btn_delete', + 'text': 'Ne pas archiver', + 'action': function() { + jQuery('#demmatpayslip_archive_action').val('delete'); + jQuery('#demmatpayslip_archive_action_form').submit(); + } + }); + } + if (paramArchived === -1 || paramArchived === 1) { + buttons.push({ + 'id': 'btn_refresh_status', + 'text': 'Actualiser les états', + 'action': function() { + jQuery('#demmatpayslip_archive_action').val('refresh_status'); + jQuery('#demmatpayslip_archive_action_form').submit(); + } + }); + } + var table = jQuery('#archive_list').DataTable({ "language" : { "processing": "Traitement en cours...", @@ -94,32 +134,7 @@ jQuery(document).ready(function(){ 'selector': 'input[name="archive_select[]"]' }, 'dom': 'Blfrtip', - 'buttons': [ - { - 'id': 'btn_refresh_status', - 'text': 'Actualiser les états', - 'action': function() { - jQuery('#demmatpayslip_archive_action').val('refresh_status'); - jQuery('#demmatpayslip_archive_action_form').submit(); - } - }, - { - 'id': 'btn_create', - 'text': 'Archiver', - 'action': function() { - 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(); - } - } - ] + 'buttons': buttons }); jQuery('#archive_select_all').click(function(){ diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index bcc68e6..549d42c 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -172,8 +172,8 @@ class PageController extends Controller { if (empty($dematpayslipArchiveExistList)) { $dematpayslipArchive = new DematpayslipArchive(); } elseif (count($dematpayslipArchiveExistList) === 1) { - if (!empty($dematpayslipArchiveExistList[0]->getPastellIdDocument())) { - $warningMsg = $this->l->t('Le bulletin de paie de l\'agent "' . $agentUser->getLastname() . ' ' . $agentUser->getFirstname() . '" pour la période du ' . $startDate . ' au ' . $endDate . ' est déjà en cours d\'archivage.'); + if ($dematpayslipArchiveExistList[0]->isArchived()===true) { + $warningMsg = $this->l->t('Le bulletin de paie de l\'agent "' . $agentUser->getLastname() . ' ' . $agentUser->getFirstname() . '" pour la période du ' . $startDate . ' au ' . $endDate . ' est déjà archivée.'); $this->_logCsvLine($warningMsg, self::LOG_WARNING, $agentUser, $startDate, $endDate); $this->_processWarningMsg($warningMsg); } else { @@ -188,6 +188,135 @@ class PageController extends Controller { return $dematpayslipArchive; } + /** + * Archive process + * + * @param DematpayslipArchiveMapper $dematpayslipArchiveMapper Archive table mapper + * @param DematpayslipArchive $dematpayslipArchive Archive + */ + private function _archiveProcess(DematpayslipArchiveMapper $dematpayslipArchiveMapper, DematpayslipArchive $dematpayslipArchive) { + $archiveFlowNum = 1; // archiving for 5 years by default + + // get dematpayslip user + if (!empty($dematpayslipArchive->getDematpayslipIdUser())) { + $dematpayslipUser = $this->_dematpayslipUserMapper->find($dematpayslipArchive->getDematpayslipIdUser()); + if ($dematpayslipUser->getDisabled() == 0) { + $archiveFlowNum = 2; // archiving for 50 years + } + } + + // Pastell API config + $pastellConfigFlowId = $this->config->getAppValue($this->appName, 'pastell_config_flow' . $archiveFlowNum . '_id', ''); + $pastellConfigFlowMapper = new PastellConfigFlowMapper(\OC::$server->getDatabaseConnection()); + $pastellConfigFlow = $pastellConfigFlowMapper->find($pastellConfigFlowId); + + try { + // Pastell API connection + $pastellAPI = new PastellAPI($pastellConfigFlow->getIdConfig()); + + $canCreateArchive = false; + if ($dematpayslipArchive->isArchived() === false) { + $canCreateArchive = true; + } else { + // get and modify document last action + $responseData = $pastellAPI->getEntityDocument($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument()); + if (!empty($responseData['last_action']['action'])) { + $dematpayslipArchive->setPastellLastAction($responseData['last_action']['action']); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + } + } + + if ($canCreateArchive === false) { + $this->_msgList['error'][] = $this->l->t('L\'archive "' . $dematpayslipArchive->getFilePath() . '" a déjà été créée.'); + } else { + // create document + $nowDateTime = new \DateTime('now', \OC::$server->getDateTimeZone()->getTimeZone()); + $responseData = $pastellAPI->postEntityDocument($pastellConfigFlow->getIdE(), array( + 'type' => 'pdf-generique' + )); + $dematpayslipArchive->setPastellIdDocument($responseData['id_d']); + $dematpayslipArchive->setPastellLastAction($responseData['last_action']['action']); + $dematpayslipArchive->setStatus(DematpayslipArchive::STATUS_CREATED); + $dematpayslipArchive->setStatusTime($nowDateTime->getTimestamp()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + + if ($dematpayslipArchive->getPastellLastAction() == 'creation') { + // set document title + $nowDateTime = new \DateTime('now', \OC::$server->getDateTimeZone()->getTimeZone()); + $responseData = $pastellAPI->patchEntityDocument($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), array( + 'libelle' => $dematpayslipArchive->getId() . '_' . $dematpayslipArchive->getStartDate() . '_' . $dematpayslipArchive->getEndDate() + )); + $dematpayslipArchive->setPastellLastAction($responseData['content']['last_action']['action']); + $dematpayslipArchive->setStatus(DematpayslipArchive::STATUS_TITLED); + $dematpayslipArchive->setStatusTime($nowDateTime->getTimestamp()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + } + if ($dematpayslipArchive->getPastellLastAction() == 'modification') { + // send document file + $nowDateTime = new \DateTime('now', \OC::$server->getDateTimeZone()->getTimeZone()); + $fileId = $dematpayslipArchive->getIdFile(); + $filePath = Filesystem::getPath($fileId); + $file = Filesystem::getFileInfo($filePath); + $fileName = $file->getName(); + $fileContent = Filesystem::file_get_contents($filePath); + $responseData = $pastellAPI->postEntityDocumentFile($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), 'document', 0, $fileName, $fileContent); + $dematpayslipArchive->setPastellLastAction($responseData['content']['last_action']['action']); + $dematpayslipArchive->setStatus(DematpayslipArchive::STATUS_FILE_SENT); + $dematpayslipArchive->setStatusTime($nowDateTime->getTimestamp()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + + // set orientation action on document + $nowDateTime = new \DateTime('now', \OC::$server->getDateTimeZone()->getTimeZone()); + $responseData = $pastellAPI->postEntityDocumentAction($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), 'orientation'); + if ($responseData['result'] == true) { + // get and modify document last action + $responseData = $pastellAPI->getEntityDocument($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument()); + if (!empty($responseData['last_action']['action'])) { + $dematpayslipArchive->setPastellLastAction($responseData['last_action']['action']); + $dematpayslipArchive->setStatus(DematpayslipArchive::STATUS_ORIENTATION); + $dematpayslipArchive->setStatusTime($nowDateTime->getTimestamp()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + } + } + } + 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(), + 'periode_2_de_paie' => $dematpayslipArchive->getEndDate(), + 'periode_1_de_paie' => $dematpayslipArchive->getStartDate(), + ); + $jsonFileName = 'sae_config.json'; + $jsonFilePath = $this->_tmpDirUserPath . DIRECTORY_SEPARATOR . $jsonFileName; + Filesystem::fopen($jsonFilePath, 'w+'); + Filesystem::file_put_contents($jsonFilePath, json_encode($saeConfigArr)); + + // add meta-data on document + $nowDateTime = new \DateTime('now', \OC::$server->getDateTimeZone()->getTimeZone()); + $jsonFileContent = Filesystem::file_get_contents($jsonFilePath); + $responseData = $pastellAPI->postEntityDocumentFile($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), 'sae_config', 0, $jsonFileName, $jsonFileContent); + $dematpayslipArchive->setPastellLastAction($responseData['content']['last_action']['action']); + $dematpayslipArchive->setStatus(DematpayslipArchive::STATUS_METADATA_SENT); + $dematpayslipArchive->setStatusTime($nowDateTime->getTimestamp()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + } + + if ($dematpayslipArchive->getStatus() < DematpayslipArchive::STATUS_METADATA_SENT) { + $this->_msgList['error'][] = $this->l->t('L\'archive "' . $dematpayslipArchive->getFilePath() . '" n\'a pas été correctement archivée [status=' . $dematpayslipArchive->getStatus() .'].'); + } else { + $this->_msgList['success'][] = $this->l->t('L\'archive "' . $dematpayslipArchive->getFilePath() . '" a été créée.'); + } + } + } catch (\Exception $e) { + $this->_msgList['error'][] = $e->getMessage(); + } + } + /** * Save archive file for an agent and a period * @@ -205,6 +334,8 @@ class PageController extends Controller { * @throws \Exception */ private function _archiveSaveForAgentAndPeriod(DematpayslipArchiveMapper $dematpayslipArchiveMapper, DematpayslipArchive $dematpayslipArchive, $archiveFilePath, DematpayslipUser $agentUser, $startDate, $endDate, $year, $month, $editionDate, $importTime) { + $nowDateTime = new \DateTime('now', \OC::$server->getDateTimeZone()->getTimeZone()); + $archiveFile = Filesystem::getFileInfo($archiveFilePath); $archiveFileChecksum = Filesystem::hash('md5', $archiveFilePath); @@ -221,6 +352,8 @@ class PageController extends Controller { $dematpayslipArchive->setStartDate($startDate); $dematpayslipArchive->setEndDate($endDate); $dematpayslipArchive->setEditionDate($editionDate); + $dematpayslipArchive->setStatus(DematpayslipArchive::STATUS_INITIALIZED); + $dematpayslipArchive->setStatusTime($nowDateTime->getTimestamp()); $dematpayslipArchive->setImportTime($importTime); $dematpayslipArchive->setChecksum($archiveFileChecksum); @@ -286,7 +419,7 @@ class PageController extends Controller { // get dematpayslip user if (!empty($dematpayslipArchive->getDematpayslipIdUser())) { - $dematpayslipUser = $dematpayslipArchiveMapper->find($dematpayslipArchive->getDematpayslipIdUser()); + $dematpayslipUser = $this->_dematpayslipUserMapper->find($dematpayslipArchive->getDematpayslipIdUser()); if ($dematpayslipUser->getDisabled() == 0) { $archiveFlowNum = 2; // archiving for 50 years } @@ -310,8 +443,14 @@ class PageController extends Controller { } catch (\Exception $e) { $this->_msgList['error'][] = $e->getMessage(); } + + if (count($this->_msgList['error']) > 0) break; } } + + if (count($this->_msgList['error']) <= 0) { + $this->_msgList['success'][] = $this->l->t('Liste actualisée avec succès.'); + } } $dematpayslipArchiveList = $dematpayslipArchiveMapper->findAllArchived($archived); @@ -2326,6 +2465,8 @@ class PageController extends Controller { $archived = filter_input(INPUT_POST, 'archived', FILTER_SANITIZE_NUMBER_INT); if ($archived === null) { $archived = -1; + } else { + $archived = intval($archived); } $refresh = false; @@ -2342,121 +2483,33 @@ class PageController extends Controller { foreach ($archiveSelectIdList as $archiveSelectId) { $dematpayslipArchive = $dematpayslipArchiveMapper->find(intval($archiveSelectId)); if (!empty($dematpayslipArchive)) { - $archiveFlowNum = 1; // archiving for 5 years by default - - // get dematpayslip user - if (!empty($dematpayslipArchive->getDematpayslipIdUser())) { - $dematpayslipUser = $this->_dematpayslipUserMapper->find($dematpayslipArchive->getDematpayslipIdUser()); - if ($dematpayslipUser->getDisabled() == 0) { - $archiveFlowNum = 2; // archiving for 50 years - } - } - - // Pastell API config - $pastellConfigFlowId = $this->config->getAppValue($this->appName, 'pastell_config_flow' . $archiveFlowNum . '_id', ''); - $pastellConfigFlowMapper = new PastellConfigFlowMapper(\OC::$server->getDatabaseConnection()); - $pastellConfigFlow = $pastellConfigFlowMapper->find($pastellConfigFlowId); - - try { - // Pastell API connection - $pastellAPI = new PastellAPI($pastellConfigFlow->getIdConfig()); - - $canCreateArchive = false; - if (empty($dematpayslipArchive->getPastellIdDocument())) { - $canCreateArchive = true; - } else { - // get and modify document last action - $responseData = $pastellAPI->getEntityDocument($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument()); - if (!empty($responseData['last_action']['action'])) { - $dematpayslipArchive->setPastellLastAction($responseData['last_action']['action']); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - } - } - - if ($canCreateArchive === false) { - $this->_msgList['error'][] = $this->l->t('L\'archive "' . $dematpayslipArchive->getFilePath() . '" a déjà été créée.'); - } else { - // create document - $responseData = $pastellAPI->postEntityDocument($pastellConfigFlow->getIdE(), array( - 'type' => 'pdf-generique' - )); - $dematpayslipArchive->setPastellIdDocument($responseData['id_d']); - $dematpayslipArchive->setPastellLastAction($responseData['last_action']['action']); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - - if ($dematpayslipArchive->getPastellLastAction() == 'creation') { - // set document title - $responseData = $pastellAPI->patchEntityDocument($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), array( - 'libelle' => $dematpayslipArchive->getId() . '_' . $dematpayslipArchive->getStartDate() . '_' . $dematpayslipArchive->getEndDate() - )); - $dematpayslipArchive->setPastellLastAction($responseData['content']['last_action']['action']); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - } - if ($dematpayslipArchive->getPastellLastAction() == 'modification') { - // send document file - $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); - $dematpayslipArchive->setPastellLastAction($responseData['content']['last_action']['action']); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - - // set orientation action on document - $responseData = $pastellAPI->postEntityDocumentAction($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), 'orientation'); - if ($responseData['result'] == true) { - // get and modify document last action - $responseData = $pastellAPI->getEntityDocument($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument()); - if (!empty($responseData['last_action']['action'])) { - $dematpayslipArchive->setPastellLastAction($responseData['last_action']['action']); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - } - } - } - 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(), - 'periode_2_de_paie' => $dematpayslipArchive->getEndDate(), - 'periode_1_de_paie' => $dematpayslipArchive->getStartDate(), - ); - $jsonFileName = 'sae_config.json'; - $jsonFilePath = $this->_tmpDirUserPath . DIRECTORY_SEPARATOR . $jsonFileName; - Filesystem::fopen($jsonFilePath, 'w+'); - Filesystem::file_put_contents($jsonFilePath, json_encode($saeConfigArr)); - - // add meta-data on document - $jsonFileContent = Filesystem::file_get_contents($jsonFilePath); - $responseData = $pastellAPI->postEntityDocumentFile($pastellConfigFlow->getIdE(), $dematpayslipArchive->getPastellIdDocument(), 'sae_config', 0, $jsonFileName, $jsonFileContent); - $dematpayslipArchive->setPastellLastAction($responseData['content']['last_action']['action']); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - $this->_msgList['success'][] = $this->l->t('L\'archive "' . $dematpayslipArchive->getFilePath() . '" a été créée.'); - } - } - } catch (\Exception $e) { - $this->_msgList['error'][] = $e->getMessage(); - } + $this->_archiveProcess($dematpayslipArchiveMapper, $dematpayslipArchive); } } } + } elseif ($action == 'create_all') { + $dematpayslipArchiveMapper = new DematpayslipArchiveMapper(\OC::$server->getDatabaseConnection()); + $dematpayslipArchiveList = $dematpayslipArchiveMapper->findAllArchived(0); + + foreach ($dematpayslipArchiveList as $dematpayslipArchive) { + if (!empty($dematpayslipArchive)) { + $this->_archiveProcess($dematpayslipArchiveMapper, $dematpayslipArchive); + } + } } elseif ($action == 'delete') { + $nowDateTime = new \DateTime('now', \OC::$server->getDateTimeZone()->getTimeZone()); $dematpayslipArchiveMapper = new DematpayslipArchiveMapper(\OC::$server->getDatabaseConnection()); if (!empty($archiveSelectIdList)) { 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.');; + if ($dematpayslipArchive->isArchived() === true) { + $this->_msgList['error'][] = $this->l->t('Impossible de supprimer le bulletin de paie "' . $dematpayslipArchive->getFilePath() . '" déjà archivé.');; } else { - $dematpayslipArchiveMapper->delete($dematpayslipArchive); + $dematpayslipArchive->setStatus(DematpayslipArchive::STATUS_DELETED); + $dematpayslipArchive->setStatusTime($nowDateTime->getTimestamp()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); } } } diff --git a/lib/Db/DematpayslipArchive.php b/lib/Db/DematpayslipArchive.php index 02c699c..a939e25 100644 --- a/lib/Db/DematpayslipArchive.php +++ b/lib/Db/DematpayslipArchive.php @@ -7,6 +7,17 @@ use OCP\AppFramework\Db\Entity; class DematpayslipArchive extends Entity implements JsonSerializable { + /** + * Const status + */ + const STATUS_DELETED = -1; + const STATUS_INITIALIZED = 0; + const STATUS_CREATED = 1; + const STATUS_TITLED = 2; + const STATUS_FILE_SENT = 3; + const STATUS_ORIENTATION = 4; + const STATUS_METADATA_SENT = 5; + protected $idFile; protected $idUser; protected $filePath; @@ -21,7 +32,8 @@ class DematpayslipArchive extends Entity implements JsonSerializable { protected $startDate; protected $endDate; protected $editionDate; - protected $disabled; + protected $status; + protected $statusTime; protected $pastellUrl; protected $pastellLastAction; protected $importTime; @@ -44,11 +56,25 @@ class DematpayslipArchive extends Entity implements JsonSerializable { 'startDate' => $this->startDate, 'endDate' => $this->endDate, 'editionDate' => $this->editionDate, - 'disabled' => $this->disabled, + 'status' => $this->status, + 'status_time' => $this->statusTime, 'pastellUrl' => $this->pastellUrl, 'pastellLastAction' => $this->pastellLastAction, 'importTime' => $this->importTime, 'checksum' => $this->checksum, ]; } + + /** + * Determine if it have already been archived (can't modify) + * + * @return bool + */ + public function isArchived() { + if (!empty($this->getPastellIdDocument())) { + return true; + } else { + return false; + } + } } diff --git a/lib/Db/DematpayslipArchiveMapper.php b/lib/Db/DematpayslipArchiveMapper.php index f9a53d9..efe3c3f 100644 --- a/lib/Db/DematpayslipArchiveMapper.php +++ b/lib/Db/DematpayslipArchiveMapper.php @@ -68,7 +68,10 @@ class DematpayslipArchiveMapper extends QBMapper { ) ->andWhere( $qb->expr()->eq('end_date', $qb->createNamedParameter($end_date)) - ); + ) + ->andWhere( + $qb->expr()->gte('status', $qb->createNamedParameter(DematpayslipArchive::STATUS_INITIALIZED)) + );; return $this->findEntities($qb); } @@ -79,15 +82,15 @@ class DematpayslipArchiveMapper extends QBMapper { $qb->select('*'); $qb->from($this->getTableName()); $qb->where( - $qb->expr()->eq('disabled', $qb->createNamedParameter(0)) + $qb->expr()->gte('status', $qb->createNamedParameter(DematpayslipArchive::STATUS_INITIALIZED)) ); if ($archived == 1) { - $qb->where( + $qb->andWhere( $qb->expr()->isNotNull('pastell_id_document') ); } elseif ($archived == 0) { - $qb->where( + $qb->andWhere( $qb->expr()->isNull('pastell_id_document') ); } diff --git a/lib/Migration/Version020000Date20200603030000.php b/lib/Migration/Version020000Date20200608040000.php similarity index 94% rename from lib/Migration/Version020000Date20200603030000.php rename to lib/Migration/Version020000Date20200608040000.php index a8229ff..d65832a 100644 --- a/lib/Migration/Version020000Date20200603030000.php +++ b/lib/Migration/Version020000Date20200608040000.php @@ -7,7 +7,7 @@ use OCP\DB\ISchemaWrapper; use OCP\Migration\SimpleMigrationStep; use OCP\Migration\IOutput; -class Version020000Date20200603030000 extends SimpleMigrationStep { +class Version020000Date20200608040000 extends SimpleMigrationStep { /** * @param IOutput $output @@ -95,11 +95,15 @@ class Version020000Date20200603030000 extends SimpleMigrationStep { 'notnull' => true, 'length' => 32, ]); - $table->addColumn('disabled', 'smallint', [ + $table->addColumn('status', 'smallint', [ 'notnull' => true, 'length' => 1, 'default' => 0, ]); + $table->addColumn('status_time', 'integer', [ + 'notnull' => false, + 'unsigned' => true, + ]); $table->addColumn('pastell_url', 'string', [ 'notnull' => true, 'length' => 255, @@ -123,7 +127,6 @@ class Version020000Date20200603030000 extends SimpleMigrationStep { $table->setPrimaryKey(['id']); $table->addUniqueIndex(['id_file'], 'dematpayslip_archive_id_file'); $table->addUniqueIndex(['pastell_id_document'], 'dematpayslip_archive_pastell_id_document'); - $table->addUniqueIndex(['siret', 'matricule', 'lastname', 'firstname', 'start_date', 'end_date'], 'dematpayslip_archive_agent_period'); $table->addIndex(['id_user'], 'dematpayslip_archive_id_user'); $table->addIndex(['dematpayslip_id_user'], 'dematpayslip_archive_dematpayslip_id_user'); } diff --git a/templates/content/archive_list.php b/templates/content/archive_list.php index e23475a..b38bce7 100644 --- a/templates/content/archive_list.php +++ b/templates/content/archive_list.php @@ -58,7 +58,7 @@ <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; ?>" /> + <input type="hidden" id="<?php print 'param_' . $paramName; ?>" name="<?php print $paramName; ?>" value="<?php print $paramValue; ?>" /> <?php } ?> <div class="table-responsive"> <table class="table table-bordered" id="archive_list"> -- GitLab