diff --git a/module/program/model.php b/module/program/model.php index 84eef5815d..aacbebdc4e 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -721,32 +721,6 @@ class programModel extends model ->remove('delta,future,contactListMenu') ->get(); - if($program->parent) - { - $parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($program->parent)->fetch(); - if($parentProgram) - { - /* Child program begin cannot less than parent. */ - if(!empty($program->name) and $program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin); - - /* When parent set end then child program end cannot greater than parent. */ - if(!empty($program->name) and$parentProgram->end != '0000-00-00' and $program->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end); - - /* When parent set end then child program cannot set longTime. */ - if(!empty($program->name) and empty($program->end) and $this->post->delta == 999 and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end); - - /* The budget of a child program cannot beyond the remaining budget of the parent program. */ - $program->budgetUnit = $parentProgram->budgetUnit; - if(isset($program->budget)) - { - $availableBudget = $this->getBudgetLeft($parentProgram); - if($program->budget > $availableBudget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; - } - - if(dao::isError()) return false; - } - } - /* Redefines the language entries for the fields in the project table. */ foreach(explode(',', $this->config->program->create->requiredFields) as $field) { @@ -817,17 +791,6 @@ class programModel extends model $program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->edit['id'], $this->post->uid); $children = $this->getChildren($programID); - if($children > 0) - { - $minChildBegin = $this->dao->select('type, begin as minBegin')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->orderBy('begin_asc')->fetch(); - $maxChildEnd = $this->dao->select('type, 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(); - - $minChildType = ($minChildBegin->type == 'project') ? $this->lang->project->common : $this->lang->program->childProgram; - $maxChildType = ($maxChildEnd->type == 'project') ? $this->lang->project->common : $this->lang->program->childProgram; - if($minChildBegin and $program->begin > $minChildBegin->minBegin) dao::$errors['begin'] = sprintf($this->lang->program->beginGreateChild, $minChildType, $minChildBegin->minBegin); - if($maxChildEnd and $program->end < $maxChildEnd->maxEnd and $this->post->delta != 999) dao::$errors['end'] = sprintf($this->lang->program->endLetterChild, $maxChildType, $maxChildEnd->maxEnd); - if(dao::isError()) return false; - } if($program->parent) { @@ -836,22 +799,6 @@ class programModel extends model ->where('root')->eq($programID) ->andwhere('type')->eq('line') ->exec(); - - $parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($program->parent)->fetch(); - if($parentProgram) - { - if(!empty($program->name) and $program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin); - if(!empty($program->name) and $parentProgram->end != '0000-00-00' and $program->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end); - if(!empty($program->name) and empty($program->end) and $this->post->delta == 999 and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end); - } - - /* The budget of a child program cannot beyond the remaining budget of the parent program. */ - $program->budgetUnit = $parentProgram->budgetUnit; - if($program->budget != 0) - { - $availableBudget = $this->getBudgetLeft($parentProgram); - if($program->budget > $availableBudget + $oldProgram->budget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; - } } if(dao::isError()) return false; diff --git a/module/project/model.php b/module/project/model.php index fff3a0fe4a..42c99b0993 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1106,26 +1106,6 @@ class projectModel extends model $program = new stdClass(); if($project->parent) { - $program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($project->parent)->fetch(); - if($program) - { - /* Child project begin cannot less than parent. */ - if(!empty($project->name) and $project->begin < $program->begin) dao::$errors['begin'] = sprintf($this->lang->project->beginGreateChild, $program->begin); - - /* When parent set end then child project end cannot greater than parent. */ - if(!empty($project->name) and $program->end != '0000-00-00' and $project->end > $program->end) dao::$errors['end'] = sprintf($this->lang->project->endLetterChild, $program->end); - - if(dao::isError()) return false; - } - - /* The budget of a child project cannot beyond the remaining budget of the parent program. */ - $project->budgetUnit = $program->budgetUnit; - if(isset($project->budget) and $program->budget != 0) - { - $availableBudget = $this->loadModel('program')->getBudgetLeft($program); - if($availableBudget > 0 and $project->budget > $availableBudget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; - } - /* Judge products not empty. */ if(empty($linkedProductsCount) and !isset($_POST['newProduct'])) { @@ -1369,30 +1349,6 @@ class projectModel extends model ->remove('products,branch,plans,delta,future,contactListMenu,teamMembers') ->get(); - if($project->parent) - { - $program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($project->parent)->fetch(); - - if($program) - { - /* Child project begin cannot less than parent. */ - if(!empty($project->name) and $project->begin < $program->begin) dao::$errors['begin'] = sprintf($this->lang->project->beginGreateChild, $program->begin); - - /* When parent set end then child project end cannot greater than parent. */ - if(!empty($project->name) and $program->end != '0000-00-00' and $project->end > $program->end) dao::$errors['end'] = sprintf($this->lang->project->endLetterChild, $program->end); - - if(dao::isError()) return false; - } - - /* The budget of a child project cannot beyond the remaining budget of the parent project. */ - $project->budgetUnit = $program->budgetUnit; - if($project->budget != 0 and $program->budget != 0) - { - $availableBudget = $this->loadModel('program')->getBudgetLeft($program); - if($project->budget > $availableBudget + $oldProject->budget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; - } - } - $executionsCount = $this->dao->select('COUNT(*) as count')->from(TABLE_PROJECT) ->where('project')->eq($project->id) ->andWhere('deleted')->eq('0') @@ -1553,25 +1509,6 @@ class projectModel extends model $projects[$projectID]->lastEditedDate = helper::now(); if(isset($data->codes)) $projects[$projectID]->code = $projectCode; - if($projects[$projectID]->parent) - { - $parentProject = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($projects[$projectID]->parent)->fetch(); - - if($parentProject) - { - /* Child project begin cannot less than parent. */ - if(!empty($projects[$projectID]->name) and $projects[$projectID]->begin < $parentProject->begin) - { - dao::$errors[] = "ID {$projects[$projectID]->id}" . sprintf($this->lang->project->beginGreateChild, $parentProject->begin) . "\n"; - } - - /* When parent set end then child project end cannot greater than parent. */ - if(!empty($projects[$projectID]->name) and $parentProject->end != '0000-00-00' and $projects[$projectID]->end > $parentProject->end) - { - dao::$errors[] = "ID {$projects[$projectID]->id}" . sprintf($this->lang->project->endLetterChild, $parentProject->end) . "\n"; - } - } - } foreach($extendFields as $extendField) {