From dd05231b2779067cee8566afd3b68c140da4308c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 15:04:24 +0800 Subject: [PATCH 01/43] fix image routes --- .../vue/components/bookings/forms/BookingFormComponent.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue b/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue index 414f1a42..65b355f8 100644 --- a/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue @@ -7,7 +7,7 @@
- +
@@ -21,7 +21,7 @@
- +
From 3acde619cc155e5f3f662dcf297e25202d16160f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 3 Oct 2021 15:06:08 +0800 Subject: [PATCH 02/43] add destination account admin user --- .../General/Eloquent/Filters/IssuerNot.php | 20 ++++++ .../ValueObjects/Constants/RoleTypes.php | 8 +++ app/Http/Resources/TransactionResource.php | 1 + app/Models/Transaction.php | 10 +++ .../banks/elements/BankInComponent.vue | 36 ++++++++++ .../bookings/elements/BookingComponent.vue | 4 +- .../elements/PaymentProofComponent.vue | 67 +++++++++---------- .../forms/PaymentProofFormComponent.vue | 1 + .../assets/vue/vuex/modules/authentication.js | 2 + .../views/pages/banks/customers.blade.php | 2 +- .../pages/dashboards/account_admin.blade.php | 13 ++++ .../views/pages/dashboards/admin.blade.php | 2 +- .../views/pages/dashboards/customer.blade.php | 2 +- .../views/pages/dashboards/index.blade.php | 1 + resources/views/pages/settings.blade.php | 45 +------------ resources/views/partials/header.blade.php | 2 +- routes/transaction.php | 1 + 17 files changed, 134 insertions(+), 83 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/IssuerNot.php create mode 100644 resources/assets/vue/components/banks/elements/BankInComponent.vue create mode 100644 resources/views/pages/dashboards/account_admin.blade.php diff --git a/app/Classes/General/Eloquent/Filters/IssuerNot.php b/app/Classes/General/Eloquent/Filters/IssuerNot.php new file mode 100644 index 00000000..77423b5d --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/IssuerNot.php @@ -0,0 +1,20 @@ +where('issuer', '!=', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/RoleTypes.php b/app/Classes/ValueObjects/Constants/RoleTypes.php index 3027bcb1..ec5fe961 100644 --- a/app/Classes/ValueObjects/Constants/RoleTypes.php +++ b/app/Classes/ValueObjects/Constants/RoleTypes.php @@ -16,4 +16,12 @@ final class RoleTypes public const USER = 3; + public const CURRENCY_SUPPLIER = 4; + + public const MONEY_MULE = 5; + + public const ORIGIN_ACCOUNT_ADMIN = 6; + + public const DESTINATION_ACCOUNT_ADMIN = 7; + } \ No newline at end of file diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index fc0dff73..1793d191 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -21,6 +21,7 @@ class TransactionResource extends JsonResource 'booking' => new BookingResource($this->booking), 'type' => (int) $this->type, 'bill_no' => $this->bill_no, + 'recipient_bank_account' => new BankResource($this->when((int) $this->type === TransactionType::BILL,$this->booking->bank)), 'amount' => (double) $this->amount, 'original_amount' => (double) $this->original_amount, 'currency' => new CurrencyResource($this->currency), diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 9d1ed5b9..2624117b 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -9,6 +9,8 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\HasOneThrough; use Illuminate\Database\Eloquent\Relations\MorphMany; @@ -24,6 +26,14 @@ class Transaction extends AbstractModel implements Documentable return $this->BelongsTo( Booking::class, 'booking_id', 'id'); } + /** + * @return BelongsTo + */ + public function recipientBankAccount(): BelongsTo + { + return $this->BelongsTo(Bank::class); + } + /** * @return MorphMany */ diff --git a/resources/assets/vue/components/banks/elements/BankInComponent.vue b/resources/assets/vue/components/banks/elements/BankInComponent.vue new file mode 100644 index 00000000..ff42850a --- /dev/null +++ b/resources/assets/vue/components/banks/elements/BankInComponent.vue @@ -0,0 +1,36 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/elements/BookingComponent.vue b/resources/assets/vue/components/bookings/elements/BookingComponent.vue index 509e9840..99c3228c 100644 --- a/resources/assets/vue/components/bookings/elements/BookingComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BookingComponent.vue @@ -40,13 +40,13 @@
Payable Amount
{{this.item.amount}} {{this.item.fixed_currency.short_code}}
-
+
status
{{item.status === 3 ? 'Complete' : 'In Progress'}}
-
+
Billing
Pending... diff --git a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue index 5356070b..c403af9d 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue @@ -3,48 +3,45 @@
-
-
-
+
+
+
-
Reference
- -
- {{item.booking.marking}} + -
-
Date
-
- {{item.updated_at}}
+
-
-
Marking
-
- {{item.booking.company.reference}} -
-
-
-
Currency
-
- {{item.original_currency.short_code}} -
-
-
-
Amount
-
- {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} -
-
-
-
+
+
+
+
+
+
+ style=" fill:#000000;">
diff --git a/resources/assets/vue/components/bookings/forms/PaymentProofFormComponent.vue b/resources/assets/vue/components/bookings/forms/PaymentProofFormComponent.vue index 612b8735..0c85a3f7 100644 --- a/resources/assets/vue/components/bookings/forms/PaymentProofFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PaymentProofFormComponent.vue @@ -10,6 +10,7 @@
+
diff --git a/resources/assets/vue/vuex/modules/authentication.js b/resources/assets/vue/vuex/modules/authentication.js index b28ddb10..19ab2317 100644 --- a/resources/assets/vue/vuex/modules/authentication.js +++ b/resources/assets/vue/vuex/modules/authentication.js @@ -13,6 +13,8 @@ export default { isSuperAdmin: (state, getters) => getters.getDecodedAccessToken.user.type === 0 || getters.getDecodedAccessToken.user.type === 1, isAdmin: (state, getters) => getters.getDecodedAccessToken.user.type === 0 || getters.getDecodedAccessToken.user.type === 1 || getters.getDecodedAccessToken.user.type === 2, + isCustomer: (state, getters) => getters.getDecodedAccessToken.user.type === 3, + isDestinationAccountAdmin: (state, getters) => getters.getDecodedAccessToken.user.type === 7, getUserName: (state, getters) => getters.getUpdatedFullname || getters.getDecodedAccessToken.user.name, getUserId: (state, getters) => getters.getDecodedAccessToken.user.id, getUserEmail: (state, getters) => getters.getDecodedAccessToken.user.email, diff --git a/resources/views/pages/banks/customers.blade.php b/resources/views/pages/banks/customers.blade.php index d755c801..92901def 100644 --- a/resources/views/pages/banks/customers.blade.php +++ b/resources/views/pages/banks/customers.blade.php @@ -1,4 +1,4 @@ -
+
diff --git a/resources/views/pages/dashboards/account_admin.blade.php b/resources/views/pages/dashboards/account_admin.blade.php new file mode 100644 index 00000000..d3a1c657 --- /dev/null +++ b/resources/views/pages/dashboards/account_admin.blade.php @@ -0,0 +1,13 @@ +
+
+
+
+ + + +
+
+
+
\ No newline at end of file diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 71944a13..31ad8d1c 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -328,7 +328,7 @@
- + diff --git a/resources/views/pages/dashboards/customer.blade.php b/resources/views/pages/dashboards/customer.blade.php index c5e842c2..3e877546 100644 --- a/resources/views/pages/dashboards/customer.blade.php +++ b/resources/views/pages/dashboards/customer.blade.php @@ -1,4 +1,4 @@ -
+
diff --git a/resources/views/pages/dashboards/index.blade.php b/resources/views/pages/dashboards/index.blade.php index 496640e4..a1d93610 100644 --- a/resources/views/pages/dashboards/index.blade.php +++ b/resources/views/pages/dashboards/index.blade.php @@ -2,4 +2,5 @@ @section('inner_content') @include('pages.dashboards.admin') @include('pages.dashboards.customer') + @include('pages.dashboards.account_admin') @endsection \ No newline at end of file diff --git a/resources/views/pages/settings.blade.php b/resources/views/pages/settings.blade.php index 9157dbc5..edb38329 100644 --- a/resources/views/pages/settings.blade.php +++ b/resources/views/pages/settings.blade.php @@ -512,17 +512,17 @@
-
+
-
+
-
+
-
-
-
-
-
-
-
- -
-
-
-
-
Announcements
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index 9a0e09ad..ecbd150d 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -41,7 +41,7 @@
Urgent List
- diff --git a/routes/transaction.php b/routes/transaction.php index cab4d241..9f10c6cc 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -9,6 +9,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => route::post('/supplier/{id}/bill/create', 'CreateSupplierTransactionController@create')->name('supplier.create'); route::post('{id}/bill/verification', 'CreatePaymentProofDocumentController@verify')->name('bill.verification'); + route::post('{id}/bill/pay', 'CreatePaymentProofDocumentController@pay')->name('bill.pay'); Route::post('booking/{id}/details/update', 'CreatePurchaseOrderTransactionController@create')->name('po.create'); From d3c69a57c0a86b9928b0122ea444c7cb67828034 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 3 Oct 2021 15:11:05 +0800 Subject: [PATCH 03/43] add destination account admin user --- resources/views/pages/dashboards/account_admin.blade.php | 2 +- resources/views/pages/dashboards/admin.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/pages/dashboards/account_admin.blade.php b/resources/views/pages/dashboards/account_admin.blade.php index d3a1c657..e8256f8f 100644 --- a/resources/views/pages/dashboards/account_admin.blade.php +++ b/resources/views/pages/dashboards/account_admin.blade.php @@ -2,7 +2,7 @@
- + diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 31ad8d1c..7471027f 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -328,7 +328,7 @@
- + From 23d93178c763a481353e0696e6620a30e3a534ba Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:22:48 +0800 Subject: [PATCH 04/43] download all delivery orders --- composer.json | 3 ++- routes/web.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7a3ac9b3..7c7d11ba 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "rinvex/countries": "^6.1", "spatie/laravel-activitylog": "^3.14", "spatie/laravel-permission": "^3.17", - "tymon/jwt-auth": "^1.0" + "tymon/jwt-auth": "^1.0", + "ext-zip": "*" }, "require-dev": { "facade/ignition": "^2.0", diff --git a/routes/web.php b/routes/web.php index 1578a131..84b143a3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,8 +5,10 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Route; +use Illuminate\Support\Facades\Storage; /* |-------------------------------------------------------------------------- @@ -69,6 +71,32 @@ Route::get('/transfer/merge/{marking}', function ($marking) { return view('pages.booking_merge', ['marking' => $marking]); })->name('booking.merge'); +Route::get('/test', function(){ + + Auth::login(User::findOrFail(3)); + + $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download + $zip = new ZipArchive(); + if ($zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { + + //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> + $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); + + foreach ($bookings as $booking) { + $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); + if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { + echo 'Could not add file to ZIP: ' . $file; + } + } + + // Close ZipArchive + $zip->close(); + } else { + echo 'Could not open ZIP file.'; + } + + +}); Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); From c089fb08d1c25cf5da05925c5ab68c94ad4a6b42 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:47:23 +0800 Subject: [PATCH 05/43] download all delivery orders --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 84b143a3..44b7168e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -72,7 +72,7 @@ Route::get('/transfer/merge/{marking}', function ($marking) { })->name('booking.merge'); Route::get('/test', function(){ - +dd('yes'); Auth::login(User::findOrFail(3)); $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download From 4dc0a8d232550b8f2bb578e9a775f75720c309a9 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:47:56 +0800 Subject: [PATCH 06/43] download all delivery orders --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 44b7168e..84b143a3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -72,7 +72,7 @@ Route::get('/transfer/merge/{marking}', function ($marking) { })->name('booking.merge'); Route::get('/test', function(){ -dd('yes'); + Auth::login(User::findOrFail(3)); $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download From 51b89c1f31b9b5fd44b7bc20e972f0176950dc2b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:49:37 +0800 Subject: [PATCH 07/43] download all delivery orders --- routes/web.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/routes/web.php b/routes/web.php index 84b143a3..947b44c7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -74,25 +74,28 @@ Route::get('/transfer/merge/{marking}', function ($marking) { Route::get('/test', function(){ Auth::login(User::findOrFail(3)); + try { + $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download + $zip = new ZipArchive(); + if ($zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { - $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download - $zip = new ZipArchive(); - if ($zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { + //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> + $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); - //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> - $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); - - foreach ($bookings as $booking) { - $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); - if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { - echo 'Could not add file to ZIP: ' . $file; + foreach ($bookings as $booking) { + $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); + if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { + echo 'Could not add file to ZIP: ' . $file; + } } - } - // Close ZipArchive - $zip->close(); - } else { - echo 'Could not open ZIP file.'; + // Close ZipArchive + $zip->close(); + } else { + echo 'Could not open ZIP file.'; + } + } catch (Exception $exception) { + dd('test'); } From 6d8296e5e7caeee00f2671e413852ed9b4ba3a6a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:49:58 +0800 Subject: [PATCH 08/43] download all delivery orders --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 947b44c7..69db0524 100644 --- a/routes/web.php +++ b/routes/web.php @@ -95,7 +95,7 @@ Route::get('/test', function(){ echo 'Could not open ZIP file.'; } } catch (Exception $exception) { - dd('test'); + dd($exception); } From 11a92c1f04d625e804ad5b9f2d3985fd7f7c9d9d Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:52:01 +0800 Subject: [PATCH 09/43] download all delivery orders --- routes/web.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index 69db0524..d1debbeb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,12 +1,8 @@ open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { From 5b573cb4dc4ccc32327ed1812d53ddaeda8e086a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:54:30 +0800 Subject: [PATCH 10/43] download all delivery orders --- routes/web.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index d1debbeb..54bd6604 100644 --- a/routes/web.php +++ b/routes/web.php @@ -69,10 +69,9 @@ Route::get('/transfer/merge/{marking}', function ($marking) { Route::get('/test', function(){ - Auth::login(User::findOrFail(3)); + Auth::login(User::findOrFail(1)); try { $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download - dd($zip_file); $zip = new ZipArchive(); if ($zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { From 7d17375a881cb55e73d8849624255737f0c1c439 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 12:57:00 +0800 Subject: [PATCH 11/43] download all delivery orders --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 54bd6604..f9fbb3c1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -73,7 +73,7 @@ Route::get('/test', function(){ try { $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download $zip = new ZipArchive(); - if ($zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { + if ($zip->open(storage_path().'/'.$zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); From bf38962a12b10f9f21aa3caa9b16a99b52032d7a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 13:01:01 +0800 Subject: [PATCH 12/43] download all delivery orders --- routes/web.php | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/routes/web.php b/routes/web.php index f9fbb3c1..4f29e811 100644 --- a/routes/web.php +++ b/routes/web.php @@ -69,30 +69,30 @@ Route::get('/transfer/merge/{marking}', function ($marking) { Route::get('/test', function(){ - Auth::login(User::findOrFail(1)); - try { - $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download - $zip = new ZipArchive(); - if ($zip->open(storage_path().'/'.$zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { - - //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> - $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); - - foreach ($bookings as $booking) { - $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); - if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { - echo 'Could not add file to ZIP: ' . $file; - } - } - - // Close ZipArchive - $zip->close(); - } else { - echo 'Could not open ZIP file.'; - } - } catch (Exception $exception) { - dd($exception); - } +// Auth::login(User::findOrFail(1)); +// try { +// $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download +// $zip = new ZipArchive(); +// if ($zip->open(storage_path().'/'.$zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { +// +// //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> +// $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); +// +// foreach ($bookings as $booking) { +// $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); +// if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { +// echo 'Could not add file to ZIP: ' . $file; +// } +// } +// +// // Close ZipArchive +// $zip->close(); +// } else { +// echo 'Could not open ZIP file.'; +// } +// } catch (Exception $exception) { +// dd($exception); +// } }); From f94a5389c439d1d7c236ca33333eb3ad547e3994 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 8 Oct 2021 21:59:47 +0800 Subject: [PATCH 13/43] list companies without confirmed payments --- .../Eloquent/Filters/WithOutTransactions.php | 20 +++++++++++++ .../Filters/WithoutConfirmedPayments.php | 24 ++++++++++++++++ app/Models/Company.php | 12 ++++++++ composer.json | 5 ++-- resources/views/pages/settings.blade.php | 28 ++++++++++++++++++- 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/WithOutTransactions.php create mode 100644 app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php diff --git a/app/Classes/General/Eloquent/Filters/WithOutTransactions.php b/app/Classes/General/Eloquent/Filters/WithOutTransactions.php new file mode 100644 index 00000000..3b551f65 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithOutTransactions.php @@ -0,0 +1,20 @@ +whereDoesntHave('transactions'); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php b/app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php new file mode 100644 index 00000000..e17ed5da --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php @@ -0,0 +1,24 @@ +whereDoesntHave('transactions', function($transaction){ + return $transaction->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + }); + } +} \ No newline at end of file diff --git a/app/Models/Company.php b/app/Models/Company.php index c1a6a191..1922fa10 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -12,6 +12,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Collection; +use Staudenmeir\EloquentHasManyDeep\HasManyDeep; +use Staudenmeir\EloquentHasManyDeep\HasRelationships; + /** * Class Company @@ -27,6 +30,7 @@ use Illuminate\Support\Collection; */ class Company extends AbstractModel implements Documentable { + use HasRelationships; use SoftDeletes; protected $table = 'companies'; @@ -90,6 +94,14 @@ class Company extends AbstractModel implements Documentable return $this->HasMany(Booking::class, 'company_id'); } + /** + * @return hasManyDeep + */ + public function transactions(): hasManyDeep + { + return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'booking_id'], ['id', 'id']); + } + /** * @return Builder */ diff --git a/composer.json b/composer.json index 7c7d11ba..377c8932 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": "^7.2.5", "ext-fileinfo": "*", "ext-json": "^1.6", + "ext-zip": "*", "barryvdh/laravel-dompdf": "^0.9.0", "carlos-meneses/laravel-mpdf": "^2.1", "fideloper/proxy": "^4.2", @@ -23,8 +24,8 @@ "rinvex/countries": "^6.1", "spatie/laravel-activitylog": "^3.14", "spatie/laravel-permission": "^3.17", - "tymon/jwt-auth": "^1.0", - "ext-zip": "*" + "staudenmeir/eloquent-has-many-deep": "^1.7", + "tymon/jwt-auth": "^1.0" }, "require-dev": { "facade/ignition": "^2.0", diff --git a/resources/views/pages/settings.blade.php b/resources/views/pages/settings.blade.php index edb38329..b7f03a6b 100644 --- a/resources/views/pages/settings.blade.php +++ b/resources/views/pages/settings.blade.php @@ -522,7 +522,7 @@
-
+
+
+
+
+
+
+ +
+
+
+
+
Leads
+
+
+
+
+
@@ -547,6 +566,13 @@
+
+ + + +
From 861857acdf9e3f57eb2907ec25ce23d064f60136 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 8 Oct 2021 22:02:24 +0800 Subject: [PATCH 14/43] list companies without confirmed payments --- resources/views/pages/settings.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/settings.blade.php b/resources/views/pages/settings.blade.php index b7f03a6b..cc875a29 100644 --- a/resources/views/pages/settings.blade.php +++ b/resources/views/pages/settings.blade.php @@ -566,7 +566,7 @@
-
+