Compare commits

...

44 Commits

Author SHA1 Message Date
Dillon 0e79bbfd6a Quick undo experimental security check 2023-10-16 13:24:30 +08:00
Dillon Ngo 3a411e8b9a Merge branch 'dillon/44-customer-satisfaction-feedback-project-b' into 'master'
Preparation for help menu

See merge request CIEFWorldwideSdnBhd/shipping-portal!175
2023-10-15 17:16:57 +00:00
Dillon Ngo d17beda04b Merge branch 'dillon/44-customer-satisfaction-feedback-project' into 'master'
New Feedback Form for gathering feedback from customer

See merge request CIEFWorldwideSdnBhd/shipping-portal!174
2023-10-15 10:19:13 +00:00
Dillon 7acc6932b5 Merge branch 'master' into dillon/44-customer-satisfaction-feedback-project 2023-10-15 18:07:26 +08:00
edmondlang 31905e56be enable top up for superadmin 2023-10-13 15:00:30 +08:00
edmondlang 6508155aea fix group payment not showing in wallet transaction history 2023-10-12 13:17:24 +08:00
edmondlang 760f8684ea fix group payment not showing in wallet transaction history 2023-10-12 13:12:50 +08:00
edmondlang 979b8b2ef9 show accident-approve-invoice 2023-10-12 13:06:51 +08:00
edmondlang 9a0073e906 add company active wallet web 2023-10-12 12:43:35 +08:00
edmondlang 976e54bb4c temporary disable wallet top up 2023-10-11 17:33:22 +08:00
edmondlang 87226377be update packinglist measurement template 2023-10-09 20:38:53 +08:00
edmondlang 674fd84fa0 update packinglist measurement template 2023-10-09 20:31:02 +08:00
edmondlang da1ed10740 update packinglist measurement template 2023-10-09 20:30:36 +08:00
edmondlang eb73d20b00 update packinglist measurement 2023-10-09 20:27:42 +08:00
edmondlang 158fa2eefe Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into add-delivery-order-to-invoice 2023-10-09 00:26:24 +08:00
edmondlang fa4cfc0d75 debug billplz 2023-10-08 23:53:39 +08:00
edmondlang f87bcff930 update packinglist measurement 2023-10-08 21:48:47 +08:00
Dillon e774962c44 Backend validation for generating feedback url 2023-10-08 18:58:43 +08:00
Dillon 0a14a64fbb Security Patch - Retrieving list of packing list 2023-10-08 16:56:15 +08:00
Dillon ee5051fc26 Merge branch 'dillon/44-customer-satisfaction-feedback-project-e' into dillon/44-customer-satisfaction-feedback-project 2023-10-08 05:25:57 +08:00
Dillon 034c93091a Security Patch - Exporting packinglist data to excel file 2023-10-08 05:25:38 +08:00
Dillon 8b184313cb Error 500 fix 2023-10-08 05:14:03 +08:00
Dillon c2b097e6d1 Merge branch 'dillon/44-customer-satisfaction-feedback-project-e' into dillon/44-customer-satisfaction-feedback-project 2023-10-08 05:12:58 +08:00
Dillon b0195a9640 Merge branch 'dillon/44-customer-satisfaction-feedback-project-d' into dillon/44-customer-satisfaction-feedback-project 2023-10-08 04:55:39 +08:00
Dillon 38d69434fa Security Patch - Exporting packinglist data to excel file 2023-10-08 04:54:38 +08:00
Dillon 1b559f91a2 Security Patch - Exporting feedback data to excel file 2023-10-08 03:50:19 +08:00
edmondlang 05a21af5a6 add line break on top of the file 2023-10-07 18:58:47 +08:00
edmondlang 3e7fbdbafc update packinglist mearuement in invoice 2023-10-07 17:56:47 +08:00
Dillon 527eca50fe Minor UI Fix 2023-10-07 08:42:53 +08:00
Dillon d010a8f8c7 Function for admin to export feedback data 2023-10-07 08:12:52 +08:00
Dillon 7bc2ca512a Function for admin to export feedback data 2023-10-07 07:33:51 +08:00
Dillon b76e0ebeef Merge branch 'dillon/44-customer-satisfaction-feedback-project-a' into dillon/44-customer-satisfaction-feedback-project 2023-10-07 07:33:07 +08:00
Dillon f595c43f2c Function for admin to export feedback data 2023-10-07 07:24:06 +08:00
Jia Sheng Lee 553d2c44aa add delivery order to shipping invoice 2023-10-04 16:53:11 +08:00
Dillon 3f1a8a6d12 Security patch for generating feedback url (for internal and external api calling) 2023-09-30 17:06:36 +08:00
Dillon 2240c1723d Merge branch 'dillon/44-customer-satisfaction-feedback-project' into dillon/44-customer-satisfaction-feedback-project-a 2023-09-30 15:30:10 +08:00
edmondlang c493b3786c update credit_note pdf 2023-09-25 22:34:13 +08:00
Dillon 25417ba5be New api for public use to get feedback url 2023-09-21 21:31:25 +08:00
edmondlang 99f4699260 update wallet credit note 2023-09-15 18:42:14 +08:00
edmondlang 0ea52048e1 update wallet credit note 2023-09-15 18:37:04 +08:00
edmondlang a47bb95e50 update wallet credit note 2023-09-15 18:32:36 +08:00
edmondlang 431aed18d3 update wallet credit note 2023-09-15 18:03:39 +08:00
edmondlang 6ab289057b wallet credit note 2023-09-15 17:34:16 +08:00
JiaSheng c55a8e7af9 fix account statement mapping issue 2023-09-14 14:59:02 +08:00
155 changed files with 1255 additions and 730 deletions
@@ -0,0 +1,97 @@
<?php
namespace App\Classes\General\Abstracts;
use App\Classes\Exceptions\ErrorException;
use App\Classes\Exceptions\InternalServerErrorException;
use App\Classes\ValueObjects\Constants\Notifications;
use App\Classes\ValueObjects\Constants\HttpStatus;
use App\Classes\ValueObjects\Response\ApiResponseObject;
use ErrorException as GeneralExceptions;
use TypeError;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Facades\DB;
abstract class Abstract2ControllerLogic
{
/**
* @return array
*/
abstract protected function notification(): array;
/**
* @return string
*/
private function getNotificationTitle():string {
return $this->notification()['title'] ? $this->notification()['title']: Notifications::UNDEFINED['title'];
}
/**
* @return string
*/
private function getNotificationMessage():string {
return $this->notification()['message'] ? $this->notification()['message']: Notifications::UNDEFINED['message'];
}
/**
* @param Request $request
* @return BinaryFileResponse
* @throws ErrorException
*/
abstract protected function logic(Request $request) : BinaryFileResponse;
/**
* @param Request $request
* @return BinaryFileResponse
*/
public function execute(Request $request) : BinaryFileResponse {
try {
DB::beginTransaction();
$response = $this->logic($request);
DB::commit();
return $response;
} catch (ErrorException|GeneralExceptions|TypeError $exception){
abort(404, $exception->getMessage());
}
}
/**
* @param array|null $data
* @return JsonResponse
*/
public function response(?array $data = []) : JsonResponse {
return (new ApiResponseObject($this->getNotificationTitle().' Successful',
$this->getNotificationMessage(),
HttpStatus::OK_WITH_MESSAGE, $data))->handler();
}
/**
* @param JsonResource $resource
* @return JsonResponse
*/
public function resourceResponse(JsonResource $resource){
return $this->response(['data' => $resource]);
}
/**
* @param ResourceCollection $collection
* @return JsonResponse
*/
public function collectionResponse(ResourceCollection $collection){
return $this->response(json_decode($collection->response()->getContent(), true));
}
}
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
abstract class AbstractRule
{
abstract protected function authorized(): bool;
abstract protected function authorized($object): bool;
abstract protected function validators($object): bool;
@@ -26,8 +26,8 @@ abstract class AbstractRule
*/
public function passes(?DataTransferObject $object = null): bool {
try {
if(!$this->authorized()){
throw new AccessForbiddenException('You don\'t have permission to preform this action');
if(!$this->authorized($object)){
throw new AccessForbiddenException('You don\'t have permission to perform this action');
}
$this->validators($object);
@@ -36,11 +36,11 @@ abstract class AbstractRule
return true;
} catch(AccessForbiddenException $exception){
throw new AccessForbiddenException('You don\'t have permission to preform this action');
throw new AccessForbiddenException('You don\'t have permission to perform this action');
} catch(\Exception $exception){
throw new RequestValidationException($exception->getMessage());
}
}
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class PaymentMethodNotIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereNotIn('payment_method', $value);
}
}
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -54,4 +54,4 @@ class CanAuthenticateUser extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanCreateUser extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCrossAuthenticateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -51,4 +51,4 @@ class CanCrossAuthenticateUser extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanDeleteUser extends AbstractRule
return true;
}
}
}
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -39,4 +39,4 @@ class CanFetchUser extends AbstractRule
return true;
}
}
}
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -62,4 +62,4 @@ class CanGeneratePasswordReset extends AbstractRule
}
}
}
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -39,4 +39,4 @@ class CanListUsers extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanRegisterUser extends AbstractRule
{
return true;
}
}
}
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -62,4 +62,4 @@ class CanResetPassword extends AbstractRule
return $this->passwordResetTokenExists->execute($object->getToken());
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanUpdateUser extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanCreateAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanDeleteAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanFetchAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanListAddresses extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanUpdateAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -47,4 +47,4 @@ class CanCreateAnnouncement extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanDeleteAnnouncement extends AbstractRule
return true;
}
}
}
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanUpdateAnnouncement extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateBank extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -47,4 +47,4 @@ class CanCreateBank extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteBank extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanDeleteBank extends AbstractRule
return true;
}
}
}
@@ -12,7 +12,7 @@ class CanListBanks extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -34,4 +34,4 @@ class CanListBanks extends AbstractRule
{
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateBank extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanUpdateBank extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanAssignEmployee extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanAssignEmployee extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateCompany extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanCreateCompany extends AbstractRule
{
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateCompanyModule extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchCompany extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanFetchCompany extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanListCompanies extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanListCompanies extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanUpdateCompany extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanUpdateCompany extends AbstractRule
{
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCreateContact extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanCreateContact extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanCreateCurrency extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanDeleteCurrency extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanFetchCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanFetchCurrency extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanListCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -38,4 +38,4 @@ class CanListCurrency extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanUpdateCurrency extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
if (!\Auth::user()->can('add currency_rate')) {
@@ -52,4 +52,4 @@ class CanCreateRate extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -42,4 +42,4 @@ class CanDeleteRate extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanFetchRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanFetchRate extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanListRates extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -42,4 +42,4 @@ class CanListRates extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanUpdateRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -55,4 +55,4 @@ class CanUpdateRate extends AbstractRule
return true;
}
}
}
@@ -12,7 +12,7 @@ class CanApproveDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanApproveDocument extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanCreateDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -50,4 +50,4 @@ class CanCreateDocument extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanCreateFile extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -50,4 +50,4 @@ class CanCreateFile extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanListDocuments extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
/*
@@ -44,4 +44,4 @@ class CanListDocuments extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanRenderDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanRenderDocument extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanUpdateDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -50,4 +50,4 @@ class CanUpdateDocument extends AbstractRule
return true;
}
}
}
@@ -11,7 +11,7 @@ class CanUpdateDocumentReference extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanUpdateDocumentReference extends AbstractRule
return true;
}
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Classes\Modules\Exports\ControllersLogic;
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
use App\Classes\Modules\Exports\Services\ExportsFeedback;
use App\Classes\Modules\Exports\Standards\Rules\CanExportFeedback;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Maatwebsite\Excel\Excel;
class ExportFeedbackDataLogic extends Abstract2ControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Feedback',
'message' => 'You have successfully exported feedback data'
];
}
/** @var ExportsFeedback */
private $exportsFeedback;
/** @var CanExportFeedback */
private $canExportFeedback;
/**
* ExportFeedbackDataLogic constructor.
* @param ExportsFeedback $exportsFeedback
* @param CanExportFeedback $canExportFeedback
*/
public function __construct(ExportsFeedback $exportsFeedback, CanExportFeedback $canExportFeedback)
{
$this->exportsFeedback = $exportsFeedback;
$this->canExportFeedback = $canExportFeedback;
}
/**
* @param Request $request
* @return Response
*/
public function logic(Request $request) : BinaryFileResponse
{
$this->canExportFeedback->passes();
$response = $this->exportsFeedback->download('feedback.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
ob_end_clean();
return $response;
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Classes\Modules\Exports\ControllersLogic;
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
use App\Classes\Modules\Exports\Standards\Rules\CanExportPackingList;
use App\Classes\Modules\Exports\Services\ExportsOnHoldPackingList;
use App\Classes\Modules\Exports\Services\ExportsPendingArrangementDeliveryList;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Maatwebsite\Excel\Excel;
class ExportPackingListLogic extends Abstract2ControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved PackingList',
'message' => 'You have successfully exported PackingList'
];
}
/** @var ExportsOnHoldPackingList */
private $exportsOnHoldPackingList;
/** @var ExportsPendingArrangementDeliveryList */
private $exportsPendingArrangementDeliveryList;
/** @var CanExportPackingList */
private $canExportPackingList;
/**
* ExportPackingListLogic constructor.
* @param ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList
* @param ExportsOnHoldPackingList $exportsOnHoldPackingList
* @param CanExportPackingList $canExportPackingList
*/
public function __construct(ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList, ExportsOnHoldPackingList $exportsOnHoldPackingList, CanExportPackingList $canExportPackingList)
{
$this->exportsPendingArrangementDeliveryList = $exportsPendingArrangementDeliveryList;
$this->exportsOnHoldPackingList = $exportsOnHoldPackingList;
$this->canExportPackingList = $canExportPackingList;
}
/**
* @param Request $request
* @return Response
*/
public function logic(Request $request) : BinaryFileResponse
{
$this->canExportPackingList->passes();
$isSetPendingArrangement = $request->header('PendingArrangement');
if($isSetPendingArrangement){
$response = $this->exportsPendingArrangementDeliveryList->download('packing-list-delivery.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
}
else {
$response = $this->exportsOnHoldPackingList->download('packing-list-on-hold.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
}
ob_end_clean();
return $response;
}
}
@@ -0,0 +1,70 @@
<?php
namespace App\Classes\Modules\Exports\Services;
use App\Models\QAUserAnswerSelected;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use App\Classes\ValueObjects\Constants\QASystemSourceType;
use Carbon\Carbon;
class ExportsFeedback implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
{
use Exportable;
public function headings(): array
{
return [
'Question Set',
'Question Text',
'Answer',
'Source System',
'Source Marking',
'Source Email',
'Created Date'
];
}
/**
* @return \Illuminate\Support\Collection|mixed
*/
public function query()
{
return QAUserAnswerSelected::whereHas('question', function ($query) {
$query->whereHas('questionnaire', function ($innerQuery) {
$innerQuery->where('group', 'feedback');
})->where('created_at', '>', Carbon::now()->subMonths(1));
})->orderBy('created_at', 'desc');
}
/**
* @param QAUserAnswerSelected $userAnswer
*
* @return array
*/
public function map($userAnswer): array
{
$source = $userAnswer->userSource;
$user = $userAnswer->source_id === 0 ? $userAnswer->user : null;
$user_marking = '';
if($user){
$companyModule = $user->companyModule()->first();
$user_marking = $companyModule ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : "";
}
return [
$userAnswer->question->questionnaire->description,
$userAnswer->question->question_text,
$userAnswer->free_text_answer,
$user ? QASystemSourceType::getText(QASystemSourceType::IZYIM) : QASystemSourceType::getText($source->system),
$user ? $user_marking : $source->marking,
$user ? $user->email : $source->email,
Carbon::parse($userAnswer->created_at)->format('d-m-Y'),
];
}
}
@@ -0,0 +1,48 @@
<?php
namespace App\Classes\Modules\Exports\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\ValueObjects\Constants\RoleTypes;
class CanExportFeedback extends AbstractRule
{
/**
* @return bool
*/
protected function authorized($object): bool
{
if(Auth()->user()){
$roleToCheck = Auth()->user()->type;
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
return true;
}
else {
return false;
}
}
return false;
}
/**
* @param $object
* @return bool
*/
protected function validators($object): bool
{
return true;
}
/**
* @param $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -0,0 +1,49 @@
<?php
namespace App\Classes\Modules\Exports\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\ValueObjects\Constants\RoleTypes;
class CanExportPackingList extends AbstractRule
{
/**
* @return bool
*/
protected function authorized($object): bool
{
if(Auth()->user()){
$roleToCheck = Auth()->user()->type;
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
return true;
}
else {
return false;
}
}
return false;
}
/**
* @param $object
* @return bool
*/
protected function validators($object): bool
{
return true;
}
/**
* @param $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -7,11 +7,13 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\HelpMenu\DataTransferObjects\UrlObject;
use App\Classes\Modules\HelpMenu\Standards\Rules\CanGenerateFeedbackUrl;
use App\Classes\Modules\HelpMenu\Services\CreatesUrl;
use App\Classes\Modules\HelpMenu\DataTransferObjects\GenerateFeedbackUrlObject;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Log;
class GenerateFeedbackUrlLogic extends AbstractControllerLogic
{
@@ -51,10 +53,16 @@ class GenerateFeedbackUrlLogic extends AbstractControllerLogic
*/
public function logic(Request $request) : JsonResponse
{
$this->canGenerateFeedbackUrl->passes();
$apiKey = "";
if($request->get('apiKeyExist'))
{
$apiKey = $request->get('apiKeyExist');
}
$object = new GenerateFeedbackUrlObject($apiKey, $request->input('system'), $request->input('customer_marking'), $request->input('email'), $request->input('question_set'));
$this->canGenerateFeedbackUrl->passes($object);
$shortUrl = Str::random(20);
$originalText = $request->input('system') . '|' . $request->input('customer_marking'). '|' . $request->input('email'). '|' . $request->input('question_set') . '|' . $shortUrl;
$originalText = $object->getSystem() . '|' . $object->getCustomerMarking(). '|' . $object->getEmail(). '|' . $object->getQuestionSet() . '|' . $shortUrl;
$originalUrl = Crypt::encryptString($originalText);
@@ -0,0 +1,79 @@
<?php
namespace App\Classes\Modules\HelpMenu\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
class GenerateFeedbackUrlObject implements DataTransferObject
{
/** @var string */
private $apiKey;
/** @var string */
private $system;
/** @var string */
private $customerMarking;
/** @var string */
private $email;
/** @var string */
private $questionSet;
/**
* GenerateFeedbackUrlObject constructor.
* @param string $apiKey
*/
public function __construct(string $apiKey = "", ?string $system, ?string $customerMarking, ?string $email, ?string $questionSet)
{
$this->apiKey = $apiKey;
$this->system = $system;
$this->customerMarking = $customerMarking;
$this->email = $email;
$this->questionSet = $questionSet;
}
/**
* @return string
*/
public function getApiKey(): string
{
return $this->apiKey;
}
/**
* @return string
*/
public function getSystem(): ?string
{
return $this->system;
}
/**
* @return string
*/
public function getCustomerMarking(): ?string
{
return $this->customerMarking;
}
/**
* @return string
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @return string
*/
public function getQuestionSet(): ?string
{
return $this->questionSet;
}
}
@@ -11,7 +11,7 @@ class CanFetchHelpMenuQuestion extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -5,30 +5,52 @@ namespace App\Classes\Modules\HelpMenu\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\ValueObjects\Constants\RoleTypes;
use App\Classes\Modules\HelpMenu\Standards\Validators\FeedbackUrlValidation;
use App\Classes\Modules\HelpMenu\DataTransferObjects\GenerateFeedbackUrlObject;
use Illuminate\Support\Facades\Log;
class CanGenerateFeedbackUrl extends AbstractRule
{
/** @var FeedbackUrlValidation */
private $feedbackUrlValidation;
/**
* @return bool
* CanGenerateFeedbackUrl constructor.
* @param FeedbackUrlValidation $feedbackUrlValidation
*/
protected function authorized(): bool
public function __construct(FeedbackUrlValidation $feedbackUrlValidation)
{
$roleToCheck = Auth()->user()->type;
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
return true;
} else {
return false;
}
$this->feedbackUrlValidation = $feedbackUrlValidation;
}
/**
* @param $object
* @return bool
*/
protected function authorized($object): bool
{
$user = Auth()->user();
if($user){
$roleToCheck = Auth()->user()->type;
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
return true;
}
}
else if($object->getApiKey()){
return true;
}
return false;
}
/**
* @param GenerateFeedbackUrlObject $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return true;
return $this->feedbackUrlValidation->validate($object);
}
/**
@@ -12,7 +12,7 @@ class CanListHelpMenuQuestions extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
$roleToCheck = Auth()->user()->type;
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
@@ -0,0 +1,44 @@
<?php
namespace App\Classes\Modules\HelpMenu\Standards\Validators;
use App\Classes\General\Abstracts\AbstractValidation;
use App\Classes\Modules\HelpMenu\DataTransferObjects\GenerateFeedbackUrlObject;
class FeedbackUrlValidation extends AbstractValidation
{
/**
* @param GenerateFeedbackUrlObject $object
* @return array
*/
protected function data($object): array {
return [
'system' => $object->getSystem(),
'email' => $object->getEmail(),
'question_set' => $object->getQuestionSet()
// 'customer_marking' => $object->getCustomerMarking(),
];
}
/**
* @return array
*/
protected function rules(): array {
return [
'system' => 'required',
'email' => 'required',
'question_set' => 'required',
// 'customer_marking' => 'required',
];
}
/**
* @return array
*/
protected function messages(): array {
return [];
}
}
@@ -11,7 +11,7 @@ class CanApproveChangeOrderAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -11,7 +11,7 @@ class CanChangeOrderAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -17,7 +17,7 @@ class CanConfirmOrder extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -18,7 +18,7 @@ class CanCreateOrder extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -42,4 +42,4 @@ class CanCreateOrder extends AbstractRule
{
return true;
}
}
}
@@ -17,7 +17,7 @@ class CanCreateOrderRole extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -12,7 +12,7 @@ class CanFetchOrder extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -39,4 +39,4 @@ class CanFetchOrder extends AbstractRule
return true;
}
}
}
@@ -12,7 +12,7 @@ class CanListOrders extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -17,7 +17,7 @@ class CanUpdateCurrentStep extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanUpdateCurrentStep extends AbstractRule
{
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCreatePackingList extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanCreatePackingListPackage extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanDeletePackingList extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchPackingList extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\PackingLists\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
use App\Classes\ValueObjects\Constants\RoleTypes;
class CanListPackingLists extends AbstractRule
{
@@ -13,11 +14,19 @@ class CanListPackingLists extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
// if(Auth()->user()){
// $roleToCheck = Auth()->user()->type;
// if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
// return true;
// }
// else {
// return false;
// }
// }
// return false;
return true;
}
/**
@@ -26,7 +26,7 @@ class CanUpdatePackingList extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanCreateContainer extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanDeleteContainer extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchContainer extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanListContainers extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanUpdateContainer extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanCreatePackage extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -27,7 +27,7 @@ class CanCreatePackageItem extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanDeletePackage extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchPackage extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanListPackages extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanUpdatePackage extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanCreateItem extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanDeleteItem extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchItem extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanListItems extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanUpdatePackageItem extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanCreateReceipt extends AbstractRule
/** @var ReceiptValidation */
private $receiptValidation;
public function __construct(ReceiptValidation $receiptValidation)
{
$this->receiptValidation = $receiptValidation;
@@ -23,7 +23,7 @@ class CanCreateReceipt extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanCreateReceipt extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanCreateReceiptDetail extends AbstractRule
/** @var ReceiptDetailValidation */
private $receiptDetailValidation;
public function __construct(ReceiptDetailValidation $receiptDetailValidation)
{
$this->receiptDetailValidation = $receiptDetailValidation;
@@ -23,7 +23,7 @@ class CanCreateReceiptDetail extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanCreateReceiptDetail extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCreateRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanDeleteRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanListRemarks extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanUpdateRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;

Some files were not shown because too many files have changed in this diff Show More