$cats = Rsys::get_category(); foreach ($cats as $cat) { $catOptions[$cat['id']] = $cat['name']; } $form->addElement('select', 'category', get_lang('ResourceType'), $catOptions); $form->add_textfield('name', get_lang('ResourceName'), true, array('maxlength' => '128')); $form->addElement('textarea', 'description', get_lang('Description'), array('rows' => '3', 'cols' => '40')); $form->addRule('category', get_lang('ThisFieldIsRequired'), 'required'); // TODO: get list of courses (to link it to the item) //$form->addElement('select', 'course_code', get_lang('ItemCourse'),array(''=>'','value'=>'tag')); //$form->addRule('course', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('style_submit_button', 'submit', get_lang('AddNewResource'), 'class="add"'); if ($form->validate()) { $values = $form->exportValues(); if (Rsys::add_item($values['name'], $values['description'], $values['category'], $values['course_code'])) { Display::display_normal_message(Rsys::get_return_msg(get_lang('ResourceAdded'), "m_item.php?action=m_rights&item_id=" . Rsys::get_item_id($values['name']), get_lang('MItemRight') . ' ' . $values['name']), false); } else { Display::display_normal_message(Rsys::get_return_msg(get_lang('ResourceExist'), "m_item.php?action=add", get_lang('AddNewResource')), false); } } else { $form->display(); } break; case 'edit': $item = Rsys::get_item($_GET['id']); $cats = Rsys::get_category(); foreach ($cats as $cat) { $catOptions[$cat['id']] = $cat['name']; } $interbreadcrumb[] = array("url" => "mysubscriptions.php", "name" => get_lang('Booking')); $interbreadcrumb[] = array("url" => "m_item.php", "name" => get_lang('ManageResources'));