Ejemplo n.º 1
0
 function pastEvents()
 {
     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');
     $mod_perm = checkPerm('mod', true);
     $id_course = $_SESSION['idCourse'];
     $order_by = importVar('order_by', false, 'c.name, e.title, e.date, e.deadLine');
     $out = $GLOBALS['page'];
     $out->setWorkingZone('content');
     $man_res = new Man_Reservation();
     $acl =& Docebo::user()->getAcl();
     $user_idst = getLogUserId();
     $events = array();
     $events = $man_res->viewPastEvents($id_course, getLogUserId(), $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=past_events&amp;order_by=c.name, e.title DESC">' . $lang->def('_TITLE') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=past_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=pastevents&amp;order_by=c.name, l.name DESC">' . $lang->def('_LOCATION') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=past_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=past_events&amp;order_by=c.name, e.date DESC">' . $lang->def('_DATE') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=past_events&amp;order_by=c.name, e.date">' . $lang->def('_DATE') . '</a>', $lang->def('_NUMBER_SUBSCRIBED'), isset($_GET['order_by']) && $_GET['order_by'] == 'c.name, e.deadLine' ? '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=past_events&amp;order_by=c.name, e.deadLine DESC">' . $lang->def('_DEADLINE') . '</a>' : '<a href="index.php?modname=reservation&op=reservation&amp;active_tab=past_events&amp;order_by=c.name, e.deadLine">' . $lang->def('_DEADLINE') . '</a>');
         $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=past_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_USER_SUBSCRIBED] . '/' . $event[EVENT_MAX_USER];
                 $count[] = Format::date($event[EVENT_DEADLINE], 'date');
                 $tb->addBody($count);
             }
         }
         $out->add($tb->getTable() . '</div>');
     } else {
         $out->add($lang->def('_NO_RESERVATION_FOUND'), 'content');
     }
 }