/** * 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); }
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(); }
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']); }
/** * 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; }
public function actionJsonrecords($param) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return Report::find($param)->all(); }
/** * 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); }
public function postReportStateNotAccepted($id) { $report = \App\Models\Report::find($id); $report->state = 'not_accepted'; $report->save(); return redirect()->back(); }