From c53f1463ec43f2f13070c0648df4000f007f2d69 Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Thu, 20 Oct 2022 13:17:53 +0800 Subject: [PATCH] + Add dtable. --- module/program/ui/browse.html.php | 55 ++++++++++++++++++++++++++++- zin/block.class.php | 2 +- zin/wg.func.php | 1 + zin/wg/dtable/v1.php | 58 +++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 zin/wg/dtable/v1.php diff --git a/module/program/ui/browse.html.php b/module/program/ui/browse.html.php index dd1bfcedfe..6e5e93ebc5 100644 --- a/module/program/ui/browse.html.php +++ b/module/program/ui/browse.html.php @@ -1,6 +1,7 @@ lang->program->featureBar['browse'] as $key => $label) { @@ -29,7 +30,59 @@ $menu = block('h'); $menu->toolbar = $toolbar; $menu->actionbar = $actionbar; +/* Table. */ +$table = dtable(); +$table->col('name', $this->lang->nameAB)->flex(1); +$table->col('status', $this->lang->program->status)->width(60)->type('html'); +$table->col('pm', $this->lang->program->PM)->width(100)->type('html'); +$table->col('budget', $this->lang->project->budget)->width(60); +$table->col('begin', $this->lang->project->begin)->width(60); +$table->col('end', $this->lang->project->end)->width(60); +$table->col('progress', $this->lang->project->progress)->width(100)->type('html'); +$table->col('actions', $this->lang->actions)->width(60); + +$rows = array(); +$this->loadModel('project'); +foreach($programs as $program) +{ + $row = new stdclass(); + $row->name = $program->name; + $row->status = '' . zget($lang->project->statusList, $program->status, '') . ''; + $row->parent = $program->parent; + + $row->pm = ''; + if(!empty($program->PM)) + { + $userName = zget($users, $program->PM); + $row->pm .= html::smallAvatar(array('avatar' => $usersAvatar[$program->PM], 'account' => $program->PM, 'name' => $userName), (($program->type == 'program' and $program->grade == 1 )? 'avatar-circle avatar-top avatar-' : 'avatar-circle avatar-') . zget($userIdPairs, $program->PM)); + $userID = isset($PMList[$program->PM]) ? $PMList[$program->PM]->id : ''; + $row->pm .= html::a($this->createLink('user', 'profile', "userID=$userID", '', true), $userName, '', "title='{$userName}' data-toggle='modal' data-type='iframe' data-width='600'"); + } + + $programBudget = $this->project->getBudgetWithUnit($program->budget); + $row->budget = $program->budget != 0 ? zget($lang->project->currencySymbol, $program->budgetUnit) . ' ' . $programBudget : $this->lang->project->future; + $row->begin = $program->begin; + $row->end = $program->end == LONG_TIME ? $lang->program->longTime : $program->end; + + $row->progress = ''; + if(isset($progressList[$program->id])) + { + $row->progress = "
"; + $row->progress = "
" . round($progressList[$program->id]) . "
"; + } + + $row->actions = array(); + + $rows[] = $row; +} +$table->data($rows); + +$content = block(); +$content->table = $table; + +/* Layout. */ $page = page('list'); -$page->top->menu = $menu; +$page->top->menu = $menu; +$page->right->content = $content; $page->x(); diff --git a/zin/block.class.php b/zin/block.class.php index 340004b6c5..5db0c3eae0 100644 --- a/zin/block.class.php +++ b/zin/block.class.php @@ -29,7 +29,7 @@ class block } } -function block($type) +function block($type = 'v') { return new block($type); } diff --git a/zin/wg.func.php b/zin/wg.func.php index 3e32663218..755ca367e3 100644 --- a/zin/wg.func.php +++ b/zin/wg.func.php @@ -11,3 +11,4 @@ function select($text = '', $v = 0) {return wgFactory('select', $text);} function tab($text = '', $v = 0) {return wgFactory('tab', $text);} function toolbar($text = '', $v = 0) {return wgFactory('toolbar', $text);} function actionbar($text = '', $v = 0) {return wgFactory('actionbar', $text);} +function dtable($text = '', $v = 0) {return wgFactory('dtable', $text);} diff --git a/zin/wg/dtable/v1.php b/zin/wg/dtable/v1.php new file mode 100644 index 0000000000..53f60bf342 --- /dev/null +++ b/zin/wg/dtable/v1.php @@ -0,0 +1,58 @@ +name = $name; + $this->title = $title; + } + + public function width($width) + { + $this->width = $width; + return $this; + } + + public function type($type) + { + $this->type = $type; + return $this; + } + + public function flex($width) + { + $this->flex = $width; + return $this; + } + +} + +class dtable +{ + public $cols = array(); + + public function __construct($text = '') + { + $this->text = $text; + } + + public function col($name, $title) + { + $col = new column($name, $title); + $this->cols[] = $col; + return $col; + } + + public function data($data) + { + $this->data = $data; + } + + public function toString() + { + $html = '
'; + $html .= ''; + + return $html; + } +}