public function groupsAll() { $user_info = ""; $user_info = Auth::user(); $group = DB::table('groups')->get(); $user_all_groups = $userinGroup = ''; if (Auth::check()) { $userinGroup = KarmaHelper::getuserGroup(); } if (!empty($userinGroup)) { foreach ($userinGroup as $key => $value) { $user_all_groups[] = $value->id; } } return View::make('group.grouplist', array('pageTitle' => 'Groups Directory | KarmaCircles', 'pageDescription' => 'Search among the groups of like-minded professionals, create your own, or join one to explore the happiness of giving and taking free help.', 'user_all_groups' => $user_all_groups, 'CurrentUser' => $user_info, 'group' => $group)); }
public static function getKcuser($user_id) { $getUser = array(); $getUser = KarmaHelper::getTestUsers(); $user_info = Auth::User(); if (!empty($user_info)) { $Receiver = $user_info->id; } if (empty($Receiver)) { if ($user_id > 0) { $Usergroup = KarmaHelper::getuserGroup(); $All_groups = ''; if (!$Usergroup->isEmpty()) { foreach ($Usergroup as $key => $value) { $All_groups[] = $value->id; } $getKcuser = DB::table('users as u')->join('users_groups', 'u.id', '=', 'users_groups.user_id')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->whereIn('users_groups.group_id', $All_groups)->WhereNotIn('u.id', $getUser)->Where('u.id', '!=', $user_id)->distinct()->where('u.userstatus', '=', 'approved')->orderByRaw("RANd()")->take(3)->get(); if (empty($getKcuser)) { $getKcuser = DB::table('users as u')->join('users_groups', 'u.id', '=', 'users_groups.user_id')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->WhereNotIn('u.id', $getUser)->Where('u.id', '!=', $user_id)->distinct()->where('u.userstatus', '=', 'approved')->orderByRaw("RANd()")->take(3)->get(); } return $getKcuser; } } else { $kscore = 12; $kscore = Adminoption::Where('option_name', '=', 'Set Kscore Value')->select("option_value")->first(); if (!empty($kscore)) { $kscore = $kscore->option_value; } $getKcuser = DB::table('users as u')->join('users_groups', 'u.id', '=', 'users_groups.user_id')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->where('u.userstatus', '=', 'approved')->WhereNotIn('u.id', $getUser)->Where('u.id', '!=', $user_id)->distinct()->Where('u.karmascore', '>', $kscore)->orderByRaw("RANd()")->take(3)->get(); return $getKcuser; } } else { if ($user_id > 0) { $Usergroup = KarmaHelper::getuserGroup(); $All_groups = ''; if (!$Usergroup->isEmpty()) { foreach ($Usergroup as $key => $value) { $All_groups[] = $value->id; } $getKcuser = DB::table('users as u')->join('users_groups', 'u.id', '=', 'users_groups.user_id')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->whereIn('users_groups.group_id', $All_groups)->WhereNotIn('u.id', $getUser)->Where('u.id', '!=', $Receiver)->Where('u.id', '!=', $user_id)->distinct()->where('u.userstatus', '=', 'approved')->orderByRaw("RANd()")->take(3)->get(); if (empty($getKcuser)) { $getKcuser = DB::table('users as u')->join('users_groups', 'u.id', '=', 'users_groups.user_id')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->WhereNotIn('u.id', $getUser)->Where('u.id', '!=', $Receiver)->Where('u.id', '!=', $user_id)->distinct()->where('u.userstatus', '=', 'approved')->orderByRaw("RANd()")->take(3)->get(); } return $getKcuser; } } else { $kscore = 12; $kscore = Adminoption::Where('option_name', '=', 'Set Kscore Value')->select("option_value")->first(); if (!empty($kscore)) { $kscore = $kscore->option_value; } $getKcuser = DB::table('users as u')->join('users_groups', 'u.id', '=', 'users_groups.user_id')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->where('u.userstatus', '=', 'approved')->WhereNotIn('u.id', $getUser)->Where('u.id', '!=', $Receiver)->Where('u.id', '!=', $user_id)->distinct()->Where('u.karmascore', '>', $kscore)->orderByRaw("RANd()")->take(3)->get(); return $getKcuser; } } }
public function dashboard($idget = null) { $user_info = Auth::user(); $totalNotesPending = 0; $Receiver = $user_info->id; $ReceiverDetail = User::find($Receiver); $MeetingRequestPending = $ReceiverDetail->Giver()->Where('status', '=', 'pending')->count(); //echo $MeetingRequestPending;exit; // Calculate number of connection user have on KC platform //echo $MeetingRequestPending; $user_id = 0; $location = ''; if (!empty($user_info)) { $user_id = $user_info->id; $location = $user_info->location; } /*Dashboard section*/ // fetch user connections on KC $getUserConnection = KarmaHelper::getUserConnection($user_id, $location); $user_connection_onkc = 0; if (!empty($getUserConnection)) { foreach ($getUserConnection as $key => $value) { if (isset($value->con_user_id)) { $user_connection_onkc++; } } } // fetch pending karmanote requests $PendingRequest = array(); $totalPendingRequest = 0; $PendingRequest = KarmaHelper::getPendingKarmaNotes($user_info->id); if (!empty($PendingRequest)) { $totalPendingRequest = count($PendingRequest); } //fetch pending KM requests only received no read no unread $totalReceivedRequest = 0; $GiverInMeeting = Auth::User()->Giver()->where('status', 'pending')->orderBy('updated_at', 'DESC')->get(); if (!empty($GiverInMeeting)) { $totalReceivedRequest = count($GiverInMeeting); } //fetch pending karma intros $totalintroductionInitiated = 0; $IntroducerInitiated = Auth::User()->Introducer; if (!empty($IntroducerInitiated)) { foreach ($IntroducerInitiated as $key => $value) { if (!empty($value['user_id_receiver'])) { $value['user_id_receiver'] = User::find($value['user_id_receiver'])->toArray(); } if (!empty($value['user_id_giver'])) { $value['user_id_giver'] = User::find($value['user_id_giver'])->toArray(); } else { $value['user_id_giver'] = Connection::find($value['connection_id_giver'])->toArray(); } if ($value->status == 'pending') { $totalintroductionInitiated++; } } } // fetch queries that have been posted in the last 7 days within common groups including both public & private. $Usergroup = KarmaHelper::getuserGroup(); $All_groups = ''; $group_question = 0; $totagroupquestion = 0; $yesterday = Carbon::now()->subDays(1); $one_week_ago = Carbon::now()->subWeeks(1); $group_question = DB::table('questions')->select(array('*'))->where('questions.user_id', '!=', $user_info->id)->where('questions.queryStatus', 'open')->where('questions.created_at', '>=', $one_week_ago)->where('questions.created_at', '<=', $yesterday)->orderBy('questions.created_at', 'DESC')->groupBy('id')->get(); if (!empty($group_question)) { $totagroupquestion = count($group_question); } // fetch a 3 random users on KC platform with a common group of logged in user $getKcuser = array(); $getKcuser = KarmaHelper::getKcuser(0); if (empty($getKcuser)) { // fetch a user connection either KC or NON KC $getsuggestion = KarmaHelper::getUserConnection($user_id, $location); //get test users id $getUser = KarmaHelper::getTestUsers(); if (!empty($getsuggestion)) { foreach ($getsuggestion as $key => $value) { $test_match = in_array($value->con_user_id, $getUser); if ($value->con_user_id != "" && $test_match != 1) { $getKc = DB::table('users as u')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->where('u.id', '=', $value->con_user_id)->where('u.userstatus', '=', 'approved')->get(); if (!empty($getKc)) { $value->networkid = $getKc; } } } $getsuggestion = $getsuggestion[array_rand($getsuggestion)]; } // fetch a user connection only nON kc $getinvites = ""; $getinvites = KarmaHelper::getUserNonKcConnection($user_id, $location); if (!empty($getinvites)) { $getinvites = $getinvites[array_rand($getinvites)]; } } $checkMeetingStatus = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[0]->id); $checkMeetingStatusOne = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[1]->id); $checkMeetingStatusTwo = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[2]->id); //fetch random 5 unique notes $getKarmanote = ""; $getKarmanote = KarmaHelper::getKarmanote(); foreach ($getKcuser as $key => $value) { $giver_id = $value->id; $MeetingRequestPending = KarmaHelper::karmaMeetingPendingCount($Receiver, $giver_id); $MeetingRequestPendingArray[] = $MeetingRequestPending; } return View::make('dashboard', array('pageTitle' => 'Dashboard | Karmacircles', 'pageDescription' => 'KarmaCircles is an online peer-to-peer knowledge sharing platform.', 'MeetingRequestPending' => $MeetingRequestPendingArray[0], 'MeetingRequestPendingOne' => $MeetingRequestPendingArray[1], 'MeetingRequestPendingTwo' => $MeetingRequestPendingArray[2], 'totagroupquestion' => $totagroupquestion, 'getKarmanote' => $getKarmanote, 'getKcuserTwo' => $getKcuser[2], 'getKcuserOne' => $getKcuser[1], 'getKcuser' => $getKcuser[0], 'checkMeetingStatus' => $checkMeetingStatus, 'checkMeetingStatusOne' => $checkMeetingStatusOne, 'checkMeetingStatusTwo' => $checkMeetingStatusTwo, 'totalintroductionInitiated' => $totalintroductionInitiated, 'totalReceivedRequest' => $totalReceivedRequest, 'totalPendingRequest' => $totalPendingRequest, 'user_connection_onkc' => $user_connection_onkc, 'CurrentUser' => $user_info, 'PendingMeetingRequest' => $MeetingRequestPending, 'NotesPendingRequest' => $totalNotesPending)); }