/** * Make image response. * * @param $file * @return \Illuminate\Http\Response */ public function image($file) { $image = $this->document->image($file); $reqEtag = Request::getEtags(); $genEtag = $this->document->etag($file); if (isset($reqEtag[0])) { if ($reqEtag[0] === $genEtag) { return response('', 304); } } return response($image->encode('png'), 200, ['Content-Type' => 'image/png', 'Cache-Control' => 'public, max-age=0', 'Etag' => $genEtag]); }
protected function fillFooter() { foreach ($this->document->scripts as $pack) { foreach ($pack as $file) { $this->footer[] = '<script src="' . $file . '"></script>'; } } $this->document->addJsSettings(['locale' => app('contentLang')]); $this->document->addScript('token', "var token = '{$_SESSION['csrf_token']}';"); $this->document->addScript('extend', '$.extend(syd, ' . json_encode($this->document->js) . ');'); $this->footer[] = '<ul id="notify"></ul>'; $this->footer[] = '<script>' . "\n" . implode("\n\n", $this->document->internal_scripts) . "\n" . '</script>'; }
/** * Save an entry * * @return Response */ public function save(Request $request) { $this->validate($request, ['title' => 'required|max:255', 'description' => 'required']); if (Storage::move('.tmp/' . $request->filename, 'files/' . $request->filename)) { $document = new Document(); $document->title = $request->title; $document->description = $request->description; $document->course = $request->course; $document->professor = $request->professor; $document->filename = $request->filename; $document->approved = false; $document->save(); } return 'f**k'; }
/** * Get all of the Documents for a given user. * * @param User $user * @return Collection */ public function forUser(User $user) { return Document::all(); //('user_id', $user->id) //->orderBy('created_at', 'asc') //->get(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['file' => 'required']); $file = $request->file('file'); if ($file->isValid()) { $name = $file->getClientOriginalName(); $key = 'documents/' . $name; Storage::disk('s3')->put($key, file_get_contents($file)); $document = new Document(); $document->name = $name; $document->file = $key; $document->save(); $document->requestPreview(); } return redirect('documents'); }
/** * Display the specified resource. * * @param string $uuid * @return \Illuminate\Http\Response */ public function show($uuid) { $doc = Document::byUuid($uuid); if (!$doc) { abort(404); } return view('documents.show', compact('doc')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if (!$request->hasFile('document')) { /** @todo Error handling */ throw new RuntimeException('No document :('); } $file = $request->file('document'); $filename = $file->getClientOriginalName(); $data = $file->openFile()->fread($file->getSize()); $document = new Document(); $document->data = $data; $document->filename = $filename; $document->mime_type = $file->getMimeType(); $document->title = $request->input('title', $filename); $document->save(); return redirect()->route('documents.index')->with('message', 'Document created successfully.'); }
/** * Handle the event. * * @param array $results * @return void */ public function handle($results) { $document_id = $results['user_data']['document_id']; $document = Document::find($document_id); $document->preview_url = $results['preview']['url']; $document->preview = json_encode($results); $document->save(); Event::fire(new FilePreviewsGenerated($document)); }
/** * [update description] * @param [type] $id [description] * @return [type] [description] */ public function update(UpdateDocumentRequest $request, $id) { $document = Document::find($id); if (!$document) { return $this->respondNotFound('Document does not exist'); } // Call fill on the document and pass in the data $document->fill(Input::all()); $document->save(); return $this->respondNoContent(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $documents = \App\Document::all(); foreach ($documents as $document) { $path = base_path('docs' . DIRECTORY_SEPARATOR . $document->name); $document->content = \File::get($path); $document->save(); $document->touch(); $this->info(sprintf('Success updating %d: %s', $document->id, $document->name)); } $this->warn('Finished.'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $entity = \App\Document::find($id); $wi = new \WorkflowInstance('material-request', $entity->id, $entity->state, $entity); if ($request->get('op_type') == 'state_change') { $new_state = $request->get('new_state'); $wi->setState($new_state); $entity->state = $new_state; $entity->save(); } // end if op_type is state_change return Redirect('/'); }
protected function postComment(Request $request) { if ($request->exists('comment')) { if ($request->exists('approve')) { $user = Auth::user(); $user_id = $user->id; $document_id = $request->document_id; Document::where('id', $document_id)->update(['status' => 'approved']); Comment::create(['comment' => $request->comment, 'boss_id' => $user->id, 'document_id' => $document_id]); return Redirect::route('documents')->with('success', 'Document approved successful'); } else { if ($request->exists('decline')) { $user = Auth::user(); $user_id = $user->id; $document_id = $request->document_id; Document::where('id', $document_id)->update(['status' => 'declined']); Comment::create(['comment' => $request->comment, 'boss_id' => $user->id, 'document_id' => $document_id]); return Redirect::route('documents')->with('success', 'Document declined successful'); } } } else { return Redirect::route('documents')->with('fail', 'Something wrong!!'); } }
public function documentsValidated($id, $value) { $course = Course::with(['users' => function ($query) { $query->where('level', 1); }, 'manager'])->find($id); if (empty($course)) { Flash::error('Ce cours n\'existe pas.'); return abort(404); } if (Auth::user()->level_id <= 3 && !$course->users->contains(Auth::user())) { Flash::error('Vous n\'avez pas les droits suffisants.'); return Redirect::back(); } if ($value != 0 && $value != 1) { Flash::error('Requête invalide.'); return Redirect::back(); } $documents = Document::where('course_id', $id)->where('validated', $value)->with('author')->paginate(15); $filter = $value == 0 ? 'invalidés' : 'validés'; return view('admin.courses.documents', compact('documents', 'filter', 'course')); }
/** * Create new Document instances in the DB, * Move the original file to document directory. * * @param $singleDimArr * @param $directoryPath * @param $projectID * @param $originalProjectSlug */ protected function moveDocumentsAndSaveToDB($singleDimArr, $directoryPath, $projectID, $originalProjectSlug) { foreach ($singleDimArr as $file) { if (!is_null($file)) { if ($file instanceof UploadedFile) { Document::create(['filename' => preg_replace('/[\\s]+/', '_', $file->getClientOriginalName()), 'project_id' => $projectID]); $file->move($directoryPath, preg_replace('/[\\s]+/', '_', $file->getClientOriginalName())); } else { // In the instance the user renames the project, move the saved documents to the new directory. $originalDirectory = public_path('documents/' . $originalProjectSlug); if (is_dir($originalDirectory)) { $originalFile = file_get_contents($originalDirectory . '/' . $file); file_put_contents($directoryPath . '/' . $file, $originalFile); } } } } }
/** * Execute the command. * * @return void */ public function handle() { $document = Document::create($this->data); event(new FeedableEvent('DocumentUploaded', $this->user, $document, null)); return $document; }
public function store(Request $request) { $validator = $this->validator($request->all()); if ($validator->fails()) { Flash::error('Impossible d\'ajouter le document, veuillez vérifier les champs renseignés, ainsi que le format de votre document.'); return Redirect::back()->withErrors($validator->errors()); } $file = $request->file('file'); $ext = $file->getClientOriginalExtension(); $clientName = $file->getClientOriginalName(); $destPath = public_path() . '/files/documents'; $fileName = $request->course_id . Auth::user()->id . date('dmYHis') . rand(10000, 99999) . '.' . $ext; if ($file->move($destPath, $fileName)) { $title = $request->title; $description = $request->description; $user_id = Auth::user()->id; $course_id = $request->course_id; Document::create(['title' => $title, 'name' => $fileName, 'description' => $description, 'course_id' => $course_id, 'user_id' => $user_id]); Flash::success('Le document a bien été ajouté.'); } else { Flash::error('Une erreur est survenue. Veuillez réessayer. Si le problème persiste, contactez un administrateur.'); } return Redirect::back(); }
public static function downloadLink($file_name) { $link = url('/'); if (Laralum::isDocument($file_name)) { $document = Document::where('name', $file_name)->first(); $link = route('Laralum::document_downloader', ['slug' => $document->slug]); } return $link; }
public function document_view($id) { $objDocument = \App\Document::findOrFail($id); $Filename = $objDocument->filename; if (!$this->objLoggedInUser->HasPermission("View/Documents") || !$Filename) { abort('404'); } $tmp = explode(".", $Filename); switch ($tmp[count($tmp) - 1]) { case "pdf": $ctype = "application/pdf"; break; case "exe": $ctype = "application/octet-stream"; break; case "zip": $ctype = "application/zip"; break; case "docx": case "doc": $ctype = "application/msword"; break; case "csv": case "xls": case "xlsx": $ctype = "application/vnd.ms-excel"; break; case "ppt": $ctype = "application/vnd.ms-powerpoint"; break; case "gif": $ctype = "image/gif"; break; case "png": $ctype = "image/png"; break; case "jpeg": case "jpg": $ctype = "image/jpg"; break; case "tif": case "tiff": $ctype = "image/tiff"; break; case "psd": $ctype = "image/psd"; break; case "bmp": $ctype = "image/bmp"; break; case "ico": $ctype = "image/vnd.microsoft.icon"; break; default: $ctype = "application/force-download"; } header("Content-type: {$ctype}"); // It will be called downloaded.pdf header("Content-Disposition:attachment;filename='{$Filename}'"); echo Storage::get("Documents/{$Filename}"); }
/** * Download the current document as a raw file * @method showpdf * @param [type] $id [description] * @return [type] [description] */ public function showraw($id) { $document = Document::find($id); return Response::download(storage_path('documents') . DIRECTORY_SEPARATOR . $document->raw_file_path); }
/** * Delete the given Document. * * @param int $id * @return Redirect */ public function getDelete($id = null) { $document = Document::destroy($id); // Redirect to the group management page return redirect('admin/documents')->with('success', Lang::get('message.success.delete')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $documents) { // check that the file is valid if ($request->hasFile('original_file') && (!$request->file('original_file')->isValid() || $request->file('original_file')->getClientMimeType() !== 'text/xml')) { throw new Exception('Please upload a valid xml document.'); } if ($request->hasFile('original_file')) { return $this->storeFile($request); } $input = Input::all(); $document = Document::find($documents); $document->update($input); if (!empty($input['tags'][0])) { Tag::resolveTags($document, explode(',', $input['tags'][0])); } if ($file_original_name = Session::get('file_original_name')) { // get the file $file_temp_name = Session::get('file_temp_name'); $file_temp_path = ".." . DIRECTORY_SEPARATOR . "temp"; $file_temp = $file_temp_path . DIRECTORY_SEPARATOR . $file_temp_name; $file_new_name = "{$document->id}_{$file_original_name}_raw.xml"; $file_new_name_p = "{$document->id}_{$file_original_name}_parsed.pdf"; $file_new_path = ".." . DIRECTORY_SEPARATOR . "documents"; $file_new = $file_new_path . DIRECTORY_SEPARATOR . $file_new_name; Storage::move($file_temp, $file_new); // update the document $document->update(['raw_file_path' => $file_new_name, 'parsed_file_path' => $file_new_name_p]); Event::fire(new DocumentWasUploaded($document)); Session::pull('file_original_name'); Session::pull('file_temp_name'); Session::pull('file_temp_path'); } return $this->operationSuccessful(); }
/** * Generate doc and download. * * @param int $id * @return \Illuminate\Http\Response */ public function download($id) { $document = Document::findOrFail($id); $phpWord = new PhpWord(); $template = public_path() . "/download/template.docx"; $file = public_path() . "/download/result.docx"; $download = $phpWord->loadTemplate($template); $download->setValue('COMPANY', $document->company); $download->setValue('OWNER', $document->owner); $download->saveAs($file); $headers = array('Content-Type: application/docx'); return response()->download($file, 'result.docx', $headers); }
/** * Update the specified resource in storage. * * @param Inscription $inscription * @return Response */ public function update(Inscription $inscription, Request $request) { $this->authorize('edit', $inscription); //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input. //$inscription = Inscription::findOrFail($id); if (!isset($request['step']) || $request['step'] < 1 && $request['step'] > 3) { return redirect('inscription.create'); } //actualizar estudiante if ($request['step'] == 1) { $inscription->student->update($request->all()); //actualizar grupo if ($inscription->group_id != $request['group_id']) { //buscar grupo anterior $inscription->group->students()->detach($inscription->student); //agregamos al nuevo $inscription->group_id = $request['group_id']; $group = Group::find($request['group_id']); $group->students()->attach($inscription->student); } $inscription->update($request->all()); //mostrar paso 2 return view('inscription.step2', compact('inscription')); } elseif ($request['step'] == 2) { if ($request['tutor_id'] != 0 && $inscription->tutor_id != $request['tutor_id']) { $inscription->student->tutor_id = $request['tutor_id']; $inscription->student->save(); } if ($inscription->student->tutor) { $inscription->student->tutor->update($request->all()); } else { $inscription->student->tutor_id = Tutor::create($request->all())->id; $inscription->student->save(); } //mostrar paso 3 ... return view('inscription.step3', compact('inscription')); } elseif ($request['step'] == 3) { if ($inscription->student->document) { $request['student_id'] = $inscription->student_id; $inscription->student->document->update($request->all()); } else { $request['student_id'] = $inscription->student_id; Document::create($request->all()); return redirect()->route('inscription.show', [$inscription]); } } return redirect('inscription'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Project $project, Document $document) { $document->delete(); return response()->json(['status' => 'success', 'message' => 'Document deleted.']); }
/** * Get the model instance or create one. * * @param string $file * @return mixed */ public function find($file) { return Document::whereName($file)->first() ?: Document::create(['author_id' => 1, 'name' => $file, 'content' => File::get($this->getPath($file))]); }
public function input2(Request $request) { $Sheet = $request->input('Document_ID'); //Проверяем документ на ведомость $document = DB::connection('sqlsrv')->table('Documents')->selectRaw('DocumentType_Code,Document_ID')->where('Document_ID', $Sheet)->where('DocumentType_Code', 170)->get(); if ($document->isEmpty()) { $Point_ID = $request->input('point_id'); $Reading_Value = $request->input('Reading_Value'); $PReading_Value = $request->input('PReading_Value'); $Action_Date = $request->input('Action_Date'); $MeterReading_ID = $request->input('MeterReading_ID'); $ReadingType_Code = $request->input('ReadingType_Code'); if (Input::has("MeterReading_ID0")) { $MeterReading_ID = $request->input('MeterReading_ID0'); $Reading_Value = $request->input('Reading_Value0'); $PReading_Value = $request->input('PReading_Value0'); $Document_ID = $request->input('Document_ID0'); $ReadingType_Code = $request->input('ReadingType_Code0'); DB::connection('sqlsrv')->table('MeterReadings')->where('MeterReading_ID', $MeterReading_ID)->update(['Reading_Value' => $Reading_Value, 'Reading_Difference_Value' => $Reading_Value - $PReading_Value, 'Daily_Difference_Value' => ($Reading_Value - $PReading_Value) / 30]); $MeterReadings = DB::connection('sqlsrv')->table('MeterReadings')->where('MeterReading_ID', $MeterReading_ID)->first(); $PointActions = DB::connection('sqlsrv')->table('PointActions')->where('Meter_ID', $MeterReadings->Meter_ID)->where('Document_ID', $Document_ID)->where('PointAction_ID', $MeterReadings->PointAction_ID)->first(); DB::connection('sqlsrv')->table('PointConsumptions')->where('PointAction_ID', $PointActions->PointAction_ID)->where('Point_ID', $PointActions->Point_ID)->where('Deal_ID', $PointActions->Deal_ID)->where('Document_ID', $PointActions->Document_ID)->update(['PointConsumption_Value' => $Reading_Value - $PReading_Value]); $PointConsumptions = DB::connection('sqlsrv')->table('PointConsumptions')->where('PointAction_ID', $PointActions->PointAction_ID)->where('Point_ID', $PointActions->Point_ID)->where('Deal_ID', $PointActions->Deal_ID)->where('Document_ID', $PointActions->Document_ID)->first(); $PointConsumptionItems = DB::connection('sqlsrv')->table('PointConsumptionItems')->where('PointConsumption_ID', $PointConsumptions->PointConsumption_ID)->first(); DB::connection('sqlsrv')->table('PointConsumptionItems')->where('PointConsumption_ID', $PointConsumptions->PointConsumption_ID)->update(['PointConsumptionItem_Value' => $Reading_Value - $PReading_Value, 'DailyConsumption_Value' => ($Reading_Value - $PReading_Value) / $PointConsumptionItems->Days_Count]); DB::connection('sqlsrv')->table('PointConsumptionStatuses')->where('PointConsumption_ID', $PointConsumptions->PointConsumption_ID)->update(['PointConsumption_Value' => $Reading_Value - $PReading_Value]); DB::connection('sqlsrv')->table('MeterConsumptions')->where('PointConsumptionItem_ID', $PointConsumptionItems->PointConsumptionItem_ID)->update(['MeterConsumption_Value' => $Reading_Value - $PReading_Value]); DB::connection('sqlsrv')->table('PointConsumptionItemLines')->where('PointConsumptionItem_ID', $PointConsumptionItems->PointConsumptionItem_ID)->where('ReadingType_Code', $ReadingType_Code)->update(['PointConsumptionItemLine_Value' => $Reading_Value - $PReading_Value, 'DailyPointConsumptionItemLine_Value' => ($Reading_Value - $PReading_Value) / $PointConsumptionItems->Days_Count]); } Session::flash('msg', 'Успешно обновлено'); $ConsumptionSheet_ID = Session::get('ConsumptionSheet_ID'); $results = DB::connection('sqlsrv')->table('ConsumptionSheets')->join('MeteringRoutePoints', 'MeteringRoutePoints.Document_ID', '=', 'ConsumptionSheets.MeteringRoute_ID')->join('DealPoints', 'DealPoints.Point_ID', '=', 'MeteringRoutePoints.Point_ID')->join('Deals', 'Deals.Deal_ID', '=', 'DealPoints.Deal_ID')->join('PointAssets', 'PointAssets.Point_ID', '=', 'MeteringRoutePoints.Point_ID')->join('Assets', 'Assets.Asset_ID', '=', 'PointAssets.Asset_ID')->select('ConsumptionSheet_ID', 'MeteringRoutePoints.Point_ID', 'MeteringRoutePoints.Document_ID', 'Deals.Deal_ID', 'Deal_Num', 'Subject_Name', 'Address_Name', 'Serial_Number')->where('ConsumptionSheets.ConsumptionSheet_ID', $ConsumptionSheet_ID)->get(); return View::make('admin.legal.list', compact('results')); } $id = Document::insertGetId(['Document_Num' => 'б/н', 'Document_Date' => '2016-09-30', 'DocumentType_Code' => '108', 'Comments' => '{"Deal_ID":' . $Sheet . ',"Deal_Num":' . $Sheet . ',"Is_Deal_Num_Incomplete":false,"Subject_Name":"","Supplier_Name":"","SupplierServices_Names":"","ReadingsReadBy":"Supplier","Person":"Каниболоцкий С. В.","Person_ID":6865254,"Action_Date":"30.09.2016","BaseDocumentType_Code":1,"CorrectionPeriodId":" ","calculationMethod":0,"calculationMethodDate":null,"pStatusCode":1,"p_DealType_Code":["2"],"p_Deal_ID":"","p_Deal_Num":"","p_Subject_Name":"","Is_Include_Agreements":true,"Is_Include_Accounts":false,"p_Substation_IDs":"","p_Substation_Names":"","p_ConsumptionGroup_Code":"","p_BranchGroup_IDs":"","p_BranchGroup_Names":"","p_District_Codes":"","p_District_Names":"","p_Department_IDs":"","p_Department_Names":"","p_Supplier_IDs":"","p_Supplier_Names":"Все","p_Point_ID":"","p_Point_Name":""}', 'Date_Fix' => '2016-09-30', 'User_ID' => 167, 'Date_Create' => date('Y-m-d H:i'), 'Period_ID' => 92, 'Status_ID' => 2565, 'Status_User_ID' => '167', 'Status_Date' => date('Y-m-d H:i')]); $id = new Document(); $id->Document_Num = 'б/н'; $id->Document_Date = '2016-09-30'; $id->DocumentType_Code = '108'; $id->save(); echo $id->id; }
public function deleteDocument($id) { $document = Document::find($id); if (isset($document)) { Document::where('id', $id)->update(['status' => 'deleted']); } return Redirect::route('documents')->with('success', 'Document deleted successful.'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $document = Document::find($id); $document->delete(); Flash::error('El dococumento con el asunto ' . $document->asunto . " ha sido eliminado de forma exitosa."); return redirect()->route('document.index'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $document = \App\Document::FindOrFail($id); $document->delete(); return redirect('document'); }