mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
1 Commits
dev
...
replicate-support
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b9c411c3d |
@@ -0,0 +1,120 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Classes\General\Interfaces\Documentable;
|
||||||
|
use App\Classes\General\Interfaces\Transactionable;
|
||||||
|
use App\Classes\General\Traits\LogData;
|
||||||
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
|
use App\Scopes\CustomerBookingsScope;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||||
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Booking
|
||||||
|
* @package App\Models
|
||||||
|
*
|
||||||
|
* @property \App\Models\Company company_id
|
||||||
|
* @property \App\Models\Bank transferable_bank_id
|
||||||
|
* @property string marking
|
||||||
|
* @property string reference
|
||||||
|
* @property float fix_amount
|
||||||
|
* @property int convertible_currency_id
|
||||||
|
* @property int conversion_currency_id
|
||||||
|
*/
|
||||||
|
class Booking extends AbstractModel implements Documentable, Transactionable
|
||||||
|
{
|
||||||
|
use HasRelationships;
|
||||||
|
use SoftDeletes;
|
||||||
|
use LogData;
|
||||||
|
|
||||||
|
protected $table = 'bookings';
|
||||||
|
|
||||||
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo
|
||||||
|
*/
|
||||||
|
public function company(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->BelongsTo(Company::class, 'company_id')->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo
|
||||||
|
*/
|
||||||
|
public function service(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->BelongsTo(ServiceType::class, 'service_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo
|
||||||
|
*/
|
||||||
|
public function bank(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->BelongsTo(Bank::class, 'bank_id')->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo
|
||||||
|
*/
|
||||||
|
public function fixedCurrency(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->BelongsTo(Currency::class, 'fix_currency_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo
|
||||||
|
*/
|
||||||
|
public function convertibleCurrency(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->BelongsTo(Currency::class, 'convertible_currency_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo
|
||||||
|
*/
|
||||||
|
public function conversionCurrency(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->BelongsTo(Currency::class, 'conversion_currency_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return MorphMany
|
||||||
|
*/
|
||||||
|
public function documents(): MorphMany
|
||||||
|
{
|
||||||
|
return $this->MorphMany(Document::class, 'owner');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return MorphMany
|
||||||
|
*/
|
||||||
|
public function transactions(): MorphMany
|
||||||
|
{
|
||||||
|
return $this->MorphMany(Transaction::class, 'owner');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return hasManyDeep
|
||||||
|
*/
|
||||||
|
public function bills(): hasManyDeep
|
||||||
|
{
|
||||||
|
return $this->hasManyDeep(Transaction::class, [Transaction::class.' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function booted()
|
||||||
|
{
|
||||||
|
if (auth()->user()) {
|
||||||
|
if (auth()->user()->type === RoleTypes::USER) {
|
||||||
|
static::addGlobalScope(new CustomerBookingsScope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
@extends('layouts.base_portal')
|
||||||
|
@section('inner_content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col bg-white p-t-15 p-b-15">
|
||||||
|
<div class="row no-margin">
|
||||||
|
<div class="col-12">
|
||||||
|
<form method="post" >
|
||||||
|
@csrf
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<input class="form-control" type="text" name="marking" placeholder="Marking" value="{{$marking}}">
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<input class="form-control" type="text" name="customer_email" placeholder="Email" value="{{$email}}">
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<input class="form-control" type="text" name="booking_reference" placeholder="Booking Reference" value="{{$bookingReference}}">
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button class="btn btn-complete" type="submit">Search</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<main>
|
||||||
|
@if($company)
|
||||||
|
@php
|
||||||
|
$employees = $company->employees;
|
||||||
|
$primaryEmployee = $employees->first();
|
||||||
|
$identification = $company->documents->whereIn('document_type', \App\Classes\ValueObjects\Constants\DocumentType::IDENTIFICATION_DOCUMENTS)->first()
|
||||||
|
@endphp
|
||||||
|
<section id="customer-account" class="m-b-50">
|
||||||
|
<h3>Customer Account</h3>
|
||||||
|
<p>Marking: <span><a href="{{route('customer.profile', $company->reference)}}" target="_blank">{{$company->reference}}</a></span></p>
|
||||||
|
<p>Account Type: <span>{{$company->type === 1 ? 'Business' : 'Personal'}}</span></p>
|
||||||
|
@if($company->type === 1)<p>Company's Name: <span>{{$company->name}}</span></p>@endif
|
||||||
|
<p>Customer's Name: <span>{{$employees->pluck('name')->implode(', ')}}</span></p>
|
||||||
|
<p>Email: <span>{{$employees->pluck('email')->implode(', ')}}</span></p>
|
||||||
|
<p>Phone: <span>{{$company->contacts->pluck('phone')->implode(', ')}}</span></p>
|
||||||
|
<p>Registration Date: <span>{{$company->created_at->format('d-m-Y')}}</span></p>
|
||||||
|
</section>
|
||||||
|
<section id="customer-verification" class="m-b-50">
|
||||||
|
<h3>Customer Verification</h3>
|
||||||
|
<p>Email Verification Status: <span>{{ $primaryEmployee->status === 2 ? 'Verified' : 'Pending Verification'}}</span></p>
|
||||||
|
<p>Identification Verification Status: <span>{{$identification ? ($identification->status === 2 ? 'Verified' : 'Pending Verification') : 'Not Submitted'}}</span></p>
|
||||||
|
</section>
|
||||||
|
@if(!$booking)
|
||||||
|
<section>
|
||||||
|
<h3>Customer Bookings</h3>
|
||||||
|
@php
|
||||||
|
$bookings = $company->bookings()->whereIn('status', [2, 3])->get();
|
||||||
|
@endphp
|
||||||
|
<section>
|
||||||
|
@foreach($bookings as $booking)
|
||||||
|
@php
|
||||||
|
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
|
||||||
|
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
|
||||||
|
@endphp
|
||||||
|
<section class="m-b-50">
|
||||||
|
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
|
||||||
|
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
|
||||||
|
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
|
||||||
|
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
|
||||||
|
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
|
||||||
|
@php $i = 1; @endphp
|
||||||
|
@foreach($payments as $payment)
|
||||||
|
@php
|
||||||
|
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
|
||||||
|
$transferProof = null;
|
||||||
|
$status = 'Pending Submission';
|
||||||
|
|
||||||
|
if($payment->status === 1) {
|
||||||
|
$status = 'Pending Approval';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($payment->status === 2) {
|
||||||
|
$status = 'Pending Confirmation';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array($payment->status, [4, 5])) {
|
||||||
|
$status = 'Rejected/Failed Payment';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($bill) {
|
||||||
|
if($bill->status === 1) {
|
||||||
|
$status = 'Pending Transfer Proof';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array($bill->status, [2, 3])) {
|
||||||
|
$status = 'Transfer Complete';
|
||||||
|
$transferProof = $bill->documents()->first();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@endphp
|
||||||
|
<section class="m-b-35">
|
||||||
|
<p>{{$i++}}.</p>
|
||||||
|
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
|
||||||
|
<p>Status: <span>{{$status}}</span></p>
|
||||||
|
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
|
||||||
|
@if($bill)
|
||||||
|
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
|
||||||
|
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
|
||||||
|
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
|
||||||
|
@endif
|
||||||
|
</section>
|
||||||
|
@endforeach
|
||||||
|
</section>
|
||||||
|
@endforeach
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
@if($booking)
|
||||||
|
@php
|
||||||
|
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
|
||||||
|
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
|
||||||
|
@endphp
|
||||||
|
<section>
|
||||||
|
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
|
||||||
|
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
|
||||||
|
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
|
||||||
|
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
|
||||||
|
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
|
||||||
|
@php $i = 1; @endphp
|
||||||
|
@foreach($payments as $payment)
|
||||||
|
@php
|
||||||
|
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
|
||||||
|
$transferProof = null;
|
||||||
|
|
||||||
|
$status = 'Pending Submission';
|
||||||
|
|
||||||
|
if($payment->status === 1) {
|
||||||
|
$status = 'Pending Approval';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($payment->status === 2) {
|
||||||
|
$status = 'Pending Confirmation';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array($payment->status, [4, 5])) {
|
||||||
|
$status = 'Rejected/Failed Payment';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($bill) {
|
||||||
|
if($bill->status === 1) {
|
||||||
|
$status = 'Pending Transfer Proof';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array($bill->status, [2, 3])) {
|
||||||
|
$status = 'Transfer Complete';
|
||||||
|
$transferProof = $bill->documents()->first();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@endphp
|
||||||
|
<section class="m-b-35">
|
||||||
|
<p>{{$i++}}.</p>
|
||||||
|
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
|
||||||
|
<p>Status: <span>{{$status}}</span></p>
|
||||||
|
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
|
||||||
|
@if($bill)
|
||||||
|
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
|
||||||
|
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
|
||||||
|
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
|
||||||
|
@endif
|
||||||
|
</section>
|
||||||
|
@endforeach
|
||||||
|
</section>
|
||||||
|
@endif
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -44,6 +44,8 @@ use Illuminate\Support\Facades\DB;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\Booking;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -795,4 +797,46 @@ Route::get('/invoices/approve', function(Request $request){
|
|||||||
|
|
||||||
})->name('invoices.approve');
|
})->name('invoices.approve');
|
||||||
|
|
||||||
|
Route::get('/support', function () {
|
||||||
|
return view('pages.customer_support', [
|
||||||
|
'marking' => null,
|
||||||
|
'email' => null,
|
||||||
|
'bookingReference' => null,
|
||||||
|
'company' => null,
|
||||||
|
'booking' => null
|
||||||
|
]);
|
||||||
|
})->name('support');
|
||||||
|
|
||||||
|
Route::post('/support', function (Request $request) {
|
||||||
|
|
||||||
|
$marking = $request->input('marking');
|
||||||
|
$email = $request->input('customer_email');
|
||||||
|
$bookingReference = $request->input('booking_reference');
|
||||||
|
|
||||||
|
$company = null;
|
||||||
|
$booking = null;
|
||||||
|
|
||||||
|
if($email) {
|
||||||
|
$company = Company::whereHas('Employees', function($user) use($email) {
|
||||||
|
return $user->where('email', $email);
|
||||||
|
})->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($marking) {
|
||||||
|
$company = Company::where('reference', $marking)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($bookingReference) {
|
||||||
|
$booking = Booking::where('marking', $bookingReference)->first();
|
||||||
|
$company = $booking->company;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.customer_support', [
|
||||||
|
'marking' => $marking,
|
||||||
|
'email' => $email,
|
||||||
|
'bookingReference' => $bookingReference,
|
||||||
|
'company' => $company,
|
||||||
|
'booking' => $booking,
|
||||||
|
]);
|
||||||
|
|
||||||
|
})->name('support');
|
||||||
Reference in New Issue
Block a user