Beispiel #1
0
 function events()
 {
     checkPerm('view');
     require_once _base_ . '/lib/lib.navbar.php';
     require_once _base_ . '/lib/lib.table.php';
     require_once $GLOBALS['where_lms'] . '/lib/lib.reservation_perm.php';
     $roomperm = new ReservationRoomPermissions();
     $perm = 'view';
     $lang =& DoceboLanguage::createInstance('reservation');
     $order_by = importVar('order_by', false, 'c.name, e.title, e.date, e.deadLine');
     $mod_perm = checkPerm('mod', true);
     $id_course = $_SESSION['idCourse'];
     $out = $GLOBALS['page'];
     $out->setWorkingZone('content');
     $man_res = new Man_Reservation();
     $acl =& Docebo::user()->getAcl();
     $user_idst = getLogUserId();
     $events = array();
     $events = $man_res->viewEvents($id_course, $order_by);
     if ($events) {
         $cont_h = array(isset($_GET['order_by']) && $_GET['order_by'] == 'c.name, e.title' ? '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.title DESC">' . $lang->def('_TITLE') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.title">' . $lang->def('_TITLE') . '</a>', isset($_GET['order_by']) && $_GET['order_by'] == 'c.name, l.name' ? '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, l.name DESC">' . $lang->def('_LOCATION') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, l.name">' . $lang->def('_LOCATION') . '</a>', isset($_GET['order_by']) && $_GET['order_by'] == 'c.name, e.date' ? '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.date DESC">' . $lang->def('_DATE') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.date">' . $lang->def('_DATE') . '</a>', isset($_GET['order_by']) && $_GET['order_by'] == 'c.name, e.fromTime' ? '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.fromTime DESC">' . $lang->def('_FROM_TIME') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.fromTime">' . $lang->def('_FROM_TIME') . '</a>', isset($_GET['order_by']) && $_GET['order_by'] == 'c.name, e.toTime' ? '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.toTime DESC">' . $lang->def('_TO_TIME') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.toTime">' . $lang->def('_TO_TIME') . '</a>', $lang->def('_NUMBER_SUBSCRIBED'), $lang->def('_AVAILABLE_PLACES'), isset($_GET['order_by']) && $_GET['order_by'] == 'c.name, e.deadLine' ? '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.deadLine DESC">' . $lang->def('_DEADLINE') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=events&amp;order_by=c.name, e.deadLine">' . $lang->def('_DEADLINE') . '</a>', $lang->def('_REGISTRATION'));
         $type_h = array('', '', '', '', '', '', '', '', '');
         $tb = new Table(100000);
         $tb->setColsStyle($type_h);
         $tb->addHead($cont_h);
         $temp_cat = '';
         foreach ($events as $event) {
             $all_perm = $roomperm->getAllReservationPerm($event[EVENT_ID]);
             $can_view = isset($all_perm[$perm]) ? checkRoomPerm($all_perm[$perm], $user_idst) : TRUE;
             if ($can_view || $mod_perm) {
                 if ($temp_cat != $event[EVENT_CATEGORY_NAME]) {
                     if ($temp_cat != '') {
                         $out->add($tb->getTable());
                         $out->add('<br/>');
                     }
                     $temp_cat = $event[EVENT_CATEGORY_NAME];
                     $table_caption = $event[EVENT_CATEGORY_NAME];
                     $max_subscription = $man_res->getMaxSubscriptionForCategory($event[EVENT_ID_CATEGORY]);
                     if ($max_subscription) {
                         $table_caption .= ' : ' . $lang->def('_MAX_SUBSCRIPTION_FOR_CATEGORY') . ' : ' . $max_subscription;
                     }
                     $tb = new Table(100000, $table_caption);
                     $tb->setColsStyle($type_h);
                     $tb->addHead($cont_h);
                 }
                 $count = array();
                 $count[] = $event[EVENT_TITLE];
                 if ($event[EVENT_ID_LABORATORY]) {
                     $count[] = '<a href="index.php?modname=reservation&amp;op=info_location&amp;active_tab=events&amp;id_location=' . $event[EVENT_ID_LABORATORY] . (isset($_GET['order_by']) ? '&amp;order_by=' . $_GET['order_by'] : '') . '">' . $event[EVENT_LABORATORY_NAME] . '</a>';
                 } else {
                     $count[] = $event[EVENT_LABORATORY_NAME];
                 }
                 $count[] = Format::date($event[EVENT_DATE], 'date');
                 $count[] = $event[EVENT_FROM_TIME];
                 $count[] = $event[EVENT_TO_TIME];
                 $count[] = $event[EVENT_USER_SUBSCRIBED] . '/' . $event[EVENT_MAX_USER];
                 if ($event[EVENT_AVAILABLE_PLACES] > 0) {
                     $count[] = $event[EVENT_AVAILABLE_PLACES];
                 } else {
                     $count[] = '0';
                 }
                 $count[] = Format::date($event[EVENT_DEADLINE], 'date');
                 if ($man_res->controlUserSubscription(getLogUserId(), $event[EVENT_ID])) {
                     $count[] = '<a href="index.php?modname=reservation&amp;op=del_subscription&amp;id_event=' . $event[EVENT_ID] . '">' . $lang->def('_CANCEL_REGISTRATION') . '</a>';
                 } else {
                     if ($event[EVENT_AVAILABLE_PLACES] > 0) {
                         if ($man_res->controlMaxSubscriptionForCategory($event[EVENT_ID_CATEGORY], getLogUserId())) {
                             $count[] = '<a href="index.php?modname=reservation&amp;op=add_subscription&amp;id_event=' . $event[EVENT_ID] . '&amp;confirm=1&amp;ap=mod_profile&amp;from=2">' . $lang->def('_REGISTER') . '</a>';
                         } else {
                             if ($man_res->controlSwitchPossibility($event[EVENT_ID_COURSE], $event[EVENT_ID_CATEGORY], getLogUserId())) {
                                 $count[] = '<a href="index.php?modname=reservation&amp;op=switch_subscription&amp;id_event=' . $event[EVENT_ID] . '&amp;id_course=' . $id_course . '&amp;id_category=' . $event[EVENT_ID_CATEGORY] . '">' . $lang->def('_SWITCH_REGISTRATION') . '</a>';
                             } else {
                                 $count[] = $lang->def('_ROOM_FULL');
                             }
                         }
                     } else {
                         $count[] = $lang->def('_ROOM_FULL');
                     }
                 }
                 $tb->addBody($count);
             }
         }
         $out->add($tb->getTable() . '</div>');
     } else {
         $out->add($lang->def('_NO_RESERVATION_FOUND'), 'content');
     }
 }