From 8178cda2b41eb4f67a46532419a12e96d068c83b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 12 Oct 2021 13:13:12 +0800 Subject: [PATCH] create sales report range frontend --- .../Reports/MonthlyReportController.php | 5 +- package.json | 1 - .../MonthlySalesReportSectionComponent.vue | 265 ++++++++++-------- routes/api.php | 2 +- 4 files changed, 152 insertions(+), 121 deletions(-) diff --git a/app/Http/Controllers/Reports/MonthlyReportController.php b/app/Http/Controllers/Reports/MonthlyReportController.php index 2406d197..f112fab2 100644 --- a/app/Http/Controllers/Reports/MonthlyReportController.php +++ b/app/Http/Controllers/Reports/MonthlyReportController.php @@ -17,9 +17,8 @@ use Illuminate\Http\Request; class MonthlyReportController { public function salesReport(Request $request): JsonResponse { - - $from = $request->input('from') ? Carbon::parse($request->input('from')) : Carbon::now()->startOfMonth(); - $to = $request->input('to') ? Carbon::parse($request->input('to')) : Carbon::now()->endOfMonth(); + $from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth(); + $to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth(); $containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get(); diff --git a/package.json b/package.json index d5b37663..26b57108 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "v-money": "^0.8.1", "vue": "^2.6.10", "vue-avatar": "^2.1.8", - "vue-bootstrap-datetimepicker": "^5.0.1", "vue-debounce": "^2.6.0", "vue-template-compiler": "^2.6.10", "vue-the-mask": "^0.11.1", diff --git a/resources/assets/vue/components/reports/sections/MonthlySalesReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlySalesReportSectionComponent.vue index 13680a58..3a9a04ca 100644 --- a/resources/assets/vue/components/reports/sections/MonthlySalesReportSectionComponent.vue +++ b/resources/assets/vue/components/reports/sections/MonthlySalesReportSectionComponent.vue @@ -2,154 +2,181 @@
-
+
-
-
-
-
-
-
- Total CBM -
+
+
+
+
+
+ +
-
-
-
-
-

{{(Math.ceil(report.total_cbm * 1000) / 1000).toFixed(3)}} +{{(report.daily_cbm).toFixed(0)}} CBM/Day

- {{((report.total_cbm / 800) * 100).toFixed(2)}}% - Goal: 800 CBM -
-
-
-
-
-
-
+
+
+ +
+
+
+ +
+
-
-
-
-
-
-
-
-
- Activated Orders +
+
+
+
+
+
+
+
+ Total CBM +
+
-
-
-
-
-
-

{{report.activated_orders}}

- {{((report.activated_orders / report.total_orders) * 100).toFixed(2)}}% - Created Orders: {{report.total_orders}} +
+
+
+

{{(Math.ceil(report.total_cbm * 1000) / 1000).toFixed(3)}} +{{(report.daily_cbm).toFixed(0)}} CBM/Day

+ {{((report.total_cbm / 800) * 100).toFixed(2)}}% + Goal: 800 CBM +
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- Active Customers +
+
+
+
+
+
+
+ Activated Orders +
+
-
-
-
-
-
-

{{report.active_customers}}

- {{((report.active_customers / report.total_customers) * 100).toFixed(2)}}% - Total Customers: {{report.total_customers}} +
+
+
+

{{report.activated_orders}}

+ {{((report.activated_orders / report.total_orders) * 100).toFixed(2)}}% + Created Orders: {{report.total_orders}} +
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- New Customers +
+
+
+
+
+
+
+ Active Customers +
+
-
-
-
-
-
-

{{report.new_customers}}

- {{((report.new_converted_customers / report.new_customers) * 100).toFixed(2)}}% - Confirmed Order: {{report.new_converted_customers}} +
+
+
+

{{report.active_customers}}

+ {{((report.active_customers / report.total_customers) * 100).toFixed(2)}}% + Total Customers: {{report.total_customers}} +
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- Containers +
+
+
+
+
+
+
+ New Customers +
+
+
+
+
+
+
+

{{report.new_customers}}

+ {{((report.new_converted_customers / report.new_customers) * 100).toFixed(2)}}% + Confirmed Order: {{report.new_converted_customers}} +
+
+
+
+
+
+
+
-
-
-
-

{{report.containers}}

+
+
+
+
+
+
+
+
+ Containers +
+
+
-
-
-
-
-
-
+
+
+
+

{{report.containers}}

+
+
+
+
+
+
+
+
+
@@ -169,9 +196,15 @@ return { section: 'monthlyReportSection', isLoading: true, - report: null + report: null, + from: '', + to: '', } }, + validations: { + from: {}, + to: {}, + }, computed: { pendingQueue () { return this.$store.getters.isInCompleteQueue(this.section); @@ -190,7 +223,7 @@ methods: { fetchReport(){ this.isLoading = true; - this.submit(route('api.report.sales'), 'get', this.section, false, false) + this.submit(route('api.report.sales', this.from, this.to), 'get', this.section, false, false) }, successHandler(response){ this.$store.dispatch('completeList', {'name': this.section, 'data': []}); diff --git a/routes/api.php b/routes/api.php index ba440e0c..66d162a9 100644 --- a/routes/api.php +++ b/routes/api.php @@ -50,7 +50,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/schedule.php'; - Route::get('/report/sales', 'Reports\MonthlyReportController@salesReport')->name('report.sales'); + Route::get('/report/sales/{from?}/{to?}', 'Reports\MonthlyReportController@salesReport')->name('report.sales'); Route::get('/report/service', 'Reports\MonthlyReportController@serviceReport')->name('report.service'); });