/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create(Request $request) { $inquiry = DB::table('inquiries')->orderBy('stop', 'desc')->first(); $start = Carbon::parse($inquiry->stop)->format('Y-m-d'); $stop = Carbon::parse($inquiry->stop)->addWeek()->format('Y-m-d'); // echo $start; // $inputData = $request->all(); // if ($start>$inputData['start']) // { // echo "start is kleiner"; // } // echo $inputData['start']; $this->validate($request, ['inquiry' => 'required|max:255', 'awnser' => 'required|max:255', 'option1' => 'required|max:255', 'option2' => 'required|max:255', 'option3' => 'required|max:255', 'start' => 'required|date:after:' . $start, 'stop' => 'required|date:after:' . $stop]); $inputData = $request->all(); $inquiry = new Inquiry(); $inquiry->question = $inputData['inquiry']; $inquiry->awnser = $inputData['awnser']; $inquiry->option1 = $inputData['option1']; $inquiry->option2 = $inputData['option2']; $inquiry->option3 = $inputData['option3']; $inquiry->start = $inputData['start']; $inquiry->stop = $inputData['stop']; $inquiry->save(); return redirect()->route('home'); }
/** * @param Inquiry $inquiry * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ public function delete(Inquiry $inquiry) { $exists = OrganizationInquiry::where('inquiry_id', $inquiry->id)->pluck('organization_id'); if (count($exists) == 0) { $inquiry->delete(); return redirect()->route('admin::inquiry'); } else { echo 'in organizations: ' . implode(', ', array_unique($exists->all())); } }
/** * Run the database seeds. * * @return void */ public function run() { $start = Carbon::today(); $stop = Carbon::today()->addWeek(); $inquiry = new Inquiry(); $inquiry->question = "Who was the 3rd Doctor?"; $inquiry->awnser = "Jon Pertwee"; $inquiry->option1 = "Matt Smitt"; $inquiry->option2 = "That one British Guy!"; $inquiry->option3 = "David Tannent"; $inquiry->start = $start; $inquiry->stop = $stop; $inquiry->save(); }
public function enquiries() { $search = \Input::get('q'); $locale = $this->lang; // AGENT if ($this->admin->role_id == 3) { if ($search) { $enquiries = \App\Inquiry::whereHas('property', function ($q) use($search, $locale) { $q->where('user_id', $this->admin->id)->whereHas('propertyLanguages', function ($q) use($search, $locale) { $q->where('locale', $locale)->where('title', 'like', $search . '%'); }); })->orderBy('created_at', 'desc')->paginate($this->limit); } else { $enquiries = \App\Inquiry::whereHas('property', function ($q) { $q->where('user_id', $this->admin->id); })->orderBy('created_at', 'desc')->paginate($this->limit); } } else { if ($search) { $enquiries = \App\Inquiry::whereHas('property', function ($q) use($search, $locale) { $q->whereHas('propertyLanguages', function ($q) use($search, $locale) { $q->where('locale', $locale)->where('title', 'like', $search . '%'); }); })->orderBy('created_at', 'desc')->paginate($this->limit); } else { $enquiries = \App\Inquiry::orderBy('created_at', 'desc')->paginate($this->limit); } } return view('admin.pages.enquiries', compact('enquiries')); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('inquiries')->delete(); for ($i = 0; $i < count($this->items); $i++) { $row = array_combine(['user_id', 'car_id', 'model', 'price_from', 'price_to', 'year_from', 'year_to', 'city_id', 'metro', 'street', 'name', 'phone', 'information'], $this->items[$i]); Inquiry::create($row); } }
public function create($id) { $inquiry_id = $id; $inquiry = Inquiry::find($inquiry_id); if (is_null($inquiry)) { return redirect()->back()->with('status', 'Missing Inquiry Reference'); } return view('demographic.create')->with('inquiry', $inquiry); }
public function homepage() { $user = Auth::user() ?: false; $cars = Car::with('inquiriesCount')->orderBy('domestic', 'asc')->orderBy('name')->get(); $cars1 = $cars->filter(function ($item) { return $item->name == "ВАЗ"; }); $cars2 = $cars->filter(function ($item) { return $item->name != "ВАЗ"; }); $cars = $cars1->merge($cars2); $carsList = $cars->lists('name', 'id')->toArray(); $lastInquiries = Inquiry::with('car', 'city')->orderBy('created_at', 'desc')->paginate(config('vars.inquiries_per_page')); $lastInquiries->setPath('inquiry/index'); Carbon::setLocale(config('app.locale')); $lastNews = News::orderBy('published_at', 'desc')->paginate(config('vars.news_per_page')); $lastNews->setPath('news/index'); $cities = City::lists('name', 'id')->all(); $blocks = Block::all()->keyBy('alias'); $faq = Faq::all(); return view('homepage', compact('user', 'cars', 'carsList', 'lastInquiries', 'lastNews', 'cities', 'blocks', 'faq')); }
public function inquiryPage(Organization $organization) { $inquiryHistory = OrganizationInquiry::where('organization_id', $organization->id)->with('inquiry')->get(); return view('admin.organization.inquiries', ['inquiries' => Inquiry::all(), 'organization' => $organization, 'organizationInquiries' => $inquiryHistory, 'menu' => 'inquiries']); }
public function store(Request $request) { $datedoc = Carbon::now(-6); $yr = $datedoc->year; $mo = $datedoc->month; $dom = $datedoc->day; $doy = $datedoc->dayOfYear; $dateadmission = $request->input('dateadmission'); if (!empty($dateadmission) || $dateadmission == '0000-00-00') { $dateparts = explode('-', $dateadmission); $partyear = $dateparts[0]; $partmonth = $dateparts[1]; $partdom = $dateparts[2]; $dateadmission = Carbon::createFromDate($partyear, $partmonth, $partdom, -6); //return redirect()->back()->with('status',"Date Admission is $dateadmission"); } else { //uh oh, we dont have an admission date. return redirect()->back()->with('status', 'You must specifcy an admission date!'); } if (Auth::check()) { $staff_id = Auth::user()->id; $sfname = Auth::user()->fname; $slname = Auth::user()->lname; } else { return redirect('auth/login'); } $program_id = $request->input('program_id'); $inquiry_id = $request->input('inquiry_id'); $inquiry = Inquiry::find($inquiry_id); if (is_null($inquiry)) { return redirect()->back()->with('status', 'You must have a valid Inquiry'); } //$existingmrn = $inquiry->mrn; $episode_id = $inquiry->episode_id; $client_id = $inquiry->client_id; if (is_null($client_id)) { $client_id = 0; } $currentmrn = $inquiry->mrn; $fname = $inquiry->fname; $lname = $inquiry->lname; $mi = $inquiry->mi; $dob = $inquiry->dob; //=========close previous admissions since you cant have more than one at a time $clearresult = DB::table('admissions')->where('inquiry_id', '=', $inquiry_id)->update(['status_id' => '13', 'status' => 'Discharged', 'dctype_id' => '19', 'dctype' => 'Pending Review', 'datedischarge' => $datedoc]); //=================================== $status = "Admitted"; $status_id = 12; $dctype_id = 18; $dctype = "Not Applicable"; $program_id = $request->input('program_id'); if (is_null($program_id)) { return redirect()->back()->with('status', 'You are missing a valid program id'); } $serviceref = Service::find($program_id); $program = $serviceref->service; $admission = new Admission(); $looper = 0; $vals = array($inquiry_id, $client_id, $episode_id); $flds = array('inquiry_id', 'client_id', 'episode_id'); foreach ($flds as $fld) { $admission->setAttribute($fld, Input::has($fld) ? $vals[$looper] : '0'); $looper++; } //======================= $morechks = array('eie', 'dss'); foreach ($morechks as $morechk) { $admission->setAttribute($morechk, Input::has($morechk) ? true : false); } $admission->mo = $mo; $admission->doy = $doy; $admission->dom = $dom; $admission->yr = $yr; $admission->fname = $fname; //$request->input('fname'); $admission->lname = $lname; //$request->input('lname'); $admission->mi = $mi; $admission->sfname = $sfname; $admission->sfname = $sfname; $admission->slname = $slname; $admission->staff_id = $staff_id; $admission->datedoc = $dateadmission; $admission->dateadmission = $dateadmission; //$request->input('dateadmission'); $admission->datedischarge = $request->input('datedischarge'); $admission->program_id = $request->input('program_id'); $admission->program = $program; $admission->status_id = $status_id; //$request->input('status_id'); $admission->status = $status; $admission->dctype_id = $dctype_id; //$request->input('dctype_id'); $admission->dctype = $dctype; $admission->save(); $admission_id = $admission->id; //====== assign mrn ======/ //$mymsg = "yr: $yr mo: $mo dom: $dom "; //return redirect()->back()->with('status',$mymsg); //first we need to check for previous admissions - not including this one. $numadmissions = DB::table('admissions')->where('eie', '!=', '1')->whereNotIn('id', [$admission_id])->where('inquiry_id', '=', $inquiry_id)->count(); //get the current number of admissions so far this month. $admissionsmtd = DB::table('admissions')->where('eie', '!=', '1')->whereNotIn('id', [$admission_id])->where('mo', '=', $mo)->where('yr', '=', $yr)->count(); $admissionsmtd = $admissionsmtd + 1; //$admissionsmtd = 777; $totlength = 7; //======= heres the split where former clients get one set of things and new clients another. //============================================================ if ($numadmissions < 1) { //then its a brand spanking new admission and we need to generate an mrn and a new client_id //====== $molength = strlen($mo); //check to see if its a two digit or one digit if ($molength == 1) { //if it has only one digit then pad it by one zero. $newmo = str_pad($mo, 2, "0", STR_PAD_LEFT); } //next we get the maxadmission id $admissionsmtdlength = strlen($admissionsmtd); $padlength = $totlength - $admissionsmtdlength; $padlength = abs($padlength); //make sure it isnt a negative number $newnum = str_pad($admissionsmtd, $padlength, "0", STR_PAD_LEFT); $yrend = substr("{$yr}", -2); //get the last two numbers $newmrn = $yrend . "-" . $newmo . $newnum; //$mymsg = "mrn: $newmrn "; //return redirect()->back()->with('status',$mymsg); $client = new Client(); $client->fname = $fname; $client->lname = $lname; $client->datedoc = $dateadmission; //$client->dob = $dob; $client->isalias = 0; $client->eie = 0; $client->dss = 0; $client->sfname = $sfname; $client->slname = $slname; $client->staff_id = $staff_id; $client->inquiry_id = $inquiry_id; $client->episode_id = $episode_id; $client->mrn = $newmrn; $client->save(); $client_id = $client->id; //we probably need the dob in here somewhere too. $updateresult = DB::table('admissions')->where('inquiry_id', '=', $inquiry_id)->where('id', '=', $admission_id)->update(['mrn' => $newmrn, 'client_id' => $client_id]); $updateresult2 = DB::table('inquiries')->where('id', '=', $inquiry_id)->update(['mrn' => $newmrn, 'client_id' => $client_id]); $mrn = new Mrn(); $mrn->mrn = $newmrn; $mrn->datedoc = $dateadmission; $mrn->eie = 0; $mrn->fname = $fname; $mrn->lname = $lname; $mrn->client_id = $client_id; $mrn->inquiry_id = $inquiry_id; $mrn->episode_id = $episode_id; $mrn->save(); $mrnumber = $newmrn; //=================== } else { $inquiry = Inquiry::find($inquiry_id); if (is_null($inquiry)) { return redirect()->back()->with('status', 'You must have a valid Inquiry'); } $existingmrn = $inquiry->mrn; $episode_id = $inquiry->episode_id; $client_id = $inquiry->client_id; $mrnumber = $inquiry->mrn; //we need to update the client table with the last admission information //$updateresult = DB::table('admissions')->where('inquiry_id','=',$inquiry_id) // ->where('id','=',$admission_id) // ->update(['mrn' => $newmrn,'client_id'=>$client_id]); } //this is where we update all existing records with the client_id. //ideally we would get the names of the tables that need to be updated //from those identified through the mfl. that way we don't have to hope //to keep track of what will be completed during inquiry and updated later. // for our purposes right now, we are just going to list them. $tables = array("assessments", "admissions", "demographics", "ice", "payors"); foreach ($tables as $table) { $updatedone = DB::table($table)->where('inquiry_id', '=', $inquiry_id)->update(['mrn' => $mrnumber, 'client_id' => $client_id]); } //if($client_id > 0) // { // //return redirect()->route('clientview', $client_id); // } else { return redirect()->route('inquiryview', $inquiry_id); // } }
/** * Remove the specified resource from storage. * * @param int $id * @param Request $request * @return Response */ public function destroy($id, Request $request) { Inquiry::destroy($id); if ($request->ajax()) { return response()->json(['status' => 'success', 'message' => 'Объявление удалено']); } Flash::success("Запись #{$id} удалена"); return redirect()->back(); }
/** * Show the inquires from the homepage. * * @return \Illuminate\Http\Response */ public function index() { return view('cms.inquiries', ['inquiries' => Inquiry::all()]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $inquiry = Inquiry::find($id); $inquiry->delete(); // return redirect()->back(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'Inquiry has been deleted'), 'id' => $id)); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response * @internal param Request $request */ public function destroy($id) { Inquiry::destroy($id); Flash::success("Запись - {$id} удалена"); return redirect(route('admin.inquiries.index')); }
public function postIndex(ContactFormRequest $request) { Inquiry::create($request->all()); $url = $request->input('url'); return redirect($url)->with('message.success', "<strong>Success!</strong> Thank you for contacting us. We'll be in touch very soon."); }
public function show($id) { $inquiry = Inquiry::find($id); $user = User::find($inquiry->user_id); return view('contacts.inquiry_show', ['title' => $inquiry->type . " Inquiry"]); }
/** * Bootstrap any application services. * * @return void */ public function boot() { Inquiry::created(function ($inquiry) { event(new InquiryWasCreated($inquiry)); }); }
public function getData() { $data = Inquiry::all(); return response()->json(['count' => count($data), 'data' => $data]); }
public function update(Request $request, $id) { $datedoc = Carbon::now(-6); $inquiry_id = $id; $inquiry = Inquiry::find($inquiry_id); $inquiry->fname = $request->input('fname'); $inquiry->lname = $request->input('lname'); $inquiry->callerfname = $request->input('callerfname'); $inquiry->callerlname = $request->input('callerlname'); $inquiry->staff_id = $staff_id; $inquiry->sfname = $sfname; $inquiry->slname = $slname; $inquiry->isalias = 0; //$inquiry->aliasfname = ""; // $inquiry->aliaslname = ""; $inquiry->poc = $request->input('poc'); $inquiry->precipevent = $request->input('precipevent'); $inquiry->dob = $request->input('dob'); $inquiry->callerhphone = $request->input('callerhphone'); $inquiry->callercphone = $request->input('callercphone'); $inquiry->hphone = $request->input('hphone'); $inquiry->cphone = $request->input('cphone'); $morechks = array('eie', 'dss'); foreach ($morechks as $morechk) { $inquiry->setAttribute($morechk, Input::has($morechk) ? true : false); } $inquiry->client_id = 0; $inquiry->episode_id = 0; $inquiry->datedoc = $datedoc; $inquiry->mrn = 0; $inquiry->recordstatus_id = 1; //we'll say that one means active. $inquiry->save(); $inquiry_id = $inquiry->id; return redirect()->route('inquiryview', $inquiry_id); }