55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace OCA\Gestion\Helpers;
|
|
|
|
use OCA\Gestion\Constants\VCalendarPropertyConstant;
|
|
|
|
class FileExportHelpers
|
|
{
|
|
|
|
|
|
public static function FormatTextForExport(string $text){
|
|
$textFormatted = utf8_decode(html_entity_decode($text));
|
|
return $textFormatted;
|
|
}
|
|
|
|
public static function GetAddressAndCityFromAddress(string $adresse){
|
|
$adresseResult = "Aucun adresse";
|
|
$cityResult = "Aucune ville";
|
|
$adresses = explode("-",$adresse);
|
|
if(isset($adresses[0])){
|
|
$adresseResult = self::RemoveSpaceFromString($adresses[0]);
|
|
}
|
|
if(isset($adresses[1])){
|
|
$cityResult = self::RemoveSpaceFromString($adresses[1]);
|
|
}
|
|
return [
|
|
"address" => $adresseResult,
|
|
"city" => $cityResult
|
|
];
|
|
}
|
|
|
|
public static function GetSexeLabel(string $sexeKey){
|
|
return $sexeKey === 'f' ? 'Mme' : 'Mr';
|
|
}
|
|
|
|
public static function RemoveSpaceFromString(string $string){
|
|
$stringWithoutSpace = trim($string);
|
|
$stringWithoutSpace = str_replace(" ",'',$stringWithoutSpace);
|
|
return $stringWithoutSpace;
|
|
}
|
|
|
|
public static function GetAbsenceTypeLabelFromKey(string $key){
|
|
$label = null;
|
|
$absenceTypes = VCalendarPropertyConstant::ABSENCE_TYPES_KEYS_VALUES;
|
|
foreach($absenceTypes as $absenceTypeKey => $absenceTypeLabel){
|
|
if($absenceTypeKey == $key){
|
|
$label = $absenceTypeLabel;
|
|
break;
|
|
}
|
|
}
|
|
return $label;
|
|
}
|
|
|
|
}
|