public function notifyClose($id)
 {
     $notify = Notifications::where('id', $id)->first();
     $notify->status = 1;
     $notify->save();
     return Response::json(['result' => true, 'data' => $notify]);
 }
 /**
  * This function submits the changes made in event progress
  *
  * @param string        POST data (from event progress update)
  *
  * @return  if successful, 'Events Assigned To Me' page for Team Member
  */
 public function EditProgress()
 {
     $input = Request::all();
     $iName = $input['EventID'];
     $user_id = \Auth::user()->id;
     $iPercentage = array();
     $iStatus = array();
     $iTaskID = array();
     if (isset($_POST['doneprogress'])) {
         $today = Carbon::today()->toDateString();
         $em = Quote_Requests::select('*')->where('id', $iName)->first();
         $mailData = ['EventID' => $iName, 'EventType' => $em->EventType, 'DueDate' => $em->DueDate, 'CompletedOn' => $today, 'FirstName' => $em->UserName];
         //send email to customer
         Mail::send('emails.event-complete', $mailData, function ($message) use($em) {
             $message->to($em->Email, 'Test')->subject('Your Event Is Ready!');
         });
         //send a notification to customer
         $newNotification = new Notifications();
         $newNotification->title = 'Event Complete';
         $newNotification->body = $em->EventType . ' planning is complete';
         $newNotification->icon = 'icon';
         $newNotification->link = 'dashboard/events/progresscustomer?EventID=' . $iName;
         $newNotification->readStatus = '0';
         $newNotification->save();
         $message = $em->EventType . ' planning is complete';
         $icon = 'icon';
         $link = 'dashboard/events/progresscustomer?EventID=' . $iName;
         $title = 'Event Complete';
         Pusher::trigger('notifications', 'success_notification', ['message' => $message, 'icon' => $icon, 'link' => $icon, 'title' => $title]);
         return redirect('dashboard/events/myevents')->with('message', 'You Completed The Event');
     } else {
         foreach ($input['percentage'] as $x) {
             $iPercentage[] = $x;
         }
         foreach ($input['status'] as $y) {
             $iStatus[] = $y;
         }
         foreach ($input['taskid'] as $z) {
             $iTaskID[] = $z;
         }
         foreach ($input['taskid'] as $z => $value) {
             $today = Carbon::today()->toDateString();
             Event_Tasks::where('EventID', $iName)->where('id', $iTaskID[$z])->update(['Percentage' => $iPercentage[$z], 'Status' => $iStatus[$z], 'LastUpdated' => $today]);
         }
         return redirect('dashboard/events/myevents')->with('message', 'Record Added Successfully');
     }
 }
 /**
  * This function is to store the reservation details to db.
  * After storing the details this function redirects to the My Reservation view.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function hallReservation()
 {
     try {
         //set the timezone
         date_default_timezone_set("Asia/Colombo");
         $customer_email = Auth::user()->email;
         $customer_id = Customer::where('email', $customer_email)->value('cus_id');
         $customer_name = Customer::where('email', $customer_email)->value('name');
         $hall_name = HALL::where('hall_id', session('hall_selected'))->value('title');
         $event_date = session('event_date');
         //create instance of the HALL_RESERVATION model
         $hall_reservation = new HALL_RESERVATION();
         $hall_reservation->reserve_date = session('event_date');
         $hall_reservation->time_slot = session('timeSlot');
         $hall_reservation->total_amount = session('total_payable');
         $hall_reservation->cus_id = $customer_id;
         $hall_reservation->hall_id = session('hall_selected');
         $hall_reservation->status = 'PENDING';
         $hall_reservation->save();
         //retrieve the reservation id of the last saved reservation
         $res_id = $hall_reservation->hall_reservation_id;
         //delete the reservation details since already stored in the db
         Session::forget(['event_date', 'total_payable', 'hall_selected', 'CanPay']);
         //create an array in order to send the mail view with reservation details
         $data = array('res_id' => $res_id, 'hall_name' => $hall_name, 'event_date' => $event_date, 'name' => $customer_name);
         $job = new SendEmail($data, $customer_email, "initial_reservation_mail");
         $this->dispatch($job);
         //send a initial mail
         /*  Mail::send('emails.InitialRoomReservationMail', $data, function ($message)use($customer_email) {
                         $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
         
                         $message->to($customer_email)->subject('Welcome to Amalya Reach!');
                     });*/
         //pusher
         $newNotification = new Notifications();
         $newNotification->notification = "New Reservation";
         $newNotification->body = "Room Reservation has been made";
         $newNotification->readStatus = '0';
         $newNotification->save();
         Pusher::trigger('notifications', 'Reservation', ['message' => 'New Hall Reservation has been made']);
         return redirect('myreserv')->with(['hreserv_status' => 'Reservation has been successfully made']);
     } catch (\Exception $e) {
         abort(500, $e->getMessage());
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $networks = Network::where('user_id', Auth::user()->id)->get();
     $user = Auth::user();
     $traps = Traps::where('user_id', $user->id)->where('status', 1)->get();
     $networks->push(['name' => 'Default', 'id' => 0]);
     $notifications = Notifications::latest()->get();
     return view('network.index')->with('traps', $traps)->with('notifications', $notifications)->with('networks', $networks);
 }
 public function editUser($id)
 {
     if ($id != Auth::user()->id) {
         return redirect(route('network.index'));
     }
     $user = User::findOrFail($id);
     $notifications = Notifications::latest()->get();
     return view('users.user_change')->with('user', $user)->with('notifications', $notifications);
 }
 /**
  * This function store the room reservation details to db and clears the session
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function roomReservation(Request $request)
 {
     //set the timezone
     date_default_timezone_set("Asia/Colombo");
     //get the customer details currently logged in
     $customer_email = Auth::user()->email;
     $customer_id = Customer::where('email', $customer_email)->value('cus_id');
     $customer_name = Customer::where('email', $customer_email)->value('name');
     //convert the dates to date time insatance and get the difference
     $datetime1 = new DateTime(session('check_in'));
     $datetime2 = new DateTime(session('check_out'));
     $interval = $datetime1->diff($datetime2);
     //get the requested reservation details from the session
     $no_of_guests = session('adults') + session('kids');
     //formt the number of nights
     $no_of_nights = $interval->format('%d%') + config('constants.ADD_ONE_NIGHT');
     //call the saveReservationDetails function to save the reservation details to the database
     $res_id = $this->saveReservationDetails(session('check_in'), session('check_out'), $no_of_nights, $customer_id);
     //insert the the details to the RES_RMTYPE_CNT_RATE table
     foreach (session('room_types') as $room_type) {
         DB::table('RES_RMTYPE_CNT_RATE')->insert(['room_reservation_id' => $res_id, 'room_type_id' => $room_type, 'rate_code' => session('rate_code' . $room_type), 'count' => session('no_of_rooms' . $room_type)]);
     }
     //create an array with reservation details in ordr to send to the mail view
     $data = array('res_id' => $res_id, 'check_in' => session('check_in'), 'check_out' => session('check_out'), 'nights' => $no_of_nights, 'no_of_rooms' => session('rooms'), 'guests' => $no_of_guests, 'name' => $customer_name);
     //observer design pattern is used here, but this is design pattern is no use full
     /*$sub =  new ReservationRoom();
       $sub->attach(new ReservationTask());
       $sub->clearSession();*/
     //clear session
     $this->clearRoomSession("Full");
     //call the mailfunction send an email
     $this->sendInitialMail($data, $customer_email);
     //send an pusher notification to the admin
     //remove the magic values
     $newNotification = new Notifications();
     $newNotification->notification = "New Reservation";
     $newNotification->body = "Room Reservation has been made";
     $newNotification->readStatus = '0';
     $newNotification->save();
     Pusher::trigger('notifications', 'Reservation', ['message' => 'New Room Reservation has been made']);
     return redirect('myreserv')->with(['reserv_status' => 'Room_Reservation']);
 }
 public function updateNotifications(Request $request)
 {
     $id = Auth::id();
     $input = $request->all();
     Notifications::find($input['banner_id'])->users()->attach(User::find($id));
     //        DB::table('notification_user')
     //            ->where('user_id', $id)
     //            ->update(['read' => 1]);
     $nu = NotificationUser::where('user_id', '=', Auth::user()->id)->first();
     $nu->read = 1;
     $nu->update();
     return redirect()->back();
 }
