edit.html.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <?php
  2. /**
  3. * The edit ui file of todo module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Zemei Wang<wangzemei@easycorp.ltd>
  8. * @package todo
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. jsVar('moduleList', $config->todo->moduleList);
  13. jsVar('objectsMethod', $config->todo->getUserObjectsMethod);
  14. jsVar('defaultType', $todo->type);
  15. jsVar('objectID', $todo->objectID);
  16. jsVar('nameBoxLabel', array('custom' => $lang->todo->name, 'objectID' => $lang->todo->objectID));
  17. jsVar('vision', $config->vision);
  18. jsVar('noOptions', $lang->todo->noOptions);
  19. jsVar('chosenType', $lang->todo->typeList);
  20. jsVar('userID', $app->user->id);
  21. jsVar('userAccount', $app->user->account);
  22. jsVar('todoAccount', $todo->account);
  23. if($todo->cycle && $todo->config)
  24. {
  25. $todo->config = json_decode($todo->config);
  26. $type = '';
  27. if(isset($todo->config->type)) $type = $todo->config->type == 'day' && isset($todo->config->cycleYear) ? 'year' : $todo->config->type;
  28. jsVar('cycleType', $type);
  29. if(isset($todo->config->type) && $todo->config->type == 'day' && isset($todo->config->cycleYear)) $todo->date = '';
  30. if(isset($todo->config->month) || isset($todo->config->week)) $todo->date = '';
  31. }
  32. else
  33. {
  34. jsVar('cycleType', '');
  35. }
  36. /**
  37. * 构建日期控件,用于非周期待办展示。
  38. * Build date control for off-cycle todo display.
  39. *
  40. * @param object $todo
  41. * @return mixed
  42. */
  43. $buildDateControl = function($todo)
  44. {
  45. global $lang;
  46. if($todo->cycle) return null;
  47. return formRow
  48. (
  49. setClass('items-center'),
  50. formGroup
  51. (
  52. set::label($lang->todo->date),
  53. set::width('1/3'),
  54. datepicker
  55. (
  56. setClass('date'),
  57. set::name('date'),
  58. set::value($todo->date == FUTURE_TIME ? '' : $todo->date),
  59. set::disabled($todo->date == FUTURE_TIME),
  60. on::change('changeDate')
  61. )
  62. ),
  63. formGroup
  64. (
  65. setClass('items-center ml-4'),
  66. checkbox
  67. (
  68. setID('switchDate'),
  69. set::name('switchDate'),
  70. set::text($lang->todo->periods['future']),
  71. set::checked($todo->date == FUTURE_TIME),
  72. on::change('togglePending')
  73. )
  74. )
  75. );
  76. };
  77. /**
  78. * 构建周期为天的设置。
  79. * Build setting with cycle of day.
  80. *
  81. * @param object $todo
  82. * @return mixed
  83. */
  84. $buildCycleOfDayConfig = function($todo)
  85. {
  86. global $lang;
  87. return formRow
  88. (
  89. setClass('cycle-config cycle-type-detail type-day hidden'),
  90. formGroup
  91. (
  92. set::label($lang->todo->cycleConfig),
  93. set::required(true),
  94. set::width('1/3'),
  95. inputGroup
  96. (
  97. setClass('have-fix'),
  98. span(setClass('input-group-addon justify-center'), $lang->todo->from),
  99. datePicker(setID('config_date'), set::name('config[date]'), set::value($todo->date ? $todo->date : date('Y-m-d')), on::change('verifyCycleDate'))
  100. )
  101. ),
  102. formGroup
  103. (
  104. set::label($lang->todo->every),
  105. set::required(true),
  106. setClass('config-day flex items-center highlight-suffix'),
  107. inputControl
  108. (
  109. set::suffix($lang->todo->cycleDay),
  110. set::suffixWidth('30'),
  111. input
  112. (
  113. setID('spaceDay'),
  114. set::name('config[day]'),
  115. set::value(isset($todo->config->day) ? $todo->config->day : ''),
  116. on::change('verifySpaceDay')
  117. )
  118. )
  119. )
  120. );
  121. };
  122. /**
  123. * 构建周期为周的设置。
  124. * Build setting with cycle of week.
  125. *
  126. * @param object $todo
  127. * @return mixed
  128. */
  129. $buildCycleOfWeekConfig = function($todo)
  130. {
  131. global $lang;
  132. return formRow
  133. (
  134. setClass('cycle-config cycle-type-detail type-week hidden'),
  135. formGroup
  136. (
  137. set::label($lang->todo->cycleConfig),
  138. set::required(true),
  139. set::width('1/2'),
  140. inputGroup
  141. (
  142. setClass('have-fix'),
  143. span(setClass('input-group-addon'), $lang->todo->weekly),
  144. picker
  145. (
  146. set
  147. (
  148. array(
  149. 'required' => true,
  150. 'name' => 'config[week]',
  151. 'items' => $lang->todo->dayNames,
  152. 'value' => isset($todo->config->week) ? $todo->config->week : 1,
  153. 'multiple' => true
  154. )
  155. )
  156. )
  157. )
  158. )
  159. );
  160. };
  161. /**
  162. * 构建周期为月的设置。
  163. * Build setting with cycle of month.
  164. *
  165. * @param object $todo
  166. * @return mixed
  167. */
  168. $buildCycleOfMonthConfig = function($todo)
  169. {
  170. global $lang;
  171. $days = array();
  172. for($day = 1; $day <= 31; $day ++) $days[$day] = $day . $lang->todo->day;
  173. return formRow
  174. (
  175. setClass('cycle-config cycle-type-detail type-month hidden'),
  176. formGroup
  177. (
  178. setClass('have-fix'),
  179. set::label($lang->todo->cycleConfig),
  180. set::required(true),
  181. set::width('1/2'),
  182. inputGroup
  183. (
  184. span(setClass('input-group-addon'), $lang->todo->monthly),
  185. picker(set(array('required' => true, 'multiple' => true, 'id' => 'config_month', 'name' => 'config[month]', 'items' => $days, 'value' => isset($todo->config->month) ? $todo->config->month : '')))
  186. )
  187. )
  188. );
  189. };
  190. /**
  191. * 构建周期为年的设置。
  192. * Build setting with cycle of year.
  193. *
  194. * @param object $todo
  195. * @return mixed
  196. */
  197. $buildCycleOfYearConfig = function($todo)
  198. {
  199. global $lang;
  200. $days = array();
  201. for($day = 1; $day <= 31; $day ++) $days[$day] = $day . $lang->todo->day;
  202. return formRow
  203. (
  204. setClass('cycle-config cycle-type-detail type-year hidden'),
  205. formGroup
  206. (
  207. setClass('have-fix'),
  208. set::width('1/2'),
  209. set::label($lang->todo->cycleConfig),
  210. set::required(true),
  211. inputGroup
  212. (
  213. span(setClass('input-group-addon'), $lang->todo->specify),
  214. picker
  215. (
  216. set
  217. (
  218. array(
  219. 'required' => true,
  220. 'id' => 'config_specify_month',
  221. 'name' => 'config[specify][month]',
  222. 'items' => $lang->datepicker->monthNames,
  223. 'multiple' => false,
  224. 'value' => isset($todo->config->specify->month) ? $todo->config->specify->month : 0
  225. )
  226. ),
  227. on::change('setDays')
  228. ),
  229. picker
  230. (
  231. set
  232. (
  233. array(
  234. 'required' => true,
  235. 'id' => 'specifiedDay',
  236. 'name' => 'config[specify][day]',
  237. 'items' => $days,
  238. 'multiple' => false,
  239. 'value' => isset($todo->config->specify->day) ? $todo->config->specify->day : 1
  240. )
  241. )
  242. )
  243. )
  244. )
  245. );
  246. };
  247. /**
  248. * 构建生成待办控件。
  249. * Build generating todo control.
  250. *
  251. * @param object $todo
  252. * @return mixed
  253. */
  254. $buildBeforeDays = function($todo)
  255. {
  256. global $lang;
  257. return formRow
  258. (
  259. setClass('cycle-config'),
  260. formGroup
  261. (
  262. set
  263. (
  264. array(
  265. 'label' => $lang->todo->generate,
  266. 'class' => 'have-fix highlight-suffix',
  267. 'width' => '1/3'
  268. )
  269. ),
  270. inputControl
  271. (
  272. set::prefix($lang->todo->advance),
  273. set::prefixWidth('42'),
  274. input
  275. (
  276. set
  277. (
  278. array(
  279. 'class' => 'before-days',
  280. 'name' => 'config[beforeDays]',
  281. 'value' => $todo->config->beforeDays
  282. )
  283. )
  284. ),
  285. to::suffix($lang->todo->cycleDay),
  286. set::suffixWidth('30')
  287. )
  288. )
  289. );
  290. };
  291. /**
  292. * 构建周期时间控件。
  293. * Build deadline control.
  294. *
  295. * @param object $todo
  296. * @return mixed
  297. */
  298. $buildDeadline = function($todo)
  299. {
  300. global $lang;
  301. return formRow
  302. (
  303. setClass('cycle-config'),
  304. formGroup
  305. (
  306. set::width('1/3'),
  307. set::label($lang->todo->deadline),
  308. datePicker(setID('config_end'), set::name('config[end]'), set::value(isset($todo->config->end) ? $todo->config->end : ''))
  309. )
  310. );
  311. };
  312. /**
  313. * 构建周期类型。
  314. * Build cycle type.
  315. *
  316. * @param object $todo
  317. * @return mixed
  318. */
  319. $buildCycleType = function($todo)
  320. {
  321. global $lang;
  322. $cycleTypeOptions = array(
  323. array('text' => $lang->todo->cycleDay, 'value' => 'day'),
  324. array('text' => $lang->todo->cycleWeek, 'value' => 'week'),
  325. array('text' => $lang->todo->cycleMonth, 'value' => 'month'),
  326. array('text' => $lang->todo->cycleYear, 'value' => 'year')
  327. );
  328. $type = '';
  329. if(isset($todo->config->type)) $type = $todo->config->type == 'day' && isset($todo->config->cycleYear) ? 'year' : $todo->config->type;
  330. return formRow
  331. (
  332. setClass('cycle-config'),
  333. formGroup
  334. (
  335. set::label($lang->todo->cycleType),
  336. set::required(true),
  337. radioList
  338. (
  339. set
  340. (
  341. array(
  342. 'name' => 'config[type]',
  343. 'id' => 'cycleType',
  344. 'value' => $type,
  345. 'inline' => true,
  346. 'items' => $cycleTypeOptions
  347. )
  348. ),
  349. on::change('changeCycleType')
  350. )
  351. )
  352. );
  353. };
  354. /**
  355. * 构建待办类型,用于非周期待办展示。
  356. * Build todo type for off-cycle todo display.
  357. *
  358. * @param object $todo
  359. * @return mixed
  360. */
  361. $buildTodoType = function($todo)
  362. {
  363. global $lang;
  364. if($todo->cycle) return null;
  365. return formGroup
  366. (
  367. set::width('1/3'),
  368. set::label($lang->todo->type),
  369. picker(set(array('required' => true, 'name' => 'type', 'items' => $lang->todo->typeList, 'value' => $todo->type, 'onchange' => 'changeType(this)')))
  370. );
  371. };
  372. formPanel
  373. (
  374. setID('editTodoPanel'),
  375. set::title(''),
  376. set::submitBtnText($lang->save),
  377. div
  378. (
  379. setClass('flex items-center pb-2.5'),
  380. span($lang->todo->edit),
  381. span(setClass('text-lg font-bold ml-3'), $todo->name),
  382. label(setClass('circle ml-2 label-id px-2'), $todo->id)
  383. ),
  384. $buildDateControl($todo),
  385. $todo->cycle ? fragment
  386. (
  387. $buildCycleType($todo),
  388. $buildCycleOfDayConfig($todo),
  389. $buildCycleOfWeekConfig($todo),
  390. $buildCycleOfMonthConfig($todo),
  391. $buildCycleOfYearConfig($todo),
  392. $buildBeforeDays($todo),
  393. $buildDeadline($todo)
  394. ) : null,
  395. $buildTodoType($todo),
  396. formRow
  397. (
  398. formGroup
  399. (
  400. set(array('width' => '1/3', 'label' => $lang->todo->assignTo)),
  401. picker
  402. (
  403. set
  404. (
  405. array(
  406. 'required' => true,
  407. 'items' => $users,
  408. 'value' => $todo->assignedTo,
  409. 'id' => 'assignedTo',
  410. 'name' => 'assignedTo',
  411. 'disabled' => $todo->private
  412. )
  413. ),
  414. on::change('changeAssignedTo()')
  415. )
  416. ),
  417. formGroup
  418. (
  419. setClass('items-center ml-4'),
  420. checkbox
  421. (
  422. set
  423. (
  424. array(
  425. 'id' => 'private',
  426. 'name' => 'private',
  427. 'text' => $lang->todo->private,
  428. 'value' => $todo->private ? 'on' : '',
  429. 'checked' => !empty($todo->private)
  430. )
  431. ),
  432. set::disabled($todo->assignedTo != $app->user->account || $todo->assignedTo != $todo->account),
  433. on::change("zui.Picker.query('[name=assignedTo]').render({disabled: e.target.checked})")
  434. ),
  435. btn
  436. (
  437. set::icon('help'),
  438. toggle::tooltip(array('placement' => 'right', 'title' => $lang->todo->privateTip, 'type' => 'white', 'class-name' => 'text-gray border border-light')),
  439. set::square(true),
  440. setClass('ghost h-6 mt-0.5 tooltip-btn')
  441. )
  442. )
  443. ),
  444. formRow
  445. (
  446. formGroup
  447. (
  448. set::width('3/4'),
  449. set(array('id' => 'nameBox', 'required' => true, 'label' => (($todo->type == 'custom' || $config->vision == 'rnd') ? $lang->todo->name : $lang->todo->objectID), 'class' => 'name-box')),
  450. div
  451. (
  452. setClass('w-full'),
  453. setID('nameInputBox'),
  454. input(set(array('id' => 'name', 'name' => 'name', 'value' => $todo->name)))
  455. )
  456. ),
  457. formGroup
  458. (
  459. set::width('1/4'),
  460. setClass('priBox'),
  461. set::label($lang->todo->pri),
  462. priPicker(setID('pri'), set::name('pri'), set::items($lang->todo->priList), set::value($todo->pri))
  463. )
  464. ),
  465. formGroup
  466. (
  467. set::label($lang->todo->desc),
  468. setID('desc'),
  469. editor
  470. (
  471. set::name('desc'),
  472. html($todo->desc)
  473. )
  474. ),
  475. formGroup
  476. (
  477. set::width('1/3'),
  478. set::label($lang->todo->status),
  479. set::control(array('control' => 'picker', 'id' => 'status', 'name' => 'status', 'items' => $lang->todo->statusList, 'value' => $todo->status))
  480. ),
  481. formRow
  482. (
  483. setClass('items-center'),
  484. formGroup
  485. (
  486. set::label($lang->todo->beginAndEnd),
  487. set::width('2/3'),
  488. inputGroup
  489. (
  490. picker
  491. (
  492. set
  493. (
  494. array(
  495. 'required' => true,
  496. 'id' => 'begin',
  497. 'name' => 'begin',
  498. 'items' => $times,
  499. 'value' => $todo->begin,
  500. 'disabled' => $todo->begin == 2400
  501. )
  502. ),
  503. on::change('selectNext')
  504. ),
  505. span
  506. (
  507. setClass('input-group-addon ring-0'),
  508. $lang->todo->timespanTo
  509. ),
  510. picker
  511. (
  512. set
  513. (
  514. array(
  515. 'required' => true,
  516. 'id' => 'end',
  517. 'name' => 'end',
  518. 'items' => $times,
  519. 'value' => $todo->end,
  520. 'disabled' => $todo->begin == 2400
  521. )
  522. ),
  523. on::change('verifyEndTime')
  524. )
  525. )
  526. ),
  527. div
  528. (
  529. setClass('ml-4 flex items-center'),
  530. checkbox
  531. (
  532. set
  533. (
  534. array(
  535. 'id' => 'dateSwitcher',
  536. 'name' => 'dateSwitcher',
  537. 'checked' => $todo->begin == 2400,
  538. 'text' => $lang->todo->periods['future']
  539. )
  540. ),
  541. on::change('switchDateFeature')
  542. )
  543. )
  544. )
  545. );
  546. render();