function describe_period_span($starts, $ends) { list($start_period, $start_date) = period_date_string($starts); list(, $end_date) = period_date_string($ends, -1); $duration = $ends - $starts; toPeriodString($start_period, $duration, $dur_units); return $start_date . " - " . $duration . " " . $dur_units; }
} # If we have not been provided with starting time if (empty($start_hour) && $morningstarts < 10) { $start_hour = "0{$morningstarts}"; } if (empty($start_hour)) { $start_hour = "{$morningstarts}"; } if (empty($start_min)) { $start_min = "00"; } // Remove "Undefined variable" notice if (!isset($rep_num_weeks)) { $rep_num_weeks = ""; } $enable_periods ? toPeriodString($start_min, $duration, $dur_units) : toTimeString($duration, $dur_units); #now that we know all the data to fill the form with we start drawing it if (!getWritable($create_by, getUserName())) { showAccessDenied($day, $month, $year, $area); exit; } print_header($day, $month, $year, $area); ?> <SCRIPT LANGUAGE="JavaScript"> // do a little form verifying function validate_and_submit () { // null strings and spaces only strings not allowed if(/(^$)|(^\s+$)/.test(document.forms["main"].name.value)) {
function describe_period_span($starts, $ends) { global $enable_periods, $periods_name, $vocab, $duration; list($start_period, $start_date) = period_date_string($starts); list(, $end_date) = period_date_string($ends, -1); $duration = $ends - $starts; toPeriodString($start_period, $duration, $dur_units); if ($duration > 1) { list(, $start_date) = period_date_string($starts); list(, $end_date) = period_date_string($ends, -1); $temp = $start_date . " ==> " . $end_date; } else { $temp = $start_date . " - " . $duration . " " . $dur_units; } return $temp; }
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";*/ } } /* echo '</table>',PHP_EOL; echo '</td>',PHP_EOL,'</tr>',PHP_EOL,'</table>',PHP_EOL;*/ $tplArrayEditEntry['vocab']['cancel'] = get_vocab('cancel');
// on slot boundaries, but is left in for good measure). $am7 = mktime($morningstarts, $morningstarts_minutes, 0, $month, $day, $year, is_dst($month, $day, $year, $morningstarts)); $starttime = round_t_down($starttime, $resolution, $am7); $endtime = round_t_up($endtime, $resolution, $am7); // If they asked for 0 minutes, and even after the rounding the slot length is still // 0 minutes, push that up to 1 resolution unit. if ($endtime == $starttime) { $endtime += $resolution; } // Now get the duration, which will be needed for email notifications // (We do this before we adjust for DST so that the user sees what they expect to see) $duration = $endtime - $starttime; $date = getdate($starttime); if ($enable_periods) { $period = ($date['hours'] - 12) * 60 + $date['minutes']; toPeriodString($period, $duration, $dur_units, FALSE); } else { toTimeString($duration, $dur_units, FALSE); } // Adjust the endtime for DST $endtime += cross_dst($starttime, $endtime); if (isset($rep_type) && $rep_type != REP_NONE && isset($rep_end_month) && isset($rep_end_day) && isset($rep_end_year)) { // Get the repeat entry settings $end_date = $start_seconds + mktime(0, 0, 0, $rep_end_month, $rep_end_day, $rep_end_year); } else { $rep_type = REP_NONE; $end_date = 0; // to avoid an undefined variable notice } if (!isset($rep_day)) { $rep_day = array();
} } if ($rep_type == 6) { $nb = 1; //Affiche le jour cycle. $opt .= get_vocab('jour_cycle').' '.$jours_c; } if($opt) 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"; 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); 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"; } } // Fin du tableau de la colonne de droite echo "\n</table>\n"; // Fin de la colonne de droite et fin du tableau echo "</td></tr></table>\n"; ?> <div id="fixe"> <input type="button" value="<?php echo get_vocab("cancel")?>" onclick="window.location.href='<?php echo $page.".php?year=".$year."&month=".$month."&day=".$day."&area=".$area."&room=".$room; ?>'" />
$rep_opt = isset($row['rep_opt']) ? $row['rep_opt'] : NULL; $rep_num_weeks = isset($row['rep_num_weeks']) ? $row['rep_num_weeks'] : NULL; 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']); } // The optional last parameters below are set to FALSE because we don't want the units // translated - otherwise they will end up getting translated twice, resulting // in an undefined index error. $enable_periods ? toPeriodString($start_period, $duration, $dur_units, FALSE) : toTimeString($duration, $dur_units, FALSE); } // Now that we know the room, check that we have confirm rights for it if necessary if (($action == "accept" || $action == "reject") && !auth_book_admin($user, $room_id)) { showAccessDenied($day, $month, $year, $area, isset($room) ? $room : ""); exit; } // ACTION = "ACCEPT" if ($action == "accept") { if (!mrbsConfirmEntry($id, $series)) { $returl .= "&error=accept_failed"; } elseif ($need_to_send_mail) { $result = notifyAdminOnBooking(TRUE, $id, $series, $action); } } // ACTION = "MORE_INFO"
/** * 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; }