/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     Log::alert('Executed Cron Job');
     $KarmaNotePending = Meetingrequest::where('status', '=', 'confirmed')->where('cronjobflag', '=', '0')->get();
     if (!empty($KarmaNotePending)) {
         foreach ($KarmaNotePending as $key => $value) {
             $meetingtimezone = $value->meetingtimezone;
             $meetingdatetime = $value->meetingdatetime;
             $user_id_giver = $value->user_id_giver;
             $user_id_receiver = $value->user_id_receiver;
             $meetingId = $value->id;
             $CurrentTimeWithZone = KarmaHelper::calculateTime($meetingtimezone);
             //echo "<pre>";print_r($meetingdatetime);echo "</pre>";
             //echo "<pre>";print_r($meetingdatetime);echo "</pre>";die();
             if ($CurrentTimeWithZone > $meetingdatetime) {
                 $diffDate = KarmaHelper::dateDiff($CurrentTimeWithZone, $meetingdatetime);
                 $diffDate = $diffDate->days * 24 + $diffDate->h;
                 $EmailTriggerTime = Adminoption::where('option_name', '=', 'KarmaNote Email Trigger Time')->first();
                 if (!empty($EmailTriggerTime)) {
                     $EmailTriggerTime = $EmailTriggerTime->toArray();
                     $EmailTriggerTime = $EmailTriggerTime['option_value'];
                 } else {
                     $EmailTriggerTime = '24';
                 }
                 if ($diffDate >= $EmailTriggerTime) {
                     //$date = Carbon::now()->addMinutes(5);
                     Queue::push('MessageSender', array('type' => '4', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId));
                     $Meetingrequest = Meetingrequest::find($meetingId);
                     $Meetingrequest->cronjobflag = '1';
                     $Meetingrequest->status = 'over';
                     $Meetingrequest->save();
                     DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'over', 'unread_flag' => 'true', 'entry_updated_on' => Carbon::now()));
                     $messageData = new Message();
                     $messageData->request_id = $meetingId;
                     $messageData->sender_id = $user_id_giver;
                     $messageData->giver_id = $user_id_giver;
                     $messageData->receiver_id = $user_id_receiver;
                     $messageData->message_type = 'system';
                     $messageText = 'Meeting should be over now.';
                     $messageData->messageText = $messageText;
                     $messageData->save();
                     //Queue::push('UpdateUser', array('id' => $user_id,'result' => $result));
                 }
             }
         }
     }
 }
Ejemplo 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;
 }
Ejemplo n.º 3
0
 public function deleteUser()
 {
     $id = Input::get('userId');
     $test_user = DB::table('admin_option')->where('option_name', 'Test User Emails')->select('option_value')->get();
     if (!empty($test_user)) {
         $count = 0;
         foreach ($test_user as $value) {
             foreach (explode(',', $value->option_value) as $test_user_id) {
                 if ($id == $test_user_id) {
                     $count = $count + 1;
                 }
             }
         }
     } else {
         $count = 0;
     }
     if ($count > 0) {
         $connections = Connection::Where('user_id', '=', $id)->first();
         if (!empty($connections)) {
             $connections->user_id = null;
             $connections->save();
         }
         $deletekarmanote = Karmanote::where('user_idreceiver', '=', $id)->delete();
         $deletekarmanote = Karmanote::where('user_idgiver', '=', $id)->delete();
         $deleterequest = Meetingrequest::where('user_id_receiver', '=', $id)->delete();
         $deletekarmanote = Meetingrequest::where('user_id_giver', '=', $id)->delete();
         $deletekarmanote = Meetingrequest::where('user_id_introducer', '=', $id)->delete();
         $deleteusergroups = Usersgroup::where('user_id', '=', $id)->delete();
         $findquestion = Question::Where('user_id', '=', $id)->get();
         if (!empty($findquestion)) {
             foreach ($findquestion as $val) {
                 $question_id = $val->id;
                 $findgroupquestion = Groupquestion::Where('question_id', '=', $question_id)->get();
                 if (!empty($findgroupquestion)) {
                     $deletegroupquestion = Groupquestion::Where('question_id', '=', $question_id)->delete();
                 }
                 $findQuestionwillingtohelp = Questionwillingtohelp::Where('question_id', '=', $question_id)->get();
                 if (!empty($findQuestionwillingtohelp)) {
                     $deleteQuestionwillingtohelp = Questionwillingtohelp::Where('question_id', '=', $question_id)->delete();
                 }
             }
         }
         $deleteQuestionwillingtohelp = Questionwillingtohelp::Where('user_id', '=', $id)->delete();
         if (!empty($findquestion)) {
             $deletequestion = Question::where('user_id', '=', $id)->delete();
         }
         $deletekarmacircles = Karmacircle::where('user_id', '=', $id)->delete();
         $deletekarmaFeed = Karmafeed::where('receiver_id', '=', $id)->orWhere('giver_id', '=', $id)->delete();
         $userMykarmaDelete = Mykarma::where('user_id', '=', $id)->delete();
         $userMessageDelete = Message::where('receiver_id', '=', $id)->orWhere('giver_id', '=', $id)->delete();
         $getIntroDataDelete = KarmaIntro::where('intro_giver_id', '=', $id)->orWhere('intro_receiver_id', '=', $id)->orWhere('intro_introducer_id', '=', $id)->delete();
         $getMyKarmaDataDelete = Mykarma::where('user_id', '=', $id)->delete();
         $user = User::find($id);
         $user->delete();
         echo "User " . $id . " deleted";
     } else {
         echo "User " . $id . " cant be deleted.Its not a test user.";
     }
 }