xref: /plugin/bez/tpl/task_form.php (revision 6e6a7f3d0aaf4e171aa66fc7fe7d493ef8f0d677)
1<?php
2if ($nparams['bez'] === 'issue') {
3	$id = $this->id('issue', 'id', $template['issue']->id, 'action', $template['action'], 'tid', $template['tid'], 'kid', $template['kid']);
4} elseif ($nparams['bez'] === 'task_form') {
5	$id = $this->id('task_form', 'action', $template['action'], 'tid', $template['tid']);
6} else {
7	$id = $this->id('task', 'action', $template['action'], 'tid', $template['tid']);
8}
9?>
10<a name="z_"></a>
11<form 	class="bez_form bez_task_form"
12		action="?id=<?php echo $id ?>" method="POST">
13		<input type="hidden" name="id" value="<?php echo $id ?>">
14
15		<fieldset class="bds_form">
16			<?php if ($template['tid'] !== '-1'): ?>
17				<div class="row">
18				<label for="id"><?php echo $bezlang['id'] ?>:</label>
19				<span><strong>#z<?php echo $template['task']->id ?></strong></span>
20				</div>
21
22				<?php if (isset($template['issue']) &&
23                    $template['task']->acl_of('cause') >= BEZ_PERMISSION_CHANGE): ?>
24				<div class="row">
25					<label for="cause"><?php echo ucfirst($bezlang['cause']) ?>:</label>
26					<span>
27						<select name="cause" id="cause">
28							<option <?php if ($value['cause'] == '') echo 'selected' ?>
29								value="">--- <?php echo $bezlang['correction'] ?> ---</option>
30
31							<?php foreach ($template['causes'] as $cause): ?>
32								<option <?php if ($value['cause'] === $cause->id) echo 'selected' ?>
33								 value="<?php echo $cause->id ?>">#p<?php echo $cause->id ?></option>
34							<?php endforeach ?>
35						</select>
36					</span>
37				</div>
38				<?php endif ?>
39			<?php endif ?>
40			<div class="row">
41			<label for="executor"><?php echo $bezlang['executor'] ?>:</label>
42			<span>
43			<?php if ($template['task']->acl_of('executor') >= BEZ_PERMISSION_CHANGE): ?>
44				<select name="executor" id="executor" data-validation="required">
45					<option value="">--- <?php echo $bezlang['select'] ?>---</option>
46				<?php foreach ($template['users'] as $nick => $name): ?>
47					<option <?php if ($value['executor'] === $nick) echo 'selected' ?>
48					 value="<?php echo $nick ?>"><?php echo $name ?></option>
49				<?php endforeach ?>
50				</select>
51			<?php else: ?>
52				<input type="hidden" name="executor" value="<?php echo $value['executor'] ?>">
53				<strong>
54				<?php echo $this->model->users->get_user_full_name($value['executor']) ?>
55				</strong>
56			<?php endif ?>
57
58
59			</span>
60			</div>
61
62			<div class="row">
63				<label for="task"><?php echo $bezlang['description'] ?>:</label>
64				<span>
65                    <?php if ($template['task']->acl_of('plan_date') >= BEZ_PERMISSION_CHANGE): ?>
66                        <div class="bez_toolbar"></div>
67                    <?php endif ?>
68					<textarea name="task" id="task" data-validation="required" <?php if ($template['task']->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>><?php echo $value['task'] ?></textarea>
69				</span>
70			</div>
71
72			<div class="row task_plan_field">
73				<label for="plan_date"><?php echo $bezlang['plan_date'] ?>:</label>
74				<span>
75                    <input name="plan_date" style="width:90px;" data-validation="required,date" value="<?php echo $value['plan_date'] ?>"
76                    <?php if ($template['task']->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>
77                    />
78                    <div style="display:inline" id="task_datapair">
79                        <?php echo $bezlang['from_hour'] ?>
80                        <input name="start_time" style="width:60px;" class="time start" value="<?php echo $value['start_time'] ?>"
81                        data-validation="required,custom"
82                        data-validation-regexp="^(\d{1,2}):(\d{1,2})$"
83                        data-validation-depends-on="all_day_event"
84                        <?php if ($template['task']->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>
85                        />
86                        <?php echo $bezlang['to_hour'] ?>
87                        <input name="finish_time" style="width:60px;" class="time end" value="<?php echo $value['finish_time'] ?>"
88                        data-validation="required,custom"
89                        data-validation-regexp="^(\d{1,2}):(\d{1,2})$"
90                        data-validation-depends-on="all_day_event"
91                        <?php if ($template['task']->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>
92                        />
93                    </div>
94				</span>
95			</div>
96
97			<div class="row">
98				<label></label>
99				<span>
100					<label>
101                        <?php if ($template['task']->acl_of('all_day_event') >= BEZ_PERMISSION_CHANGE): ?>
102                        <input type="checkbox" name="all_day_event" value="1"
103                            <?php if (!isset($value['all_day_event']) ||
104                                        $value['all_day_event'] === '1'): ?>
105                                checked
106                            <?php endif ?> />
107                        <?php else: ?>
108                             <input type="checkbox" disabled
109                            <?php if ($template['task']->all_day_event === '1'): ?>
110                                checked
111                            <?php endif ?> />
112                        <?php endif ?> <?php echo $bezlang['all_day_event'] ?>
113                    </label>
114
115                </span>
116			</div>
117
118			<div class="row">
119			<label for="tasktype"><?php echo $bezlang['task_type'] ?>:</label>
120			<span>
121                <select id="tasktype" name="tasktype" <?php if ($template['task']->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>>
122                    <?php if (isset($template['issue'])): ?>
123                    <option <?php if ($value['tasktype'] == '') echo 'selected' ?> value=""><?php echo $bezlang['tasks_no_type'] ?></option>
124                    <?php endif; ?>
125
126                    <?php foreach ($template['tasktypes'] as $tasktype): ?>
127                        <option <?php if ($value['tasktype'] == $tasktype->id) echo 'selected' ?> value="<?php echo $tasktype->id ?>"><?php echo $tasktype->type ?></option>
128                    <?php endforeach ?>
129                </select>
130			</span>
131			</div>
132
133			<div class="row">
134				<label for="cost"><?php echo $bezlang['cost'] ?>:</label>
135				<span><input 	type="number" name="cost" id="cost"
136								min="0" step="0.01"
137                                value="<?php echo $value['cost'] ?>"
138                                <?php if ($template['task']->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>></span>
139			</div>
140			<?php if ($template['tid'] !== '-1'): ?>
141				<div class="row">
142				<label for="task_state"><?php echo $bezlang['task_state'] ?>:</label>
143				<span>
144					<strong><?php echo $template['task']->state_string ?></strong>
145				</span>
146				</div>
147
148				<?php if (  $template['task']->state === '1' ||
149                            $template['task']->state === '2'): ?>
150					<div class="row">
151						<label for="reason">
152							<?php if ($template['task']->state === '1'): ?>
153								<?php echo $bezlang['evaluation'] ?>:
154							<?php elseif ($template['task']->state === '2'): ?>
155								<?php echo $bezlang['reason'] ?>:
156							<?php endif ?>
157						</label>
158						<span>
159                            <?php if ($template['task']->acl_of('reason') >= BEZ_PERMISSION_CHANGE): ?>
160                                <div class="bez_toolbar"></div>
161                            <?php endif ?>
162                            <textarea name="reason" id="reason" <?php if ($template['task']->acl_of('reason') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>><?php echo $value['reason'] ?></textarea>
163                        </span>
164					</div>
165				<?php endif ?>
166
167			<?php endif ?>
168			<div class="row">
169				<label></label>
170				<span style="padding-top:10px;">
171					<input type="submit" value="<?php echo $template['tid'] === '-1' ? $bezlang['add'] : $bezlang['correct'] ?>">
172					<a href="?id=<?php
173				if ($nparams['bez'] === 'issue') {
174					echo $this->id('issue', 'id', $template['issue']->id);
175				} else if ($nparams['bez'] === 'task' && $template['task']->id != '') {
176					echo $this->id('task', 'tid', $template['task']->id);
177				} else if ($template['tasktype'] != '') {
178                    echo $this->id('tasks', 'tasktype', $template['tasktype']);
179                } else {
180                    echo $this->id('tasks');
181                }
182				?><?php if ($template['tid'] !== '-1') echo '#z'.$template['tid'] ?>"
183				class="bez_delete_button bez_link_button">
184					<?php echo $bezlang['cancel'] ?>
185				</a>
186			</span>
187        </div>
188    </fieldset>
189</form>
190