Ejemplo n.º 1
0
function get_booking($type, $campusid, $date, $multiply, $size, $finaldate, $days, $frequency)
{
    global $DB;
    $sqlfiltrocapacidad = '';
    if ($multiply == 1) {
        $fechas = days_calculator($date, $finaldate, $days, $frequency);
        $fechasArray = array();
        foreach ($fechas as $fecha) {
            $fechasArray[] = "'" . $fecha . "'";
        }
        $date = implode(",", $fechasArray);
        if ($size != '0') {
            $sizePieces = explode("-", $size);
            if ($sizePieces[1] == "+") {
                $sizePieces[1] = 1000;
            }
            // $sqlfiltrocapacidad = "AND rs.capacidad BETWEEN $sizePieces[0] AND $sizePieces[1]";
        }
    } else {
        $date = "'" . date('Y-m-d', $date) . "'";
    }
    $modulos = array();
    $sqldisponibilidad = "SELECT salaid, salanombre, moduloid, modulonombre, moduloinicio, modulofin,capacidad , MAX(ocupada) as ocupada FROM (\n\tSELECT rs.id AS salaid,\n\trs.nombre AS salanombre,\n\trs.capacidad as capacidad,\n\trm.id AS moduloid,\n\trm.nombre_modulo as modulonombre,\n\trm.hora_inicio as moduloinicio,\n\trm.hora_fin as modulofin,\n\trr.activa as status,\n\tCASE WHEN rr.id IS NULL THEN 0 ELSE 1 END AS ocupada\n\tFROM {reservasalas_salas} AS rs\n\tINNER JOIN {reservasalas_edificios} AS re ON (re.id = rs.edificios_id AND rs.tipo = {$type} AND re.id={$campusid})\n\tINNER JOIN {reservasalas_modulos} AS rm ON (rm.edificio_id = re.id AND rm.nombre_modulo not like '%B') \n\tLEFT JOIN {reservasalas_reservas} AS rr ON (rr.salas_id = rs.id AND rr.modulo = rm.id AND rr.fecha_reserva IN ({$date}) AND rr.activa=1)\n\tWHERE 1=1\n\t\n\tORDER BY rs.id, rm.nombre_modulo ASC) AS disp\n\tGROUP BY salaid, moduloid";
    // $sqlfiltrocapacidad (line 80)
    $data = $DB->get_recordset_sql($sqldisponibilidad);
    return $data;
}
Ejemplo n.º 2
0
 $nombresala = explode(",", $nombresala);
 $error = array();
 $values = array();
 if (!has_capability('local/reservasalas:advancesearch', context_system::instance())) {
     list($weekBookings, $todayBookings) = booking_availability($initialDate);
     if ($todayBookings == 2 || count($room) > 3 || $CFG->reservasDia - $todayBookings - count($room) + 1 < 0 && $CFG->reservasSemana - $weekBookings - count($room) + 1 < 0) {
         $validation = false;
     } else {
         $validation = true;
     }
 } else {
     $validation = true;
 }
 for ($i = 1; $i < count($room); $i++) {
     if ($multiply == 1 && has_capability('local/reservasalas:advancesearch', context_system::instance())) {
         $fechas = days_calculator($initialDate, $finaldate, $days, $frequency);
         foreach ($fechas as $fecha) {
             if (validation_booking($room[$i], $moduleid[$i], $fecha)) {
                 $time = time();
                 $data = array();
                 $data['fecha_reserva'] = $fecha[$i];
                 $data['modulo'] = $moduleid[$i];
                 $data['confirmado'] = 0;
                 $data['activa'] = 1;
                 $data['alumno_id'] = $USER->id;
                 $data['salas_id'] = $room[$i];
                 $data['fecha_creacion'] = $time;
                 $data['nombre_evento'] = $eventname;
                 $data['asistentes'] = $asistentes;
                 $DB->insert_record('reservasalas_reservas', $data);
                 $values[] = array('sala' => $room[$i], 'nombresala' => $nombresala[$i], 'modulo' => $moduleid[$i], 'nombremodulo' => $nombremodulo[$i], 'inicio' => $inicio[$i], 'termino' => $termino[$i], 'fecha' => $initialDate);