private static function handleBudget($request) { if (!System::hasBudget(date('Y'))) { System::newBudget($request->budget); } else { System::updateBudget($request->budget); } }
/** * 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 static function addExpense($amount) { $thisMonthExpense = System::getThisMonthExpense(); DB::table('statistic_expenses')->where('year', date('Y'))->where('month', date('n'))->update(['cost' => $thisMonthExpense + $amount]); }
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'); }
/** * @return \yii\db\ActiveQuery */ public function getSystem() { return $this->hasOne(System::className(), ['id' => 'system_id']); }
/** * 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(); }; }
public function indexAction() { $systemList = System::query()->where("id_user = :idUser:"******"active = 1")->bind(['idUser' => $this->session->get('user-id')])->order('name')->execute(); $this->view->setVars(['systemList' => $systemList, 'test' => $this->session->get('user-id')]); }
public function run() { DB::table('system')->delete(); System::create(['variable' => 'request_status', 'content' => 'a:4:{i:0;s:4:"REST";i:1;s:9:"REQUESTED";i:2;s:7:"ORDERED";i:3;s:8:"RECIEVED";}']); System::create(['variable' => 'barcode_prefix', 'content' => 'a:2:{i:0;s:1:"(";i:1;s:1:")";}']); }