getModuleRoot() . 'transfer/ui/showimport.html.php'; jsVar('childrenDateLimit', $childrenDateLimit); jsVar('parentTasks', $parentTasks); jsVar('tasks', $oldTasks); jsVar('jsDatas', array_values($datas)); $team = array(); foreach($fields['assignedTo']['items'] as $account => $name) $team[] = array('text' => $name, 'value' => $account); jsVar('team', $team); pageJS(<<<'JAVASCRIPT' $(function() { var tbodyInited = false; $('#mainContainer > #mainContent .panel-body .form .form-batch-container .table tbody').on('inited', function() { if(tbodyInited) return false; tbodyInited = true; $.each($('#mainContent .form .form-batch-container tbody tr'), function(trIndex) { const data = jsDatas[trIndex]; if(data.team != undefined) { let $estimate = $(this).find('.form-batch-control[data-name="estimate"]').empty(); $.each(data.team, function(index, account){ $estimate.append('
') let $estimateInputGroup = $estimate.find('.input-group').last(); $estimateInputGroup.append($('').picker({name: 'team[' + data.id + '][]', items: team, defaultValue: account, required: true}));; $estimateInputGroup.append($('')); }); } }); }); }); window.renderImportRowData = function($row, index, row) { if(row.id != undefined && tasks[row.id] != undefined) { const task = tasks[row.id]; $row.attr('data-parent', task.parent).attr('data-id', task.id); if(parentTasks[task.parent] != undefined && taskDateLimit == 'limit') { const parentTask = parentTasks[task.parent]; $row.find('[id^="estStarted"]').on('inited', function(e, info) { if(parentTask.estStarted == '') info[0].render({disabled: true}); }); $row.find('[id^="deadline"]').on('inited', function(e, info) { if(parentTask.deadline == '') info[0].render({disabled: true}); }); } } }; $(document).off('change', 'input[name^="estStarted"], input[name^="deadline"]').on('change', 'input[name^="estStarted"], input[name^="deadline"]', function() { if(taskDateLimit != 'limit') return; const $currentRow = $(this).closest('tr'); const taskID = $currentRow.attr('data-id'); if(taskID == undefined) return; const parentID = tasks[taskID].parent; const field = $(this).closest('.form-batch-control').data('name'); const estStarted = $currentRow.find('[name^=estStarted]').val(); const deadline = $currentRow.find('[name^=deadline]').val(); const parentTask = parentTasks[parentID] ? parentTasks[parentID] : {estStarted: '', deadline: ''}; if(field == 'estStarted') { const $estStartedTd = $currentRow.find('td[data-name=estStarted]'); $estStartedTd.find('.date-tip').remove(); const $childrenEstStarted = $(this).closest('tbody').find('tr[data-parent="' + taskID + '"]').find('[name^=estStarted]'); $childrenEstStarted.each(function(){$(this).zui('datePicker').render({disabled: estStarted.length == 0});}); if(estStarted.length > 0) { let $datetip = $(''); 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(); if(parentEstStarted.length > 0 && estStarted < parentEstStarted) $datetip.append('