diff --git a/appinfo/info.xml b/appinfo/info.xml index 9679bc1596a1085065dd56fc06906e9ab55c8254..af91e80d6fa88a2b0672611e80df9bc217a26104 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ <name>Bulletins</name> <summary>Dématérialisation des bulletins de paie</summary> <description><![CDATA[Dématérialisation des bulletins de paie]]></description> - <version>3.1.1</version> + <version>3.1.2</version> <licence>agpl</licence> <author mail="support@open-dsi.fr" >Open-DSI</author> <namespace>Dematpayslip</namespace> diff --git a/lib/BackgroundJob/ArchiveProcess.php b/lib/BackgroundJob/ArchiveProcess.php index 195156fb0abe73edb32445294eb5e17f9f550860..22d83e44500f2a7b0a4a43f43b25ae27d116bcbe 100644 --- a/lib/BackgroundJob/ArchiveProcess.php +++ b/lib/BackgroundJob/ArchiveProcess.php @@ -195,7 +195,7 @@ class ArchiveProcess extends TimedJob { $this->_timeZone = new DateTimeZone($timeZoneName); // run once by interval - //$taskDefaultInterval = 120; + //$taskDefaultInterval = 60; $taskDefaultInterval = 3600 * 4; // 4h $taskInterval = intval($this->_config->getAppValue($this->_appName,$this->_appName . '_archive_cron_interval', $taskDefaultInterval)); //print __METHOD__ . ' : time_zone_name=' . $timeZoneName . ', cron_interval=' . $taskInterval . "\n"; @@ -256,18 +256,17 @@ class ArchiveProcess extends TimedJob { if ($result < 0) { $msgErrorList = $dematpayslipArchive->getMsgList('error'); - $this->_log('Error : ' . explode("\r\n", $msgErrorList), self::LOG_ERROR); + foreach ($msgErrorList as $msgError) { + $this->_log('Error : ' . $msgError, self::LOG_ERROR); + } $processMsgList['error'][] = $dematpayslipArchive; - $dematpayslipArchive->setError(1); - $this->_dematpayslipArchiveMapper->update($dematpayslipArchive); } else { $msgSuccessList = $dematpayslipArchive->getMsgList('success'); if (!empty($msgSuccessList)) { - $this->_log('Success : ' . explode("\r\n", $msgSuccessList), self::LOG_SUCCESS); + foreach ($msgSuccessList as $msgSuccess) { + $this->_log('Success : ' . $msgSuccess, self::LOG_SUCCESS); + } $processMsgList['success'][] = $dematpayslipArchive; - $dematpayslipArchive->setError(0); - $dematpayslipArchive->setOrientationProgress(DematpayslipArchive::OPERATION_FINISHED); - $this->_dematpayslipArchiveMapper->update($dematpayslipArchive); } } } diff --git a/lib/BackgroundJob/IndexationProcess.php b/lib/BackgroundJob/IndexationProcess.php index 56fec92aa8a887d429de680847fe0fb29e16de9e..9b9144411ad936cb36595770d7f10de79b1e4b3e 100644 --- a/lib/BackgroundJob/IndexationProcess.php +++ b/lib/BackgroundJob/IndexationProcess.php @@ -281,12 +281,9 @@ class IndexationProcess extends TimedJob { $result = $process->indexation($processMsgList); if ($result < 0) { - $this->_log('Indexation process : Error : ', self::LOG_ERROR); - $msgList = $process->getMsgList(); - if (!empty($msgList['error'])) { - foreach ($msgList['error'] as $msgError) { - $this->_log("\n" . $msgError, self::LOG_ERROR); - } + $msgErrorList = $process->getMsgList('error'); + foreach ($msgErrorList as $msgError) { + $this->_log('Error : ' . $msgError, self::LOG_ERROR); } } else { $nbError = count($processMsgList['error']); diff --git a/lib/Db/DematpayslipArchive.php b/lib/Db/DematpayslipArchive.php index 506b336345fb4206cfd747fa0ce2dbb127a83993..998f7aaf820107cc4ab430097ef64ae0e3b9f4e0 100644 --- a/lib/Db/DematpayslipArchive.php +++ b/lib/Db/DematpayslipArchive.php @@ -318,8 +318,8 @@ class DematpayslipArchive extends Entity implements JsonSerializable { * @param IDBConnection $dbConnection Database connection * @param IL10N $l10n Lang * @param IRootFolder $rootFolder Root folder - * @param DematpayslipArchiveMapper $dematpayslipArchiveMapper Archive table mapper - * @param DematpayslipUserMapper $dematpayslipUserMapper User table mapper + * @param DematpayslipArchiveMapper $dematpayslipArchiveMapper Archive mapper + * @param DematpayslipUserMapper $dematpayslipUserMapper User mapper * @param DateTimeZone $dateTimeZone [=null] Date time zone * @return int <0 if errors else >0 on success */ @@ -335,7 +335,7 @@ class DematpayslipArchive extends Entity implements JsonSerializable { try { // Demat config - $dematAppDataDir = $config->getAppValue($appName, 'app_data_dir', 'dematpayslip'); + $appDataDir = $config->getAppValue($appName, 'app_data_dir', 'dematpayslip'); $userId = $config->getAppValue($appName, 'user_id', 'demat'); // Pastell API config @@ -361,7 +361,7 @@ class DematpayslipArchive extends Entity implements JsonSerializable { } if ($canModifyArchive === false) { - $this->_msgList['error'][] = $l10n->t('L\'archive "' . $this->getFilePath() . '" a déjà été créée.'); + $this->_msgList['warning'][] = $l10n->t('L\'archive "' . $this->getFilePath() . '" a déjà été créée.'); } else { // 1. create document if (empty($this->getPastellIdDocument())) { @@ -373,7 +373,7 @@ class DematpayslipArchive extends Entity implements JsonSerializable { $this->setPastellLastAction($responseData['last_action']['action']); $this->setStatus(self::STATUS_CREATED); $this->setStatusTime($nowDateTime->getTimestamp()); - $this->update($this); + $dematpayslipArchiveMapper->update($this); } // 2. set document title if ($this->getStatus() == self::STATUS_CREATED) { @@ -384,16 +384,26 @@ class DematpayslipArchive extends Entity implements JsonSerializable { $this->setPastellLastAction($responseData['content']['last_action']['action']); $this->setStatus(self::STATUS_TITLED); $this->setStatusTime($nowDateTime->getTimestamp()); - $this->update($this); + $dematpayslipArchiveMapper->update($this); } // 3. send document file if ($this->getStatus() == self::STATUS_TITLED) { $nowDateTime = new DateTime('now', $dateTimeZone); $fileId = $this->getIdFile(); - //$filePath = Filesystem::getPath($fileId); - //$file = Filesystem::getFileInfo($filePath); - $fileNode = $rootFolder->getById($fileId)[0]; - if ($fileNode instanceof File) { + $filePath = $this->getFilePath(); + $fileNode = null; + try { + $fileNodeExists = $rootFolder->nodeExists($filePath); + if ($fileNodeExists) { + //$fileNode = $rootFolder->getById($fileId)[0]; + $fileNode = $rootFolder->get($filePath); + } else { + $this->_msgList['error'][] = $l10n->t('Le fichier a envoyer en archive "' . $filePath . '" [id = ' . $fileId . '] n\'a pas été trouvé [status=' . $this->getStatus() .'].'); + } + } catch (Exception $e) { + $this->_msgList['error'][] = $l10n->t('Impossible de récupérer le fichier a envoyer en archive "' . $filePath . '" [status=' . $this->getStatus() .'].'); + } + if (!empty($fileNode) && $fileNode instanceof File) { $fileName = $fileNode->getName(); $fileContent = $fileNode->getContent(); $responseData = $pastellAPI->postEntityDocumentFile($pastellConfigFlow->getIdE(), $this->getPastellIdDocument(), 'document', 0, $fileName, $fileContent); @@ -401,6 +411,8 @@ class DematpayslipArchive extends Entity implements JsonSerializable { $this->setStatus(self::STATUS_FILE_SENT); $this->setStatusTime($nowDateTime->getTimestamp()); $dematpayslipArchiveMapper->update($this); + } else { + $this->_msgList['error'][] = $l10n->t('Mauvais fichier a envoyer en archive "' . $filePath . '" [status=' . $this->getStatus() .'].'); } } // 4. send to SAE @@ -428,17 +440,14 @@ class DematpayslipArchive extends Entity implements JsonSerializable { ); $jsonFileName = 'sae_config.json'; - //$tmpJsonFilePath = tempnam(sys_get_temp_dir(), 'sae'); $userFolder = $rootFolder->getUserFolder($userId); - $dematAppDataTmpPath = $userFolder->getPath() . DIRECTORY_SEPARATOR . $dematAppDataDir; - $tmpJsonFilePath = tempnam($dematAppDataTmpPath, 'sae'); - if (!$tmpJsonFilePath) { - $this->_msgList['error'][] = $l10n->t('Impossible de créer le nom du fichier temporaire "' . $dematAppDataTmpPath . '" [status=' . $this->getStatus() .'].'); + $appDataTmpPath = $userFolder->getPath() . DIRECTORY_SEPARATOR . $appDataDir . DIRECTORY_SEPARATOR . DematpayslipProcess::$appTmpDirName; + $saeConfigFilePath = $appDataTmpPath . DIRECTORY_SEPARATOR . uniqid('sae'); + if (!$saeConfigFilePath) { + $this->_msgList['error'][] = $l10n->t('Impossible de créer le nom du fichier temporaire "' . $appDataTmpPath . '" [status=' . $this->getStatus() .'].'); } else { - //$result = Filesystem::fopen($tmpJsonFilePath, 'w+'); try { - //$jsonFileContent = Filesystem::file_get_contents($tmpJsonFilePath); - $tmpJsonFile = $rootFolder->newFile($tmpJsonFilePath, json_encode($saeConfigArr)); + $tmpJsonFile = $rootFolder->newFile($saeConfigFilePath, json_encode($saeConfigArr)); $nowDateTime = new DateTime('now', $dateTimeZone); $responseData = $pastellAPI->postEntityDocumentExternalData($pastellConfigFlow->getIdE(), $this->getPastellIdDocument(), 'sae_config', array( 'file_name' => $jsonFileName, @@ -447,9 +456,10 @@ class DematpayslipArchive extends Entity implements JsonSerializable { $this->setPastellLastAction($responseData['content']['last_action']['action']); $this->setStatus(self::STATUS_METADATA_SENT); $this->setStatusTime($nowDateTime->getTimestamp()); - $this->update($this); + $dematpayslipArchiveMapper->update($this); + $tmpJsonFile->delete(); } catch (Exception $e) { - $this->_msgList['error'][] = $l10n->t('Impossible d\'écrire dans le fichier temporaire "' . $tmpJsonFilePath . '" [status=' . $this->getStatus() .'].'); + $this->_msgList['error'][] = $l10n->t('Impossible d\'écrire dans le fichier temporaire "' . $saeConfigFilePath . '" [status=' . $this->getStatus() .'].'); } } } @@ -471,9 +481,13 @@ class DematpayslipArchive extends Entity implements JsonSerializable { if ($this->getStatus() < self::STATUS_ORIENTATION) { $this->_msgList['error'][] = $l10n->t('L\'archive "' . $this->getFilePath() . '" n\'a pas été correctement créée [status=' . $this->getStatus() .'].'); + $this->setError(1); } else { $this->_msgList['success'][] = $l10n->t('L\'archive "' . $this->getFilePath() . '" a été créée.'); + $this->setError(0); + $this->setOperationProgress(self::OPERATION_FINISHED); } + $dematpayslipArchiveMapper->update($this); } if (count($this->_msgList['error']) > 0) { @@ -482,7 +496,7 @@ class DematpayslipArchive extends Entity implements JsonSerializable { return 1; } } catch (Exception $e) { - $this->_msgList['error'][] = $e->getMessage(); + $this->_msgList['error'][] = 'Exception ' . __METHOD__ . ' : error=' . $e->getMessage(); return -1; } } diff --git a/lib/Db/DematpayslipProcess.php b/lib/Db/DematpayslipProcess.php index 0b49cce989a188b2f9418e5866fa34bbcc5a776c..d340469767cdb304258b9824bd10e1e1e0da5be8 100644 --- a/lib/Db/DematpayslipProcess.php +++ b/lib/Db/DematpayslipProcess.php @@ -151,7 +151,9 @@ class DematpayslipProcess extends Entity implements JsonSerializable { */ private $_logLevel = self::LOG_DEBUG; - /** @var string folder path */ + /** + * @var string folder path + */ private $_uploadDirUserPath; private $_uploadDirFullPath; private $_checkDirUserPath; @@ -204,6 +206,11 @@ class DematpayslipProcess extends Entity implements JsonSerializable { */ private $_pastellAppExists = false; + /** + * @var string app tmp directory name + */ + public static $appTmpDirName = 'tmp'; + protected $processing; protected $phase; protected $phaseStartTime; @@ -396,7 +403,7 @@ class DematpayslipProcess extends Entity implements JsonSerializable { self::_removeAllFilesDir($this->_checkDirFullPath); } - // TODO : init process and delete archives links (status initialized and process must terminate = 0) + // init process and delete archives links (status initialized and process must terminate = 0) $this->_processInit(); $this->_dematpayslipProcessMapper->update($this); } @@ -523,7 +530,7 @@ class DematpayslipProcess extends Entity implements JsonSerializable { $this->_reportDirUserPath = $appDataDirPath . DIRECTORY_SEPARATOR . 'report'; $this->_uploadDirUserPath = $appDataDirPath . DIRECTORY_SEPARATOR . 'upload'; $this->_exportDirUserPath = $appDataDirPath . DIRECTORY_SEPARATOR . 'export'; - $this->_tmpDirUserPath = $appDataDirPath . DIRECTORY_SEPARATOR . 'tmp'; + $this->_tmpDirUserPath = $appDataDirPath . DIRECTORY_SEPARATOR . self::$appTmpDirName; // get user for payslip $user = $this->_userManager->get($this->_userId); @@ -809,10 +816,17 @@ class DematpayslipProcess extends Entity implements JsonSerializable { /** * Get message list * - * @return array[] + * @param string $type [=''] Type of message (success, warning, error) + * @return array Message list */ - public function getMsgList() { - return $this->_msgList; + public function getMsgList($type = '') { + if (!empty($type) && isset($this->_msgList[$type])) { + $msgList = $this->_msgList[$type]; + } else { + $msgList = $this->_msgList; + } + + return $msgList; } /** @@ -1041,7 +1055,7 @@ class DematpayslipProcess extends Entity implements JsonSerializable { } if ($this->getHasError()<=0) { - // vider le dossier Upload + // clean upload directory if (is_dir($this->_uploadDirFullPath)) { self::_removeAllFilesDir($this->_uploadDirFullPath); } @@ -1745,9 +1759,12 @@ class DematpayslipProcess extends Entity implements JsonSerializable { // process skip lines if (in_array($csvCheckLineNum, $dematpayslipProcessSkipLineIdList)) { - // save PDF temp file path and activate indexation job - $archive = new DematpayslipArchive(); - $archive->saveFromFilePathAndAgent($pdfPayslipCheckFileNode, $dematpayslipArchiveMapper, $agentUser, $startDate, $endDate, $year, $month, $editionDate, DematpayslipArchive::STATUS_INITIALIZED, null, $this->getId(), $pdfPagesNum, $operationAsk, DematpayslipArchive::OPERATION_INDEXATION); + // check if not already archived (return null if already archived with warning) + $checkArchive = $this->_archiveCheckBeforeSave($dematpayslipArchiveMapper, $agentUser, $startDate, $endDate); + if (!empty($checkArchive)) { + // save PDF temp file path and activate indexation job + $checkArchive->saveFromFilePathAndAgent($pdfPayslipCheckFileNode, $dematpayslipArchiveMapper, $agentUser, $startDate, $endDate, $year, $month, $editionDate, DematpayslipArchive::STATUS_INITIALIZED, null, $this->getId(), $pdfPagesNum, $operationAsk, DematpayslipArchive::OPERATION_INDEXATION); + } $csvCheckLineNum++; continue; @@ -1755,9 +1772,12 @@ class DematpayslipProcess extends Entity implements JsonSerializable { // no user but archiving for 5 years "BulletinsNoIndex/HORODATE/SIRET-MATRICULE/PERIODE.pdf" if (empty($agentUser->getEmail())) { - // save PDF temp file path and activate indexation job - $archive = new DematpayslipArchive(); - $archive->saveFromFilePathAndAgent($pdfPayslipCheckFileNode, $dematpayslipArchiveMapper, $agentUser, $startDate, $endDate, $year, $month, $editionDate, DematpayslipArchive::STATUS_INITIALIZED, null, $this->getId(), $pdfPagesNum, $operationAsk, DematpayslipArchive::OPERATION_INDEXATION); + // check if not already archived (return null if already archived with warning) + $checkArchive = $this->_archiveCheckBeforeSave($dematpayslipArchiveMapper, $agentUser, $startDate, $endDate); + if (!empty($checkArchive)) { + // save PDF temp file path and activate indexation job + $checkArchive->saveFromFilePathAndAgent($pdfPayslipCheckFileNode, $dematpayslipArchiveMapper, $agentUser, $startDate, $endDate, $year, $month, $editionDate, DematpayslipArchive::STATUS_INITIALIZED, null, $this->getId(), $pdfPagesNum, $operationAsk, DematpayslipArchive::OPERATION_INDEXATION); + } $csvCheckLineNum++; continue; @@ -1820,17 +1840,11 @@ class DematpayslipProcess extends Entity implements JsonSerializable { $agentUser->setId($dematpayslipUser->getId()); $agentUser->setUserId($dematpayslipUser->getUserId()); - // chek if user disabled payslip - if ($dematpayslipUser->getDisabled() != 1) { - // agent want payslip - // save PDF temp file path and activate indexation job - $archive = new DematpayslipArchive(); - $archive->saveFromFilePathAndAgent($pdfPayslipCheckFileNode, $dematpayslipArchiveMapper, $agentUser, $startDate, $endDate, $year, $month, $editionDate, DematpayslipArchive::STATUS_INITIALIZED, null, $this->getId(), $pdfPagesNum, $operationAsk, DematpayslipArchive::OPERATION_INDEXATION); - } else { - // agent disabled payslip + // check if not already archived (return null if already archived with warning) + $checkArchive = $this->_archiveCheckBeforeSave($dematpayslipArchiveMapper, $agentUser, $startDate, $endDate); + if (!empty($checkArchive)) { // save PDF temp file path and activate indexation job - $archive = new DematpayslipArchive(); - $archive->saveFromFilePathAndAgent($pdfPayslipCheckFileNode, $dematpayslipArchiveMapper, $agentUser, $startDate, $endDate, $year, $month, $editionDate, DematpayslipArchive::STATUS_INITIALIZED, null, $this->getId(), $pdfPagesNum, $operationAsk, DematpayslipArchive::OPERATION_INDEXATION); + $checkArchive->saveFromFilePathAndAgent($pdfPayslipCheckFileNode, $dematpayslipArchiveMapper, $agentUser, $startDate, $endDate, $year, $month, $editionDate, DematpayslipArchive::STATUS_INITIALIZED, null, $this->getId(), $pdfPagesNum, $operationAsk, DematpayslipArchive::OPERATION_INDEXATION); } } else { $errorMsg = $this->_l10n->t('L\'utilisateur "' . $userFindByEmailId . '" n\'a pas de dossier SIRET-MATRICULE associé [siret="' . $agentUser->getSiret() . '", matricule="' . $agentUser->getMatricule() . '", email="' . $agentUser->getEmail() . '"].'); @@ -1886,8 +1900,9 @@ class DematpayslipProcess extends Entity implements JsonSerializable { // log file $logFileName = $phaseStartDateTime->format('Y-m-d_H-i-s') . '_' . $this->getPhase() . '_log'; - $logFilePath = $this->_reportDirFullPath . DIRECTORY_SEPARATOR . $logFileName; - $this->_logFile = fopen($logFilePath, 'w+'); + $logFilePath = $this->_reportDirUserPath . DIRECTORY_SEPARATOR . $logFileName; + $logFileFullPath = $this->_reportDirFullPath . DIRECTORY_SEPARATOR . $logFileName; + $this->_logFile = fopen($logFileFullPath, 'w+'); $this->_logCsvCols(array('date', 'heure', 'niveau', 'message', 'siret', 'matricule', 'nom_prenom', 'zip_city', 'date_debut', 'date_fin', 'email')); $this->_logCsvLine('## ' . $this->_l10n->t('Début du processus d\'indexation.') . ' ##', self::LOG_DEBUG); @@ -2064,68 +2079,62 @@ class DematpayslipProcess extends Entity implements JsonSerializable { if (empty($agentUser->getEmail())) { $this->_logCsvLine('-- ' . $this->_l10n->t('Création du PDF non dématérialisé de l\'agent (aucun email) : ' . ($csvCheckLineNum + 1)) . ' --', self::LOG_DEBUG, $agentUser, $startDate, $endDate); - // check if not already archived (return null if already archived with warning) - $dematpayslipArchiveCheck = null; - if ($operationAskArchive) { - $dematpayslipArchiveCheck = $this->_archiveCheckBeforeSave($dematpayslipArchiveMapper, $agentUser, $startDate, $endDate); - } - - if (!$operationAskArchive || !empty($dematpayslipArchiveCheck)) { - // add all agent pdf pages - $pdfPayslipNoDemat = new \setasign\Fpdi\Fpdi(); - $this->_logCsvLine($this->_l10n->t('Ajout des pages PDF au bulletin de paie à ne pas indexer.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); - foreach ($pdfPageNumList as $pdfPageNum) { - $this->_logCsvLine($this->_l10n->t('Ajout de la page ' . $pdfPageNum . '.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); - $pdfPayslipNoDemat->AddPage(); - $pdfPayslipNoDemat->setSourceFile($pdfOriginFileFullPath); - $pdfPayslipNoDematId = $pdfPayslipNoDemat->importPage($pdfPageNum); - $pdfPayslipNoDemat->useTemplate($pdfPayslipNoDematId); - } - - // create PDF payslip - $payslipNoDematHorodateDirPath = $this->_payslipNoIndexDir . DIRECTORY_SEPARATOR . $phaseStartDateTime->format('Y-m-d_H-i-s'); - try { - $userFolder->get($payslipNoDematHorodateDirPath); - } catch (Exception $e) { - $createdFolder = $userFolder->newFolder($payslipNoDematHorodateDirPath); - if (!$createdFolder) { - $archiveError++; - $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateDirPath . '".'); - $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); - $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); - } - } - $payslipNoDematHorodateAgentDirPath = $payslipNoDematHorodateDirPath . DIRECTORY_SEPARATOR . $agentUser->getSiret() . '-' . $agentUser->getMatricule(); - try { - $userFolder->get($payslipNoDematHorodateAgentDirPath); - } catch (Exception $e) { - $createdFolder = $userFolder->newFolder($payslipNoDematHorodateAgentDirPath); - if (!$createdFolder) { - $archiveError++; - $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateAgentDirPath . '".'); - $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); - $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); - } + // add all agent pdf pages + //$pdfPayslipNoDemat = new \setasign\Fpdi\Fpdi(); + //$this->_logCsvLine($this->_l10n->t('Ajout des pages PDF au bulletin de paie à ne pas indexer.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); + //foreach ($pdfPageNumList as $pdfPageNum) { + // $this->_logCsvLine($this->_l10n->t('Ajout de la page ' . $pdfPageNum . '.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); + // $pdfPayslipNoDemat->AddPage(); + // $pdfPayslipNoDemat->setSourceFile($pdfOriginFileFullPath); + // $pdfPayslipNoDematId = $pdfPayslipNoDemat->importPage($pdfPageNum); + // $pdfPayslipNoDemat->useTemplate($pdfPayslipNoDematId); + //} + + // create PDF payslip + $payslipNoDematHorodateDirPath = $this->_payslipNoIndexDir . DIRECTORY_SEPARATOR . $phaseStartDateTime->format('Y-m-d_H-i-s'); + try { + $userFolder->get($payslipNoDematHorodateDirPath); + } catch (Exception $e) { + $createdFolder = $userFolder->newFolder($payslipNoDematHorodateDirPath); + if (!$createdFolder) { + $archiveError++; + $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateDirPath . '".'); + $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); + $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); } - $payslipNoDematPDFPath = $payslipNoDematHorodateAgentDirPath . DIRECTORY_SEPARATOR . $startDate . '_' . $endDate; - - // create PDF payslip in no index folder - $this->_logCsvLine($this->_l10n->t('Créer le PDF du bulletin de paie non dematérialisé.'), self::LOG_DEBUG); - $pdfPayslipNoDemat->Output('F', $userHomeFilesDirPath . DIRECTORY_SEPARATOR . $payslipNoDematPDFPath); - $pdfPayslipFilePath = $payslipNoDematPDFPath . '.pdf'; - try { - /** @var File $payslipNoDematPDFNode */ - $payslipNoDematPDFNode = $userFolder->get($payslipNoDematPDFPath); - $payslipNoDematPDFNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath); - $dematpayslipArchive->setFilePath($payslipNoDematPDFNode->getPath()); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - } catch (Exception $e) { + } + $payslipNoDematHorodateAgentDirPath = $payslipNoDematHorodateDirPath . DIRECTORY_SEPARATOR . $agentUser->getSiret() . '-' . $agentUser->getMatricule(); + try { + $userFolder->get($payslipNoDematHorodateAgentDirPath); + } catch (Exception $e) { + $createdFolder = $userFolder->newFolder($payslipNoDematHorodateAgentDirPath); + if (!$createdFolder) { $archiveError++; - $errorMsg = $this->_l10n->t('Impossible de déplacer le PDF du bulletin de paie non dematérialisé "' . $userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath . '".'); - $this->_logCsvLine($errorMsg, self::LOG_ERROR); + $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateAgentDirPath . '".'); + $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); } } + $payslipNoDematPDFPath = $payslipNoDematHorodateAgentDirPath . DIRECTORY_SEPARATOR . $startDate . '_' . $endDate; + + // create PDF payslip in no index folder + $this->_logCsvLine($this->_l10n->t('Créer le PDF du bulletin de paie non dematérialisé.'), self::LOG_DEBUG); + //$pdfPayslipNoDemat->Output('F', $userHomeFilesDirPath . DIRECTORY_SEPARATOR . $payslipNoDematPDFPath); + $pdfPayslipFilePath = $payslipNoDematPDFPath . '.pdf'; + try { + /** @var File $payslipNoDematPDFNode */ + //$payslipNoDematPDFNode = $userFolder->get($payslipNoDematPDFPath); + $payslipNoDematPDFNode = $userFolder->get($pdfPayslipCheckFilePath); + $payslipNoDematPDFNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath); + $dematpayslipArchive->setIdFile($payslipNoDematPDFNode->getId()); + $dematpayslipArchive->setFilePath($payslipNoDematPDFNode->getPath()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + } catch (Exception $e) { + $archiveError++; + $errorMsg = $this->_l10n->t('Impossible de déplacer le PDF du bulletin de paie non dematérialisé "' . $userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath . '".'); + $this->_logCsvLine($errorMsg, self::LOG_ERROR); + $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); + } if ($archiveError > 0) { // file finished with errors @@ -2230,95 +2239,82 @@ class DematpayslipProcess extends Entity implements JsonSerializable { } if (!$this->hasError()) { - // check if not already archived (return null if already archived with warning) - $dematpayslipArchiveCheck = null; - if ($operationAskArchive) { - $dematpayslipArchiveCheck = $this->_archiveCheckBeforeSave($dematpayslipArchiveMapper, $agentUser, $startDate, $endDate); - } - - if (!$operationAskArchive || !empty($dematpayslipArchiveCheck)) { - // move user agent payslip file in "SIRET-MATRICULE/ANNEE/PERIODE.pdf" - $pdfPayslipFilePath = $payslipsMatriculeYearDirPath . DIRECTORY_SEPARATOR . $period . '.pdf'; - $this->_logCsvLine($this->_l10n->t('Déplacement du fichier PDF du bulletin de paie de la période [' . $period . '].'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); - try { - $pdfPayslipCheckFileNode = $userFolder->get($pdfPayslipCheckFilePath); - $pdfPayslipCheckFileNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath); - $dematpayslipArchive->setFilePath($pdfPayslipCheckFileNode->getPath()); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - } catch (Exception $e) { - $archiveError++; - $errorMsg = $this->_l10n->t('Impossible de déplacer le bulletin de paie "' . $pdfPayslipCheckFilePath . '" dans "' . $userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath . '".'); - $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); - $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); - } + // move user agent payslip file in "SIRET-MATRICULE/ANNEE/PERIODE.pdf" + $pdfPayslipFilePath = $payslipsMatriculeYearDirPath . DIRECTORY_SEPARATOR . $period . '.pdf'; + $this->_logCsvLine($this->_l10n->t('Déplacement du fichier PDF du bulletin de paie de la période [' . $period . '].'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); + try { + $pdfPayslipCheckFileNode = $userFolder->get($pdfPayslipCheckFilePath); + $pdfPayslipCheckFileNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath); + $dematpayslipArchive->setIdFile($pdfPayslipCheckFileNode->getId()); + $dematpayslipArchive->setFilePath($pdfPayslipCheckFileNode->getPath()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + } catch (Exception $e) { + $archiveError++; + $errorMsg = $this->_l10n->t('Impossible de déplacer le bulletin de paie "' . $pdfPayslipCheckFilePath . '" dans "' . $userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath . '".'); + $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); + $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); } } } else { // agent disabled payslip $this->_logCsvLine($this->_l10n->t('L\'utlisateur a désactivé la dématérialisation des fiches de paie [email=' . $agentUser->getEmail() . '].'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); - // check if not already archived (return null if already archived with warning) - $dematpayslipArchiveCheck = null; - if ($operationAskArchive) { - $dematpayslipArchiveCheck = $this->_archiveCheckBeforeSave($dematpayslipArchiveMapper, $agentUser, $startDate, $endDate); - } - - if (!$operationAskArchive || !empty($dematpayslipArchiveCheck)) { - // create PDF payslip - $payslipNoDematHorodateDirPath = $this->_payslipNoIndexDir . DIRECTORY_SEPARATOR . $phaseStartDateTime->format('Y-m-d_H-i-s'); - try { - $userFolder->get($payslipNoDematHorodateDirPath); - } catch (Exception $e) { - $createdFolder = $userFolder->newFolder($payslipNoDematHorodateDirPath); - if (!$createdFolder) { - $archiveError++; - $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateDirPath . '".'); - $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); - $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); - } - } - - $payslipNoDematHorodateAgentDirPath = $payslipNoDematHorodateDirPath . DIRECTORY_SEPARATOR . $agentUser->getSiret() . '-' . $agentUser->getMatricule(); - try { - $userFolder->get($payslipNoDematHorodateAgentDirPath); - } catch (Exception $e) { - $createdFolder = $userFolder->newFolder($payslipNoDematHorodateAgentDirPath); - if (!$createdFolder) { - $archiveError++; - $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateAgentDirPath . '".'); - $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); - $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); - } - } - $payslipNoDematPDFPath = $payslipNoDematHorodateAgentDirPath . DIRECTORY_SEPARATOR . $startDate . '_' . $endDate; - $pdfPayslipNoDemat = new \setasign\Fpdi\Fpdi(); - - // add all agent pdf pages - $this->_logCsvLine($this->_l10n->t('Ajout des pages PDF au bulletin de paie à ne pas indexer.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); - foreach ($pdfPageNumList as $pdfPageNum) { - $this->_logCsvLine($this->_l10n->t('Ajout de la page ' . $pdfPageNum . '.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); - $pdfPayslipNoDemat->AddPage(); - $pdfPayslipNoDemat->setSourceFile($pdfOriginFileFullPath); - $pdfPayslipNoDematId = $pdfPayslipNoDemat->importPage($pdfPageNum); - $pdfPayslipNoDemat->useTemplate($pdfPayslipNoDematId); + // create PDF payslip + $payslipNoDematHorodateDirPath = $this->_payslipNoIndexDir . DIRECTORY_SEPARATOR . $phaseStartDateTime->format('Y-m-d_H-i-s'); + try { + $userFolder->get($payslipNoDematHorodateDirPath); + } catch (Exception $e) { + $createdFolder = $userFolder->newFolder($payslipNoDematHorodateDirPath); + if (!$createdFolder) { + $archiveError++; + $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateDirPath . '".'); + $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); + $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); } + } - // create PDF payslip in no index folder - $this->_logCsvLine($this->_l10n->t('Créer le PDF du bulletin de paie non dematérialisé.'), self::LOG_DEBUG); - $pdfPayslipNoDemat->Output('F', $userHomeFilesDirPath . DIRECTORY_SEPARATOR . $payslipNoDematPDFPath); - $pdfPayslipFilePath = $payslipNoDematPDFPath . '.pdf'; - try { - $payslipNoDematPDFNode = $userFolder->get($payslipNoDematPDFPath); - $payslipNoDematPDFNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath); - $dematpayslipArchive->setFilePath($payslipNoDematPDFNode->getPath()); - $dematpayslipArchiveMapper->update($dematpayslipArchive); - } catch (Exception $e) { + $payslipNoDematHorodateAgentDirPath = $payslipNoDematHorodateDirPath . DIRECTORY_SEPARATOR . $agentUser->getSiret() . '-' . $agentUser->getMatricule(); + try { + $userFolder->get($payslipNoDematHorodateAgentDirPath); + } catch (Exception $e) { + $createdFolder = $userFolder->newFolder($payslipNoDematHorodateAgentDirPath); + if (!$createdFolder) { $archiveError++; - $errorMsg = $this->_l10n->t('Impossible de déplacer le PDF du bulletin de paie non dematérialisé "' . $userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath . '".'); - $this->_logCsvLine($errorMsg, self::LOG_ERROR); + $errorMsg = $this->_l10n->t('Impossible de créeer le dossier "' . $payslipNoDematHorodateAgentDirPath . '".'); + $this->_logCsvLine($errorMsg, self::LOG_ERROR, $agentUser, $startDate, $endDate); $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); } } + $payslipNoDematPDFPath = $payslipNoDematHorodateAgentDirPath . DIRECTORY_SEPARATOR . $startDate . '_' . $endDate; + //$pdfPayslipNoDemat = new \setasign\Fpdi\Fpdi(); + + // add all agent pdf pages + //$this->_logCsvLine($this->_l10n->t('Ajout des pages PDF au bulletin de paie à ne pas indexer.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); + //foreach ($pdfPageNumList as $pdfPageNum) { + // $this->_logCsvLine($this->_l10n->t('Ajout de la page ' . $pdfPageNum . '.'), self::LOG_DEBUG, $agentUser, $startDate, $endDate); + // $pdfPayslipNoDemat->AddPage(); + // $pdfPayslipNoDemat->setSourceFile($pdfOriginFileFullPath); + // $pdfPayslipNoDematId = $pdfPayslipNoDemat->importPage($pdfPageNum); + // $pdfPayslipNoDemat->useTemplate($pdfPayslipNoDematId); + //} + + // create PDF payslip in no index folder + $this->_logCsvLine($this->_l10n->t('Créer le PDF du bulletin de paie non dematérialisé.'), self::LOG_DEBUG); + //$pdfPayslipNoDemat->Output('F', $userHomeFilesDirPath . DIRECTORY_SEPARATOR . $payslipNoDematPDFPath); + $pdfPayslipFilePath = $payslipNoDematPDFPath . '.pdf'; + try { + //$payslipNoDematPDFNode = $userFolder->get($payslipNoDematPDFPath); + $payslipNoDematPDFNode = $userFolder->get($pdfPayslipCheckFilePath); + $payslipNoDematPDFNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath); + $dematpayslipArchive->setIdFile($payslipNoDematPDFNode->getId()); + $dematpayslipArchive->setFilePath($payslipNoDematPDFNode->getPath()); + $dematpayslipArchiveMapper->update($dematpayslipArchive); + } catch (Exception $e) { + $archiveError++; + $errorMsg = $this->_l10n->t('Impossible de déplacer le PDF du bulletin de paie non dematérialisé "' . $userFolder->getPath() . DIRECTORY_SEPARATOR . $pdfPayslipFilePath . '".'); + $this->_logCsvLine($errorMsg, self::LOG_ERROR); + $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $csvCheckLineNum); + } } } else { $archiveError++; @@ -2371,7 +2367,7 @@ class DematpayslipProcess extends Entity implements JsonSerializable { if (!empty($skipArchiveList)) { foreach ($skipArchiveList as $skipArchive) { $processMsgList['success'][] = $skipArchive; - // remove file + // remove payslip created in check directory try { $skipArchiveNode = $this->_rootFolder->get($skipArchive->getFilePath()); $skipArchiveNode->delete(); @@ -2490,14 +2486,14 @@ class DematpayslipProcess extends Entity implements JsonSerializable { // get csv log file (during check process) $logCheckFileName = self::PHASE_ID_CHECK . '_log.csv'; if (!empty($logCheckFileName)) { - $this->_logCsvLine($this->_l10n->t('Déplacement du fichier de Log créé après vérification dans le dossier du rapport.'), self::LOG_DEBUG); + $this->_logCsvLine($this->_l10n->t('Déplacement du fichier de log créé après vérification dans le dossier du rapport.'), self::LOG_DEBUG); $logCheckFileUserPath = $this->_checkDirUserPath . DIRECTORY_SEPARATOR . $logCheckFileName; $reportFileUserPath = $reportSubDirPath . DIRECTORY_SEPARATOR . $logCheckFileName; try { $logCheckFileUserNode = $userFolder->get($logCheckFileUserPath); $logCheckFileUserNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $reportFileUserPath); } catch (Exception $e) { - $errorMsg = $this->_l10n->t('Impossible de déplacer le fichier de Log de vérification "' . $logCheckFileName . '" dans le dossier du rapport "' . $reportSubDirName . '".'); + $errorMsg = $this->_l10n->t('Impossible de déplacer le fichier de log de vérification "' . $logCheckFileName . '" dans le dossier du rapport "' . $reportSubDirName . '".'); $this->_logCsvLine($errorMsg, self::LOG_ERROR); $this->_processErrorMsg(-1, $errorMsg, $phaseStep, $phaseStepNum); } @@ -2517,24 +2513,26 @@ class DematpayslipProcess extends Entity implements JsonSerializable { $this->_logCsvLine('## ' . $this->_l10n->t('Fin du processus d\'indexation.') . ' ##', self::LOG_DEBUG); fclose($this->_logFile); - // rename (log file) + // rename log file try { $logFileNode = $userFolder->get($logFilePath); $logFileNode->move($userFolder->getPath() . DIRECTORY_SEPARATOR . $logFilePath . '.csv'); } catch (Exception $e) { - $this->_msgList['error'][] = $this->_l10n->t('Impossible de déplacer le fichier de log "' . $logFilePath . '" .'); + $this->_msgList['error'][] = $this->_l10n->t('Impossible de déplacer le fichier de log "' . $userFolder->getPath() . DIRECTORY_SEPARATOR . $logFilePath . '.csv' . '" .'); } $this->setProcessing(0); $this->_dematpayslipProcessMapper->update($this); // empty process skip lines $this->_dematpayslipProcessSkipMapper->deleteAllByIdProcess($this->getId()); + } - return 1; - } else { + if ($this->hasError()) { return -1; + } else { + return 1; } } catch (Exception $e) { - $this->_msgList['error'][] = $e->getMessage(); + $this->_msgList['error'][] = 'Exception ' . __METHOD__ . ' : error=' . $e->getMessage(); return -1; } } @@ -2666,7 +2664,40 @@ class DematpayslipProcess extends Entity implements JsonSerializable { foreach ($archiveSelectIdList as $archiveSelectId) { $dematpayslipArchive = $dematpayslipArchiveMapper->find(intval($archiveSelectId)); if (!empty($dematpayslipArchive)) { - $dematpayslipArchive->archiveProcess($this->_appName, $this->_config, $this->_dbConnection, $this->_l10n, $this->_rootFolder, $dematpayslipArchiveMapper, $this->_dematpayslipUserMapper, $this->_timeZone); + // get operation progress and launch process + $operationProgress = $dematpayslipArchive->getOperationProgress(); + if ($operationProgress == DematpayslipArchive::OPERATION_INDEXATION) { + $processList = $this->_dematpayslipProcessMapper->findAll(); + if (!empty($processList)) { + $process = current($processList); + if ($process->getPhase() == DematpayslipProcess::PHASE_ID_INDEXATION) { + $processMsgList = array( + 'error' => array(), + 'success' => array(), + ); + $process->load($this->_appName, $this->_config, $this->_dbConnection, $this->_l10n, $this->_rootFolder, $this->_shareManager, $this->_userManager, $this->_userId, $this->_dematpayslipProcessMapper, $this->_dematpayslipProcessSkipMapper, $this->_dematpayslipUserMapper, $this->_timeZone); + $process->indexation($processMsgList); + $errorMsgList = $process->getMsgList('error'); + $successMsgList = $process->getMsgList('success'); + if (!empty($errorMsgList)) { + $this->_msgList['error'][] = end($errorMsgList); + } + if (!empty($successMsgList)) { + $this->_msgList['success'][] = end($successMsgList); + } + } + } + } else if ($operationProgress == DematpayslipArchive::OPERATION_ARCHIVE) { + $dematpayslipArchive->archiveProcess($this->_appName, $this->_config, $this->_dbConnection, $this->_l10n, $this->_rootFolder, $dematpayslipArchiveMapper, $this->_dematpayslipUserMapper, $this->_timeZone); + $errorMsgList = $dematpayslipArchive->getMsgList('error'); + $successMsgList = $dematpayslipArchive->getMsgList('success'); + if (!empty($errorMsgList)) { + $this->_msgList['error'][] = end($errorMsgList); + } + if (!empty($successMsgList)) { + $this->_msgList['success'][] = end($successMsgList); + } + } } } } @@ -2681,6 +2712,14 @@ class DematpayslipProcess extends Entity implements JsonSerializable { $operationAskList = explode('+', $operationAsk); if (in_array(DematpayslipArchive::OPERATION_ARCHIVE, $operationAskList)) { $dematpayslipArchive->archiveProcess($this->_appName, $this->_config, $this->_dbConnection, $this->_l10n, $this->_rootFolder, $dematpayslipArchiveMapper, $this->_dematpayslipUserMapper, $this->_timeZone); + $errorMsgList = $dematpayslipArchive->getMsgList('error'); + $successMsgList = $dematpayslipArchive->getMsgList('success'); + if (!empty($errorMsgList)) { + $this->_msgList['error'][] = end($errorMsgList); + } + if (!empty($successMsgList)) { + $this->_msgList['success'][] = end($successMsgList); + } } } } @@ -2691,7 +2730,40 @@ class DematpayslipProcess extends Entity implements JsonSerializable { foreach ($archiveSelectIdList as $archiveSelectId) { $dematpayslipArchive = $dematpayslipArchiveMapper->find(intval($archiveSelectId)); if (!empty($dematpayslipArchive)) { - $dematpayslipArchive->archiveProcess($this->_appName, $this->_config, $this->_dbConnection, $this->_l10n, $this->_rootFolder, $dematpayslipArchiveMapper, $this->_dematpayslipUserMapper, $this->_timeZone); + // get operation progress and launch process + $operationProgress = $dematpayslipArchive->getOperationProgress(); + if ($operationProgress == DematpayslipArchive::OPERATION_INDEXATION) { + $processList = $this->_dematpayslipProcessMapper->findAll(); + if (!empty($processList)) { + $process = current($processList); + if ($process->getPhase() == DematpayslipProcess::PHASE_ID_INDEXATION) { + $processMsgList = array( + 'error' => array(), + 'success' => array(), + ); + $process->load($this->_appName, $this->_config, $this->_dbConnection, $this->_l10n, $this->_rootFolder, $this->_shareManager, $this->_userManager, $this->_userId, $this->_dematpayslipProcessMapper, $this->_dematpayslipProcessSkipMapper, $this->_dematpayslipUserMapper, $this->_timeZone); + $process->indexation($processMsgList); + $errorMsgList = $process->getMsgList('error'); + $successMsgList = $process->getMsgList('success'); + if (!empty($errorMsgList)) { + $this->_msgList['error'][] = end($errorMsgList); + } + if (!empty($successMsgList)) { + $this->_msgList['success'][] = end($successMsgList); + } + } + } + } else if ($operationProgress == DematpayslipArchive::OPERATION_ARCHIVE) { + $dematpayslipArchive->archiveProcess($this->_appName, $this->_config, $this->_dbConnection, $this->_l10n, $this->_rootFolder, $dematpayslipArchiveMapper, $this->_dematpayslipUserMapper, $this->_timeZone); + $errorMsgList = $dematpayslipArchive->getMsgList('error'); + $successMsgList = $dematpayslipArchive->getMsgList('success'); + if (!empty($errorMsgList)) { + $this->_msgList['error'][] = end($errorMsgList); + } + if (!empty($successMsgList)) { + $this->_msgList['success'][] = end($successMsgList); + } + } } } } diff --git a/lib/Migration/Version030102Date20210812020000.php b/lib/Migration/Version030102Date20210812020000.php new file mode 100644 index 0000000000000000000000000000000000000000..82d4acdd3dc81a84e615c2902bca0e47ced98f59 --- /dev/null +++ b/lib/Migration/Version030102Date20210812020000.php @@ -0,0 +1,39 @@ +<?php + +namespace OCA\Dematpayslip\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\IDBConnection; +use OCP\Migration\SimpleMigrationStep; +use OCP\Migration\IOutput; + +use OCA\Dematpayslip\Db\DematpayslipArchive; + +class Version030102Date20210812020000 extends SimpleMigrationStep { + + /** @var IDBConnection */ + protected $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('dematpayslip_archive'); + + $table->dropIndex('demat_archive_id_file'); + $table->addIndex(['id_file'], 'demat_archive_id_file'); + + return $schema; + } +}