diff --git a/module/program/control.php b/module/program/control.php index e905731605..00f4269037 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -595,6 +595,7 @@ class program extends control } /** + * 导出项目集。 * Export program. * * @param string $status @@ -602,36 +603,35 @@ class program extends control * @access public * @return void */ - public function export($status, $orderBy) + public function export(string $status, string $orderBy) { if($_POST) { - $programLang = $this->lang->program; - $programConfig = $this->config->program; - /* Create field lists. */ - $fields = $this->post->exportFields ? $this->post->exportFields : explode(',', $programConfig->list->exportFields); + $fields = $this->post->exportFields ? $this->post->exportFields : explode(',', $this->config->program->list->exportFields); foreach($fields as $key => $fieldName) { $fieldName = trim($fieldName); - $fields[$fieldName] = zget($programLang, $fieldName); + $fields[$fieldName] = zget($this->lang->program, $fieldName); unset($fields[$key]); } - $programs = $this->program->getList($status, $orderBy, null); + /* Get and process program list. */ $users = $this->loadModel('user')->getPairs('noletter'); - foreach($programs as $i => $program) + $programs = $this->program->getList($status, $orderBy, null); + $products = $this->program->getProductByProgram(array_keys($programs)); + foreach($programs as $programID => $program) { - $program->PM = zget($users, $program->PM); - $program->status = $this->processStatus('project', $program); - $program->model = zget($this->lang->project->modelList, $program->model); - $program->product = implode(",", $this->dao->select('name')->from(TABLE_PRODUCT)->where('program')->eq($program->id)->fetchPairs('name')); - $program->budget = $program->budget . zget($this->lang->project->unitList, $program->budgetUnit); + $program->PM = zget($users, $program->PM); + $program->status = $this->processStatus('project', $program); + $program->model = zget($this->lang->project->modelList, $program->model); + $program->product = empty($products[$programID]) ? '' : implode(",", helper::arrayColumn($products[$programID], 'name')); + $program->budget = $program->budget . zget($this->lang->project->unitList, $program->budgetUnit); if($this->post->exportType == 'selected') { $checkedItem = $this->cookie->checkedItem; - if(strpos(",$checkedItem,", ",{$program->id},") === false) unset($programs[$i]); + if(strpos(",$checkedItem,", ",{$program->id},") === false) unset($programs[$programID]); } } diff --git a/module/program/model.php b/module/program/model.php index cf03065421..e762714a45 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -314,7 +314,7 @@ class programModel extends model */ public function getKanbanStatisticData(array $programs): array { - $productGroup = $this->programTao->getProductByProgram(array_keys($programs)); + $productGroup = $this->getProductByProgram(array_keys($programs)); $productIdList = array(); foreach($productGroup as $programID => $products) { @@ -1295,14 +1295,15 @@ class programModel extends model } /** + * 判断操作按钮是否可以点击。 * Judge an action is clickable or not. * - * @param object $program - * @param string $action + * @param object $program + * @param string $action * @access public * @return bool */ - public static function isClickable($program, $action) + public static function isClickable(object $program, string $action): bool { $action = strtolower($action); @@ -1826,4 +1827,23 @@ class programModel extends model } return $result; } + + /** + * 获取项目集下的产品列表信息。 + * Get product list information under the program. + * + * @param array $programIdList + * @access public + * @return array + */ + public function getProductByProgram(array $programIdList = array()): array + { + return $this->dao->select('*')->from(TABLE_PRODUCT) + ->where('deleted')->eq(0) + ->andWhere('status')->ne('closed') + ->beginIF(!empty($programIdList))->andWhere('program')->in($programIdList)->fi() + ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi() + ->orderBy('order_asc') + ->fetchGroup('program'); + } } diff --git a/module/program/tao.php b/module/program/tao.php index 6ede7f973d..5430af321e 100644 --- a/module/program/tao.php +++ b/module/program/tao.php @@ -30,25 +30,6 @@ class programTao extends programModel ->fetchAll('id'); } - /** - * 获取项目集下的产品列表信息。 - * Get product list information under the program. - * - * @param array $programIdList - * @access protected - * @return array - */ - protected function getProductByProgram(array $programIdList = array()): array - { - return $this->dao->select('*')->from(TABLE_PRODUCT) - ->where('deleted')->eq(0) - ->andWhere('status')->ne('closed') - ->beginIF(!empty($programIdList))->andWhere('program')->in($programIdList)->fi() - ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi() - ->orderBy('order_asc') - ->fetchGroup('program'); - } - /** *获取所有根项目集基本数据。 * Get base data of all root programs. diff --git a/module/program/test/tao/getproductbyprogram.php b/module/program/test/model/getproductbyprogram.php similarity index 100% rename from module/program/test/tao/getproductbyprogram.php rename to module/program/test/model/getproductbyprogram.php