<?php

namespace App\Http\Controllers;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	// GET /bills/view/{uid}/SUB_transactions
	public function SUB_transactions(Request $request, $uid) {
		$record = DB::table('bill')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('bill')->where('id', $uid)->first();
			if($record) return redirect('/bills/view/' . $record->uid . '/SUB_transactions');
		}
		$subRecords = DB::table('pro_transaction')->where('bill_id', $record->id)->get();
		return response()->view('pro/bills_SINGLE/SUB_transactions', compact('record', 'subRecords'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

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