public function single($mr, $currentMonth) { $actualVisits = []; $MonthlyCustomerProducts = []; $MRLine = []; $doctors = Customer::where('mr_id', $mr)->get(); foreach ($doctors as $singleDoctor) { $actualVisits[$singleDoctor->id] = Report::where('mr_id', $mr)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count(); $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray(); } $products = Product::where('line_id', Employee::findOrFail($mr)->line_id)->get(); $coverageStats = Employee::coverageStats($mr, $currentMonth); $allManagers = Employee::yourManagers($mr); $totalProducts = Employee::monthlyDirectSales($mr, $currentMonth); $totalSoldProductsSales = $totalProducts['totalSoldProductsSales']; $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice']; $currentMonth = \Carbon\Carbon::parse($currentMonth); $lines = MrLines::select('line_id', 'from', 'to')->where('mr_id', $mr)->get(); foreach ($lines as $line) { $lineFrom = \Carbon\Carbon::parse($line->from); $lineTo = \Carbon\Carbon::parse($line->to); if (!$currentMonth->lte($lineTo) && $currentMonth->gte($lineFrom)) { $MRLine = MrLines::where('mr_id', $mr)->where('line_id', $line->line_id)->get(); } } $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice, 'MRLines' => $MRLine]; return view('am.line.single', $dataView); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(EmployeeRequest $request, $id) { $employee = Employee::findOrFail($id); $employee->update($request->all()); flash()->success('Success!', 'Employee details saved successfully!'); return redirect('employees'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $employee = Employee::findOrFail($id); $name = $employee->name . " " . $employee->lastname; Employee::destroy($id); return redirect(route('employees.index'))->with('message', 'Empleado ' . $name . ' eliminado corectamente'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $employee = Employee::findOrFail(Input::get('id')); $employee->first_name = Input::get('first_name'); $employee->last_name = Input::get('last_name'); $employee->name = Input::get('first_name') . ' ' . Input::get('last_name'); $employee->email = Input::get('email'); $employee->position = Input::get('position'); $employee->phone = Input::get('phone'); $employee->location_id = Input::get('location'); $employee->status = 1; $employee->role_id = 5; $employee->department = Input::get('department'); $employee->extension_no = Input::get('extension_no'); $employee->vehicle_no = Input::get('vehicle_no'); $employee->save(); return Response::json(array('success' => 'Employee has been updated!')); }
public function doCreate(CreateMessageRequest $request) { $uploaded = false; foreach ($request->employees as $key => $singleEmployee) { $user = Employee::findOrFail($singleEmployee); $message = new Message(); $message->sender = \Auth::user()->id; $message->receiver = $singleEmployee; $message->subject = $request->subject; $message->time = \Carbon\Carbon::now()->toTimeString(); if ($message->save()) { $messageReply = new MessageReply(); $messageReply->sender = \Auth::user()->id; $messageReply->msg_id = $message->id; $messageReply->text = $request->message; $messageReply->time = \Carbon\Carbon::now()->toTimeString(); \File::makeDirectory(public_path('uploads/inbox/') . $message->id); if ($messageReply->save()) { if ($request->file('attachment')) { $file = $request->file('attachment'); $messageReply->is_attachment = 1; $messageReply->save(); $extension = $file->getClientOriginalExtension(); if ($file->isValid()) { if ($uploaded) { copy($uploaded, public_path('uploads/inbox/' . $this->originalDir)); } else { if ($file->move(public_path('uploads/inbox/' . $message->id), $messageReply->id . '.' . $extension)) { $uploaded = public_path('uploads/inbox/' . $message->id) . '/' . $messageReply->id . '.' . $extension; $this->originalDir = $message->id; } } } } } \Mail::send('admin.emails.new_message', ['user' => $user], function ($m) use($user) { $m->from('*****@*****.**', 'CloudsCRM'); $m->to($user->email, $user->name)->subject('New Message!'); }); } } return redirect()->back()->with('message', 'Message has been sent successfully !'); }
public function single($currentMonth) { $actualVisits = []; $MonthlyCustomerProducts = []; $doctors = Customer::where('mr_id', \Auth::user()->id)->get(); foreach ($doctors as $singleDoctor) { $actualVisits[$singleDoctor->id] = Report::where('mr_id', \Auth::user()->id)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count(); $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray(); } $products = Product::where('line_id', Employee::findOrFail(\Auth::user()->id)->line_id)->get(); $coverageStats = Employee::coverageStats(\Auth::user()->id, $currentMonth); $allManagers = Employee::yourManagers(\Auth::user()->id); $totalProducts = Employee::monthlyDirectSales(\Auth::user()->id, $currentMonth); $totalSoldProductsSales = $totalProducts['totalSoldProductsSales']; $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice']; $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice]; \Session::set('customers', $doctors); return view('mr.line.single', $dataView); }
public function logDriver($id) { return $id == 999999999 ? 'Client Driver' : ($id == 0 ? '' : Employee::findOrFail($id)->name); }
public function postEditSMProfile(SMRequest $request) { $employee = Employee::findOrFail(\Auth::user()->id); $employee->name = $request->name; $employee->email = $request->email; $employee->password = \Hash::make($request->password); try { $employee->save(); return redirect()->back()->with('message', 'Your Profile has been updated successfully !'); } catch (ParseException $ex) { echo 'Failed to update your profile , with error message: ' . $ex->getMessage(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $employee = Employee::findOrFail($id); $employee->delete(); return Redirect::action('EmployeeController@index'); }
public function update(Request $request, $id) { $employee = Employee::findOrFail($id); $employee->update($request::all()); return $employee; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $employee = Employee::findOrFail($id)->delete(); return Redirect::route('admin.employee.list.index')->withFlashSuccess('Employee data was successfully deleted.'); }
/** * Store client information associated with driver * @param Request $request * Created by smartrahat Date: 04.11.2015 Time: 02:39PM * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function changeClient(Request $request) { $request['action'] = 'Add'; $request['c_description'] = 'Add driver'; $request['e_description'] = 'Assign to client'; $employee = Employee::findOrFail($request['eid']); $employee->update($request->only('cid')); Log::create($request->all()); return redirect('employee/' . $request['eid']); }
public function handleDeleteEmployee() { // Handle the delete confirmation. $id = Input::get('employee'); $employee = Employee::findOrFail($id); $employee->delete(); return Redirect::action('CommonController@employees'); }
public function removeDriver(Request $request) { $redirect = $request['cid']; $request['c_description'] = 'Driver removed'; $request['e_description'] = 'Removed form client'; $request['action'] = 'Remove'; Log::create($request->all()); // update log $driver = Employee::findOrFail($request['eid']); $request['cid'] = 0; $driver->update($request->only(['cid'])); // update driver's foreign key return redirect('client/' . $redirect); }
public function doDelete($id) { $employee = Employee::findOrFail($id); try { $this->deletAvatar($id); $employee->delete(); return redirect()->back()->with('message', 'Employee has been deleted successfully !'); } catch (ParseException $ex) { echo 'Failed to delete this employee , with error message: ' . $ex->getMessage(); } }
public function search() { $doctors = Customer::where('mr_id', \Auth::user()->id)->get(); $MRLine = Employee::findOrFail(\Auth::user()->id)->line_id; $products = Product::where('line_id', $MRLine)->get(); $gifts = Gift::all(); $dataView = ['doctors' => $doctors, 'products' => $products, 'gifts' => $gifts]; return view('mr.search.reports.search', $dataView); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $employee = Employee::findOrFail($id); $employee->delete(); return redirect(route('phonebook.contact.index')); }
public function destroy($id) { $employee = Employee::findOrFail($id); $employee->delete(); return redirect()->to('/hr/employee'); }
public function reportSearch($type) { $searchResult = \Session::get('searchResult'); $from = \Session::get('date_from'); $to = \Session::get('date_to'); $emp = Employee::findOrFail(\Session::get('emp'))->name; $level = \Session::get('level'); \Excel::create('report-search', function ($excel) use($searchResult, $emp, $level, $from, $to) { $excel->sheet('from-' . $from . '-to-' . $to, function ($sheet) use($searchResult, $emp, $level, $from, $to) { $sheet->setAllBorders('thin'); $sheet->loadView('admin.export.search_report_result')->with('emp', $emp)->with('level', $level)->with('searchResult', $searchResult)->with('date_from', $from)->with('date_to', $to); }); })->export($type); }
public static function areYou($MRId) { $yourId = \Auth::user()->id; return $yourId == Employee::findOrFail($MRId)->id; }