diff --git a/trunk/module/productplan/control.php b/trunk/module/productplan/control.php
index 82cf05c3c2..ff9bc561c6 100644
--- a/trunk/module/productplan/control.php
+++ b/trunk/module/productplan/control.php
@@ -37,8 +37,9 @@ class productplan extends control
{
if(!empty($_POST))
{
- $this->productplan->create();
+ $planID = $this->productplan->create();
if(dao::isError()) die(js::error(dao::getError()));
+ $this->loadModel('action')->create('productplan', $planID, 'opened');
die(js::locate($this->createLink('productplan', 'browse', "product=$product"), 'parent'));
}
@@ -53,9 +54,11 @@ class productplan extends control
{
if(!empty($_POST))
{
- $this->productplan->update($planID);
+ $changes = $this->productplan->update($planID);
if(dao::isError()) die(js::error(dao::getError()));
- die(js::locate($this->createLink('productplan', 'browse', "product={$this->post->product}"), 'parent'));
+ $actionID = $this->loadModel('action')->create('productplan', $planID, 'edited');
+ $this->action->logHistory($actionID, $changes);
+ die(js::locate(inlink('view', "planID=$planID"), 'parent'));
}
$plan = $this->productplan->getByID($planID);
@@ -76,16 +79,16 @@ class productplan extends control
else
{
$plan = $this->productplan->getById($planID);
- $this->productplan->delete($planID);
- die(js::locate($this->createLink('productplan', 'browse', "productID=$plan->product"), 'parent'));
+ $this->productplan->delete(TABLE_PRODUCTPLAN, $planID);
+ die(js::locate(inlink('browse', "productID=$plan->product"), 'parent'));
}
}
/* 浏览计划列表。*/
public function browse($product = 0)
{
+ $this->session->set('productPlanList', $this->app->getURI(true));
$this->commonAction($product);
-
$this->view->header->title = $this->lang->productplan->browse;
$this->view->position[] = $this->lang->productplan->browse;
$this->view->plans = $this->productplan->getList($product);
@@ -97,12 +100,15 @@ class productplan extends control
{
$this->session->set('storyList', $this->app->getURI(true));
$plan = $this->productplan->getByID($planID);
+ if(!$plan) die(js::error($this->lang->notFound) . js::locate('back'));
$this->commonAction($plan->product);
$this->view->header->title = $this->lang->productplan->view;
$this->view->position[] = $this->lang->productplan->view;
$this->view->planStories= $this->loadModel('story')->getPlanStories($planID);
$this->view->products = $this->product->getPairs();
$this->view->plan = $plan;
+ $this->view->actions = $this->loadModel('action')->getList('productplan', $planID);
+ $this->view->users = $this->loadModel('user')->getPairs();
$this->display();
}
diff --git a/trunk/module/productplan/model.php b/trunk/module/productplan/model.php
index f19acc8ee7..16536ee242 100644
--- a/trunk/module/productplan/model.php
+++ b/trunk/module/productplan/model.php
@@ -34,13 +34,18 @@ class productplanModel extends model
/* 获取列表。*/
public function getList($product = 0)
{
- return $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('product')->eq($product)->orderBy('begin')->fetchAll();
+ return $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('product')->eq($product)
+ ->andWhere('deleted')->eq(0)
+ ->orderBy('begin')->fetchAll();
}
/* 获取name=>value的键值对。*/
public function getPairs($product = 0)
{
- return array('' => '') + $this->dao->select('id,title')->from(TABLE_PRODUCTPLAN)->where('product')->eq((int)$product)->orderBy('begin')->fetchPairs();
+ return array('' => '') + $this->dao->select('id,title')->from(TABLE_PRODUCTPLAN)
+ ->where('product')->eq((int)$product)
+ ->andWhere('deleted')->eq(0)
+ ->orderBy('begin')->fetchPairs();
}
/* 创建。*/
@@ -57,17 +62,14 @@ class productplanModel extends model
/* 编辑。*/
public function update($planID)
{
+ $oldPlan = $this->getById($planID);
$plan = fixer::input('post')
->stripTags('title')
->specialChars('desc')
->get();
$this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->batchCheck($this->config->productplan->edit->requiredFields, 'notempty')->where('id')->eq((int)$planID)->exec();
- }
+ if(!dao::isError()) return common::createChanges($oldPlan, $plan);
- /* 删除计划。*/
- public function delete($planID)
- {
- return $this->dao->delete()->from(TABLE_PRODUCTPLAN)->where('id')->eq((int)$planID)->exec();
}
/* 关联需求。*/
diff --git a/trunk/module/productplan/view/browse.html.php b/trunk/module/productplan/view/browse.html.php
index 0eccbc1012..5b4a3c1907 100644
--- a/trunk/module/productplan/view/browse.html.php
+++ b/trunk/module/productplan/view/browse.html.php
@@ -32,11 +32,11 @@
-
productplan->title;?>
+ productplan->title;?>
productplan->begin;?>
productplan->end;?>
productplan->desc;?>
- actions;?>
+ actions;?>
| productplan->id;?> | -id;?> - | |
|---|---|---|
| productplan->title;?> | -title;?> + | deleted) echo "class='deleted'";?>>title;?> |
| productplan->begin;?> | @@ -48,6 +44,19 @@desc);?> |