<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;

class invitations_SINGLE_Controller extends Controller
{
    public $selfName = 'invitations_SINGLE_Controller';
    public $dashboardName = 'dashboard';

	// GET /invitations/view/{uid}/ACTION_deactivate
	public function ACTION_deactivate(Request $request, $uid) {
		$record = DB::table('invitation')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('invitation')->where('id', $uid)->first();
			if($record) return redirect('/invitations/view/' . $record->uid . '/ACTION_deactivate');
		}
		return response()->view('admin/invitations_SINGLE/ACTION_deactivate', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /invitations/view/{uid}/ACTION_reactivate
	public function ACTION_reactivate(Request $request, $uid) {
		$record = DB::table('invitation')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('invitation')->where('id', $uid)->first();
			if($record) return redirect('/invitations/view/' . $record->uid . '/ACTION_reactivate');
		}
		return response()->view('admin/invitations_SINGLE/ACTION_reactivate', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /invitations/view/{uid}/ACTION_sendEmail
	public function ACTION_sendEmail(Request $request, $uid) {
		$record = DB::table('invitation')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('invitation')->where('id', $uid)->first();
			if($record) return redirect('/invitations/view/' . $record->uid . '/ACTION_sendEmail');
		}
		return response()->view('admin/invitations_SINGLE/ACTION_sendEmail', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /invitations/view/{uid}/ACTION_sendSms
	public function ACTION_sendSms(Request $request, $uid) {
		$record = DB::table('invitation')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('invitation')->where('id', $uid)->first();
			if($record) return redirect('/invitations/view/' . $record->uid . '/ACTION_sendSms');
		}
		return response()->view('admin/invitations_SINGLE/ACTION_sendSms', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /invitations/view/{uid}/ACTION_putMedicareInfoAsGuest
	public function ACTION_putMedicareInfoAsGuest(Request $request, $uid) {
		$record = DB::table('invitation')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('invitation')->where('id', $uid)->first();
			if($record) return redirect('/invitations/view/' . $record->uid . '/ACTION_putMedicareInfoAsGuest');
		}
		return response()->view('admin/invitations_SINGLE/ACTION_putMedicareInfoAsGuest', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /invitations/view/{uid}/ACTION_updateBasic
	public function ACTION_updateBasic(Request $request, $uid) {
		$record = DB::table('invitation')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('invitation')->where('id', $uid)->first();
			if($record) return redirect('/invitations/view/' . $record->uid . '/ACTION_updateBasic');
		}
		return response()->view('admin/invitations_SINGLE/ACTION_updateBasic', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /invitations/view/{uid}/SUB_dashboard
	public function SUB_dashboard(Request $request, $uid) {
		$record = DB::table('invitation')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('invitation')->where('id', $uid)->first();
			if($record) return redirect('/invitations/view/' . $record->uid . '/SUB_dashboard');
		}
		return response()->view('admin/invitations_SINGLE/SUB_dashboard', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}
}
