public function profile($profilename, $id) { $profileSelf = 0; $CurrentUserDetail = ""; $profileUserDetail = User::find($id); $profileUserDetailCount = DB::table('users')->count(); //echo '<pre>';print_r($profileUserDetailCount);die; $first_name = $profileUserDetail->fname; $last_name = $profileUserDetail->lname; $name = $first_name . ' ' . $last_name; $userId = Auth::User(); if (!empty($userId)) { $Receiver = $userId->id; } if (Auth::check()) { $checkMeetingStatus = DB::select(DB::raw("select user_id_receiver,user_id_giver,id,status from requests where (user_id_receiver=" . $Receiver . " OR user_id_receiver=" . $id . ") AND (user_id_giver=" . $Receiver . " OR user_id_giver=" . $id . " ) AND status NOT IN ('completed','archived','cancelled') order by created_at DESC limit 1")); } if (empty($profileUserDetail)) { if (Auth::check()) { return Redirect::to('404'); } else { return Redirect::to('/'); } } $profileNameCheck = $profileUserDetail->fname . '-' . $profileUserDetail->lname; if ($profileUserDetail == '' || strtolower($profilename) != strtolower($profileNameCheck) || $profileUserDetail->termsofuse == '0' || $profileUserDetail->userstatus != 'approved') { if (Auth::check()) { return Redirect::to('404'); } else { return Redirect::to('/'); } } $profileUserSkills = $profileUserDetail->Tags; if (Auth::check()) { $CurrentUserDetail = Auth::User(); $CurrentUserId = $CurrentUserDetail->id; if ($CurrentUserId == $profileUserDetail['id']) { $profileSelf = "1"; } else { $profileSelf = "0"; } } $users_group = User::find($id)->Groups; //Karma notes block $karmaTrailUser = $karmaReceivedUser = $karmaSentUser = ''; $start = 0; $perpage = 15; $karmaTrail = KarmaHelper::getKarmaTrail($id, $start, $perpage); //echo "<pre>";print_r($users_group->toArray());echo "</pre>";die; /*$karmaReceived = KarmaHelper::getReceivedRequestKarmaNotes($id); $karmaSent = KarmaHelper::getSentKarmaNotes($id);*/ if (count($karmaTrail) > 0) { foreach ($karmaTrail as $trail) { $userSkills = ""; $karma['user_id_receiver'] = User::find($trail->user_id_receiver)->toArray(); if (!empty($trail->user_id_giver)) { $karma['user_id_giver'] = User::find($trail->user_id_giver)->toArray(); } else { //echo '<pre>';print_r($trail->connection_id_giver);die; $karma['user_id_giver'] = Connection::find($trail->connection_id_giver)->toArray(); } if ($id == $trail->user_id_receiver) { $karma['status'] = $trail->statusreceiver; } else { $karma['status'] = $trail->statusgiver; } $karma['piclink'] = $trail->piclink; $karma['karmaNotes'] = $trail->details; if (!empty($trail->skills)) { $userSkills = KarmaHelper::getSkillsname($trail->skills); } $karma['skills'] = $userSkills; $karma['req_id'] = $trail->req_id; $karma['meetingdatetime'] = date('F d, Y', strtotime($trail->meetingdatetime)); $karma['created_at'] = date('F d, Y', strtotime($trail->created_at)); $karmaTrailUser[] = $karma; } } //echo "<pre>";print_r($karmaTrailUser);echo "</pre>";die; $karmaReceived = $profileUserDetail->KarmanoteReceiver()->orderBy('karmanotes.created_at', 'desc')->skip($start)->take($perpage)->get(); //echo "<pre>";print_r($karmaReceived->toArray());echo "</pre>";die; $karmaSent = $profileUserDetail->KarmanoteGiver()->orderBy('karmanotes.created_at', 'desc')->skip($start)->take($perpage)->get(); if (!empty($karmaReceived)) { foreach ($karmaReceived->toArray() as $received) { $userReceivedSkills = ""; $karmareceived['user_id_receiver'] = User::find($received['user_idreceiver'])->toArray(); if (!empty($received['user_id_giver'])) { $karmareceived['user_id_giver'] = User::find($received['user_idgiver'])->toArray(); } else { $karmareceived['user_id_giver'] = Connection::find($received['connection_idgiver'])->toArray(); } $karmareceived['karmaNotes'] = $received['details']; if (!empty($received['skills'])) { $userReceivedSkills = KarmaHelper::getSkillsname($received['skills']); } $karmareceived['skills'] = $userReceivedSkills; $karmareceived['status'] = $received['statusgiver']; $karmareceived['req_id'] = $received['req_id']; $karmareceived['req_detail'] = Meetingrequest::find($received['req_id']); $karmareceived['created_at'] = date('F d, Y', strtotime($received['created_at'])); $karmaReceivedUser[] = $karmareceived; } } //echo "<pre>";print_r($karmaSent->toArray());echo "</pre>";die; if (!empty($karmaSent)) { foreach ($karmaSent->toArray() as $sent) { $userSentSkills = ""; $karmasent['user_id_receiver'] = User::find($sent['user_idreceiver'])->toArray(); if (!empty($sent['user_idgiver'])) { $karmasent['user_id_giver'] = User::find($sent['user_idgiver'])->toArray(); } else { $karmasent['user_id_giver'] = Connection::find($sent['connection_idgiver'])->toArray(); } $karmasent['karmaNotes'] = $sent['details']; if (!empty($sent['skills'])) { $userSentSkills = KarmaHelper::getSkillsname($sent['skills']); } $karmasent['skills'] = $userSentSkills; $karmasent['req_id'] = $sent['req_id']; $karmasent['req_detail'] = Meetingrequest::find($sent['req_id'])->toArray(); $karmasent['status'] = $sent['statusreceiver']; $karmasent['created_at'] = date('F d, Y', strtotime($sent['created_at'])); $karmaSentUser[] = $karmasent; } } //function to check how much meeting are happend in one week. // if(!empty($Receiver)){ // $MeetingRequestPending = KarmaHelper::karmaMeetingPendingCount($Receiver,$id); // }else{ $MeetingRequestPending = 0; //} if (!empty($userId)) { $checkMeetingStatus = KarmaHelper::getMeetingStatusForWeb($Receiver, $id); } else { $checkMeetingStatus = array(); $receiverData = array(); $giverData = array(); } //echo '<pre>';print_r($checkMeetingStatus);die; //latest karma Query if (!empty($checkMeetingStatus)) { $receiverData = User::find($checkMeetingStatus['receiverId']); $giverData = User::find($checkMeetingStatus['giverId']); } $getKarmaQuery = DB::table('questions')->select('questions.question_url', 'questions.subject', 'questions.id')->where('questions.user_id', $id)->where('questions.queryStatus', '=', 'open')->orderBy('questions.created_at', 'desc')->first(); //echo '<pre>';print_r($getKarmaQuery);die; return View::make('profile', array('meetingStatus' => $checkMeetingStatus, 'receiverData' => $receiverData, 'giverData' => $giverData, 'checkMeetingStatus' => $checkMeetingStatus, 'getKarmaQuery' => $getKarmaQuery, 'pageTitle' => $name . ' Profile | KarmaCircles', 'pageDescription' => $name . ' is on KarmaCircles. Join KarmaCircles to request a meeting from ' . $name . ' for free. KarmaCircles makes it easy for people to give and receive help for free.', 'id' => $id, 'CurrentUser' => $CurrentUserDetail, 'MeetingRequestPending' => $MeetingRequestPending, 'ProfileUserSkills' => $profileUserSkills, 'profileUserDetail' => $profileUserDetail, 'profileSelf' => $profileSelf, 'karmaTrail' => $karmaTrailUser, 'karmaReceived' => $karmaReceivedUser, 'karmaSent' => $karmaSentUser, 'countTrail' => 0, 'countReceived' => 0, 'countSent' => 0, 'profielURL' => '', 'karmascore' => '', 'ProfileUserGroup' => $users_group))->with('title', "Welcome to profile")->with('description', "Profile Description")->with('desc', "Profile Description"); }
public function ajaxdashboardSuggestion() { $getinvites = ""; $getsuggestion = array(); $user_info = Auth::user(); $user_id = 0; $location = ''; if (!empty($user_info)) { $user_id = $user_info->id; $location = $user_info->location; $ReceiverDetail = User::find($user_id); } $user_info = Auth::user(); $getKcuser = KarmaHelper::getKcuser(0); $skipcount = ''; //if(!empty($_REQUEST['skipcount'])) $skipcount = $_REQUEST['skipcount']; if (empty($getKcuser)) { $getsuggestion = KarmaHelper::getUserConnection($user_id, $location); if (!empty($getsuggestion)) { foreach ($getsuggestion as $key => $value) { if ($value->con_user_id != "") { $getKcuser = 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($getKcuser)) { $value->networkid = $getKcuser; } } } $getsuggestion = $getsuggestion[array_rand($getsuggestion)]; //$skipcount ++; } // fetch a user connection only nON kc $getinvites = KarmaHelper::getUserNonKcConnection($user_id, $location); if (!empty($getinvites)) { $getinvites = $getinvites[array_rand($getinvites)]; } } $skipcountreq = $skipcount + 1; $skipcountintro = $skipcount + 2; $skipcountinvite = $skipcount + 3; $checkMeetingStatus = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[0]->id); $checkMeetingStatusOne = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[1]->id); $checkMeetingStatusTwo = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[2]->id); foreach ($getKcuser as $key => $value) { $giver_id = $value->id; //$MeetingRequestPending = KarmaHelper::karmaMeetingPendingCount($user_id,$giver_id); $MeetingRequestPending = '0'; $MeetingRequestPendingArray[] = $MeetingRequestPending; } return View::make('ajaxdashboard_suggestion', array('CurrentUser' => $user_info, 'checkMeetingStatus' => $checkMeetingStatus, 'checkMeetingStatusOne' => $checkMeetingStatusOne, 'checkMeetingStatusTwo' => $checkMeetingStatusTwo, 'MeetingRequestPending' => $MeetingRequestPendingArray[0], 'MeetingRequestPendingOne' => $MeetingRequestPendingArray[1], 'MeetingRequestPendingTwo' => $MeetingRequestPendingArray[2], 'pageTitle' => 'Dashboard', 'getinvites' => $getinvites, 'getsuggestion' => $getsuggestion, 'getKcuser' => $getKcuser[0], 'getKcuserOne' => $getKcuser[1], 'getKcuserTwo' => $getKcuser[2], 'skipcountreq' => $skipcountreq, 'skipcountintro' => $skipcountintro, 'skipcountinvite' => $skipcountinvite)); }