public function update_user(UserEditRequest $request) { $id = Auth::id(); $password = $request->get('old_password'); if (Auth::attempt(array('id' => $id, 'password' => $password))) { $user = User::whereId($id)->firstOrFail(); $user->first_name = $request->get('first_name'); $user->last_name = $request->get('last_name'); $user->dob = $request->get('dob'); $user->email = $request->get('email'); $new_password = $request->get('password'); if ($new_password != "") { $user->password = Hash::make($new_password); } $user->save(); $calendar = Calendar::where('user_id', '=', $id)->firstOrFail(); $calendar->name = $request->get('first_name'); $calendar->save(); $message = 'valid'; return $message; } else { $message = 'invalid'; return $message; } }
public function getMain() { $user_id = Auth::id(); $name = DB::table('users')->where('id', '=', $user_id)->value('first_name'); $calendar = Calendar::where('user_id', '=', $user_id)->where('name', '=', $name)->first(); return Response::json($calendar); }
private function saveDetail($booking, $locks, $user) { $count = 0; foreach ($locks as $key => $lock) { $zoneCode = substr($lock, 0, 1); $calendar = Calendar::where('opened_at', $booking->sale_at)->where('code', $zoneCode)->first(); $detail = BookingDetail::create(['code' => date('Ymd-His') . '-' . $user->id . '-' . ($count + 1), 'bookingID' => $booking->id, 'bookingCode' => $booking->code, 'zoneID' => $calendar->zoneID, 'zoneCode' => $calendar->code, 'zoneNumber' => $lock, 'price' => $calendar->price_type2, 'status' => 'BK', 'sale_at' => $booking->sale_at]); $count++; } }
public function zone($date) { if ($date == null) { return response()->json(['result' => false, 'message' => 'please select date.']); } $calendar = Calendar::where('active', 1)->where('opened_at', $date)->orderBy('code')->get(); if ($calendar == null) { return response()->json(['result' => false, 'message' => 'can not get booking calendar.']); } return response()->json(['result' => true, 'data' => $calendar, 'message' => 'success']); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Request $request) { // $page = $request->input('page'); $pageSize = $request->input('pageSize'); $skip = ($page - 1) * $pageSize; $calendars = Calendar::where('active', 1)->groupBy('opened_at')->skip($skip)->take($pageSize)->get(); $count = count(Calendar::where('active', 1)->groupBy('opened_at')->get()); if ($calendars == null) { return response()->json(['result' => false, 'message' => 'can not get calendar.']); } foreach ($calendars as $key => $calendar) { $calendar->booking = Booking::where('sale_at', $calendar->opened_at . ' 00:00:00')->whereNotIn('status', ['RM'])->count(); $calendar->checkin = Booking::where('sale_at', $calendar->opened_at . ' 00:00:00')->where('status', 'CN')->count(); $calendar->undefine = Booking::where('sale_at', $calendar->opened_at . ' 00:00:00')->where('status', 'BK')->count(); } return response()->json(['result' => true, 'data' => $calendars, 'message' => 'success', 'total' => $count]); }
/** * Execute the console command. * * @return mixed */ public function handle() { // Get all calendar entries that are due in two hours. $now = date('Y-m-d H:i:s'); $events = Calendar::where('Reminded', '=', false)->where('Start', '<=', date('Y-m-d H:i:s', strtotime($now) + 7200))->get(); // Now remind each user. foreach ($events as $event) { $user = User::where('TypeId', '=', $event->WorkerId)->first(); $notification = Notification::create(array('UserId' => $user->Id, 'Created' => $now, 'Reason' => 'Recordatorio de Evento: ' . $event->Title, 'Url' => '/calendar/' . $event->Id, 'Seen' => false)); // Update event. $event->Reminded = true; $event->save(); // Now check if this event should be rescheduled. switch ($event->Type) { case 2: // Add event next week. Calendar::create(array('Start' => date('Y-m-d H:i:s', strtotime($event->Start) + 604800), 'End' => date('Y-m-d H:i:s', strtotime($event->End) + 604800), 'WorkerId' => $event->WorkerId, 'Title' => $event->Title, 'AllDay' => $event->AllDay, 'Type' => $event->Type)); break; case 3: // Add event next Month. Calendar::create(array('Start' => date('Y-m-d H:i:s', strtotime($event->Start) + 2419200), 'End' => date('Y-m-d H:i:s', strtotime($event->End) + 2419200), 'WorkerId' => $event->WorkerId, 'Title' => $event->Title, 'AllDay' => $event->AllDay, 'Type' => $event->Type)); break; case 4: // Add event next Year. Calendar::create(array('Start' => date('Y-m-d H:i:s', strtotime($event->Start) + 29030400), 'End' => date('Y-m-d H:i:s', strtotime($event->End) + 29030400), 'WorkerId' => $event->WorkerId, 'Title' => $event->Title, 'AllDay' => $event->AllDay, 'Type' => $event->Type)); break; } } // Check for provider payments. $events = Calendar::where('Type', '=', 5)->where('Start', '<=', date('Y-m-d H:i:s', strtotime($now) + 172800))->get(); // Now remind each user. foreach ($events as $event) { $user = User::where('TypeId', '=', $event->WorkerId)->first(); $notification = Notification::create(array('UserId' => $user->Id, 'Created' => $now, 'Reason' => 'Dentro de dos dias se deberia pagar: ' . $event->Title, 'Url' => '/calendar/' . $event->Id, 'Seen' => false)); // Update event. $event->Reminded = true; $event->save(); } }
$events = Calendar::where('active', '1')->where('opened_at', $date)->get(); return response()->json($events); }); Route::post('/admin/signin/valid', 'Backend\\HomeController@check'); Route::group(['middleware' => 'auth'], function () { Route::get('/admin/account', 'Backend\\AdminController@index'); Route::get('/admin/account/create', 'Backend\\AdminController@create'); Route::post('/admin/account/create', 'Backend\\AdminController@store'); Route::post('/admin/account/search', 'Backend\\AdminController@search'); Route::put('/admin/account/update/{id}', 'Backend\\AdminController@update'); Route::get('/admin/home', 'Backend\\HomeController@index'); Route::get('/admin/calendar', 'Backend\\CalendarController@index'); Route::post('/admin/calendar/save', 'Backend\\CalendarController@store'); Route::post('/admin/calendar/update', 'Backend\\CalendarController@update'); Route::get('/admin/calendar/delete/{date}', function ($date) { $events = Calendar::where('opened_at', $date)->delete(); return response()->json($events); }); Route::get('/admin/calendar/close/month/{date}', 'Backend\\CalendarController@closeMouth'); Route::get('/admin/calendar/close/day/{date}', 'Backend\\CalendarController@closeDay'); Route::get('/admin/payment', 'Backend\\PaymentController@index'); Route::get('/admin/payment/date', 'Backend\\PaymentController@date'); Route::get('/admin/payment/zone/{date}', 'Backend\\PaymentController@zone'); Route::post('/admin/payment/search', 'Backend\\PaymentController@search'); Route::post('/admin/payment/update', 'Backend\\PaymentController@update'); Route::get('/admin/payment/show/{id}', 'Backend\\PaymentController@show'); Route::get('/admin/paymentmonth', 'Backend\\PaymentMonthlyController@index'); Route::get('/admin/paymentmonth/date', 'Backend\\PaymentMonthlyController@date'); Route::get('/admin/paymentmonth/zone/{date}', 'Backend\\PaymentMonthlyController@zone'); Route::post('/admin/paymentmonth/search', 'Backend\\PaymentMonthlyController@search'); Route::post('/admin/paymentmonth/update', 'Backend\\PaymentMonthlyController@update');
/** * Function that gets events from a worker's calendar. * * @return Response */ public function getEvents() { // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(array()); } // Get the worker. $worker = Worker::find(Auth::user()->TypeId); // Get the events. $events = array(); $calendar = Calendar::where('WorkerId', '=', $worker->Id)->get(); foreach ($calendar as $event) { array_push($events, array('id' => $event->Id, 'start' => $event->Start, 'end' => $event->End, 'allDay' => $event->AllDay, 'title' => $event->Title)); } // Return response. return response()->json($events); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { $rules = array('open' => 'required', 'date' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('result' => false, 'message' => 'valid input.')); } $count = 0; $arr = $request->input('open'); for ($i = 0; $i < count($arr); $i++) { $open = (object) $arr[$i]; if (isset($open->value)) { if ($open->value) { if (!isset($open->calendarID)) { $open->calendarID = 0; } $calendar = Calendar::where('id', $open->calendarID)->get()->first(); if (!isset($calendar)) { $calendar = new Calendar(); } $calendar->code = $open->code; $calendar->zoneID = $open->id; $calendar->name = $open->name; $calendar->maxLock = $open->maxLock; $calendar->row = $open->row; $calendar->availableLock = $open->maxLock - $open->close; $calendar->price_type1 = $open->price_type1; $calendar->price_type2 = $open->price_type2; $calendar->active = $open->active; $calendar->opened_at = $request->input('date') . ' 00:00:00'; $calendar->created_at = date("Y-m-d H:i:s"); $calendar->save(); $count++; } else { if (isset($open->calendarID)) { $calendar = Calendar::where('id', $open->calendarID)->delete(); } } } } return response()->json(array('result' => true, 'message' => 'success [' . $count . '].', 'id' => $request->input('date'))); }
public function getZone($date) { $zones = Calendar::where('opened_at', $date)->groupBy('name')->get(); return response()->json($zones); }
/** * [getAbsenceInYear description] * @param Request $request [description] * @param [type] $month [description] * @return [type] [description] */ public function getAbsenceInYear(Request $request, $employee_id, $year) { $desSigns = DescriptionSign::all(); $emInYear = Calendar::where('year', $year)->where('employee_id', $employee_id)->get(); foreach ($emInYear as $key => $value) { for ($i = 1; $i <= 31; $i++) { if ($value->{'n' . $i} != '') { array_walk($desSigns, array($this, 'changeCountDesSign'), $value->{'n' . $i}); } } } $desSigns = $this->assignDayOffLeft($desSigns); return json_encode($desSigns); }