$item_count_result, 'bidder_count_result' => $bidder_count_result, 'winner_count_result' => $winner_count_result ]); } public function bidderlist() { $bidderlist_results = Bidders::orderBy('bidder_assigned_number', 'asc') ->orderBy('bidder_lname', 'asc') ->orderBy('bidder_fname', 'asc') ->get(); 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 FROM winning_bids INNER JOIN items AS items ON winning_bids.winning_item_num=items.iditems WHERE winning_bidder_num = $checkout_bidder "); WinningBids::with('items') ->where('winning_bidder_num', $checkout_bidder) ->get(); $checkout_info_results = DB::select("SELECT winning_bids.*, bidders.*, sum(winning_cost) AS total_cost FROM winning_bids INNER JOIN bidders AS bidders ON winning_bids.winning_bidder_num=bidders.idbidders WHERE winning_bidder_num = $checkout_bidder GROUP BY winning_bids.winning_bidder_num "); return view('checkout', [ 'checkout_list_results' => $checkout_list_results, 'checkout_info_results' => $checkout_info_results ]); } else { $winnertotal = $checkout_req->winnertotal; $bidder_num = $checkout_req->checkoutbiddernum; $payment_method = $checkout_req->checkout_payment_method; $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 FROM winning_bids INNER JOIN items AS items ON winning_bids.winning_item_num=items.iditems WHERE winning_bidder_num = $bidder_num "); $checkout_info_results = DB::select("SELECT winning_bids.*, bidders.*, sum(winning_cost) AS total_cost FROM winning_bids INNER JOIN bidders AS bidders ON winning_bids.winning_bidder_num=bidders.idbidders WHERE winning_bidder_num = $bidder_num GROUP BY winning_bids.winning_bidder_num "); $checkout_result = DB::table('checkout')->insertGetID( [ 'bidder_num' => $bidder_num, 'winnertotal' => $winnertotal, 'payment_method' => $payment_method, 'check_number' => $check_number, 'cc_transaction' => $cc_transaction, '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 ]); } } public function checkoutCompleteList() { $checkout_complete_results = DB::select("SELECT checkout.*, bidders.* FROM checkout INNER JOIN bidders AS bidders 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() { $finaltally_results = DB::select("SELECT winning_bids.*, sum(winning_bids.winning_cost) AS total_due, bidders.* FROM winning_bids INNER JOIN bidders as bidders ON winning_bids.winning_bidder_num=bidders.idbidders GROUP BY winning_bids.winning_bidder_num ORDER BY bidders.bidder_lname "); 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) { $checkoutid = $receiptpdf_request->checkout_id; $checkout_final_results = DB::select("SELECT * FROM checkout WHERE checkout_id = $checkoutid "); $bidder_num = $checkout_final_results['0']->bidder_num; $checkout_list_results = DB::select("SELECT *, items.item_assigned_num, items.item_desc FROM winning_bids INNER JOIN items AS items ON winning_bids.winning_item_num=items.iditems WHERE winning_bidder_num = $bidder_num "); $checkout_info_results = DB::select("SELECT winning_bids.*, bidders.*, sum(winning_cost) AS total_cost FROM winning_bids INNER JOIN bidders AS bidders ON winning_bids.winning_bidder_num=bidders.idbidders WHERE winning_bidder_num = $bidder_num GROUP BY winning_bids.winning_bidder_num "); //dd($checkout_final_results); $checkout_data = [ 'checkout_final_results' => $checkout_final_results, 'checkout_list_results' => $checkout_list_results, 'checkout_info_results' => $checkout_info_results ]; // 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 reprintReceipt(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() { $winnerlist_results = DB::select("SELECT *, bidders.bidder_assigned_number, items.item_assigned_num FROM winning_bids INNER JOIN bidders as bidders ON winning_bids.winning_bidder_num=bidders.idbidders INNER JOIN items as items ON winning_bids.winning_item_num=items.iditems 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() { $winnersbyitem_results = DB::select("SELECT * FROM winning_bids INNER JOIN items as items ON winning_bids.winning_item_num=items.iditems INNER JOIN bidders AS bidders ON winning_bids.winning_bidder_num=bidders.idbidders ORDER BY item_assigned_num ASC "); 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 *, items.item_assigned_num FROM winning_bids INNER JOIN items AS items ON winning_bids.winning_item_num=items.iditems WHERE winning_bidder_num = $winner_total_bidder "); $winnertotal_info_results = DB::select("SELECT winning_bids.*, bidders.*, sum(winning_cost) AS total_cost FROM winning_bids INNER JOIN bidders AS bidders ON winning_bids.winning_bidder_num=bidders.idbidders WHERE winning_bidder_num = $winner_total_bidder GROUP BY winning_bids.winning_bidder_num "); return view('winnertotal', [ 'winnertotal_list_results' => $winnertotal_list_results, 'winnertotal_info_results' => $winnertotal_info_results ]); } public function winningbidderlist() { $winnerlist_results = DB::select("SELECT winning_bidder_num FROM winning_bids GROUP BY winning_bidder_num ORDER BY winning_bidder_num "); return view('winningbidderlist', ['winnerlist_results' => $winnerlist_results]); } }