/** * Retrieve the details for a specific commodity * @param integer $id * @return array */ public function actionView($id = NULL) { if ($id === NULL) { throw new HttpException(400, 'Missing ID parameter'); } $query = System::find()->where(['id' => $id]); return ResponseBuilder::build($query, 'systems', Yii::$app->request->get('sort', 'name'), Yii::$app->request->get('order', 'asc')); }
public function getExportMonitor() { $year = System::find('CJ_WEB_ND')->value; $term = System::find('CJ_WEB_XQ')->value; $results = $this->retrieveMonitorResults($year, $term); $sheetName = $year . '~' . ($year + 1) . '学年度' . Term::find($term)->mc . '学期教师评学监控表'; $datas[0] = ['教师工号', '教师姓名', '所在学院', '课程序号', '已评数量']; foreach ($results as $result) { $row = array(); $row[] = $result->jsgh; $row[] = $result->jsxm; $row[] = $result->xymc; $row[] = $result->kcxh; $row[] = $result->count; $datas[] = $row; } Excel::create('export', function ($excel) use($sheetName, $datas) { $excel->setTitle('Guangxi Normal University Teacher Evaludate Students Monitor Report'); $excel->setCreator('Dean')->setCompany('Guangxi Normal University'); $excel->sheet($sheetName, function ($sheet) use($datas) { $sheet->setOrientation('landscape'); $sheet->fromArray($datas, null, 'A1', false, false); }); })->export('xls'); }
/** * The object parser for EDDB systems * @return function */ private function getSystemsObjectParser() { return function ($obj) { // Remove attributes we don't want to be applied unset($obj[0]['updated_at']); $model = System::find()->where(['id' => $obj[0]['id']])->one(); if ($model === NULL) { $model = new System(); } else { if ($model->updated_at + 43200 >= time()) { // If the model is less than 12 hours old, skip it. $this->stdOut('.'); return; } } $this->stdOut('Importing system: '); $this->stdOut("{$obj[0]['name']}\n", Console::BOLD); // Null set the station for consistancy if ($obj[0]['state'] == "None") { $obj[0]['state'] = NULL; } foreach ($obj[0] as $name => $value) { if ($model->hasAttribute($name)) { $model->{$name} = $value; } } $model->save(); }; }