mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-25 15:34:02 +00:00
Merge branch 'dillon/110-period-lock' into vapor/development
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanCreateBooking;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBookingLockLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Booking Locked',
|
||||
'message' => 'You have successfully lock Booking from editing'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateBooking */
|
||||
private $canCreateBooking;
|
||||
|
||||
/** @var FetchesBooking */
|
||||
private $fetchesBooking;
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreatesKeyValuePair */
|
||||
private $createsKeyValuePair;
|
||||
|
||||
/**
|
||||
* CreateBookingLockLogic constructor.
|
||||
* @param CanCreateBooking $canCreateBooking
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesKeyValuePair $createsKeyValuePair
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
*/
|
||||
public function __construct(CanCreateBooking $canCreateBooking, FetchesCompany $fetchesCompany, CreatesKeyValuePair $createsKeyValuePair, FetchesBooking $fetchesBooking)
|
||||
{
|
||||
$this->canCreateBooking = $canCreateBooking;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsKeyValuePair = $createsKeyValuePair;
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
// $password = $request->input('password');
|
||||
// if($password !== 'prototype'){
|
||||
// throw new AccessForbiddenException('Incorrect Password');
|
||||
// }
|
||||
|
||||
$booking = $this->fetchesBooking->execute(['id' => $request->input('booking_id')]);
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::BOOKING_IS_LOCKED, 1);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
private function updateOrCreateKeyValuePair($booking, $key, $value)
|
||||
{
|
||||
$booking->attributesKVP()->updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $value]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanDeleteBooking;
|
||||
use App\Classes\Modules\Bookings\Services\DeletesBooking;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class DeleteBookingLockLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Booking Unlock',
|
||||
'message' => 'You have successfully unlock the Booking for editing'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanDeleteBooking */
|
||||
private $canDeleteBooking;
|
||||
|
||||
/** @var DeletesBooking */
|
||||
private $deletesBooking;
|
||||
|
||||
/** @var FetchesBooking */
|
||||
private $fetchesBooking;
|
||||
|
||||
|
||||
public function __construct(
|
||||
CanDeleteBooking $canDeleteBooking,
|
||||
DeletesBooking $deletesBooking,
|
||||
FetchesBooking $fetchesBooking
|
||||
)
|
||||
{
|
||||
$this->canDeleteBooking = $canDeleteBooking;
|
||||
$this->deletesBooking = $deletesBooking;
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$password = $request->input('password');
|
||||
if($password !== 'prototype'){
|
||||
throw new AccessForbiddenException('Incorrect Password');
|
||||
}
|
||||
|
||||
$booking = $this->fetchesBooking->execute(['id' => $request->route('id')]);
|
||||
$booking->attributesKVP()->where('key', KVPKey::BOOKING_IS_LOCKED)->delete();
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,13 +14,16 @@ use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
use App\Classes\Modules\Rules\DataTransferObjects\CheckTransferPeriodLockRuleVariant2DTO;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding;
|
||||
|
||||
use App\Classes\Modules\Rules\Services\RuleEvaluator;
|
||||
use App\Classes\Modules\Rules\Standards\Rules\CanPassTransferPeriodLockRule;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\CriteriaNotFulfilledException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateBookingAmountLogic extends AbstractControllerLogic
|
||||
@@ -52,6 +55,12 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var RuleEvaluator */
|
||||
private $ruleEvaluator;
|
||||
|
||||
/** @var CanPassTransferPeriodLockRule */
|
||||
private $canPassTransferPeriodLockRule;
|
||||
|
||||
/**
|
||||
* UpdateBookingAmountLogic constructor.
|
||||
* @param CanUpdateBooking $canUpdateBooking
|
||||
@@ -59,29 +68,47 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
* @param CalculatesBookingOutstanding $calculatesBookingOutstanding
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param RuleEvaluator $ruleEvaluator
|
||||
* @param CanPassTransferPeriodLockRule $canPassTransferPeriodLockRule
|
||||
*/
|
||||
public function __construct(CanUpdateBooking $canUpdateBooking, UpdatesBookingFixedAmount $updatesBookingFixedAmount, FetchesBooking $fetchesBooking, CalculatesBookingOutstanding $calculatesBookingOutstanding, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
public function __construct(CanUpdateBooking $canUpdateBooking, UpdatesBookingFixedAmount $updatesBookingFixedAmount, FetchesBooking $fetchesBooking, CalculatesBookingOutstanding $calculatesBookingOutstanding, UpdatesTransactionStatus $updatesTransactionStatus, RuleEvaluator $ruleEvaluator, CanPassTransferPeriodLockRule $canPassTransferPeriodLockRule)
|
||||
{
|
||||
$this->canUpdateBooking = $canUpdateBooking;
|
||||
$this->updatesBookingFixedAmount = $updatesBookingFixedAmount;
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
$this->calculatesBookingOutstanding = $calculatesBookingOutstanding;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->ruleEvaluator = $ruleEvaluator;
|
||||
$this->canPassTransferPeriodLockRule = $canPassTransferPeriodLockRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws MalformedRequestException
|
||||
* @throws CriteriaNotFulfilledException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
//cief todo: Prototype Period Lock - Starts
|
||||
$reqData['id'] = $request->route('id');
|
||||
$dto = new CheckTransferPeriodLockRuleVariant2DTO($reqData);
|
||||
|
||||
$result = $this->ruleEvaluator->evaluate([
|
||||
$this->canPassTransferPeriodLockRule,
|
||||
], $dto);
|
||||
|
||||
if ($result->failed()) {
|
||||
throw new CriteriaNotFulfilledException("- " . implode("<br>- ", $result->messages()));
|
||||
}
|
||||
//cief todo: Prototype Period Lock - Ends
|
||||
|
||||
$booking = $this->fetchesBooking->execute(['id' => $request->route('id')]);
|
||||
|
||||
$input_amount = number_format( floatval(str_replace(',', '', $request->input('fix_amount', $booking->fix_amount))), 5, '.', '');
|
||||
|
||||
$minimum_amount = $booking->fix_amount - $this->calculatesBookingOutstanding->execute($booking);
|
||||
|
||||
|
||||
if (((float)$input_amount + 0.01) < (float)$minimum_amount) {
|
||||
$input_amount = 0;
|
||||
// throw new MalformedRequestException('Booking Amount cannot be less than '. $minimum_amount .'.');
|
||||
@@ -100,4 +127,4 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic
|
||||
return $this->resourceResponse(new BookingResource($booking));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Rules\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\CriteriaNotFulfilledException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Rules\DataTransferObjects\CheckTransferPeriodLockRuleDTO;
|
||||
use App\Classes\Modules\Rules\Services\RuleEvaluator;
|
||||
use App\Classes\Modules\Rules\Standards\Rules\CanPassTransferPeriodLockRule;
|
||||
use App\Http\Resources\RuleResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CheckTransferPeriodLockRuleLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Rule Check Transfer Period Lock',
|
||||
'message' => 'You have successfully passed all rules evaluated'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var RuleEvaluator */
|
||||
private $ruleEvaluator;
|
||||
|
||||
/** @var CanPassTransferPeriodLockRule */
|
||||
private $canPassTransferPeriodLockRule;
|
||||
|
||||
/**
|
||||
* CheckTransferPeriodLockRuleLogic constructor.
|
||||
* @param RuleEvaluator $ruleEvaluator
|
||||
* @param CanPassTransferPeriodLockRule $canPassTransferPeriodLockRule
|
||||
*/
|
||||
public function __construct(RuleEvaluator $ruleEvaluator, CanPassTransferPeriodLockRule $canPassTransferPeriodLockRule)
|
||||
{
|
||||
$this->ruleEvaluator = $ruleEvaluator;
|
||||
$this->canPassTransferPeriodLockRule = $canPassTransferPeriodLockRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\CriteriaNotFulfilledException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$dto = new CheckTransferPeriodLockRuleDTO($request->all());
|
||||
|
||||
$result = $this->ruleEvaluator->evaluate([
|
||||
$this->canPassTransferPeriodLockRule,
|
||||
], $dto);
|
||||
|
||||
if ($result->failed()) {
|
||||
throw new CriteriaNotFulfilledException("- " . implode("<br>- ", $result->messages()));
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new RuleResource((object)$result));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Rules\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CheckTransferPeriodLockRuleDTO implements DataTransferObject
|
||||
{
|
||||
public int $bookingId;
|
||||
public int $companyId;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->bookingId = $data['booking_id'];
|
||||
$this->companyId = $data['company_id'];
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'booking_id' => $this->bookingId,
|
||||
'company_id' => $this->companyId,
|
||||
];
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Rules\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CheckTransferPeriodLockRuleVariant2DTO implements DataTransferObject
|
||||
{
|
||||
public int $bookingId;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->bookingId = $data['id'];
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->bookingId,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Rules\Standards\Rules;
|
||||
|
||||
use App\Classes\Exceptions\CriteriaNotFulfilledException;
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CanPassTransferPeriodLockRule extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var FetchesBooking */
|
||||
private $fetchesBooking;
|
||||
|
||||
|
||||
/**
|
||||
* CanPassTransferPeriodLockRule constructor.
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
*/
|
||||
public function __construct(FetchesBooking $fetchesBooking)
|
||||
{
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
$booking = $this->fetchesBooking->execute(['id' => $object->bookingId]);
|
||||
$bookingAttribute = $booking->attributesKVP()->where('key', KVPKey::BOOKING_IS_LOCKED)->first();
|
||||
|
||||
if($bookingAttribute && in_array(Auth::user()->type, RoleTypes::ADMIN_ROLES)){
|
||||
throw new CriteriaNotFulfilledException("Booking is locked for edit.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\Jobs\SendUserPaymentProofUploadedEmail;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Models\Company;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -92,6 +93,10 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->createInvoiceTransactionProcessor->execute($transaction->owner->booking);
|
||||
|
||||
//cief todo: Prototype Period Lock - Starts
|
||||
$this->updateOrCreateKeyValuePair($transaction->owner->booking, KVPKey::BOOKING_IS_LOCKED, 1);
|
||||
//cief todo: Prototype Period Lock - Ends
|
||||
|
||||
// send email to customer
|
||||
// todo: a function to send a proof to the receipiant, they have to give us a email of the receipiant and also need to submiited purchase order
|
||||
$companyEmployee = $transaction->owner->booking->company->employees;
|
||||
@@ -104,4 +109,11 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
private function updateOrCreateKeyValuePair($booking, $key, $value)
|
||||
{
|
||||
$booking->attributesKVP()->updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $value]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@ class KVPKey
|
||||
|
||||
public const BOOKING_EINVOICE_ELIGIBLE = 'BOOKING_EINVOICE_ELIGIBLE';
|
||||
|
||||
public const BOOKING_IS_LOCKED = 'BOOKING_IS_LOCKED';
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use App\Classes\Modules\Bookings\ControllersLogic\CreateBookingLockLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBookingLockController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateBookingLockLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateBookingLockLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use App\Classes\Modules\Bookings\ControllersLogic\DeleteBookingLockLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteBookingLockController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteBookingLockLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteBookingLockLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Rules;
|
||||
use App\Classes\Modules\Rules\ControllersLogic\CheckEInvoiceRuleLogic;
|
||||
use App\Classes\Modules\Rules\ControllersLogic\CheckPurchaseOrderRuleLogic;
|
||||
use App\Classes\Modules\Rules\ControllersLogic\CheckTransferRuleLogic;
|
||||
use App\Classes\Modules\Rules\ControllersLogic\CheckTransferPeriodLockRuleLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -36,4 +37,13 @@ class CheckRuleController
|
||||
public function checkTransferRule(Request $request, CheckTransferRuleLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CheckTransferPeriodLockRuleLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function checkTransferPeriodLockRule(Request $request, CheckTransferPeriodLockRuleLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
+49
-7
@@ -1,6 +1,21 @@
|
||||
<template>
|
||||
<div class="row parentContainer">
|
||||
<div class="col">
|
||||
<!-- cief todo: Prototype Period Lock - Starts -->
|
||||
<button v-if="booking && !locked && lockInitialized && $store.getters.isAdmin" @click="lock">
|
||||
🔒 Lock Page
|
||||
</button>
|
||||
|
||||
<page-lock v-if="booking"
|
||||
:active="locked"
|
||||
:section="section + 'PeriodLock'"
|
||||
:company-id="booking.company.id"
|
||||
:booking-id="booking.id"
|
||||
:password="''"
|
||||
v-on:lock="lock"
|
||||
v-on:initializeLock="initializeLock">
|
||||
</page-lock>
|
||||
<!-- cief todo: Prototype Period Lock - Ends -->
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
|
||||
<div class="row" v-show="!isLoading" v-if="booking">
|
||||
<div class="col-md col-sm-12 m-b-20">
|
||||
@@ -423,7 +438,7 @@
|
||||
<div class="col-12 col-sm-12 col-md-5 mt-3 mt-sm-0">
|
||||
<!-- <booking-payment-quotation-component :data="booking" :section="section"></booking-payment-quotation-component> -->
|
||||
<booking-payment-quotation-v2-component :data="booking" :section="section"></booking-payment-quotation-v2-component>
|
||||
<div class="row m-t-20" v-if="booking.payment_attempts.length">
|
||||
<div class="row m-t-20" v-if="booking.payment_attempts && booking.payment_attempts.length">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
@@ -497,7 +512,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20" v-if="booking.expired_payment_attempts.length">
|
||||
<div class="row m-t-20" v-if="booking.expired_payment_attempts && booking.expired_payment_attempts.length">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
@@ -546,7 +561,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20" v-if="booking.payment_history.length">
|
||||
<div class="row m-t-20" v-if="booking.payment_history && booking.payment_history.length">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
@@ -563,7 +578,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col" v-if="booking.payment_history.length">
|
||||
<div class="col" v-if="booking.payment_history && booking.payment_history.length">
|
||||
<div class="alert alert-danger padding-15" role="alert">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@@ -609,7 +624,9 @@
|
||||
attention: false,
|
||||
bearShowing: false,
|
||||
oneSixEightEightServiceIds: [4, 10],
|
||||
parameters: {}
|
||||
parameters: {},
|
||||
locked: true,
|
||||
lockInitialized: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -678,7 +695,10 @@
|
||||
if(section === this.section + 'CheckTransferRule'){
|
||||
window.location.href = route('billplz.bill', payload.payment_reference);
|
||||
}
|
||||
else
|
||||
else if(section === this.section + 'Lock'){
|
||||
this.locked = true;
|
||||
}
|
||||
else if(section === this.section)
|
||||
{
|
||||
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
|
||||
this.isLoading = false;
|
||||
@@ -689,7 +709,7 @@
|
||||
if(section === this.section + 'CheckTransferRule' && statusCode === 422){
|
||||
console.log('Transfer expired, please create new transfer');
|
||||
}
|
||||
else{
|
||||
else if(section === this.section){
|
||||
window.location.href = this.route('dashboard');
|
||||
}
|
||||
},
|
||||
@@ -708,6 +728,28 @@
|
||||
};
|
||||
this.submit(route('api.rule.check.transfer'), 'post', this.section + 'CheckTransferRule', false, true);
|
||||
},
|
||||
initializeLock(state) {
|
||||
this.lockInitialized = true;
|
||||
this.locked = state;
|
||||
},
|
||||
lock(state){
|
||||
this.lockInitialized = true;
|
||||
this.parameters = {
|
||||
booking_id: this.booking.id,
|
||||
};
|
||||
if(state){
|
||||
this.submit(
|
||||
route("api.booking.create.lock"),
|
||||
"post",
|
||||
this.section + 'Lock',
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
else{
|
||||
this.locked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<transition name="fade">
|
||||
<div v-if="localActive" class="overlay-lock">
|
||||
<div class="backdrop">
|
||||
|
||||
</div>
|
||||
<div class="content" v-if="!isLoading">
|
||||
<div class="lock-box">
|
||||
<p>To edit, please enter the password to unlock page:</p>
|
||||
|
||||
<input
|
||||
v-model="passwordInput"
|
||||
type="password"
|
||||
placeholder="Enter password"
|
||||
class="password-input"
|
||||
@keyup.enter="verifyPassword"
|
||||
/>
|
||||
|
||||
<button @click="verifyPassword" class="unlock-btn">
|
||||
Unlock
|
||||
</button>
|
||||
|
||||
<p v-if="errorMessage" class="error">{{ errorMessage }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "PageLock",
|
||||
props: {
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
section: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
companyId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
bookingId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
default: "1234", // 🔐 Default password (you can override in parent)
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
pendingQueue() {
|
||||
return this.$store.getters.isInCompleteQueue(this.section);
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
localActive: this.active,
|
||||
passwordInput: "",
|
||||
errorMessage: "",
|
||||
isLoading: true,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
active(newVal) {
|
||||
this.localActive = newVal;
|
||||
},
|
||||
pendingQueue(inComplete) {
|
||||
if (inComplete) {
|
||||
this.fetchStatus();
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch("updateListQueue", { name: this.section });
|
||||
},
|
||||
methods: {
|
||||
fetchStatus() {
|
||||
this.isLoading = true;
|
||||
this.parameters = {
|
||||
booking_id: this.bookingId,
|
||||
company_id: this.companyId,
|
||||
};
|
||||
this.submit(
|
||||
route("api.rule.check.transfer.period.lock"),
|
||||
"post",
|
||||
this.section,
|
||||
false,
|
||||
false
|
||||
);
|
||||
},
|
||||
successHandler(response, section, payload) {
|
||||
console.log('response: ' , JSON.stringify(response));
|
||||
console.log('section: ' , JSON.stringify(section));
|
||||
console.log('payload: ' , JSON.stringify(payload));
|
||||
if(section === this.section){
|
||||
this.$emit("initializeLock", false); // emit unlock
|
||||
this.localActive = false;
|
||||
}
|
||||
if(section === this.section + 'UnLock'){
|
||||
this.$emit("lock", false); // emit unlock
|
||||
this.localActive = false;
|
||||
this.passwordInput = '';
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.isLoading = false;
|
||||
}, 2000);
|
||||
},
|
||||
errorHandler(response, statusCode, section) {
|
||||
this.isLoading = false;
|
||||
if (statusCode === 422) {
|
||||
// this.$emit("lock", true);
|
||||
}
|
||||
else if(statusCode === 403) {
|
||||
this.errorMessage = response.message;
|
||||
}
|
||||
},
|
||||
verifyPassword() {
|
||||
// if (this.passwordInput === this.password) {
|
||||
this.errorMessage = "";
|
||||
this.parameters = {
|
||||
booking_id: this.bookingId,
|
||||
password: this.passwordInput,
|
||||
};
|
||||
this.submit(
|
||||
route("api.booking.delete.lock", this.bookingId),
|
||||
"delete",
|
||||
this.section + 'UnLock',
|
||||
false,
|
||||
true
|
||||
);
|
||||
// } else {
|
||||
// this.errorMessage = "Incorrect password. Please try again.";
|
||||
// }
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.overlay-lock {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: auto;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.lock-box {
|
||||
background: white;
|
||||
border-radius: 1rem;
|
||||
padding: 2rem 3rem;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
|
||||
text-align: center;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
.password-input {
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.unlock-btn {
|
||||
margin-top: 1rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border: none;
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.unlock-btn:hover {
|
||||
background: #43a047;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
</style>
|
||||
@@ -3,6 +3,8 @@
|
||||
use App\Http\Controllers\Bookings\RegenerateBookingPaymentRVController;
|
||||
use App\Http\Controllers\Bookings\RegenerateBookingEInvoiceController;
|
||||
use App\Http\Controllers\Bookings\UpdateBookingAmountController;
|
||||
use App\Http\Controllers\Bookings\CreateBookingLockController;
|
||||
use App\Http\Controllers\Bookings\DeleteBookingLockController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Bookings'], function () {
|
||||
@@ -10,6 +12,8 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking
|
||||
Route::get('/list', 'ListBookingsController@list')->name('list');
|
||||
Route::get('/list/job', 'ListBookingsJobController@list')->name('list.job');
|
||||
Route::post('/create', 'CreateBookingController@create')->name('create');
|
||||
Route::post('/create/lock', [CreateBookingLockController::class, 'create'])->name('create.lock');
|
||||
Route::delete('/delete/lock/{id}', [DeleteBookingLockController::class, 'delete'])->name('delete.lock');
|
||||
Route::put('/update/{id}', 'UpdateBookingController@update')->name('update');
|
||||
Route::put('/recipient/update/{id}', 'UpdateBookingRecipientController@update')->name('update.recipient');
|
||||
Route::put('/cancel/{id}', 'CancelBookingController@cancel')->name('cancel');
|
||||
|
||||
@@ -9,4 +9,6 @@ Route::prefix('rule')
|
||||
Route::post('/check/eInvoice', [CheckRuleController::class, 'checkEInvoiceRule'])->name('check.einvoice');
|
||||
Route::post('/check/purchase-order', [CheckRuleController::class, 'checkPurchaseOrderRule'])->name('check.purchase.order');
|
||||
Route::post('/check/tranfer', [CheckRuleController::class, 'checkTransferRule'])->name('check.transfer');
|
||||
|
||||
Route::post('/check/tranfer/period-lock', [CheckRuleController::class, 'checkTransferPeriodLockRule'])->name('check.transfer.period.lock');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user