From e22e3a3b7ff2badc22bc33887d02bfb6d92f8764 Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Thu, 17 Jan 2013 02:51:47 +0000 Subject: [PATCH] * add actions of product. --- module/product/control.php | 34 +++++++++++++++++++++++++ module/product/model.php | 40 ++++++++++++++++++++++++++++++ module/product/view/close.html.php | 27 ++++++++++++++++++++ module/product/view/view.html.php | 2 ++ 4 files changed, 103 insertions(+) create mode 100644 module/product/view/close.html.php diff --git a/module/product/control.php b/module/product/control.php index d4f969b7bd..70654fe0e2 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -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. * diff --git a/module/product/model.php b/module/product/model.php index 68b86e65eb..bf0ba27d52 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -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; + } } diff --git a/module/product/view/close.html.php b/module/product/view/close.html.php new file mode 100644 index 0000000000..b56c8d5b58 --- /dev/null +++ b/module/product/view/close.html.php @@ -0,0 +1,27 @@ + + * @package product + * @version $Id: close.html.php 935 2013-01-16 07:49:24Z wwccss@gmail.com $ + * @link http://www.zentao.net + */ +?> + +
+ + + + + + + + + +
name;?>
comment;?>
goback, $this->session->taskList); ?>
+ +
+ diff --git a/module/product/view/view.html.php b/module/product/view/view.html.php index ff65577f7c..45f752c27f 100644 --- a/module/product/view/view.html.php +++ b/module/product/view/view.html.php @@ -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');