Merge branch 'convert-models' of tfmm/Silent-Auction into master

This commit is contained in:
tfmm 2019-02-13 16:03:11 -05:00 committed by Gogs
commit bd9b7f7956
33 changed files with 763 additions and 407 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace App\Helpers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Bidders;
class BidderSelectList
{
public static function bidderShowNumbers()
{
$bidder_num_results = Bidders::orderBy('bidder_assigned_number')
->get();
$bidder_num = '<option disabled selected hidden value="">choose...</option>';
foreach ($bidder_num_results as $bidder_num_result) {
$bidder_num .= '<option value="' .
$bidder_num_result->idbidders .
'">' .
$bidder_num_result->bidder_assigned_number .
' - ' .
$bidder_num_result->bidder_fname .
' ' .
$bidder_num_result->bidder_lname .
'</option>';
}
return $bidder_num;
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Helpers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Checkout;
class CheckoutBidderSelectList
{
public static function checkoutBidderShowNumbers()
{
$checkout_bidder_num_results = Checkout::join('bidders', 'checkout.bidder_num', '=', 'bidders.idbidders')
->orderBy('bidders.bidder_assigned_number', 'asc')
->get();
$checkout_bidder_num = '<option disabled selected hidden value="">choose...</option>';
foreach ($checkout_bidder_num_results as $checkout_bidder_num_result) {
$checkout_bidder_num .= '<option value="' .
$checkout_bidder_num_result->bidders->idbidders .
'">' .
$checkout_bidder_num_result->bidders->bidder_assigned_number .
' - ' .
$checkout_bidder_num_result->bidders->bidder_fname .
' ' .
$checkout_bidder_num_result->bidders->bidder_lname .
'</option>';
}
return $checkout_bidder_num;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Helpers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Items;
class ItemSelectList
{
public static function itemShowNumbers()
{
$item_num_results = Items::orderBy('item_assigned_num')
->get();
$item_nums = '<option disabled="disabled" selected="selected" value="0">choose...</option>';
foreach ($item_num_results as $item_num_result) {
$item_nums .= '<option value="' .
$item_num_result->iditems .
'">' .
$item_num_result->item_assigned_num .
'</option>';
}
return $item_nums;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Helpers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Bidders;
use App\Models\Items;
use App\Models\Checkout;
use App\Models\PaymentMethods;
use App\Models\WinningBids;
class PaymentMethodSelectList
{
public static function paymentShowMethods()
{
$payment_method_results = PaymentMethods::orderBy('pm_name')
->get();
$payment_methods = '<option disabled="disabled" selected="selected" value="0">choose...</option>';
foreach ($payment_method_results as $payment_method_result) {
$payment_methods .= '<option value="' .
$payment_method_result->pm_id .
'">' .
$payment_method_result->pm_name .
'</option>';
}
return $payment_methods;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Helpers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Bidders;
use App\Models\Items;
use App\Models\Checkout;
use App\Models\PaymentMethods;
use App\Models\WinningBids;
class WinningBidSelectList
{
public static function winningBidShowNumbers()
{
$winning_bid_num_results = WinningBids::join('items', 'winning_bids.winning_item_num', '=', 'items.iditems')
->orderBy('items.item_assigned_num')
->get();
$winning_bid_num = '<option disabled selected hidden value="">choose...</option>';
foreach ($winning_bid_num_results as $winning_bid_num_result) {
$winning_bid_num .= '<option value="' .
$winning_bid_num_result->idwinning_bids .
'">' .
$winning_bid_num_result->item_assigned_num .
' - ' .
$winning_bid_num_result->item_desc .
'</option>';
}
return $winning_bid_num;
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Helpers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Bidders;
use App\Models\Items;
use App\Models\Checkout;
use App\Models\PaymentMethods;
use App\Models\WinningBids;
class WinningBidderSelectList
{
public static function winningBidderShowNumbers()
{
$winning_bidder_num_results = WinningBids::join(
'bidders',
'winning_bids.winning_bidder_num',
'=',
'bidders.idbidders'
)
->groupBy('winning_bidder_num')
->orderBy('bidders.bidder_assigned_number')
->get();
$winning_bidder_num = '<option disabled selected hidden value="">choose...</option>';
foreach ($winning_bidder_num_results as $winning_bidder_num_result) {
$winning_bidder_num .= '<option value="' .
$winning_bidder_num_result->idbidders .
'">' .
$winning_bidder_num_result->bidder_assigned_number .
' - ' .
$winning_bidder_num_result->bidder_fname .
' ' .
$winning_bidder_num_result->bidder_lname .
'</option>';
}
return $winning_bidder_num;
}
}

View File

@ -5,82 +5,84 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use View; use View;
Use App\helpers; use App\helpers;
use PDF; use PDF;
//use Converter; use App\Models\Bidders;
use App\Models\Items;
use App\Models\Checkout;
use App\Models\PaymentMethods;
use App\Models\WinningBids;
class PagesController extends Controller class PagesController extends Controller
{ {
public function home() public function home()
{ {
$item_count_result = DB::select("SELECT $item_count_result = Items::count();
count(items.item_assigned_num) AS item_count $bidder_count_result = Bidders::count();
FROM items $winner_count_result = WinningBids::count();
"); return view('home', [
$bidder_count_result = DB::select("SELECT 'item_count_result' => $item_count_result,
count(bidders.bidder_assigned_number) AS bidder_count 'bidder_count_result' => $bidder_count_result,
FROM bidders 'winner_count_result' => $winner_count_result
"); ]);
$winner_count_result = DB::select("SELECT
count(winning_bids.idwinning_bids) AS winner_count
FROM winning_bids
");
return view('home', ['item_count_result' => $item_count_result, 'bidder_count_result' => $bidder_count_result, 'winner_count_result' => $winner_count_result]);
}
public function bidderlist()
{
$bidderlist_results = DB::select("SELECT
*
FROM bidders
ORDER BY bidder_assigned_number ASC, bidder_fname ASC
");
return view('bidderlist', ['bidderlist_results' => $bidderlist_results]);
}
public function bidders(Request $bidder_req)
{
if(!$bidder_req->bidderlname){
return view('bidders');
} }
$bidder_lname = $bidder_req->bidderlname;
$bidder_fname = $bidder_req->bidderfname;
$bidder_addr = $bidder_req->bidderaddr;
$bidder_city = $bidder_req->biddercity;
$bidder_state = $bidder_req->bidderstate;
$bidder_zip = $bidder_req->bidderzip;
$bidder_phone = $bidder_req->bidderphone;
$bidder_email = $bidder_req->bidderemail;
$bidder_assigned_number = $bidder_req->biddernum;
$bidder_insert = DB::table('bidders')->insert(
[
'bidder_lname' => $bidder_lname ,
'bidder_fname' => $bidder_fname ,
'bidder_addr' => $bidder_addr ,
'bidder_city' => $bidder_city ,
'bidder_state' => $bidder_state ,
'bidder_zip' => $bidder_zip ,
'bidder_phone' => $bidder_phone ,
'bidder_email' => $bidder_email ,
'bidder_assigned_number' => $bidder_assigned_number
]);
return redirect('bidders');
}
public function checkout(Request $checkout_req) public function bidderlist()
{ {
if(!$checkout_req->checkoutbiddernum){ $bidderlist_results = Bidders::orderBy('bidder_assigned_number', 'asc')
return view('checkout_select_form'); ->orderBy('bidder_lname', 'asc')
} elseif(!$checkout_req->checkout_payment_method){ ->orderBy('bidder_fname', 'asc')
$checkout_bidder = $checkout_req->checkoutbiddernum; ->get();
$checkout_list_results = DB::select("SELECT return view('bidderlist', ['bidderlist_results' => $bidderlist_results]);
}
public function bidders(Request $bidder_req)
{
if (!$bidder_req->bidderlname) {
return view('bidders');
}
$bidder_lname = $bidder_req->bidderlname;
$bidder_fname = $bidder_req->bidderfname;
$bidder_addr = $bidder_req->bidderaddr;
$bidder_city = $bidder_req->biddercity;
$bidder_state = $bidder_req->bidderstate;
$bidder_zip = $bidder_req->bidderzip;
$bidder_phone = $bidder_req->bidderphone;
$bidder_email = $bidder_req->bidderemail;
$bidder_assigned_number = $bidder_req->biddernum;
$bidder_insert = Bidders::updateOrCreate(
[
'bidder_assigned_number' => $bidder_assigned_number,
],
[
'bidder_lname' => $bidder_lname ,
'bidder_fname' => $bidder_fname ,
'bidder_addr' => $bidder_addr ,
'bidder_city' => $bidder_city ,
'bidder_state' => $bidder_state ,
'bidder_zip' => $bidder_zip ,
'bidder_phone' => $bidder_phone ,
'bidder_email' => $bidder_email
]
);
return redirect('bidders');
}
public function checkout(Request $checkout_req)
{
if (!$checkout_req->checkoutbiddernum) {
return view('checkout_select_form');
} elseif (!$checkout_req->checkout_payment_method) {
$checkout_bidder = $checkout_req->checkoutbiddernum;
$checkout_list_results = DB::select("SELECT
*, items.item_assigned_num *, items.item_assigned_num
FROM winning_bids FROM winning_bids
INNER JOIN items AS items INNER JOIN items AS items
ON winning_bids.winning_item_num=items.iditems ON winning_bids.winning_item_num=items.iditems
WHERE winning_bidder_num = $checkout_bidder WHERE winning_bidder_num = $checkout_bidder
"); ");
$checkout_info_results = DB::select("SELECT $checkout_info_results = DB::select("SELECT
winning_bids.*, winning_bids.*,
bidders.*, bidders.*,
sum(winning_cost) AS total_cost sum(winning_cost) AS total_cost
@ -90,22 +92,25 @@ class PagesController extends Controller
WHERE winning_bidder_num = $checkout_bidder WHERE winning_bidder_num = $checkout_bidder
GROUP BY winning_bids.winning_bidder_num GROUP BY winning_bids.winning_bidder_num
"); ");
return view('checkout', ['checkout_list_results' => $checkout_list_results, 'checkout_info_results' => $checkout_info_results]); return view('checkout', [
} else { 'checkout_list_results' => $checkout_list_results,
$winnertotal = $checkout_req->winnertotal; 'checkout_info_results' => $checkout_info_results
$bidder_num = $checkout_req->checkoutbiddernum; ]);
$payment_method = $checkout_req->checkout_payment_method; } else {
$check_number = $checkout_req->check_number; $winnertotal = $checkout_req->winnertotal;
$cc_transaction = $checkout_req->cc_transaction; $bidder_num = $checkout_req->checkoutbiddernum;
$cc_amount = $checkout_req->cc_amount; $payment_method = $checkout_req->checkout_payment_method;
$checkout_list_results = DB::select("SELECT $check_number = $checkout_req->check_number;
$cc_transaction = $checkout_req->cc_transaction;
$cc_amount = $checkout_req->cc_amount;
$checkout_list_results = DB::select("SELECT
*, items.item_assigned_num, items.item_desc *, items.item_assigned_num, items.item_desc
FROM winning_bids FROM winning_bids
INNER JOIN items AS items INNER JOIN items AS items
ON winning_bids.winning_item_num=items.iditems ON winning_bids.winning_item_num=items.iditems
WHERE winning_bidder_num = $bidder_num WHERE winning_bidder_num = $bidder_num
"); ");
$checkout_info_results = DB::select("SELECT $checkout_info_results = DB::select("SELECT
winning_bids.*, winning_bids.*,
bidders.*, bidders.*,
sum(winning_cost) AS total_cost sum(winning_cost) AS total_cost
@ -115,56 +120,57 @@ class PagesController extends Controller
WHERE winning_bidder_num = $bidder_num WHERE winning_bidder_num = $bidder_num
GROUP BY winning_bids.winning_bidder_num GROUP BY winning_bids.winning_bidder_num
"); ");
$checkout_result = DB::table('checkout')->insertGetID( $checkout_result = DB::table('checkout')->insertGetID(
[ [
'bidder_num' => $bidder_num, 'bidder_num' => $bidder_num,
'winnertotal' => $winnertotal, 'winnertotal' => $winnertotal,
'payment_method' => $payment_method, 'payment_method' => $payment_method,
'check_number' => $check_number, 'check_number' => $check_number,
'cc_transaction' => $cc_transaction, 'cc_transaction' => $cc_transaction,
'cc_amount' => $cc_amount, 'cc_amount' => $cc_amount,
] ]
); );
return view('checkout_complete', ['checkout_result' => $checkout_result, 'checkout_list_results' => $checkout_list_results, 'checkout_info_results' => $checkout_info_results, 'payment_method' => $payment_method, 'check_number' => $check_number, 'cc_transaction' => $cc_transaction]); return view('checkout_complete', [
'checkout_result' => $checkout_result,
'checkout_list_results' => $checkout_list_results,
'checkout_info_results' => $checkout_info_results,
'payment_method' => $payment_method,
'check_number' => $check_number,
'cc_transaction' => $cc_transaction
]);
}
} }
}
public function checkout_complete_list() public function checkoutCompleteList()
{ {
$checkout_complete_results = DB::select("SELECT $checkout_complete_results = Checkout::join('bidders', 'checkout.bidder_num', '=', 'bidders.idbidders')
checkout.*, ->groupBy('bidder_num')
bidders.* ->orderBy('bidders.bidder_assigned_number', 'asc')
FROM checkout ->get();
INNER JOIN bidders AS bidders return view('checkout_complete_list', ['checkout_complete_results' => $checkout_complete_results]);
ON checkout.bidder_num=bidders.idbidders
GROUP BY checkout.bidder_num
ORDER BY bidders.bidder_assigned_number ASC
");
return view('checkout_complete_list', ['checkout_complete_results' => $checkout_complete_results]);
}
public function editwinners(Request $edit_win_req)
{
if(!$edit_win_req->winid){
return view('editwinners');
} }
$winning_bid_id = $edit_win_req->winid;
$winner_bidder = $edit_win_req->winnerbiddernum;
$winner_cost = $edit_win_req->winnerbid;
$winner_insert = DB::table('winning_bids')
->where('idwinning_bids', $winning_bid_id)
->update(
[
'winning_bidder_num' => $winner_bidder,
'winning_cost' => $winner_cost
]
);
return redirect('editwinners');
}
public function finaltally() public function editwinners(Request $edit_win_req)
{ {
$finaltally_results = DB::select("SELECT if (!$edit_win_req->winid) {
return view('editwinners');
}
$winning_bid_id = $edit_win_req->winid;
$winner_bidder = $edit_win_req->winnerbiddernum;
$winner_cost = $edit_win_req->winnerbid;
$winner_insert = WinningBids::where('idwinning_bids', $winning_bid_id)
->update(
[
'winning_bidder_num' => $winner_bidder,
'winning_cost' => $winner_cost
]
);
return redirect('editwinners');
}
public function finaltally()
{
$finaltally_results = DB::select("SELECT
winning_bids.*, winning_bids.*,
sum(winning_bids.winning_cost) AS total_due, sum(winning_bids.winning_cost) AS total_due,
bidders.* bidders.*
@ -174,55 +180,50 @@ class PagesController extends Controller
GROUP BY winning_bids.winning_bidder_num GROUP BY winning_bids.winning_bidder_num
ORDER BY bidders.bidder_lname ORDER BY bidders.bidder_lname
"); ");
return view('finaltally', ['finaltally_results' => $finaltally_results]); return view('finaltally', ['finaltally_results' => $finaltally_results]);
}
public function itemlist()
{
$itemlist_results = DB::select("SELECT
*
FROM items
ORDER BY item_assigned_num ASC
");
return view('itemlist', ['itemlist_results' => $itemlist_results]);
}
public function items(Request $items_req)
{
if(!$items_req->itemnum){
return view('items');
} }
$item_assigned_num = $items_req->itemnum;
$item_desc = $items_req->itemdesc;
$item_min_bid = $items_req->itemminbid;
$items_est_value = $items_req->itemestvalue;
$item_insert = DB::table('items')->insert(
[
'item_assigned_num' => $item_assigned_num,
'item_desc' => $item_desc,
'item_min_bid' => $item_min_bid,
'item_est_value' => $items_est_value
]);
return redirect('items');
}
public function receiptpdf(Request $receiptpdf_request) public function itemlist()
{ {
$checkoutid = $receiptpdf_request->checkout_id; $itemlist_results = Items::orderBy('item_assigned_num', 'asc')
$checkout_final_results = DB::select("SELECT ->get();
* return view('itemlist', ['itemlist_results' => $itemlist_results]);
FROM checkout }
WHERE checkout_id = $checkoutid
"); public function items(Request $items_req)
$bidder_num = $checkout_final_results['0']->bidder_num; {
$checkout_list_results = DB::select("SELECT if (!$items_req->itemnum) {
return view('items');
}
$item_assigned_num = $items_req->itemnum;
$item_desc = $items_req->itemdesc;
$item_min_bid = $items_req->itemminbid;
$items_est_value = $items_req->itemestvalue;
$item_insert = DB::table('items')->insert(
[
'item_assigned_num' => $item_assigned_num,
'item_desc' => $item_desc,
'item_min_bid' => $item_min_bid,
'item_est_value' => $items_est_value
]
);
return redirect('items');
}
public function receiptpdf(Request $receiptpdf_request)
{
$checkoutid = $receiptpdf_request->checkout_id;
$checkout_final_results = Checkout::where('checkout_id', '=', $checkoutid)
->first();
$bidder_num = $checkout_final_results->bidder_num;
$checkout_list_results = DB::select("SELECT
*, items.item_assigned_num, items.item_desc *, items.item_assigned_num, items.item_desc
FROM winning_bids FROM winning_bids
INNER JOIN items AS items INNER JOIN items AS items
ON winning_bids.winning_item_num=items.iditems ON winning_bids.winning_item_num=items.iditems
WHERE winning_bidder_num = $bidder_num WHERE winning_bidder_num = $bidder_num
"); ");
$checkout_info_results = DB::select("SELECT $checkout_info_results = DB::select("SELECT
winning_bids.*, winning_bids.*,
bidders.*, bidders.*,
sum(winning_cost) AS total_cost sum(winning_cost) AS total_cost
@ -232,74 +233,56 @@ class PagesController extends Controller
WHERE winning_bidder_num = $bidder_num WHERE winning_bidder_num = $bidder_num
GROUP BY winning_bids.winning_bidder_num GROUP BY winning_bids.winning_bidder_num
"); ");
//dd($checkout_final_results); $checkout_data = [
$checkout_data = [ 'checkout_final_results' => $checkout_final_results,
'checkout_final_results' => $checkout_final_results, 'checkout_list_results' => $checkout_list_results,
'checkout_list_results' => $checkout_list_results, 'checkout_info_results' => $checkout_info_results
'checkout_info_results' => $checkout_info_results ];
]; return view('receiptpdf', $checkout_data);
// dd($checkout_data);
//$pdf = PDF::loadView('receiptpdf', $checkout_data);
//dd($pdf);
// $receiptcontentview = View::make('receiptpdf', $checkout_data);
// $receiptcontent = $receiptcontentview->render();
// $pdf = PDF::loadHTML($receiptcontent);
// $pdf = PDF::loadView('receiptpdf', $checkout_data);
// return $pdf->stream('receipt.pdf');
return view('receiptpdf', $checkout_data);
}
public function reprint_receipt(Request $reprint_receipt_req)
{
if(!$reprint_receipt_req->reprintbiddernum){
return view('reprint_receipt_form');
} else {
$bidnum=$reprint_receipt_req->reprintbiddernum;
$checkout_id = DB::select("SELECT
checkout_id
FROM checkout
WHERE bidder_num = $bidnum
");
return redirect()->route('receiptpdf', ['checkout_id' => $checkout_id['0']->checkout_id]);
} }
}
public function winnerlist() public function reprintReceipt(Request $reprint_receipt_req)
{ {
$winnerlist_results = DB::select("SELECT if (!$reprint_receipt_req->reprintbiddernum) {
*, bidders.bidder_assigned_number, items.item_assigned_num return view('reprint_receipt_form');
FROM winning_bids } else {
INNER JOIN bidders as bidders $bidnum=$reprint_receipt_req->reprintbiddernum;
ON winning_bids.winning_bidder_num=bidders.idbidders $checkout_result = Checkout::where('bidder_num', '=', $bidnum)
INNER JOIN items as items ->first();
ON winning_bids.winning_item_num=items.iditems return redirect()->route('receiptpdf', ['checkout_id' => $checkout_result->checkout_id]);
ORDER BY winning_item_num ASC }
");
return view('winnerlist', ['winnerlist_results' => $winnerlist_results]);
}
public function winners(Request $winners_req)
{
if(!$winners_req->winnerbid){
return view('winners');
} }
$winner_item = $winners_req->winneritemnum;
$winner_bidder = $winners_req->winnerbiddernum;
$winner_cost = $winners_req->winnerbid;
$winner_insert = DB::table('winning_bids')->insert(
[
'winning_item_num' => $winner_item,
'winning_bidder_num' => $winner_bidder,
'winning_cost' => $winner_cost
]
);
return redirect('winners');
}
public function winnersbyitem() public function winnerlist()
{ {
$winnersbyitem_results = DB::select("SELECT $winnerlist_results = WinningBids::join('bidders', 'winning_bids.winning_bidder_num', '=', 'bidders.idbidders')
->groupBy('winning_bidder_num')
->orderBy('bidders.bidder_assigned_number')
->get();
return view('winnerlist', ['winnerlist_results' => $winnerlist_results]);
}
public function winners(Request $winners_req)
{
if (!$winners_req->winnerbid) {
return view('winners');
}
$winner_item = $winners_req->winneritemnum;
$winner_bidder = $winners_req->winnerbiddernum;
$winner_cost = $winners_req->winnerbid;
$winner_insert = DB::table('winning_bids')->insert(
[
'winning_item_num' => $winner_item,
'winning_bidder_num' => $winner_bidder,
'winning_cost' => $winner_cost
]
);
return redirect('winners');
}
public function winnersbyitem()
{
$winnersbyitem_results = DB::select("SELECT
* *
FROM winning_bids FROM winning_bids
INNER JOIN items as items INNER JOIN items as items
@ -308,23 +291,23 @@ class PagesController extends Controller
ON winning_bids.winning_bidder_num=bidders.idbidders ON winning_bids.winning_bidder_num=bidders.idbidders
ORDER BY item_assigned_num ASC ORDER BY item_assigned_num ASC
"); ");
return view('winnersbyitem', ['winnersbyitem_results' => $winnersbyitem_results]); return view('winnersbyitem', ['winnersbyitem_results' => $winnersbyitem_results]);
}
public function winnertotal(Request $winnertotal_req)
{
if(!$winnertotal_req->winnerbiddernum){
return view('winnertotalform');
} }
$winner_total_bidder = $winnertotal_req->winnerbiddernum;
$winnertotal_list_results = DB::select("SELECT public function winnertotal(Request $winnertotal_req)
{
if (!$winnertotal_req->winnerbiddernum) {
return view('winnertotalform');
}
$winner_total_bidder = $winnertotal_req->winnerbiddernum;
$winnertotal_list_results = DB::select("SELECT
*, items.item_assigned_num *, items.item_assigned_num
FROM winning_bids FROM winning_bids
INNER JOIN items AS items INNER JOIN items AS items
ON winning_bids.winning_item_num=items.iditems ON winning_bids.winning_item_num=items.iditems
WHERE winning_bidder_num = $winner_total_bidder WHERE winning_bidder_num = $winner_total_bidder
"); ");
$winnertotal_info_results = DB::select("SELECT $winnertotal_info_results = DB::select("SELECT
winning_bids.*, winning_bids.*,
bidders.*, bidders.*,
sum(winning_cost) AS total_cost sum(winning_cost) AS total_cost
@ -334,17 +317,18 @@ class PagesController extends Controller
WHERE winning_bidder_num = $winner_total_bidder WHERE winning_bidder_num = $winner_total_bidder
GROUP BY winning_bids.winning_bidder_num GROUP BY winning_bids.winning_bidder_num
"); ");
return view('winnertotal', ['winnertotal_list_results' => $winnertotal_list_results, 'winnertotal_info_results' => $winnertotal_info_results]); return view('winnertotal', [
} 'winnertotal_list_results' => $winnertotal_list_results,
'winnertotal_info_results' => $winnertotal_info_results
]);
}
public function winningbidderlist() public function winningbidderlist()
{ {
$winnerlist_results = DB::select("SELECT $winnerlist_results = WinningBids::join('bidders', 'winning_bids.winning_bidder_num', '=', 'bidders.idbidders')
winning_bidder_num ->groupBy('winning_bidder_num')
FROM winning_bids ->orderBy('bidders.bidder_assigned_number')
GROUP BY winning_bidder_num ->get();
ORDER BY winning_bidder_num return view('winningbidderlist', ['winnerlist_results' => $winnerlist_results]);
"); }
return view('winningbidderlist', ['winnerlist_results' => $winnerlist_results]);
}
} }

View File

@ -34,7 +34,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class, \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\HttpsRedirect::class, \App\Http\Middleware\HttpsRedirect::class,
], ],
'api' => [ 'api' => [

View File

@ -13,12 +13,12 @@ class HttpsRedirect
* @param \Closure $next * @param \Closure $next
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if (!$request->secure() && env('APP_ENV') === 'prod') { if (!$request->secure() && env('APP_ENV') === 'prod') {
return redirect()->secure($request->getRequestUri()); return redirect()->secure($request->getRequestUri());
} }
return $next($request); return $next($request);
} }
} }

38
app/Models/Bidders.php Normal file
View File

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Bidders extends Model
{
protected $table = 'bidders';
protected $fillable = [
'bidder_fname',
'bidder_lname',
'bidder_addr',
'bidder_city',
'bidder_state',
'bidder_zip',
'bidder_phone',
'bidder_email',
'bidder_assigned_number',
'created_at',
'updated_at'
];
protected $dates = [
'created_at',
'updated_at'
];
public function checkout()
{
return $this->hasMany('App\Models\Checkout', 'bidder_num', 'idbidders');
}
public function winningBids()
{
return $this->hasMany('App\Models\WinningBids', 'winning_bidder_num', 'idbidders');
}
}

35
app/Models/Checkout.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Checkout extends Model
{
protected $table = 'checkout';
protected $fillable = [
'bidder_num',
'winnertotal',
'payment_method',
'check_number',
'cc_transaction',
'cc_amount',
'created_at',
'updated_at'
];
protected $dates = [
'created_at',
'updated_at'
];
public function bidders()
{
return $this->belongsTo('App\Models\Bidders', 'bidder_num', 'idbidders');
}
public function paymentMethod()
{
return $this->hasMany('App\Models\PaymentMethods', 'payment_method', 'pm_id');
}
}

28
app/Models/Items.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Items extends Model
{
protected $table = 'items';
protected $fillable = [
'item_desc',
'item_min_bid',
'item_est_value',
'item_assigned_num',
'created_at',
'updated_at'
];
protected $dates = [
'created_at',
'updated_at'
];
public function winningBids()
{
return $this->belongsTo('App\Models\WinningBids', 'iditems', 'winning_item_num');
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class PaymentMethods extends Model
{
protected $table = 'payment_methods';
protected $fillable = [
'pm_name',
'created_at',
'updated_at'
];
protected $dates = [
'created_at',
'updated_at'
];
public function checkout()
{
return $this->belongsTo('App\Models\Checkout', 'payment_method', 'pm_id');
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class WinningBids extends Model
{
protected $table = 'winning_bids';
protected $fillable = [
'winning_bidder_num',
'winning_cost',
'winning_item_num',
'created_at',
'updated_at'
];
protected $dates = [
'created_at',
'updated_at'
];
public function items()
{
return $this->hasMany('App\Models\Items', 'iditems', 'winning_item_num');
}
public function bidders()
{
return $this->belongsTo('App\Models\Bidders', 'winning_bidder_num', 'idbidders');
}
}

View File

@ -14,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
} }
/** /**

View File

@ -1,115 +0,0 @@
<?php
namespace App;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class BidderSelectList
{
public static function BidderShowNumbers()
{
$bidder_num_results = DB::select("SELECT
*
FROM bidders
ORDER BY bidder_assigned_number
");
$bidder_num = '<option disabled selected hidden value="">choose...</option>';
foreach($bidder_num_results as $bidder_num_result){
$bidder_num .= '<option value="' . $bidder_num_result->idbidders . '">' . $bidder_num_result->bidder_assigned_number . ' - ' . $bidder_num_result->bidder_fname . ' ' . $bidder_num_result->bidder_lname .'</option>';
}
return $bidder_num;
}
}
class CheckoutBidderSelectList
{
public static function CheckoutBidderShowNumbers()
{
$checkout_bidder_num_results = DB::select("SELECT
bidder_num, bidders.*
FROM checkout
INNER JOIN bidders AS bidders
ON checkout.bidder_num=bidders.idbidders
GROUP BY bidders.bidder_assigned_number
ORDER BY bidders.bidder_assigned_number
");
$checkout_bidder_num = '<option disabled selected hidden value="">choose...</option>';
foreach($checkout_bidder_num_results as $checkout_bidder_num_result){
$checkout_bidder_num .= '<option value="' . $checkout_bidder_num_result->idbidders . '">' . $checkout_bidder_num_result->bidder_assigned_number . ' - ' . $checkout_bidder_num_result->bidder_fname . ' ' . $checkout_bidder_num_result->bidder_lname .'</option>';
}
return $checkout_bidder_num;
}
}
class ItemSelectList
{
public static function ItemShowNumbers()
{
$item_num_results = DB::select("SELECT
*
FROM items
ORDER BY item_assigned_num
");
$item_nums = '<option disabled="disabled" selected="selected" value="0">choose...</option>';
foreach($item_num_results as $item_num_result){
$item_nums .= '<option value="' . $item_num_result->iditems . '">' . $item_num_result->item_assigned_num . '</option>';
}
return $item_nums;
}
}
class PaymentMethodSelectList
{
public static function PaymentShowMethods()
{
$payment_method_results = DB::select("SELECT
*
FROM payment_methods
ORDER BY pm_name
");
$payment_methods = '<option disabled="disabled" selected="selected" value="0">choose...</option>';
foreach($payment_method_results as $payment_method_result){
$payment_methods .= '<option value="' . $payment_method_result->pm_id . '">' . $payment_method_result->pm_name . '</option>';
}
return $payment_methods;
}
}
class WinningBidSelectList
{
public static function WinningBidShowNumbers()
{
$winning_bid_num_results = DB::select("SELECT
*
FROM winning_bids
INNER JOIN items AS items
ON winning_bids.winning_item_num = items.iditems
ORDER BY items.item_assigned_num
");
$winning_bid_num = '<option disabled selected hidden value="">choose...</option>';
foreach($winning_bid_num_results as $winning_bid_num_result){
$winning_bid_num .= '<option value="' . $winning_bid_num_result->idwinning_bids . '">' . $winning_bid_num_result->item_assigned_num . ' - ' . $winning_bid_num_result->item_desc .'</option>';
}
return $winning_bid_num;
}
}
class WinningBidderSelectList
{
public static function WinningBidderShowNumbers()
{
$winning_bidder_num_results = DB::select("SELECT
winning_bidder_num, bidders.*
FROM winning_bids
INNER JOIN bidders AS bidders
ON winning_bids.winning_bidder_num=bidders.idbidders
GROUP BY winning_bidder_num
ORDER BY winning_bidder_num
");
$winning_bidder_num = '<option disabled selected hidden value="">choose...</option>';
foreach($winning_bidder_num_results as $winning_bidder_num_result){
$winning_bidder_num .= '<option value="' . $winning_bidder_num_result->idbidders . '">' . $winning_bidder_num_result->bidder_assigned_number . ' - ' . $winning_bidder_num_result->bidder_fname . ' ' . $winning_bidder_num_result->bidder_lname .'</option>';
}
return $winning_bidder_num;
}
}
?>

View File

@ -31,7 +31,12 @@
"Tests\\": "tests/" "Tests\\": "tests/"
}, },
"files": [ "files": [
"app/helpers.php" "app/Helpers/BidderSelectList.php",
"app/Helpers/CheckoutBidderSelectList.php",
"app/Helpers/ItemSelectList.php",
"app/Helpers/PaymentMethodSelectList.php",
"app/Helpers/WinningBidderSelectList.php",
"app/Helpers/WinningBidSelectList.php"
] ]
}, },

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTimestampsBidders extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('bidders', function ($table) {
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTimestampsCheckout extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('checkout', function ($table) {
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTimestampsItems extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('items', function ($table) {
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTimestampsWinningbids extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('winning_bids', function ($table) {
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTimestampsPaymentmethods extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('payment_methods', function ($table) {
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -84,7 +84,7 @@
</label> </label>
<div class=col-sm-4> <div class=col-sm-4>
<select name="checkout_payment_method" id="checkout_payment_method" required class=form-control> <select name="checkout_payment_method" id="checkout_payment_method" required class=form-control>
<?php echo App\PaymentMethodSelectList::PaymentShowMethods(); ?> <?php echo App\Helpers\PaymentMethodSelectList::PaymentShowMethods(); ?>
</select> </select>
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@
</label> </label>
<div class=col-sm-4> <div class=col-sm-4>
<select name="checkoutbiddernum" id="checkoutbiddernum" required class=form-control> <select name="checkoutbiddernum" id="checkoutbiddernum" required class=form-control>
<?php echo App\WinningBidderSelectList::WinningBidderShowNumbers(); ?> <?php echo App\Helpers\WinningBidderSelectList::winningBidderShowNumbers(); ?>
</select> </select>
</div> </div>
</div> </div>

View File

@ -15,7 +15,7 @@
</label> </label>
<div class=col-sm-2> <div class=col-sm-2>
<select name="winid" id="winid" required class=form-control> <select name="winid" id="winid" required class=form-control>
<?php echo App\WinningBidSelectList::WinningBidShowNumbers(); ?> <?php echo App\Helpers\WinningBidSelectList::winningBidShowNumbers(); ?>
</select> </select>
</div> </div>
</div> </div>
@ -25,7 +25,7 @@
</label> </label>
<div class=col-sm-2> <div class=col-sm-2>
<select name="winnerbiddernum" id="winnerbiddernum" required class=form-control> <select name="winnerbiddernum" id="winnerbiddernum" required class=form-control>
<?php echo App\BidderSelectList::BidderShowNumbers(); ?> <?php echo App\Helpers\BidderSelectList::bidderShowNumbers(); ?>
</select> </select>
</div> </div>
</div> </div>

View File

@ -25,19 +25,13 @@
</tr> </tr>
<tr> <tr>
<td> <td>
@foreach($item_count_result as $item_count_result) {{ $item_count_result }}
{{ $item_count_result->item_count }}
@endforeach
</td> </td>
<td> <td>
@foreach($bidder_count_result as $bidder_count_result) {{ $bidder_count_result }}
{{ $bidder_count_result->bidder_count }}
@endforeach
</td> </td>
<td> <td>
@foreach($winner_count_result as $winner_count_result) {{ $winner_count_result }}
{{ $winner_count_result->winner_count }}
@endforeach
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -108,21 +108,19 @@
</h4> </h4>
</th> </th>
<th> <th>
@foreach($checkout_final_results as $checkout_final_result) @if($checkout_final_results->payment_method==1)
@if($checkout_final_result->payment_method==1) <h4>
<h4> CASH
CASH </h4>
</h4> @elseif($checkout_final_results->payment_method==2)
@elseif($checkout_final_result->payment_method==2) <h4>
<h4> CHECK Number {{ $checkout_final_results->check_number }}
CHECK Number {{ $checkout_final_result->check_number }} </h4>
</h4> @else
@else <h4>
<h4> CREDIT {{ $checkout_final_results->cc_transaction }}
CREDIT {{ $checkout_final_result->cc_transaction }} </h4>
</h4> @endif
@endif
@endforeach
</th> </th>
</tr> </tr>
</table> </table>

View File

@ -16,7 +16,7 @@
</label> </label>
<div class=col-sm-4> <div class=col-sm-4>
<select name="reprintbiddernum" id="checkoutbiddernum" required class=form-control> <select name="reprintbiddernum" id="checkoutbiddernum" required class=form-control>
<?php echo App\CheckoutBidderSelectList::CheckoutBidderShowNumbers(); ?> <?php echo App\Helpers\CheckoutBidderSelectList::checkoutBidderShowNumbers(); ?>
</select> </select>
</div> </div>
</div> </div>

View File

@ -15,7 +15,7 @@
foreach($winnerlist_results as $winnerlist_result){ foreach($winnerlist_results as $winnerlist_result){
echo "<td>" . $winnerlist_result->winning_bidder_num . "</td>"; echo "<td>" . $winnerlist_result->bidders->bidder_assigned_number . "</td>";
// do we need a new row? // do we need a new row?
if($i % 6 === 0){ if($i % 6 === 0){

View File

@ -16,7 +16,7 @@
</label> </label>
<div class=col-sm-2> <div class=col-sm-2>
<select name="winneritemnum" id="winneritemnum" required class=form-control> <select name="winneritemnum" id="winneritemnum" required class=form-control>
<?php echo App\ItemSelectList::ItemShowNumbers(); ?> <?php echo App\Helpers\ItemSelectList::itemShowNumbers(); ?>
</select> </select>
</div> </div>
</div> </div>
@ -26,7 +26,7 @@
</label> </label>
<div class=col-sm-2> <div class=col-sm-2>
<select name="winnerbiddernum" id="winnerbiddernum" required class=form-control> <select name="winnerbiddernum" id="winnerbiddernum" required class=form-control>
<?php echo App\BidderSelectList::BidderShowNumbers(); ?> <?php echo App\Helpers\BidderSelectList::bidderShowNumbers(); ?>
</select> </select>
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@
</label> </label>
<div class=col-sm-4> <div class=col-sm-4>
<select name="winnerbiddernum" id="winnerbiddernum" required class=form-control> <select name="winnerbiddernum" id="winnerbiddernum" required class=form-control>
<?php echo App\BidderSelectList::BidderShowNumbers(); ?> <?php echo App\Helpers\BidderSelectList::bidderShowNumbers(); ?>
</select> </select>
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@
// start first row // start first row
echo "<tr>"; echo "<tr>";
foreach($winnerlist_results as $winnerlist_result){ foreach($winnerlist_results as $winnerlist_result){
echo "<td><h3>" . $winnerlist_result->winning_bidder_num . "</h3></td>"; echo "<td><h3>" . $winnerlist_result->bidders->bidder_assigned_number . "</h3></td>";
// do we need a new row? // do we need a new row?
if($i % 8 === 0){ if($i % 8 === 0){
echo "</tr><tr>"; echo "</tr><tr>";

View File

@ -24,7 +24,7 @@ Route::group(['middleware' => 'auth'], function() {
Route::post('bidderlist', [ 'uses' => 'PagesController@bidderlist']); Route::post('bidderlist', [ 'uses' => 'PagesController@bidderlist']);
Route::get('checkout', [ 'uses' => 'PagesController@checkout']); Route::get('checkout', [ 'uses' => 'PagesController@checkout']);
Route::post('checkout', [ 'uses' => 'PagesController@checkout']); Route::post('checkout', [ 'uses' => 'PagesController@checkout']);
Route::get('checkout_complete_list', [ 'uses' => 'PagesController@checkout_complete_list' ]); Route::get('checkout_complete_list', [ 'uses' => 'PagesController@checkoutCompleteList' ]);
Route::get('editwinners', [ 'uses' => 'PagesController@editwinners']); Route::get('editwinners', [ 'uses' => 'PagesController@editwinners']);
Route::post('editwinners', [ 'uses' => 'PagesController@editwinners']); Route::post('editwinners', [ 'uses' => 'PagesController@editwinners']);
Route::get('finaltally', [ 'uses' => 'PagesController@finaltally']); Route::get('finaltally', [ 'uses' => 'PagesController@finaltally']);
@ -32,8 +32,8 @@ Route::group(['middleware' => 'auth'], function() {
Route::post('items', [ 'uses' => 'PagesController@items']); Route::post('items', [ 'uses' => 'PagesController@items']);
Route::get('itemlist', [ 'uses' => 'PagesController@itemlist']); Route::get('itemlist', [ 'uses' => 'PagesController@itemlist']);
Route::post('itemlist', [ 'uses' => 'PagesController@itemlist']); Route::post('itemlist', [ 'uses' => 'PagesController@itemlist']);
Route::get('reprint_receipt', ['uses' => 'PagesController@reprint_receipt']); Route::get('reprint_receipt', ['uses' => 'PagesController@reprintReceipt']);
Route::post('reprint_receipt', ['uses' => 'PagesController@reprint_receipt']); Route::post('reprint_receipt', ['uses' => 'PagesController@reprintReceipt']);
Route::get('receiptpdf', ['uses' => 'PagesController@receiptpdf'])->name('receiptpdf'); Route::get('receiptpdf', ['uses' => 'PagesController@receiptpdf'])->name('receiptpdf');
Route::get('winners', [ 'uses' => 'PagesController@winners']); Route::get('winners', [ 'uses' => 'PagesController@winners']);
Route::post('winners', [ 'uses' => 'PagesController@winners']); Route::post('winners', [ 'uses' => 'PagesController@winners']);