+ add the feature of delete and view to product.

This commit is contained in:
wangchunsheng
2010-04-10 14:50:59 +00:00
parent b73c1c8349
commit 1b282d497d
10 changed files with 104 additions and 25 deletions

View File

@@ -28,11 +28,16 @@ class action extends control
{
/* 登记session。*/
$uri = $this->app->getURI(true);
$this->session->set('bugList', $uri);
$this->session->set('caseList', $uri);
$this->session->set('storyList', $uri);
$this->session->set('taskList', $uri);
$this->session->set('buildList', $uri);
$this->session->set('productList', $uri);
$this->session->set('productPlanList', $uri);
$this->session->set('releaseList', $uri);
$this->session->set('storyList', $uri);
$this->session->set('projectList', $uri);
$this->session->set('taskList', $uri);
$this->session->set('buildList', $uri);
$this->session->set('bugList', $uri);
$this->session->set('caseList', $uri);
$this->session->set('testtaskList', $uri);
/* 设置标题和导航条。*/
$this->view->header->title = $this->lang->action->trash;

View File

@@ -30,7 +30,7 @@ class build extends control
{
$buildID = $this->build->create($projectID);
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action')->create('build', $buildID, 'Opened');
$this->loadModel('action')->create('build', $buildID, 'opened');
die(js::locate($this->createLink('project', 'build', "project=$projectID"), 'parent'));
}

View File

@@ -104,6 +104,7 @@ $lang->product->menu->story = array('link' => '需求列表|product|browse|prod
$lang->product->menu->plan = array('link' => '计划列表|productplan|browse|productID=%s', 'subModule' => 'productplan');
$lang->product->menu->release= array('link' => '发布列表|release|browse|productID=%s', 'subModule' => 'release');
$lang->product->menu->roadmap= '路线图|product|roadmap|productID=%s';
$lang->product->menu->view = '基本信息|product|view|productID=%s';
$lang->product->menu->edit = '编辑产品|product|edit|productID=%s';
$lang->product->menu->module = '维护模块|tree|browse|productID=%s&view=product';
$lang->product->menu->delete = array('link' => '删除产品|product|delete|productID=%s', 'target' => 'hiddenwin');

View File

@@ -74,6 +74,7 @@ $lang->resource->todo->import2Today = 'import2Today';
$lang->resource->product->index = 'index';
$lang->resource->product->browse = 'browse';
$lang->resource->product->create = 'create';
$lang->resource->product->view = 'view';
$lang->resource->product->edit = 'edit';
$lang->resource->product->delete = 'delete';
$lang->resource->product->roadmap= 'roadmap';

View File

@@ -38,7 +38,7 @@ class product extends control
/* 获取所有的产品列表。如果还没有产品,则跳转到产品的添加页面。*/
$this->products = $this->product->getPairs();
if(empty($this->products) and $this->methodName != 'create') $this->locate($this->createLink('product', 'create'));
if(empty($this->products) and strpos('create|view', $this->methodName) === false) $this->locate($this->createLink('product', 'create'));
$this->assign('products', $this->products);
}
@@ -60,7 +60,8 @@ class product extends control
$browseType = strtolower($browseType);
/* 设置当前的产品id和模块id。*/
$this->session->set('storyList', $this->app->getURI(true));
$this->session->set('storyList', $this->app->getURI(true));
$this->session->set('productList', $this->app->getURI(true));
$productID = common::saveProductState($productID, key($this->products));
$moduleID = ($browseType == 'bymodule') ? (int)$param : 0;
@@ -113,6 +114,7 @@ class product extends control
{
$productID = $this->product->create();
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action')->create('product', $productID, 'opened');
die(js::locate($this->createLink($this->moduleName, 'browse', "productID=$productID"), 'parent'));
}
@@ -129,9 +131,11 @@ class product extends control
{
if(!empty($_POST))
{
$this->product->update($productID);
$changes = $this->product->update($productID);
if(dao::isError()) die(js::error(dao::getError()));
die(js::locate($this->createLink('product', 'browse', "product=$productID"), 'parent'));
$actionID = $this->loadModel('action')->create('product', $productID, 'edited');
$this->action->logHistory($actionID, $changes);
die(js::locate(inlink('view', "product=$productID"), 'parent'));
}
/* 设置菜单。*/
@@ -146,19 +150,35 @@ class product extends control
$this->display();
}
/* 查看详情。*/
public function view($productID)
{
/* 设置菜单。*/
$this->product->setMenu($this->products, $productID);
$product = $this->dao->findById($productID)->from(TABLE_PRODUCT)->fetch();
$this->view->header->title = $this->lang->product->view . $this->lang->colon . $product->name;
$this->view->position[] = html::a($this->createLink($this->moduleName, 'browse'), $product->name);
$this->view->position[] = $this->lang->product->view;
$this->view->product = $product;
$this->view->actions = $this->loadModel('action')->getList('product', $productID);
$this->view->users = $this->user->getPairs();
$this->display();
}
/* 删除产品。*/
public function delete($productID, $confirm = 'no')
{
if($confirm == 'no')
{
echo js::confirm($this->lang->product->confirmDelete, $this->createLink('product', 'delete', "productID=$productID&confirm=yes"));
exit;
die(js::confirm($this->lang->product->confirmDelete, $this->createLink('product', 'delete', "productID=$productID&confirm=yes")));
}
else
{
$this->product->delete($productID);
echo js::locate($this->createLink('product', 'browse'), 'parent');
exit;
$this->product->delete(TABLE_PRODUCT, $productID);
$this->session->set('product', ''); // 清除session。
die(js::locate($this->createLink('product', 'browse'), 'parent'));
}
}

View File

@@ -24,6 +24,7 @@
$lang->product->common = '产品视图';
$lang->product->index = "产品首页";
$lang->product->browse = "浏览产品";
$lang->product->view = "产品信息";
$lang->product->edit = "编辑产品";
$lang->product->create = "新增产品";
$lang->product->read = "产品详情";

View File

@@ -53,13 +53,13 @@ class productModel extends model
/* <20><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD>б<EFBFBD><D0B1><EFBFBD>*/
public function getList()
{
return $this->dao->select('*')->from(TABLE_PRODUCT)->where('company')->eq($this->app->company->id)->fetchAll('id');
return $this->dao->select('*')->from(TABLE_PRODUCT)->where('deleted')->eq(0)->fetchAll('id');
}
/* <20><>ȡ<EFBFBD><C8A1>Ʒid=>name<6D>б<EFBFBD><D0B1><EFBFBD>*/
public function getPairs()
{
return $this->dao->select('id,name')->from(TABLE_PRODUCT)->where('company')->eq($this->app->company->id)->fetchPairs();
return $this->dao->select('id,name')->from(TABLE_PRODUCT)->where('deleted')->eq(0)->fetchPairs();
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>*/
@@ -86,6 +86,7 @@ class productModel extends model
{
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>*/
$productID = (int)$productID;
$oldProduct = $this->getById($productID);
$product = fixer::input('post')
->stripTags('name,code')
->specialChars('desc')
@@ -98,14 +99,9 @@ class productModel extends model
->check('code', 'unique', "id != $productID")
->where('id')->eq($productID)
->exec();
if(!dao::isError()) return common::createChanges($oldProduct, $product);
}
/* ɾ<><C9BE>ijһ<C4B3><D2BB><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>*/
public function delete($productID)
{
return $this->dao->delete()->from(TABLE_PRODUCT)->where('id')->eq((int)$productID)->andWhere('company')->eq($this->app->company->id)->limit(1)->exec();
}
/* <20><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>Ŀid=>value<75>б<EFBFBD><D0B1><EFBFBD>*/
public function getProjectPairs($productID)
{

View File

@@ -25,7 +25,7 @@
<?php include '../../common/view/header.html.php';?>
<div class='yui-d0'>
<form method='post' target='hiddenwin'>
<table align='center' class='table-4'>
<table class='table-1'>
<caption><?php echo $lang->product->create;?></caption>
<tr>
<th class='rowhead'><?php echo $lang->product->name;?></th>

View File

@@ -25,7 +25,7 @@
<?php include '../../common/view/header.html.php';?>
<div class='yui-d0'>
<form method='post' target='hiddenwin'>
<table align='center' class='table-4'>
<table align='center' class='table-1'>
<caption><?php echo $lang->product->edit;?></caption>
<tr>
<th class='rowhead'><?php echo $lang->product->name;?></th>

View File

@@ -0,0 +1,55 @@
<?php
/**
* The view view of product module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2009-2010 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package product
* @version $Id$
* @link http://www.zentao.cn
*/
?>
<?php include '../../common/view/header.html.php';?>
<div class='yui-d0'>
<table align='center' class='table-1'>
<caption><?php echo $lang->product->view;?></caption>
<tr>
<th class='rowhead'><?php echo $lang->product->name;?></th>
<td <?php if($product->deleted) echo "class='deleted'";?>><?php echo $product->name;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->code;?></th>
<td><?php echo $product->code;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->desc;?></th>
<td><?php echo nl2br($product->desc);?></td>
</tr>
</table>
<div class='a-center f-16px strong'>
<?php
$browseLink = $this->session->productList ? $this->session->productList : inlink('browse', "productID=$product->id");
if(!$product->deleted)
{
common::printLink('product', 'edit', "productID=$product->id", $lang->edit);
common::printLink('product', 'delete', "productID=$product->id", $lang->delete, 'hiddenwin');
}
echo html::a($browseLink, $lang->goback);
?>
</div>
<?php include '../../common/view/action.html.php';?>
</div>
<?php include '../../common/view/footer.html.php';?>