functional

This commit is contained in:
monde
2017-05-29 19:03:36 +00:00
parent 26da6e6784
commit 35924e05a3
8 changed files with 266 additions and 39 deletions
+131 -15
View File
@@ -27,24 +27,140 @@ class BillController extends Controller
} }
public function manage(Request $stuff) public function manage(Request $stuff)
{ {
return view('manage', ['username' => $stuff->input('username')]); $test = DB::table('bills')->where('username', 'juice')->pluck('billname');
$users = DB::table('users')->pluck('username');
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
foreach ($test as $gus) {
echo $gus . " " . $responsibleid[0];
echo "<br>";
}
//return view('manage', ['username' => $stuff->input('username'), 'message' => ''])->with('test', $test);
return view('manage', ['username' => $stuff->input('username'), 'message' => ""])->with('test', $test)->with('users', $users)->with('payer', '')->with('bills', '')->with('amountpaids', '')->with('totals', '')->with('responsibleid', $responsibleid)->with('count', '');
}
public function managebill(Request $stuff)
{
$test = DB::table('bills')->where('username', 'juice')->pluck('billname');
$users = DB::table('users')->pluck('username');
$username = $stuff->input('username');
$billname = $stuff->input('billname');
$date = $stuff->input('date');
$total = $stuff->input('total');
$each = $stuff->input('each');
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
$emptdate = isset($date);
$empttotal = isset($total);
$empteach = isset($each);
if (!$emptdate | !$empttotal | !$empteach)
{
//return view('manage', ['username' => $username, 'message' => "Remeber to fill in all of the fields"])->with('test', $test);
return view('manage', ['username' => $username, 'message' => "Remeber to fill in all of the fields"])->with('test', $test)->with('users', $users)->with('payer', '')->with('bills', '')->with('amountpaids', '')->with('totals', '')->with('responsibleid', $responsibleid)->with('count', '');
}
else
{
$responsibleid = $date . $billname;
DB::table('transactions')->insert([
'billname' => $billname, 'date' => $date, 'cost' => $total, 'responsible' => $responsibleid, 'username' => $username, 'people' => $each
]);
//return view('manage', ['username' => $username, 'message' => "The bill has been posted for others to see"])->with('test', $test);
return view('manage', ['username' => $username, 'message' => "The bill has been posted for others to see"])->with('test', $test)->with('users', $users)->with('payer', '')->with('bills', '')->with('amountpaids', '')->with('totals', '')->with('responsibleid', $responsibleid)->with('count','');
}
}
public function addpeople(Request $stuff)
{
$test = DB::table('bills')->where('username', 'juice')->pluck('billname');
$users = DB::table('users')->pluck('username');
//$id = DB::table('transactions')->where('username', $stuff->input('username'))->pluck('id');
$date = $stuff->input('date');
$username = $stuff->input('username');
$billname = $stuff->input('billname');
$payer = $stuff->input('payer');
$amountpaid = $stuff->input('amountpaid');
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
$count = $amountpaids->count();
$num = '0';
echo ++$num;
echo "All users" . "<br>";
foreach ($users as $groov)
{
echo $groov . "<br>";
}
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);
$full = $full . "";
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();
if ($roomtype === 'Single' | $roomtype === 'single')
{
DB::table('responsible')->insert(
['id' => $id, 'billname' => $billname, 'username' => $payer, 'amountpaid' => $amountpaid, 'total' => '292', 'owner' => $username]);
}
else
{
DB::table('responsible')->insert(
['id' => $id, 'billname' => $billname, 'username' => $payer, 'amountpaid' => $amountpaid, 'total' => '262', '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', '')->with('totals', '')->with('responsibleid', $responsibleid)->with('count', $count);
}
public function calcbill(Request $stuff)
{
$test = DB::table('bills')->where('username', 'juice')->pluck('billname');
$users = DB::table('users')->pluck('username');
$payer = $stuff->input('payer');
$bills = DB::table('responsible')->where('username', $payer)->pluck('billname');
$amountpaids = DB::table('responsible')->where('username', $payer)->pluck('amountpaid');
$totals = DB::table('responsible')->where('username', $payer)->pluck('total');
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
$count = $amountpaids->count();
DB::table('responsible')->where('id', $responsibleid)->update(['amountpaid' => $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);
}
public function debt(Request $stuff)
{
$test = DB::table('bills')->where('username', 'juice')->pluck('billname');
$users = DB::table('users')->pluck('username');
$payer = $stuff->input('payer');
$bills = DB::table('responsible')->where('username', $payer)->pluck('billname');
$amountpaids = DB::table('responsible')->where('username', $payer)->pluck('amountpaid');
$totals = DB::table('responsible')->where('username', $payer)->pluck('total');
$responsibleid = DB::table('responsible')->where('owner', $stuff->input('username'))->pluck('id');
$count = $amountpaids->count();
echo $count . "<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);
} }
public function view(Request $stuff) public function view(Request $stuff)
{ {
//DB::table('users')->where('username', $username)->first(); $grass = DB::table('bills')->pluck('billname');
//$bills[] = dDB::table('bills')->where('') return view('view', ['username' => $stuff->input('username')])->with('grass', $grass);
$billrecord = DB::table('bills')->get(); }
$bills; public function viewbill(Request $stuff)
foreach ($billrecord as $bill) { {
echo $bill->billname; echo "Hey " . $stuff->input('username') . " you chose: ";
echo $stuff->input('tough');
echo "<br>"; echo "<br>";
$bills[] = $bill->billname;
} return "Yup";
foreach ($bills as $w) {
echo $w;
echo "<br>";
}
return view('view', ['username' => $stuff->input('username')])->with('billrecord', $billrecord);
//return view('view', ['username' => $stuff->input('username')])->with('bills', $bills);
} }
} }
+3 -1
View File
@@ -26,6 +26,8 @@ class HomeController extends Controller
$username = $stuff->input('username'); $username = $stuff->input('username');
$password = $stuff->input('password'); $password = $stuff->input('password');
$confirm = $stuff->input('confirm'); $confirm = $stuff->input('confirm');
$room = $stuff->input('room');
echo "room: " . $room . "<br>";
$emptfirstname = isset($firstname); $emptfirstname = isset($firstname);
$emptlastname = isset($lastname); $emptlastname = isset($lastname);
@@ -42,7 +44,7 @@ class HomeController extends Controller
return view('register', ['message' => 'Password and confirm must be the same']); return view('register', ['message' => 'Password and confirm must be the same']);
} }
DB::table('users')->insert( DB::table('users')->insert(
['firstname' => $firstname, 'lastname' => $lastname, 'username' => $username, 'password' => $password] ['firstname' => $firstname, 'lastname' => $lastname, 'username' => $username, 'password' => $password, 'room' => $room]
); );
return view('created', ['username' => $username]); return view('created', ['username' => $username]);
} }
+2
View File
@@ -26,6 +26,8 @@
{{ Form::hidden('username', $username) }} {{ Form::hidden('username', $username) }}
<p> <p>
{{ Form::label('lbl', 'bill name', array('style' => 'font-size:400%')) }} {{ Form::label('lbl', 'bill name', array('style' => 'font-size:400%')) }}
</p>
<p>
{{ Form::text('billname', '', array('style' => 'font-size:400%')) }} {{ Form::text('billname', '', array('style' => 'font-size:400%')) }}
</p> </p>
<p> <p>
+110 -4
View File
@@ -15,23 +15,129 @@
<div class="jumbotron text-center"> <div class="jumbotron text-center">
<h1>Alright {{ $username }}, here is where you can manage the bills you own bills</h1> <h1>Alright {{ $username }}, here is where you can manage the bills you own bills</h1>
{!! Form::open(array('action' => 'HomeController@home')) !!} {!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }} {{ Form::hidden('username', $username) }}
<p> <p>
{{ Form::button('user Home', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }} {{ Form::button('user Home', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }}
</p> </p>
{!! Form::close() !!} {!! Form::close() !!}
{!! Form::open(array('action' => 'BillController@createbill')) !!} {!! Form::open(array('action' => 'BillController@managebill')) !!}
{{ Form::hidden('username', $username) }} {{ Form::hidden('username', $username) }}
<select name="billname">
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
</select>
<p> <p>
{{ Form::label('lbl', 'bill name', array('style' => 'font-size:400%')) }} {{ Form::label('datelabel', "enter in yyyymm") }}
{{ Form::text('billname', '', array('style' => 'font-size:400%')) }} {{ Form::text('date') }}
</p> </p>
<p> <p>
{{ Form::label('totallabel', 'total bill amount') }}
{{ Form::text('total') }}
</p>
<p>
{{ Form::label('eachlabel', 'each bill amount') }}
{{ Form::text('each') }}
</p>
{{ Form::button('Create Bill', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }} {{ Form::button('Create Bill', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }}
</p> </p>
{!! Form::close() !!} {!! Form::close() !!}
<h1>{{ $message }}</h1>
<div>
<br><br>
<h1>Add people to the bill</h1>
{!! Form::open(array('action' => 'BillController@addpeople')) !!}
{{ Form::hidden('username', $username) }}
<p>
<select name="billname">
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
</select>
</p>
<p>
<select name="payer">
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
</select>
</p>
<p>
{{ Form::label('datelabel', 'date in yyyymm') }}
{{ Form::text('date') }}
</p>
<p>
{{ Form::label('amountpaidlabel', 'amount paid') }}
{{ Form::text('amountpaid') }}
</p>
<p>
{{ Form::button('Add person', array('style' => '', 'type' => 'submit')) }}
</p>
{!! Form::close() !!}
</div>
<div>
<br><br>
<h1>Manage a bill</h1>
{!! Form::open(array('action' => 'BillController@calcbill')) !!}
{{ Form::hidden('username', $username) }}
<p>
<select name="billname">
@foreach ($test as $bax)
<option value={{ $bax }}>{{ $bax }}</option>
@endforeach
</select>
</p>
<p>
<select name="payer">
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
</select>
</p>
<p>
<select name="responsibleid">
@foreach ($responsibleid as $dax)
<option value={{ $dax }}>{{ $dax }}</option>
@endforeach
</select>
</p>
<p>
{{ Form::label('amountpaidlabel', 'amount paid') }}
{{ Form::text('amountpaid') }}
</p>
<p>
{{ Form::button('Add person', array('style' => '', 'type' => 'submit')) }}
</p>
{!! Form::close() !!}
</div>
<div>
<br><br>
<h1>Who owes you cash</h1>
{!! Form::open(array('action' => 'BillController@debt')) !!}
{{ Form::hidden('username', $username) }}
<p>
<select name="payer">
@foreach ($users as $cax)
<option value={{ $cax }}>{{ $cax }}</option>
@endforeach
</select>
</p>
<p>
{{ Form::button('check', array('style' => '', 'type' => 'submit')) }}
</p>
{!! Form::close() !!}
{{ $empt = isset($payer[0]) }}
@if (!$empt)
nothing
@endif
@if ($empt)
@for ($i = 0; $i < $count; ++$i)
{{ $payer }} {{ $bills[$i] }} {{ $amountpaids[$i] }} {{ $totals[$i] }} <br>
@endfor
@endif
</div>
</div> </div>
</body> </body>
</html> </html>
+4
View File
@@ -40,6 +40,10 @@
{{ Form::label('confirm') }} {{ Form::label('confirm') }}
{{ Form::password('confirm') }} {{ Form::password('confirm') }}
</p> </p>
<p>
{{ Form::label('roomlabel') }}
{{ Form::select('room', array('single' => 'single', 'double' => 'double')) }}
</p>
<p> <p>
{{ Form::submit('register me') }} {{ Form::submit('register me') }}
</p> </p>
-2
View File
@@ -25,7 +25,6 @@ height: 30%;
<br> <br>
{!! Form::open(array('action' => 'BillController@create')) !!} {!! Form::open(array('action' => 'BillController@create')) !!}
{{ Form::hidden('username', $username) }} {{ Form::hidden('username', $username) }}
<p> <p>
{{ Form::button('create', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }} {{ Form::button('create', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }}
@@ -33,7 +32,6 @@ height: 30%;
{!! Form::close() !!} {!! Form::close() !!}
{!! Form::open(array('action' => 'BillController@manage')) !!} {!! Form::open(array('action' => 'BillController@manage')) !!}
{{ Form::hidden('username', $username) }} {{ Form::hidden('username', $username) }}
<p> <p>
{{ Form::button('mange', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }} {{ Form::button('mange', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }}
+5 -11
View File
@@ -15,25 +15,19 @@
<div class="jumbotron text-center"> <div class="jumbotron text-center">
<h1>Alright {{ $username }}, here is where you can view bills that you need to pay...</h1> <h1>Alright {{ $username }}, here is where you can view bills that you need to pay...</h1>
{!! Form::open(array('action' => 'HomeController@home')) !!} {!! Form::open(array('action' => 'HomeController@home')) !!}
{{ Form::hidden('username', $username) }} {{ Form::hidden('username', $username) }}
<p> <p>
{{ Form::button('user Home', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }} {{ Form::button('user Home', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }}
</p> </p>
{!! Form::close() !!} {!! Form::close() !!}
{!! Form::open(array('action' => 'BillController@createbill')) !!} {!! Form::open(array('action' => 'BillController@viewbill')) !!}
{{ Form::hidden('username', $username) }} {{ Form::hidden('username', $username) }}
<p> <select name='tough'>
</p> @foreach ($grass as $record)
<ul> <option value={{ $record }}>{{ $record }}</option>
@foreach ($billrecord as $bill)
<li>{{{ $bill->billname }}}<li>
@endforeach @endforeach
</ul> </select>
<p>
{{ Form::text('billname', '', array('style' => 'height:40%;width:70%')) }}
</p>
<p> <p>
{{ Form::button('Create Bill', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }} {{ Form::button('Create Bill', array('style' => 'height:40%;width:70%', 'type' => 'submit')) }}
</p> </p>
+5
View File
@@ -19,7 +19,12 @@ Route::post('userhome/maxipad', 'HomeController@home');
Route::post('userhome/maxipad/create', 'BillController@create'); Route::post('userhome/maxipad/create', 'BillController@create');
Route::post('userhome/maxipad/create/done', 'BillController@createbill'); Route::post('userhome/maxipad/create/done', 'BillController@createbill');
Route::post('userhome/maxiad/manage', 'BillController@manage'); Route::post('userhome/maxiad/manage', 'BillController@manage');
Route::post('userhome/maxipad/managebill', 'BillController@managebill');
Route::post('userhome/maxipad/managebilluser', 'BillController@addpeople');
Route::post('userhome/maxipad/yup/managebilluser', 'BillController@calcbill');
Route::post('userhome/maxipad/gasmaskgrasp/manage', 'BillController@debt');
Route::post('userhome/maxipad/view', 'BillController@view'); Route::post('userhome/maxipad/view', 'BillController@view');
Route::post('userhome/maxi[ad/viewbill', 'BillController@viewbill');
Route::get('laravel', function () { Route::get('laravel', function () {
return view('welcome'); return view('welcome');
}); });