diff --git a/app/Http/Controllers/Contracts/ContractAdminController.php b/app/Http/Controllers/Contracts/ContractAdminController.php index e430d41ee..bc68b886a 100644 --- a/app/Http/Controllers/Contracts/ContractAdminController.php +++ b/app/Http/Controllers/Contracts/ContractAdminController.php @@ -8,6 +8,7 @@ use Carbon\Carbon; //Libraries use App\Library\Esi\Mail; +use App\Library\Lookups\LookupHelper; //Jobs use App\Jobs\ProcessSendEveMailJob; @@ -181,6 +182,6 @@ class ContractAdminController extends Controller $subject = 'New Alliance Production Contract Available'; $body = "A new contract is available for the alliance contracting system. Please check out Services Site if you want to bid on the production contract.

Sincerely,
Warped Intentions Leadership"; - ProcessSendEveMailJob::dispatch($body, $config['alliance'], 'alliance', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5)); + ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5)); } } diff --git a/app/Http/Controllers/Contracts/ContractController.php b/app/Http/Controllers/Contracts/ContractController.php index f0c132d52..c8fee01df 100644 --- a/app/Http/Controllers/Contracts/ContractController.php +++ b/app/Http/Controllers/Contracts/ContractController.php @@ -22,6 +22,97 @@ class ContractController extends Controller $this->middleware('role:User'); } + /** + * Display the contract dashboard and whether you have any outstanding contracts + */ + public function displayContractDashboard() { + $contracts::where([ + 'finished' => false, + 'issuer_id' => auth()->user()->getId(), + ])->get(); + + return view('contracts.dashboard.main'); + } + + /** + * Display past contracts for the user + */ + public function displayPastContractsNew() { + $contracts = Contract::where([ + 'finished' => true, + 'issuer_id' => auth()->user()->getId(), + ])->get(); + + return view('contracts.dashboard.past')->with('contracts', $contracts); + } + + /** + * Display the page to create a new contract + */ + public function displayNewContractNew() { + return view('contracts.dashboard.new'); + } + + /** + * Store a new contract + */ + public function storeNewContractNew(Request $request) { + $this->validate($request, [ + 'name' => 'required', + 'date' => 'required', + 'body' => 'required', + 'type' => 'required', + ]); + + $lookup = new LookupHelper; + + $date = new Carbon($request->date); + $body = nl2br($request->body); + + $user_id = auth()->user()->getId(); + $name = auth()->user()->getName(); + $char = $lookup->GetCharacterInfo($user_id); + $corp = $lookup->GetCorporationInfo($char->corporation_id); + + //Store the contract in the database + $contract = new Contract; + $contract->issuer_id = auth()->user()->getId(); + $contract->issuer_name = auth()->user()->getName(); + $contract->title = $request->name; + $contract->end_date = $request->date; + $contract->body = $body; + $contract->type = $request->type; + $contract->save(); + + //Send a mail out to all of the people who can bid on a contract + $this->NewContractMail(); + + return redirect('/contracts/dashboard/main')->with('success', 'Contract posted.'); + } + + public function storeAcceptContractNew(Request $request) { + /** + * If the user is the contract owner, then continue. + * Otherwise, exit out with an error stating the person is not the contract owner. + */ + $this->validate($request, [ + 'contract_id' => 'required', + 'bid_id' => 'required', + 'character_id' => 'required', + 'bid_amount' => 'required', + ]); + + $check = + + Contract::where([ + 'contract_id' => $request->contract_id, + 'issuer_id' => auth()->user()->getId(), + ])->update([ + 'finished' => true, + 'final_cost' => $request->bid_amount, + ]); + } + /** * Controller function to display the bids placed on contracts */ diff --git a/app/Models/Contracts/Contract.php b/app/Models/Contracts/Contract.php index f6b3458c9..9beb1c83e 100644 --- a/app/Models/Contracts/Contract.php +++ b/app/Models/Contracts/Contract.php @@ -18,6 +18,10 @@ class Contract extends Model * @var array */ protected $fillable = [ + 'issuer_id', + 'issuer_name', + 'issuer_corp_id', + 'issuer_corp_name', 'title', 'type', 'end_date',