Exemplo n.º 1
0
function modBooking()
{
    require_once $GLOBALS['where_scs'] . '/lib/lib.booking.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    YuiLib::load(array('selector' => 'selector-beta-min.js'));
    $lang =& DoceboLanguage::createInstance('conference', 'lms');
    $room_id = Get::req('id', DOTY_INT, 0);
    $booking = new RoomBooking();
    $acl_man =& Docebo::user()->getAclManager();
    $user_booked = $booking->getRoomSubscriptions($room_id);
    if (isset($_POST['confirm'])) {
        foreach ($user_booked as $user) {
            $booking->setApproved($user['idUser'], $room_id, isset($_POST['user_' . $user['idUser']]) ? 1 : 0);
            Util::jump_to('index.php?modname=conference&op=list');
        }
    } else {
        cout(getTitleArea($lang->def('_MOD_BOOKING_TITLE')) . '<div class="std_block">');
        $conference = new Conference_Manager();
        $tb = new Table(0, $lang->def('_USER_BOOKED'), $lang->def('_USER_BOOKED'));
        $cont_h = array($lang->def('_FULLNAME'), $lang->def('_BOOKING_DATE'), '');
        $type_h = array('', 'align_center', 'align_center');
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        $user_selected = 0;
        $max_user_selectable = $conference->getRoomMaxParticipants($room_id);
        $array_unchecked = array();
        cout(Form::openForm('user_booking_form', 'index.php?modname=conference&amp;op=modbooking&amp;id=' . $room_id));
        foreach ($user_booked as $user) {
            $user_info = $acl_man->getUser($user['idUser'], false);
            $cont = array();
            if ($user_info[ACL_INFO_FIRSTNAME] !== '' && $user_info[ACL_INFO_LASTNAME]) {
                $cont[] = $user_info[ACL_INFO_FIRSTNAME] . ' ' . $user_info[ACL_INFO_LASTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
            } elseif ($user_info[ACL_INFO_FIRSTNAME] !== '') {
                $cont[] = $user_info[ACL_INFO_FIRSTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
            } elseif ($user_info[ACL_INFO_LASTNAME] !== '') {
                $cont[] = $user_info[ACL_INFO_LASTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
            } else {
                $cont[] = $acl_man->relativeId($user_info[ACL_INFO_USERID]);
            }
            $cont[] = Format::date($user['date'], 'datetime');
            $cont[] = '<div class="form_line_l"><input class="check" type="checkbox" id="user_' . $user['idUser'] . '" name="user_' . $user['idUser'] . '" value="1" ' . ($user['valid'] ? 'checked="checked"' : '') . '/></div>';
            if ($user['valid']) {
                $user_selected++;
            } else {
                $array_unchecked[] = 'user_' . $user['idUser'];
            }
            $tb->addBody($cont);
        }
        reset($user_booked);
        addJs($GLOBALS['where_lms_relative'] . '/modules/conference/', 'conference.js');
        cout('<script>' . "\n" . 'var num_checked = ' . $user_selected . ';' . "\n" . 'var max_checked =' . $max_user_selectable . ';' . "\n");
        cout('unchecked = new Array(');
        $first = true;
        foreach ($array_unchecked as $unchecked) {
            if ($first) {
                cout('"' . $unchecked . '"');
                $first = false;
            } else {
                cout(',"' . $unchecked . '"');
            }
        }
        cout(');' . "\n");
        cout('</script>' . "\n" . $tb->getTable() . Form::openButtonSpace() . Form::getButton('confirm', 'confirm', $lang->def('_CONFIRM')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm());
        foreach ($user_booked as $user) {
            cout('<script>YAHOO.util.Event.addListener("user_' . $user['idUser'] . '", "click", onClick);</script>');
        }
        cout('<script>controlChecked();</script>');
        cout('</div>');
    }
}