Bug where the correct amount paid and total due for a bill was not showing up properly for those viewing bills they belong to
This commit is contained in:
@@ -25,6 +25,7 @@ class BillController extends Controller
|
|||||||
]);
|
]);
|
||||||
return view('createbill', ['username' => $stuff->input('username'), 'message' => 'Bill created']);
|
return view('createbill', ['username' => $stuff->input('username'), 'message' => 'Bill created']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function manage(Request $stuff)
|
public function manage(Request $stuff)
|
||||||
{
|
{
|
||||||
$test = DB::table('bills')->where('username', $stuff->input('username'))->pluck('billname');
|
$test = DB::table('bills')->where('username', $stuff->input('username'))->pluck('billname');
|
||||||
@@ -75,21 +76,8 @@ class BillController extends Controller
|
|||||||
$amountpaids = DB::table('responsible')->where('username', $payer)->pluck('amountpaid');
|
$amountpaids = DB::table('responsible')->where('username', $payer)->pluck('amountpaid');
|
||||||
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
|
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
|
||||||
$count = $amountpaids->count();
|
$count = $amountpaids->count();
|
||||||
if ($billname !== "Rent" | $billname !== "rent")
|
if ($billname === "Rent" || $billname === "rent")
|
||||||
{
|
{
|
||||||
echo "Not equal" . "<br>";
|
|
||||||
$id = $date . $billname;
|
|
||||||
$cost = DB::table('transactions')->where('responsible', $id)->pluck('cost')->first();
|
|
||||||
$people = DB::table('transactions')->where('responsible', $id)->pluck('people')->first();
|
|
||||||
$full = ($cost * 100) / ($people * 100);
|
|
||||||
echo $id . $billname . $payer . $amountpaid . $full . $username;
|
|
||||||
DB::table('responsible')->insert(
|
|
||||||
['id' => $id, 'billname' => $billname, 'username' => $payer, 'amountpaid' => $amountpaid, 'total' => $full, 'owner' => $username]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "It's the rent bill" . "<br>";
|
|
||||||
$id = $date . $billname;
|
$id = $date . $billname;
|
||||||
$cost = DB::table('transactions')->where('responsible', $id)->pluck('cost')->first();
|
$cost = DB::table('transactions')->where('responsible', $id)->pluck('cost')->first();
|
||||||
$roomtype = DB::table('users')->where('username', $payer)->pluck('room')->first();
|
$roomtype = DB::table('users')->where('username', $payer)->pluck('room')->first();
|
||||||
@@ -104,6 +92,16 @@ class BillController extends Controller
|
|||||||
['id' => $id, 'billname' => $billname, 'username' => $payer, 'amountpaid' => $amountpaid, 'total' => '262', 'owner' => $username]);
|
['id' => $id, 'billname' => $billname, 'username' => $payer, 'amountpaid' => $amountpaid, 'total' => '262', 'owner' => $username]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$id = $date . $billname;
|
||||||
|
$cost = DB::table('transactions')->where('responsible', $id)->pluck('cost')->first();
|
||||||
|
$people = DB::table('transactions')->where('responsible', $id)->pluck('people')->first();
|
||||||
|
$full = ($cost * 100) / ($people * 100);
|
||||||
|
DB::table('responsible')->insert(
|
||||||
|
['id' => $id, 'billname' => $billname, 'username' => $payer, 'amountpaid' => $amountpaid, 'total' => $full, 'owner' => $username]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return view('manage', ['username' => $username, 'message' => $payer . " has been added to the bill"])->with('test', $test)->with('users', $users)->with('payer', '')->with('bills', '')->with('amountpaids', $amountpaids)->with('totals', '')->with('responsibleid', $responsibleid)->with('count', '');
|
return view('manage', ['username' => $username, 'message' => $payer . " has been added to the bill"])->with('test', $test)->with('users', $users)->with('payer', '')->with('bills', '')->with('amountpaids', $amountpaids)->with('totals', '')->with('responsibleid', $responsibleid)->with('count', '');
|
||||||
}
|
}
|
||||||
@@ -119,7 +117,6 @@ class BillController extends Controller
|
|||||||
$count = $amountpaids->count();
|
$count = $amountpaids->count();
|
||||||
|
|
||||||
DB::table('responsible')->where('id', $stuff->input('responsibleid'))->update(['amountpaid' => $stuff->input('amountpaid')]);
|
DB::table('responsible')->where('id', $stuff->input('responsibleid'))->update(['amountpaid' => $stuff->input('amountpaid')]);
|
||||||
echo $stuff->input('amountpaid') . "<br>";
|
|
||||||
|
|
||||||
return view('manage', ['username' => $stuff->input('username'), 'message' => ''])->with('test', $test)->with('users', $users)->with('payer', $payer)->with('bills', $bills)->with('amountpaids', $amountpaids)->with('totals', $totals)->with('responsibleid', $responsibleid)->with('count', $count);
|
return view('manage', ['username' => $stuff->input('username'), 'message' => ''])->with('test', $test)->with('users', $users)->with('payer', $payer)->with('bills', $bills)->with('amountpaids', $amountpaids)->with('totals', $totals)->with('responsibleid', $responsibleid)->with('count', $count);
|
||||||
}
|
}
|
||||||
@@ -136,23 +133,21 @@ class BillController extends Controller
|
|||||||
|
|
||||||
return view('manage', ['username' => $stuff->input('username'), 'message' => ''])->with('test', $test)->with('users', $users)->with('payer', $payer)->with('bills', $bills)->with('amountpaids', $amountpaids)->with('totals', $totals)->with('responsibleid', $responsibleid)->with('count', $count);
|
return view('manage', ['username' => $stuff->input('username'), 'message' => ''])->with('test', $test)->with('users', $users)->with('payer', $payer)->with('bills', $bills)->with('amountpaids', $amountpaids)->with('totals', $totals)->with('responsibleid', $responsibleid)->with('count', $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view(Request $stuff)
|
public function view(Request $stuff)
|
||||||
{
|
{
|
||||||
$grass = DB::table('bills')->pluck('billname');
|
$grass = DB::table('bills')->pluck('billname');
|
||||||
return view('view', ['username' => $stuff->input('username')])->with('grass', $grass)->with('billname', '')->with('owner', '')->with('amountpaid', '')->with('total', '');
|
return view('view', ['username' => $stuff->input('username')])->with('grass', $grass)->with('billname', '')->with('owner', '')->with('amountpaid', '')->with('total', '')->with('count', '');
|
||||||
}
|
}
|
||||||
public function viewbill(Request $stuff)
|
public function viewbill(Request $stuff)
|
||||||
{
|
{
|
||||||
$grass = DB::table('bills')->pluck('billname');
|
$grass = DB::table('bills')->pluck('billname');
|
||||||
$billchoice = $stuff->input('tough');
|
$billchoice = $stuff->input('tough');
|
||||||
$owner = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->pluck('owner')->first();
|
$owner = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->where('billname', $billchoice)->pluck('owner');
|
||||||
$amountpaid = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->pluck('amountpaid')->first();
|
$amountpaid = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->where('billname', $billchoice)->pluck('amountpaid');
|
||||||
$total = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->pluck('total')->first();
|
$total = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->where('billname', $billchoice)->pluck('total');
|
||||||
|
$count = DB::table('responsible')->where('username', $stuff->input('username'))->where('billname', $billchoice)->count();
|
||||||
|
|
||||||
echo "Hey " . $stuff->input('username') . " you chose: ";
|
return view('view', ['username' => $stuff->input('username')])->with('grass', $grass)->with('billname', $billchoice)->with('owner', $owner)->with('amountpaid', $amountpaid)->with('total', $total)->with('count', $count);
|
||||||
echo $stuff->input('tough');
|
|
||||||
echo "<br>";
|
|
||||||
|
|
||||||
return view('view', ['username' => $stuff->input('username')])->with('grass', $grass)->with('billname', $billchoice)->with('owner', $owner)->with('amountpaid', $amountpaid)->with('total', $total);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{!! Form::close() !!}
|
{!! Form::close() !!}
|
||||||
<div class="jumbotron text-center maincontentarea">
|
<div class="jumbotron text-center maincontentarea">
|
||||||
<h1>Alright {{ $username }}, here is where you can create bills</h1>
|
<h1>Alright {{ $username }}, here is where you can create bills</h1><br>
|
||||||
<br>
|
|
||||||
|
|
||||||
{!! Form::open(array('action' => 'BillController@createbill')) !!}
|
{!! Form::open(array('action' => 'BillController@createbill')) !!}
|
||||||
{{ Form::hidden('username', $username) }}
|
{{ Form::hidden('username', $username) }}
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>HomeIsWhereTheMoneyIs</title>
|
<title>HomeIsWhereTheMoneyIs</title>
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||||
|
|
||||||
<!-- Optional theme -->
|
<!-- Optional theme -->
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
<!-- Latest compiled and minified JavaScript -->
|
<!-- Latest compiled and minified JavaScript -->
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="http://108.255.70.130/css/scc.css">
|
<link rel="stylesheet" type="text/css" href="http://108.255.70.130/css/scc.css">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
<div class="jumbotron text-center maincontentarea">
|
<div class="jumbotron text-center maincontentarea">
|
||||||
<h1>Alright {{ $username }}, here is where you can manage the bills you own</h1>
|
<h1>Alright {{ $username }}, here is where you can manage the bills you own</h1>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
<div>
|
||||||
<div><h1 class="addbillmonthsection">
|
<h1 class="addbillmonthsection">
|
||||||
{!! Form::open(array('action' => 'BillController@managebill')) !!}
|
{!! Form::open(array('action' => 'BillController@managebill')) !!}
|
||||||
{{ Form::hidden('username', $username) }}
|
{{ Form::hidden('username', $username) }}
|
||||||
<br>
|
<br>
|
||||||
@@ -60,9 +60,7 @@
|
|||||||
{{ Form::button('add bill', array('class' => 'createbillmonthamount', 'type' => 'submit')) }}
|
{{ Form::button('add bill', array('class' => 'createbillmonthamount', 'type' => 'submit')) }}
|
||||||
<br><br>
|
<br><br>
|
||||||
<h1>{{ $message }}</h1>
|
<h1>{{ $message }}</h1>
|
||||||
</p>
|
|
||||||
{!! Form::close() !!}
|
{!! Form::close() !!}
|
||||||
</h1>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="addpeoplesection">
|
<div class="addpeoplesection">
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
<!doctype>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>HomeIsWhereTheMoneyIs</title>
|
<title>HomeIsWhereTheMoneyIs</title>
|
||||||
@@ -10,15 +10,13 @@
|
|||||||
<!-- Latest compiled and minified JavaScript -->
|
<!-- Latest compiled and minified JavaScript -->
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="http://108.255.70.130/css/scc.css">
|
<link rel="stylesheet" type="text/css" href="http://108.255.70.130/css/scc.css">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<a href="/"><h1 class="logomaxipad">Home</h1></a>
|
<a href="/"><h1 class="logomaxipad">Home</h1></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="jumbotron text-center maincontentarea">
|
<div class="jumbotron text-center maincontentarea">
|
||||||
<h1 class="sectiontitle">Registration Page</h1>
|
<h1 class="sectiontitle">Registration Page</h1><br>
|
||||||
<br>
|
|
||||||
{{ Form::open(array('action' => 'HomeController@registerUser', 'method' => 'post')) }}
|
{{ Form::open(array('action' => 'HomeController@registerUser', 'method' => 'post')) }}
|
||||||
<p>
|
<p>
|
||||||
{{ Form::label('firstnamelabel', 'first name') }}
|
{{ Form::label('firstnamelabel', 'first name') }}
|
||||||
|
|||||||
@@ -13,9 +13,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="jumbotron text-center maincontentarea">
|
<div class="jumbotron text-center maincontentarea">
|
||||||
<h1>What's good {{$username}}? it's your home page</h1>
|
<h1>Hey {{$username}}, how is it going? it's your home page</h1>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
{!! Form::open(array('action' => 'BillController@create')) !!}
|
{!! Form::open(array('action' => 'BillController@create')) !!}
|
||||||
{{ Form::hidden('username', $username) }}
|
{{ Form::hidden('username', $username) }}
|
||||||
<p>
|
<p>
|
||||||
@@ -30,7 +29,6 @@
|
|||||||
</p>
|
</p>
|
||||||
{!! Form::close() !!}
|
{!! Form::close() !!}
|
||||||
{!! Form::open(array('action' => 'BillController@view')) !!}
|
{!! Form::open(array('action' => 'BillController@view')) !!}
|
||||||
|
|
||||||
{{ Form::hidden('username', $username) }}
|
{{ Form::hidden('username', $username) }}
|
||||||
<p>
|
<p>
|
||||||
{{ Form::button('view', array('class' => 'viewsection', 'type' => 'submit')) }}
|
{{ Form::button('view', array('class' => 'viewsection', 'type' => 'submit')) }}
|
||||||
|
|||||||
@@ -45,12 +45,14 @@
|
|||||||
<th>total</th>
|
<th>total</th>
|
||||||
<th>owner</th>
|
<th>owner</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@for ($index=0; $index< $count ; $index++)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $billname }}</td>
|
<td>{{ $billname }} </td>
|
||||||
<td>{{ $amountpaid }}</td>
|
<td>{{ $amountpaid[$index] }}</td>
|
||||||
<td>{{ $total }}</td>
|
<td>{{ $total[$index] }}</td>
|
||||||
<td>{{ $owner }}</td>
|
<td>{{ $owner[$index] }} </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@endfor
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<button class="logout"><a href="/">log out</a></button>
|
<button class="logout"><a href="/">log out</a></button>
|
||||||
|
|||||||
Reference in New Issue
Block a user