Exemple #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');
     }
 }
Exemple #2
0
    function viewEvent()
    {
        checkPerm('view');
        require_once _base_ . '/lib/lib.navbar.php';
        require_once _base_ . '/lib/lib.table.php';
        $lang =& DoceboLanguage::createInstance('reservation');
        $mod_perm = checkPerm('mod', true);
        $out = $GLOBALS['page'];
        $out->setWorkingZone('content');
        $man_res = new Man_Reservation();
        $acl =& Docebo::user()->getAcl();
        $user_idst = getLogUserId();
        $events = array();
        $events = $man_res->viewEvents();
        $out->add(getTitleArea($lang->def('_RESERVATION')) . '<div class="std_block">', 'content');
        $error = importVar('error', false, '');
        if ($error !== '') {
            switch ($error) {
                case 'del_event':
                    $out->add(getErrorUi($lang->def('_DEL_EVENT_ERROR')));
                    break;
            }
        }
        if (count($events)) {
            $tb = new Table(10, $lang->def('_EVENT_CAPTION'), $lang->def('_EVENT_CAPTION'));
            $tb->initNavBar('ini', 'button');
            $ini = $tb->getSelectedElement();
            $cont_h = array($lang->def('_TITLE'), $lang->def('_CATEGORY'), $lang->def('_DATE'), $lang->def('_FROM_TIME'), $lang->def('_TO_TIME'), $lang->def('_NUMBER_SUBSCRIBED'), $lang->def('_AVAILABLE_PLACES'), $lang->def('_DEADLINE'));
            $type_h = array('', '', '', '', '', '', '', '');
            if ($mod_perm) {
                $type_h = array('', '', '', '', '', '', '', '', 'image', 'image', 'image');
                //,'image');
                $cont_h = array($lang->def('_TITLE'), $lang->def('_CATEGORY'), $lang->def('_DATE'), $lang->def('_FROM_TIME'), $lang->def('_TO_TIME'), $lang->def('_NUMBER_SUBSCRIBED'), $lang->def('_AVAILABLE_PLACES'), $lang->def('_DEADLINE'), '<img src="' . getPathImage() . 'standard/moduser.png" title="' . $lang->def('_SET_ROOM_VIEW_PERM') . '" alt="' . $lang->def('_SET_ROOM_VIEW_PERM') . '" />', '<img src="' . getPathImage() . '/standard/edit.png" title="' . $lang->def('_MOD') . '" alt="' . $lang->def('_MOD') . '" />', '<img src="' . getPathImage() . '/standard/delete.png" title="' . $lang->def('_DEL') . '" alt="' . $lang->def('_DEL') . '" />');
            }
            $tb->setColsStyle($type_h);
            $tb->addHead($cont_h);
            if ($events) {
                foreach ($events as $event) {
                    $count = array();
                    $count[] = $event[EVENT_TITLE];
                    $count[] = $event[EVENT_CATEGORY_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];
                    $count[] = $event[EVENT_AVAILABLE_PLACES];
                    $count[] = Format::date($event[EVENT_DEADLINE], 'date');
                    if ($mod_perm) {
                        $count[] = '<a href="index.php?modname=reservation&amp;op=set_room_view_perm&amp;id_event=' . $event[EVENT_ID] . '"><img src="' . getPathImage() . 'standard/moduser.png" alt="' . $lang->def('_SET_ROOM_VIEW_PERM') . '" title="' . $lang->def('_SET_ROOM_VIEW_PERM') . '" /></a>';
                        //$count[] = '<a href="index.php?modname=reservation&amp;op=add_registration&amp;id_event='.$event[EVENT_ID].'&amp;id_course='.$event[EVENT_ID_COURSE].'"><img src="'.getPathImage().'/standard/add.png" title="'.$lang->def('_ADD_USER').'" alt="'.$lang->def('_ALT_ADD_USER').'" /></a>';
                        $count[] = '<a href="index.php?modname=reservation&amp;op=mod_event&amp;id_event=' . $event[EVENT_ID] . '"><img src="' . getPathImage() . '/standard/edit.png" title="' . $lang->def('_MOD') . '" alt="' . $lang->def('_MOD') . '" /></a>';
                        $count[] = '<a href="index.php?modname=reservation&amp;op=del_event&amp;id_event=' . $event[EVENT_ID] . '"><img src="' . getPathImage() . '/standard/delete.png" title="' . $lang->def('_DEL') . '" alt="' . $lang->def('_DEL') . '" /></a>';
                    }
                    $tb->addBody($count);
                }
                require_once _base_ . '/lib/lib.dialog.php';
                setupHrefDialogBox('a[href*=del_event]');
            }
            if ($mod_perm) {
                $tb->addActionAdd('<a href="index.php?modname=reservation&amp;op=add_event">
					<img src="' . getPathImage() . 'standard/add.png" title="' . $lang->def('_NEW_EVENT') . '" alt="' . $lang->def('_NEW_EVENT') . '" /> ' . $lang->def('_NEW_EVENT') . '</a>');
            }
            $out->add($tb->getTable() . $tb->getNavBar($ini, count($events)) . '</div>');
        } else {
            if ($mod_perm) {
                $out->add('<div class="events_action_top"><p><a href="index.php?modname=reservation&amp;op=add_event">' . $lang->def('_NEW_EVENT') . '</a></p></div>', 'content');
            }
            $out->add($lang->def('_NO_RESERVATION_FOUND'), 'content');
        }
        $out->add('</div>', 'content');
    }