Example #8
0
 /**
  * Define the application's command schedule.
  * @link http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     /* $schedule->command('queue:listen')->everyMinute();*/
     /*$schedule->command('inspire')
       ->hourly();*/
     // This scheduled task backs up the db at midnight everyday
     $serial_num = BACKUP_LOG::max('serial_num');
     $newSerial_num = sprintf('%08d', $serial_num + 1);
     $currentSerialNum = BACKUP_LOG::find($serial_num);
     $currentSerialNum->serial_num = $newSerial_num;
     $currentSerialNum->save();
     // This shell command will be executed at Midnight everyday
     $schedule->exec('mysqldump -u' . env('DB_USERNAME') . ' -p' . env('DB_PASSWORD') . ' ' . env('DB_DATABASE') . ' > ' . env('BACKUP_PATH') . $newSerial_num . "_scheduled_backup_`date`" . '.sql')->daily();
     /*// This shell command will be executed at the specified time everyday
       // Test this with php artisan schedule:run
       $schedule->exec('mysqldump -u'.env('DB_USERNAME').' -p'.env('DB_PASSWORD').' '.env('DB_DATABASE').' > '.env('BACKUP_PATH').$newSerial_num."_scheduled_backup_`date`".'.sql')
           ->dailyAt("14:34");*/
     $newNotification = new Notifications();
     $newNotification->notification = "Backup successful!";
     $newNotification->body = 'Backup #' . $newSerial_num . ' created.';
     $newNotification->readStatus = '0';
     $newNotification->save();
 }
 /**
  * save a customer inwuiry and send an email to admin email which is hardcoded
  *
  * @param Request $request
  */
 public function saveinquiry(Request $request)
 {
     $inq = new Inquiry();
     $inq->name = $request->input('fullname');
     $inq->company = $request->input('company');
     $inq->email = $request->input('email');
     $inq->message = $request->input('message');
     $inq->status = '1';
     $inq->save();
     // save notification to DB and to pusher
     $newNotification = new Notifications();
     $newNotification->notification = "New Customer Inquiry!";
     $newNotification->body = 'New Customer Inquiry has been made.';
     $newNotification->readStatus = '0';
     $newNotification->save();
     Pusher::trigger('notifications', 'new_backup_notification', ['message' => 'New Customer Inquiry has been made.']);
     // get admin's email
     $email = User::where('role', 'admin')->first()->email;
     Mail::send('emails.inquiry', ['inq' => $inq], function ($message) use($email) {
         $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
         //$message->to("*****@*****.**")->subject('Amalaya Reach Inquiry');
         $message->to($email)->subject('Amalaya Reach Inquiry');
     });
 }
