Beispiel #1
0
				}

				if ($responsable_eleve1 != null) {
					$notification->setEmail($responsable_eleve1->getMel());
					$notification->setTelephone($responsable_eleve1->getTelPort());
					$notification->setAdresseId($responsable_eleve1->getAdresseId());
					$notification->addResponsableEleve($responsable_eleve1);
				}
				if ($responsable_eleve2 != null) {
					if ($responsable_eleve1 == null
					|| $responsable_eleve2->getAdresseId() == $responsable_eleve1->getAdresseId()) {
						$notification->addResponsableEleve($responsable_eleve2);
					}
				}
				$notification->save();
				$tab_notification_creee[$key_ele]=$notification->getId();
				$nb_notifications++;

				//$url='./visu_notification.php?id_notification='.$notification->getId().'';



				/*
					$notification->setTypeNotification($_POST['type_notification']);
					$notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ETAT_INITIAL);
					
					
						} elseif ($modif == 'ajout_responsable') {
							$responsable = ResponsableEleveQuery::create()->findOneByResponsableEleveId($_POST["pers_id"]);
							if ($responsable != null && !$notification->getResponsableEleves()->contains($responsable)) {
							$notification->addResponsableEleve($responsable);
            }
        }
    }
    if ($responsable_eleve1 != null) {
        $notification->setEmail($responsable_eleve1->getMel());
        $notification->setTelephone($responsable_eleve1->getTelPort());
        $notification->setAdresseId($responsable_eleve1->getAdresseId());
        $notification->addResponsableEleve($responsable_eleve1);
    }
    if ($responsable_eleve2 != null) {
        if ($responsable_eleve1 == null || $responsable_eleve2->getAdresseId() == $responsable_eleve1->getAdresseId()) {
            $notification->addResponsableEleve($responsable_eleve2);
        }
    }
    $notification->save();
    header("Location: ./visu_notification.php?id_notification=" . $notification->getId() . '&menu=' . $menu);
    die;
} elseif (isset($_POST["modifier_type"])) {
    $message_enregistrement .= modif_type($saisie, $utilisateur);
    if ($message_enregistrement == '') {
        $message_enregistrement = '<span style="color:green">Modification du type enregistrée.</span>';
    }
    include "visu_saisie.php";
    die;
} elseif (isset($_GET["version"])) {
    if ($utilisateur->getStatut() != 'cpe' && $utilisateur->getStatut() != 'scolarite') {
        $message_enregistrement .= '<span style="color:red">Modification non autorisée.</span>';
        $temoin_erreur_saisie = "y";
        include "visu_saisie.php";
        die;
    }
	/**
	 * Exclude object from result
	 *
	 * @param     AbsenceEleveNotification $absenceEleveNotification Object to remove from the list of results
	 *
	 * @return    AbsenceEleveNotificationQuery The current query, for fluid interface
	 */
	public function prune($absenceEleveNotification = null)
	{
		if ($absenceEleveNotification) {
			$this->addUsingAlias(AbsenceEleveNotificationPeer::ID, $absenceEleveNotification->getId(), Criteria::NOT_EQUAL);
		}

		return $this;
	}
	/**
	 * Filter the query by a related AbsenceEleveNotification object
	 *
	 * @param     AbsenceEleveNotification|PropelCollection $absenceEleveNotification The related object(s) to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    JNotificationResponsableEleveQuery The current query, for fluid interface
	 */
	public function filterByAbsenceEleveNotification($absenceEleveNotification, $comparison = null)
	{
		if ($absenceEleveNotification instanceof AbsenceEleveNotification) {
			return $this
				->addUsingAlias(JNotificationResponsableElevePeer::A_NOTIFICATION_ID, $absenceEleveNotification->getId(), $comparison);
		} elseif ($absenceEleveNotification instanceof PropelCollection) {
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
			return $this
				->addUsingAlias(JNotificationResponsableElevePeer::A_NOTIFICATION_ID, $absenceEleveNotification->toKeyValue('PrimaryKey', 'Id'), $comparison);
		} else {
			throw new PropelException('filterByAbsenceEleveNotification() only accepts arguments of type AbsenceEleveNotification or PropelCollection');
		}
	}
                }
            }
        }
        if ($responsable_eleve1 != null) {
            $notification->setEmail($responsable_eleve1->getMel());
            $notification->setTelephone($responsable_eleve1->getTelPort());
            $notification->setAdresseId($responsable_eleve1->getAdresseId());
            $notification->addResponsableEleve($responsable_eleve1);
        }
        if ($responsable_eleve2 != null) {
            if ($responsable_eleve1 == null || $responsable_eleve2->getAdresseId() == $responsable_eleve1->getAdresseId()) {
                $notification->addResponsableEleve($responsable_eleve2);
            }
        }
        $notification->save();
        $_POST["id_notification"] = $notification->getId();
        include "visu_notification.php";
        die;
    }
}
if ($modif == 'type') {
    $notification->setTypeNotification($_POST['type']);
    $notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ETAT_INITIAL);
} else {
    if ($modif == 'statut') {
        $notification->setStatutEnvoi($_POST["statut"]);
    } else {
        if ($modif == 'commentaire') {
            $notification->setCommentaire($_POST["commentaire"]);
        } elseif ($modif == 'enlever_responsable') {
            if (0 != JNotificationResponsableEleveQuery::create()->filterByAbsenceEleveNotification($notification)->filterByResponsableEleveId($_POST["pers_id"])->limit(1)->delete()) {
/**
   * Envoi une notification (email ou sms uniquement)
   *
   * @param AbsenceEleveNotification $notification
   * @param String $message le message texte a envoyer
   * @return String message d'erreur si envoi échoué
   */
  public static function EnvoiNotification($notification, $message){
    $return_message = '';
    if ($notification->getStatutEnvoi() != AbsenceEleveNotificationPeer::STATUT_ENVOI_ETAT_INITIAL && $notification->getStatutEnvoi() != AbsenceEleveNotificationPeer::STATUT_ENVOI_ETAT_INITIAL) {
	return 'Seul une notification de statut initial ou prete à envoyer peut être envoyée avec cette méthode';
    }
    if ($notification->getTypeNotification() != AbsenceEleveNotificationPeer::TYPE_NOTIFICATION_EMAIL &&
	    $notification->getTypeNotification() != AbsenceEleveNotificationPeer::TYPE_NOTIFICATION_SMS) {
	return 'Seul une notification de type email ou sms peut être envoyée avec cette méthode';
    } elseif ($notification->getTypeNotification() == AbsenceEleveNotificationPeer::TYPE_NOTIFICATION_EMAIL) {
	if ($notification->getEmail() == null || $notification->getEmail() == '') {
	    $notification->setErreurMessageEnvoi('email non renseigné');
	    $notification->save();
	    return 'Echec de l\'envoi : email non renseigné.';
	}

	require_once('../lib/email_validator.php');
	if (!validEmail($notification->getEmail())) {
	    $notification->setErreurMessageEnvoi('adresse email non valide');
	    $notification->save();
	    return 'Erreur : adresse email non valide.';
	}

	$email_abs_etab = getSettingValue("gepiAbsenceEmail");
	if ($email_abs_etab == null || $email_abs_etab == '') {
	    $email_abs_etab = getSettingValue("gepiSchoolEmail");
	}
	$envoi = mail($notification->getEmail(),
		"Notification d'absence ".getSettingValue("gepiSchoolName").' - Ref : '.$notification->getId().' -',
		$message,
	       "From: ".$email_abs_etab."\r\n"
	       ."X-Mailer: PHP/" . phpversion());

	$notification->setDateEnvoi('now');
	if ($envoi) {
	    $notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_SUCCES);
	    $return_message = '';
	} else {
	    $return_message = 'Non accepté pour livraison.';
	    $notification->setErreurMessageEnvoi($return_message);
	    $notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ECHEC);
	}
	$notification->save();
	return $return_message;

    } else if ($notification->getTypeNotification() == AbsenceEleveNotificationPeer::TYPE_NOTIFICATION_SMS) {
	if (getSettingValue("abs2_sms")!='y') {
	    return 'Erreur : envoi de sms désactivé.';
	}

	// Load the template
	if (getSettingValue("abs2_sms_prestataire")=='tm4b') {
	    $url = "http://www.tm4b.com/client/api/http.php";
	    $hote = "tm4b.com";
	    $script = "/client/api/http.php";
	    $param['username'] = getSettingValue("abs2_sms_username"); // identifiant de notre compte TM4B
	    $param['password'] = getSettingValue("abs2_sms_password"); // mot de passe de notre compte TM4B
	    $param['type'] = 'broadcast'; // envoi de sms
	    $param['msg'] = $message; // message que l'on désire envoyer

	    $tel = $notification->getTelephone();
	    if (mb_substr($tel, 0, 1) == '0') {
		$tel = '33'.mb_substr($tel, 1, 9);
	    }
	    $param['to'] = $tel; // numéros de téléphones auxquels on envoie le message
	    $param['from'] = getSettingValue("gepiSchoolName"); // expéditeur du message (first class uniquement)
	    $param['route'] = 'business'; // type de route (pour la france, business class uniquement)
	    $param['version'] = '2.1';
	    $param['sim'] = 'yes'; // on active le mode simulation, pour tester notre script
	} else if (getSettingValue("abs2_sms_prestataire")=='123-sms') {
	    $url = "http://www.123-SMS.net/http.php";
	    $hote = "123-SMS.net";
	    $script = "/http.php";
	    $param['email'] = getSettingValue("abs2_sms_username"); // identifiant de notre compte TM4B
	    $param['pass'] = getSettingValue("abs2_sms_password"); // mot de passe de notre compte TM4B
	    $param['message'] = $message; // message que l'on désire envoyer
	    $param['numero'] = $notification->getTelephone(); // numéros de téléphones auxquels on envoie le message
	} else if (getSettingValue("abs2_sms_prestataire")=='pluriware') {
            $url = "http://sms.pluriware.fr/httpapi.php";
            $hote = "pluriware.fr";
            $script = "/httpapi.php";
            $param['user'] = getSettingValue("abs2_sms_username"); // identifiant du compte Pluriware
            $param['pass'] = getSettingValue("abs2_sms_password"); // mot de passe du compte Pluriware
	    $param['cmd'] = 'sendsms';            
	    $param['txt'] = $message; // message a envoyer
		$tel = $notification->getTelephone();
		$tel = str_replace(" ","",$tel);
		$tel = str_replace(".","",$tel);
		$tel = str_replace("-","",$tel);
		$tel = str_replace("/","",$tel);
	    if (mb_substr($tel, 0, 1) == '0') { //Ajout indicatif 33
		$tel = '33'.mb_substr($tel, 1, 9);
	    }
        $param['to'] = $tel; // numéro de téléphone auxquel on envoie le message
	    $param['from'] = str_replace(" ","",getSettingValue("gepiSchoolTel")); // expéditeur du message (facultatif)
	    /*
    		Les  parametres suivants sont pour le moment facultatifs (janv/2011) 
        mais peuvent êtres utiles pour une évolution future ou en cas de debug
	    */
	    $param['gepi_school'] = getSettingValue("gepiSchoolName");
	    $param['gepi_version'] = getSettingValue("version"); // pour debug au cas ou
	    $param['gepi_mail'] = getSettingValue("gepiSchoolEmail"); // remontée éventuelle des réponses par mail
	    $param['gepi_rne'] = getSettingValue("gepiSchoolRne"); // identification supplémentaire
	    $param['gepi_pays'] = getSettingValue("gepiSchoolPays"); // peux servir pour corriger ou insérer l'indicatif international du num tel
		
		//echo "<pre>";
		//echo print_r($param);
		//echo "</pre>";
	}

	$requete = '';
	foreach($param as $clef => $valeur)  {
	    $requete .= $clef . '=' . urlencode($valeur); // il faut bien formater les valeurs
	    $requete .= '&';
	}

	if (in_array  ('curl', get_loaded_extensions())) {
	    //on utilise curl pour la requete au service sms
	    $ch = curl_init();
	    curl_setopt($ch, CURLOPT_URL, $url);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	    curl_setopt($ch, CURLOPT_POST, 1);
	    curl_setopt($ch, CURLOPT_POSTFIELDS, $requete);
	    $reponse = curl_exec($ch);
	    curl_close($ch);
	} else {
	    $longueur_requete = strlen($requete);
	    $methode = "POST";
	    $entete = $methode . " " . $script . " HTTP/1.1\r\n";
	    $entete .= "Host: " . $hote . "\r\n";
	    $entete .= "Content-Type: application/x-www-form-urlencoded\r\n";
	    $entete .= "Content-Length: " . $longueur_requete . "\r\n";
	    $entete .= "Connection: close\r\n\r\n";
	    $entete .= $requete . "\r\n";
	    $socket = fsockopen($hote, 80, $errno, $errstr);
	    if($socket) {
		fputs($socket, $entete); // envoi de l'entete
		while(!feof($socket)) {
		    $reponseArray[] = fgets($socket); // recupere les resultats
		}
		$reponse = $reponseArray[8];
		fclose($socket);
	    } else {
		$reponse = 'error : no socket available.';
	    }
	}

	$notification->setDateEnvoi('now');

	//traitement de la réponse
	if (getSettingValue("abs2_sms_prestataire")=='tm4b') {
	    if (mb_substr($reponse, 0, 5) == 'error') {
		$return_message = 'Erreur : message non envoyé. Code erreur : '.$reponse;
		$notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ECHEC);
		$notification->setErreurMessageEnvoi($reponse);
	    } else {
		$notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ECHEC);
	    }
	} else if (getSettingValue("abs2_sms_prestataire")=='123-sms') {
	    if ($reponse != '80') {
		$return_message = 'Erreur : message non envoyé. Code erreur : '.$reponse;
		$notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ECHEC);
		$notification->setErreurMessageEnvoi($reponse);
	    } else {
		$notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ECHEC);
	    }
	} else if (getSettingValue("abs2_sms_prestataire")=='pluriware') {
            if (mb_substr($reponse, 0, 3) == 'ERR') {
                $return_message = 'Erreur : message non envoyé. Code erreur : '.$reponse;
                $notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ECHEC);
                $notification->setErreurMessageEnvoi($reponse);
            } else {
                $notification->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_SUCCES);
            }
        }
		
	$notification->save();
	return $return_message;
    }
  }
