Пример #1
0
 public function estDeCompetence(\TRC\CoreBundle\Entity\DDC\DDC $ddc, \TRC\CoreBundle\Entity\Fonction $fonction)
 {
     if (!is_null($fonction->getProfil()) && $fonction->getProfil()->getDdp()) {
         $tdc = $ddc->getTdc();
         $Montant = $ddc->getCdcd()->getMontant();
         $ddps = $this->em->getRepository('TRCCoreBundle:DDP')->findBy(array("fonction" => $fonction), array("id" => "desc"), null, 0);
         foreach ($ddps as $key => $ddp) {
             if ($ddp->concerneTdc($tdc) && $ddp->couvrirMontant($Montant)) {
                 return true;
             }
         }
     }
     return false;
 }
Пример #2
0
 public function affectationAction(Request $request, $matricule, $entite, $idfonction = null)
 {
     $em = $this->getDoctrine()->getManager();
     $utilisateur = $em->getRepository('TRCCoreBundle:Utilisateur')->findOneByMatricule($matricule);
     $fonction = null;
     $profils = array();
     if ($utilisateur === null) {
         throw $this->createNotFoundException("Error [{$matricule}] INCONNU | Utilisateur");
     }
     $etape = "choix-entite";
     $title = "Choix de l'entité";
     $entites = $em->getRepository('TRCCoreBundle:' . $entite)->findAll();
     if ($idfonction !== null) {
         $fonction = $em->getRepository('TRCCoreBundle:Fonction')->findOneByMatricule($idfonction);
         if ($fonction === null || $fonction->getActeur()->getId() != $utilisateur->getActeur()->getId()) {
             throw $this->createNotFoundException("Error [{$matricule}] INCONNU");
         }
         $title = "Choix de profil";
         $etape = "Choix-profil";
         $profils = $em->getRepository('TRCCoreBundle:Profil')->findByEntite($entite);
     }
     if ($request->isMethod('POST')) {
         $sysmatricule = $this->get('trc_core.matricule');
         $sysjournal = $this->get('trc_core.journal');
         $action = $request->request->get('action');
         if ($action == 'entite') {
             $params = $request->request->all();
             $matricule = $request->request->get('input-entite');
             $entity = $em->getRepository('TRCCoreBundle:' . $entite)->findOneByMatricule($matricule);
             foreach ($em->getRepository('TRCCoreBundle:Fonction')->findByActeur($utilisateur->getActeur()) as $key => $value) {
                 $value->setActive(false);
                 if (is_null($value->getDateretrait())) {
                     $value->setDateretrait(new \DateTime());
                 }
             }
             $utilisateur->getCompte()->setRoles(array());
             $fonction = new Fonction();
             $fonction->setActeur($utilisateur->getActeur());
             $fonction->setEntite($entity->getEntite());
             $fonction->setMatricule($sysmatricule->matriculeStandard($fonction));
             $em->persist($fonction);
             $sysjournal->enregistrer(array('user' => $this->getUser(), 'type' => null, 'contenu' => "affectation de " . $utilisateur->getMatricule() . " à " . $entity->getNom()));
             $em->flush();
             return $this->redirect($this->generateUrl('trc_admin_affectation_de_profil_a_une_fonction', array('matricule' => $utilisateur->getMatricule(), 'entite' => $entite, 'idfonction' => $fonction->getMatricule())));
         } elseif ($action == 'profil') {
             $matricule = $request->request->get('input-profil');
             $profil = $em->getRepository('TRCCoreBundle:Profil')->findOneByMatricule($matricule);
             $sysgu = $this->get('trc_core.gu');
             if ($profil->getResponsable() && $sysgu->aUnResponsable($fonction->getEntite())) {
                 $responsable = $sysgu->getResponsableEntite($fonction->getEntite());
                 $rr = $sysgu->getEntite($fonction->getEntite());
                 throw $this->createNotFoundException($rr->getNom() . ' possède déjà un responsable : ' . $responsable->getPrenom() . " " . $responsable->getNom());
             }
             $fonction->setProfil($profil);
             $utilisateur->getCompte()->setRoles(array($profil->getRole()));
             $em->flush();
             return $this->redirect($this->generateUrl('trc_admin_utilisateurs_voir', array('matricule' => $utilisateur->getMatricule())));
         }
     }
     return $this->render('TRCAdminBundle:Utilisateurs:affectation.html.twig', array('utilisateur' => $utilisateur, 'etape' => $etape, 'entites' => $entites, 'title' => $title, 'fonction' => $fonction, 'profils' => $profils));
 }
 /**
  * {@inheritDoc}
  */
 public function getArchive()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getArchive', []);
     return parent::getArchive();
 }