Esempio n. 1
0
 function addCategoy()
 {
     checkPerm('view');
     require_once _base_ . '/lib/lib.form.php';
     $lang =& DoceboLanguage::createInstance('reservation');
     $id_course = importVar('id_course', true, 0);
     $out = $GLOBALS['page'];
     $out->setWorkingZone('content');
     $man_res = new Man_Reservation();
     if (isset($_GET['confirm'])) {
         $confirm = importVar('confirm', true, 0);
         $name = importVar('name', false, '');
         $max_subscription = importVar('max_subscription', true, 0);
         if ($name == '') {
             Util::jump_to('index.php?modname=reservation&op=add_category&error=name&id_course=' . $id_course . '&name=' . $name . '&max_subscription=' . $max_subscription);
         }
         if ($confirm) {
             $result = $man_res->addCategory($name, $max_subscription, $id_course);
         }
         if ($result) {
             Util::jump_to('index.php?modname=reservation&op=view_category');
         }
         Util::jump_to('index.php?modname=reservation&op=add_category&error=category&id_course=' . $id_course . '&name=' . $name . '&max_subscription=' . $max_subscription);
     }
     $out->add(getTitleArea($lang->def('_NEW_CATEGORY'), '', $lang->def('_NEW_CATEGORY')) . '<div class="std_block">');
     $error = importVar('error', false, '');
     if ($error !== '') {
         switch ($error) {
             case 'name':
                 $out->add(getErrorUi($lang->def('_WRONG_NAME_CATEGORY')));
                 break;
             case 'category':
                 $out->add(getErrorUi($lang->def('_WRONG_INSERT_CATEGORY')));
                 break;
         }
     }
     $out->add(Form::openForm('form_event', 'index.php?modname=reservation&amp;op=add_category&amp;confirm=1') . Form::openElementSpace() . Form::getTextfield($lang->def('_NAME'), 'name', 'name', 255, isset($_GET['name']) ? $_GET['name'] : '') . Form::getTextfield($lang->def('_CATEGORY_MAX_SUBSCRIPTION'), 'max_subscription', 'max_subscription', 255, isset($_GET['max_subscription']) ? $_GET['max_subscription'] : '0') . Form::getHidden('id_course', 'id_course', $id_course) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('send_category', 'send_category', $lang->def('_NEW_CATEGORY')) . Form::getButton('undo_cat', 'undo_cat', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm());
     $out->add('</div>', 'content');
 }