/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $dateA = Input::get('dateApplication'); $dateApplication = date(microtime(substr($dateA, 6, 4) . "-" . substr($dateA, 3, 2) . "-" . substr($dateA, 0, 2) . " " . substr($dateA, 10, 6)) * 10000); $boosterI = Input::get('boosterInjection'); $boosterInjection = date(microtime(substr($boosterI, 6, 4) . "-" . substr($boosterI, 3, 2) . "-" . substr($boosterI, 0, 2) . " " . substr($boosterI, 10, 6)) * 10000); //dd($request->diseaseName); $animalName = Animal::where('id', $request->animalName)->pluck('nombre'); $diseaseName = Disease::where('id', $request->diseaseName)->pluck('name'); $vaccineName = Vaccine::where('id', $request->vaccineName)->pluck('name'); $vc = new VaccinationControl(); $vc->idUser = Auth::id(); $vc->animalName = $animalName; $vc->diseaseName = $diseaseName; $vc->vaccineName = $vaccineName; $vc->dateApplication = Input::get('dateApplication'); $vc->dose = Input::get('dose'); $vc->responsible = Input::get('responsible'); $vc->boosterInjection = Input::get('boosterInjection'); //dd($vc); $vc->save(); $event = new Calendar(); $event->idUser = Auth::id(); $event->title = 'Vacunacion'; $event->body = 'Programada'; $event->url = 'http://localhost:8000/vaccinationControl'; $event->class = 'Preventivo'; $event->start = $dateApplication; $event->end = $boosterInjection; $event->save(); return redirect()->route('vaccinationControl.show'); }
public function save($data1, $data2) { $calendar = new Calendar(); $calendar->nbmatches = $data1; $calendar->team = $data2; $calendar->save(); }
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; } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show() { $events = Calendar::all(); $events = json_encode(array("success" => 1, "result" => $events)); //dd($events); return view('calendar.calendar', compact('events')); }
/** * Run the database seeds. * * @return void */ public function run() { Calendar::create(array('name' => 'Brenda', 'color' => '0, 153, 255', 'user_id' => 1)); Calendar::create(array('name' => 'one day', 'color' => '255, 102, 153', 'user_id' => 1)); Calendar::create(array('name' => 'long events', 'color' => '255, 153, 102', 'user_id' => 1)); Calendar::create(array('name' => 'single repeats', 'color' => '0, 102, 0', 'user_id' => 1)); Calendar::create(array('name' => 'long repeats', 'color' => '0, 51, 153', 'user_id' => 1)); Calendar::create(array('name' => 'banana', 'color' => '204, 204, 0', 'user_id' => 1)); }
public function store(Request $request) { $name = Input::get('name'); $color = Input::get('color'); $user_id = Auth::id(); Calendar::create(array('name' => $name, 'color' => $color, 'user_id' => $user_id)); $addedCalendarId = DB::table('calendars')->where('name', '=', $name)->value('id'); return Response::json(['name' => $name, 'color' => $color, 'id' => $addedCalendarId]); }
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']); }
public static function weeklyEvent($event, $start, $end) { $weeklyEvents = array(); $period = static::periodDay($event->day_of_week, $start, $end); foreach ($period as $periodFrom) { $periodTo = clone $periodFrom; $periodFrom->add(Calendar::timeInterval($event->time_from)); $periodTo->add(Calendar::timeInterval($event->time_to)); $weeklyEvents[] = array('start' => $periodFrom->format(\DateTime::ISO8601), 'end' => $periodTo->format(\DateTime::ISO8601)); } return $weeklyEvents; }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $rules = ['summary' => 'required|string', 'description' => 'required|string', 'location' => 'required|string', 'timezone' => 'required|timezone']; $messages = ['required' => 'The :attribute field is required.', 'timezone' => 'The :attribute field should be a valid timezone', 'string' => 'The :attribute field be a string']; try { $validator = Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { return response($validator->errors(), 400); } else { $calendar = new Calendar(); $calendar->summary = $request->summary; $calendar->description = $request->description; $calendar->location = $request->location; $calendar->timezone = $request->timezone; $calendar->user_id = $this->user->id; $calendar->save(); return response($calendar, 201); } } catch (Exception $e) { return response($e->getMessage(), 404); } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $user = User::create(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'email' => $data['email'], 'dob' => $data['dob'], 'gender' => $data['gender'], 'password' => bcrypt($data['password'])]); $name = $data['first_name']; $email = $data['email']; $user_id = $user->id; Calendar::create(array('name' => $name, 'color' => '51, 153, 255', 'user_id' => $user_id)); Todolist::create(array('name' => 'To Do', 'color' => '0, 0, 102', 'user_id' => $user_id)); Style::create(array('theme_name' => 'default', 'body_backgroundColor' => '218, 173, 134', 'buttons_backgroundColor' => '117, 168, 202', 'buttons_borderColor' => '89, 105, 114', 'navBar_backgroundColor' => '201, 216, 197', 'menuModal_backgroundColor' => '255, 246, 253', 'user_id' => $user_id)); $emaildata = array('name' => $name); Mail::send('emails.welcome', $emaildata, function ($message) use($email) { $message->from('*****@*****.**', 'gmPlanner'); $message->to($email)->subject('Welcome to gmPlanner'); }); return $user; }
/** * 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(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $calendar = Calendar::find($id); $calendar->delete(); // redirect Session::flash('message', 'Successfully deleted!'); return redirect('home'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(Event $event) { $calendars = \App\Calendar::lists('name', 'id'); $checked = $event->calendars()->lists('id')->toArray(); return view('events.edit', compact('calendars', 'checked', 'event')); }
public function events() { $start = new Carbon(\Input::get('start')); $end = new Carbon(\Input::get('end')); return json_encode(Calendar::events($start, $end, EventSchedule::all())); }
/** * [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); }
public function getZone($date) { $zones = Calendar::where('opened_at', $date)->groupBy('name')->get(); return response()->json($zones); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $calendarRequest, Calendar $calendar) { $calendar->update($calendarRequest->input()); return redirect()->action('CalendarsController@index'); }
/** * 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'))); }
$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');
public function ejecutar_alimento(Request $request) { $rules = array('dose' => 'required', 'responsible' => 'required'); $this->validate($request, $rules); $dateA = Input::get('dateApplication'); $dateApplication = date(microtime(substr($dateA, 6, 4) . "-" . substr($dateA, 3, 2) . "-" . substr($dateA, 0, 2) . " " . substr($dateA, 10, 6)) * 10000); $boosterI = Input::get('boosterInjection'); $boosterInjection = date(microtime(substr($dateA, 6, 4) . "-" . substr($dateA, 3, 2) . "-" . substr($dateA, 0, 2) . " " . substr($dateA, 10, 6)) * 10000); $price = Food_Supplement::where('id', $request->food_supplements)->pluck('price_kg'); //$animalName=Animal::where('id',$request->animalName)->pluck('nombre'); //$food_supplement=Food_Supplement::where('id',$request->food_supplements)->pluck('nameProduct'); $dc = new DietaryControl(); $dc->idUser = Auth::id(); $dc->idAnimal = $request->animalName; $dc->idFood_Supplemet = $request->food_supplements; $dc->dateApplication = $request->dateApplication; $dc->Dosage = $request->dose; $dc->value = $request->dose * $price; $dc->responsible = $request->responsible; $dc->save(); $event = new Calendar(); $event->idUser = Auth::id(); $event->title = 'Alimentacion'; $event->body = 'Programada'; $event->url = 'http://localhost:8000/vaccinationControl'; $event->class = 'Preventivo'; $event->start = $dateApplication; $event->end = $boosterInjection; $event->save(); return redirect()->route('animal.index'); }
/** * Function that deletes a specified event from worker's calendar. * * @return Response */ public function deleteEvent() { // Validate Input. $validator = Validator::make(Input::all(), array('id' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'Informacion incompleta!']); } // 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 event and delete it. $event = Calendar::find(Input::get('id')); $event->delete(); // Return response. $response['state'] = 'Success'; $response['message'] = 'Evento eliminado exitosamente!'; return response()->json($response); }
$res = ""; foreach ($contents as $row) { foreach ($row as $key => $val) { if (is_array($val)) { foreach ($val as $val2) { $res .= $key . ":" . trim($val2) . "\r\n"; } } else { $res .= $key . ":" . trim($val) . "\r\n"; } } } return Response::make($res)->header("Content-type", "text/calendar; charset=utf-8")->header("Content-disposition", "attachment; filename=\"cal.ics\""); }); Route::get('/event/hide/{calId?}/{uid?}', function ($calId = null, $uid = null) { $calendar = Calendar::find($calId); if (is_null($calendar)) { return redirect()->back(); } $hiddenEvent = new HiddenEvent(); $hiddenEvent->calendar = $calendar->id; $hiddenEvent->uid = $uid; $hiddenEvent->save(); return redirect()->back(); }); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route