showimport.html.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace zin;
  3. include $app->getModuleRoot() . 'transfer/ui/showimport.html.php';
  4. jsVar('childrenDateLimit', $childrenDateLimit);
  5. jsVar('parentTasks', $parentTasks);
  6. jsVar('tasks', $oldTasks);
  7. jsVar('jsDatas', array_values($datas));
  8. $team = array();
  9. foreach($fields['assignedTo']['items'] as $account => $name) $team[] = array('text' => $name, 'value' => $account);
  10. jsVar('team', $team);
  11. pageJS(<<<'JAVASCRIPT'
  12. $(function()
  13. {
  14. var tbodyInited = false;
  15. $('#mainContainer > #mainContent .panel-body .form .form-batch-container .table tbody').on('inited', function()
  16. {
  17. if(tbodyInited) return false;
  18. tbodyInited = true;
  19. $.each($('#mainContent .form .form-batch-container tbody tr'), function(trIndex)
  20. {
  21. const data = jsDatas[trIndex];
  22. if(data.team != undefined)
  23. {
  24. let $estimate = $(this).find('.form-batch-control[data-name="estimate"]').empty();
  25. $.each(data.team, function(index, account){
  26. $estimate.append('<div class="input-group estimate-box"></div>')
  27. let $estimateInputGroup = $estimate.find('.input-group').last();
  28. $estimateInputGroup.append($('<div class="form-group-wrapper picker-box"></div>').picker({name: 'team[' + data.id + '][]', items: team, defaultValue: account, required: true}));;
  29. $estimateInputGroup.append($('<input type="text" name="estimate[' + data.id + '][]" id="estimate_' + index + '" value="' + data.estimate[index] + '" class="form-control" autocomplete="off">'));
  30. });
  31. }
  32. });
  33. });
  34. });
  35. window.renderImportRowData = function($row, index, row)
  36. {
  37. if(row.id != undefined && tasks[row.id] != undefined)
  38. {
  39. const task = tasks[row.id];
  40. $row.attr('data-parent', task.parent).attr('data-id', task.id);
  41. if(parentTasks[task.parent] != undefined && taskDateLimit == 'limit')
  42. {
  43. const parentTask = parentTasks[task.parent];
  44. $row.find('[id^="estStarted"]').on('inited', function(e, info)
  45. {
  46. if(parentTask.estStarted == '') info[0].render({disabled: true});
  47. });
  48. $row.find('[id^="deadline"]').on('inited', function(e, info)
  49. {
  50. if(parentTask.deadline == '') info[0].render({disabled: true});
  51. });
  52. }
  53. }
  54. };
  55. $(document).off('change', 'input[name^="estStarted"], input[name^="deadline"]').on('change', 'input[name^="estStarted"], input[name^="deadline"]', function()
  56. {
  57. if(taskDateLimit != 'limit') return;
  58. const $currentRow = $(this).closest('tr');
  59. const taskID = $currentRow.attr('data-id');
  60. if(taskID == undefined) return;
  61. const parentID = tasks[taskID].parent;
  62. const field = $(this).closest('.form-batch-control').data('name');
  63. const estStarted = $currentRow.find('[name^=estStarted]').val();
  64. const deadline = $currentRow.find('[name^=deadline]').val();
  65. const parentTask = parentTasks[parentID] ? parentTasks[parentID] : {estStarted: '', deadline: ''};
  66. if(field == 'estStarted')
  67. {
  68. const $estStartedTd = $currentRow.find('td[data-name=estStarted]');
  69. $estStartedTd.find('.date-tip').remove();
  70. const $childrenEstStarted = $(this).closest('tbody').find('tr[data-parent="' + taskID + '"]').find('[name^=estStarted]');
  71. $childrenEstStarted.each(function(){$(this).zui('datePicker').render({disabled: estStarted.length == 0});});
  72. if(estStarted.length > 0)
  73. {
  74. let $datetip = $('<div class="date-tip"></div>');
  75. let parentEstStarted = typeof tasks[parentID] == 'undefined' || $(this).closest('tbody').find('[name="estStarted[' + parentID + ']"]').length == 0 ? parentTask.estStarted : $(this).closest('tbody').find('[name="estStarted[' + parentID + ']"]').val();
  76. if(parentEstStarted.length > 0 && estStarted < parentEstStarted) $datetip.append('<div class="form-tip text-danger">' + overParentEstStartedLang.replace('%s', parentEstStarted) + '</div>');
  77. let childEstStarted = childrenDateLimit[taskID] ? childrenDateLimit[taskID].estStarted : '';
  78. $childrenEstStarted.each(function()
  79. {
  80. if(childEstStarted.length == 0 || ($(this).val().length > 0 && $(this).val() < childEstStarted)) childEstStarted = $(this).val();
  81. });
  82. if(childEstStarted.length > 0 && estStarted > childEstStarted)
  83. {
  84. $datetip.append('<div class="form-tip text-warning">' + overChildEstStartedLang.replace('%s', childEstStarted) + '<span class="ignore-date ignore-child underline">' + ignoreLang + '</span></div>');
  85. $datetip.off('click', '.ignore-child').on('click', '.ignore-child', function(e){ignoreTip(e)});
  86. }
  87. $estStartedTd.append($datetip);
  88. }
  89. }
  90. if(field == 'deadline')
  91. {
  92. const $deadlineTd = $currentRow.find('td[data-name=deadline]');
  93. $deadlineTd.find('.date-tip').remove();
  94. const $childrenDeadline = $(this).closest('tbody').find('tr[data-parent="' + taskID + '"]').find('[name^=deadline]');
  95. $childrenDeadline.each(function(){$(this).zui('datePicker').render({disabled: deadline.length == 0});});
  96. if(deadline.length > 0)
  97. {
  98. let $datetip = $('<div class="date-tip"></div>');
  99. let parentDeadline = typeof tasks[parentID] == 'undefined' || $(this).closest('tbody').find('[name="deadline[' + parentID + ']"]').length == 0 ? parentTask.deadline : $(this).closest('tbody').find('[name="deadline[' + parentID + ']"]').val();
  100. if(parentDeadline.length > 0 && deadline > parentDeadline) $datetip.append('<div class="form-tip text-danger">' + overParentDeadlineLang.replace('%s', parentDeadline) + '</div>');
  101. let childDeadline = childrenDateLimit[taskID] ? childrenDateLimit[taskID].deadline : '';
  102. $childrenDeadline.each(function()
  103. {
  104. if(childDeadline.length == 0 || ($(this).val().length > 0 && $(this).val() > childDeadline)) childDeadline = $(this).val();
  105. });
  106. if(childDeadline.length > 0 && deadline < childDeadline)
  107. {
  108. $datetip.append('<div class="form-tip text-warning">' + overChildDeadlineLang.replace('%s', childDeadline) + '<span class="ignore-date ignore-child underline">' + ignoreLang + '</span></div>');
  109. $datetip.off('click', '.ignore-child').on('click', '.ignore-child', function(e){ignoreTip(e)});
  110. }
  111. $deadlineTd.append($datetip);
  112. }
  113. }
  114. });
  115. JAVASCRIPT
  116. );