if (!$notif_courrier_a_envoyer_col->isEmpty()) {$notif = new AbsenceEleveNotification();
    echo 'Nouveaux courriers';
    echo '<table id="table_liste_absents" style="border-spacing:0px;">';
    //en tete commentaire
    echo '</tr>';
    echo '<th>id</th>';
    echo '<th></th>';
    echo '<th>responsables</th>';
    echo '<th>adresse</th>';
    echo '<th>statut</th>';
    echo '<th>date d\'envoi</th>';
    echo '<th>traitement</th>';
    echo '</tr>';
    foreach($notif_courrier_a_envoyer_col as $notif) {
	echo '<tr>';
	echo '<td><a href="visu_notification.php?id_notification='.$notif->getId().'">'.$notif->getId().'</a></td>';
	echo '<td>';
	echo ' <a href="generer_notifications_par_lot.php?retirer_id_notification='.$notif->getId().'">Retirer du lot</a>';
	echo '</td>';
	echo '<td>';
	foreach ($notif->getResponsableEleves() as $responsable) {
	    //$responsable = new ResponsableEleve();
	    echo $responsable->getCivilite().' '.strtoupper($responsable->getNom()).' '.$responsable->getPrenom();
	    if (!$notif->getResponsableEleves()->isLast()) {
		echo ', ';
	    }
	}
	echo '</td>';
	echo '<td>';
	if ($notif->getAdresse() != null) {
	    echo $notif->getAdresse()->getDescriptionSurUneLigne();
Beispiel #8
0
        $responsable_eleve2 = null;
        foreach ($traitement->getResponsablesInformationsSaisies() as $responsable_information) {
            if ($responsable_information->getNiveauResponsabilite() == '1') {
                $responsable_eleve1 = $responsable_information->getResponsableEleve();
            } else if ($responsable_information->getNiveauResponsabilite() == '2') {
                $responsable_eleve2 = $responsable_information->getResponsableEleve();
            }
        }
        if ($responsable_eleve1 != null) {
            $notification->setEmail($responsable_eleve1->getMel());
            $notification->setTelephone($responsable_eleve1->getTelPort());
            $notification->setAdresseId($responsable_eleve1->getAdresseId());
            $notification->addResponsableEleve($responsable_eleve1);
        }
        if ($responsable_eleve2 != null) {
            if ($responsable_eleve1 == null
                    || $responsable_eleve2->getAdresseId() == $responsable_eleve1->getAdresseId()) {
                $notification->addResponsableEleve($responsable_eleve2);
            }
        }
        $notification->save();

        $url='./visu_notification.php?id_notification='.$notification->getId().'';
        if($menu){
            $url.='&menu=false';
        }
	header("Location:".$url);
        die;
    }
}
?>
	/**
	 * Declares an association between this object and a AbsenceEleveNotification object.
	 *
	 * @param      AbsenceEleveNotification $v
	 * @return     JNotificationResponsableEleve The current object (for fluent API support)
	 * @throws     PropelException
	 */
	public function setAbsenceEleveNotification(AbsenceEleveNotification $v = null)
	{
		if ($v === null) {
			$this->setANotificationId(NULL);
		} else {
			$this->setANotificationId($v->getId());
		}

		$this->aAbsenceEleveNotification = $v;

		// Add binding for other direction of this n:n relationship.
		// If this object has already been added to the AbsenceEleveNotification object, it will not be re-added.
		if ($v !== null) {
			$v->addJNotificationResponsableEleve($this);
		}

		return $this;
	}