From 778fb656e9621a11ff0195e7ce40d0dc5cf1490c Mon Sep 17 00:00:00 2001 From: liumengyi Date: Mon, 22 Jan 2024 10:09:16 +0800 Subject: [PATCH] * Fix bug #44518, show date tip if it exceeds the date range of the program. --- module/project/js/common.ui.js | 47 +++++++++++++++++++++--------- module/project/lang/de.php | 4 +-- module/project/lang/en.php | 4 +-- module/project/lang/fr.php | 4 +-- module/project/lang/zh-cn.php | 4 +-- module/project/ui/common.field.php | 5 +++- module/project/ui/create.html.php | 4 ++- module/project/ui/edit.html.php | 8 +++-- 8 files changed, 54 insertions(+), 26 deletions(-) diff --git a/module/project/js/common.ui.js b/module/project/js/common.ui.js index 2e6b3cc460..389ad3c196 100644 --- a/module/project/js/common.ui.js +++ b/module/project/js/common.ui.js @@ -96,6 +96,7 @@ function computeWorkDays() $('#delta' + days).prop('checked', true); } } + checkProjectInfo(); } /** @@ -209,36 +210,54 @@ window.toggleMultiple = function(e) * @access public * @return void */ -function checkBudget(projectID) +function checkBudget() { if(ignoreTips['budgetTip']) return; + $('#budgetTip').addClass('hidden'); + checkProjectInfo(); +} + +function checkProjectInfo() +{ const programID = $('[name=parent]').val(); if(programID == 0) { $('[name=budget]').removeAttr('placeholder'); $('#budgetTip').addClass('hidden'); + $('#dateTip').addClass('hidden'); return false; } if(typeof(projectID) == 'undefined') projectID = 0; - $('#budgetTip').addClass('hidden'); $.getJSON($.createLink('project', 'ajaxGetProjectFormInfo', 'objectType=project&objectID=' + projectID + "&selectedProgramID=" + programID), function(data) { - if(typeof(data.availableBudget) == 'undefined') return; - - const budget = $('[name=budget]').val() * budgetUnitValue; - if(budget != 0 && budget !== null && budget > data.availableBudget) + let dateTip = ''; + if(typeof(data.selectedProgramBegin) != 'undefined' && $('[name=begin]').val() != '' && $('[name=begin]').val() > data.selectedProgramBegin) dateTip += beginLessThanParent.replace('%s', data.selectedProgramBegin); + if(typeof(data.selectedProgramEnd) != 'undefined' && $('[name=end]').val() != '' && $('[name=end]').val() < data.selectedProgramEnd) dateTip += endGreatThanParent.replace('%s', data.selectedProgramEnd); + if(dateTip != '') { - const currency = currencySymbol[data.budgetUnit]; - const availableBudget = (data.availableBudget / budgetUnitValue).toFixed(2); - const budgetTip = budgetOverrun.replace('%s', currency + availableBudget); - $('[name=budget]').attr('placeholder', budgetTip); - $('#budgetTip').html(budgetTip); - $('#budgetTip').append($('' + ignore + '')); - $('#budgetTip').removeClass('hidden'); - $('#budgetTip').off('click', '#ignoreBudget').on('click', '#ignoreBudget', function(){ignoreTip('budgetTip')}); + $('#dateTip').html(dateTip); + $('#dateTip').append($('' + ignore + '')); + $('#dateTip').removeClass('hidden'); + $('#dateTip').off('click', '#ignoreDate').on('click', '#ignoreDate', function(){ignoreTip('dateTip')}); + } + + if(typeof(data.availableBudget) != 'undefined') + { + const budget = $('[name=budget]').val() * budgetUnitValue; + if(budget != 0 && budget !== null && budget > data.availableBudget) + { + const currency = currencySymbol[data.budgetUnit]; + const availableBudget = (data.availableBudget / budgetUnitValue).toFixed(2); + const budgetTip = budgetOverrun.replace('%s', currency + availableBudget); + $('[name=budget]').attr('placeholder', budgetTip); + $('#budgetTip').html(budgetTip); + $('#budgetTip').append($('' + ignore + '')); + $('#budgetTip').removeClass('hidden'); + $('#budgetTip').off('click', '#ignoreBudget').on('click', '#ignoreBudget', function(){ignoreTip('budgetTip')}); + } } }); } diff --git a/module/project/lang/de.php b/module/project/lang/de.php index 94f4104010..d1442a68fa 100644 --- a/module/project/lang/de.php +++ b/module/project/lang/de.php @@ -427,8 +427,8 @@ $lang->project->cannotCancelCat = "There are child {$lang->projectCommon}s $lang->project->parentBeginEnd = "The begin and end date of the parent {$lang->projectCommon}: %s ~ %s"; $lang->project->parentBudget = "The budget of the parent program: "; -$lang->project->beginLessThanParent = "The start date of the {$lang->projectCommon} is < the start date of the parent program: . "; -$lang->project->endGreatThanParent = "The finish date of the {$lang->projectCommon} is > the finish date of the parent program: . "; +$lang->project->beginLessThanParent = "The start date of the {$lang->projectCommon} is < the start date of the parent program: %s. "; +$lang->project->endGreatThanParent = "The finish date of the {$lang->projectCommon} is > the finish date of the parent program: %s. "; $lang->project->dateExceedParent = "The start and finish date of the {$lang->projectCommon} was > the start and finish date of the parent program:"; $lang->project->beginGreatEqualChild = "The start date of the {$lang->projectCommon} should be ≥ the start date of program: %s."; $lang->project->endLessThanChild = "The finish date of the {$lang->projectCommon} should be ≤ the finish date of program: %s."; diff --git a/module/project/lang/en.php b/module/project/lang/en.php index a8bd140fe3..3c7e7e93a4 100644 --- a/module/project/lang/en.php +++ b/module/project/lang/en.php @@ -431,8 +431,8 @@ $lang->project->cannotCancelCat = "There are child {$lang->projectCommon}s $lang->project->parentBeginEnd = "The begin and end date of the parent {$lang->projectCommon}: %s ~ %s"; $lang->project->parentBudget = "The budget of the parent program: "; -$lang->project->beginLessThanParent = "The start date of the {$lang->projectCommon} is < the start date of the parent program: . "; -$lang->project->endGreatThanParent = "The finish date of the {$lang->projectCommon} is > the finish date of the parent program: . "; +$lang->project->beginLessThanParent = "The start date of the {$lang->projectCommon} is < the start date of the parent program: %s. "; +$lang->project->endGreatThanParent = "The finish date of the {$lang->projectCommon} is > the finish date of the parent program: %s. "; $lang->project->dateExceedParent = "The start and finish date of the {$lang->projectCommon} was > the start and finish date of the parent program:"; $lang->project->beginGreatEqualChild = "The start date of the {$lang->projectCommon} should be ≥ the start date of program: %s."; $lang->project->endLessThanChild = "The finish date of the {$lang->projectCommon} should be ≤ the finish date of program: %s."; diff --git a/module/project/lang/fr.php b/module/project/lang/fr.php index 0b49d6ab6c..ee6ba511c1 100644 --- a/module/project/lang/fr.php +++ b/module/project/lang/fr.php @@ -427,8 +427,8 @@ $lang->project->cannotCancelCat = "There are child {$lang->projectCommon}s $lang->project->parentBeginEnd = "The begin and end date of the parent {$lang->projectCommon}: %s ~ %s"; $lang->project->parentBudget = "The budget of the parent program: "; -$lang->project->beginLessThanParent = "The start date of the {$lang->projectCommon} is < the start date of the parent program: . "; -$lang->project->endGreatThanParent = "The finish date of the {$lang->projectCommon} is > the finish date of the parent program: . "; +$lang->project->beginLessThanParent = "The start date of the {$lang->projectCommon} is < the start date of the parent program: %s. "; +$lang->project->endGreatThanParent = "The finish date of the {$lang->projectCommon} is > the finish date of the parent program: %s. "; $lang->project->dateExceedParent = "The start and finish date of the {$lang->projectCommon} was > the start and finish date of the parent program:"; $lang->project->beginGreatEqualChild = "The start date of the {$lang->projectCommon} should be ≥ the start date of program: %s."; $lang->project->endLessThanChild = "The finish date of the {$lang->projectCommon} should be ≤ the finish date of program: %s."; diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php index 0aa7a23731..ed65143246 100644 --- a/module/project/lang/zh-cn.php +++ b/module/project/lang/zh-cn.php @@ -432,8 +432,8 @@ $lang->project->cannotCancelCat = "该{$lang->projectCommon}下已经有子 $lang->project->parentBeginEnd = "父{$lang->projectCommon}起止时间:%s ~ %s"; $lang->project->parentBudget = "父项目集预算:"; -$lang->project->beginLessThanParent = "{$lang->projectCommon}的开始日期小于了父项目集的开始日期:。"; -$lang->project->endGreatThanParent = "{$lang->projectCommon}的完成日期大于了父项目集的完成日期:。"; +$lang->project->beginLessThanParent = "{$lang->projectCommon}的开始日期小于了父项目集的开始日期:%s。"; +$lang->project->endGreatThanParent = "{$lang->projectCommon}的完成日期大于了父项目集的完成日期:%s。"; $lang->project->dateExceedParent = "{$lang->projectCommon}的起止日期已超出父项目集的起止日期:"; $lang->project->beginGreatEqualChild = "{$lang->projectCommon}的开始日期应大于等于项目集的最小开始日期:%s"; $lang->project->endLessThanChild = "{$lang->projectCommon}的完成日期应小于等于项目集的最大完成日期:%s"; diff --git a/module/project/ui/common.field.php b/module/project/ui/common.field.php index eacf19f9c9..0fed3f0250 100644 --- a/module/project/ui/common.field.php +++ b/module/project/ui/common.field.php @@ -51,7 +51,10 @@ $fields->field('begin') ->control('inputGroup') ->itemBegin('begin')->control('datePicker')->placeholder($lang->project->begin)->value(data('project.begin') ? data('project.begin') : date('Y-m-d'))->required(true)->itemEnd() ->item(array('control' => 'span', 'text' => '-')) - ->itemBegin('end')->control('datePicker')->placeholder($lang->project->end)->required(true)->value(data('project.end'))->itemEnd(); + ->itemBegin('end')->control('datePicker')->placeholder($lang->project->end)->required(true)->value(data('project.end'))->itemEnd() + ->tip('123') + ->tipProps(array('id' => 'dateTip')) + ->tipClass('text-warning hidden'); $fields->field('days')->label($lang->project->days . $lang->project->daysUnit)->control('input'); diff --git a/module/project/ui/create.html.php b/module/project/ui/create.html.php index 014fa88c8a..161f0df068 100644 --- a/module/project/ui/create.html.php +++ b/module/project/ui/create.html.php @@ -22,6 +22,8 @@ jsVar('budgetUnitValue', $config->project->budget->tenThousand); jsVar('+projectID', $copyProjectID); jsVar('LONG_TIME', LONG_TIME); jsVar('weekend', $config->execution->weekend); +jsVar('beginLessThanParent', $lang->project->beginLessThanParent); +jsVar('endGreatThanParent', $lang->project->endGreatThanParent); $modelMenuItems = array(); foreach($lang->project->modelList as $key => $text) @@ -62,7 +64,7 @@ formGridPanel on::change('[name=future]', 'toggleBudget'), on::change('[name=begin], [name=end]', 'computeWorkDays'), on::change('[name^=products]', 'productChange'), - on::change('#parent, #budget', "checkBudget(0)"), + on::change('[name=parent], [name=budget]', 'checkBudget'), set::title($lang->project->create), set::fullModeOrders(array('begin,days,PM,budget', !empty($config->setCode) ? 'parent,hasProduct,name,code,begin' : 'parent,name,hasProduct,begin')), set::fields($fields) diff --git a/module/project/ui/edit.html.php b/module/project/ui/edit.html.php index be121da53f..82e501a4fc 100644 --- a/module/project/ui/edit.html.php +++ b/module/project/ui/edit.html.php @@ -25,6 +25,10 @@ jsVar('unmodifiableMainBranches', $unmodifiableMainBranches); jsVar('unLinkProductTip', $lang->project->unLinkProductTip); jsVar('allProducts', $allProducts); jsVar('branchGroups', $branchGroups); +jsVar('projectID', $projectID); +jsVar('from', $from); +jsVar('programID', $programID); +jsVar('LONG_TIME', LONG_TIME); $labelClass = $config->project->labelClass[$model]; @@ -55,9 +59,9 @@ formGridPanel on::change('[name=hasProduct]', 'changeType'), on::change('[name=future]', 'toggleBudget'), on::change('[name=begin], [name=end]', 'computeWorkDays'), - on::change('[name=parent], [name=budget]', "checkBudget({$project->id})"), + on::change('[name=parent], [name=budget]', 'checkBudget'), on::change('[name^=products]', 'productChange'), - on::change('#parent', 'setParentProgram'), + on::change('[name=parent]', 'setParentProgram'), set::fullModeOrders(array('begin,days,PM,budget', !empty($config->setCode) ? 'parent,hasProduct,name,code,begin' : 'parent,name,hasProduct,begin')), set::modeSwitcher(false), set::defaultMode('full'),