Esempio n. 1
0
 /**
  * Save attached Media to existing Issue
  */
 public function saveAttachedMedia($file)
 {
     $site = Site::findOrFail($this->site_id);
     $path = "filebank/site/" . $site->id . '/issue';
     $name = 'issue-' . $site->code . '-' . $this->id . '-' . Auth::user()->id . '-' . sha1(time()) . '.' . strtolower($file->getClientOriginalExtension());
     $path_name = $path . '/' . $name;
     $file->move($path, $name);
     // resize the image to a width of 1024 and constrain aspect ratio (auto height)
     if (exif_imagetype($path_name)) {
         Image::make(url($path_name))->resize(1024, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save($path_name);
     } else {
         Toastr::error("Bad image");
     }
     $this->photo = $name;
     $this->save();
 }
Esempio n. 2
0
 /**
  * Reject the given doc and return it to inactive.
  */
 public function reject(Request $request, $id)
 {
     $doc = WmsDoc::findOrFail($id);
     $doc->principle_signed_id = null;
     $doc->principle_signed_date = '0000-00-00 00:00:00';
     $doc->user_signed_id = null;
     $doc->user_signed_date = '0000-00-00 00:00:00';
     $doc->status = 0;
     $doc->save();
     if ($doc->for_company_id == Auth::user()->company->id) {
         Toastr::info("Sign off request cancelled");
     } else {
         Toastr::error("Rejected sign off");
     }
     return redirect('/safety/doc/wms/' . $doc->id . '/edit');
 }
Esempio n. 3
0
 /**
  * store the posts data in database and bind the image
  *
  * @param PostsFormRequest $request
  * @return mixed
  */
 public function store(PostsFormRequest $request)
 {
     if (\Input::hasFile('image')) {
         $post = $this->repository->createPost($request, \Input::file('image'));
     } else {
         Toastr::error(trans('messages.imageError'), $title = Auth::user()->name, $options = []);
         return redirect()->back();
     }
     Toastr::success(trans('messages.yourPostCreated'), $title = $post->title, $options = []);
     return redirect()->to(App::getLocale() . '/blog/post/' . $post->id);
 }
 public function jobstartPDF(Request $request)
 {
     $today = Carbon::now()->format('Y-m-d');
     $planner = DB::table('site_planner AS p')->select(['p.id', 'p.site_id', 'p.entity_type', 'p.entity_id', 'p.task_id', 'p.from', 't.code'])->join('trade_task as t', 'p.task_id', '=', 't.id')->whereDate('p.from', '>=', $today)->where('t.code', 'START')->orderBy('p.from')->get();
     //dd($planner);
     $startdata = [];
     foreach ($planner as $plan) {
         $site = Site::findOrFail($plan->site_id);
         $entity_name = "Carpenter";
         if ($plan->entity_type == 'c') {
             $entity_name = Company::find($plan->entity_id)->name;
         }
         $startdata[] = ['date' => Carbon::createFromFormat('Y-m-d H:i:s', $plan->from)->format('M j'), 'code' => $site->code, 'name' => $site->name, 'company' => $entity_name];
     }
     $pdf = PDF::loadView('pdf/plan-jobstart', compact('startdata'));
     if ($request->has('view_pdf')) {
         return $pdf->stream();
     }
     if ($request->has('email_pdf')) {
         /*$file = public_path('filebank/tmp/jobstart-' . Auth::user()->id  . '.pdf');
           if (file_exists($file))
               unlink($file);
           $pdf->save($file);*/
         if ($request->get('email_list')) {
             $email_list = explode(';', $request->get('email_list'));
             $email_list = array_map('trim', $email_list);
             // trim white spaces
             $data = ['user_fullname' => Auth::user()->fullname, 'user_company_name' => Auth::user()->company->name, 'startdata' => $startdata];
             Mail::send('emails/jobstart', $data, function ($m) use($email_list, $data) {
                 $user_email = Auth::user()->email;
                 $user_email ? $send_from = $user_email : ($send_from = '*****@*****.**');
                 $m->from($send_from, Auth::user()->fullname);
                 $m->to($email_list);
                 $m->subject('Upcoming Job Start Dates');
             });
             if (count(Mail::failures()) > 0) {
                 foreach (Mail::failures as $email_address) {
                     Toastr::error("Failed to send to {$email_address}");
                 }
             } else {
                 Toastr::success("Sent email");
             }
             return view('planner/export/start');
         }
     }
 }