/**
 		Function name: saveKarmanote()
 		Created by : Evon
 		Created on : 04/10/2014
 	**/
 public function saveKarmanote()
 {
     $CurrentUser = Auth::User();
     $meetingId = $receiverId = $giverId = $note = $receiverName = $giverName = $ShareKarmaNote = '';
     $note = array();
     if (!empty(Input::get('ShareKarmaNote'))) {
         $ShareKarmaNote = Input::get('ShareKarmaNote');
     }
     if (!empty(Input::get('meetingId'))) {
         $meetingId = Input::get('meetingId');
     }
     if (!empty(Input::get('receiverId'))) {
         $receiverId = Input::get('receiverId');
     }
     if (!empty(Input::get('introducerId'))) {
         $introducerId = Input::get('introducerId');
     }
     if (!empty(Input::get('giverId'))) {
         $giverId = Input::get('giverId');
     }
     if (!empty(Input::get('skillTags'))) {
         $skills = Input::get('skillTags');
     }
     if (!empty(Input::get('details'))) {
         $note = Input::get('details');
     }
     if (!empty(Input::get('receiverName'))) {
         $receiverName = Input::get('receiverName');
     }
     if (!empty(Input::get('giverName'))) {
         $giverName = Input::get('giverName');
     }
     //print_r($ShareKarmaNote);die;
     if (!$this->Karmanote->isValid(Input::all())) {
         return Redirect::back()->withInput()->withErrors($this->Karmanote->errors);
     } else {
         $feedType = 'KarmaNote';
         $karmaNote = new Karmanote();
         $karmaNote->req_id = $meetingId;
         $karmaNote->user_idgiver = $giverId;
         $karmaNote->user_idreceiver = $receiverId;
         $karmaNote->details = strip_tags($note);
         if (!empty($skills)) {
             $karmaNote->skills = implode(',', $skills);
         } else {
             $karmaNote->skills = '';
         }
         $karmaNote->viewstatus = 0;
         if ($ShareKarmaNote == 1) {
             $karmaNote->share_onlinkedin = $ShareKarmaNote;
         }
         $karmaNote->created_at = KarmaHelper::currentDate();
         $karmaNote->save();
         $karmaNoteId = $karmaNote->id;
         //$karmaNoteMessage=$karmaNote->details;
         if (!empty($skills)) {
             $getName = $getSkillDataName = "";
             foreach ($skills as $key => $value) {
                 $getName = Tag::where('id', '=', $value)->select('name')->first();
                 $getSkillDataName .= $getName->name . ",";
             }
             $result = rtrim($getSkillDataName, ",");
             $karmaNoteMessage = $karmaNote->details . "\nEndorsements: " . $result;
         } else {
             $karmaNoteMessage = $karmaNote->details;
         }
         $Meetingrequest = Meetingrequest::find($meetingId);
         $Meetingrequest->status = 'completed';
         $Meetingrequest->save();
         $messageData = new Message();
         $messageData->request_id = $meetingId;
         $messageData->sender_id = $CurrentUser->id;
         $messageData->giver_id = $giverId;
         $messageData->receiver_id = $CurrentUser->id;
         $messageText = $CurrentUser->fname . ' ' . $CurrentUser->lname . ' has sent a KarmaNote.';
         $messageData->messageText = $messageText;
         $messageData->save();
         $messageData = new Message();
         $messageData->message_type = 'user';
         $messageData->request_id = $meetingId;
         $messageData->sender_id = $CurrentUser->id;
         $messageData->giver_id = $giverId;
         $messageData->receiver_id = $CurrentUser->id;
         $messageTextOfKarmaNote = $karmaNoteMessage;
         $messageData->messageText = $messageTextOfKarmaNote;
         $messageData->save();
         DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'completed', 'entry_updated_on' => Carbon::now()));
         DB::table('requests')->where('id', '=', $meetingId)->update(array('status' => 'completed'));
         $userRole = 'Receiver';
         $changeStatus = KarmaHelper::updateMeetingStatus($meetingId, $userRole);
         KarmaHelper::updateKarmaScore($giverId, $receiverId);
         //KarmaHelper::storeKarmacirclesRecord($giverId,$receiverId);
         //KarmaHelper::storeKarmacirclesRelation($giverId,$receiverId);
         KarmaHelper::storeKarmacirclesfeed($giverId, $receiverId, $feedType, $karmaNoteId);
         if (!empty($introducerId)) {
             KarmaHelper::updateIntroducerKarmaScore($introducerId);
         }
         if (!empty($ShareKarmaNote)) {
             $receiverDetail = User::find($receiverId);
             //MessageHelper::shareOnLinkedin($receiverDetail->token,'asdasd');die();
             Queue::push('MessageSender', array('type' => '9', 'user_id_giver' => $giverId, 'user_id_receiver' => $receiverId, 'meetingId' => $meetingId));
         }
         //$sendLinkedinMessage =  MessageHelper::triggerEmailAndMessage($giverId,$receiverId,'5',$meetingId);
         Queue::push('MessageSender', array('type' => '5', 'user_id_giver' => $giverId, 'user_id_receiver' => $receiverId, 'meetingId' => $meetingId));
         return Redirect::to('meeting/' . $receiverName . '-' . $giverName . '/' . $meetingId);
     }
 }
Esempio n. 2
0
 /**
  * Function to save confirm meeting data.
  *
  * @return Response
  */
 public static function commonMeetingHappened($meetingId, $userRole)
 {
     $getMeetingId = Meetingrequest::where('id', '=', $meetingId)->first();
     $userId = $getMeetingId->user_id_receiver;
     $getUser = User::find($userId);
     DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'happened', 'entry_updated_on' => Carbon::now()));
     DB::table('requests')->where('id', '=', $meetingId)->update(array('status' => 'happened'));
     $getGiverData = DB::table('requests')->join('users', 'requests.user_id_giver', '=', 'users.id')->where('requests.id', '=', $meetingId)->select('requests.user_id_giver', 'users.fname', 'users.lname')->get();
     //Add message in requests_messages table
     if (!empty($getGiverData)) {
         $messageData = new Message();
         $messageData->request_id = $meetingId;
         $messageData->sender_id = $getGiverData[0]->user_id_giver;
         $messageData->giver_id = $getGiverData[0]->user_id_giver;
         $messageData->receiver_id = $userId;
         $messageText = $getGiverData[0]->fname . ' ' . $getGiverData[0]->lname . ' has indicated that the meeting has happened.';
         $messageData->messageText = $messageText;
         $messageData->save();
         $changeStatus = KarmaHelper::updateMeetingStatus($meetingId, $userRole);
     } else {
         $getGiverData = array();
     }
     return $getGiverData;
 }