* add actions of product.

This commit is contained in:
zhujinyong
2013-01-17 02:51:47 +00:00
parent bd9b503eba
commit e22e3a3b7f
4 changed files with 103 additions and 0 deletions
+34
View File
@@ -220,6 +220,40 @@ class product extends control
$this->display();
}
/**
* Close product.
*
* @param int $productID
* @access public
* @return void
*/
public function close($productID)
{
$product = $this->product->getById($productID);
$actions = $this->loadModel('action')->getList('product', $productID);
if(!empty($_POST))
{
$changes = $this->product->close($productID);
if(dao::isError()) die(js::error(dao::getError()));
if($this->post->comment != '' or !empty($changes))
{
$actionID = $this->action->create('product', $productID, 'Closed', $this->post->comment);
$this->action->logHistory($actionID, $changes);
}
die(js::locate($this->createLink('product', 'view', "productID=$productID"), 'parent'));
}
$this->product->setMenu($this->products, $productID);
$this->view->product = $product;
$this->view->header->title = $this->view->product->name . $this->lang->colon .$this->lang->close;
$this->view->position[] = $this->lang->close;
$this->view->actions = $actions;
$this->display();
}
/**
* View a product.
*
+40
View File
@@ -286,6 +286,29 @@ class productModel extends model
if(!dao::isError()) return common::createChanges($oldProduct, $product);
}
/**
* Close product.
*
* @param int $productID.
* @access public
* @return void
*/
public function close($productID)
{
$oldProduct = $this->getById($productID);
$now = helper::now();
$product= fixer::input('post')
->setDefault('status', 'closed')
->remove('comment')->get();
$this->dao->update(TABLE_PRODUCT)->data($product)
->autoCheck()
->where('id')->eq((int)$productID)
->exec();
if(!dao::isError()) return common::createChanges($oldProduct, $product);
}
/**
* Get projects of a product in pairs.
*
@@ -566,4 +589,21 @@ class productModel extends model
foreach($stories as $key => $story) $totalEstimate += $story->estimate;
return sprintf($this->lang->product->storySummary, count($stories), $totalEstimate);
}
/**
* Judge an action is clickable or not.
*
* @param object $product
* @param string $action
* @access public
* @return void
*/
public function isClickable($product, $action)
{
$action = strtolower($action);
if($action == 'close') return $product->status != 'closed';
return true;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* The close file of project module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Chunsheng Wang<wwccss@gmail.com>
* @package product
* @version $Id: close.html.php 935 2013-01-16 07:49:24Z wwccss@gmail.com $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<form method='post' target='hiddenwin'>
<table class='table-1'>
<caption><?php echo $product->name;?></caption>
<tr>
<td class='rowhead'><?php echo $lang->comment;?></td>
<td><?php echo html::textarea('comment', '', "rows='6' class='area-1'");?></td>
</tr>
<tr>
<td colspan='2' class='a-center'><?php echo html::submitButton() . html::linkButton($lang->goback, $this->session->taskList); ?></td>
</tr>
</table>
<?php include '../../common/view/action.html.php';?>
</form>
<?php include '../../common/view/footer.html.php';?>
+2
View File
@@ -20,6 +20,8 @@
if(!$product->deleted)
{
ob_start();
common::printIcon('product', 'close', "productID=$product->id", $product);
common::printDivider();
common::printIcon('product', 'edit', $params);
common::printIcon('product', 'delete', $params, '', 'button', '', 'hiddenwin');