diff --git a/module/program/control.php b/module/program/control.php index f54144784f..b6593cbd5a 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -704,23 +704,6 @@ class program extends control echo $html; } - /** - * Ajax: Get childish information. - * - * @param int $programID - * @access public - * @return void - */ - public function ajaxGetChildInfo($programID) - { - $data = array(); - $minChildBegin = $this->dao->select('begin as minBegin')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->orderBy('begin_asc')->fetch('minBegin'); - $maxChildEnd = $this->dao->select('end as maxEnd')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->ne('0000-00-00')->orderBy('end_desc')->fetch('maxEnd'); - - $data = array('minChildBegin' => $minChildBegin, 'maxChildEnd' => $maxChildEnd); - echo json_encode($data); - } - /** * Update program order. * diff --git a/module/program/js/common.js b/module/program/js/common.js index 06dcdf816e..a64e3c2cc6 100644 --- a/module/program/js/common.js +++ b/module/program/js/common.js @@ -330,7 +330,8 @@ function setBudgetTipsAndAclList(parentID) */ function compareChildDate() { - if(getMethodName == 'create') return; + if(page == 'create') return; + var end = $('#end').val(); var begin = $('#begin').val(); if(end.length > 0 && begin.length > 0) @@ -338,22 +339,34 @@ function compareChildDate() var programEnd = new Date(end); var programBegin = new Date(begin); - $.get(createLink('program', 'ajaxGetChildInfo', 'programID=' + programID), function(data) + $.get(createLink('project', 'ajaxGetObjectInfo', 'objectType=program&objectID=' + programID + '&selectedProgramID=' + selectedProgramID), function(data) { var dateTip = ''; var childInfo = JSON.parse(data); var childBegin = new Date(childInfo.minChildBegin); var childEnd = new Date(childInfo.maxChildEnd); - if(programBegin > childBegin) dateTip = "" + beginGreateChild + childInfo.minChildBegin + ""; - if(programEnd < childEnd) dateTip = "" + endLetterChild + childInfo.maxChildEnd + ""; - if((programEnd < childBegin && programEnd < childEnd) || (programBegin > childBegin && programBegin > childEnd) || (programBegin > childBegin && programEnd < childEnd)) dateTip = "" + dateExceedChild + childInfo.minChildBegin + "~" + childInfo.maxChildEnd + ""; - if($('#dateTip').length > 0) $('#dateTip').remove(); + if(programBegin <= childBegin && programEnd >= childEnd) return; + + if(programBegin > childBegin && programEnd >= childEnd) + { + dateTip = "" + beginGreateChild + childInfo.minChildBegin + ""; + } + else if(programEnd < childEnd && programBegin <= childBegin) + { + dateTip = "" + endLetterChild + childInfo.maxChildEnd + ""; + } + else + { + dateTip = "" + dateExceedChild + childInfo.minChildBegin + "~" + childInfo.maxChildEnd + ""; + } + $('#dateBox').after(dateTip); }); } } + /** * The date is out of the range of the parent project set, and a prompt is given. * @@ -367,13 +380,11 @@ function outOfDateTip() if(end.length > 0 && begin.length > 0) { var selectedProgramID = $('#parent').val(); - var budget = $('#budget').val(); var programEnd = new Date(end); var programBegin = new Date(begin); if(selectedProgramID == 0) { - if($('#dateTip').length > 0) $('#dateTip').remove(); compareChildDate(); return false; } @@ -381,20 +392,32 @@ function outOfDateTip() if(typeof(programID) == 'undefined') programID = 0; $.get(createLink('project', 'ajaxGetParentInfo', 'objectType=program&objectID=' + programID + "&selectedProgramID=" + selectedProgramID), function(data) { + var dateTip = ''; var data = JSON.parse(data); var parentEnd = new Date(data.selectedProgramEnd); var parentBegin = new Date(data.selectedProgramBegin); - var dateTip = ""; - if(programBegin < parentBegin && programEnd <= parentEnd) dateTip = "" + beginLetterParent + data.selectedProgramBegin + ""; - if(programBegin >= parentBegin && programEnd > parentEnd) dateTip = "" + endGreaterParent + data.selectedProgramEnd + ""; - if((programBegin < parentBegin && programEnd > parentEnd) || (programEnd <= parentBegin && programBegin <= parentBegin) || (programBegin >= parentEnd && programEnd >= parentEnd)) dateTip = "" + dateExceedParent + data.selectedProgramBegin + "~" + data.selectedProgramEnd + ""; + if(programBegin >= parentBegin && programEnd <= parentEnd) + { + compareChildDate(); + return; + } + + if(programBegin < parentBegin && programEnd <= parentEnd) + { + dateTip = "" + beginLetterParent + data.selectedProgramBegin + ""; + } + else if(programBegin >= parentBegin && programEnd > parentEnd) + { + dateTip = "" + endGreaterParent + data.selectedProgramEnd + ""; + } + else + { + dateTip = "" + dateExceedParent + data.selectedProgramBegin + "~" + data.selectedProgramEnd + ""; + } if($('#dateTip').length > 0) $('#dateTip').remove(); $('#dateBox').after(dateTip); - if(dateTip.length != 0) return; - - compareChildDate(); }); } } diff --git a/module/program/view/create.html.php b/module/program/view/create.html.php index 6a4d37de75..20b891c4ba 100644 --- a/module/program/view/create.html.php +++ b/module/program/view/create.html.php @@ -45,7 +45,7 @@ program->beginLetterParent);?> program->endGreaterParent);?> program->dateExceedParent);?> -app->getMethodName());?> +app->getMethodName());?> program->subAclList : $lang->program->aclList;?> program->create->requiredFields;?>