diff --git a/api/v1/entries/executions.php b/api/v1/entries/executions.php index 0bd49f493d..507076dabb 100644 --- a/api/v1/entries/executions.php +++ b/api/v1/entries/executions.php @@ -22,6 +22,7 @@ class executionsEntry extends entry { $appendFields = $this->param('fields', ''); $withProject = $this->param('withProject', ''); + if(strpos(strtolower(",{$appendFields},"), ',dropmenu,') !== false) return $this->getDropMenu(); if($projectID) { @@ -101,4 +102,50 @@ class executionsEntry extends entry $this->send(201, $this->format($execution, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time')); } + + /** + * Get drop menu. + * + * @access public + * @return void + */ + public function getDropMenu() + { + $control = $this->loadController('execution', 'ajaxGetDropMenu'); + $control->ajaxGetDropMenu($this->request('executionID', 0), $this->request('module', 'execution'), $this->request('method', 'task'), $this->request('extra', '')); + + $data = $this->getData(); + if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message); + + $account = $this->app->user->account; + $projects = $data->data->projects; + $dropMenu = array('involved' => array(), 'other' => array(), 'closed' => array()); + foreach($data->data->executions as $projectID => $projectExecutions) + { + foreach($projectExecutions as $execution) + { + if(helper::diffDate(date('Y-m-d'), $execution->end) > 0) $execution->delay = true; + $teams = $execution->teams; + $execution = $this->filterFields($execution, 'id,project,model,type,name,code,status,PM,delay'); + + $projectName = zget($projects, $execution->project, ''); + if($projectName) $execution->name = $projectName . '/' . $execution->name; + + if($execution->status == 'closed') + { + $dropMenu['closed'][] = $execution; + } + elseif($execution->status != 'done' and $execution->status != 'closed' and ($execution->PM == $account or isset($teams->$account))) + { + $dropMenu['involved'][] = $execution; + } + else + { + $dropMenu['other'][] = $execution; + } + } + } + + $this->send(200, $dropMenu); + } } diff --git a/api/v1/entries/products.php b/api/v1/entries/products.php index 8eefb08255..6aa0ca75f7 100644 --- a/api/v1/entries/products.php +++ b/api/v1/entries/products.php @@ -20,8 +20,8 @@ class productsEntry extends entry */ public function get($programID = 0) { - $fields = strtolower($this->param('fields', '')); - if(strpos(",{$fields},", ',dropmenu,') !== false) return $this->getDropMenu(); + $fields = $this->param('fields', ''); + if(strpos(strtolower(",{$fields},"), ',dropmenu,') !== false) return $this->getDropMenu(); if(!$programID) $programID = $this->param('program', 0); diff --git a/api/v1/entries/programs.php b/api/v1/entries/programs.php index 3e61e2ff43..96f2e53891 100644 --- a/api/v1/entries/programs.php +++ b/api/v1/entries/programs.php @@ -23,7 +23,7 @@ class programsEntry extends Entry $mergeChildren = $this->param('mergeChildren', 0); $fields = $this->param('fields', ''); - if(stripos(",{$fields},", ",dropmenu,") !== false) return $this->getDropMenu(); + if(stripos(strtolower(",{$fields},"), ",dropmenu,") !== false) return $this->getDropMenu(); $program = $this->loadController('program', 'browse'); $program->browse($this->param('status', 'all'), $this->param('order', 'order_asc'));