Exemplo n.º 1
0
 /**
  * reset uses to check,
  * whether user is registered,
  *  if it is, then update new password.
  *
  * @return string
  */
 public function reset(Request $request)
 {
     $credentials = $request->only('email', 'password');
     $newpassword = $request->newpassword;
     $mail = $request->email;
     try {
         // verify the credentials and create a token for the user
         if (!($token = JWTAuth::attempt($credentials))) {
             return response()->json(['error' => 'invalid_credentials', 'status' => 201], 201);
         }
     } catch (JWTException $e) {
         // something went wrong
         return response()->json(['error' => 'could_not_create_token', 'status' => 500], 500);
     }
     if ($this->CheckInternet()) {
         $adminName = \DB::select('SELECT firstname FROM users WHERE email = "' . $mail . '"');
         $sendMail = new EmailController();
         $content = 'Dear Administrator, your updated password is ' . $newpassword;
         $subject = 'COUPLEY Password Update';
         $sendMail->SendMail($mail, $adminName[0]->firstname, $subject, $content);
         $hashed = \Hash::make($newpassword);
         \DB::table('users')->where('email', $mail)->update(['password' => $hashed]);
         return response()->json(['password' => 'uptodate', 'status' => 200], 200);
     } else {
         return response()->json(['error' => 'No_network', 'status' => 203], 203);
     }
 }
 /**
  * checks whether new email is already in the database
  * old and new email can be similler for the selected admin only.
  *
  * @param string        $someString
  *
  * @return string
  */
 public function update(Request $request)
 {
     $email = $request->email;
     $id = $request->id;
     $job = $request->job;
     $firstname = $request->firstname;
     $lastname = $request->lastname;
     $admin = \DB::select('SELECT email FROM users WHERE email = "' . $email . '" not in
                                         (select email from users where id!=' . $id . ')');
     if ($this->CheckInternet()) {
         if ($admin == null) {
             //update
             \DB::table('users')->where('id', $id)->update(['firstname' => $firstname, 'lastname' => $lastname, 'job' => $job, 'email' => $email]);
             $sendMail = new EmailController();
             $content = 'Dear ' . $firstname . ', Your profile been Updated.
                 Your Email is ' . $email . ' Please visit
                 WWW.COUPLEY.COM/cp-admin#/AdminLogin';
             $subject = 'COUPLEY Administrator Update';
             $sendMail->SendMail($email, $firstname, $subject, $content);
             return response()->json(['you can use this email' => $admin, 'status' => 200], 200);
         } else {
             return response()->json(['email' => 'email already exists', 'status' => 201], 201);
         }
     } else {
         return response()->json(['status' => 203], 203);
     }
 }
Exemplo n.º 3
0
 /**
  * Updates password of user profile.
  *
  * @param object        $request
  *
  *
  * @return json
  */
 public function updatePassword(Request $request)
 {
     $username = $request->username;
     $newPassword = \Hash::make($request->password);
     try {
         $user = User::where('username', $username)->get()[0];
         $email = $user->email;
         $name = $user->firstname;
         $subject = 'Password change';
         $content = "You password was changed ! <br/>\n                If you didnt make this change please follow this link to reset your password <br/>\n                <a href='http://localhost:3000/#/forgotpwd'> Reset </a> \n            ";
         User::where('username', $username)->update(['password' => $newPassword]);
         $emailController = new EmailController();
         $emailController->SendMail($email, $name, $subject, $content);
         return response()->json(['status' => 200, 'done' => true], 200);
     } catch (Illuminate\Database\QueryException $e) {
         return response()->json(['status' => 200], 200);
     }
 }
Exemplo n.º 4
0
 /**
  * This function used to send the rejected details of a quote made by a customer
  *
  * @param string  POST Data
  *
  * @return success or fail message using $result variable
  */
 public function SendRejectQuoteAdmin()
 {
     $id = Request::all();
     $quoteID = $id['eventid'];
     $reason = $id['selectReason'];
     $message = $id['rejectMessage'];
     $addedDate = date('Y-m-d');
     try {
         /*
          *
          */
         $rejectedQuote = new Rejected_Quotes();
         $rejectedQuote->QuoteID = $quoteID;
         $rejectedQuote->Reason = $reason;
         $rejectedQuote->Message = $message;
         $rejectedQuote->RejectedDate = $addedDate;
         $rejectedQuote->save();
         Quote_Requests::where('id', $quoteID)->update(['Status' => 'Rejected']);
         $result = array('eventID' => $quoteID, 'message' => 'success');
         $user = Quote_Requests::select('Username', 'Email')->where('id', $quoteID)->get();
         foreach ($user as $key) {
             $username = $key->Username;
             $emailuser = $key->Email;
         }
         $email = new EmailController();
         $email->quoteRejectedEmail($username, $emailuser, $quoteID, $reason, $message);
         return redirect('dashboard/quote-requests/reject-quote')->with('result', $result);
     } catch (QueryException $e) {
         $result = array('eventID' => $quoteID, 'message' => 'fail');
         return redirect('dashboard/quote-requests/reject-quote')->with('result', $result);
     }
 }
Exemplo n.º 5
0
 public function ProcessSaleRequest($Input)
 {
     // Get logged user, or register as guest
     $objUser = \Auth::User() ?: \App\User::GetGuestAccount();
     // TODO:  Nice error handling would be nice
     if (!$objUser) {
         App::abort('500', 'Invalid form request:  Could not determine user account to submit form');
     }
     // Create invoice
     $objInvoice = new \App\Invoice();
     $objInvoice->user_id = $objUser->id;
     $objInvoice->type = $Input['RequestType'];
     $objInvoice->company_name = $Input['CompanyName'];
     $objInvoice->first_name = $Input['FirstName'];
     $objInvoice->last_name = $Input['LastName'];
     $objInvoice->email = $Input['EmailAddress'];
     $objInvoice->phone = $Input['PhoneNumber'];
     $objInvoice->status = \App\Invoice::STATUS_NEW;
     $objInvoice->comments = $Input['Comments'];
     if (!$objInvoice->save()) {
         App::abort('500', 'Master invoice could not save.  Breaking page.  Not saving invoice items.');
     }
     // Invoice Items
     $tInvoiceItemFields = ['Brand', 'Environment', 'MotivePower', 'Capacity', 'Attachment', 'OperatingHours', 'Accessories' => ['LP Tank', 'Opportunity Charger', 'Seat Belt', 'Strobe Light', 'Fire Extinguisher', 'Side Shifter']];
     if ($Input['RequestType'] == static::REQUEST_TYPE_RENTAL) {
         unset($tInvoiceItemFields[0]);
     }
     // Brand
     foreach ($tInvoiceItemFields as $Item) {
         if (is_array($Item)) {
             foreach ($Item as $Accessory) {
                 if (in_array($Accessory, $Input['Accessories'])) {
                     $objInvoiceItem = new \App\InvoiceItem();
                     $objInvoiceItem->invoice_id = $objInvoice->id;
                     $objInvoiceItem->type = 'Accessory';
                     $objInvoiceItem->title = "{$Accessory}";
                     $objInvoiceItem->status = \App\InvoiceItem::STATUS_ACTIVE;
                     $objInvoiceItem->save();
                 }
             }
         } else {
             if ($Input[$Item]) {
                 $objInvoiceItem = new \App\InvoiceItem();
                 $objInvoiceItem->invoice_id = $objInvoice->id;
                 $objInvoiceItem->type = $Item;
                 $objInvoiceItem->title = $Input[$Item];
                 $objInvoiceItem->status = \App\InvoiceItem::STATUS_ACTIVE;
                 $objInvoiceItem->save();
             }
         }
     }
     EmailController::sendSalesEmail($Input);
     return redirect('/forms/success');
 }
Exemplo n.º 6
0
 /**
  * Update the specified resource in storage.
  *
  * @return Response
  */
 public function update(Request $request)
 {
     //Initialize input properties
     if ($request->filing_type == 'RFC') {
         $validator = Validator::make($request->all(), ['approver_response' => 'required', 'notes' => 'required', 'remarks' => 'required']);
     } else {
         if ($request->filing_type == 'RFR' || $request->filing_type == 'QAC') {
             $validator = Validator::make($request->all(), ['approver_response' => 'required', 'remarks' => 'required']);
         }
     }
     //Redirect back if with input errors
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //Initialization
     $approver_response = $request->approver_response;
     $EASRequest = new EASRequest();
     $user_id = trim(Auth::user()->app_code);
     if ($approver_response == 'Denied' || $approver_response == 'Signed' || $approver_response == 'On-Hold') {
         //Update the request
         $EASRequest->respondRequest($request->request_code, $approver_response, $request->approver_level, trim($request->remarks));
         //Get updated details
         $data = [];
         $data['details'] = $EASRequest->getRequestDetails($request->request_code, $user_id);
         $data['details']['approver_level'] = $request->approver_level;
         //Email Appropriate recipients
         $mail = new EmailController();
         $mail->send($data['details'], $approver_response);
         return $this->show(trim($data['details']['rfc_code']));
     } else {
         if ($approver_response == 'Edit') {
             //Update the request
             $EASRequest->updateRequest($request->request_code, $user_id, $request->all(), $request->filing_type);
             //Get updated details
             $data = [];
             $data['details'] = $EASRequest->getRequestDetails($request->request_code, $user_id);
             //Email Appropriate recipients
             $mail = new EmailController();
             $mail->send($data['details'], $approver_response);
             return $this->edit(trim($data['details']['rfc_code']), $request->filing_type, 'update');
         }
     }
 }