From d5bee55d085e42158ff2041e03834552fafa1d20 Mon Sep 17 00:00:00 2001 From: "shiyangyangwork@yahoo.cn" Date: Tue, 21 Feb 2012 04:26:11 +0000 Subject: [PATCH] * finish task #713. --- module/product/config.php | 2 +- module/product/control.php | 19 ++++++++++++++++++ module/product/model.php | 22 +++++++++++++++++--- module/product/view/order.html.php | 32 ++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 module/product/view/order.html.php diff --git a/module/product/config.php b/module/product/config.php index a1cf8c4ae7..2f678f5b03 100644 --- a/module/product/config.php +++ b/module/product/config.php @@ -1,5 +1,5 @@ product->orderBy = 'code'; +$config->product->orderBy = 'isClosed, `order`'; global $lang, $app; $app->loadLang('story'); diff --git a/module/product/control.php b/module/product/control.php index 1831128a11..0f55d60157 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -350,6 +350,25 @@ class product extends control $this->display(); } + /** + * order product + * + * @param int $productID + * @access public + * @return void + */ + public function order($productID) + { + if($_POST) + { + $this->product->saveOrder(); + die(js::reload('parent')); + } + $this->product->setMenu($this->products, $productID); + $this->view->products = $this->product->getList('noclosed'); + $this->display(); + } + /** * AJAX: get projects of a product in html select. * diff --git a/module/product/model.php b/module/product/model.php index 3ea298c7e8..f326fec5c6 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -91,6 +91,20 @@ class productModel extends model return $this->session->product; } + /** + * Save order + * + * @access public + * @return void + */ + public function saveOrder() + { + foreach($_POST as $productID => $order) + { + $this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($order)->where('id')->eq($productID)->exec(); + } + } + /** * Check privilege. * @@ -154,8 +168,10 @@ class productModel extends model { return $this->dao->select('*')->from(TABLE_PRODUCT) ->where('deleted')->eq(0) - ->beginIF($status != 'all')->andWhere('status')->in($status)->fi() + ->beginIF($status = 'noclosed')->andWhere('status')->ne('closed')->fi() + ->beginIF($status != 'all' and $status != 'noclosed')->andWhere('status')->in($status)->fi() ->beginIF($limit > 0)->limit($limit)->fi() + ->orderBy('`order` asc') ->fetchAll('id'); } @@ -167,9 +183,9 @@ class productModel extends model */ public function getPairs($mode = '') { - $orderBy = !empty($this->config->product->orderBy) ? $this->config->product->orderBy : 'code'; + $orderBy = !empty($this->config->product->orderBy) ? $this->config->product->orderBy : 'isClosed, `order`'; $mode .= $this->cookie->productMode; - $products = $this->dao->select('*') + $products = $this->dao->select('*, IF(INSTR(" closed", status) < 2, 0, 1) AS isClosed') ->from(TABLE_PRODUCT) ->where('deleted')->eq(0) ->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() diff --git a/module/product/view/order.html.php b/module/product/view/order.html.php new file mode 100644 index 0000000000..e7e970b9c9 --- /dev/null +++ b/module/product/view/order.html.php @@ -0,0 +1,32 @@ + + * @package product + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+ + + + + + + + + + + + + + +
product->id?>product->name?>product->order?>
id?>name?>id, $product->order, "size='5'")?>
+
+ +