Example #1
0
$PAGE->requires->js('/local/teammanager/js/select2.full.js');
$PAGE->requires->css('/local/teammanager/css/select2.min.css');
$PAGE->requires->js('/blocks/learning_plan/js/jquery.dataTables.js');
$PAGE->requires->js('/blocks/learning_plan/js/custom.js');
$PAGE->requires->css('/blocks/learning_plan/css/jquery.dataTables.css');
$PAGE->requires->js('/local/costcenter/js/costcenter.js');
$PAGE->requires->js('/local/costcenter/js/delete_confirm.js');
$output = $PAGE->get_renderer('local_costcenter');

echo $output->header();
//echo "<h2 class='tmhead2' id='local_costcenter_heading'>".get_string('pluginname', 'local_costcenter')."</h2>";

//$costcenter->print_costcentertabs('view', $id = NULL);
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);

$editform = new costcenter_form(null, array('id' => $id, 'tool' => $costcenter_instance, 'editoroptions' => $editoroptions));

$editform->set_data($costcenter_instance);

$costcenterlist = $DB->get_records('local_costcenter');
if ((empty($costcenterlist)and has_capability('local/costcenter:manage', $systemcontext)) || ($editform->is_submitted() && !$editform->is_validated())) {
    $collapse = false;
//    print_error('costcenternotcreated', 'local_costcenter', $CFG->wwwroot . '/local/costcenter/costcenter.php');
}
//if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding and has_capability('local/costcenter:manage', $systemcontext)) {
//    echo $output->box(get_string('allowframembedding', 'local_costcenter'));
//}
if ($editform->is_cancelled()) {
    redirect($PAGE->url);
} else if ($data = $editform->get_data()) {
    $data->description = $data->description['text'];
            array_push($users, $userid);
        }
    }
    $costcenter->add_users($users, $data->moveto);
}



$heading = ($id > 0) ? get_string('editcostcenter', 'local_costcenter') : get_string('createcostcenter', 'local_costcenter');
$PAGE->navbar->add(get_string('pluginname', 'local_costcenter'), new moodle_url('/local/costcenter/index.php', array('id' => $id)));

$PAGE->navbar->add($heading);
$PAGE->set_title($strheading);
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);

$editform = new costcenter_form(null, array('id' => $id, 'tool' => $costcenter_instance, 'editoroptions' => $editoroptions));


if ($id > 0) {
    $costcenter_instance->description = array('text' => $costcenter_instance->description, 'format' => FORMAT_HTML);
}
$editform->set_data($costcenter_instance);

if ($editform->is_cancelled()) {
    redirect($returnurl);
} else if ($data = $editform->get_data()) {
    $data->description = $data->description['text'];
    if ($data->id > 0) {
        $costcenter->costcenter_update_instance($data->id, $data);
    } else {
        $costcenter->costcenter_add_instance($data);