From e0bdc6863ddb4de0f5cc1e75236f2990c5bc4522 Mon Sep 17 00:00:00 2001 From: amazing-username Date: Sun, 30 Jul 2017 13:54:08 -0500 Subject: [PATCH] Bug where the correct amount paid and total due for a bill was not showing up properly for those viewing bills they belong to --- app/Http/Controllers/BillController.php | 43 ++++---- resources/views/createbill.blade.php | 20 ++-- resources/views/home.blade.php | 3 +- resources/views/login.blade.php | 1 - resources/views/manage.blade.php | 124 ++++++++++++------------ resources/views/register.blade.php | 80 ++++++++------- resources/views/userhome.blade.php | 10 +- resources/views/view.blade.php | 28 +++--- 8 files changed, 148 insertions(+), 161 deletions(-) diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 659a334..28d1826 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -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" . "
"; - $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" . "
"; $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') . "
"; 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 "
"; - - 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); } } diff --git a/resources/views/createbill.blade.php b/resources/views/createbill.blade.php index 94e24e8..34cda4a 100644 --- a/resources/views/createbill.blade.php +++ b/resources/views/createbill.blade.php @@ -13,18 +13,16 @@ - {!! Form::open(array('action' => 'HomeController@home')) !!} - {{ Form::hidden('username', $username) }} -

+ {!! Form::open(array('action' => 'HomeController@home')) !!} + {{ Form::hidden('username', $username) }} +

