src/Traitement/NotificationActionTraitement.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Traitement;
  3. use App\Constants\NotificationActionConstant;
  4. use App\Entity\NotificationAction;
  5. use App\Manager\Notifications\NotificationActionListingManager;
  6. use Doctrine\ORM\EntityManager;
  7. class NotificationActionTraitement
  8. {
  9. /**
  10. * Undocumented function
  11. *
  12. * @param EntityManager $em
  13. * @param integer $idDossier
  14. * @param integer $idCentre
  15. * @param integer $optionAction
  16. * @param string $dataTransfertAppel
  17. * @return void
  18. */
  19. public static function generateDataListeAction(EntityManager $em, int $idDossier, int $idCentre, int $optionAction, string $dataTransfertAppel = null)
  20. {
  21. $typeNotif = NotificationActionConstant::TYPE_APPEL;
  22. $typeNotifAutre = NotificationActionConstant::TYPE_APPEL_AUTRE;
  23. $typePhrase = NotificationActionConstant::ACTION_PHRASE_GENERIQUE;
  24. $listeActionAppel = NotificationActionListingManager::getListeNotificationActionByCentre($em, $idCentre, $typeNotif, $typePhrase);
  25. if($optionAction == NotificationActionConstant::ACTION_PHRASE_SPECIFIQUE && !is_null($idDossier)) {
  26. $typeOptionAutre = NotificationActionConstant::ACTION_PHRASE_SPECIFIQUE;
  27. $listeActionAppelAutre = NotificationActionListingManager::getListeNotificationActionByDossier($em, $idCentre, $idDossier, $typeNotifAutre, $typeOptionAutre);
  28. } else {
  29. $listeActionAppelAutre = NotificationActionListingManager::getListeNotificationActionByCentre($em, $idCentre, $typeNotifAutre, $typePhrase);
  30. }
  31. $dataListeAppel = [];
  32. $dataListeAppelAutre = [];
  33. $checkTelVideFiche = [];
  34. if(!is_null($dataTransfertAppel)){
  35. $checkTelVideFiche = explode('|', $dataTransfertAppel);
  36. //Ajout bouton PRENDRE MESSAGE et AUTRE après reucpération bouton action transférer
  37. $checkTelVideFiche[] = 'ACT_PRD_MSG';
  38. $checkTelVideFiche[] = 'ACT_AUTRES';
  39. }
  40. foreach($listeActionAppel as $l) {
  41. $bOk = true;
  42. if(!empty($checkTelVideFiche)){
  43. if(!in_array($l->getCodeAction(), $checkTelVideFiche)){
  44. $bOk = false;
  45. }
  46. }
  47. if($bOk) {
  48. $d = self::getDataAction($l);
  49. if(!empty($d)) {
  50. $dataListeAppel[] = $d;
  51. }
  52. }
  53. }
  54. foreach($listeActionAppelAutre as $l) {
  55. $d = self::getDataAction($l);
  56. if(!empty($d)) {
  57. $dataListeAppelAutre[] = $d;
  58. }
  59. }
  60. $res = array('action_appel' => $dataListeAppel, 'action_autre' => $dataListeAppelAutre);
  61. return $res;
  62. }
  63. /**
  64. * Undocumented function
  65. *
  66. * @param NotificationAction $action
  67. * @return array
  68. */
  69. public static function getDataAction(NotificationAction $action)
  70. {
  71. $result = [];
  72. if($action->getIdNotifAction()){
  73. $result = array(
  74. 'id' => intval($action->getIdNotifAction()),
  75. 'libelle' => $action->getLibelle(),
  76. 'icon' => $action->getIcon()
  77. );
  78. }
  79. return $result;
  80. }
  81. }