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:
amazing-username
2017-07-30 13:54:08 -05:00
parent 3e994db966
commit e0bdc6863d
8 changed files with 148 additions and 161 deletions
+19 -24
View File
@@ -25,6 +25,7 @@ class BillController extends Controller
]);
return view('createbill', ['username' => $stuff->input('username'), 'message' => 'Bill created']);
}
public function manage(Request $stuff)
{
$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');
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
$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;
$cost = DB::table('transactions')->where('responsible', $id)->pluck('cost')->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]);
}
}
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', '');
}
@@ -119,7 +117,6 @@ class BillController extends Controller
$count = $amountpaids->count();
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);
}
@@ -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);
}
public function view(Request $stuff)
{
$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)
{
$grass = DB::table('bills')->pluck('billname');
$billchoice = $stuff->input('tough');
$owner = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->pluck('owner')->first();
$amountpaid = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->pluck('amountpaid')->first();
$total = DB::table('responsible')->orderBy('id', 'desc')->where('username', $stuff->input('username'))->pluck('total')->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'))->where('billname', $billchoice)->pluck('amountpaid');
$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: ";
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);
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);
}
}
+9 -11
View File
@@ -13,18 +13,16 @@
</head>
<body>
{!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }}
<p>
{!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }}
<p>
<div>
{{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
{{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
</div>
</p>
{!! Form::close() !!}
<div class="jumbotron text-center maincontentarea">
<h1>Alright {{ $username }}, here is where you can create bills</h1>
<br>
</p>
{!! Form::close() !!}
<div class="jumbotron text-center maincontentarea">
<h1>Alright {{ $username }}, here is where you can create bills</h1><br>
{!! Form::open(array('action' => 'BillController@createbill')) !!}
{{ Form::hidden('username', $username) }}
<p>
@@ -34,7 +32,7 @@
{{ Form::text('billname', '') }}
</p>
<p>
{{ Form::button('Create Bill', array('class' => 'createbill', 'type' => 'submit')) }}
{{ Form::button('Create Bill', array('class' => 'createbill', 'type' => 'submit')) }}
</p>
{!! Form::close() !!}
<h1>{{$message}}</h1>
+1 -2
View File
@@ -1,9 +1,8 @@
<!doctype html>
<html>
<head>
<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">
<!-- 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">
-1
View File
@@ -10,7 +10,6 @@
<!-- 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>
<link rel="stylesheet" type="text/css" href="http://108.255.70.130/css/scc.css">
</head>
<body>
<div>
+61 -63
View File
@@ -13,56 +13,54 @@
</head>
<body>
{!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }}
<p>
{!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }}
<p>
<div>
{{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
{{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
</div>
</p>
{!! Form::close() !!}
</p>
{!! Form::close() !!}
<div class="jumbotron text-center maincontentarea">
<h1>Alright {{ $username }}, here is where you can manage the bills you own</h1>
<br><br>
<div><h1 class="addbillmonthsection">
{!! Form::open(array('action' => 'BillController@managebill')) !!}
{{ Form::hidden('username', $username) }}
<br>
<p>
{{ Form::label('billnamelabel', 'billname', array('style' => 'font-size:500%'))}}
</p>
<p>
<select name="billname">
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
</select>
</p>
<p>
{{ Form::label('datelabel', "enter date in yyyymm") }}
</p>
<p>
{{ Form::text('date', '') }}
</p>
<p>
{{ Form::label('totallabel', 'total bill amount') }}
</p>
<p>
{{ Form::text('total', '') }}
</p>
<p>
{{ Form::label('eachlabel', 'how many people') }}
</p>
<p>
{{ Form::text('each', '') }}
</p>
{{ Form::button('add bill', array('class' => 'createbillmonthamount', 'type' => 'submit')) }}
<br><br>
<h1>{{ $message }}</h1>
</p>
{!! Form::close() !!}
</h1>
<div>
<h1 class="addbillmonthsection">
{!! Form::open(array('action' => 'BillController@managebill')) !!}
{{ Form::hidden('username', $username) }}
<br>
<p>
{{ Form::label('billnamelabel', 'billname', array('style' => 'font-size:500%'))}}
</p>
<p>
<select name="billname">
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
</select>
</p>
<p>
{{ Form::label('datelabel', "enter date in yyyymm") }}
</p>
<p>
{{ Form::text('date', '') }}
</p>
<p>
{{ Form::label('totallabel', 'total bill amount') }}
</p>
<p>
{{ Form::text('total', '') }}
</p>
<p>
{{ Form::label('eachlabel', 'how many people') }}
</p>
<p>
{{ Form::text('each', '') }}
</p>
{{ Form::button('add bill', array('class' => 'createbillmonthamount', 'type' => 'submit')) }}
<br><br>
<h1>{{ $message }}</h1>
{!! Form::close() !!}
</div>
<div class="addpeoplesection">
<br><br>
@@ -74,9 +72,9 @@
</p>
<p>
<select name="billname">
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
</select>
</p>
<p>
@@ -84,9 +82,9 @@
</p>
<p>
<select name="payer">
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
</select>
</p>
<p>
@@ -117,9 +115,9 @@
</p>
<p>
<select name="billname">
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
</select>
</p>
<p>
@@ -127,9 +125,9 @@
</p>
<p>
<select name="payer">
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
</select>
</p>
<p>
@@ -137,9 +135,9 @@
</p>
<p>
<select name="responsibleid">
@foreach ($responsibleid as $dax)
<option value={{ $dax }}>{{ $dax }}</option>
@endforeach
@foreach ($responsibleid as $dax)
<option value={{ $dax }}>{{ $dax }}</option>
@endforeach
</select>
</p>
<p>
@@ -164,9 +162,9 @@
</p>
<p>
<select name="payer">
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
</select>
</p>
<p>
+39 -41
View File
@@ -1,4 +1,4 @@
<!doctype>
<html>
<head>
<title>HomeIsWhereTheMoneyIs</title>
@@ -10,53 +10,51 @@
<!-- 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>
<link rel="stylesheet" type="text/css" href="http://108.255.70.130/css/scc.css">
</head>
<body>
<div>
<a href="/"><h1 class="logomaxipad">Home</h1></a>
</div>
<div class="jumbotron text-center maincontentarea">
<h1 class="sectiontitle">Registration Page</h1>
<br>
<h1 class="sectiontitle">Registration Page</h1><br>
{{ Form::open(array('action' => 'HomeController@registerUser', 'method' => 'post')) }}
<p>
{{ Form::label('firstnamelabel', 'first name') }}
<br>
{{ Form::text('firstname', '') }}
</p>
<p>
{{ Form::label('lastnamelabel', 'last name') }}
<br>
{{ Form::text('lastname', '') }}
</p>
<p>
{{ Form::label('usernamelabel', 'username') }}
<br>
{{ Form::text('username', '') }}
</p>
<p>
{{ Form::label('passwordlabel', 'password') }}
<br>
{{ Form::password('password') }}
</p>
<p>
{{ Form::label('confirmlabel', 'confirm') }}
<br>
{{ Form::password('confirm') }}
</p>
<p>
{{ Form::label('roomlabel', 'room') }}
<br>
<select name="room" class="registeraccounttype">
<option>single</option>
<option>double</option>
</select>
</p>
<p>
<br>
{{ Form::submit('register me', array('class' => 'registeraccount')) }}
</p>
<p>
{{ Form::label('firstnamelabel', 'first name') }}
<br>
{{ Form::text('firstname', '') }}
</p>
<p>
{{ Form::label('lastnamelabel', 'last name') }}
<br>
{{ Form::text('lastname', '') }}
</p>
<p>
{{ Form::label('usernamelabel', 'username') }}
<br>
{{ Form::text('username', '') }}
</p>
<p>
{{ Form::label('passwordlabel', 'password') }}
<br>
{{ Form::password('password') }}
</p>
<p>
{{ Form::label('confirmlabel', 'confirm') }}
<br>
{{ Form::password('confirm') }}
</p>
<p>
{{ Form::label('roomlabel', 'room') }}
<br>
<select name="room" class="registeraccounttype">
<option>single</option>
<option>double</option>
</select>
</p>
<p>
<br>
{{ Form::submit('register me', array('class' => 'registeraccount')) }}
</p>
{{ Form::close() }}
<h1>{{ $message }}</h1>
</div>
+4 -6
View File
@@ -13,27 +13,25 @@
</head>
<body>
<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>
{!! Form::open(array('action' => 'BillController@create')) !!}
{{ Form::hidden('username', $username) }}
<p>
{{ Form::button('create', array('class' => 'createsection', 'type' => 'submit')) }}
{{ Form::button('create', array('class' => 'createsection', 'type' => 'submit')) }}
</p>
{!! Form::close() !!}
{!! Form::open(array('action' => 'BillController@manage')) !!}
{{ Form::hidden('username', $username) }}
<p>
{{ Form::button('mange', array('class' => 'managesection', 'type' => 'submit')) }}
{{ Form::button('mange', array('class' => 'managesection', 'type' => 'submit')) }}
</p>
{!! Form::close() !!}
{!! Form::open(array('action' => 'BillController@view')) !!}
{{ Form::hidden('username', $username) }}
<p>
{{ Form::button('view', array('class' => 'viewsection', 'type' => 'submit')) }}
{{ Form::button('view', array('class' => 'viewsection', 'type' => 'submit')) }}
</p>
{!! Form::close() !!}
<button class="logout"><a href="/">log out</a></button>
+15 -13
View File
@@ -13,14 +13,14 @@
</head>
<body>
{!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }}
<p>
{!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }}
<p>
<div>
{{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
{{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
</div>
</p>
{!! Form::close() !!}
</p>
{!! Form::close() !!}
<div class="jumbotron text-center maincontentarea">
<h1>Alright {{ $username }}, here is where you can view bills that you need to pay...</h1>
@@ -28,9 +28,9 @@
{{ Form::hidden('username', $username) }}
<p>
<select name='tough'>
@foreach ($grass as $record)
<option value={{ $record }}>{{ $record }}</option>
@endforeach
@foreach ($grass as $record)
<option value={{ $record }}>{{ $record }}</option>
@endforeach
</select>
</p>
<p>
@@ -45,12 +45,14 @@
<th>total</th>
<th>owner</th>
</tr>
@for ($index=0; $index< $count ; $index++)
<tr>
<td>{{ $billname }}</td>
<td>{{ $amountpaid }}</td>
<td>{{ $total }}</td>
<td>{{ $owner }}</td>
<td>{{ $billname }} </td>
<td>{{ $amountpaid[$index] }}</td>
<td>{{ $total[$index] }}</td>
<td>{{ $owner[$index] }} </td>
</tr>
@endfor
</table>
</div>
<button class="logout"><a href="/">log out</a></button>