- {{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }} + {{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
-

- {!! Form::close() !!} -
-

Alright {{ $username }}, here is where you can create bills

-
- +

+ {!! Form::close() !!} +
+

Alright {{ $username }}, here is where you can create bills


{!! Form::open(array('action' => 'BillController@createbill')) !!} {{ Form::hidden('username', $username) }}

@@ -34,7 +32,7 @@ {{ Form::text('billname', '') }}

- {{ Form::button('Create Bill', array('class' => 'createbill', 'type' => 'submit')) }} + {{ Form::button('Create Bill', array('class' => 'createbill', 'type' => 'submit')) }}

{!! Form::close() !!}

{{$message}}

diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 17fb2ea..001d0d2 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -1,9 +1,8 @@ - + HomeIsWhereTheMoneyIs - diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php index 1d9d2bc..24f500f 100644 --- a/resources/views/login.blade.php +++ b/resources/views/login.blade.php @@ -10,7 +10,6 @@ -
diff --git a/resources/views/manage.blade.php b/resources/views/manage.blade.php index a1bfa83..db76377 100644 --- a/resources/views/manage.blade.php +++ b/resources/views/manage.blade.php @@ -13,56 +13,54 @@ - {!! Form::open(array('action' => 'HomeController@home')) !!} - {{ Form::hidden('username', $username) }} -

+ {!! Form::open(array('action' => 'HomeController@home')) !!} + {{ Form::hidden('username', $username) }} +

- {{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }} + {{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
-

- {!! Form::close() !!} +

+ {!! Form::close() !!}

Alright {{ $username }}, here is where you can manage the bills you own



- -

- {!! Form::open(array('action' => 'BillController@managebill')) !!} - {{ Form::hidden('username', $username) }} -
-

- {{ Form::label('billnamelabel', 'billname', array('style' => 'font-size:500%'))}} -

-

- -

-

- {{ Form::label('datelabel', "enter date in yyyymm") }} -

-

- {{ Form::text('date', '') }} -

-

- {{ Form::label('totallabel', 'total bill amount') }} -

-

- {{ Form::text('total', '') }} -

-

- {{ Form::label('eachlabel', 'how many people') }} -

-

- {{ Form::text('each', '') }} -

- {{ Form::button('add bill', array('class' => 'createbillmonthamount', 'type' => 'submit')) }} -

-

{{ $message }}

-

- {!! Form::close() !!} - +
+

+ {!! Form::open(array('action' => 'BillController@managebill')) !!} + {{ Form::hidden('username', $username) }} +
+

+ {{ Form::label('billnamelabel', 'billname', array('style' => 'font-size:500%'))}} +

+

+ +

+

+ {{ Form::label('datelabel', "enter date in yyyymm") }} +

+

+ {{ Form::text('date', '') }} +

+

+ {{ Form::label('totallabel', 'total bill amount') }} +

+

+ {{ Form::text('total', '') }} +

+

+ {{ Form::label('eachlabel', 'how many people') }} +

+

+ {{ Form::text('each', '') }} +

+ {{ Form::button('add bill', array('class' => 'createbillmonthamount', 'type' => 'submit')) }} +

+

{{ $message }}

+ {!! Form::close() !!}


@@ -74,9 +72,9 @@

@@ -84,9 +82,9 @@

@@ -117,9 +115,9 @@

@@ -127,9 +125,9 @@

@@ -137,9 +135,9 @@

@@ -164,9 +162,9 @@

diff --git a/resources/views/register.blade.php b/resources/views/register.blade.php index b363c8b..bfa30d9 100644 --- a/resources/views/register.blade.php +++ b/resources/views/register.blade.php @@ -1,4 +1,4 @@ - + HomeIsWhereTheMoneyIs @@ -10,53 +10,51 @@ -

-

Registration Page

-
+

Registration Page


{{ Form::open(array('action' => 'HomeController@registerUser', 'method' => 'post')) }} -

- {{ Form::label('firstnamelabel', 'first name') }} -
- {{ Form::text('firstname', '') }} -

-

- {{ Form::label('lastnamelabel', 'last name') }} -
- {{ Form::text('lastname', '') }} -

-

- {{ Form::label('usernamelabel', 'username') }} -
- {{ Form::text('username', '') }} -

-

- {{ Form::label('passwordlabel', 'password') }} -
- {{ Form::password('password') }} -

-

- {{ Form::label('confirmlabel', 'confirm') }} -
- {{ Form::password('confirm') }} -

-

- {{ Form::label('roomlabel', 'room') }} -
- -

-

-
- {{ Form::submit('register me', array('class' => 'registeraccount')) }} -

+

+ {{ Form::label('firstnamelabel', 'first name') }} +
+ {{ Form::text('firstname', '') }} +

+

+ {{ Form::label('lastnamelabel', 'last name') }} +
+ {{ Form::text('lastname', '') }} +

+

+ {{ Form::label('usernamelabel', 'username') }} +
+ {{ Form::text('username', '') }} +

+

+ {{ Form::label('passwordlabel', 'password') }} +
+ {{ Form::password('password') }} +

+

+ {{ Form::label('confirmlabel', 'confirm') }} +
+ {{ Form::password('confirm') }} +

+

+ {{ Form::label('roomlabel', 'room') }} +
+ +

+

+
+ {{ Form::submit('register me', array('class' => 'registeraccount')) }} +

{{ Form::close() }}

{{ $message }}

diff --git a/resources/views/userhome.blade.php b/resources/views/userhome.blade.php index 0cf3363..7318d01 100644 --- a/resources/views/userhome.blade.php +++ b/resources/views/userhome.blade.php @@ -13,27 +13,25 @@
-

What's good {{$username}}? it's your home page

+

Hey {{$username}}, how is it going? it's your home page



- {!! Form::open(array('action' => 'BillController@create')) !!} {{ Form::hidden('username', $username) }}

- {{ Form::button('create', array('class' => 'createsection', 'type' => 'submit')) }} + {{ Form::button('create', array('class' => 'createsection', 'type' => 'submit')) }}

{!! Form::close() !!} {!! Form::open(array('action' => 'BillController@manage')) !!} {{ Form::hidden('username', $username) }}

- {{ Form::button('mange', array('class' => 'managesection', 'type' => 'submit')) }} + {{ Form::button('mange', array('class' => 'managesection', 'type' => 'submit')) }}

{!! Form::close() !!} {!! Form::open(array('action' => 'BillController@view')) !!} - {{ Form::hidden('username', $username) }}

- {{ Form::button('view', array('class' => 'viewsection', 'type' => 'submit')) }} + {{ Form::button('view', array('class' => 'viewsection', 'type' => 'submit')) }}

{!! Form::close() !!} diff --git a/resources/views/view.blade.php b/resources/views/view.blade.php index 9773feb..f112595 100644 --- a/resources/views/view.blade.php +++ b/resources/views/view.blade.php @@ -13,14 +13,14 @@ - {!! Form::open(array('action' => 'HomeController@home')) !!} - {{ Form::hidden('username', $username) }} -

+ {!! Form::open(array('action' => 'HomeController@home')) !!} + {{ Form::hidden('username', $username) }} +

- {{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }} + {{ Form::button('user home', array('class' => 'userhome', 'type' => 'submit')) }}
-

- {!! Form::close() !!} +

+ {!! Form::close() !!}

Alright {{ $username }}, here is where you can view bills that you need to pay...

@@ -28,9 +28,9 @@ {{ Form::hidden('username', $username) }}

@@ -45,12 +45,14 @@ total owner + @for ($index=0; $index< $count ; $index++) - {{ $billname }} - {{ $amountpaid }} - {{ $total }} - {{ $owner }} + {{ $billname }} + {{ $amountpaid[$index] }} + {{ $total[$index] }} + {{ $owner[$index] }} + @endfor