function output_row($row) { global $ajax, $json_data; $values = array(); // booking name $html_name = htmlspecialchars($row['name']); $values[] = "<a title=\"{$html_name}\" href=\"view_entry.php?id=" . $row['entry_id'] . "\">{$html_name}</a>"; // created by $values[] = htmlspecialchars($row['create_by']); // start time and link to day view $date = getdate($row['start_time']); $link = "<a href=\"day.php?day={$date['mday']}&month={$date['mon']}&year={$date['year']}&area=" . $row['area_id'] . "\">"; if (empty($row['enable_periods'])) { $link_str = time_date_string($row['start_time']); } else { list(, $link_str) = period_date_string($row['start_time']); } $link .= "{$link_str}</a>"; // add a span with the numeric start time in the title for sorting $values[] = "<span title=\"" . $row['start_time'] . "\"></span>" . $link; // description $values[] = htmlspecialchars($row['description']); if ($ajax) { $json_data['aaData'][] = $values; } else { echo "<tr>\n<td>\n"; echo implode("</td>\n<td>", $values); echo "</td>\n</tr>\n"; } }
function generateApproveButtons($id, $series) { global $returl, $PHP_SELF; global $entry_info_time, $entry_info_user, $repeat_info_time, $repeat_info_user; $info_time = $series ? $repeat_info_time : $entry_info_time; $info_user = $series ? $repeat_info_user : $entry_info_user; $this_page = basename($PHP_SELF); if (empty($info_time)) { $info_title = get_vocab("no_request_yet"); } else { $info_title = get_vocab("last_request") . ' ' . time_date_string($info_time); if (!empty($info_user)) { $info_title .= " " . get_vocab("by") . " {$info_user}"; } } echo "<tr>\n"; echo "<td>" . ($series ? get_vocab("series") : get_vocab("entry")) . ":</td>\n"; echo "<td>\n"; generateButton("approve_entry_handler.php", $id, $series, "approve", $returl, get_vocab("approve")); generateButton($this_page, $id, $series, "reject", $returl, get_vocab("reject")); generateButton($this_page, $id, $series, "more_info", $returl, get_vocab("more_info"), $info_title); echo "</td>\n"; echo "</tr>\n"; }
$area_name = htmlspecialchars($row['area_name']); $type = $row['type']; $room_id = $row['room_id']; $updated = time_date_string($row['last_updated']); // need to make DST correct in opposite direction to entry creation // so that user see what he expects to see $duration = $row['duration'] - cross_dst($row['start_time'], $row['end_time']); if ($enable_periods) { list($start_period, $start_date) = period_date_string($row['start_time']); } else { $start_date = time_date_string($row['start_time']); } if ($enable_periods) { list(, $end_date) = period_date_string($row['end_time'], -1); } else { $end_date = time_date_string($row['end_time']); } $rep_type = 0; if ($series == 1) { $rep_type = $row['rep_type']; $rep_end_date = utf8_strftime('%A %d %B %Y', $row['end_date']); $rep_opt = $row['rep_opt']; $rep_num_weeks = $row['rep_num_weeks']; // I also need to set $id to the value of a single entry as it is a // single entry from a series that is used by del_entry.php and // edit_entry.php // So I will look for the first entry in the series where the entry is // as per the original series settings $sql = "SELECT id\n FROM {$tbl_entry}\n WHERE repeat_id=\"{$id}\" AND entry_type=\"1\"\n ORDER BY start_time\n LIMIT 1"; $res = sql_query($sql); if (!$res) {
/** * @param integer $action */ function send_mail($id_entry, $action, $dformat, $tab_id_moderes = array()) { global $vocab, $grrSettings, $locale, $weekstarts, $enable_periods, $periods_name; $message_erreur = ''; // $action = 1 -> Création // $action = 2 -> Modification // $action = 3 -> Suppression // $action = 4 -> Suppression automatique // $action = 5 -> réservation en attente de modération // $action = 6 -> Résultat d'une décision de modération // $action = 7 -> Notification d'un retard dans la restitution d'une ressource. /* fixme faire le tri entre phpMailer et la class my_mailer */ /* todo ajouter un $port smtp dans les settings */ require_once 'phpmailer/PHPMailerAutoload.php'; define('GRR_FROM', Settings::get('grr_mail_from')); define('GRR_FROMNAME', Settings::get('grr_mail_fromname')); require_once './include/mail.inc.php'; //$m = new my_phpmailer(); $mail = new PHPMailer(); if (Settings::get('grr_mail_method') == 'smtp') { $smtpUsername = Settings::get('grr_mail_Username'); $smtpPassword = Settings::get('grr_mail_Password'); if ($smtpUsername != "") { $mail->SMTPAuth = true; $mail->Username = $smtpUsername; $mail->Password = $smtpPassword; } else { $mail->SMTPAuth = false; } $mail->Host = Settings::get('grr_mail_smtp'); $mail->Port = 587; $mail->isSMTP(); } else { $mail->isSendMail(); } //$mail->SMTPDebug = 2; //$mail->Debugoutput = 'html'; $mail->CharSet = 'UTF-8'; $mail->setFrom(GRR_FROM, GRR_FROMNAME); $mail->SetLanguage("fr", "./phpmailer/language/"); setlocale(LC_ALL, $locale); $sql = "SELECT " . TABLE_PREFIX . "_entry.name,\n\t" . TABLE_PREFIX . "_entry.description,\n\t" . TABLE_PREFIX . "_entry.beneficiaire,\n\t" . TABLE_PREFIX . "_room.room_name,\n\t" . TABLE_PREFIX . "_area.area_name,\n\t" . TABLE_PREFIX . "_entry.type,\n\t" . TABLE_PREFIX . "_entry.room_id,\n\t" . TABLE_PREFIX . "_entry.repeat_id,\n\t" . grr_sql_syntax_timestamp_to_unix("" . TABLE_PREFIX . "_entry.timestamp") . ",\n\t(" . TABLE_PREFIX . "_entry.end_time - " . TABLE_PREFIX . "_entry.start_time),\n\t" . TABLE_PREFIX . "_entry.start_time,\n\t" . TABLE_PREFIX . "_entry.end_time,\n\t" . TABLE_PREFIX . "_room.area_id,\n\t" . TABLE_PREFIX . "_room.delais_option_reservation,\n\t" . TABLE_PREFIX . "_entry.option_reservation,\n\t" . TABLE_PREFIX . "_entry.moderate,\n\t" . TABLE_PREFIX . "_entry.beneficiaire_ext,\n\t" . TABLE_PREFIX . "_entry.jours,\n\t" . TABLE_PREFIX . "_entry.clef,\n\t" . TABLE_PREFIX . "_entry.courrier\n\tFROM " . TABLE_PREFIX . "_entry, " . TABLE_PREFIX . "_room, " . TABLE_PREFIX . "_area\n\tWHERE " . TABLE_PREFIX . "_entry.room_id = " . TABLE_PREFIX . "_room.id\n\tAND " . TABLE_PREFIX . "_room.area_id = " . TABLE_PREFIX . "_area.id\n\tAND " . TABLE_PREFIX . "_entry.id='" . protect_data_sql($id_entry) . "'\n\t"; $res = grr_sql_query($sql); if (!$res) { fatal_error(0, grr_sql_error()); } if (grr_sql_count($res) < 1) { fatal_error(0, get_vocab('invalid_entry_id')); } $row = grr_sql_row($res, 0); grr_sql_free($res); get_planning_area_values($row[12]); $breve_description = bbcode(removeMailUnicode(htmlspecialchars($row[0])), 'nobbcode'); $description = bbcode(removeMailUnicode(htmlspecialchars($row[1])), 'nobbcode'); $beneficiaire = htmlspecialchars($row[2]); $room_name = removeMailUnicode(htmlspecialchars($row[3])); $area_name = removeMailUnicode(htmlspecialchars($row[4])); $room_id = $row[6]; $repeat_id = $row[7]; $date_avis = strftime("%Y/%m/%d", $row[10]); $delais_option_reservation = $row[13]; $option_reservation = $row[14]; $moderate = $row[15]; $beneficiaire_ext = htmlspecialchars($row[16]); $jours_cycle = htmlspecialchars($row[17]); $duration = $row[9]; if ($enable_periods == 'y') { list($start_period, $start_date) = period_date_string($row[10]); } else { $start_date = time_date_string($row[10], $dformat); } $rep_type = 0; if ($repeat_id != 0) { $res = grr_sql_query("SELECT rep_type, end_date, rep_opt, rep_num_weeks FROM " . TABLE_PREFIX . "_repeat WHERE id='" . protect_data_sql($repeat_id) . "'"); if (!$res) { fatal_error(0, grr_sql_error()); } $test = grr_sql_count($res); if ($test != 1) { fatal_error(0, "Deux reservation on le meme ID."); } else { $row2 = grr_sql_row($res, 0); $rep_type = $row2[0]; $rep_end_date = strftime($dformat, $row2[1]); $rep_opt = $row2[2]; $rep_num_weeks = $row2[3]; } grr_sql_free($res); } if ($enable_periods == 'y') { toPeriodString($start_period, $duration, $dur_units); } else { toTimeString($duration, $dur_units); } $weeklist = array("unused", "every week", "week 1/2", "week 1/3", "week 1/4", "week 1/5"); if ($rep_type == 2) { $affiche_period = $vocab[$weeklist[$rep_num_weeks]]; } else { $affiche_period = $vocab['rep_type_' . $rep_type]; } // Le bénéficiaire $beneficiaire_email = affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, "onlymail"); if ($beneficiaire != "") { $beneficiaire_actif = grr_sql_query1("SELECT etat FROM " . TABLE_PREFIX . "_utilisateurs WHERE login='******'"); if ($beneficiaire_actif == -1) { $beneficiaire_actif = 'actif'; } // Cas des admins } else { if ($beneficiaire_ext != "" && $beneficiaire_email != "") { $beneficiaire_actif = "actif"; } else { $beneficiaire_actif = "inactif"; } } // Utilisateur ayant agit sur la réservation $user_login = getUserName(); $user_email = grr_sql_query1("SELECT email FROM " . TABLE_PREFIX . "_utilisateurs WHERE login='******'"); // // Elaboration du message destiné aux utilisateurs désignés par l'admin dans la partie "Mails automatiques" // //Nom de l'établissement et mention "mail automatique" $message = removeMailUnicode(Settings::get("company")) . " - " . $vocab["title_mail"]; // Url de GRR $message = $message . traite_grr_url("", "y") . "\n\n"; $sujet = $vocab["subject_mail1"] . $room_name . " - " . $date_avis; if ($action == 1) { $sujet = $sujet . $vocab["subject_mail_creation"]; $message .= $vocab["the_user"] . affiche_nom_prenom_email($user_login, "", "formail"); $message = $message . $vocab["creation_booking"]; $message = $message . $vocab["the_room"] . $room_name . " (" . $area_name . ") \n"; } else { if ($action == 2) { $sujet = $sujet . $vocab["subject_mail_modify"]; if ($moderate == 1) { $sujet .= " (" . $vocab["en_attente_moderation"] . ")"; } $message .= $vocab["the_user"] . affiche_nom_prenom_email($user_login, "", "formail"); $message = $message . $vocab["modify_booking"]; $message = $message . $vocab["the_room"] . $room_name . " (" . $area_name . ") "; } else { if ($action == 3) { $sujet = $sujet . $vocab["subject_mail_delete"]; if ($moderate == 1) { $sujet .= " (" . $vocab["en_attente_moderation"] . ")"; } $message .= $vocab["the_user"] . affiche_nom_prenom_email($user_login, "", "formail"); $message = $message . $vocab["delete_booking"]; $message = $message . $vocab["the_room"] . $room_name . " (" . $area_name . ") \n"; } else { if ($action == 4) { $sujet = $sujet . $vocab["subject_mail_delete"]; $message = $message . $vocab["suppression_automatique"]; $message = $message . $vocab["the_room"] . $room_name . " (" . $area_name . ") \n"; } else { if ($action == 5) { $sujet = $sujet . $vocab["subject_mail_moderation"]; $message = $message . $vocab["reservation_en_attente_de_moderation"]; $message = $message . $vocab["the_room"] . $room_name . " (" . $area_name . ") \n"; } else { if ($action == 6) { $sujet = $sujet . $vocab["subject_mail_decision_moderation"]; $resmoderate = grr_sql_query("SELECT moderate, motivation_moderation FROM " . TABLE_PREFIX . "_entry_moderate WHERE id ='" . protect_data_sql($id_entry) . "'"); if (!$resmoderate) { fatal_error(0, grr_sql_error()); } if (grr_sql_count($resmoderate) < 1) { fatal_error(0, get_vocab('invalid_entry_id')); } $rowModerate = grr_sql_row($resmoderate, 0); grr_sql_free($resmoderate); $moderate_decision = $rowModerate[0]; $moderate_description = $rowModerate[1]; $message .= $vocab["the_user"] . affiche_nom_prenom_email($user_login, "", "formail"); $message = $message . $vocab["traite_moderation"]; $message = $message . $vocab["the_room"] . $room_name . " (" . $area_name . ") "; $message = $message . $vocab["reservee au nom de"]; $message = $message . $vocab["the_user"] . affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, "formail") . " \n"; if ($moderate_decision == 2) { $message .= "\n" . $vocab["moderation_acceptee"]; } else { if ($moderate_decision == 3) { $message .= "\n" . $vocab["moderation_refusee"]; } } if ($moderate_description != "") { $message .= "\n" . $vocab["motif"] . $vocab["deux_points"]; $message .= $moderate_description . " \n----"; } $message .= "\n" . $vocab["voir_details"] . $vocab["deux_points"] . "\n"; if (count($tab_id_moderes) == 0) { $message .= "\n" . traite_grr_url("", "y") . "view_entry.php?id=" . $id_entry; } else { foreach ($tab_id_moderes as $id_moderes) { $message .= "\n" . traite_grr_url("", "y") . "view_entry.php?id=" . $id_moderes; } } $message .= "\n\n" . $vocab["rappel_de_la_demande"] . $vocab["deux_points"] . "\n"; } else { if ($action == 7) { $sujet .= $vocab["subject_mail_retard"]; $message .= $vocab["message_mail_retard"] . $vocab["deux_points"] . " \n"; $message .= $room_name . " (" . $area_name . ") \n"; $message .= $vocab["nom emprunteur"] . $vocab["deux_points"]; $message .= affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, "formail") . " \n"; if ($beneficiaire_email != "") { $message .= $vocab["un email envoye"] . $beneficiaire_email . " \n"; } $message .= "\n" . $vocab["changer statut lorsque ressource restituee"] . $vocab["deux_points"]; $message .= "\n" . traite_grr_url("", "y") . "view_entry.php?id=" . $id_entry . " \n"; } } } } } } } if ($action == 2 || $action == 3) { $message = $message . $vocab["reservee au nom de"]; $message = $message . $vocab["the_user"] . affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, "formail") . " \n"; } if ($action == 5 || $action == 7) { $repondre = Settings::get("webmaster_email"); } else { $repondre = $user_email; } // // Infos sur la réservation // $reservation = ''; $reservation = $reservation . $vocab["start_of_the_booking"] . " " . $start_date . "\n"; $reservation = $reservation . $vocab["duration"] . " " . $duration . " " . $dur_units . "\n"; if (trim($breve_description) != "") { $reservation = $reservation . $vocab["namebooker"] . preg_replace("/ /", " ", $vocab["deux_points"]) . " " . $breve_description . "\n"; } else { $reservation = $reservation . $vocab["entryid"] . $room_id . "\n"; } if ($description != '') { $reservation = $reservation . $vocab["description"] . " " . $description . "\n"; } // Champ additionnel $reservation .= affichage_champ_add_mails($id_entry); // Type de réservation $temp = grr_sql_query1("SELECT type_name FROM " . TABLE_PREFIX . "_type_area WHERE type_letter='" . $row[5] . "'"); if ($temp == -1) { $temp = "?" . $row[5] . "?"; } else { $temp = removeMailUnicode($temp); } $reservation = $reservation . $vocab["type"] . preg_replace("/ /", " ", $vocab["deux_points"]) . " " . $temp . "\n"; if ($rep_type != 0) { $reservation = $reservation . $vocab["rep_type"] . " " . $affiche_period . "\n"; } if ($rep_type != 0) { if ($rep_type == 2) { $opt = ""; for ($i = 0; $i < 7; $i++) { $daynum = ($i + $weekstarts) % 7; if ($rep_opt[$daynum]) { $opt .= day_name($daynum) . " "; } } if ($opt) { $reservation = $reservation . $vocab["rep_rep_day"] . " " . $opt . "\n"; } } if ($rep_type == 6) { if (Settings::get("jours_cycles_actif") == "Oui") { $reservation = $reservation . $vocab["rep_type_6"] . preg_replace("/ /", " ", $vocab["deux_points"]) . ucfirst(substr($vocab["rep_type_6"], 0, 1)) . $jours_cycle . "\n"; } } $reservation = $reservation . $vocab["rep_end_date"] . " " . $rep_end_date . "\n"; } if ($delais_option_reservation > 0 && $option_reservation != -1) { $reservation = $reservation . "*** " . $vocab["reservation_a_confirmer_au_plus_tard_le"] . " " . time_date_string_jma($option_reservation, $dformat) . " ***\n"; } $reservation = $reservation . "-----\n"; $message = $message . $reservation; $message = $message . $vocab["msg_no_email"] . Settings::get("webmaster_email"); $message = html_entity_decode($message); $sql = "SELECT u.email FROM " . TABLE_PREFIX . "_utilisateurs u, " . TABLE_PREFIX . "_j_mailuser_room j WHERE (j.id_room='" . protect_data_sql($room_id) . "' AND u.login=j.login and u.etat='actif') ORDER BY u.nom, u.prenom"; $res = grr_sql_query($sql); $nombre = grr_sql_count($res); if ($nombre > 0) { $tab_destinataire = array(); for ($i = 0; $row = grr_sql_row($res, $i); $i++) { if ($row[0] != "") { $tab_destinataire[] = $row[0]; } } foreach ($tab_destinataire as $value) { if (Settings::get("grr_mail_Bcc") == "y") { $mail->AddBCC($value); } else { $mail->AddAddress($value); } } $mail->Subject = $sujet; $mail->Body = $message; $mail->AddReplyTo($repondre); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } } $mail->ClearAddresses(); $mail->ClearBCCs(); $mail->ClearReplyTos(); if ($action == 7) { $mail_admin = find_user_room($room_id); if (count($mail_admin) > 0) { foreach ($mail_admin as $value) { if (Settings::get("grr_mail_Bcc") == "y") { $mail->AddBCC($value); } else { $mail->AddAddress($value); } } $mail->Subject = $sujet; $mail->Body = $message; $mail->AddReplyTo($repondre); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } } $mail->ClearAddresses(); $mail->ClearBCCs(); $mail->ClearReplyTos(); } if ($action == 7) { $sujet7 = $vocab["subject_mail1"] . $room_name . " - " . $date_avis; $sujet7 .= $vocab["subject_mail_retard"]; $message7 = removeMailUnicode(Settings::get("company")) . " - " . $vocab["title_mail"]; $message7 .= traite_grr_url("", "y") . "\n\n"; $message7 .= $vocab["ressource empruntee non restituée"] . "\n"; $message7 .= $room_name . " (" . $area_name . ")"; $message7 .= "\n" . $reservation; $message7 = html_entity_decode($message7); $destinataire7 = $beneficiaire_email; $repondre7 = Settings::get("webmaster_email"); $mail->AddAddress($destinataire7); $mail->Subject = $sujet7; $mail->Body = $message7; $mail->AddReplyTo($repondre7); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } if ($action == 4) { $destinataire4 = $beneficiaire_email; $repondre4 = Settings::get("webmaster_email"); $mail->AddAddress($destinataire4); $mail->Subject = $sujet; $mail->Body = $message; $mail->AddReplyTo($repondre4); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } if ($action == 5) { $mail_admin = find_user_room($room_id); if (count($mail_admin) > 0) { foreach ($mail_admin as $value) { if (Settings::get("grr_mail_Bcc") == "y") { $mail->AddBCC($value); } else { $mail->AddAddress($value); } } $sujet5 = $vocab["subject_mail1"] . $room_name . " - " . $date_avis; $sujet5 .= $vocab["subject_mail_moderation"]; $message5 = removeMailUnicode(Settings::get("company")) . " - " . $vocab["title_mail"]; $message5 .= traite_grr_url("", "y") . "\n\n"; $message5 .= $vocab["subject_a_moderer"]; $message5 .= "\n" . traite_grr_url("", "y") . "validation.php?id=" . $id_entry; $message5 .= "\n\n" . $vocab['created_by'] . affiche_nom_prenom_email($user_login, "", "formail"); $message5 .= "\n" . $vocab['room'] . $vocab['deux_points'] . $room_name . " (" . $area_name . ") \n"; $message5 = html_entity_decode($message5); $repondre5 = Settings::get("webmaster_email"); $mail->Subject = $sujet5; $mail->Body = $message5; $mail->AddReplyTo($repondre5); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } } $mail->ClearAddresses(); $mail->ClearBCCs(); $mail->ClearReplyTos(); } if ($action == 5 && $beneficiaire_email != '' && $beneficiaire_actif == 'actif') { $sujet5 = $vocab["subject_mail1"] . $room_name . " - " . $date_avis; $sujet5 .= $vocab["subject_mail_moderation"]; $message5 = removeMailUnicode(Settings::get("company")) . " - " . $vocab["title_mail"]; $message5 .= traite_grr_url("", "y") . "\n\n"; $message5 .= $vocab["texte_en_attente_de_moderation"]; $message5 .= "\n" . $vocab["rappel_de_la_demande"] . $vocab["deux_points"]; $message5 .= "\n" . $vocab["the_room"] . $room_name . " (" . $area_name . ")"; $message5 .= "\n" . $reservation; $message5 = html_entity_decode($message5); $destinataire5 = $beneficiaire_email; $repondre5 = Settings::get("webmaster_email"); $mail->AddAddress($destinataire5); $mail->Subject = $sujet5; $mail->Body = $message5; $mail->AddReplyTo($repondre5); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } if ($action == 6 && $beneficiaire_email != '' && $beneficiaire_actif == 'actif') { $sujet6 = $vocab["subject_mail1"] . $room_name . " - " . $date_avis; $sujet6 .= $vocab["subject_mail_decision_moderation"]; $message6 = $message; $destinataire6 = $beneficiaire_email; $repondre6 = $user_email; $mail->AddAddress($destinataire6); $mail->Subject = $sujet6; $mail->Body = $message6; $mail->AddReplyTo($repondre6); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } // Cas d'une création, modification ou suppression d'un message par un utilisateur différent du bénéficiaire : // On envoie un message au bénéficiaire de la réservation pour l'avertir d'une modif ou d'une suppression if (($action == 1 || $action == 2 || $action == 3) && (strtolower($user_login) != strtolower($beneficiaire) || Settings::get('send_always_mail_to_creator') == '1') && $beneficiaire_email != '' && $beneficiaire_actif == 'actif') { $sujet2 = $vocab["subject_mail1"] . $room_name . " - " . $date_avis; $message2 = removeMailUnicode(Settings::get("company")) . " - " . $vocab["title_mail"]; $message2 = $message2 . traite_grr_url("", "y") . "\n\n"; $message2 = $message2 . $vocab["the_user"] . affiche_nom_prenom_email($user_login, "", "formail"); if ($action == 1) { $sujet2 = $sujet2 . $vocab["subject_mail_creation"]; $message2 = $message2 . $vocab["creation_booking_for_you"]; $message2 = $message2 . $vocab["the_room"] . $room_name . " (" . $area_name . ")."; } else { if ($action == 2) { $sujet2 = $sujet2 . $vocab["subject_mail_modify"]; $message2 = $message2 . $vocab["modify_booking"]; $message2 = $message2 . $vocab["the_room"] . $room_name . " (" . $area_name . ")"; $message2 = $message2 . $vocab["created_by_you"]; } else { $sujet2 = $sujet2 . $vocab["subject_mail_delete"]; $message2 = $message2 . $vocab["delete_booking"]; $message2 = $message2 . $vocab["the_room"] . $room_name . " (" . $area_name . ")"; $message2 = $message2 . $vocab["created_by_you"]; } } $message2 = $message2 . "\n" . $reservation; $message2 = html_entity_decode($message2); $destinataire2 = $beneficiaire_email; $repondre2 = $user_email; $mail->AddAddress($destinataire2); $mail->Subject = $sujet2; $mail->Body = $message2; $mail->AddReplyTo($repondre2); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } return $message_erreur; }
if ($opt) { $tplArrayEditEntry['pasPeriode']['opt'] = $opt; $tplArrayEditEntry['pasPeriode']['nb'] = $nb; /*if ($nb == 1) { echo '<tr><td class="E"><b>'.get_vocab('rep_rep_day').'</b> '.$opt.'</td></tr>'."\n"; } else { echo '<tr><td class="E"><b>'.get_vocab('rep_rep_days').'</b> '.$opt.'</td></tr>'."\n"; }*/ } else { $tplArrayEditEntry['pasPeriode']['opt'] = false; } if ($enable_periods == 'y') { list($start_period, $start_date) = period_date_string($start_time); } else { $start_date = time_date_string($start_time, $dformat); } $duration = $end_time - $start_time; if ($enable_periods == 'y') { toPeriodString($start_period, $duration, $dur_units); } else { toTimeString($duration, $dur_units, true); } $tplArrayEditEntry['pasPeriode']['startDate'] = $start_date; $tplArrayEditEntry['pasPeriode']['duration'] = $duration; $tplArrayEditEntry['pasPeriode']['durUnits'] = $dur_units; $tplArrayEditEntry['pasPeriode']['repEndDate'] = $rep_end_date; /*echo '<tr><td class="E"><b>'.get_vocab('date').get_vocab('deux_points').'</b> '.$start_date.'</td></tr>'."\n"; echo '<tr><td class="E"><b>'.get_vocab('duration').'</b> '.$duration.' '.$dur_units.'</td></tr>'."\n"; echo '<tr><td class="E"><b>'.get_vocab('rep_end_date').'</b> '.$rep_end_date.'</td></tr>'."\n";*/ }
# Go back to the admin page Header("Location: admin.php"); } else { print_header($day, $month, $year, $area); # We tell them how bad what theyre about to do is # Find out how many appointments would be deleted $sql = "select name, start_time, end_time from mrbs_entry where room_id={$room}"; $res = sql_query($sql); if (!$res) { echo sql_error(); } elseif (sql_count($res) > 0) { echo get_vocab("deletefollowing") . ":<ul>"; for ($i = 0; $row = sql_row($res, $i); $i++) { echo "<li>{$row['0']} ("; echo time_date_string($row[1]) . " -> "; echo time_date_string($row[2]) . ")"; } echo "</ul>"; } echo "<center>"; echo "<H1>" . get_vocab("sure") . "</h1>"; echo "<H1><a href=\"del.php?type=room&room={$room}&confirm=Y\">" . get_vocab("YES") . "!</a> <a href=admin.php>" . get_vocab("NO") . "!</a></h1>"; echo "</center>"; include "trailer.inc"; } } if ($type == "area") { # We are only going to let them delete an area if there are # no rooms. its easier $n = sql_query1("select count(*) from mrbs_room where area_id={$area}"); if ($n == 0) {
function send_mail($id_entry,$action,$dformat,$tab_id_moderes=array()) { $message_erreur = ""; // $action = 1 -> Création // $action = 2 -> Modification // $action = 3 -> Suppression // $action = 4 -> Suppression automatique // $action = 5 -> réservation en attente de modération // $action = 6 -> Résultat d'une décision de modération // $action = 7 -> Notification d'un retard dans la restitution d'une ressource. global $vocab, $grrSettings, $locale, $weekstarts, $enable_periods, $periods_name; require_once ("./include/mail.inc.php"); $m= new my_phpmailer(); $m->SetLanguage("fr","./phpmailer/language/"); setlocale(LC_ALL,$locale); // Récupération des données concernant la réservation $sql = " SELECT ".TABLE_PREFIX."_entry.name, ".TABLE_PREFIX."_entry.description, ".TABLE_PREFIX."_entry.beneficiaire, ".TABLE_PREFIX."_room.room_name, ".TABLE_PREFIX."_area.area_name, ".TABLE_PREFIX."_entry.type, ".TABLE_PREFIX."_entry.room_id, ".TABLE_PREFIX."_entry.repeat_id, " . grr_sql_syntax_timestamp_to_unix("".TABLE_PREFIX."_entry.timestamp") . ", (".TABLE_PREFIX."_entry.end_time - ".TABLE_PREFIX."_entry.start_time), ".TABLE_PREFIX."_entry.start_time, ".TABLE_PREFIX."_entry.end_time, ".TABLE_PREFIX."_room.area_id, ".TABLE_PREFIX."_room.delais_option_reservation, ".TABLE_PREFIX."_entry.option_reservation, ".TABLE_PREFIX."_entry.moderate, ".TABLE_PREFIX."_entry.beneficiaire_ext, ".TABLE_PREFIX."_entry.jours FROM ".TABLE_PREFIX."_entry, ".TABLE_PREFIX."_room, ".TABLE_PREFIX."_area WHERE ".TABLE_PREFIX."_entry.room_id = ".TABLE_PREFIX."_room.id AND ".TABLE_PREFIX."_room.area_id = ".TABLE_PREFIX."_area.id AND ".TABLE_PREFIX."_entry.id='".protect_data_sql($id_entry)."' "; $res = grr_sql_query($sql); if (! $res) fatal_error(0, grr_sql_error()); if(grr_sql_count($res) < 1) fatal_error(0, get_vocab('invalid_entry_id')); $row = grr_sql_row($res, 0); grr_sql_free($res); // Récupération des données concernant l'affichage du planning du domaine /*Renvoie les paramètres d'affichage du domaine Cas où les créneaux sont basés sur les intitulés : $enable_periods = y Dans ce cas chaque créneau correspond à une minute entre 12 h et 12 h 59 (on peut donc définir au plus 59 créneaux !) $periods_name[] = tableau des intitulés des créneaux $resolution = 60 : on impose un « pas » de 60 secondes, c'est-à-dire 1 minute $morningstarts = 12 : début des réservation à 12 h $eveningends = 12 :heure de fin des réservations : 12 h $eveningends_minutes : nombre de minutes à ajouter à l'heure $eveningends pour avoir la fin réelle d'une journée. Dans ce cas, il est égal à : (nombre d'intitulé – 1) $weekstarts = $twentyfourhour_format = $row_[6]; Cas où les créneaux sont basés sur le temps $enable_periods = n $resolution $morningstarts $eveningends $eveningends_minutes $weekstarts $twentyfourhour_format */ get_planning_area_values($row[12]); $breve_description = bbcode(removeMailUnicode(grr_htmlSpecialChars($row[0])),'nobbcode'); $description = bbcode(removeMailUnicode(grr_htmlSpecialChars($row[1])),'nobbcode'); $beneficiaire = grr_htmlSpecialChars($row[2]); $room_name = removeMailUnicode(grr_htmlSpecialChars($row[3])); $area_name = removeMailUnicode(grr_htmlSpecialChars($row[4])); $type = $row[5]; $room_id = $row[6]; $repeat_id = $row[7]; $updated = time_date_string($row[8],$dformat); $date_avis = strftime("%Y/%m/%d",$row[10]); $delais_option_reservation = $row[13]; $option_reservation = $row[14]; $moderate = $row[15]; $beneficiaire_ext = grr_htmlSpecialChars($row[16]); $jours_cycle = grr_htmlSpecialChars($row[17]); $duration = $row[9]; if($enable_periods=='y') list( $start_period, $start_date) = period_date_string($row[10]); else $start_date = time_date_string($row[10],$dformat); if($enable_periods=='y') list( , $end_date) = period_date_string($row[11], -1); else $end_date = time_date_string($row[11],$dformat); $rep_type = 0; if($repeat_id != 0) { $res = grr_sql_query("SELECT rep_type, end_date, rep_opt, rep_num_weeks FROM ".TABLE_PREFIX."_repeat WHERE id='".protect_data_sql($repeat_id)."'"); if (! $res) fatal_error(0, grr_sql_error()); if (grr_sql_count($res) == 1) { $row2 = grr_sql_row($res, 0); $rep_type = $row2[0]; $rep_end_date = strftime($dformat,$row2[1]); $rep_opt = $row2[2]; $rep_num_weeks = $row2[3]; } grr_sql_free($res); } if ($enable_periods=='y') toPeriodString($start_period, $duration, $dur_units); else toTimeString($duration, $dur_units); $weeklist = array("unused","every week","week 1/2","week 1/3","week 1/4","week 1/5"); if ($rep_type == 2) $affiche_period = $vocab[$weeklist[$rep_num_weeks]]; else $affiche_period = $vocab['rep_type_'.$rep_type]; // Le bénéficiaire $beneficiaire_email = affiche_nom_prenom_email($beneficiaire,$beneficiaire_ext,"onlymail"); if ($beneficiaire != "") { $beneficiaire_actif = grr_sql_query1("select etat from ".TABLE_PREFIX."_utilisateurs where login='******'"); if ($beneficiaire_actif == -1) $beneficiaire_actif = 'actif'; // cas des administrateurs } else if (($beneficiaire_ext != "") and ($beneficiaire_email!="")) { $beneficiaire_actif = "actif"; } else $beneficiaire_actif = "inactif"; // Utilisateur ayant agit sur la réservation $user_login=getUserName(); $user_email = grr_sql_query1("select email from ".TABLE_PREFIX."_utilisateurs where login='******'"); // // Elaboration du message destiné aux utilisateurs désignés par l'admin dans la partie "Mails automatiques" // //Nom de l'établissement et mention "mail automatique" $message = removeMailUnicode(getSettingValue("company"))." - ".$vocab["title_mail"]; // Url de GRR $message = $message.traite_grr_url("","y")."\n\n"; $sujet = $vocab["subject_mail1"].$room_name." - ".$date_avis; if ($action == 1) { // Nouvelle réservation $sujet = $sujet.$vocab["subject_mail_creation"];// - Nouvelle réservation // L'utilisateur nom prénom (email) $message .= $vocab["the_user"].affiche_nom_prenom_email($user_login,"","formail"); $message = $message.$vocab["creation_booking"]; // a réservé // la ressource "nom de la ressource" ("nom du domaine") $message=$message.$vocab["the_room"].$room_name." (".$area_name.") \n"; } else if ($action == 2) { // Modification d'une réservation $sujet = $sujet.$vocab["subject_mail_modify"];// - Modification d'une réservation if ($moderate == 1) $sujet .= " (".$vocab["en_attente_moderation"].")";// (en attente de modération) // L'utilisateur nom prénom (email) $message .= $vocab["the_user"].affiche_nom_prenom_email($user_login,"","formail"); $message = $message.$vocab["modify_booking"];// a modifié la réservation de // la ressource "nom de la ressource" ("nom du domaine") $message=$message.$vocab["the_room"].$room_name." (".$area_name.") "; } else if ($action == 3) { // Suppression d'une réservation $sujet = $sujet.$vocab["subject_mail_delete"];// - Suppression d'une réservation if ($moderate == 1) $sujet .= " (".$vocab["en_attente_moderation"].")";// (en attente de modération) // L'utilisateur nom prénom (email) $message .= $vocab["the_user"].affiche_nom_prenom_email($user_login,"","formail"); $message = $message.$vocab["delete_booking"]; // a supprimé la réservation de // la ressource "nom de la ressource" ("nom du domaine") $message=$message.$vocab["the_room"].$room_name." (".$area_name.") \n"; } else if ($action == 4) { // Suppression automatique $sujet = $sujet.$vocab["subject_mail_delete"]; // - Suppression d'une réservation // Le délai de confirmation de réservation a été dépassé.\nSuppression automatique de la réservation de $message = $message.$vocab["suppression_automatique"]; // la ressource "nom de la ressource" ("nom du domaine") $message=$message.$vocab["the_room"].$room_name." (".$area_name.") \n"; } else if ($action == 5) { // En attente de modération $sujet = $sujet.$vocab["subject_mail_moderation"];// - Réservation en attente de modération //La réservation suivante est en attente de modération pour $message = $message.$vocab["reservation_en_attente_de_moderation"]; // la ressource "nom de la ressource" ("nom du domaine") $message=$message.$vocab["the_room"].$room_name." (".$area_name.") \n"; } else if ($action == 6) { // Décision de la modération $sujet = $sujet.$vocab["subject_mail_decision_moderation"];// - Traitement d'une réservation en attente de modération // On récupère les infos du traitement $resmoderate = grr_sql_query("select moderate, motivation_moderation from ".TABLE_PREFIX."_entry_moderate where id ='".protect_data_sql($id_entry)."'"); if (! $resmoderate) fatal_error(0, grr_sql_error()); if (grr_sql_count($resmoderate) < 1) fatal_error(0, get_vocab('invalid_entry_id')); $rowModerate = grr_sql_row($resmoderate, 0); grr_sql_free($resmoderate); $moderate_decision = $rowModerate[0]; $moderate_description = $rowModerate[1]; // L'utilisateur nom prénom (email) $message .= $vocab["the_user"].affiche_nom_prenom_email($user_login,"","formail"); $message = $message.$vocab["traite_moderation"]; // a traité la demande de réservation de // la ressource "nom de la ressource" ("nom du domaine") $message=$message.$vocab["the_room"].$room_name." (".$area_name.") "; $message = $message.$vocab["reservee au nom de"];// reservee au nom de // L'utilisateur nom prénom (email) $message = $message.$vocab["the_user"].affiche_nom_prenom_email($beneficiaire,$beneficiaire_ext,"formail")." \n"; if ($moderate_decision == 2) $message .= "\n".$vocab["moderation_acceptee"]; // Votre demande a été acceptée. else if ($moderate_decision == 3) $message .= "\n".$vocab["moderation_refusee"]; // Votre demande a été refusée. if ($moderate_description != "") { $message .= "\n".$vocab["motif"].$vocab["deux_points"]; // Motif : $message .= $moderate_description." \n----"; } $message .= "\n".$vocab["voir_details"].$vocab["deux_points"]."\n"; // Voir les détails : if (count($tab_id_moderes) == 0 ) $message .= "\n".traite_grr_url("","y")."view_entry.php?id=".$id_entry; else { foreach($tab_id_moderes as $id_moderes) { $message .= "\n".traite_grr_url("","y")."view_entry.php?id=".$id_moderes; } } $message .= "\n\n".$vocab["rappel_de_la_demande"].$vocab["deux_points"]."\n"; // Rappel de la demande : // Notification d'un retard dans la restitution de la ressource } else if ($action == 7) { $sujet .= $vocab["subject_mail_retard"]; // - Urgent : Retard dans la restitution d'une ressource empruntée" // La réservation suivante n'a pas été restituée $message .= $vocab["message_mail_retard"].$vocab["deux_points"]." \n"; // la ressource "nom de la ressource" ("nom du domaine") $message .=$room_name." (".$area_name.") \n"; // Nom de l'emprunteur $message .= $vocab["nom emprunteur"].$vocab["deux_points"]; $message .= affiche_nom_prenom_email($beneficiaire,$beneficiaire_ext,"formail")." \n"; if ($beneficiaire_email != "") $message .= $vocab["un email envoye"].$beneficiaire_email." \n"; $message .= "\n".$vocab["changer statut lorsque ressource restituee"].$vocab["deux_points"]; $message .= "\n".traite_grr_url("","y")."view_entry.php?id=".$id_entry." \n"; } if (($action == 2) or ($action==3)) { $message = $message.$vocab["reservee au nom de"];// reservee au nom de // L'utilisateur nom prénom (email) $message = $message.$vocab["the_user"].affiche_nom_prenom_email($beneficiaire,$beneficiaire_ext,"formail")." \n"; } if (($action == 5) or ($action == 7)) $repondre = getSettingValue("webmaster_email"); else $repondre = $user_email; // // Infos sur la réservation // $reservation = ''; $reservation = $reservation.$vocab["start_of_the_booking"]." ".$start_date."\n"; $reservation = $reservation.$vocab["duration"]." ".$duration." ".$dur_units."\n"; if (trim($breve_description) != "") $reservation = $reservation.$vocab["namebooker"].preg_replace("/ /", " ",$vocab["deux_points"])." ".$breve_description."\n"; else $reservation = $reservation.$vocab["entryid"].$room_id."\n"; if ($description !='') { $reservation = $reservation.$vocab["description"]." ".$description."\n"; } // Champ additionnels $reservation .= affichage_champ_add_mails($id_entry); #Type de réservation $temp = grr_sql_query1("select type_name from ".TABLE_PREFIX."_type_area where type_letter='".$row[5]."'"); if ($temp == -1) $temp = "?".$row[5]."?"; else $temp = removeMailUnicode($temp); $reservation = $reservation.$vocab["type"].preg_replace("/ /", " ",$vocab["deux_points"])." ".$temp."\n"; if($rep_type != 0) { $reservation = $reservation.$vocab["rep_type"]." ".$affiche_period."\n"; } if($rep_type != 0) { // cas d'une periodicité "une semaine sur n", on affiche les jours de périodicité if ($rep_type == 2) { $opt = ""; # Display day names according to language and preferred weekday start. for ($i = 0; $i < 7; $i++) { $daynum = ($i + $weekstarts) % 7; if ($rep_opt[$daynum]) $opt .= day_name($daynum) . " "; } if($opt) $reservation = $reservation.$vocab["rep_rep_day"]." ".$opt."\n"; } // cas d'une periodicité "Jour Cycle", on affiche le numéro du jour cycle if ($rep_type == 6) { if (getSettingValue("jours_cycles_actif") == "Oui") $reservation = $reservation.$vocab["rep_type_6"].preg_replace("/ /", " ",$vocab["deux_points"]).ucfirst(substr($vocab["rep_type_6"],0,1)).$jours_cycle."\n"; } $reservation = $reservation.$vocab["rep_end_date"]." ".$rep_end_date."\n"; } if (($delais_option_reservation > 0) and ($option_reservation != -1)) $reservation = $reservation."*** ".$vocab["reservation_a_confirmer_au_plus_tard_le"]." ".time_date_string_jma($option_reservation,$dformat)." ***\n"; $reservation = $reservation."-----\n"; // message complet du message $message = $message.$reservation; // Si vous ne souhaitez plus recevoir ces messages automatiques, écrivez en ce sens au gestionnaire de Grr : $message = $message.$vocab["msg_no_email"].getSettingValue("webmaster_email");; $message = html_entity_decode_all_version($message); // Fin de l'élaboration du message destiné aux utilisateurs devant recevoir les mails automatiques // // maintenant, on envoie le message // // Décommenter la ligne suivante (et une ligne un peu plus bas) si on veut, pour une ressource modérée, ne pas envoyer de mails tant que la résa n'est pas acceptée //if ((($action != 5) and ($action!=6)) or (($action==6) and ($moderate_decision==2))) { $sql = "SELECT u.email FROM ".TABLE_PREFIX."_utilisateurs u, ".TABLE_PREFIX."_j_mailuser_room j WHERE (j.id_room='".protect_data_sql($room_id)."' and u.login=j.login and u.etat='actif') order by u.nom, u.prenom"; $res = grr_sql_query($sql); $nombre = grr_sql_count($res); if ($nombre>0) { $tab_destinataire = array(); for ($i = 0; ($row = grr_sql_row($res, $i)); $i++) { if ($row[0] != "") { $tab_destinataire[] = $row[0]; } } foreach($tab_destinataire as $value) { if (getSettingValue("grr_mail_Bcc") == "y") $m->AddBCC( $value ); else $m->AddAddress( $value ); } $m->Subject = $sujet; $m->Body = $message; $m->AddReplyTo( $repondre ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; } $m->ClearAddresses(); $m->ClearBCCs(); $m->ClearReplyTos(); // Décommenter la ligne suivante (voir également un peu plus haut) si on veut, pour une ressource modérée, ne pas envoyer de mails tant que la résa n'est pas acceptée //} // Cas d'une notification de retard : on envoie le *** même message *** aus gestionnaires de la ressources // ou aux administrateurs du domaine if ($action == 7) { $mail_admin = find_user_room ($room_id); if (count($mail_admin) > 0) { foreach($mail_admin as $value) { if (getSettingValue("grr_mail_Bcc") == "y") $m->AddBCC( $value ); else $m->AddAddress( $value ); } $m->Subject = $sujet; $m->Body = $message; $m->AddReplyTo( $repondre ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; } $m->ClearAddresses(); $m->ClearBCCs(); $m->ClearReplyTos(); } // Cas d'une notification de retard // On envoie un message à l'emprunteur if ($action == 7) { $sujet7 = $vocab["subject_mail1"].$room_name." - ".$date_avis; $sujet7 .= $vocab["subject_mail_retard"]; $message7 = removeMailUnicode(getSettingValue("company"))." - ".$vocab["title_mail"]; $message7 .= traite_grr_url("","y")."\n\n"; // Sauf erreur, la ressource suivante que vous avez emprunté n'a pas été restituée. S'il s'agit d'une erreur, veuillez ne pas tenir compte de ce courrier. $message7 .= $vocab["ressource empruntee non restituée"]."\n"; $message7 .= $room_name." (".$area_name.")"; $message7 .= "\n".$reservation; $message7 = html_entity_decode_all_version($message7); $destinataire7 = $beneficiaire_email; $repondre7 = getSettingValue("webmaster_email"); $m->AddAddress( $destinataire7 ); $m->Subject = $sujet7; $m->Body = $message7; $m->AddReplyTo( $repondre7 ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; $m->ClearAddresses(); $m->ClearReplyTos(); } // Cas d'une suppression automatique // On envoie un message à l'emprunteur if ($action == 4) { $destinataire4 = $beneficiaire_email; $repondre4 = getSettingValue("webmaster_email"); $m->AddAddress( $destinataire4 ); $m->Subject = $sujet; $m->Body = $message; $m->AddReplyTo( $repondre4 ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; $m->ClearAddresses(); $m->ClearReplyTos(); } // Cas d'une moderation // On envoie un message au gestionnaires de la ressources ou aux administrateurs du domaine // pour prévenir qu'une réservation est en attente de modération if ($action == 5) { $mail_admin = find_user_room ($room_id); if (count($mail_admin) > 0) { foreach($mail_admin as $value) { if (getSettingValue("grr_mail_Bcc") == "y") $m->AddBCC( $value ); else $m->AddAddress( $value ); } $sujet5 = $vocab["subject_mail1"].$room_name." - ".$date_avis; $sujet5 .= $vocab["subject_mail_moderation"];// - Réservation en attente de modération $message5 = removeMailUnicode(getSettingValue("company"))." - ".$vocab["title_mail"]; $message5 .= traite_grr_url("","y")."\n\n"; $message5 .= $vocab["subject_a_moderer"]; $message5 .= "\n".traite_grr_url("","y")."view_entry.php?id=".$id_entry; $message5 .= "\n\n".$vocab['created_by'].affiche_nom_prenom_email($user_login,"","formail"); $message5 .= "\n".$vocab['room'].$vocab['deux_points'].$room_name." (".$area_name.") \n"; $message5 = html_entity_decode_all_version($message5); $repondre5 = getSettingValue("webmaster_email"); $m->Subject = $sujet5; $m->Body = $message5; $m->AddReplyTo( $repondre5 ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; } $m->ClearAddresses(); $m->ClearBCCs(); $m->ClearReplyTos(); } // Cas d'une moderation // On envoie un message au bénéficiaire de la réservation pour l'avertir que sa demande est en attente de modération // if (($action == 5) and ($beneficiaire_email!='') and ($beneficiaire_actif=='actif')) { $sujet5 = $vocab["subject_mail1"].$room_name." - ".$date_avis; $sujet5 .= $vocab["subject_mail_moderation"]; $message5 = removeMailUnicode(getSettingValue("company"))." - ".$vocab["title_mail"]; $message5 .= traite_grr_url("","y")."\n\n"; $message5 .= $vocab["texte_en_attente_de_moderation"]; $message5 .= "\n".$vocab["rappel_de_la_demande"].$vocab["deux_points"]; $message5 .= "\n".$vocab["the_room"].$room_name." (".$area_name.")"; $message5 .= "\n".$reservation; $message5 = html_entity_decode_all_version($message5); $destinataire5 = $beneficiaire_email; $repondre5 = getSettingValue("webmaster_email"); $m->AddAddress( $destinataire5 ); $m->Subject = $sujet5; $m->Body = $message5; $m->AddReplyTo( $repondre5 ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; $m->ClearAddresses(); $m->ClearReplyTos(); } // Cas d'une modération // On envoie un message au bénéficiaire de la réservation pour l'avertir de la désision d'une modération // if (($action == 6) and ($beneficiaire_email!='') and ($beneficiaire_actif=='actif')) { // Décision de la modération $sujet6 = $vocab["subject_mail1"].$room_name." - ".$date_avis; $sujet6 .= $vocab["subject_mail_decision_moderation"];// - Traitement d'une réservation en attente de modération // Pour le message : on reprend le même que celui constitué pour le préposés aux mails automatiques $message6 = $message; $destinataire6 = $beneficiaire_email; $repondre6 = $user_email; $m->AddAddress( $destinataire6 ); $m->Subject = $sujet6; $m->Body = $message6; $m->AddReplyTo( $repondre6 ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; $m->ClearAddresses(); $m->ClearReplyTos(); } // Cas d'une création, modification ou suppression d'un message par un utilisateur différent du bénéficiaire : // On envoie un message au bénéficiaire de la réservation pour l'avertir d'une modif ou d'une suppression // if ((($action == 1) or ($action == 2) or ($action==3)) and ((strtolower($user_login) != strtolower($beneficiaire)) or (getSettingValue('send_always_mail_to_creator')=='1')) and ($beneficiaire_email!='') and ($beneficiaire_actif=='actif')) { $sujet2 = $vocab["subject_mail1"].$room_name." - ".$date_avis; $message2 = removeMailUnicode(getSettingValue("company"))." - ".$vocab["title_mail"]; $message2 = $message2.traite_grr_url("","y")."\n\n"; $message2 = $message2.$vocab["the_user"].affiche_nom_prenom_email($user_login,"","formail"); if ($action == 1) { $sujet2 = $sujet2.$vocab["subject_mail_creation"]; $message2 = $message2.$vocab["creation_booking_for_you"]; $message2=$message2.$vocab["the_room"].$room_name." (".$area_name.")."; } else if ($action == 2) { $sujet2 = $sujet2.$vocab["subject_mail_modify"]; $message2 = $message2.$vocab["modify_booking"]; $message2=$message2.$vocab["the_room"].$room_name." (".$area_name.")"; $message2 = $message2.$vocab["created_by_you"]; } else { $sujet2 = $sujet2.$vocab["subject_mail_delete"]; $message2 = $message2.$vocab["delete_booking"]; $message2=$message2.$vocab["the_room"].$room_name." (".$area_name.")"; $message2 = $message2.$vocab["created_by_you"]; } $message2 = $message2."\n".$reservation; $message2 = html_entity_decode_all_version($message2); $destinataire2 = $beneficiaire_email; $repondre2 = $user_email; $m->AddAddress( $destinataire2 ); $m->Subject = $sujet2; $m->Body = $message2; $m->AddReplyTo( $repondre2 ); if(!$m->Send()) $message_erreur .= $m->ErrorInfo; $m->ClearAddresses(); $m->ClearReplyTos(); } return $message_erreur; }
function display_entry_row($row) { echo "<tr>\n"; echo "<td> </td>\n"; // reservation name, with a link to the view_entry page echo "<td>"; echo "<a href=\"view_entry.php?id=" . $row['id'] . "\">" . htmlspecialchars($row['name']) . "</a></td>\n"; // create_by, area and room names echo "<td>" . htmlspecialchars($row['create_by']) . "</td>\n"; echo "<td>" . htmlspecialchars($row['area_name']) . "</td>\n"; echo "<td>" . htmlspecialchars($row['room_name']) . "</td>\n"; // start date, with a link to the day.php $link = getdate($row['start_time']); echo "<td>"; // <span> for sorting echo "<span title=\"" . $row['start_time'] . "\"></span>"; echo "<a href=\"day.php?day={$link['mday']}&month={$link['mon']}&year={$link['year']}&area=" . $row['area_id'] . "\">"; if (empty($row['enable_periods'])) { $link_str = time_date_string($row['start_time']); } else { list(, $link_str) = period_date_string($row['start_time']); } echo "{$link_str}</a></td>"; // action buttons echo "<td>\n"; display_buttons($row, FALSE); echo "</td>\n"; echo "</tr>\n"; }
$area_name = htmlspecialchars($row[4]); $type = $row[5]; $room_id = $row[6]; $updated = time_date_string(MDB_Date::mdbstamp2Unix($row[7])); # need to make DST correct in opposite direction to entry creation # so that user see what he expects to see $duration = $row[8] - cross_dst($row[9], $row[10]); if ($enable_periods) { list($start_period, $start_date) = period_date_string($row[9]); } else { $start_date = time_date_string($row[9]); } if ($enable_periods) { list(, $end_date) = period_date_string($row[10], -1); } else { $end_date = time_date_string($row[10]); } $rep_type = 0; if ($series == 1) { $rep_type = $row[11]; $rep_end_date = utf8_strftime('%A %d %B %Y', $row[12]); $rep_opt = $row[13]; $rep_num_weeks = $row[14]; # I also need to set $id to the value of a single entry as it is a # single entry from a series that is used by del_entry.php and # edit_entry.php # So I will look for the first entry in the series where the entry is # as per the original series settings $types = array('integer'); $sql = "\nSELECT id\nFROM {$tbl_entry}\nWHERE repeat_id=\"{$id}\"\n AND entry_type=\"1\"\n"; # ORDER BY start_time";
<TH><?php echo $vocab["createdby"]; ?> </TH> <TH><?php echo $vocab["namebooker"]; ?> </TH> <TH><?php echo $vocab["description"]; ?> </TH> <TH><?php echo $vocab["start_date"]; ?> </TH> </TR> <?php for ($i = 0; $row = sql_row($result, $i); $i++) { echo "<TR>"; echo "<TD><A HREF=\"view_entry.php?id={$row['0']}\">{$vocab['view']}</A></TD>\n"; echo "<TD>" . htmlspecialchars($row[1]) . "</TD>\n"; echo "<TD>" . htmlspecialchars($row[2]) . "</TD>\n"; echo "<TD>" . htmlspecialchars($row[3]) . "</TD>\n"; // generate a link to the day.php $link = getdate($row[4]); echo "<TD><A HREF=\"day.php?day={$link['mday']}&month={$link['mon']}&year={$link['year']}&area={$row['5']}\">" . time_date_string($row[4]) . "</A></TD>"; echo "</TR>\n"; } echo "</TABLE>\n"; include "trailer.inc";
function display_entry_row($row) { echo "<tr>\n"; echo "<td class=\"control\"> </td>\n"; // reservation name, with a link to the view_entry page echo "<td>"; echo "<a href=\"view_entry/id:" . $row['id'] . "\">" . htmlspecialchars($row['name']) . "</a></td>\n"; // create_by, area and room names echo "<td>" . htmlspecialchars($row['create_by']) . "</td>\n"; echo "<td>" . htmlspecialchars($row['area_name']) . "</td>\n"; echo "<td>" . htmlspecialchars($row['room_name']) . "</td>\n"; // start date, with a link to the day.php $link = getdate($row['start_time']); echo "<td>"; $url = formatURLFull($link[year], $link[mon], $link[mday], $row['area_id'], NULL); echo "<a href=\"day/{$url}\">"; if (empty($row['enable_periods'])) { $link_str = time_date_string($row['start_time']); } else { list(, $link_str) = period_date_string($row['start_time']); } echo "{$link_str}</a></td>"; // action buttons echo "<td>\n"; display_buttons($row, FALSE); echo "</td>\n"; echo "</tr>\n"; }
?> </th> <th><?php echo get_vocab("start_date"); ?> </th> </tr> </thead> <tbody> <?php for ($i = 0; $row = sql_row_keyed($result, $i); $i++) { echo "<tr>\n"; echo "<td><a href=\"view_entry.php?id=" . $row['entry_id'] . "\">" . get_vocab("view") . "</a></td>\n"; echo "<td>" . htmlspecialchars($row['create_by']) . "</td>\n"; echo "<td>" . htmlspecialchars($row['name']) . "</td>\n"; echo "<td>" . htmlspecialchars($row['description']) . "</td>\n"; // generate a link to the day.php $link = getdate($row['start_time']); echo "<td><a href=\"day.php?day={$link['mday']}&month={$link['mon']}&year={$link['year']}&area=" . $row['area_id'] . "\">"; if (empty($enable_periods)) { $link_str = time_date_string($row['start_time']); } else { list(, $link_str) = period_date_string($row['start_time']); } echo "{$link_str}</a></td>"; echo "</tr>\n"; } echo "</tbody>\n"; echo "</table>\n"; require_once "trailer.inc";
//print the page header print_header("", "", "", $type = "with_session"); echo "<div class=\"page_sans_col_gauche\">"; //We tell them how bad what theyre about to do is //Find out how many appointments would be deleted $sql = "SELECT name, start_time, end_time FROM " . TABLE_PREFIX . "_entry WHERE room_id={$room}"; $res = grr_sql_query($sql); if (!$res) { echo grr_sql_error(); } else { if (grr_sql_count($res) > 0) { echo get_vocab("deletefollowing") . ":<ul>"; for ($i = 0; $row = grr_sql_row($res, $i); $i++) { echo "<li>{$row['0']} ("; echo time_date_string($row[1], $dformat) . " -> "; echo time_date_string($row[2], $dformat) . ")"; } echo "</ul>"; } } echo "<h1 style=\"text-align:center;\">" . get_vocab("sure") . "</h1>"; echo "<h1 style=\"text-align:center;\"><a href=\"admin_room_del.php?type=room&room={$room}&confirm=Y&id_area={$id_area}\">" . get_vocab("YES") . "!</a> <a href=\"admin_room.php?id_area={$id_area}\">" . get_vocab("NO") . "!</a></h1>"; echo "</div>"; } } if ($type == "area") { // Seul l'admin peut supprimer un domaine if (authGetUserLevel(getUserName(), $id_area, 'area') < 5) { showAccessDenied($back); exit; }
function reporton(&$row, &$last_area_room, &$last_date, $sortby, $display) { global $typel; global $output_as_csv; global $csv_row_sep; global $custom_fields, $field_natures, $field_lengths, $tbl_entry; global $approval_somewhere, $confirmation_somewhere; global $strftime_format; // Initialise the line for CSV reports $line = ""; // Display Area/Room, but only when it changes: $area_room = $row['area_name'] . " - " . $row['room_name']; $date = utf8_strftime($strftime_format['date'], $row['start_time']); // entries to be sorted on area/room echo $output_as_csv ? '' : "<div class=\"div_report\">\n"; if ($sortby == "r") { if ($area_room != $last_area_room) { echo $output_as_csv ? '' : "<h2>" . get_vocab("room") . ": " . escape($area_room) . "</h2>\n"; } if ($date != $last_date || $area_room != $last_area_room) { echo $output_as_csv ? '' : "<h3>" . get_vocab("date") . ": " . $date . "</h3>\n"; $last_date = $date; } // remember current area/room that is being processed. // this is done here as the if statement above needs the old // values if ($area_room != $last_area_room) { $last_area_room = $area_room; } } else { if ($date != $last_date) { echo $output_as_csv ? '' : "<h2>" . get_vocab("date") . ": " . $date . "</h2>\n"; } if ($area_room != $last_area_room || $date != $last_date) { echo $output_as_csv ? '' : "<h3>" . get_vocab("room") . ": " . escape($area_room) . "</h3>\n"; $last_area_room = $area_room; } // remember current date that is being processed. // this is done here as the if statement above needs the old // values if ($date != $last_date) { $last_date = $date; } } if ($output_as_csv) { $line = csv_row_add_value($line, $area_room); // for the CSV report put the area-room name on every line $line = csv_row_add_value($line, $row['name']); } else { echo "<div class=\"report_entry_title\">\n"; echo "<div class=\"report_entry_name\">\n"; // Brief Description (title), linked to view_entry: echo "<a href=\"view_entry/id:" . $row['id'] . "\">" . htmlspecialchars($row['name']) . "</a>\n"; echo "</div>\n"; } echo $output_as_csv ? '' : "<div class=\"report_entry_when\">\n"; // what do you want to display duration or end date/time if ($display == "d") { // Start date/time and duration: $when = empty($row['enable_periods']) ? describe_span($row['start_time'], $row['end_time']) : describe_period_span($row['start_time'], $row['end_time']); } else { // Start date/time and End date/time: $when = empty($row['enable_periods']) ? start_to_end($row['start_time'], $row['end_time']) : start_to_end_period($row['start_time'], $row['end_time']); } if ($output_as_csv) { $line = csv_row_add_value($line, $when); } else { echo "{$when}\n"; echo "</div>\n"; echo "</div>\n"; echo "<table>\n"; echo "<colgroup>\n"; echo "<col class=\"col1\">\n"; echo "<col class=\"col2\">\n"; echo "</colgroup>\n"; } // Description: if ($output_as_csv) { $line = csv_row_add_value($line, $row['description']); } else { echo "<tr>\n"; echo "<td>" . get_vocab("description") . ":</td>\n"; echo "<td>" . escape($row['description']) . "</td>\n"; echo "</tr>\n"; } // Entry Type: $et = empty($typel[$row['type']]) ? "?" . $row['type'] . "?" : $typel[$row['type']]; if ($output_as_csv) { $line = csv_row_add_value($line, $et); } else { echo "<tr>\n"; echo "<td>" . get_vocab("type") . ":</td>\n"; echo "<td>" . escape($et) . "</td>\n"; echo "</tr>\n"; } // Created by: if ($output_as_csv) { $line = csv_row_add_value($line, $row['create_by']); } else { echo "<tr>\n"; echo "<td>" . get_vocab("createdby") . ":</td>\n"; echo "<td>" . escape($row['create_by']) . "</td>\n"; echo "</tr>\n"; } // Confirmation status if ($confirmation_somewhere) { // Translate the status field bit into meaningful text if ($row['confirmation_enabled']) { $confirmation_status = $row['status'] & STATUS_TENTATIVE ? get_vocab("tentative") : get_vocab("confirmed"); } else { $confirmation_status = ''; } // Now output the text if ($output_as_csv) { $line = csv_row_add_value($line, $confirmation_status); } else { echo "<tr>\n"; echo "<td>" . get_vocab("confirmation_status") . ":</td>\n"; echo "<td>" . escape($confirmation_status) . "</td>\n"; echo "</tr>\n"; } } // Approval status if ($approval_somewhere) { // Translate the status field bit into meaningful text if ($row['approval_enabled']) { $approval_status = $row['status'] & STATUS_AWAITING_APPROVAL ? get_vocab("awaiting_approval") : get_vocab("approved"); } else { $approval_status = ''; } // Now output the text if ($output_as_csv) { $line = csv_row_add_value($line, $approval_status); } else { echo "<tr>\n"; echo "<td>" . get_vocab("approval_status") . ":</td>\n"; echo "<td>" . escape($approval_status) . "</td>\n"; echo "</tr>\n"; } } // Now do any custom fields foreach ($custom_fields as $key => $value) { // Output a yes/no if it's a boolean or integer <= 2 bytes (which we will // assume are intended to be booleans) if ($field_natures[$key] == 'boolean' || $field_natures[$key] == 'integer' && isset($field_lengths[$key]) && $field_lengths[$key] <= 2) { $output = empty($row[$key]) ? get_vocab("no") : get_vocab("yes"); } else { $output = isset($row[$key]) ? $row[$key] : ''; } if ($output_as_csv) { $line = csv_row_add_value($line, $output); } else { echo "<tr>\n"; echo "<td>" . get_loc_field_name($tbl_entry, $key) . ":</td>\n"; echo "<td>" . escape($output) . "</td>\n"; echo "</tr>\n"; } } // Last updated: if ($output_as_csv) { $line = csv_row_add_value($line, time_date_string($row['last_updated'])); } else { echo "<tr>\n"; echo "<td>" . get_vocab("lastupdate") . ":</td>\n"; echo "<td>" . time_date_string($row['last_updated']) . "</td>\n"; echo "</tr>\n"; } if ($output_as_csv) { // terminate and output the line $line .= $csv_row_sep; echo $line; } else { echo "</table>\n"; echo "</div>\n\n"; } }
// We tell them how bad what theyre about to do is // Find out how many appointments would be deleted $sql = "select name, start_time, end_time from {$tbl_entry} where room_id={$room}"; $res = sql_query($sql); if (!$res) { echo sql_error(); } else { if (sql_count($res) > 0) { echo "<p>\n"; echo get_vocab("deletefollowing") . ":\n"; echo "</p>\n"; echo "<ul>\n"; for ($i = 0; $row = sql_row_keyed($res, $i); $i++) { echo "<li>" . htmlspecialchars($row['name']) . " ("; echo time_date_string($row['start_time']) . " -> "; echo time_date_string($row['end_time']) . ")</li>\n"; } echo "</ul>\n"; } } echo "<div id=\"del_room_confirm\">\n"; echo "<p>" . get_vocab("sure") . "</p>\n"; echo "<div id=\"del_room_confirm_links\">\n"; echo "<a href=\"del.php?type=room&room={$room}&confirm=Y\"><span id=\"del_yes\">" . get_vocab("YES") . "!</span></a>\n"; echo "<a href=\"admin.php\"><span id=\"del_no\">" . get_vocab("NO") . "!</span></a>\n"; echo "</div>\n"; echo "</div>\n"; include "trailer.inc"; } } if ($type == "area") {
?> </TH> <TH><?php echo get_vocab("description"); ?> </TH> <TH><?php echo get_vocab("start_date"); ?> </TH> </TR> <?php for ($i = 0; $row = sql_row($result, $i); $i++) { echo "<TR>"; echo "<TD><A HREF=\"view_entry.php?id={$row['0']}\">" . get_vocab("view") . "</A></TD>\n"; echo "<TD>" . htmlspecialchars($row[1]) . "</TD>\n"; echo "<TD>" . htmlspecialchars($row[2]) . "</TD>\n"; echo "<TD>" . htmlspecialchars($row[3]) . "</TD>\n"; // generate a link to the day.php $link = getdate($row[4]); echo "<TD><A HREF=\"day.php?day={$link['mday']}&month={$link['mon']}&year={$link['year']}&area={$row['5']}\">"; if (empty($enable_periods)) { $link_str = time_date_string($row[4]); } else { list(, $link_str) = period_date_string($row[4]); } echo "{$link_str}</A></TD>"; echo "</TR>\n"; } echo "</table>\n"; include "trailer.inc";
/** * @param int $action */ function send_mail($id_entry, $action, $dformat, $tab_id_moderes = array()) { global $vocab, $grrSettings, $locale, $weekstarts, $enable_periods, $periods_name; $message_erreur = ''; // $action = 1 -> Création // $action = 2 -> Modification // $action = 3 -> Suppression // $action = 4 -> Suppression automatique // $action = 5 -> réservation en attente de modération // $action = 6 -> Résultat d'une décision de modération // $action = 7 -> Notification d'un retard dans la restitution d'une ressource. require_once 'phpmailer/PHPMailerAutoload.php'; define('GRR_FROM', Settings::get('grr_mail_from')); define('GRR_FROMNAME', Settings::get('grr_mail_fromname')); require_once './include/mail.inc.php'; //$m = new my_phpmailer(); $mail = new PHPMailer(); if (Settings::get('grr_mail_method') == 'smtp') { $smtpUsername = Settings::get('grr_mail_Username'); $smtpPassword = Settings::get('grr_mail_Password'); if ($smtpUsername != "") { $mail->SMTPAuth = true; $mail->Username = $smtpUsername; $mail->Password = $smtpPassword; } else { $mail->SMTPAuth = false; } $mail->Host = Settings::get('grr_mail_smtp'); $mail->Port = 587; $mail->isSMTP(); } else { $mail->isSendMail(); } /* if (Settings::get('grr_mail_method') == 'smtp') { $smtpUsername = Settings::get('grr_mail_Username'); $smtpPassword = Settings::get('grr_mail_Password'); $mail->isSMTP(); } if ($smtpUsername != "") { $mail->SMTPAuth = true; $mail->Username = $smtpUsername; $mail->Password = $smtpPassword; } else { $mail->SMTPAuth = true; } $mail->Host = Settings::get('grr_mail_smtp'); $mail->Port = 587;*/ $mail->CharSet = 'UTF-8'; $mail->setFrom(GRR_FROM, GRR_FROMNAME); $mail->SetLanguage('fr', './phpmailer/language/'); setlocale(LC_ALL, $locale); $sql = 'SELECT ' . TABLE_PREFIX . '_entry.name, ' . TABLE_PREFIX . '_entry.description, ' . TABLE_PREFIX . '_entry.beneficiaire, ' . TABLE_PREFIX . '_room.room_name, ' . TABLE_PREFIX . '_area.area_name, ' . TABLE_PREFIX . '_entry.type, ' . TABLE_PREFIX . '_entry.room_id, ' . TABLE_PREFIX . '_entry.repeat_id, ' . grr_sql_syntax_timestamp_to_unix('' . TABLE_PREFIX . '_entry.timestamp') . ', (' . TABLE_PREFIX . '_entry.end_time - ' . TABLE_PREFIX . '_entry.start_time), ' . TABLE_PREFIX . '_entry.start_time, ' . TABLE_PREFIX . '_entry.end_time, ' . TABLE_PREFIX . '_room.area_id, ' . TABLE_PREFIX . '_room.delais_option_reservation, ' . TABLE_PREFIX . '_entry.option_reservation, ' . TABLE_PREFIX . '_entry.moderate, ' . TABLE_PREFIX . '_entry.beneficiaire_ext, ' . TABLE_PREFIX . '_entry.jours, ' . TABLE_PREFIX . '_entry.clef, ' . TABLE_PREFIX . '_entry.courrier FROM ' . TABLE_PREFIX . '_entry, ' . TABLE_PREFIX . '_room, ' . TABLE_PREFIX . '_area WHERE ' . TABLE_PREFIX . '_entry.room_id = ' . TABLE_PREFIX . '_room.id AND ' . TABLE_PREFIX . '_room.area_id = ' . TABLE_PREFIX . '_area.id AND ' . TABLE_PREFIX . "_entry.id='" . protect_data_sql($id_entry) . "'\n\t"; $res = grr_sql_query($sql); if (!$res) { fatal_error(0, grr_sql_error()); } if (grr_sql_count($res) < 1) { fatal_error(0, get_vocab('invalid_entry_id')); } $row = grr_sql_row($res, 0); grr_sql_free($res); get_planning_area_values($row[12]); $breve_description = bbcode(removeMailUnicode(htmlspecialchars($row[0])), 'nobbcode'); $description = bbcode(removeMailUnicode(htmlspecialchars($row[1])), 'nobbcode'); $beneficiaire = htmlspecialchars($row[2]); $room_name = removeMailUnicode(htmlspecialchars($row[3])); $area_name = removeMailUnicode(htmlspecialchars($row[4])); $room_id = $row[6]; $area_id = $row[12]; $repeat_id = $row[7]; $date_avis = strftime('%Y/%m/%d', $row[10]); $startDay = date('d', $row[11]); $startMonth = date('m', $row[11]); $startYear = date('Y', $row[11]); $delais_option_reservation = $row[13]; $option_reservation = $row[14]; $moderate = $row[15]; $beneficiaire_ext = htmlspecialchars($row[16]); $jours_cycle = htmlspecialchars($row[17]); $duration = $row[9]; if ($enable_periods == 'y') { list($start_period, $start_date) = period_date_string($row[10]); } else { $start_date = time_date_string($row[10], $dformat); } $rep_type = 0; if ($repeat_id != 0) { $res = grr_sql_query('SELECT rep_type, end_date, rep_opt, rep_num_weeks FROM ' . TABLE_PREFIX . "_repeat WHERE id='" . protect_data_sql($repeat_id) . "'"); if (!$res) { fatal_error(0, grr_sql_error()); } $test = grr_sql_count($res); if ($test != 1) { fatal_error(0, 'Deux reservation on le meme ID.'); } else { $row2 = grr_sql_row($res, 0); $rep_type = $row2[0]; $rep_end_date = strftime($dformat, $row2[1]); $rep_opt = $row2[2]; $rep_num_weeks = $row2[3]; } grr_sql_free($res); } if ($enable_periods == 'y') { toPeriodString($start_period, $duration, $dur_units); } else { toTimeString($duration, $dur_units); } $weeklist = array('unused', 'every week', 'week 1/2', 'week 1/3', 'week 1/4', 'week 1/5'); if ($rep_type == 2) { $affiche_period = $vocab[$weeklist[$rep_num_weeks]]; } else { $affiche_period = $vocab['rep_type_' . $rep_type]; } // Le bénéficiaire $beneficiaire_email = affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, 'onlymail'); if ($beneficiaire != '') { $beneficiaire_actif = grr_sql_query1('SELECT etat FROM ' . TABLE_PREFIX . "_utilisateurs WHERE login='******'"); if ($beneficiaire_actif == -1) { $beneficiaire_actif = 'actif'; } // Cas des admins } elseif ($beneficiaire_ext != '' && $beneficiaire_email != '') { $beneficiaire_actif = 'actif'; } else { $beneficiaire_actif = 'inactif'; } // Utilisateur ayant agit sur la réservation $user_login = getUserName(); $user_email = grr_sql_query1('SELECT email FROM ' . TABLE_PREFIX . "_utilisateurs WHERE login='******'"); // // Elaboration du message destiné aux utilisateurs désignés par l'admin dans la partie "Mails automatiques" // //Nom de l'établissement et mention "mail automatique" $message = removeMailUnicode(Settings::get('company')) . ' - ' . $vocab['title_mail']; // Url de GRR $message = $message . traite_grr_url('', 'y') . "\n\n"; $sujet = $vocab['subject_mail1'] . $room_name . ' - ' . $date_avis; if ($action == 1) { $sujet = $sujet . $vocab['subject_mail_creation']; $message .= $vocab['the_user'] . affiche_nom_prenom_email($user_login, '', 'formail'); $message = $message . $vocab['creation_booking']; $message = $message . $vocab['the_room'] . $room_name . ' (' . $area_name . ") \n"; } elseif ($action == 2) { $sujet = $sujet . $vocab['subject_mail_modify']; if ($moderate == 1) { $sujet .= ' (' . $vocab['en_attente_moderation'] . ')'; } $message .= $vocab['the_user'] . affiche_nom_prenom_email($user_login, '', 'formail'); $message = $message . $vocab['modify_booking']; $message = $message . $vocab['the_room'] . $room_name . ' (' . $area_name . ') '; } elseif ($action == 3) { $sujet = $sujet . $vocab['subject_mail_delete']; if ($moderate == 1) { $sujet .= ' (' . $vocab['en_attente_moderation'] . ')'; } $message .= $vocab['the_user'] . affiche_nom_prenom_email($user_login, '', 'formail'); $message = $message . $vocab['delete_booking']; $message = $message . $vocab['the_room'] . $room_name . ' (' . $area_name . ") \n"; } elseif ($action == 4) { $sujet = $sujet . $vocab['subject_mail_delete']; $message = $message . $vocab['suppression_automatique']; $message = $message . $vocab['the_room'] . $room_name . ' (' . $area_name . ") \n"; } elseif ($action == 5) { $sujet = $sujet . $vocab['subject_mail_moderation']; $message = $message . $vocab['reservation_en_attente_de_moderation']; $message = $message . $vocab['the_room'] . $room_name . ' (' . $area_name . ") \n"; } elseif ($action == 6) { $sujet = $sujet . $vocab['subject_mail_decision_moderation']; $resmoderate = grr_sql_query('SELECT moderate, motivation_moderation FROM ' . TABLE_PREFIX . "_entry_moderate WHERE id ='" . protect_data_sql($id_entry) . "'"); if (!$resmoderate) { fatal_error(0, grr_sql_error()); } if (grr_sql_count($resmoderate) < 1) { fatal_error(0, get_vocab('invalid_entry_id')); } $rowModerate = grr_sql_row($resmoderate, 0); grr_sql_free($resmoderate); $moderate_decision = $rowModerate[0]; $moderate_description = $rowModerate[1]; $message .= $vocab['the_user'] . affiche_nom_prenom_email($user_login, '', 'formail'); $message = $message . $vocab['traite_moderation']; $message = $message . $vocab['the_room'] . $room_name . ' (' . $area_name . ') '; $message = $message . $vocab['reservee au nom de']; $message = $message . $vocab['the_user'] . affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, 'formail') . " \n"; if ($moderate_decision == 2) { $message .= "\n" . $vocab['moderation_acceptee']; } elseif ($moderate_decision == 3) { $message .= "\n" . $vocab['moderation_refusee']; } if ($moderate_description != '') { $message .= "\n" . $vocab['motif'] . $vocab['deux_points']; $message .= $moderate_description . " \n----"; } $message .= "\n" . $vocab['voir_details'] . $vocab['deux_points'] . "\n"; if (count($tab_id_moderes) == 0) { $message .= "\n" . traite_grr_url('', 'y') . 'view_entry.php?id=' . $id_entry; } else { foreach ($tab_id_moderes as $id_moderes) { $message .= "\n" . traite_grr_url('', 'y') . 'view_entry.php?id=' . $id_moderes; } } $message .= "\n\n" . $vocab['rappel_de_la_demande'] . $vocab['deux_points'] . "\n"; } elseif ($action == 7) { $sujet .= $vocab['subject_mail_retard']; $message .= $vocab['message_mail_retard'] . $vocab['deux_points'] . " \n"; $message .= $room_name . ' (' . $area_name . ") \n"; $message .= $vocab['nom emprunteur'] . $vocab['deux_points']; $message .= affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, 'formail') . " \n"; if ($beneficiaire_email != '') { $message .= $vocab['un email envoye'] . $beneficiaire_email . " \n"; } $message .= "\n" . $vocab['changer statut lorsque ressource restituee'] . $vocab['deux_points']; $message .= "\n" . traite_grr_url('', 'y') . 'view_entry.php?id=' . $id_entry . " \n"; } if ($action == 2 || $action == 3) { $message = $message . $vocab['reservee au nom de']; $message = $message . $vocab['the_user'] . affiche_nom_prenom_email($beneficiaire, $beneficiaire_ext, 'formail') . " \n"; } if ($action == 5 || $action == 7) { $repondre = Settings::get('webmaster_email'); } else { $repondre = $user_email; } // // Infos sur la réservation // $reservation = ''; $reservation = $reservation . $vocab['start_of_the_booking'] . ' ' . $start_date . "\n"; $reservation = $reservation . $vocab['duration'] . ' ' . $duration . ' ' . $dur_units . "\n"; if (trim($breve_description) != '') { $reservation = $reservation . $vocab['namebooker'] . preg_replace('/ /', ' ', $vocab['deux_points']) . ' ' . $breve_description . "\n"; } else { $reservation = $reservation . $vocab['entryid'] . $room_id . "\n"; } if ($description != '') { $reservation = $reservation . $vocab['description'] . ' ' . $description . "\n"; } // Champ additionnel $reservation .= affichage_champ_add_mails($id_entry); // Type de réservation $temp = grr_sql_query1('SELECT type_name FROM ' . TABLE_PREFIX . "_type_area WHERE type_letter='" . $row[5] . "'"); if ($temp == -1) { $temp = '?' . $row[5] . '?'; } else { $temp = removeMailUnicode($temp); } $reservation = $reservation . $vocab['type'] . preg_replace('/ /', ' ', $vocab['deux_points']) . ' ' . $temp . "\n"; if ($rep_type != 0) { $reservation = $reservation . $vocab['rep_type'] . ' ' . $affiche_period . "\n"; } if ($rep_type != 0) { if ($rep_type == 2) { $opt = ''; for ($i = 0; $i < 7; ++$i) { $daynum = ($i + $weekstarts) % 7; if ($rep_opt[$daynum]) { $opt .= day_name($daynum) . ' '; } } if ($opt) { $reservation = $reservation . $vocab['rep_rep_day'] . ' ' . $opt . "\n"; } } if ($rep_type == 6) { if (Settings::get('jours_cycles_actif') == 'Oui') { $reservation = $reservation . $vocab['rep_type_6'] . preg_replace('/ /', ' ', $vocab['deux_points']) . ucfirst(substr($vocab['rep_type_6'], 0, 1)) . $jours_cycle . "\n"; } } $reservation = $reservation . $vocab['rep_end_date'] . ' ' . $rep_end_date . "\n"; } if ($delais_option_reservation > 0 && $option_reservation != -1) { $reservation = $reservation . '*** ' . $vocab['reservation_a_confirmer_au_plus_tard_le'] . ' ' . time_date_string_jma($option_reservation, $dformat) . " ***\n"; } $reservation = $reservation . "-----\n"; $message = $message . $reservation; $message = $message . $vocab['msg_no_email'] . Settings::get('webmaster_email'); $message = html_entity_decode($message); $sql = 'SELECT u.email FROM ' . TABLE_PREFIX . '_utilisateurs u, ' . TABLE_PREFIX . "_j_mailuser_room j WHERE (j.id_room='" . protect_data_sql($room_id) . "' AND u.login=j.login and u.etat='actif') ORDER BY u.nom, u.prenom"; $res = grr_sql_query($sql); $nombre = grr_sql_count($res); if ($nombre > 0) { $tab_destinataire = array(); for ($i = 0; $row = grr_sql_row($res, $i); ++$i) { if ($row[0] != '') { $tab_destinataire[] = $row[0]; } } foreach ($tab_destinataire as $value) { if (Settings::get('grr_mail_Bcc') == 'y') { $mail->AddBCC($value); } else { $mail->AddAddress($value); } } $mail->Subject = $sujet; $mail->Body = $message; $mail->AddReplyTo($repondre); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } } $mail->ClearAddresses(); $mail->ClearBCCs(); $mail->ClearReplyTos(); if ($action == 7) { $mail_admin = find_user_room($room_id); if (count($mail_admin) > 0) { foreach ($mail_admin as $value) { if (Settings::get('grr_mail_Bcc') == 'y') { $mail->AddBCC($value); } else { $mail->AddAddress($value); } } $mail->Subject = $sujet; $mail->Body = $message; $mail->AddReplyTo($repondre); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } } $mail->ClearAddresses(); $mail->ClearBCCs(); $mail->ClearReplyTos(); } if ($action == 7) { $sujet7 = $vocab['subject_mail1'] . $room_name . ' - ' . $date_avis; $sujet7 .= $vocab['subject_mail_retard']; $message7 = removeMailUnicode(Settings::get('company')) . ' - ' . $vocab['title_mail']; $message7 .= traite_grr_url('', 'y') . "\n\n"; $message7 .= $vocab['ressource empruntee non restituée'] . "\n"; $message7 .= $room_name . ' (' . $area_name . ')'; $message7 .= "\n" . $reservation; $message7 = html_entity_decode($message7); $destinataire7 = $beneficiaire_email; $repondre7 = Settings::get('webmaster_email'); $mail->AddAddress($destinataire7); $mail->Subject = $sujet7; $mail->Body = $message7; $mail->AddReplyTo($repondre7); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } if ($action == 4) { $destinataire4 = $beneficiaire_email; $repondre4 = Settings::get('webmaster_email'); $mail->AddAddress($destinataire4); $mail->Subject = $sujet; $mail->Body = $message; $mail->AddReplyTo($repondre4); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } if ($action == 5) { $mail_admin = find_user_room($room_id); if (count($mail_admin) > 0) { foreach ($mail_admin as $value) { if (Settings::get('grr_mail_Bcc') == 'y') { $mail->AddBCC($value); } else { $mail->AddAddress($value); } } $sujet5 = $vocab['subject_mail1'] . $room_name . ' - ' . $date_avis; $sujet5 .= $vocab['subject_mail_moderation']; $message5 = removeMailUnicode(Settings::get('company')) . ' - ' . $vocab['title_mail']; $message5 .= traite_grr_url('', 'y') . "\n\n"; $message5 .= $vocab['subject_a_moderer']; //$message5 .= "\n".traite_grr_url('', 'y').'view_entry.php?id='.$id_entry; /* changing view entry for the day view, to have quick look around the entry to modify*/ $message5 .= "\n" . traite_grr_url('', 'y') . 'week.php?year=' . $startYear . '&month=' . $startMonth . '&day=' . $startDay . '&room=' . $room_id; $message5 .= "\n\n" . $vocab['created_by'] . affiche_nom_prenom_email($user_login, '', 'formail'); $message5 .= "\n" . $vocab['room'] . $vocab['deux_points'] . $room_name . ' (' . $area_name . ") \n"; $message5 = html_entity_decode($message5); $repondre5 = Settings::get('webmaster_email'); $mail->Subject = $sujet5; $mail->Body = $message5; $mail->AddReplyTo($repondre5); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } } $mail->ClearAddresses(); $mail->ClearBCCs(); $mail->ClearReplyTos(); } if ($action == 5 && $beneficiaire_email != '' && $beneficiaire_actif == 'actif') { $sujet5 = $vocab['subject_mail1'] . $room_name . ' - ' . $date_avis; $sujet5 .= $vocab['subject_mail_moderation']; $message5 = removeMailUnicode(Settings::get('company')) . ' - ' . $vocab['title_mail']; $message5 .= traite_grr_url('', 'y') . "\n\n"; $message5 .= $vocab['texte_en_attente_de_moderation']; $message5 .= "\n" . $vocab['rappel_de_la_demande'] . $vocab['deux_points']; $message5 .= "\n" . $vocab['the_room'] . $room_name . ' (' . $area_name . ')'; $message5 .= "\n" . $reservation; $message5 = html_entity_decode($message5); $destinataire5 = $beneficiaire_email; $repondre5 = Settings::get('webmaster_email'); $mail->AddAddress($destinataire5); $mail->Subject = $sujet5; $mail->Body = $message5; $mail->AddReplyTo($repondre5); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } if ($action == 6 && $beneficiaire_email != '' && $beneficiaire_actif == 'actif') { $sujet6 = $vocab['subject_mail1'] . $room_name . ' - ' . $date_avis; $sujet6 .= $vocab['subject_mail_decision_moderation']; $message6 = $message; $destinataire6 = $beneficiaire_email; $repondre6 = $user_email; $mail->AddAddress($destinataire6); $mail->Subject = $sujet6; $mail->Body = $message6; $mail->AddReplyTo($repondre6); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } // Cas d'une création, modification ou suppression d'un message par un utilisateur différent du bénéficiaire : // On envoie un message au bénéficiaire de la réservation pour l'avertir d'une modif ou d'une suppression if (($action == 1 || $action == 2 || $action == 3) && (strtolower($user_login) != strtolower($beneficiaire) || Settings::get('send_always_mail_to_creator') == '1') && $beneficiaire_email != '' && $beneficiaire_actif == 'actif') { $sujet2 = $vocab['subject_mail1'] . $room_name . ' - ' . $date_avis; $message2 = removeMailUnicode(Settings::get('company')) . ' - ' . $vocab['title_mail']; $message2 = $message2 . traite_grr_url('', 'y') . "\n\n"; $message2 = $message2 . $vocab['the_user'] . affiche_nom_prenom_email($user_login, '', 'formail'); if ($action == 1) { $sujet2 = $sujet2 . $vocab['subject_mail_creation']; $message2 = $message2 . $vocab['creation_booking_for_you']; $message2 = $message2 . $vocab['the_room'] . $room_name . ' (' . $area_name . ').'; } elseif ($action == 2) { $sujet2 = $sujet2 . $vocab['subject_mail_modify']; $message2 = $message2 . $vocab['modify_booking']; $message2 = $message2 . $vocab['the_room'] . $room_name . ' (' . $area_name . ')'; $message2 = $message2 . $vocab['created_by_you']; } else { $sujet2 = $sujet2 . $vocab['subject_mail_delete']; $message2 = $message2 . $vocab['delete_booking']; $message2 = $message2 . $vocab['the_room'] . $room_name . ' (' . $area_name . ')'; $message2 = $message2 . $vocab['created_by_you']; } $message2 = $message2 . "\n" . $reservation; $message2 = html_entity_decode($message2); $destinataire2 = $beneficiaire_email; $repondre2 = $user_email; $mail->AddAddress($destinataire2); $mail->Subject = $sujet2; $mail->Body = $message2; $mail->AddReplyTo($repondre2); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; } $mail->ClearAddresses(); $mail->ClearReplyTos(); } return $message_erreur; }
function report_row(&$rows, &$data) { global $output_format, $ajax, $ajax_capable; global $csv_row_sep, $csv_col_sep; global $custom_fields, $field_natures, $field_lengths, $tbl_entry; global $approval_somewhere, $confirmation_somewhere; global $strftime_format; global $select_options; global $field_order_list; // If we're capable of delivering an Ajax request and this is not Ajax request, // then don't do anything. We're going to save sending the data until we actually // get the Ajax request; we just send the rest of the page at this stage. if ($output_format == OUTPUT_HTML && $ajax_capable && !$ajax) { return; } $values = array(); foreach ($field_order_list as $field) { $value = $data[$field]; // Some fields need some special processing to turn the raw value into something // more meaningful switch ($field) { case 'end_time': // Calculate the duration and then fall through to calculating the end date // Need the duration in seconds for sorting. Have to correct it for DST // changes so that the user sees what he expects to see $duration_seconds = $data['end_time'] - $data['start_time']; $duration_seconds -= cross_dst($data['start_time'], $data['end_time']); $d = get_duration($data['start_time'], $data['end_time'], $data['enable_periods']); $d_string = $d['duration'] . ' ' . $d['dur_units']; $d_string = escape($d_string); case 'start_time': $mod_time = $field == 'start_time' ? 0 : -1; if ($data['enable_periods']) { list(, $date) = period_date_string($value, $mod_time); } else { $date = time_date_string($value); } $value = $date; break; case 'type': $value = get_type_vocab($value); break; case 'confirmation_enabled': // Translate the status field bit into meaningful text if ($data['confirmation_enabled']) { $value = $data['status'] & STATUS_TENTATIVE ? get_vocab("tentative") : get_vocab("confirmed"); } else { $value = ''; } break; case 'approval_enabled': // Translate the status field bit into meaningful text if ($data['approval_enabled']) { $value = $data['status'] & STATUS_AWAITING_APPROVAL ? get_vocab("awaiting_approval") : get_vocab("approved"); } else { $value = ''; } break; case 'last_updated': $value = time_date_string($value); break; default: // Custom fields if (array_key_exists($field, $custom_fields)) { // Output a yes/no if it's a boolean or integer <= 2 bytes (which we will // assume are intended to be booleans) if ($field_natures[$field] == 'boolean' || $field_natures[$field] == 'integer' && isset($field_lengths[$field]) && $field_lengths[$field] <= 2) { $value = empty($value) ? get_vocab("no") : get_vocab("yes"); } elseif (isset($value)) { // If the custom field is an associative array then we want // the value rather than the array key (provided the key is not // an empty string) if (isset($select_options["entry.{$field}"]) && is_assoc($select_options["entry.{$field}"]) && array_key_exists($value, $select_options["entry.{$field}"]) && $value !== '') { $value = $select_options["entry.{$field}"][$value]; } } else { $value = ''; } } break; } $value = escape($value); // For HTML output we take special action for some fields if ($output_format == OUTPUT_HTML) { switch ($field) { case 'name': // Add a link to the entry and also a data-id value for the Bulk Delete JavaScript $value = "<a href=\"view_entry.php?id=" . $data['id'] . "\"" . " data-id=\"" . $data['id'] . "\"" . " title=\"{$value}\">{$value}</a>"; break; case 'end_time': // Process the duration and then fall through to the end_time // Include the duration in a seconds as a title in an empty span so // that the column can be sorted and filtered properly $d_string = "<span title=\"{$duration_seconds}\"></span>{$d_string}"; case 'start_time': case 'last_updated': // Include the numeric time as a title in an empty span so // that the column can be sorted and filtered properly $value = "<span title=\"{$data[$field]}\"></span>{$value}"; break; default: break; } } // Add the value to the array. We don't bother with some fields if // they are going to be irrelevant if (($confirmation_somewhere || $field != 'confirmation_enabled') && ($approval_somewhere || $field != 'approval_enabled')) { $values[] = $value; } // Special action for the duration if ($field == 'end_time') { $values[] = $d_string; } } // foreach $rows[] = $values; }
function reporton(&$row, &$last_area_room, &$last_date, $sortby, $display) { global $typel; global $enable_periods; # Display Area/Room, but only when it changes: $area_room = htmlspecialchars($row[8]) . " - " . htmlspecialchars($row[9]); $date = userdate($row[1], "%d-%b-%Y"); # entries to be sorted on area/room if ($sortby == "r") { if ($area_room != $last_area_room) { echo "<hr><h2>" . get_string('room', 'block_mrbs') . ": " . $area_room . "</h2>\n"; } if ($date != $last_date || $area_room != $last_area_room) { echo "<hr noshade=\"true\"><h3>" . get_string('date') . " " . $date . "</h3>\n"; $last_date = $date; } # remember current area/room that is being processed. # this is done here as the if statement above needs the old # values if ($area_room != $last_area_room) { $last_area_room = $area_room; } } else { if ($date != $last_date) { echo "<hr><h2>" . get_string('date') . " " . $date . "</h2>\n"; } if ($area_room != $last_area_room || $date != $last_date) { echo "<hr noshade=\"true\"><h3>" . get_string('room', 'block_mrbs') . ": " . $area_room . "</h3>\n"; $last_area_room = $area_room; } # remember current date that is being processed. # this is done here as the if statement above needs the old # values if ($date != $last_date) { $last_date = $date; } } echo "<hr><table width=\"100%\">\n"; # Brief Description (title), linked to view_entry: echo "<tr><td class=\"BL\"><a href=\"view_entry.php?id={$row['0']}\">" . htmlspecialchars($row[3]) . "</a></td>\n"; # what do you want to display duration or end date/time if ($display == "d") { # Start date/time and duration: echo "<td class=\"BR\" align=right>" . (empty($enable_periods) ? describe_span($row[1], $row[2]) : describe_period_span($row[1], $row[2])) . "</td></tr>\n"; } else { # Start date/time and End date/time: echo "<td class=\"BR\" align=right>" . (empty($enable_periods) ? start_to_end($row[1], $row[2]) : start_to_end_period($row[1], $row[2])) . "</td></tr>\n"; } # Description: echo "<tr><td class=\"BL\" colspan=2><b>" . get_string('description') . "</b> " . nl2br(htmlspecialchars($row[4])) . "</td></tr>\n"; # Entry Type: $et = empty($typel[$row[5]]) ? "?{$row['5']}?" : $typel[$row[5]]; echo "<tr><td class=\"BL\" colspan=2><b>" . get_string('type', 'block_mrbs') . "</b> {$et}</td></tr>\n"; # Created by and last update timestamp: echo "<tr><td class=\"BL\" colspan=2><small><b>" . get_string('createdby', 'block_mrbs') . "</b> " . htmlspecialchars($row[6]) . ", <b>" . get_string('lastmodified') . "</b> " . time_date_string($row[7]) . "</small></td></tr>\n"; echo "</table>\n"; }