diff --git a/module/measrecord/control.php b/module/measrecord/control.php new file mode 100644 index 0000000000..302aa4ec3b --- /dev/null +++ b/module/measrecord/control.php @@ -0,0 +1,40 @@ + + * @package measrecord + * @version $Id$ + * @link http://www.zentao.net + */ +class measrecord extends control +{ + public function browse($program = 0, $measID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 10, $pageID = 1) + { + $this->app->loadLang('measurement'); + $this->app->loadClass('pager', $static=true); + $pager = new pager($recTotal, $recPerPage, $pageID); + + $this->lang->navGroup->measrecord = 'project'; + + $this->loadModel('project')->setMenu($program); + + $this->view->records = $this->measrecord->getListByProgram($program, $measID, $orderBy, $pager); + $this->view->measList = $this->measrecord->getSavedMeas($program); + $this->view->title = $this->lang->measrecord->browse; + $this->view->program = $program; + $this->view->programs = $this->loadModel('program')->getPairs(); + $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->projects = $this->loadModel('project')->getPairsByProgram(); + + if($measID) + { + $measurement = $this->loadModel('measurement')->getByID($measID); + $measurement->params = json_decode($measurement->params); + $this->view->measurement = $measurement; + } + $this->display(); + } +} diff --git a/module/measrecord/css/browse.css b/module/measrecord/css/browse.css new file mode 100644 index 0000000000..cb0846f9f4 --- /dev/null +++ b/module/measrecord/css/browse.css @@ -0,0 +1,34 @@ +.side-col .detail-content{padding-left: 10px; margin-top: 0px} +.tree li.has-list.open:before {border-left: none;} +#measTree li {padding: 0 0 0 8px;} +#measTree li.has-list {padding-left: 20px;} +#measTree li > a {display: block; padding: 5px 0; border-radius: 2px; padding-left: 6px; height: 30px;} +#measTree li > a > span {display: inline-block;} +#measTree li > a > span + span {margin-left: 8px;} +#measTree li.selected > a {background-color: #E8F3FC;} +#measTree li.selected > a > span.title {color: #006AF1;} +#measTree .label-id {border-color: #cbd0db; color: #7d8599} +#measTree .label.label-type {background: #fff; border: 1px solid #7d8599; color:#7d8599} + +#measTree li > a > span.title {color: #3C4353; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;} +#measTree li > a > span.user {color: #838a9d;} +#measTree li > a > span.user > .icon-person {font-size: 14px; position: relative; top: -1px; color: #a6aab8} + +#measTree li > .list-toggle {transform: rotate(0deg); width: 16px; height: 16px; border: 4px solid #a6aab8; border-radius: 2px; top: 7px;} +#measTree li > .list-toggle:before {content: ' '; display: block; position: absolute; border: 1px solid #a6aab8; top: 2px; left: -3px; right: -3px; bottom: 2px; min-width: 0; transition: all .2s;} +#measTree li > .list-toggle:hover:before, +#measTree li > .list-toggle:hover {border-color: #006AF1;} +#measTree li.open > .list-toggle {width: 12px; height: 12px; top: 9px; background-color: #a6aab8; border-width: 3px; left: 3px;} +#measTree li.open > .list-toggle:before {border: none; height: 2px; width: 6px; left: 0; top: 2px; background: #fff;} +#measTree li.open > .list-toggle:hover {background: #006AF1;} + +#measTree ul > li:after {display: block; position: absolute; content: ' '; border-top: 2px solid #cbd0db; top: 14px; left: -12px; z-index: 1; width: 10px;} +#measTree ul > li:before, +#measTree ul > li.has-list:before {background: none; content: ' '; display: block; position: absolute; width: auto; height: auto; border: none; border-left: 2px solid #cbd0db; top: -13px; bottom: 12px; left: -12px;} +#measTree ul > li:last-child:before {bottom: auto; height: 29px;} +#measTree ul > li:first-child:before {top: -9px;} +#measTree ul > li.has-list:first-child:before {top: -13px;} +#measTree ul > li.tree-single-item:before {height: 23px;} +#measTree ul > li.has-list:after {width: 14px;} +#measTree ul > li.item-meas a.selected{color: #0c64eb;} +.side-col{padding-right: 5px; width: 25%} diff --git a/module/measrecord/js/browse.js b/module/measrecord/js/browse.js new file mode 100644 index 0000000000..ff645ecc8e --- /dev/null +++ b/module/measrecord/js/browse.js @@ -0,0 +1,8 @@ +$(function() +{ + var $taskTree = $('#measTree').tree( + { + name: 'measTree', + initialState: 'preserve' + }); +}); diff --git a/module/measrecord/lang/de.php b/module/measrecord/lang/de.php new file mode 100644 index 0000000000..e84c7a4536 --- /dev/null +++ b/module/measrecord/lang/de.php @@ -0,0 +1,8 @@ +measrecord->common = 'Project Measurement'; +$lang->measrecord->browse = 'History'; +$lang->measrecord->list = 'Measurements'; +$lang->measrecord->params = 'Measurement Parameters'; + +$lang->measrecord->value = 'Metrics'; +$lang->measrecord->date = 'Created'; diff --git a/module/measrecord/lang/en.php b/module/measrecord/lang/en.php new file mode 100644 index 0000000000..e84c7a4536 --- /dev/null +++ b/module/measrecord/lang/en.php @@ -0,0 +1,8 @@ +measrecord->common = 'Project Measurement'; +$lang->measrecord->browse = 'History'; +$lang->measrecord->list = 'Measurements'; +$lang->measrecord->params = 'Measurement Parameters'; + +$lang->measrecord->value = 'Metrics'; +$lang->measrecord->date = 'Created'; diff --git a/module/measrecord/lang/fr.php b/module/measrecord/lang/fr.php new file mode 100644 index 0000000000..e84c7a4536 --- /dev/null +++ b/module/measrecord/lang/fr.php @@ -0,0 +1,8 @@ +measrecord->common = 'Project Measurement'; +$lang->measrecord->browse = 'History'; +$lang->measrecord->list = 'Measurements'; +$lang->measrecord->params = 'Measurement Parameters'; + +$lang->measrecord->value = 'Metrics'; +$lang->measrecord->date = 'Created'; diff --git a/module/measrecord/lang/zh-cn.php b/module/measrecord/lang/zh-cn.php new file mode 100644 index 0000000000..ad3a24dfb1 --- /dev/null +++ b/module/measrecord/lang/zh-cn.php @@ -0,0 +1,8 @@ +measrecord->common = '项目度量'; +$lang->measrecord->browse = '度量记录'; +$lang->measrecord->list = '度量列表'; +$lang->measrecord->params = '度量参数'; + +$lang->measrecord->value = '度量值'; +$lang->measrecord->date = '创建时间'; diff --git a/module/measrecord/model.php b/module/measrecord/model.php new file mode 100644 index 0000000000..f14b9d66e6 --- /dev/null +++ b/module/measrecord/model.php @@ -0,0 +1,74 @@ + + * @package measrecord + * @version $Id$ + * @link http://www.zentao.net + */ +class measrecordModel extends model +{ + /** + * Get list by program + * + * @param int $program + * @param int $measurementID + * @param string $orderBy + * @param object $pager + * @access public + * @return array + */ + public function getListByProgram($program, $measurementID, $orderBy = 'id_desc', $pager = null) + { + return $this->dao->select('*')->from(TABLE_MEASRECORDS) + ->where('project')->eq($program) + ->andWhere('mid')->eq($measurementID) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll(); + } + + public function getSavedMeas($program) + { + return $this->dao->select('DISTINCT r.mid, m.name, m.purpose')->from(TABLE_BASICMEAS)->alias('m') + ->leftJoin(TABLE_MEASRECORDS)->alias('r') + ->on('m.id=r.mid') + ->where('project')->eq($program) + ->orderBy('m.purpose, m.order desc') + ->fetchGroup('purpose'); + } + + /** + * Save meas record. + * + * @param object $measurement + * @param array $params + * @param mix $queryResult + * @access public + * @return bool + */ + public function save($measurement, $params, $value, $type = '') + { + $record = new stdclass(); + $record->type = $type; + $record->mid = $measurement->id; + $record->measCode = $measurement->code; + $record->date = helper::today(); + $record->year = date('Y'); + $record->month = date('Ym'); + $record->week = date('W'); + $record->day = date('Ymd'); + $record->params = json_encode($params); + $record->value = $value; + + if(isset($params['$program'])) $record->program = $params['$program']; + if(isset($params['$product'])) $record->product = $params['$product']; + if(isset($params['$project'])) $record->project = $params['$project']; + + $this->dao->insert(TABLE_MEASRECORDS)->data($record)->exec(); + return !dao::isError(); + } +} diff --git a/module/measrecord/view/browse.html.php b/module/measrecord/view/browse.html.php new file mode 100644 index 0000000000..3399ef262a --- /dev/null +++ b/module/measrecord/view/browse.html.php @@ -0,0 +1,86 @@ +getModuleRoot() . 'common/view/header.html.php';?> +