xref: /plugin/bez/ctl/task_form.php (revision 19440e21319165aa878257648b2a4f0ff41928f1)
1<?php
2//~ include_once DOKU_PLUGIN."bez/models/bezcache.php";
3
4$template['tid'] = isset($nparams['tid']) ? $nparams['tid'] : '-1';
5$template['action'] = isset($nparams['action']) ? $nparams['action'] : '-default';
6
7try {
8    if (isset($_POST['tasktype'])) {
9        $tasktype = $_POST['tasktype'];
10    } else {
11        $tasktype = $nparams['tasktype'];
12    }
13    $task = $this->model->tasks->create_object_program(
14                            array('tasktype' => $tasktype));
15
16    $template['auth_level'] = $task->get_level();
17    $template['user'] = $task->get_user();
18    $value['tasktype'] = $nparams['tasktype'];
19
20    if (count($_POST) > 0) {
21        //checkboxes
22        if (!isset($_POST['all_day_event'])) {
23            $_POST['all_day_event'] = '0';
24        }
25
26        $task->set_data($_POST);
27        //update tasktype for admins
28
29        $tid = $this->model->tasks->save($task);
30//            $title = 'Dodano zadanie';
31//            $exec = $task->executor;
32//            $subject = "[$conf[title]] $title: #z$tid";
33//            $to = $this->model->users->get_user_full_name($exec).' <'.$this->model->users->get_user_email($exec).'>';
34//            $body = "$uri?id=".$this->id('show_task', 'tid', $tid);
35//            $this->helper->mail($to, $subject, $body);
36
37            header("Location: ?id=bez:task:tid:$tid");
38    } else {
39        if (isset($nparams['duplicate'])) {
40            $tid = (int)$nparams['duplicate'];
41            $task = $this->model->tasks->get_one($tid);
42            $value = $task->get_assoc();
43        } else {
44            $value['all_day_event'] = '1';
45        }
46    }
47//        $template['task_button'] = $bezlang['add'];
48//        $template['task_action'] = $this->id('task_report', 'tasktype', $nparams['tasktype']);
49    $template['users'] = $this->model->users->get_all();
50    $template['tasktypes'] = $this->model->tasktypes->get_all();
51
52} catch (ValidationException $e) {
53	$errors = $e->get_errors();
54	$value = $_POST;
55} catch (DBException $e) {
56    echo nl2br($e);
57//	header("Location: ?id=bez:tasks");
58}
59
60
61
62//$template['user'] = $task->get_user();
63//$template['user_name'] = $this->model->users->get_user_full_name($template['user']);
64//
65//$template['users'] = $this->model->users->get_all();
66//$template['tasktypes'] = $this->model->tasktypes->get_all();
67//$template['tasktype_name'] = $this->model->tasktypes->get_one($nparams['tasktype'])->type;
68