diff --git a/module/productplan/model.php b/module/productplan/model.php
index 758298a47c..dc2d5e2ed6 100644
--- a/module/productplan/model.php
+++ b/module/productplan/model.php
@@ -108,6 +108,7 @@ class productplanModel extends model
* Get plan pairs.
*
* @param array|int $product
+ * @param int $branch
* @param string $expired
* @access public
* @return array
@@ -140,7 +141,41 @@ class productplanModel extends model
{
$plans[$key] = str_replace('[2030-01-01 ~ 2030-01-01]', '[' . $this->lang->productplan->future . ']', $value);
}
- return array('' => '') + $plans;
+ return array('' => '') + $this->processFuture($plans);
+ }
+
+ /**
+ * Get plan pairs for story.
+ *
+ * @param array|int $product
+ * @param int $branch
+ * @access public
+ * @return array
+ */
+ public function getPairsForStory($product = 0, $branch = 0)
+ {
+ $date = date('Y-m-d');
+ $plans = $this->dao->select('id, CONCAT(title, " [", begin, " ~ ", end, "]") AS title')->from(TABLE_PRODUCTPLAN)
+ ->where('product')->in($product)
+ ->andWhere('deleted')->eq(0)
+ ->andWhere('end')->ge($date)
+ ->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
+ ->orderBy('begin desc')
+ ->fetchPairs();
+
+ if(!$plans)
+ {
+ $plans = $this->dao->select('id, CONCAT(title, " [", begin, " ~ ", end, "]") AS title')->from(TABLE_PRODUCTPLAN)
+ ->where('product')->in($product)
+ ->andWhere('deleted')->eq(0)
+ ->andWhere('end')->lt($date)
+ ->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
+ ->orderBy('begin desc')
+ ->limit(5)
+ ->fetchPairs();
+ }
+
+ return array('' => '') + $this->processFuture($plans);
}
/**
@@ -369,4 +404,20 @@ class productplanModel extends model
$this->dao->update(TABLE_BUG)->set('plan')->eq(0)->where('id')->eq((int)$bugID)->exec();
$this->loadModel('action')->create('bug', $bugID, 'unlinkedfromplan', '', $planID);
}
+
+ /**
+ * Process future of plans.
+ *
+ * @param array $plans
+ * @access public
+ * @return array
+ */
+ public function processFuture($plans)
+ {
+ foreach($plans as $key => $value)
+ {
+ $plans[$key] = str_replace('[2030-01-01 ~ 2030-01-01]', '[' . $this->lang->productplan->future . ']', $value);
+ }
+ return $plans;
+ }
}
diff --git a/module/productplan/view/browse.html.php b/module/productplan/view/browse.html.php
index 966593f1f1..2ad8f26266 100644
--- a/module/productplan/view/browse.html.php
+++ b/module/productplan/view/browse.html.php
@@ -99,7 +99,7 @@
if(common::hasPriv('productplan', 'delete', $plan))
{
$deleteURL = $this->createLink('productplan', 'delete', "planID=$plan->id&confirm=yes");
- echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"productplan\",confirmDelete)", '', '', "class='btn btn-icon' title='{$lang->productplan->delete}'");
+ echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"productplanList\",confirmDelete)", '', '', "class='btn btn-icon' title='{$lang->productplan->delete}'");
}
?>
diff --git a/module/story/control.php b/module/story/control.php
index 16c33b02f6..f9c4beeeef 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -238,7 +238,7 @@ class story extends control
$this->view->users = $users;
$this->view->moduleID = $moduleID;
$this->view->moduleOptionMenu = $moduleOptionMenu;
- $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $branch, 'unexpired');
+ $this->view->plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch);
$this->view->planID = $planID;
$this->view->source = $source;
$this->view->sourceNote = $sourceNote;
@@ -327,7 +327,7 @@ class story extends control
}
$moduleOptionMenu['ditto'] = $this->lang->story->ditto;
- $plans = $this->loadModel('productplan')->getPairs($productID, $branch, 'unexpired');
+ $plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch);
$plans['ditto'] = $this->lang->story->ditto;
$priList = (array)$this->lang->story->priList;
$priList['ditto'] = $this->lang->story->ditto;
diff --git a/www/js/my.full.js b/www/js/my.full.js
index 672ecbe3f4..3a94fc911d 100644
--- a/www/js/my.full.js
+++ b/www/js/my.full.js
@@ -337,7 +337,7 @@ function ajaxDelete(url, replaceID, notice)
$('#' + replaceID).html($(data).find('#' + replaceID).html());
if(typeof sortTable == 'function') sortTable();
$('#' + replaceID).find('[data-toggle=modal], a.iframe').modalTrigger();
- $('#' + replaceID).find('table.datatable').datatable();
+ if($('#' + replaceID).find('table.datatable').length) $('#' + replaceID).find('table.datatable').datatable();
});
}
}