diff --git a/module/productplan/control.php b/module/productplan/control.php index 24b3c4575d..0cf55fc312 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -115,9 +115,12 @@ class productplan extends control } $plan = $this->productplan->getByID($planID); + $oldBranch = array(); + $oldBranch[$planID] = $plan->branch; $this->commonAction($plan->product, $plan->branch); $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->edit; $this->view->position[] = $this->lang->productplan->edit; + $this->view->oldBranch = $oldBranch; $this->view->plan = $plan; $this->display(); } @@ -135,18 +138,26 @@ class productplan extends control { if(isset($_POST['planIDList'])) { + $this->commonAction($productID, $branch); $this->view->title = $this->lang->productplan->batchEdit; $this->view->position[] = html::a(inlink('browse', "productID=$productID&branch=$branch"), $this->lang->productplan->common); $this->view->position[] = $this->lang->productplan->batchEdit; - $this->view->plans = $this->productplan->getByIDList($this->post->planIDList); + $plans = $this->productplan->getByIDList($this->post->planIDList); + $this->view->plans = $plans; + $oldBranch = array(); + foreach($plans as $plan) $oldBranch[$plan->id] = $plan->branch; + $this->view->oldBranch = $oldBranch; + + $product = $this->loadModel('product')->getById($productID); + $this->view->branchProduct = $product->type == 'normal' ? false : true; die($this->display()); } elseif($_POST) { $changes = $this->productplan->batchUpdate($productID); - $this->productplan->synchronizeStory($changes); + $this->synchronizeStory($changes); $this->loadModel('action'); foreach($changes as $planID => $change) { @@ -686,6 +697,7 @@ class productplan extends control } } $oldBranch = ''; + $newBranch = ''; } } /** @@ -696,8 +708,10 @@ class productplan extends control * @access public * @return void */ - public function ajaxGetConflictStory($planID, $oldBranch, $newBranch) + public function ajaxGetConflictStory($planID, $newBranch) { + $plan = $this->productplan->getByID($planID); + $oldBranch = $plan->branch; $planStories = $this->loadModel('story')->getPlanStories($planID, 'all'); $conflictStoryIdList = ''; if($oldBranch) diff --git a/module/productplan/js/batchedit.js b/module/productplan/js/batchedit.js index e880766b68..2b3d99fa98 100644 --- a/module/productplan/js/batchedit.js +++ b/module/productplan/js/batchedit.js @@ -24,3 +24,15 @@ function changeDate(planID) $('.form-date').datetimepicker('update'); } }; +function loadWarning(planID, branch) +{ + $.get(createLink('productplan', 'ajaxGetConflictStory', 'planID=' + planID + '&newBranch=' + branch), function(conflictStories) + { + if(conflictStories != '' && !confirm(conflictStories)) + { + console.log('yes'); + $('#branch' + planID).val(oldBranch[planID]); + $('#branch' + planID).trigger("chosen:updated"); + } + }); +} diff --git a/module/productplan/js/edit.js b/module/productplan/js/edit.js index faa69a78ec..bc4c1d7387 100644 --- a/module/productplan/js/edit.js +++ b/module/productplan/js/edit.js @@ -12,11 +12,15 @@ function convertStringToDate(dateString) return Date.parse(dateString); } -function loadWarning(branch) +function loadWarning(planID, branch) { - $.get(createLink('productplan', 'ajaxGetConflictStory', 'planID=' + planID + '&oldBranch=' + oldBranch + '&newBranch=' + branch), function(conflictStories) + $.get(createLink('productplan', 'ajaxGetConflictStory', 'planID=' + planID + '&newBranch=' + branch), function(conflictStories) { - if(conflictStories != '') alert(conflictStories); + if(conflictStories != '' && !confirm(conflictStories)) + { + $('#branch').val(oldBranch[planID]); + $('#branch').trigger("chosen:updated"); + } }); } diff --git a/module/productplan/js/tags b/module/productplan/js/tags new file mode 100644 index 0000000000..7a813faef5 --- /dev/null +++ b/module/productplan/js/tags @@ -0,0 +1,16 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ +!_TAG_PROGRAM_NAME Exuberant Ctags // +!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ +!_TAG_PROGRAM_VERSION 5.9~svn20110310 // +changeDate batchedit.js /^function changeDate(planID)$/;" f +computeEndDate create.js /^function computeEndDate(delta)$/;" f +computeEndDate edit.js /^function computeEndDate(delta)$/;" f +convertStringToDate create.js /^function convertStringToDate(dateString)$/;" f +convertStringToDate edit.js /^function convertStringToDate(dateString)$/;" f +getPlanID browse.js /^function getPlanID(obj, branch)$/;" f +loadURL view.js /^function loadURL(url, type)$/;" f +loadWarning batchedit.js /^function loadWarning(planID, branch)$/;" f +loadWarning edit.js /^function loadWarning(planID, branch)$/;" f +showLink view.js /^function showLink(planID, type, orderBy, param)$/;" f diff --git a/module/productplan/model.php b/module/productplan/model.php index ca62b7a040..6b785c3e2a 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -501,10 +501,11 @@ class productplanModel extends model foreach($data->id as $planID) { $plan = new stdclass(); - $plan->title = $data->title[$planID]; - $plan->desc = $purifier->purify($data->desc[$planID]); - $plan->begin = $data->begin[$planID]; - $plan->end = $data->end[$planID]; + $plan->branch = $data->branch[$planID]; + $plan->title = $data->title[$planID]; + $plan->desc = $purifier->purify($data->desc[$planID]); + $plan->begin = $data->begin[$planID]; + $plan->end = $data->end[$planID]; if(empty($plan->title))die(js::alert(sprintf($this->lang->productplan->errorNoTitle, $planID))); if(empty($plan->begin))die(js::alert(sprintf($this->lang->productplan->errorNoBegin, $planID))); diff --git a/module/productplan/view/batchedit.html.php b/module/productplan/view/batchedit.html.php index 0a44dd63c1..8a6f0e3235 100644 --- a/module/productplan/view/batchedit.html.php +++ b/module/productplan/view/batchedit.html.php @@ -12,6 +12,7 @@ ?> +