Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajouter un DocumentType "AUTRE_PROCEDURE" #2525

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ function initializeUploadModal(
if (modal.dataset.fileType == 'photo') {
data.append('signalement-add-file[photos][]', file)
} else {
if (modal.dataset.fileFilter == 'procedure') {
data.append('documentType', 'AUTRE_PROCEDURE')
}
data.append('signalement-add-file[documents][]', file)
}
data.append('_token', addFileToken)
Expand Down
25 changes: 25 additions & 0 deletions migrations/Version20240430120311.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20240430120311 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update file document_type from AUTRE to AUTRE_PROCEDURE for documents uploaded by users that are not USAGER';
}

public function up(Schema $schema): void
{
$this->addSql('UPDATE file f SET f.document_type = "AUTRE_PROCEDURE" WHERE f.file_type = "document" AND f.document_type = "AUTRE" AND f.uploaded_by_id IS NOT NULL AND f.uploaded_by_id NOT IN (SELECT id FROM user WHERE roles LIKE "%ROLE_USAGER%")');
}

public function down(Schema $schema): void
{
}
}
3 changes: 3 additions & 0 deletions src/Controller/Back/SignalementFileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public function addFileSignalement(
? File::INPUT_NAME_DOCUMENTS
: File::INPUT_NAME_PHOTOS;
$documentType = DocumentType::AUTRE;
if ($request->get('documentType') && $request->get('documentType') === DocumentType::AUTRE_PROCEDURE->name) {
$documentType = DocumentType::AUTRE_PROCEDURE;
}
list($fileList) = $signalementFileProcessor->process($files, $inputName, $documentType);

if (!$signalementFileProcessor->isValid()) {
Expand Down
3 changes: 3 additions & 0 deletions src/Entity/Enum/DocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum DocumentType: String
case BAILLEUR_DEVIS_POUR_TRAVAUX = 'BAILLEUR_DEVIS_POUR_TRAVAUX';
case BAILLEUR_REPONSE_BAILLEUR = 'BAILLEUR_REPONSE_BAILLEUR';
case AUTRE = 'AUTRE';
case AUTRE_PROCEDURE = 'AUTRE_PROCEDURE';
case PHOTO_SITUATION = 'PHOTO_SITUATION';
case PHOTO_VISITE = 'PHOTO_VISITE';

Expand All @@ -39,6 +40,7 @@ public static function getLabelList(): array
self::BAILLEUR_DEVIS_POUR_TRAVAUX->name => 'Devis pour travaux',
self::BAILLEUR_REPONSE_BAILLEUR->name => 'Réponse bailleur',
self::AUTRE->name => 'Autre',
self::AUTRE_PROCEDURE->name => 'Autre procédure',
self::PHOTO_SITUATION->name => 'Photo de désordre',
self::PHOTO_VISITE->name => 'Photo de visite',
];
Expand Down Expand Up @@ -74,6 +76,7 @@ public static function getOrderedProcedureList(): array
self::PROCEDURE_SAISINE->name => self::PROCEDURE_SAISINE->label(),
self::BAILLEUR_DEVIS_POUR_TRAVAUX->name => self::BAILLEUR_DEVIS_POUR_TRAVAUX->label(),
self::BAILLEUR_REPONSE_BAILLEUR->name => self::BAILLEUR_REPONSE_BAILLEUR->label(),
self::AUTRE_PROCEDURE->name => self::AUTRE_PROCEDURE->label(),
];
}

Expand Down
Loading