diff --git a/api/v1/entries/executions.php b/api/v1/entries/executions.php index 41de1524eb..720df0e3a7 100644 --- a/api/v1/entries/executions.php +++ b/api/v1/entries/executions.php @@ -21,7 +21,7 @@ class executionsEntry extends entry public function get($projectID = 0) { $control = $this->loadController('execution', 'all'); - $control->all($this->param('status', 'all'), $this->param('project', $projectID), $this->param('order', 'id_desc'), 0, $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1)); + $control->all($this->param('status', 'all'), $this->param('project', $projectID), $this->param('order', 'id_desc'), 0, 0, $this->param('limit', 20), $this->param('page', 1)); $data = $this->getData(); if(isset($data->status) and $data->status == 'success') diff --git a/api/v1/entries/program.php b/api/v1/entries/program.php index f423487ef4..17a023d90b 100644 --- a/api/v1/entries/program.php +++ b/api/v1/entries/program.php @@ -9,6 +9,6 @@ * @version 1 * @link http://www.zentao.net */ -class ProgramEntry extends Entry +class programEntry extends Entry { } diff --git a/api/v1/entries/user.php b/api/v1/entries/user.php index 37dc570bae..030090ba3e 100644 --- a/api/v1/entries/user.php +++ b/api/v1/entries/user.php @@ -66,7 +66,17 @@ class userEntry extends Entry case 'product': $info->product = array('total' => 0, 'products' => array()); - $products = $this->my->getProducts(); + $products = $this->my->getProducts('ownbyme'); + if($products) + { + $info->product['total'] = $products->allCount; + $info->product['products'] = $products->products; + } + break; + case 'undoneproduct': + $info->product = array('total' => 0, 'products' => array()); + + $products = $this->my->getProducts('undone'); if($products) { $info->product['total'] = $products->allCount; diff --git a/module/my/model.php b/module/my/model.php index c79c0c1551..da415df6a8 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -60,14 +60,17 @@ class myModel extends model /** * Get my charged products. * + * @param string $type undone|ownbyme * @access public * @return object */ - public function getProducts() + public function getProducts($type = 'undone') { $products = $this->dao->select('t1.id as id,t1.*')->from(TABLE_PRODUCT)->alias('t1') ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id') ->where('t1.deleted')->eq(0) + ->beginIF($type == 'undone')->andWhere('t1.status')->eq('normal')->fi() + ->beginIF($type == 'ownbyme')->andWhere('t1.PO')->eq($this->app->user->account)->fi() ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi() ->orderBy('t1.order_asc') ->fetchAll('id'); @@ -121,10 +124,11 @@ class myModel extends model ->andWhere('t2.deleted')->eq(0) ->orderBy('t1.project') ->fetchAll('product'); - foreach($executions as $key => $execuData) + $this->loadModel('execution'); + foreach($executions as $productID => $execution) { - $execution = $this->loadModel('execution')->getById($execuData->id); - $executions[$key]->progress = ($execution->totalConsumed + $execution->totalLeft) ? floor($execution->totalConsumed / ($execution->totalConsumed + $execution->totalLeft) * 1000) / 1000 * 100 : 0; + $execution = $this->execution->getById($execution->id); + $executions[$productID]->progress = ($execution->totalConsumed + $execution->totalLeft) ? floor($execution->totalConsumed / ($execution->totalConsumed + $execution->totalLeft) * 1000) / 1000 * 100 : 0; } $allCount = count($products); @@ -139,6 +143,7 @@ class myModel extends model $product->storyFinishedTotal = isset($summaryStories[$product->id]) ? $summaryStories[$product->id]->finishedTotal : 0; $product->storyLeftTotal = isset($summaryStories[$product->id]) ? $summaryStories[$product->id]->leftTotal : 0; $product->storyFinishedRate = isset($summaryStories[$product->id]) ? $summaryStories[$product->id]->finishedRate : 0; + $product->latestExecution = isset($executions[$product->id]) ? $executions[$product->id] : ''; if($product->status != 'closed') $unclosedCount ++; if($product->status == 'closed') unset($products[$key]); }