function display_week() { global $vars; $heading_html = tag('tr'); $heading_html->add(tag('th', __p('Week', 'W'))); for ($i = 0; $i < 7; $i++) { $d = ($i + day_of_week_start()) % 7; $heading_html->add(tag('th', day_name($d))); } if (!isset($vars['week']) || !isset($vars['year'])) { soft_error(__('Invalid date.')); } $week_of_year = intval($vars['week']); $year = intval($vars['year']); $day_of_year = 1 + ($week_of_year - 1) * 7 - day_of_week(1, 1, $year); $from_stamp = mktime(0, 0, 0, 1, $day_of_year, $year); $start_month = date("n", $from_stamp); $start_year = date("Y", $from_stamp); $last_day = $day_of_year + 6; $to_stamp = mktime(23, 59, 59, 1, $last_day, $year); $end_month = date("n", $to_stamp); $end_year = date("Y", $to_stamp); $heading = month_name($start_month) . " {$start_year}"; if ($end_month != $start_month) { $heading .= " - " . month_name($end_month) . " {$end_year}"; } return tag('', tag("div", attributes('id="phpc-summary-view"'), tag("div", attributes('id="phpc-summary-head"'), tag("div", attributes('id="phpc-summary-title"'), ''), tag("div", attributes('id="phpc-summary-author"'), ''), tag("div", attributes('id="phpc-summary-category"'), ''), tag("div", attributes('id="phpc-summary-time"'), '')), tag("div", attributes('id="phpc-summary-body"'), '')), tag('table', attributes('class="phpc-main phpc-calendar"'), tag('caption', $heading), tag('colgroup', tag('col', attributes('class="phpc-week"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"'))), tag('thead', $heading_html), create_week($week_of_year, $from_stamp, $to_stamp, $year))); }
function display_month($month, $year) { global $config; $days = tag('tr'); for ($i = 0; $i < 7; $i++) { if ($config['start_monday']) { $d = $i + 1 % 7; } else { $d = $i; } $days->add(tag('th', day_name($d))); } return tag('div', month_navbar($month, $year), tag('table', attributes('class="phpc-main"', 'id="calendar"'), tag('caption', month_name($month) . " {$year}"), tag('colgroup', attributes('span="7"', 'width="1*"')), tag('thead', $days), create_month($month, $year))); }
function display_month() { global $month, $year, $phpc_home_url, $phpcid; $heading_html = tag('tr'); $heading_html->add(tag('th', __p('Week', 'W'))); for ($i = 0; $i < 7; $i++) { $d = ($i + day_of_week_start()) % 7; $heading_html->add(tag('th', day_name($d))); } $months = array(); for ($i = 1; $i <= 12; $i++) { $m = month_name($i); $months["{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$i}&year={$year}"] = $m; } $years = array(); for ($i = $year - 5; $i <= $year + 5; $i++) { $years["{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$month}&year={$i}"] = $i; } return tag('', tag("div", attributes('id="phpc-summary-view"'), tag("div", attributes('id="phpc-summary-head"'), tag("div", attributes('id="phpc-summary-title"'), ''), tag("div", attributes('id="phpc-summary-author"'), ''), tag("div", attributes('id="phpc-summary-category"'), ''), tag("div", attributes('id="phpc-summary-time"'), '')), tag("div", attributes('id="phpc-summary-body"'), '')), tag('table', attributes('class="phpc-main phpc-calendar"'), tag('caption', create_dropdown_list(month_name($month), $months), create_dropdown_list($year, $years)), tag('colgroup', tag('col', attributes('class="phpc-week"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"'))), tag('thead', $heading_html), create_month($month, $year))); }
$tplArrayEditEntry['pasPeriodique']['vocab'] = get_vocab('rep_type_' . $rep_type); $affiche_period = get_vocab('rep_type_' . $rep_type); } //echo '<tr><td class="E"><b>'.get_vocab('rep_type').'</b> '.$affiche_period.'</td></tr>'."\n"; if ($rep_type != 0) { //$tplArrayEditEntry['pasPeriodique']['repTypeNot0'] = true; $opt = ''; if ($rep_type == 2) { $nb = 0; for ($i = 0; $i < 7; ++$i) { $wday = ($i + $weekstarts) % 7; if ($rep_opt[$wday]) { if ($opt != '') { $opt .= ', '; } $opt .= day_name($wday); ++$nb; } } } if ($rep_type == 6) { $nb = 1; $opt .= get_vocab('jour_cycle') . ' ' . $jours_c; } 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 "<legend></legend>\n"; $params = array('name' => 'month_type', 'options' => array(REP_MONTH_RELATIVE => get_vocab("month_relative")), 'value' => $month_type, 'disabled' => $disabled); generate_radio($params); // Note: the select box order does not internationalise very well and could // do with revisiting. It assumes all languages have the same order as English // eg "the second Wednesday" which is probably not true. $options = array(); foreach (array('1', '2', '3', '4', '5', '-1', '-2', '-3', '-4', '-5') as $i) { $options[$i] = get_vocab("ord_" . $i); } $params = array('name' => 'month_relative_ord', 'value' => $month_relative_ord, 'disabled' => $disabled, 'options' => $options, 'force_assoc' => TRUE); generate_select($params); $options = array(); for ($i = 0; $i < 7; $i++) { $i_offset = ($i + $weekstarts) % 7; $options[$RFC_5545_days[$i_offset]] = day_name($i_offset); } $params = array('name' => 'month_relative_day', 'value' => $month_relative_day, 'disabled' => $disabled, 'options' => $options); generate_select($params); echo "</fieldset>\n"; echo "</fieldset>\n"; } // Repeat end date echo "<div id=\"rep_end_date\">\n"; echo "<label>" . get_vocab("rep_end_date") . ":</label>\n"; genDateSelector("rep_end_", $rep_end_day, $rep_end_month, $rep_end_year, '', $disabled); echo "</div>\n"; // Checkbox for skipping past conflicts if (!$disabled) { echo "<div>\n"; $params = array('label' => get_vocab("skip_conflicts") . ":", 'name' => 'skip', 'value' => !empty($skip_default));
function listevents() { global $list_prefix; $EVENTS = "<select name='deletelist'>\r\n"; $count = 0; //now we will list weekly events $sql = "SELECT * FROM " . $list_prefix . "calendar WHERE `weekly` < '7';"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if ($rows > 0) { $i = 0; while ($i < $rows) { $row = db_fetch_array($result); //calculate the time $time = $row['time']; $hour = $time[0] . $time[1]; $min = $time[2] . $time[3]; if ($hour < 12) { //we are in the am. if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "am"; } else { //we are in the pm $hour -= 12; if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "pm"; } $EVENTS .= "<option value='" . $row['id'] . "'>" . day_name($row['weekly']) . " at " . $time . "</option>\r\n"; $count++; $i++; } } //we will do the monthly events $sql = "SELECT * FROM " . $list_prefix . "calendar WHERE `monthly` NOT LIKE '';"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if ($rows > 0) { $i = 0; while ($i < $rows) { $row = db_fetch_array($result); //calculate the time $time = $row['time']; $hour = $time[0] . $time[1]; $min = $time[2] . $time[3]; if ($hour < 12) { //we are in the am. if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "am"; } else { //we are in the pm $hour -= 12; if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "pm"; } $EVENTS .= "<option value='" . $row['id'] . "'>Monthly on the " . $row['monthly'] . " at " . $time . "</option>\r\n"; $count++; $i++; } } //we will do yearly events $sql = "SELECT * FROM " . $list_prefix . "calendar WHERE `yearly` NOT LIKE '';"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if ($rows > 0) { $i = 0; while ($i < $rows) { $row = db_fetch_array($result); //calculate the time $time = $row['time']; $hour = $time[0] . $time[1]; $min = $time[2] . $time[3]; if ($hour < 12) { //we are in the am. if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "am"; } else { //we are in the pm $hour -= 12; if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "pm"; } $t = $row['yearly']; $t = monthname($t[0] . $t[1]) . " " . $t[2] . $t[3]; $EVENTS .= "<option value='" . $row['id'] . "'>Yearly on " . $t . " at " . $time . "</option>\r\n"; $count++; $i++; } } //now we will work scheduled events $sql = "SELECT * FROM " . $list_prefix . "calendar WHERE `date` NOT LIKE '';"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if ($rows > 0) { $i = 0; while ($i < $rows) { $row = db_fetch_array($result); //calculate the time $time = $row['time']; $hour = $time[0] . $time[1]; $min = $time[2] . $time[3]; if ($hour < 12) { //we are in the am. if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "am"; } else { //we are in the pm $hour -= 12; if ($hour == 0) { $hour = "12"; } $time = $hour . ":" . $min . "pm"; } $t = $row['date']; $t = monthname($t[4] . $t[5]) . " " . $t[6] . $t[7] . ", " . $t[0] . $t[1] . $t[2] . $t[3]; $EVENTS .= "<option value='" . $row['id'] . "'>" . $t . " at " . $time . "</option>\r\n"; $count++; $i++; } } if ($count == 0) { $EVENTS .= "<option value='-'>Nothing to delete</option>\r\n"; } $EVENTS .= "</select>"; return $EVENTS; }
echo " ID: " . $d[$i]["id"][$j] . " Data: " . $d[$i]["data"][$j] . "\n"; } } } echo "</pre>\n"; } // Include the active cell content management routines. // Must be included before the beginnning of the main table. if ($javascript_cursor) { echo "<SCRIPT language=\"JavaScript\" type=\"text/javascript\" src=\"xbLib.js\"></SCRIPT>\n"; echo "<SCRIPT language=\"JavaScript\">InitActiveCell(" . ($show_plus_link ? "true" : "false") . ", " . "false, " . "false, " . "\"{$highlight_method}\", " . "\"" . get_string('click_to_reserve', 'block_mrbs') . "\"" . ");</SCRIPT>\n"; } echo "<table border=\"1\" cellspacing=\"0\" width=\"100%\">\n<tr>"; # Weekday name header row: for ($weekcol = 0; $weekcol < 7; $weekcol++) { echo "<th width=\"14%\">" . day_name(($weekcol + $weekstarts) % 7) . "</th>"; } echo "</tr><tr>\n"; # Skip days in week before start of month: for ($weekcol = 0; $weekcol < $weekday_start; $weekcol++) { echo "<td bgcolor=\"#cccccc\" height=100> </td>\n"; } # Draw the days of the month: for ($cday = 1; $cday <= $days_in_month; $cday++) { if ($weekcol == 0) { echo "</tr><tr>\n"; } echo "<td valign=top height=100 class=\"month\"><div class=\"monthday\"><a href=\"day.php?year={$year}&month={$month}&day={$cday}&area={$area}\">{$cday}</a> \n"; echo "</div>"; # Anything to display for this day? if (isset($d[$cday]["id"][0])) {
$tplArray['jours'][$weekcol]['vacances'] = true; $tplArray['jours'][$weekcol]['vacancesTitle'] = $sh[1]; $class .= 'vacance '; $title = ' ' . $sh[1]; } if ($ferie_true) { $tplArray['jours'][$weekcol]['ferie'] = true; $class .= 'ferie '; } } //echo '<th class="jour_sem">'.PHP_EOL; //echo '<a class="lienPlanning '.$class.'" href="day.php?year='.$temp_year.'&month='.$temp_month.'&day='.$num_day.'&area='.$area.'" title="'.$title.'">'.day_name(($weekcol + $weekstarts) % 7).' '.$num_day.' '.$temp_month2.'</a>'.PHP_EOL; $tplArray['jours'][$weekcol]['numDay'] = $num_day; $tplArray['jours'][$weekcol]['linkHref'] = 'day.php?year=' . $temp_year . '&month=' . $temp_month . '&day=' . $num_day . '&area=' . $area; $tplArray['jours'][$weekcol]['linkTitle'] = $title; $tplArray['jours'][$weekcol]['linkText'] = day_name(($weekcol + $weekstarts) % 7) . ' ' . $num_day . ' ' . $temp_month2; /* is this day in the past ? */ if ($t < time()) { $tplArray['jours'][$weekcol]['past'] = true; } else { $tplArray['jours'][$weekcol]['past'] = false; } if (Settings::get('jours_cycles_actif') == 'Oui' && intval($jour_cycle) > -1) { if (intval($jour_cycle) > 0) { $tplArray['jours'][$weekcol]['jourCycleActifFirst'] = true; $tplArray['jours'][$weekcol]['jourCycle'] = $jour_cycle; $tplArray['vocab']['rep_type_6'] = get_vocab('rep_type_6'); //echo '<br />'.get_vocab('rep_type_6').' '.$jour_cycle; } else { $tplArray['jours'][$weekcol]['jourCycleActifFirst'] = false; $tplArray['jours'][$weekcol]['jourCycle'] = $jour_cycle;
if ($tt == $value) { $ferie_true = 1; break; } } $sh = getSchoolHolidays($tt, $temp_year); if ($sh[0] == true) { $class .= "vacance "; $title = " " . $sh[1]; } if ($ferie_true) { $class .= "ferie "; } } echo '<th class="jour_sem">' . PHP_EOL; echo '<a class="lienPlanning ' . $class . '" href="day.php?year=' . $temp_year . '&month=' . $temp_month . '&day=' . $num_day . '&area=' . $area . '" title="' . $title . '">' . day_name(($weekcol + $weekstarts) % 7) . ' ' . $num_day . ' ' . $temp_month2 . '</a>' . PHP_EOL; if (Settings::get("jours_cycles_actif") == "Oui" && intval($jour_cycle) > -1) { if (intval($jour_cycle) > 0) { echo "<br />" . get_vocab("rep_type_6") . " " . $jour_cycle; } else { echo "<br />" . $jour_cycle; } } echo '</th>' . PHP_EOL; } $num_week_day++; $num_week_day = $num_week_day % 7; } echo '</tr>' . PHP_EOL; echo '</thead>' . PHP_EOL; $li = 0;
{ $num_day = strftime("%d", $t); $temp_month = strftime("%m", $t); $temp_month2 = strftime("%b", $t); $temp_year = strftime("%Y", $t); $jour_cycle = grr_sql_query1("SELECT Jours FROM ".TABLE_PREFIX."_calendrier_jours_cycle WHERE DAY='$t'"); $t += 86400; if (!isset($correct_heure_ete_hiver) or ($correct_heure_ete_hiver == 1)) { // Correction dans le cas d'un changement d'heure if (heure_ete_hiver("hiver",$temp_year,0) == mktime(0,0,0,$temp_month,$num_day,$temp_year)) $t +=3600; if (date("H",$t) == "01") $t -=3600; } if ($display_day[$num_week_day] == 1) {// on n'affiche pas tous les jours de la semaine echo "<th style=\"width:10%;\">" . day_name(($weekcol + $weekstarts)%7) . " ".$num_day. " ".$temp_month2; if (getSettingValue("jours_cycles_actif") == "Oui" and intval($jour_cycle)>-1) if (intval($jour_cycle)>0) echo "<br />".get_vocab("rep_type_6")." ".$jour_cycle; else echo "<br />".$jour_cycle; echo "</th>\n"; } $num_week_day++;// Pour le calcul des jours à afficher $num_week_day = $num_week_day % 7;// Pour le calcul des jours à afficher } echo "</tr>"; // Fin Affichage de la première ligne contenant les jours // Affichage de la deuxième ligne contenant un lien "journée" if ($_GET['pview'] != 1) {
function create_display_table($heading, $contents) { $heading_html = tag('tr', attrs('class="ui-widget-header"')); $heading_html->add(tag('th', __p('Week', 'W'))); for ($i = 0; $i < 7; $i++) { $d = ($i + day_of_week_start()) % 7; $heading_html->add(tag('th', day_name($d))); } return tag('div', tag("div", attributes('id="phpc-summary-view"'), tag("div", attributes('id="phpc-summary-head"'), tag("div", attributes('id="phpc-summary-title"'), ''), tag("div", attributes('id="phpc-summary-author"'), ''), tag("div", attributes('id="phpc-summary-category"'), ''), tag("div", attributes('id="phpc-summary-time"'), '')), tag("div", attributes('id="phpc-summary-body"'), '')), tag('div', attrs('class="phpc-sub-title phpc-month-title ui-widget-content"'), $heading), tag('table', attrs('class="phpc-month-view"'), tag('colgroup', tag('col', attributes('class="phpc-week"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"'))), tag('thead', $heading_html), tag('tbody', $contents))); }
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; }
/** * Gather all fields values for an entry. Used for emails to get previous * entry state. * * @param int $id entry id to get data * @param int $series 1 if this is a serie or 0 * @return bool TRUE or PEAR error object if fails */ function getPreviousEntryData($id, $series) { global $tbl_area, $tbl_entry, $tbl_repeat, $tbl_room, $enable_periods; // $sql = "\n SELECT e.name,\n e.description,\n e.create_by,\n r.room_name,\n a.area_name,\n e.type,\n e.room_id,\n e.repeat_id,\n e.timestamp,\n (e.end_time - e.start_time) AS tbl_e_duration,\n e.start_time AS tbl_e_start_time,\n e.end_time AS tbl_e_end_time,\n a.area_admin_email,\n r.room_admin_email"; // Here we could just use $tbl_repeat.start_time, and not use alias, // as the last column will take precedence using mysql_fetch_array, // but for portability purpose I will not use it. if (1 == $series) { $sql .= ", re.rep_type, re.rep_opt, re.rep_num_weeks,\n (re.end_time - re.start_time) AS tbl_r_duration,\n re.start_time AS tbl_r_start_time,\n re.end_time AS tbl_r_end_time,\n re.end_date AS tbl_r_end_date"; } $sql .= "\n FROM {$tbl_entry} e, {$tbl_room} r, {$tbl_area} a "; 1 == $series ? $sql .= ', ' . $tbl_repeat . ' re ' : ''; $sql .= "\n WHERE e.room_id = r.id\n AND r.area_id = a.id\n AND e.id={$id}"; 1 == $series ? $sql .= " AND e.repeat_id = re.id" : ''; // $res = sql_query($sql); !$res ? fatal_error(0, sql_error()) : ''; sql_count($res) < 1 ? fatal_error(0, get_string('invalid_entry_id', 'block_mrbs')) : ''; $row = sql_row_keyed($res, 0); sql_free($res); // Store all needed values in $mail_previous array to pass to // notifyAdminOnDelete function (shorter than individual variables -:) ) $mail_previous['namebooker'] = $row['name']; $mail_previous['description'] = $row['description']; $mail_previous['createdby'] = $row['create_by']; $mail_previous['room_name'] = $row['room_name']; $mail_previous['area_name'] = $row['area_name']; $mail_previous['type'] = $row['type']; $mail_previous['room_id'] = $row['room_id']; $mail_previous['repeat_id'] = $row['repeat_id']; $mail_previous['updated'] = getMailTimeDateString($row[8]); $mail_previous['area_admin_email'] = $row['area_admin_email']; $mail_previous['room_admin_email'] = $row['room_admin_email']; // If we use periods if ($enable_periods) { // If we delete a serie, start_time and end_time must // come from $tbl_repeat, not $tbl_entry. // // This is not a serie if (1 != $series) { list($mail_previous['start_period'], $mail_previous['start_date']) = getMailPeriodDateString($row['tbl_e_start_time']); list($mail_previous['end_period'], $mail_previous['end_date']) = getMailPeriodDateString($row['tbl_e_end_time'], -1); // need to make DST correct in opposite direction to entry creation // so that user see what he expects to see $mail_previous['duration'] = $row['tbl_e_duration'] - cross_dst($row['tbl_e_start_time'], $row['tbl_e_end_time']); } else { list($mail_previous['start_period'], $mail_previous['start_date']) = getMailPeriodDateString($row['tbl_r_start_time']); list($mail_previous['end_period'], $mail_previous['end_date']) = getMailPeriodDateString($row['tbl_r_end_time'], 0); // use getMailTimeDateString as all I want is the date $mail_previous['rep_end_date'] = getMailTimeDateString($row['tbl_r_end_date'], FALSE); // need to make DST correct in opposite direction to entry creation // so that user see what he expects to see $mail_previous['duration'] = $row['tbl_r_duration'] - cross_dst($row['tbl_r_start_time'], $row['tbl_r_end_time']); $mail_previous['rep_opt'] = ""; switch ($row['rep_type']) { case 2: case 6: $rep_day[0] = $row['rep_opt'][0] != "0"; $rep_day[1] = $row['rep_opt'][1] != "0"; $rep_day[2] = $row['rep_opt'][2] != "0"; $rep_day[3] = $row['rep_opt'][3] != "0"; $rep_day[4] = $row['rep_opt'][4] != "0"; $rep_day[5] = $row['rep_opt'][5] != "0"; $rep_day[6] = $row['rep_opt'][6] != "0"; if ($row['rep_type'] == 6) { $mail_previous['rep_num_weeks'] = $row['rep_num_weeks']; } else { $mail_previous['rep_num_weeks'] = ""; } break; default: $rep_day = array(0, 0, 0, 0, 0, 0, 0); } for ($i = 0; $i < 7; $i++) { $wday = ($i + $weekstarts) % 7; if ($rep_day[$wday]) { $mail_previous['rep_opt'] .= day_name($wday) . " "; } } $mail_previous['rep_num_weeks'] = $row['rep_num_weeks']; } toPeriodString($mail_previous['start_period'], $mail_previous['duration'], $mail_previous['dur_units']); } else { // This is not a serie if (1 != $series) { $mail_previous['start_date'] = getMailTimeDateString($row['tbl_e_start_time']); $mail_previous['end_date'] = getMailTimeDateString($row['tbl_e_end_time']); // need to make DST correct in opposite direction to entry creation // so that user see what he expects to see $mail_previous['duration'] = $row['tbl_e_duration'] - cross_dst($row['tbl_e_start_time'], $row['tbl_e_end_time']); } else { $mail_previous['start_date'] = getMailTimeDateString($row['tbl_r_start_time']); $mail_previous['end_date'] = getMailTimeDateString($row['tbl_r_end_time']); // use getMailTimeDateString as all I want is the date $mail_previous['rep_end_date'] = getMailTimeDateString($row['tbl_r_end_date'], FALSE); // need to make DST correct in opposite direction to entry creation // so that user see what he expects to see $mail_previous['duration'] = $row['tbl_r_duration'] - cross_dst($row['tbl_r_start_time'], $row['tbl_r_end_time']); $mail_previous['rep_opt'] = ""; switch ($row['rep_type']) { case 2: case 6: $rep_day[0] = $row['rep_opt'][0] != "0"; $rep_day[1] = $row['rep_opt'][1] != "0"; $rep_day[2] = $row['rep_opt'][2] != "0"; $rep_day[3] = $row['rep_opt'][3] != "0"; $rep_day[4] = $row['rep_opt'][4] != "0"; $rep_day[5] = $row['rep_opt'][5] != "0"; $rep_day[6] = $row['rep_opt'][6] != "0"; if ($row['rep_type'] == 6) { $mail_previous['rep_num_weeks'] = $row['rep_num_weeks']; } else { $mail_previous['rep_num_weeks'] = ""; } break; default: $rep_day = array(0, 0, 0, 0, 0, 0, 0); } for ($i = 0; $i < 7; $i++) { $wday = ($i + $weekstarts) % 7; if ($rep_day[$wday]) { $mail_previous['rep_opt'] .= day_name($wday) . " "; } } $mail_previous['rep_num_weeks'] = $row['rep_num_weeks']; } toTimeString($mail_previous['duration'], $mail_previous['dur_units']); } 1 == $series ? $mail_previous['rep_type'] = $row['rep_type'] : ($mail_previous['rep_type'] = 0); // return entry previous data as an array return $mail_previous; }
echo "</pre>\n"; } // Include the active cell content management routines. // Must be included before the beginnning of the main table. if ($javascript_cursor) { echo "<script type=\"text/javascript\" src=\"xbLib.js\"></script>\n"; echo "<script type=\"text/javascript\">\n"; echo "//<![CDATA[\n"; echo "InitActiveCell(" . ($show_plus_link ? "true" : "false") . ", " . "false, " . "false, " . "\"{$highlight_method}\", " . "\"" . get_vocab("click_to_reserve") . "\"" . ");\n"; echo "//]]>\n"; echo "</script>\n"; } echo "<table class=\"dwm_main\" id=\"month_main\">\n<tr>"; // Weekday name header row: for ($weekcol = 0; $weekcol < 7; $weekcol++) { echo "<th>" . day_name(($weekcol + $weekstarts) % 7) . "</th>"; } echo "</tr><tr>\n"; // Skip days in week before start of month: for ($weekcol = 0; $weekcol < $weekday_start; $weekcol++) { echo "<td class=\"invalid\"><div class=\"cell_container\"> </div></td>\n"; } // Draw the days of the month: for ($cday = 1; $cday <= $days_in_month; $cday++) { if ($weekcol == 0) { echo "</tr><tr>\n"; } echo "<td class=\"valid\">\n"; echo "<div class=\"cell_container\">\n"; echo "<div class=\"cell_header\">\n"; // first put in the day of the month
" Data: " . $d[$i]["data"][$j] . "\n"; } } echo "</pre>\n"; } // Début du tableau affichant le planning echo "<table border=\"2\" width=\"100%\">\n"; // Début affichage première ligne (intitulé des jours) echo "<tr>"; for ($weekcol = 0; $weekcol < 7; $weekcol++) { $num_week_day = ($weekcol + $weekstarts)%7; if ($display_day[$num_week_day] == 1) // on n'affiche pas tous les jours de la semaine echo "<th style=\"width:14%;\">" . day_name($num_week_day) . "</th>\n"; } echo "</tr>\n"; // Fin affichage première ligne (intitulé des jours) // Début affichage des lignes affichant les réservations // On grise les cellules appartenant au mois précédent $weekcol = 0; if ($weekcol != $weekday_start) { echo "<tr>"; for ($weekcol = 0; $weekcol < $weekday_start; $weekcol++) { $num_week_day = ($weekcol + $weekstarts)%7; if ($display_day[$num_week_day] == 1) // on n'affiche pas tous les jours de la semaine
} } //Seulement si l'heure de fin est pares minuit, on continue le jour prochain. if ($row[1] <= $midnight_tonight) { break; } $day_num++; $t = $midnight = $midnight_tonight; } } } echo '<table class="table-bordered table-striped">', PHP_EOL, '<tr>', PHP_EOL; for ($weekcol = 0; $weekcol < 7; $weekcol++) { $num_week_day = ($weekcol + $weekstarts) % 7; if ($display_day[$num_week_day] == 1) { echo '<th style="width:14%;">', day_name(($weekcol + $weekstarts) % 7), '</th>', PHP_EOL; } } echo '</tr>', PHP_EOL; $weekcol = 0; if ($weekcol != $weekday_start) { echo '<tr>', PHP_EOL; for ($weekcol = 0; $weekcol < $weekday_start; $weekcol++) { $num_week_day = ($weekcol + $weekstarts) % 7; if ($display_day[$num_week_day] == 1) { echo '<td class="cell_month_o">', PHP_EOL, '</td>', PHP_EOL; } } } $ferie = getHolidays($year); for ($cday = 1; $cday <= $days_in_month; $cday++) {
/** * @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; }
/** * @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; }
$n = count($d[$i]["id"]); echo "Day $i has $n entries:\n"; for ($j = 0; $j < $n; $j++) echo " ID: " . $d[$i]["id"][$j] . " Data: " . $d[$i]["data"][$j] . "\n"; } } echo "</pre>\n"; } echo "<table border=\"2\" width=\"100%\">\n<tr>"; #Affichage des jours en entête for ($weekcol = 0; $weekcol < 7; $weekcol++) { $num_week_day = ($weekcol + $weekstarts)%7; if ($display_day[$num_week_day] == 1) // on n'affiche pas tous les jours de la semaine echo "<th style=\"width:14%;\">" . day_name(($weekcol + $weekstarts)%7) . "</th>"; } echo "</tr>\n"; #Ne pas tenir compte des jours avant le début du mois $weekcol = 0; if ($weekcol != $weekday_start) { echo "<tr>"; for ($weekcol = 0; $weekcol < $weekday_start; $weekcol++) { $num_week_day = ($weekcol + $weekstarts)%7; if ($display_day[$num_week_day] == 1) // on n'affiche pas tous les jours de la semaine echo "<td class=\"cell_month_o\"> </td>\n"; } } #Afficher le jour du mois for ($cday = 1; $cday <= $days_in_month; $cday++)
?> :</td> <td><?php echo get_vocab($repeat_key); ?> </td> </tr> <?php if ($rep_type != 0) { $opt = ""; if ($rep_type == 2 || $rep_type == 6) { // 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 ($rep_type == 6) { echo "<tr><td>" . get_vocab("rep_num_weeks") . " " . get_vocab("rep_for_nweekly") . ":</td><td>{$rep_num_weeks}</td></tr>\n"; } if ($opt) { echo "<tr><td>" . get_vocab("rep_rep_day") . ":</td><td>{$opt}</td></tr>\n"; } echo "<tr><td>" . get_vocab("rep_end_date") . ":</td><td>{$rep_end_date}</td></tr>\n"; } ?> </table> <?php
break; } $day_num++; $t = $midnight = $midnight_tonight; } } } // Début du tableau affichant le planning echo '<table class="table-bordered table-striped">', PHP_EOL; // Début affichage première ligne (intitulé des jours) echo '<tr>', PHP_EOL; for ($weekcol = 0; $weekcol < 7; $weekcol++) { $num_week_day = ($weekcol + $weekstarts) % 7; // on n'affiche pas tous les jours de la semaine if ($display_day[$num_week_day] == 1) { echo '<th style="width:14%;">', day_name($num_week_day), '</th>', PHP_EOL; } } echo '</tr>', PHP_EOL; // Fin affichage première ligne (intitulé des jours) // Début affichage des lignes affichant les réservations // On grise les cellules appartenant au mois précédent $weekcol = 0; if ($weekcol != $weekday_start) { echo '<tr>', PHP_EOL; for ($weekcol = 0; $weekcol < $weekday_start; $weekcol++) { $num_week_day = ($weekcol + $weekstarts) % 7; if ($display_day[$num_week_day] == 1) { echo '<td class="cell_month_o"></td>', PHP_EOL; } }
} echo ">" . utf8_strftime("%A", $tmp) . "</option>\n"; $k++; } echo "</select></td>\n"; echo "</tr>"; // Definition des jours de la semaine e afficher sur les plannings et calendriers echo "<tr>\n"; echo "<td>" . get_vocab("cocher_jours_a_afficher") . "</td>\n"; echo "<td>\n"; for ($i = 0; $i < 7; $i++) { echo "<label><input name=\"display_day[" . $i . "]\" type=\"checkbox\""; if (substr($row["display_days"], $i, 1) == 'y') { echo " checked=\"checked\""; } echo " />" . day_name($i) . "</label><br />\n"; } echo "</td>\n"; echo "</tr></table>"; echo "<h3>" . get_vocab("type_de_creneaux") . "</h3>"; echo "<table>"; //echo "<p style=\"text-align:left;\"><b>ATTENTION :</b> Les deux types de configuration des creneaux sont incompatibles entre eux : un changement du type de creneaux entraene donc, apres validation, un <b>effacement de toutes les reservations de ce domaine</b></p>."; echo "<tr><td colspan=\"2\"><label><input type=\"radio\" name=\"enable_periods\" value=\"n\" onclick=\"bascule()\" "; if ($row["enable_periods"] == 'n') { echo "checked=\"checked\""; } echo " />" . get_vocab("creneaux_de_reservation_temps") . "</label><br />"; echo "<label><input type=\"radio\" name=\"enable_periods\" value=\"y\" onclick=\"bascule()\" "; if ($row["enable_periods"] == 'y') { echo "checked=\"checked\""; }
else { $key = "rep_type_" . (isset($rep_type) ? $rep_type : "0"); echo "<tr><td class=CR><b>$lang[rep_type]</b></td><td class=CL>$lang[$key]</td></tr>\n"; if(isset($rep_type) && ($rep_type != 0)) { $opt = ""; if ($rep_type == 2) { # Display day names according to language and preferred weekday start. for ($i = 0; $i < 7; $i++) { $wday = ($i + $weekstarts) % 7; if ($rep_opt[$wday]) $opt .= day_name($wday) . " "; } } if($opt) echo "<tr><td class=CR><b>$lang[rep_rep_day]</b></td><td class=CL>$opt</td></tr>\n"; echo "<tr><td class=CR><b>$lang[rep_end_date]</b></td><td class=CL>$rep_end_date</td></tr>\n"; } } ?> <TR> <TD colspan=2 align=center> <SCRIPT LANGUAGE="JavaScript"> document.writeln ( '<INPUT TYPE="button" VALUE="<?echo $lang["save"]?>" ONCLICK="validate_and_submit()">' ); </SCRIPT>
?> </TD> </TR> <?php } else { $key = "rep_type_" . (isset($rep_type) ? $rep_type : "0"); echo "<tr><td class=\"CR\"><b>" . get_vocab("rep_type") . "</b></td><td class=\"CL\">" . get_vocab($key) . "</td></tr>\n"; if (isset($rep_type) && $rep_type != 0) { $opt = ""; if ($rep_type == 2) { # Display day names according to language and preferred weekday start. for ($i = 0; $i < 7; $i++) { $wday = ($i + $weekstarts) % 7; if ($rep_opt[$wday]) { $opt .= day_name($wday) . " "; } } } if ($opt) { echo "<tr><td class=\"CR\"><b>" . get_vocab("rep_rep_day") . "</b></td><td class=\"CL\">{$opt}</td></tr>\n"; } echo "<tr><td class=\"CR\"><b>" . get_vocab("rep_end_date") . "</b></td><td class=\"CL\">{$rep_end_date}</td></tr>\n"; } } /* We display the rep_num_weeks box only if: - this is a new entry ($id is not set) Xor - we are editing an existing repeating entry ($rep_type is set and $rep_type != 0 and $edit_type == "series" ) */
<tr> <td><b><? echo $lang["rep_type"] ?></b></td> <td><? echo $lang[$repeat_key] ?></td> </tr> <? if($rep_type != 0) { $opt = ""; if ($rep_type == 2) { # 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) echo "<tr><td><b>$lang[rep_rep_day]</b></td><td>$opt</td></tr>\n"; echo "<tr><td><b>$lang[rep_end_date]</b></td><td>$rep_end_date</td></tr>\n"; } ?> </table> <br> <p> <a href="edit_entry.php?id=<? echo $id ?>"><? echo $lang["editentry"] ?></a> <?