Example #10
0
             if (!$Database->where('id', $Post->id)->update("{$type}s", $update)) {
                 Response::dbError();
             }
             $postdata = array('type' => $type, 'id' => $Post->id);
             $message = '';
             if (isset($update['lock'])) {
                 $message .= "<p>The image appears to be in the group gallery already, so we marked it as approved.</p>";
                 Logs::action('post_lock', $postdata);
                 if ($Post->reserved_by !== $currentUser->id) {
                     Notifications::send($Post->reserved_by, 'post-approved', $postdata);
                 }
             }
             if ($type === 'request') {
                 $u = Users::get($Post->requested_by, 'id', 'name,id');
                 if (!empty($u) && $Post->requested_by !== $currentUser->id) {
                     $notifSent = Notifications::send($u->id, 'post-finished', $postdata);
                     $message .= "<p><strong>{$u->name}</strong> " . ($notifSent === 0 ? 'has been notified' : 'will receive a notification shortly') . '.' . (is_string($notifSent) ? "</p><div class='notice fail'><strong>Error:</strong> {$notifSent}" : '') . "</div>";
                 }
             }
             if (!empty($message)) {
                 Response::success($message);
             }
             Response::done();
             break;
     }
 } else {
     if ($action === 'unreserve') {
         Response::done(array('li' => Posts::getLi($Post)));
     } else {
         if ($action === 'finish') {
             Response::fail("This {$type} has not been reserved by anypony yet");
 public function read()
 {
     $id = Input::only('id');
     $notification = Notifications::findOrFail($id);
     $n = json_encode($notification);
     return Response::json($n);
 }
 public function setStatus()
 {
     Notifications::where('readStatus', '=', '0')->update(['readStatus' => 1]);
 }
 /**
  * Return user if exists; create and return if doesn't
  *
  * @param $user
  * @return User
  */
 private function findOrCreateUser($user, $provider)
 {
     $authUser = User::where('email', $user->email)->first();
     if ($authUser) {
         Session::put('user_role', $authUser->role);
         return $authUser;
     } else {
         Session::put('user_role', 'customer');
         /**
          * Random Generated Password for Social Logged Users
          *
          * @var string
          */
         $pwd = str_random(8);
         $providerName = "Social Media";
         switch ($provider) {
             case 'facebook':
                 $providerName = "Facebook";
                 break;
             case 'google':
                 $providerName = "Google+";
                 break;
             default:
                 $providerName = "Social Media";
                 break;
         }
         $mailData = ['name' => $user->name, 'pwd' => $pwd, 'provider' => $providerName, 'email' => $user->email];
         $newNotification = new Notifications();
         $title = "New user registered!";
         $message = $user->name . ' just registered using ' . $providerName . '.';
         $icon = "fa-user";
         $link = 'dashboard/users';
         $for = "admin";
         $newNotification->title = $title;
         $newNotification->body = $message;
         $newNotification->icon = $icon;
         $newNotification->link = $link;
         $newNotification->for = $for;
         $newNotification->readStatus = '0';
         $newNotification->save();
         Pusher::trigger('notifications', 'success_notification', ['message' => $message, 'icon' => $icon, 'link' => $link, 'title' => $title, 'for' => $for]);
         //Send Welcome Email
         Mail::send('emails.register-success-social', $mailData, function ($message) use($user) {
             $message->to($user->email)->subject('Welcome to PlanMyEvent.me');
         });
         return User::create(['name' => $user->name, 'email' => $user->email, 'password' => bcrypt($pwd), 'provider_id' => $user->id, 'avatar' => $user->avatar, 'provider' => $provider, 'provider_id' => $user->id, 'role' => 'customer']);
     }
 }
 public function editImage($id)
 {
     $image = Images::findOrFail($id);
     $trap = Traps::findOrFail($image->trap_id);
     $image->user_id = $trap->user_id;
     $areas = Pest_image::where('id_pest_image', $id)->get();
     $notifications = Notifications::latest()->get();
     return view('traps.edit_image')->with('image', $image)->with('areas', $areas)->with('notifications', $notifications);
 }
Example #15
0
            switch ($Notif['type']) {
                case "post-passon":
                    $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s");
                    if (empty($Post)) {
                        Posts::clearTransferAttempts($Post, $data['type'], 'del');
                        Response::fail("The {$data['type']} doesn't exist or has been deleted");
                    }
                    if ($read_action === 'true') {
                        if ($Post['reserved_by'] !== $currentUser->id) {
                            Posts::clearTransferAttempts($Post, $data['type'], 'perm', null, $currentUser->id);
                            Response::fail('You are not allowed to transfer this reservation');
                        }
                        Notifications::safeMarkRead($Notif['id'], $read_action);
                        Notifications::send($data['user'], "post-passallow", array('id' => $data['id'], 'type' => $data['type'], 'by' => $currentUser->id));
                        $Database->where('id', $data['id'])->update("{$data['type']}s", array('reserved_by' => $data['user'], 'reserved_at' => date('c')));
                        Posts::clearTransferAttempts($Post, $data['type'], 'deny');
                        Logs::action('res_transfer', array('id' => $data['id'], 'type' => $data['type'], 'to' => $data['user']));
                    } else {
                        Notifications::safeMarkRead($Notif['id'], $read_action);
                        Notifications::send($data['user'], "post-passdeny", array('id' => $data['id'], 'type' => $data['type'], 'by' => $currentUser->id));
                    }
                    Response::done();
                    break;
                default:
                    Notifications::safeMarkRead($Notif['id'], $read_action);
            }
        } else {
            Notifications::safeMarkRead($Notif['id']);
        }
        Response::done();
}
Example #16
0
 public static function FollowUser($input)
 {
     $validation = Validator::make($input, Posts::$UserPostsRules);
     if ($validation->fails()) {
         return Response::json(array('status' => '0', 'msg' => $validation->getMessageBag()->first()), 200);
     } else {
         $access_token = $input['token'];
         $other_id = $input['other_id'];
         $user_id = Users::getUserIdByToken($access_token);
         $current_time = new DateTime();
         if ($user_id) {
             $uname = Users::getUsername($user_id);
             $push_status = Users::getPushSettings($other_id);
             $user_det = Users::getUserType($user_id);
             $user_type = $user_det->user_type;
             $push_ids = Users::getUserPushIds($other_id);
             $reg_id = $push_ids->reg_id;
             $device_token = $push_ids->apn_id;
             $friend_data = DB::table('follow')->select('*')->where('follow_by', $user_id)->where('follow_to', $other_id)->first();
             $notify_message = $uname . " has started following you";
             $Ninput['sender_id'] = $user_id;
             $Ninput['receiver_id'] = $other_id;
             if ($friend_data) {
                 $Ninput['type_id'] = $friend_data->id;
             }
             $Ninput['type'] = 'follow';
             $Ninput['title'] = $notify_message;
             if (!$friend_data) {
                 $follow_id = DB::table('follow')->insertGetId(array('follow_by' => $user_id, 'follow_to' => $other_id, 'status' => '1', 'created_at' => $current_time));
                 $Ninput['type_id'] = $follow_id;
                 Notifications::addNotification($Ninput);
                 if ($push_status) {
                     Notifications::SendPushNotification($notify_message, $reg_id, $device_token, 5, $user_id, $user_type);
                 }
             } else {
                 $follow_id = DB::table('follow')->select('*')->where('follow_by', $user_id)->where('follow_to', $other_id)->delete();
                 Notifications::RemoveNotification($Ninput);
             }
             $friends = Users::GetFollowers($user_id);
             $follower_data = $friends['followers'];
             $following_data = $friends['following'];
             if ($follow_id) {
                 return Response::json(array('status' => '1', 'msg' => 'Friend List Updated', 'followers' => $follower_data, 'following' => $following_data), 200);
             } else {
                 return Response::json(array('status' => '0', 'msg' => "Error"), 200);
             }
         } else {
             return Response::json(array('status' => '0', 'msg' => "Token Expired"), 200);
         }
     }
 }
Example #17
0
 public function storeNotification(Request $request)
 {
     Notifications::create($request->all());
     flash()->success('Success', 'Notification successfully saved. All users will be notified.');
     return back();
 }
 public function uploadslip(Request $request)
 {
     $rules = array('payment_slip' => 'required|mimes:jpeg,bmp,png,jpg,gif', 'orders_number' => 'required', 'payment_channel' => 'required', 'payment_price' => 'required', 'payment_date' => 'required', 'payment_time' => 'required');
     $validator = \Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect()->intended('/member')->withErrors(array('error' => 'โปรดตรวจสอบข้อมูลใหม่อีกครั้ง'));
     }
     $now = Carbon::now('Asia/Bangkok');
     $hash = md5($now);
     $user = \Auth::user();
     $imageName = $hash . '-' . $user->id . '.' . $request->file('payment_slip')->getClientOriginalExtension();
     $request->file('payment_slip')->move(base_path() . '/public/images/slip/', $imageName);
     $link = '/images/slip/' . $imageName;
     $slip = Orders_slip::create(['payment_slip' => $link, 'orders_number' => $request->input('orders_number'), 'payment_channel' => $request->input('payment_channel'), 'payment_price' => $request->input('payment_price'), 'payment_date' => $request->input('payment_date'), 'payment_time' => $request->input('payment_time'), 'created_at' => $now, 'updated_at' => $now]);
     if ($slip->id == null) {
         return redirect()->intended('/member')->withErrors(array('error' => 'ยืนยันการชำระเงินผิดพลาด กรุณาลองใหม่อีกครั้ง'));
     }
     $order = Orders::where('orders_number', $request->input('orders_number'))->get()->first();
     $order->status = 2;
     $order->updated_at = $now;
     $order->orders_slip = $slip->id;
     $result = $order->save();
     if ($result) {
         $this->sendmail($order, $link, $slip);
     }
     //save notify
     $notify = new Notifications();
     $notify->members_id = \Auth::user()->id;
     $notify->type = "PAYMENT_CONFIRM";
     $notify->status = 0;
     $notify->created_at = $now;
     $notify->updated_at = $now;
     $notify->order_id = $order->id;
     $notify->message = "You have a new confirm payment !";
     $notify->save();
     return redirect()->intended('/member');
 }
