예제 #1
0
 /**
  * @throws Exception
  */
 public function resetPersonen()
 {
     /** @var array|AntragPerson[] $alte */
     $alte = AntragPerson::model()->findAllByAttributes(["antrag_id" => $this->id]);
     foreach ($alte as $alt) {
         $alt->delete();
     }
     $indexed = [];
     $gestellt_von = RISTools::normalize_antragvon($this->gestellt_von);
     foreach ($gestellt_von as $x) {
         if (!in_array($x["name_normalized"], $indexed)) {
             $indexed[] = $x["name_normalized"];
             $person = Person::getOrCreate($x["name"], $x["name_normalized"]);
             $ap = new AntragPerson();
             $ap->antrag_id = $this->id;
             $ap->person_id = $person->id;
             $ap->typ = AntragPerson::$TYP_GESTELLT_VON;
             if (!$ap->save()) {
                 RISTools::send_email(Yii::app()->params['adminEmail'], "Antrag:resetPersonen Error", print_r($ap->getErrors(), true), null, "system");
                 throw new Exception("Fehler");
             }
         }
     }
     $initiatorInnen = RISTools::normalize_antragvon($this->initiatorInnen);
     foreach ($initiatorInnen as $x) {
         if (!in_array($x["name_normalized"], $indexed)) {
             $indexed[] = $x["name_normalized"];
             $person = Person::getOrCreate($x["name"], $x["name_normalized"]);
             $ap = new AntragPerson();
             $ap->antrag_id = $this->id;
             $ap->person_id = $person->id;
             $ap->typ = AntragPerson::$TYP_INITIATORIN;
             if (!$ap->save()) {
                 RISTools::send_email(Yii::app()->params['adminEmail'], "Antrag:resetPersonen Error", print_r($ap->getErrors(), true), null, "system");
                 throw new Exception("Fehler");
             }
         }
     }
 }