adds most of the fields for an accessory eula agreement pdf

This commit is contained in:
Godfrey M 2022-03-21 09:18:29 -07:00
parent b2e78e3382
commit 220df9710e
3 changed files with 96 additions and 26 deletions

View file

@ -13,12 +13,16 @@ use App\Models\CheckoutAcceptance;
use App\Models\Company; use App\Models\Company;
use App\Models\Contracts\Acceptable; use App\Models\Contracts\Acceptable;
use App\Models\User; use App\Models\User;
use App\Models\AssetModel;
use App\Models\Accessory;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Http\Controllers\SettingsController; use App\Http\Controllers\SettingsController;
use Barryvdh\DomPDF\Facade\Pdf; use Barryvdh\DomPDF\Facade\Pdf;
use Carbon\Carbon;
class AcceptanceController extends Controller class AcceptanceController extends Controller
{ {
@ -129,30 +133,60 @@ class AcceptanceController extends Controller
} }
$item = $acceptance->checkoutable_type::find($acceptance->checkoutable_id); $item = $acceptance->checkoutable_type::find($acceptance->checkoutable_id);
$assigned_to = User::find($item->assigned_to);
$branding_settings= SettingsController::getPDFBranding(); if ($acceptance->checkoutable_type== 'App\Models\Asset') {
$data = [ $assigned_to = User::find($item->assigned_to);
'item_tag' => $item->asset_tag, $asset_model = AssetModel::find($item->model_id);
'item_model' => $item->model_id, $branding_settings = SettingsController::getPDFBranding();
'item_serial' => $item->serial, $data = [
'eula' => $item->getEula(), 'item_tag' => $item->asset_tag,
'check_out_date' => $acceptance->created_at, 'item_model' => $asset_model->name,
'accepted_date' => $acceptance->accepted_at, 'item_serial' => $item->serial,
'eula' => $item->getEula(),
'check_out_date' => Carbon::parse($acceptance->created_at)->format($branding_settings->date_display_format),
'accepted_date' => Carbon::parse($acceptance->accepted_at)->format($branding_settings->date_display_format),
// 'assigned_by' => self // 'assigned_by' => self
'assigned_to' => $assigned_to->first_name.' '.$assigned_to->last_name, 'assigned_to' => $assigned_to->first_name . ' ' . $assigned_to->last_name,
'company_name' => $branding_settings->site_name, 'company_name' => $branding_settings->site_name,
'signature' => storage_path().'/private_uploads/signatures/'.$sig_filename, 'signature' => storage_path() . '/private_uploads/signatures/' . $sig_filename,
'logo' => public_path().'/uploads/'.$branding_settings->logo, 'logo' => public_path() . '/uploads/' . $branding_settings->logo,
'date_settings' => $branding_settings->date_display_format, 'date_settings' => $branding_settings->date_display_format,
];
$pdf = Pdf::loadView('account.accept.accept-asset-eula', $data);
Storage::put('private_uploads/eula-pdfs/' . $acceptance->stored_eula_file, $pdf->output());
$a = new Actionlog();
$a->stored_eula = $item->getEula();
$a->stored_eula_file = $acceptance->stored_eula_file;
$a->save();
return redirect()->to('account/accept')->with('success', $return_msg);
}
// TBC: trying to get the user_id here
$accessory_user= DB::table('accessories_users')->find($acceptance->assigned_to_id);
$assigned_to = User::find($accessory_user);
$accessory_model = Accessory::find($item->id);
$branding_settings = SettingsController::getPDFBranding();
$data = [
'item_tag' => $item->model_number,
'item_model' => $accessory_model->name,
'eula' => $item->getEula(),
'check_out_date' => Carbon::parse($acceptance->created_at)->format($branding_settings->date_display_format),
'accepted_date' => Carbon::parse($acceptance->accepted_at)->format($branding_settings->date_display_format),
// 'assigned_by' => self
'assigned_to' => $assigned_to->first_name . ' ' . $assigned_to->last_name,
'company_name' => $branding_settings->site_name,
'signature' => storage_path() . '/private_uploads/signatures/' . $sig_filename,
'logo' => public_path() . '/uploads/' . $branding_settings->logo,
'date_settings' => $branding_settings->date_display_format,
]; ];
$pdf = Pdf::loadView('account.accept.accept-accessory-eula', $data);
Storage::put('private_uploads/eula-pdfs/' . $acceptance->stored_eula_file, $pdf->output());
$pdf = Pdf::loadView('account.accept.accept-eula', $data); $a = new Actionlog();
Storage::put('private_uploads/eula-pdfs/'.$acceptance->stored_eula_file, $pdf->output()); $a->stored_eula = $item->getEula();
$a->stored_eula_file = $acceptance->stored_eula_file;
$a=new Actionlog(); $a->save();
$a->stored_eula = $item->getEula();
$a->stored_eula_file = $acceptance->stored_eula_file;
$a->save();
return redirect()->to('account/accept')->with('success', $return_msg); return redirect()->to('account/accept')->with('success', $return_msg);
} }

View file

@ -10,6 +10,7 @@
@if ($signature) @if ($signature)
<center> <center>
<img src="{{ $logo }}"> <img src="{{ $logo }}">
<p>{{$company_name}}</p>
</center> </center>
@endif @endif
<br> <br>
@ -17,16 +18,14 @@
<p>Date: {{ date($date_settings) }} </p><br> <p>Date: {{ date($date_settings) }} </p><br>
<p>Asset Tag: {{ $item_tag }}</p> <p>Asset Tag: {{ $item_tag }}</p>
<p>Asset Model: {{ $item_model }}</p> <p>Asset Model: {{ $item_model }}</p>
<p>Asset Tag: {{ $item_serial }}</p><br>
@if ($eula) @if ($eula)
{!! $eula !!} {!! $eula !!}
@endif @endif
<br><br> <br>
<p> On {{$check_out_date}} {{$company_name}} is assigning item {{$item_tag}} to {{$assigned_to}}. <br>
They accept responsibility of said item until it is returned.</p><br>
<p>Assigned on: {{$check_out_date}}</p> <p>Assigned on: {{$check_out_date}}</p>
<p>Accepted on: {{$accepted_date}}</p><br> <p>Accepted on: {{$accepted_date}}</p>
<p>Assigned to: {{$assigned_to}}</p> <p>Assigned to: {{$assigned_to}}</p>
@if ($signature) @if ($signature)
<center> <center>

View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
</head>
<body>
@if ($signature)
<center>
<img src="{{ $logo }}">
<p>{{$company_name}}</p>
</center>
@endif
<br>
<p>Date: {{ date($date_settings) }} </p><br>
<p>Asset Tag: {{ $item_tag }}</p>
<p>Asset Model: {{ $item_model }}</p>
<p>Asset Serial: {{ $item_serial }}</p><br>
@if ($eula)
{!! $eula !!}
@endif
<br>
<p>Assigned on: {{$check_out_date}}</p>
<p>Accepted on: {{$accepted_date}}</p>
<p>Assigned to: {{$assigned_to}}</p>
@if ($signature)
<center>
<img src="{{ $signature }}" style="max-width: 50%">
</center>
@endif
</body>
</html>