Example #19
0
 /**
  * Approves a specific post and optionally notifies it's author
  *
  * @param string $type         request/reservation
  * @param int    $id           post id
  * @param string $notifyUserID id of user to notify
  *
  * @return array
  */
 static function approve($type, $id, $notifyUserID = null)
 {
     global $Database;
     if (!$Database->where('id', $id)->update("{$type}s", array('lock' => true))) {
         Response::dbError();
     }
     $postdata = array('type' => $type, 'id' => $id);
     Logs::action('post_lock', $postdata);
     if (!empty($notifyUserID)) {
         Notifications::send($notifyUserID, 'post-approved', $postdata);
     }
     return $postdata;
 }
 public function confirm(Request $request)
 {
     $now = new DateTime();
     $rules = array('name' => 'required', 'address' => 'required', 'trans' => 'required', 'phone' => 'required');
     $validator = \Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return Response::json(array('result' => false, 'data' => 'กลับไปที่หน้าแรก โปรดตรวจสอบข้อมูลใหม่อีกครั้ง', 'message' => $validator->messages()->all()));
     }
     //$validator->errors()->all()
     $order = new Orders();
     $orders_number = $now->format("YmdHis") . '-' . \Auth::user()->id;
     $cart = Cart::instance('cartoon');
     if ($cart->count() <= 0) {
         if ($validator->fails()) {
             return Response::json(array('result' => false, 'data' => 'กลับไปที่หน้าแรก โปรดตรวจสอบข้อมูลใหม่อีกครั้ง'));
         }
     }
     DB::beginTransaction();
     try {
         $order->orders_number = $orders_number;
         $order->members_id = \Auth::user()->id;
         $order->members_name = $request->input('name');
         $order->address = $request->input('address');
         $order->phone = $request->input('phone');
         $order->ems = $request->input('trans');
         $order->total = $cart->total();
         $order->total_grand = $cart->total() + $request->input('trans');
         $order->created_at = Carbon::now('Asia/Bangkok');
         $order->updated_at = Carbon::now('Asia/Bangkok');
         $order->status = 1;
         $order->save();
         DB::commit();
     } catch (\Exception $e) {
         DB::rollBack();
         return Response::json(array('result' => false, 'data' => 'ยืนยันผิดพลาด โปรดตรวจสอบข้อมูลใหม่อีกครั้ง', 'message' => $e));
     }
     DB::beginTransaction();
     try {
         $now = Carbon::now('Asia/Bangkok');
         foreach ($cart->content() as $key => $item) {
             $pro = Products_vol::where('code', $item->id)->get()->first();
             $orders_detail = new Orders_detail();
             $orders_detail->orders_number = $order->orders_number;
             $orders_detail->product_vol_code = $item->id;
             $orders_detail->product_vol_name = $pro->name;
             $orders_detail->product_vol_qty = $item->qty;
             $orders_detail->product_vol_per = $pro->price;
             $orders_detail->created_at = $now;
             $orders_detail->updated_at = $now;
             $orders_detail->product_vol_price = $pro->price * $item->qty;
             $orders_detail->save();
             DB::commit();
         }
     } catch (\Exception $e) {
         DB::rollBack();
         return Response::json(array('result' => false, 'data' => 'ยืนยันผิดพลาด โปรดตรวจสอบข้อมูลใหม่อีกครั้ง', 'message' => $e));
     }
     $cart->destroy();
     $this->sendmail($order);
     //save notify
     $notify = new Notifications();
     $notify->members_id = \Auth::user()->id;
     $notify->type = "CREATE_ORDER";
     $notify->status = 0;
     $notify->created_at = $now;
     $notify->updated_at = $now;
     $notify->order_id = $order->id;
     $notify->message = "You have a new order !";
     $notify->save();
     return Response::json(array('result' => true, 'data' => $order));
 }
