public function createFromImport($ligne, $output) { $prenomNom = trim($ligne[self::CSV_IDENTITE]); $nom = substr(strrchr($prenomNom, " "), 1); $prenom = trim(str_replace($nom, '', $prenomNom)); $societeAurouze = $this->dm->getRepository('AppBundle:Societe')->findOneByRaisonSociale("AUROUZE"); if (!$societeAurouze) { $output->writeln(sprintf("<error>La société Aurouze n'a pas été trouvée</error>")); return false; } $compte = $this->dm->getRepository('AppBundle:Compte')->findOneByIdentifiantReprise($ligne[self::CSV_IDENTIFIANT]); if (isset($ligne[self::CSV_TYPE])) { if (!$compte) { $tag = new CompteTag(); $tag->setIdentifiant($ligne[self::CSV_TYPE]); $tag->setNom(CompteManager::$tagsCompteLibelles[$ligne[self::CSV_TYPE]]); $this->dm->persist($tag); $compte = new Compte($societeAurouze); $compte->setIdentifiantReprise($ligne[self::CSV_IDENTIFIANT]); $compte->setNom($nom); $compte->setPrenom($prenom); $compte->setCouleur($this->random_color()); $compte->addTag($tag); return $compte; } else { $tag = new CompteTag(); $tag->setIdentifiant($ligne[self::CSV_TYPE]); $tag->setNom(CompteManager::$tagsCompteLibelles[$ligne[self::CSV_TYPE]]); $this->dm->persist($tag); $compte->addTag($tag); return $compte; } } return false; }
/** * @Route("/compte/{id}/etat", name="compte_update_etat") * @ParamConverter("compte", class="AppBundle:Compte") */ public function updateEtatAction(Request $request, Compte $compte) { if (!$request->isXmlHttpRequest()) { throw $this->createNotFoundException(); } $dm = $this->get('doctrine_mongodb')->getManager(); if ($compte) { try { $compte->setActif($request->get('etat')); $dm->persist($compte); $dm->flush(); return new Response(json_encode(array("success" => true))); } catch (\Exception $e) { } } throw new \Exception('Une erreur s\'est produite'); }
public function createContactFromImport($ligne, $output) { $identifiantRepriseEtablissement = $ligne[self::CSV_IDENTIFIANT_REPRISE_ETABLISSEMENT]; $identifiantRepriseSociete = $ligne[self::CSV_IDENTIFIANT_REPRISE_SOCIETE]; $etablissement = $this->dm->getRepository('AppBundle:Etablissement')->findOneByIdentifiantReprise($identifiantRepriseEtablissement); $societe = null; if ($etablissement) { $societe = $etablissement->getSociete(); } if (!$societe) { $societe = $this->dm->getRepository('AppBundle:Societe')->findOneByIdentifiantReprise($identifiantRepriseSociete); } if (!$societe) { $output->writeln(sprintf("\n<error>La société d'identifiant de reprise %s n'a pas été trouvée (etb? = %s)</error>", $identifiantRepriseSociete, $identifiantRepriseEtablissement)); return false; } $compte = new Compte($societe); $compte->setSociete($societe); $compte->setIdentifiantReprise($ligne[self::CSV_IDENTIFIANT_REPRISE_CONTACT]); $compte->setCivilite($this->getCivilite($ligne[self::CSV_CIVILITE])); $compte->setPrenom($ligne[self::CSV_PRENOM]); $compte->setNom($ligne[self::CSV_NOM]); $compte->setIdentite($compte->getIdentite()); $compte->setTitre($this->getTitre($ligne[self::CSV_TITRE])); $contactCoordonnee = new ContactCoordonnee(); $contactCoordonnee->setTelephoneFixe($ligne[self::CSV_TELEPHONE_FIXE]); $contactCoordonnee->setTelephoneMobile($ligne[self::CSV_TELEPHONE_PORTABLE]); $contactCoordonnee->setFax($ligne[self::CSV_FAX]); $contactCoordonnee->setEmail($ligne[self::CSV_EMAIL]); $compte->setContactCoordonnee($contactCoordonnee); $compte->setActif(boolval($ligne[self::CSV_ACTIF])); $adresse = new Adresse(); $compte->setAdresse($adresse); $this->dm->persist($compte); return $compte; }
/** * Add technicien * * @param AppBundle\Document\Compte $technicien */ public function addTechnicien(\AppBundle\Document\Compte $technicien) { foreach ($this->getTechniciens() as $tech) { if ($tech->getIdentifiant() == $technicien->getIdentifiant()) { return; } } $this->setImprime(false); $this->techniciens[] = $technicien; }