public function todo() { // get all note with a follow up date TODAY - 1 WEEK $now = \Carbon\Carbon::now('Africa/Johannesburg')->subWeeks(1)->toDateTimeString(); //$now->subWeeks(1); // set database $database = Auth::user()->getDatabase(); //change database $note = new Note(); $note->changeConnection($database); $followups = Note::on($database)->select('*')->where('followup', '>=', $now)->orderBy('followup')->get(); $owners = array(); // loop all notes with date > today foreach ($followups as $followup) { for ($x = 0; $x < $followup->properties->count(); $x++) { $detail = ['id' => $followup->properties[$x]->id, 'strKey' => $followup->properties[$x]->strKey, 'strOwners' => $followup->properties[$x]->strOwners, 'memNotes' => $followup->memNotes, 'followup' => $followup->followup]; array_push($owners, $detail); } } // dd($followups, "follow up - dashboard controller"); //dd($owners); return view('followups', compact('followups', 'owners')); }
public function index(Request $request) { // set database $database = Auth::user()->getDatabase(); //change database for notes $erf = new Note(); $erf->changeConnection($database); //change database for Street $property = new Property(); $property->changeConnection($database); // get inputs $Input = $request->input('input'); $Select = $request->input('selected'); //dd( $streetInput,$streetSelect); // check if input or select // if input ignore select if (strlen($Input) > 0) { // search $search = $Input; $properties = Property::on($database)->where('numErf', 'LIKE', "{$search}%")->orderby('numErf', 'ASC')->get(); } else { $note = Note::on($database)->where('id', $Select)->first(); $search = $note->numErf; $properties = Property::on($database)->where('numErf', $search)->orderby('numErf', 'ASC')->get(); } Session::put('search', $Input); Session::put('controllerroute', '/erf'); // view properties // return with error if no result if ($properties->count()) { return view('erfs', compact('properties', 'search')); } else { Session::flash('flash_message', '' . "No properties matching search criteria."); Session::flash('flash_type', 'alert-danger'); return Redirect::back(); } }
public function update(Request $request) { // set database $database = Auth::user()->getDatabase(); //change database $owner = new Owner(); $owner->changeConnection($database); //change database $note = new Note(); $note->changeConnection($database); // get logged in user $user = Auth::user()->name; $now = Carbon\Carbon::now('Africa/Cairo')->toDateTimeString(); // get inputs $strKey = $request->input('strKey'); $strIdentity = $request->input('strIdentity'); $strOwners = $request->input('strOwners'); $homePhone = $request->input('strHomePhoneNo'); $workPhone = $request->input('strWorkPhoneNo'); $cellPhone = $request->input('strCellPhoneNo'); $email = $request->input('EMAIL'); $note = $request->input('note'); $newnote = $request->input('newnote'); $strStreetNo = $request->input('strStreetNo'); $strStreetName = $request->input('strStreetName'); $followup = $request->input('followup'); $date = ""; if (strLen($followup) > 0) { $date = Carbon\Carbon::createFromFormat('Y-m-d', $followup); } try { // update personal details // $owner = Owner::on( $database )->where('strIDNumber', $strIdentity)->update(array('strCellPhoneNo' => $cellPhone, // 'strHomePhoneNo' => $homePhone, // 'strWorkPhoneNo' => $workPhone, // 'EMAIL' => $email, // 'updated_at'=> $now // )); $properties = Property::on($database)->where('strKey', $strKey)->update(array('strStreetNo' => $strStreetNo, 'numStreetNo' => $strStreetNo, 'strStreetName' => $strStreetName)); //dd($properties); //update owner details $owner = Owner::on($database)->where('strIDNumber', $strIdentity)->first(); $owner->strHomePhoneNo = $homePhone; $owner->strCellPhoneNo = $cellPhone; $owner->strWorkPhoneNo = $workPhone; $owner->EMAIL = $email; $owner->save(); // check if there is a new note if (strlen($newnote) > 0) { // if a previous note exists add a carrige return and new note if (strlen($note) > 0) { $updatednote = ltrim(rtrim($note)) . "\n" . $now . " " . $user . " wrote: " . "\n" . $newnote; } else { // add just the new note $updatednote = $now . " " . $user . " wrote: " . "\n" . $newnote; } // update the note $affected = Note::on($database)->where('strKey', $strKey)->update(array('memNotes' => $updatednote, 'followup' => $date, 'updated_at' => $now)); } Note::on($database)->where('strKey', $strKey)->update(array('followup' => $date, 'updated_at' => $now)); } catch (exception $e) { Session::flash('flash_message', 'Error ' . $e->getMessage()); Session::flash('flash_type', 'alert-danger'); return Redirect::back(); } Session::flash('flash_message', 'Updated ' . $strOwners . ' at ' . $now); Session::flash('flash_type', 'alert-success'); return Redirect::back(); }
public function printfollowups() { // get all note with a follow up date TODAY - 1 WEEK $now = \Carbon\Carbon::now('Africa/Johannesburg')->subWeeks(1)->toDateTimeString(); // set database $database = Auth::user()->getDatabase(); $email = Auth::user()->email; //log $action = 'PRINTING'; $comment = 'Report for ' . $database . ' - ' . 'FOLLOW-UPS'; $append = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString() . ', ' . trim($email) . ', ' . $action . ',' . $comment; Storage::append('logfile.txt', $append); //change database $note = new Note(); $note->changeConnection($database); $followups = Note::on($database)->select('*')->where('followup', '>=', $now)->orderBy('followup')->get(); // $followups->load('properties'); // dd($followups); if (strpos($database, 'FH')) { $type = 'FH'; } else { $type = 'ST'; } $owners = array(); $properties = array(); // loop all notes with date > today foreach ($followups as $followup) { for ($x = 0; $x < $followup->properties->count(); $x++) { $detail = ['id' => $followup->properties[$x]->id, 'strKey' => $followup->properties[$x]->strKey, 'strOwners' => $followup->properties[$x]->strOwners, 'memNotes' => $followup->memNotes, 'followup' => $followup->followup]; array_push($properties, $followup->properties[$x]); //array_push($owners, $detail); } } $count = sizeof($properties); // dd("print followups - reportcontroller", $properties, $count); return view('reportByFollowups', compact('properties', 'count', 'type')); }