|
|
@@ -19,6 +19,7 @@ use App\Repository\Access\AccessRepository;
|
|
|
use App\Repository\Access\FunctionTypeRepository;
|
|
|
use App\Repository\Organization\OrganizationRepository;
|
|
|
use App\Service\Core\AddressPostalUtils;
|
|
|
+use App\Service\Organization\Utils;
|
|
|
use App\Service\Rest\Operation\BaseRestOperation;
|
|
|
use App\Service\Rest\Operation\CreateOperation;
|
|
|
use App\Service\Rest\Operation\UpdateOperation;
|
|
|
@@ -57,6 +58,7 @@ class DolibarrSyncService
|
|
|
private AddressPostalUtils $addressPostalUtils,
|
|
|
private ArrayUtils $arrayUtils,
|
|
|
private TranslatorInterface $translator,
|
|
|
+ private Utils $organizationUtils
|
|
|
) {}
|
|
|
|
|
|
#[Required]
|
|
|
@@ -91,13 +93,13 @@ class DolibarrSyncService
|
|
|
|
|
|
// Get all the missions with an admin default role
|
|
|
$adminMissions = [];
|
|
|
- foreach ($this->functionTypeRepository->findBy(['roleByDefault' => RoleEnum::ROLE_ADMIN()->getValue()]) as $functionType) {
|
|
|
+ foreach ($this->functionTypeRepository->findBy(['roleByDefault' => RoleEnum::ROLE_ADMIN]) as $functionType) {
|
|
|
$adminMissions[] = $functionType->getMission();
|
|
|
}
|
|
|
|
|
|
// Store networks ids id dolibarr
|
|
|
- $cmfDolibarrId = (int)($this->dolibarrApiService->getSociety(OrganizationIdsEnum::CMF()->getValue())['id']);
|
|
|
- $ffecDolibarrId = (int)($this->dolibarrApiService->getSociety(OrganizationIdsEnum::FFEC()->getValue())['id']);
|
|
|
+ $cmfDolibarrId = (int)($this->dolibarrApiService->getSociety(OrganizationIdsEnum::CMF->value)['id']);
|
|
|
+ $ffecDolibarrId = (int)($this->dolibarrApiService->getSociety(OrganizationIdsEnum::FFEC->value)['id']);
|
|
|
|
|
|
// Loop over the Opentalent organizations, and fill up the operations list
|
|
|
$operations = [];
|
|
|
@@ -145,12 +147,12 @@ class DolibarrSyncService
|
|
|
$newSocietyData['phone'] = $this->getOrganizationPhone($organization);
|
|
|
|
|
|
// Sync Network
|
|
|
- if (!in_array($organization->getId(), [NetworkEnum::CMF()->getValue(), NetworkEnum::FFEC()->getValue()], true)) {
|
|
|
+ if (!in_array($organization->getId(), [NetworkEnum::CMF, NetworkEnum::FFEC], true)) {
|
|
|
$newSocietyData['parent'] = '' . match (
|
|
|
$this->getOrganizationNetworkId($organization)
|
|
|
) {
|
|
|
- NetworkEnum::CMF()->getValue() => $cmfDolibarrId,
|
|
|
- NetworkEnum::FFEC()->getValue() => $ffecDolibarrId,
|
|
|
+ NetworkEnum::CMF->value => $cmfDolibarrId,
|
|
|
+ NetworkEnum::FFEC->value => $ffecDolibarrId,
|
|
|
default => null
|
|
|
};
|
|
|
}
|
|
|
@@ -158,13 +160,13 @@ class DolibarrSyncService
|
|
|
// More infos
|
|
|
$infos = [];
|
|
|
$product = $organization->getSettings()->getProduct();
|
|
|
- if (SettingsProductEnum::isSchool($product)) {
|
|
|
+ if ($this->organizationUtils->isSchool($organization)) {
|
|
|
$infos[] = $this->translator->trans('STUDENTS_COUNT') . " : " .
|
|
|
- $this->countWithMission([FunctionEnum::STUDENT()->getValue()], $organizationMembers);
|
|
|
+ $this->countWithMission([FunctionEnum::STUDENT], $organizationMembers);
|
|
|
}
|
|
|
- if (SettingsProductEnum::isSchool($product) || SettingsProductEnum::isArtist($product)) {
|
|
|
+ if ($this->organizationUtils->isSchool($organization) || $this->organizationUtils->isArtist($organization)) {
|
|
|
$infos[] = $this->translator->trans('ADHERENTS_COUNT') . " : " .
|
|
|
- $this->countWithMission([FunctionEnum::ADHERENT()->getValue()], $organizationMembers);
|
|
|
+ $this->countWithMission([FunctionEnum::ADHERENT], $organizationMembers);
|
|
|
}
|
|
|
$infos[] = $this->translator->trans('ADMIN_ACCESS_COUNT') . " : " .
|
|
|
$this->countWithMission($adminMissions, $organizationMembers);
|
|
|
@@ -174,7 +176,7 @@ class DolibarrSyncService
|
|
|
$newSocietyData['array_options'] = $dolibarrSociety["array_options"];
|
|
|
$newSocietyData['array_options']['options_2iopeninfoopentalent'] = implode("\n", $infos);
|
|
|
if (!empty($product)) {
|
|
|
- $newSocietyData['array_options']['options_2iopen_software_opentalent'] = $this->translator->trans($product);
|
|
|
+ $newSocietyData['array_options']['options_2iopen_software_opentalent'] = $this->translator->trans($product->value);
|
|
|
}
|
|
|
|
|
|
// Set the society as active (warning: use the field 'status' for societies, and not 'statut'!)
|
|
|
@@ -229,13 +231,13 @@ class DolibarrSyncService
|
|
|
|
|
|
// Build parameters for the query (we'll see later if a query is needed)
|
|
|
$newContactData = [
|
|
|
- 'civility_code' => $person->getGender() ? $this->translator->trans($person->getGender()) : null,
|
|
|
+ 'civility_code' => $person->getGender() ? $this->translator->trans($person->getGender()->value) : null,
|
|
|
'lastname' => trim($person->getName()),
|
|
|
'firstname' => trim($person->getGivenName()),
|
|
|
'email' => $contact?->getEmail(),
|
|
|
'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact->getTelphone()) : null,
|
|
|
'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact->getMobilPhone()): null,
|
|
|
- 'poste' => $this->formatContactPosition($missions, $person->getGender()),
|
|
|
+ 'poste' => $this->formatContactPosition($missions, $person->getGender()->value),
|
|
|
'statut' => '1'
|
|
|
];
|
|
|
|
|
|
@@ -532,11 +534,11 @@ class DolibarrSyncService
|
|
|
protected function getOrganizationPostalAddress(Organization $organization): ?AddressPostal
|
|
|
{
|
|
|
$addressPriorities = [
|
|
|
- AddressPostalOrganizationTypeEnum::ADDRESS_BILL()->getValue(),
|
|
|
- AddressPostalOrganizationTypeEnum::ADDRESS_CONTACT()->getValue(),
|
|
|
- AddressPostalOrganizationTypeEnum::ADDRESS_HEAD_OFFICE()->getValue(),
|
|
|
- AddressPostalOrganizationTypeEnum::ADDRESS_PRACTICE()->getValue(),
|
|
|
- AddressPostalOrganizationTypeEnum::ADDRESS_OTHER()->getValue()
|
|
|
+ AddressPostalOrganizationTypeEnum::ADDRESS_BILL,
|
|
|
+ AddressPostalOrganizationTypeEnum::ADDRESS_CONTACT,
|
|
|
+ AddressPostalOrganizationTypeEnum::ADDRESS_HEAD_OFFICE,
|
|
|
+ AddressPostalOrganizationTypeEnum::ADDRESS_PRACTICE,
|
|
|
+ AddressPostalOrganizationTypeEnum::ADDRESS_OTHER
|
|
|
];
|
|
|
|
|
|
$organizationAddressPostal = $organization->getOrganizationAddressPostals();
|
|
|
@@ -560,10 +562,10 @@ class DolibarrSyncService
|
|
|
protected function getOrganizationPhone(Organization $organization): ?string
|
|
|
{
|
|
|
$contactPriorities = [
|
|
|
- ContactPointTypeEnum::BILL()->getValue(),
|
|
|
- ContactPointTypeEnum::CONTACT()->getValue(),
|
|
|
- ContactPointTypeEnum::PRINCIPAL()->getValue(),
|
|
|
- ContactPointTypeEnum::OTHER()->getValue()
|
|
|
+ ContactPointTypeEnum::BILL,
|
|
|
+ ContactPointTypeEnum::CONTACT,
|
|
|
+ ContactPointTypeEnum::PRINCIPAL,
|
|
|
+ ContactPointTypeEnum::OTHER
|
|
|
];
|
|
|
|
|
|
$contactPoints = $organization->getContactPoints();
|
|
|
@@ -592,10 +594,10 @@ class DolibarrSyncService
|
|
|
protected function getOrganizationEmail(Organization $organization): ?string
|
|
|
{
|
|
|
$contactPriorities = [
|
|
|
- ContactPointTypeEnum::BILL()->getValue(),
|
|
|
- ContactPointTypeEnum::CONTACT()->getValue(),
|
|
|
- ContactPointTypeEnum::PRINCIPAL()->getValue(),
|
|
|
- ContactPointTypeEnum::OTHER()->getValue()
|
|
|
+ ContactPointTypeEnum::BILL,
|
|
|
+ ContactPointTypeEnum::CONTACT,
|
|
|
+ ContactPointTypeEnum::PRINCIPAL,
|
|
|
+ ContactPointTypeEnum::OTHER
|
|
|
];
|
|
|
|
|
|
$contactPoints = $organization->getContactPoints();
|
|
|
@@ -651,8 +653,8 @@ class DolibarrSyncService
|
|
|
protected function getPersonContact(Person $person): ?ContactPoint
|
|
|
{
|
|
|
$contactPriorities = [
|
|
|
- ContactPointTypeEnum::PRINCIPAL()->getValue(),
|
|
|
- ContactPointTypeEnum::OTHER()->getValue()
|
|
|
+ ContactPointTypeEnum::PRINCIPAL,
|
|
|
+ ContactPointTypeEnum::OTHER
|
|
|
];
|
|
|
|
|
|
$contactPoints = $person->getContactPoints();
|
|
|
@@ -677,9 +679,9 @@ class DolibarrSyncService
|
|
|
protected function formatContactPosition(array $missions, ?string $gender = 'X'): string
|
|
|
{
|
|
|
$to_exclude = [
|
|
|
- FunctionEnum::ADHERENT()->getValue(),
|
|
|
- FunctionEnum::STUDENT()->getValue(),
|
|
|
- FunctionEnum::OTHER()->getValue()
|
|
|
+ FunctionEnum::ADHERENT->value,
|
|
|
+ FunctionEnum::STUDENT->value,
|
|
|
+ FunctionEnum::OTHER->value
|
|
|
];
|
|
|
|
|
|
$poste = implode(
|
|
|
@@ -689,8 +691,8 @@ class DolibarrSyncService
|
|
|
return $this->translator->trans(
|
|
|
$m,
|
|
|
['gender' => [
|
|
|
- GenderEnum::MISS()->getValue() => 'F',
|
|
|
- GenderEnum::MISTER()->getValue() => 'M'
|
|
|
+ GenderEnum::MISS->value=> 'F',
|
|
|
+ GenderEnum::MISTER->value => 'M'
|
|
|
][$gender] ?? 'X']
|
|
|
);
|
|
|
},
|