コード例 #1
0
 public function save($data1, $data2)
 {
     $calendar = new Calendar();
     $calendar->nbmatches = $data1;
     $calendar->team = $data2;
     $calendar->save();
 }
コード例 #2
0
 /**
  * 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');
 }
コード例 #3
0
 /**
  * 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);
     }
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\CreateShift $request)
 {
     $user = \Auth::user();
     $input = Request::all();
     // return $check = DB::table('timeOffs')->get();
     $check = DB::table('timeOffs')->where('groupid', $user['id'])->where('name', $input['name'])->where('status', 'Approved')->where('date', $input['date'])->get();
     if ($check) {
         $user = \Auth::user();
         //return a list of all employees in the user's group
         $employees = DB::table('users')->where('groupid', $user['id'])->orwhere('id', $user['id'])->orderBy('name')->get();
         $shifts = DB::table('calendars')->where('groupid', $user['id'])->orwhere('groupid', $user['groupid'])->get();
         return view('home')->with('user', $user)->with('employees', $employees)->with('shifts', $shifts)->with('dayOffError', "You have approved that employee to have that day off!");
     }
     $payableHours = strtotime($input['endShift']) - strtotime($input['startShift']);
     $overtimeHours = 0;
     //check for unpaid breaks
     if ($payableHours >= 18000) {
         $payableHours = $payableHours - 1800;
     }
     //check for overtime hours and format accordingly
     if ($payableHours > 28800) {
         $overtimeHours = $payableHours - 28800;
         $overtimeHours = $overtimeHours / 3600;
         $payableHours = 28800;
     }
     // $payableHours = date('h:i',$payableHours);
     $payableHours = $payableHours / 3600;
     $calendar = new Calendar();
     $calendar->name = $input['name'];
     $calendar->groupid = $user->id;
     $calendar->startShift = new Carbon($input['date'] . " " . $input['startShift']);
     $calendar->endShift = new Carbon($input['date'] . " " . $input['endShift']);
     $calendar->shiftDate = $input['date'];
     $calendar->payableHours = $payableHours;
     $calendar->overtimeHours = $overtimeHours;
     $calendar->save();
     return redirect('home');
 }
コード例 #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $id_users = Auth::id();
     $start = Input::get('from');
     $startf = date(microtime(substr($start, 6, 4) . "-" . substr($start, 3, 2) . "-" . substr($start, 0, 2) . " " . substr($start, 10, 6)) * 10000);
     $end = Input::get('to');
     $endf = date(microtime(substr($end, 6, 4) . "-" . substr($end, 3, 2) . "-" . substr($end, 0, 2) . " " . substr($end, 10, 6)) * 10000);
     //dd($endf);
     $event = new Calendar();
     $event->idUser = $id_users;
     $event->title = Input::get('title');
     $event->body = Input::get('event');
     $event->url = Input::get('url');
     $event->class = Input::get('class');
     $event->start = $startf;
     $event->end = $endf;
     //dd($event);
     $event->save();
     return redirect()->route('calendar.index');
     /*$this->form_validation->set_rules('from', 'Desde', 'trim|required|xss_clean');
             $this->form_validation->set_rules('to', 'Hasta', 'trim|required|xss_clean');
     		$this->form_validation->set_rules('url', 'Url', 'trim|required|xss_clean');
             $this->form_validation->set_rules('title', 'Título', 'trim|required|xss_clean');
             $this->form_validation->set_rules('event', 'Evento', 'trim|required|xss_clean');
             $this->form_validation->set_rules('class', 'Tipo de evento', 'trim|required|xss_clean');
             $this->form_validation->set_message('required', 'El  %s es requerido');
             if($this->form_validation->run() == FALSE)
             {
                 $this->index();
             }
             else
             {
             	$this->load->model("events_model");
             	$this->events_model->add();
             	redirect("calendar");
             }*/
 }
コード例 #6
0
 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');
 }
コード例 #7
0
ファイル: routes.php プロジェクト: jonasdahl/calendar
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
Route::post('/', function () {
    if (!Request::has('url')) {
        return redirect()->back();
    }
    $calendar = new Calendar();
    $calendar->url = Request::input('url');
    $calendar->save();
    return redirect('config/' . $calendar->id);
});
Route::get('/config/{id}', function ($id = null) {
    $calendar = Calendar::find($id);
    if (is_null($calendar)) {
        return redirect()->back();
    }
    $contents = $calendar->fetchArray();
    return view('config')->with('rows', $contents)->with('calendar', $calendar);
});
Route::get('/render/{id}', function ($id = null) {
    $calendar = Calendar::find($id);
    if (is_null($calendar)) {
        return redirect()->back();
    }
コード例 #8
0
 /**
  * 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')));
 }
コード例 #9
0
 /**
  *  Born calendar empty , to get data without error.
  * @param  [type] $employee_id [description]
  * @param  [type] $month       [description]
  * @param  [type] $year        [description]
  * @return [type]              [description]
  */
 public function bornCalendarEmpty($employee_id, $month, $year)
 {
     $calendar = new Calendar();
     $calendar->employee_id = $employee_id;
     $calendar->month = $month;
     $calendar->year = $year;
     $calendar->save();
     return $calendar;
 }