Example #21
0
?>
</ul></nav>
	</div>
<?php 
if (!empty($Database)) {
    if ($signedIn) {
        $Notifications = Notifications::get(null, Notifications::UNREAD_ONLY);
        ?>
	<section class="notifications"<?php 
        echo empty($Notifications) ? ' style="display:none"' : '';
        ?>
>
		<h2>Unread notifications</h2>
<?php 
        try {
            echo Notifications::getHTML($Notifications);
        } catch (Throwable $e) {
            error_log('Exception caught when rendering notifications: ' . $e->getMessage() . "\n" . $e->getTraceAsString());
            echo '<ul class="notif-list"><li>An error prevented the notifications from appearing. If this persists, <a class="send-feedback">let us know</a>.</li></ul>';
        }
        ?>
	</section>
<?php 
    }
    ?>
	<section class="<?php 
    echo $signedIn ? 'welcome' : 'login';
    ?>
">
		<h2><?php 
    echo $signedIn ? 'Signed in as' : 'Welcome!';
Example #22
0
 static function safeMarkRead($NotifID, $action = null)
 {
     try {
         Notifications::markRead($NotifID, $action);
     } catch (ServerConnectionFailureException $e) {
         error_log("Notification server down!\n" . $e->getMessage());
         Response::fail('Notification server is down! Please <a class="send-feedback">let us know</a>.');
     } catch (\Exception $e) {
         error_log("SocketEvent Error\n" . $e->getMessage());
         Response::fail('SocketEvent Error: ' . $e->getMessage());
     }
 }
Example #23
0
 public static function SetNotificationStatus()
 {
     $input = Input::all();
     return Notifications::SetNotificationStatus($input);
 }
Example #24
0
 public static function unlikePost($input)
 {
     $validation = Validator::make($input, Posts::$likePostRules);
     if ($validation->fails()) {
         return Response::json(array('status' => '0', 'msg' => $validation->getMessageBag()->first()), 200);
     } else {
         $access_token = $input['token'];
         $post_id = $input['post_id'];
         $current_time = new DateTime();
         $user_id = Users::getUserIdByToken($access_token);
         if ($user_id) {
             $like_data = DB::table('likes')->select('id')->where('post_id', $post_id)->where('user_id', $user_id)->first();
             $like_id = DB::table('likes')->select('id')->where('post_id', $post_id)->where('user_id', $user_id)->delete();
             $Ninput['sender_id'] = $user_id;
             $Ninput['receiver_id'] = Posts::getPostOwner($post_id);
             $Ninput['type_id'] = $like_data->id;
             $Ninput['type'] = 'like';
             Notifications::RemoveNotification($Ninput);
             if ($like_id) {
                 return Response::json(array('status' => '1', 'msg' => 'Post Unliked'), 200);
             }
         } else {
             return Response::json(array('status' => '0', 'msg' => "Token Expired"), 200);
         }
     }
 }