diff --git a/module/productplan/js/browse.js b/module/productplan/js/browse.js index 85b3864e43..f52f31a236 100644 --- a/module/productplan/js/browse.js +++ b/module/productplan/js/browse.js @@ -55,6 +55,6 @@ $(document).on('click', 'td.content .more', function(e) */ function getPlanID(obj) { - var planID = $(obj).attr("data-id") + var planID = $(obj).attr("data-id"); $('#planID').val(planID); } diff --git a/module/program/control.php b/module/program/control.php index c4afbdf693..39bc9908a6 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -1059,18 +1059,35 @@ class program extends control */ public function PRJBatchEdit($from = 'prjbrowse', $programID = 0) { + /* Navigation stay in program when enter from program list. */ if($from == 'pgmproject') { $this->app->rawMethod = 'pgmproject'; $this->lang->program->switcherMenu = $this->program->getPGMSwitcher($programID, true); $this->program->setPGMViewMenu($programID); } - if($from == 'prjbrowse') { $this->lang->program->menu = $this->lang->PRJ->menu; } + if($this->post->names) + { + $allChanges = $this->program->PRJBatchUpdate(); + + if(!empty($allChanges)) + { + foreach($allChanges as $projectID => $changes) + { + if(empty($changes)) continue; + + $actionID = $this->loadModel('action')->create('project', $projectID, 'Edited'); + $this->action->logHistory($actionID, $changes); + } + } + die(js::locate($this->session->projectList, 'parent')); + } + $projectIdList = $this->post->projectIdList ? $this->post->projectIdList : die(js::locate($this->session->projectList, 'parent')); $projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($projectIdList)->fetchAll('id'); @@ -1831,6 +1848,7 @@ class program extends control */ public function ajaxCheckProduct($programID, $projectID) { + /* Set vars. */ $project = $this->program->getPRJByID($projectID); $oldTopPGM = $this->program->getTopPGMByID($project->parent); $newTopPGM = $this->program->getTopPGMByID($programID); diff --git a/module/program/js/prjbatchedit.js b/module/program/js/prjbatchedit.js new file mode 100644 index 0000000000..14f1289a68 --- /dev/null +++ b/module/program/js/prjbatchedit.js @@ -0,0 +1,53 @@ +$(function() +{ + $("select[name^='parents']").change(function() + { + var $this = $(this); + var programID = $this.val(); + var projectID = $this.attr("data-id"); + var oldParent = $this.attr("data-parent"); + var title = changeProgram.replace('%s', $this.attr("data-name")); + + /* Determine whether the project can change the program set. */ + link = createLink('program', 'ajaxCheckProduct', 'programID=' + programID + '&projectID=' + projectID); + $.getJSON(link, function(data) + { + var changed = true; + + if(data && data.result) + { + changed = confirm(data.message); + } + + if(data && !data.result) + { + $('#promptTable tbody tr').remove(); + $('.modal-title').text(title); + for(var i in data.message) + { + var product = data.message[i]; + $('#promptTable').append("
" + project +"
"; + } + $('#promptTable').append("