예제 #1
0
 public function review($_projectID)
 {
     parent::view("shared/header");
     parent::view("cie/menu");
     parent::model("projects");
     $model = new projects();
     if ($_projectID != null || isset($_POST['project'])) {
         parent::model("docs");
         $model1 = new docs();
         parent::model("projects");
         $model2 = new projects();
         if (isset($_POST['project'])) {
             $project = $model2->ShowProjectByID($_POST['project']);
         } else {
             $project = $model2->ShowProjectByID($_projectID[0]);
         }
         if ($project != null) {
             parent::model("business");
             $model4 = new business();
             $cie = $model4->ShowCieByUserID($_SESSION['ID']);
             if ($project->status == 1 && $project->businessID == $cie->ID) {
                 $data['title'] = $project->title;
                 $data['projectID'] = $project->ID;
                 $internId = $project->internID;
                 if ($internId != null) {
                     //Vérifier l'existence d'une évaluation de stage
                     $data['readOnly'] = $model1->ReadOnlyAdvisor($internId, 'cieReview');
                     parent::model("accounts");
                     $model3 = new accounts();
                     $data['intern'] = $model3->ShowUserByID($internId);
                     if ($data['readOnly']) {
                         //si le formulaire existe
                         $data['review'] = $model1->LoadAdvisor($internId, "cieReview");
                         $data['alert'] = "alert-warning";
                         $data['message'] = "L'évaluation pour ce stagiaire et pour ce projet existe déjà.";
                     } else {
                         //si le formulaire n'existe pas
                         //Enregistrer le formulaire d'évaluation.
                         if (isset($_POST['sendReview']) && isset($_POST['project']) && $_SESSION['form_timer'] + 1200 > time()) {
                             try {
                                 $_POST['intern'] = $internId;
                                 $model1->SaveAdvisor($_SESSION['ID'], "cieReview", $_POST);
                                 $data['review'] = $model1->LoadAdvisor($internId, 'cieReview');
                                 $data['alert'] = "alert-success";
                                 $data['message'] = "L'évaluation a été enregistrée avec succès.";
                                 $data['readOnly'] = true;
                             } catch (Exception $e) {
                                 $data['alert'] = "alert-warning";
                                 $data['message'] = "L'évaluation n'a pas pu être enregistrée.";
                             }
                         }
                     }
                     parent::view("cie/review", $data);
                     parent::view("shared/footer");
                 } else {
                     $data['alert'] = "alert-warning";
                     $data['message'] = "Aucun stagiaire associé à ce projet.";
                     $this->index($data);
                 }
             } else {
                 $data['alert'] = "alert-warning";
                 $data['message'] = "Il vous est interdit de visualiser ce formulaire.";
                 $this->index($data);
             }
         } else {
             $data['alert'] = "alert-warning";
             $data['message'] = "Ce projet n'existe pas.";
             $this->index($data);
         }
     } else {
         $this->index(null);
     }
 }
예제 #2
0
 public function evalAdv($_review)
 {
     parent::model("accounts");
     parent::model("docs");
     $model1 = new accounts();
     $model2 = new docs();
     if (isset($_review["intern"]) && isset($_review["#review"]) || isset($_POST["intern"])) {
         $data['advisors'] = $model1->ShowUsersByRank(0);
         $data['interns'] = $model1->ShowUsersByRank(2);
         $intern = null;
         $review = null;
         if (isset($_POST['intern'])) {
             $_review = null;
             $intern = $_POST['intern'];
             $review = $_POST['review'];
         } else {
             if ($_review != null) {
                 $intern = $_review["intern"];
                 $review = $_review["#review"];
             }
         }
         $data['readOnly'] = $model2->ReadOnlyAdvisor($intern, $review);
         parent::model("projects");
         $project = new projects();
         $projectIntern = null;
         if (ctype_digit($intern)) {
             $projectIntern = $project->ShowProjectByIntern($intern);
         }
         if ($projectIntern != null) {
             if (!$data['readOnly']) {
                 if (isset($_POST['evalIntern']) && $_SESSION['form_timer'] + 300 > time()) {
                     try {
                         $model2->SaveAdvisor($_SESSION['ID'], $review, $_POST);
                         $data['alert'] = "alert-success";
                         $data['message'] = "L'évaluation a été enregistrée avec succès!";
                         $data['review'] = $model2->LoadAdvisor($intern, $review);
                         $data['readOnly'] = true;
                     } catch (exception $ex) {
                         $data['alert'] = "alert-warning";
                         $data['message'] = "L'enregistrement de l'évaluation a échoué.";
                         $this->ShowInterns($data);
                     }
                 }
             } else {
                 $data['alert'] = "alert-warning";
                 $data['message'] = "Cette évaluation existe déjà pour ce stagiaire.";
                 $data['review'] = $model2->LoadAdvisor($intern, $review);
             }
             $data['intern'] = $intern;
             $data['#review'] = $review;
             parent::view("shared/header");
             parent::view("advisor/menu");
             parent::view("advisor/eval", $data);
             parent::view("shared/footer");
         } else {
             $data['alert'] = "alert-warning";
             $data['message'] = "Ce stagiaire n'a pas encore été jumelé à un projet.";
             $this->ShowInterns($data);
         }
     } else {
         $this->ShowInterns(null);
     }
 }