public function actionIndex() { $report = new Report(); if ($report->load(Yii::$app->request->post()) && $report->validate()) { $active_from = $_POST['Report']['active_from']; $active_to = $_POST['Report']['active_to']; $query = $report->ReportSql($active_from, $active_to); //return print_r($query); return $this->render('report', ['query' => $query]); } return $this->render('index', ['report' => $report]); }
public function actionIndex() { $model = new Report(); $models = null; try { if ($model->load(Yii::$app->request->post()) && $model->validate()) { $models = $model->search(); } } catch (\Exception $e) { $msg = isset($e->errorInfo[2]) ? $e->errorInfo[2] : $e->getMessage(); $model->addError('_exception', $msg); } return $this->render('index', ['model' => $model, 'models' => $models]); }
public function postImport($id) { $report = \App\Models\Report::find($id); if (Input::hasFile('file')) { $file = Input::file('file'); $filename = $file->getClientOriginalName(); $destinationPath = public_path() . '/uploads/'; Input::file('file')->move($destinationPath, $filename); $handle = fopen(public_path() . '/uploads/' . $filename, "r"); if ($handle !== FALSE) { while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) { $depreciation = new \App\Models\Depreciation(); $name = iconv("Windows-1251", "utf-8", $data[0]); $depreciation->name = $name; $depreciation->number = $data[1]; $carrying_amount = $data[2]; $carrying_amount = str_replace(",", ".", $carrying_amount); $carrying_amount = str_replace(" ", "", $carrying_amount); $depreciation->carrying_amount = $carrying_amount; $sum = $data[3]; $sum = str_replace(",", ".", $sum); $sum = str_replace(" ", "", $sum); $depreciation->sum = $sum; $residual_value = $data[4]; $residual_value = str_replace(",", ".", $residual_value); $residual_value = str_replace(" ", "", $residual_value); $depreciation->residual_value = $residual_value; $depreciation->report_id = $id; $depreciation->save(); } } } return redirect()->back(); }
/** * Lists all Exchange models. * @return mixed */ public function actionIndex() { $searchModel = new ExchangeSearch(); $searchModel->create_time = date('Y-m-d'); $users = Users::findOne(Yii::$app->user->id); $location = $users->location_id; $dataProviderCashUSD = $searchModel->search(Yii::$app->request->queryParams, 'USD', 'cash', $location); $dataProviderHedgeUSD = $searchModel->search(Yii::$app->request->queryParams, 'USD', 'hedge', $location); $dataProviderCashEUR = $searchModel->search(Yii::$app->request->queryParams, 'EUR', 'cash', $location); $dataProviderHedgeEUR = $searchModel->search(Yii::$app->request->queryParams, 'EUR', 'hedge', $location); $sumCashUSD = $searchModel->getSum($dataProviderCashUSD); $sumHedgeUSD = $searchModel->getSum($dataProviderHedgeUSD); $sumCashEUR = $searchModel->getSum($dataProviderCashEUR); $sumHedgeEUR = $searchModel->getSum($dataProviderHedgeEUR); $model_report = Report::findOne(['date' => $searchModel->create_time, 'location_id' => $location]); $cbr = new CBRAgent(); if ($cbr->load()) { $cbrUSD = $cbr->get('USD'); $cbrEUR = $cbr->get('EUR'); } else { $cbrUSD = 0; $cbrEUR = 0; } return $this->render('index', ['searchModel' => $searchModel, 'dataProviderCashUSD' => $dataProviderCashUSD, 'dataProviderHedgeUSD' => $dataProviderHedgeUSD, 'dataProviderCashEUR' => $dataProviderCashEUR, 'dataProviderHedgeEUR' => $dataProviderHedgeEUR, 'model_report' => $model_report, 'sumCashUSD' => $sumCashUSD, 'sumHedgeUSD' => $sumHedgeUSD, 'sumCashEUR' => $sumCashEUR, 'sumHedgeEUR' => $sumHedgeEUR, 'cbrUSD' => $cbrUSD, 'cbrEUR' => $cbrEUR]); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $data = ["status" => ""]; $validatorRules = array('link' => 'required', 'reportId' => 'required|integer|exists:reports,id'); $validatorAttributes = array('link' => '临时报告链接', 'reportId' => '报告模板类别'); postCheck($validatorRules, Config::get('phylab.validatorMessage'), $validatorAttributes); if (Storage::disk('local_public')->exists('pdf_tmp/' . Request::get('link'))) { $report = Report::find(Request::get('reportId')); $experimentName = $report->experiment_name; if (Auth::user()->stars()->count() <= Config::get('phylab.starMaxCount')) { $star = Star::create(['link' => Request::get('link'), 'name' => 'Lab_' . Request::get('reportId') . '_' . $experimentName . '_report', 'user_id' => Auth::user()->id, 'report_id' => Request::get('reportId')]); if ($star) { try { Storage::disk('local_public')->copy('pdf_tmp/' . Request::get('link'), 'star_pdf/' . Request::get('link')); } catch (Exception $e) { throw new FileIOException(); } $data["status"] = SUCCESS_MESSAGE; } else { $data["status"] = FAIL_MESSAGE; } } else { throw new ReachCeilingException(); } } else { throw new NoResourceException(); } //注意通过传入的临时文件地址来转移文件 return response()->json($data); }
/** * @param $id * @return \BladeView|bool|\Illuminate\View\View */ public function showUser($id) { $user = DuoUser::find($id); $reports = Report::where('name', 'like', '%duo%')->get(); $groups = Group::all(); return view('duo.show', compact('user', 'reports', 'groups')); }
/** * Execute the console command. * * @return mixed */ public function handle() { //Get all reports where type = cucm_daily $reports = Report::where('type', 'cucm_daily')->get(); //Get all configured CUCM clusters $clusters = $this->cluster->all(); //Set timestamp for file names $timeStamp = Carbon::now('America/New_York')->toDateTimeString(); //Create array to track attachments $attachments = []; //Loop reports foreach ($reports as $index => $report) { $attachments[$index] = $report->path . $report->name . '-' . $timeStamp . '.csv'; //Persist report to disk Storage::put($attachments[$index], $report->csv_headers); //Loop each cluster and run the reports foreach ($clusters as $cluster) { $this->dispatch(new $report->job($cluster, $attachments[$index])); } } //Reports are done running, let's email to results $beautymail = app()->make(\Snowfire\Beautymail\Beautymail::class); $beautymail->send('emails.cucmDailyReporting', [], function ($message) use($attachments) { //TODO: Create system for users to manage report subscriptions. $message->to(['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'])->subject('CUCM Daily Report'); //Add all reports to email foreach ($attachments as $report) { $message->attach(storage_path($report)); } }); }
public function postReportExcel(Request $request) { $id = $request->input('report_id'); $report = \App\Models\Report::find($id); $organization = \App\Models\Organization::find($report->organization_id); $filename = $organization->inn . "_" . $report->quarter . "_квартал_" . $report->year . "_года"; $file = Excel::create($filename, function ($excel) use($report, $organization) { $excel->sheet(' Сводные данные по отчету', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->mergeCells('A2:E2'); $sheet->mergeCells('A6:E6'); $sheet->mergeCells('A11:E11'); $sheet->mergeCells('A15:E15'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Итоговые суммы по отчету'), array('Балансовая стоимость', 'Начисленный износ', 'Сумма списания', 'Остаточная стоимость'), array($report->report_total_carrying_amount, $report->report_wearout_value, $report->decommission_carrying_amount, $report->report_total_residual_value), array(''), array('Сводные данные по приобретению'), array('', 'Итого', ' Движимое имущество', 'Особо ценное движимое имущество', ' Здания и сооружения', 'Земельные участки', 'Автомобили'), array('Балансовая стоимость', $report->report_carrying_amount, $report->report_movables_carrying_amount, $report->report_value_movables_carrying_amount, $report->report_buildings_carrying_amount, $report->report_parcels_carrying_amount, $report->report_cars_carrying_amount), array('Остаточная стоимость', $report->report_residual_value, $report->report_movables_residual_value, $report->report_value_movables_residual_value, $report->report_buildings_residual_value, $report->report_parcels_residual_value, $report->report_cars_residual_value), array(''), array('Сводные данные по начислению износа'), array('Балансовая стоимость', 'Начисление износа', 'Остаточная стоимость'), array($report->report_wearout_carrying_amount, $report->report_wearout_value, $report->report_wearout_residual_value), array(''), array('Сводные данные по списанию основных средств'), array('Балансовая стоимость', 'Сумма списания'), array($report->decommission_carrying_amount, $report->decommission_sum)), null, 'A1', false, false); }); $excel->sheet('Приобретение', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $items = $report->items; $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Инвертарный номер', 'Наименование', 'Балансовая стоимость', 'Код ОКОФ', 'Остаточная стоимость')), null, 'A1', false, false); $row = 3; foreach ($items as $item) { $sheet->row($row, [$item->number, $item->name, $item->carrying_amount, $item->okof != 0 ? $item->okof : 'Земельный участок', isset($item->variable->residual_value) ? $item->variable->residual_value : 0]); $row++; } }); $excel->sheet('Начисление износа', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $depreciations = $report->depreciations()->get(['number', 'name', 'carrying_amount', 'sum', 'residual_value']); $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Инвертарный номер', 'Наименование', 'Балансовая стоимость', 'Начисленный износ', 'Остаточная стоимость')), null, 'A1', false, false); $sheet->fromModel($depreciations, null, 'A1', false, false); }); $excel->sheet('Списание', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $decommissions = $report->decommissions()->get(['number', 'name', 'carrying_amount', 'sum', 'date', 'type']); $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Инвертарный номер', 'Наименование', 'Балансовая стоимость', 'Сумма списания', 'Дата списания', 'Вид списания')), null, 'A1', false, false); $sheet->fromModel($decommissions, null, 'A1', false, false); }); })->store('xlsx', storage_path('excel/exports'), true); return Response::download($file['full']); }
/** * Run the database seeds. * * @return void */ public function run() { $this->cleanDatabase(); /* * Seed CUCM Daily Reports Table */ Report::create(['name' => 'NonePartitionReport', 'path' => 'reports/cucm/none-pt/', 'type' => 'cucm_daily', 'job' => 'App\\Jobs\\GetDnsInNonePartition', 'csv_headers' => 'Directory Number,Description']); Report::create(['name' => 'CallForwardLoopReport', 'path' => 'reports/cucm/cfwd-loop/', 'type' => 'cucm_daily', 'job' => 'App\\Jobs\\CheckForCallForwardLoop', 'csv_headers' => 'Directory Number,Description,Forward Number']); Report::create(['name' => 'PhoneFirmwareReport', 'path' => 'reports/cucm/phone-firmware/', 'type' => 'phone_firmware', 'job' => 'App\\Jobs\\GetPhoneFirmware', 'csv_headers' => 'DeviceName,Product,Description,IsRegistered,IpAddress,Model,Firmware']); Report::create(['name' => 'DuoRegisteredUsersReport', 'path' => 'reports/duo/registered-users/', 'type' => 'duo_registered_users', 'job' => 'App\\Jobs\\GenerateRegisteredDuoUsersReport', 'csv_headers' => 'username,email,status,last_login,group_name']); }
public function actionCardexReport() { $model = new Report(); if ($date_report = Yii::$app->request->post('Report')) { $ward = Yii::$app->user->identity->ward; $month = $date_report['month']; $year = $date_report['year']; $days = date('t', strtotime($year . '-' . $month . '-01')); $this->callDatereport($month, $year, $days); $month_name = $model->getMonthName($month); $ward_name = $model->getWard($ward); $sql = "select t.date,\n\tt.period,\n\ta.ward,\n\ta.admit1,\n\ta.admit2,\n\ta.admit3,\n a.admit4,\n\ta.disc1,\n\ta.disc2,\n\ta.disc3,\n\ta.disc4,\n\ta.disc5,\n\ta.disc6,\n\ta.prepare,\n\ta.cpr_time,\n\ta.cpr_no,\n\ta.respirator,\n\ta.rm_normal,\n\ta.rm_vip,\n\ta.disability,\n\ta.4a,\n\ta.3a,\n a.3b,\n\ta.2a,\n\ta.2b,\n\ta.2c,\n\ta.1a,\n\ta.1b,\n\ta.1c,\n\ta.1d,\n\tb.hn,\n\tb.rn,\n\tb.tn,\n\tb.pn,\n\tb.na,\n b.worker,\n\tb.total\nfrom tmp_report t LEFT JOIN\n(select \nne.ref,\nne.date,\nne.period,\nne.ward\n-- Admit\n,sum(if(p.admit_type=1,1,0)) as 'admit1'\n,sum(if(p.admit_type=2,1,0)) as 'admit2'\n,sum(if(p.admit_type=3,1,0)) as 'admit3'\n,sum(if(p.admit_type=4,1,0)) as 'admit4'\n-- Disc\n,sum(if(p.disc_type=1,1,0)) as 'disc1'\n,sum(if(p.disc_type=2,1,0)) as 'disc2'\n,sum(if(p.disc_type=3,1,0)) as 'disc3'\n,sum(if(p.disc_type=4,1,0)) as 'disc4'\n,sum(if(p.disc_type=5,1,0)) as 'disc5'\n,sum(if(p.disc_type=6,1,0)) as 'disc6'\n-- หัตถการ\n,sum(if(p.prepare=1,1,0)) as 'prepare'\n,sum(p.cpr) as 'cpr_time'\n,(if(p.cpr>0 and p.disc_type=0,1,0)) as 'cpr_no'\n,sum(if((p.uti>0 || p.vap>0 || p.phleb>0 || p.cutdown >0) and p.disc_type=0,1,0)) as 'respirator'\n-- คงพยาบาล\n,sum(if(p.bed_type in ('ส','น','ย','ท') and p.disc_type=0,1,0)) as 'rm_normal'\n,sum(if(p.bed_type='พ' and p.disc_type=0,1,0)) as 'rm_vip'\n,sum(if(p.disability=1 and p.disc_type=0,1,0)) as 'disability'\n-- จำแนกผู้ป่วย\n,sum(if(p.pt_type='4a' and p.disc_type=0,1,0)) as '4a'\n,sum(if(p.pt_type='3a' and p.disc_type=0,1,0)) as '3a'\n,sum(if(p.pt_type='3b' and p.disc_type=0,1,0)) as '3b'\n,sum(if(p.pt_type='2A' and p.disc_type=0,1,0)) as '2a'\n,sum(if(p.pt_type='2B' and p.disc_type=0,1,0)) as '2b'\n,sum(if(p.pt_type='2C' and p.disc_type=0,1,0)) as '2c'\n,sum(if(p.pt_type='1a' and p.disc_type=0,1,0)) as '1a'\n,sum(if(p.pt_type='1b' and p.disc_type=0,1,0)) as '1b'\n,sum(if(p.pt_type='1c' and p.disc_type=0,1,0)) as '1c'\n,sum(if(p.pt_type='1d' and p.disc_type=0,1,0)) as '1d'\nfrom nurse_event ne left join nurse_patient p on p.event_ref = ne.ref\nwhere (ne.date is not null and date != 0000-00-00) and ne.ward = " . $ward . " and month(date) = '" . $month . "' and year(date) = '" . $year . "'\ngroup by ne.date,ne.period,ne.ward\norder by ne.date,ne.period,ne.ward) a\non t.date = a.date and t.period = a.period\nleft join\n(select \tne.ref,\n\t\tne.date,\n\t\tne.period,\n\t\tne.ward,\n\t\tsum(if(s.hn =1,1,0)) as 'hn',\n\t\tsum(if(s.position in (1,2,3,4,5,10) and hn!=1,1,0)) as 'rn',\n\t\tsum(if(s.position in (6) and hn!=1,1,0)) as 'tn',\n\t\tsum(if(s.position in (7) and hn!=1,1,0)) as 'pn',\n\t\tsum(if(s.position in (8) and hn!=1,1,0)) as 'na',\n sum(if(s.position in (9) and hn!=1,1,0)) as 'worker',\n\t\tcount(se.event_ref) as 'total'\nfrom nurse_event ne left join nurse_staffevent se on ne.ref = se.event_ref\n\t\t\t\t\tleft join nurse_staff s on se.staff_ref = s.staff_ref\nwhere (ne.date is not null and date != 0000-00-00) and ne.ward = " . $ward . " and month(date) = '" . $month . "' and year(date) = '" . $year . "'\ngroup by date,period,ward) b\non a.ref = b.ref"; // $patient = NursePatient::findBySql($sql)->all(); // print_r($patient); $command = Yii::$app->db->createCommand($sql); $cardex = $command->queryAll(); $this->clearDate(); return $this->renderPartial('_cardexreport', ['cardex' => $cardex, 'month' => $month, 'year' => $year, 'month_name' => $month_name, 'ward_name' => $ward_name]); } else { return $this->render('_callcardexreport', ['model' => $model]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Report::find()->with('exchange')->limit(31); $dataProvider = new ActiveDataProvider(['query' => $query, 'totalCount' => 31, 'pagination' => ['defaultPageSize' => 31, 'pageSizeLimit' => [1, 31]]]); $this->load($params); if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['like', 'date', $this->date . '%', false]); $query->andFilterWhere(['location_id' => $this->location_id]); return $dataProvider; }
public function postImport($id) { $report = \App\Models\Report::find($id); if (Input::hasFile('file')) { $file = Input::file('file'); $filename = $file->getClientOriginalName(); $destinationPath = public_path() . '/uploads/'; Input::file('file')->move($destinationPath, $filename); $handle = fopen(public_path() . '/uploads/' . $filename, "r"); if ($handle !== FALSE) { while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) { $decommission = new \App\Models\Decommission(); $name = iconv("Windows-1251", "utf-8", $data[0]); $decommission->name = $name; $decommission->number = $data[1]; $carrying_amount = $data[2]; $carrying_amount = str_replace(",", ".", $carrying_amount); $carrying_amount = str_replace(" ", "", $carrying_amount); $decommission->carrying_amount = $carrying_amount; $date = date("Y-m-d", strtotime($data[3])); $decommission->date = $date; $decommission_type = $data[4]; $decommission_type = str_replace(" ", "", $decommission_type); switch ($decommission_type) { case 1: $decommission->type = 'sale'; break; case 2: $decommission->type = 'gratuitous transfer'; break; case 3: $decommission->type = 'decommission'; break; default: $decommission->type = null; } $sum = $data[5]; $sum = str_replace(",", ".", $sum); $sum = str_replace(" ", "", $sum); $decommission->sum = $sum; $document = iconv("Windows-1251", "utf-8", $data[6]); $decommission->document = $document; $decommission->report_id = $id; $decommission->save(); } } } return redirect()->back(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Report::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created' => SORT_DESC]], 'pagination' => ['pageSize' => 100]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created' => $this->created, 'updated' => $this->updated, 'user_id' => $this->user_id, 'status_id' => $this->status_id, 'typeperson_id' => $this->typeperson_id, 'typesolicitation_id' => $this->typesolicitation_id, 'location_id' => $this->location_id, 'analyst_id' => $this->analyst_id]); $query->andFilterWhere(['between', 'created', $this->start_date, $this->end_date]); $query->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'note_analyst', $this->note_analyst])->andFilterWhere(['like', 'cpf_cnpj', $this->cpf_cnpj])->andFilterWhere(['like', 'scholarity', $this->scholarity])->andFilterWhere(['like', 'occupation', $this->occupation])->andFilterWhere(['like', 'job_firm', $this->job_firm])->andFilterWhere(['like', 'job_role', $this->job_role])->andFilterWhere(['like', 'job_phone', $this->job_phone])->andFilterWhere(['like', 'job_admission_date', $this->job_admission_date])->andFilterWhere(['like', 'spouse_cpf', $this->spouse_cpf])->andFilterWhere(['like', 'reference', $this->reference])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Report::find(); $query->joinWith(['task']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['task'] = ['asc' => ['tasks.name' => SORT_ASC], 'desc' => ['tasks.name' => SORT_DESC]]; $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'create_date' => $this->create_date, 'report_date' => $this->report_date, 'task_id' => $this->task_id]); $query->andFilterWhere(['like', 'tasks.name', $this->task]); $query->andFilterWhere(['like', 'value', $this->value]); return $dataProvider; }
/** * Finds the Report model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $date * @param integer $location_id * @return Report the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($date, $location_id) { if (($model = Report::findOne(['date' => $date, 'location_id' => $location_id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionForm() { $model = new Report(); if ($model->load(Yii::$app->request->post())) { $model->location_is_precise = true; $date = new DateTime(); $model->time_sent = $date->format('Y-m-d H:i:s'); $model->time_updated = $date->format('Y-m-d H:i:s'); if ($model->validate()) { $model->save(); \Yii::$app->session->setFlash('submittedForm'); return $this->refresh(); } } $languages = Language::find()->all(); $language_arr = []; foreach ($languages as $language) { $language_arr[$language->id_language] = $language->name . " (" . $language->dialect . ")"; } $disabilities = DisabilityCategory::find()->all(); $disability_arr = []; foreach ($disabilities as $disability) { $disability_arr[$disability->id_disability_category] = $disability->category; } $problems = ProblemCategory::find()->all(); $problem_arr = []; foreach ($problems as $problem) { $problem_arr[$problem->id_problem_category] = $problem->category; } return $this->render('form', ['model' => $model, 'languages' => $language_arr, 'disabilities' => $disability_arr, 'problems' => $problem_arr]); }
public function run() { DB::table('reports')->delete(); Report::create(["script_link" => "1071.py", "experiment_id" => 1071, "experiment_name" => "分光仪的调整", "prepare_link" => "1071.pdf"]); }
/** * return the xml form view to front * @param int $id * @return \Illuminate\Http\Response */ public function getXmlForm($id) { $data = ["id" => ""]; $experimentId = ""; $report = Report::find($id); if ($report) { $experimentId = $report->experiment_id; $data["id"] = $id; } else { throw new NoResourceException(); } return view("report.xmlForm." . $experimentId, $data); }
/** * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse */ public function firmwareStore(Request $request) { // Avoid PHP timeouts when querying large clusters set_time_limit(0); //Get the authenticated users active cluster $cluster = \Auth::user()->activeCluster(); //Get the file submitted from the form $file = $request->file('file'); //Make sure the file is a csv and redirect back if it's not if ($file->getClientMimeType() != "text/csv" && $file->getClientOriginalExtension() != "csv") { alert()->error('File type invalid. Please use a CSV file format.'); return redirect()->back(); } //Create new Keboola\Csv Object with the submitted file $csvFile = new CsvFile($file); $csv = ''; //Loop the csv file and store the device names in an array foreach ($csvFile as $key => $row) { $csv[] = $row[0]; } // $deviceList will hold our array for RisPort $deviceList = []; // Loop device name array and assign devicename to $deviceList foreach ($csv as $phone) { $deviceList[]['DeviceName'] = $phone; } //Query the RisPort API to get IP/Registration status $devices = Utils::generateEraserList($deviceList, $cluster, false); //Get details for the phone_firmware report type $report = Report::where('type', 'phone_firmware')->first(); //Create file name for report $fileName = storage_path() . '/' . $report->path . 'firmware-report-' . Carbon::now('America/New_York')->toDateTimeString() . '.csv'; //Generate new output csv file new CsvFile($fileName); //Call the App\Jobs\GetPhoneFirmware Job $this->dispatch(new $report->job($devices, $fileName, $report->csv_headers)); //Return a response with the firmware report return response()->download($fileName); }
/** * @return \yii\db\ActiveQuery */ public function getReports() { return $this->hasMany(Report::className(), ['problem_category' => 'id_problem_category']); }
/** * @throws \PHPExcel_Exception * @throws \PHPExcel_Writer_Exception */ public function handle() { //Create the reporting Excel Object $objPHPExcel = new PHPExcel(); //Check if the recipient is assigned to a group. If not, log and continue. if ($this->user->duoGroups()->count()) { $groups = $this->user->duoGroups()->get(); } else { \Log::debug($this->user->username . ' has no groups:', [$this->user]); } //Set timestamp for file names $timeStamp = Carbon::now('America/New_York')->toDateTimeString(); //Get our Report object $duoReport = Report::where('name', 'DuoRegisteredUsersReport')->first(); $fileName = storage_path() . '/' . $duoReport->path . $timeStamp . '-' . $duoReport->name . '-' . $this->user->username . '.xlsx'; //Loop each Duo Group foreach ($groups as $group) { //Explode csv_headers to array $duoReportHeaders = explode(',', $duoReport->csv_headers); //Create the group main worksheet $this->createWorksheet($objPHPExcel, $group->name, $duoReportHeaders); //Create the 'not enrolled' worksheet $notEnrolledWorksheetName = $group->name . ' - Not Enrolled'; $this->createWorksheet($objPHPExcel, $notEnrolledWorksheetName, $duoReportHeaders); //Create an array to track users that haven't enrolled. $usersNotEnrolled = []; //Set the active sheet to the main group sheet $objPHPExcel->setActiveSheetIndexByName($group->name); //Get all users that belong to this group $duoGroupMembers = $group->duoUsers()->get(); /* * Write User data */ $row = 2; foreach ($duoGroupMembers as $member) { //Check if the user has a registered phone or token if ($member->duoPhones()->count() || $member->duoTokens()->count()) { //Record the user details in the main worksheet $objPHPExcel->getActiveSheet()->setCellValue('A' . $row, $member->username); $objPHPExcel->getActiveSheet()->setCellValue('B' . $row, $member->email); $objPHPExcel->getActiveSheet()->setCellValue('C' . $row, $member->status); $objPHPExcel->getActiveSheet()->setCellValue('D' . $row, $member->last_login); $objPHPExcel->getActiveSheet()->setCellValue('E' . $row, $member->duoGroups()->first()->name); $row++; } else { //This user hasn't enrolled. //We'll write their info to another worksheet. array_push($usersNotEnrolled, $member); } } //Set the active sheet to the 'not enrolled' group sheet $objPHPExcel->setActiveSheetIndexByName($notEnrolledWorksheetName); /* * Write 'not enrolled' data */ $row = 2; foreach ($usersNotEnrolled as $user) { //Record the user details in the 'not enrolled' worksheet $objPHPExcel->getActiveSheet()->setCellValue('A' . $row, $user->username); $objPHPExcel->getActiveSheet()->setCellValue('B' . $row, $user->email); $objPHPExcel->getActiveSheet()->setCellValue('C' . $row, $user->status); $objPHPExcel->getActiveSheet()->setCellValue('D' . $row, 'Not Enrolled'); $objPHPExcel->getActiveSheet()->setCellValue('E' . $row, $user->duoGroups()->first()->name); $row++; } unset($usersNotEnrolled); } //Remove the default sheet (there's gotta be a better way to do this....) $objPHPExcel->removeSheetByIndex(0); //Write the document $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); $objWriter->save($fileName); //Reports are done running, let's email to results $beautymail = app()->make(\Snowfire\Beautymail\Beautymail::class); $beautymail->send('emails.duo-registered-users', [], function ($message) use($fileName) { //TODO: Create system for users to manage report subscriptions. $message->from('*****@*****.**', 'Duo Reporting')->to($this->user->email)->subject('Duo Registered Users Report')->attach($fileName); }); }
public function actionLoad_report_month_all() { $order_model = new \app\models\OrdersTransportAffiliated(); $year = \Yii::$app->request->post('year'); $month = \Yii::$app->request->post('month'); $report = new Report(); $result = $report->report_month_all($year, $month); //รายได้จากการจ้างบริษัทรถร่วมวิ่ง $order_out = $order_model->find()->where(['YEAR(create_date)' => $year, 'SUBSTR(create_date,6,2)' => $month])->all(); //$truck_no_map = $report->get_truck_nomap($year, $month);//ค่าใช้จ่ายของรถในเดือนนี้ที่ยังไม่ได้ต่อรถ return $this->renderPartial('load_report_month_all', ['year' => $year, 'month' => $month, 'result' => $result, 'order_out' => $order_out]); }
/** * postReports * * Up a report of incidence user * * @access public * @params soid => string message => string report_category_id => integer * @return json * @autor Fernando Saavedra * * */ public function postReports() { $request = Request::all(); $user = User::where("soid", "=", $request["soid"])->first(); //dd($user->id); $report = new Report(); $report->soid = $request["soid"]; $report->message = $request["message"]; $report->user_id = $user->id; $report->report_category_id = $request["report_category_id"]; $report->save(); return Response::json(array("success" => true, "service" => __FUNCTION__, "message" => "Reporte levantado exitosamente")); }
public function AddForAll() { $organizations = \App\Models\Organization::all(); foreach ($organizations as $organization) { $id = $organization->id; $reports = $organization->reports; if ($reports->count()) { $maxYear = \App\Models\Report::where('organization_id', '=', $id)->max('year'); $maxQuarter = \App\Models\Report::where('organization_id', '=', $id)->where('year', '=', $maxYear)->max('quarter'); if ($maxQuarter == 4 && $maxYear != 2016) { $year = ++$maxYear; $report = new \App\Models\Report(); $report->year = $year; $report->quarter = 1; $report->organization_id = $id; $report->state = 'not_accepted'; $report->save(); } elseif ($maxQuarter != 4) { $quarter = $maxQuarter + 1; $report = new \App\Models\Report(); $report->year = $maxYear; $report->quarter = $quarter; $report->organization_id = $id; $report->state = 'not_accepted'; $report->save(); } } else { $report = new \App\Models\Report(); $report->year = 2015; $report->quarter = 1; $report->organization_id = $id; $report->state = 'not_accepted'; $report->save(); } } return redirect()->back(); }
/** * Finds the Report model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Report the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Report::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getReports() { return $this->hasMany(Report::className(), ['sms_id' => 'idRawSMSData']); }
/** * @return \yii\db\ActiveQuery */ public function getReport() { return $this->hasOne(Report::className(), ['date' => 'create_time', 'location_id' => 'location_id']); }
/** * @return \yii\db\ActiveQuery */ public function getReports() { return $this->hasMany(Report::className(), ['id_language' => 'id_language']); }
/** * @return \yii\db\ActiveQuery */ public function getReports() { return $this->hasMany(Report::className(), ['disability_category' => 'id_disability_category']); }
public function actionGet_truck_act() { $car_id = \Yii::$app->request->post('car_id'); $year = \Yii::$app->request->post('year'); $month = \Yii::$app->request->post('month'); $report = new \app\models\Report(); $result = $report->get_truck_act($year, $month, $car_id); return $this->renderPartial('sub_outgoing', ['result' => $result]); }