diff --git a/app/Classes/Modules/Exports/Services/ExportsLeadsTransactions.php b/app/Classes/Modules/Exports/Services/ExportsLeadsTransactions.php new file mode 100644 index 00000000..4b8581d6 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsLeadsTransactions.php @@ -0,0 +1,71 @@ +request = $request; + $this->listsCompanies = $listsCompanies; + } + + public function headings(): array + { + return [ + 'Agent Name', + 'User Name', + 'Contact Number', + 'Email', + 'Customer Code', + 'Register Date' + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $query = $this->listsCompanies->execute( + [ + 'business_type' => 2, + 'with_bookings' => true, + 'without_confirmed_payments' => true, + 'does_not_have_segments' => [5], + ] + ); + + return $query->toQuery(); + } + + /** + * @param $row + * @return array + */ + public function map($row): array + { + return [ + '', + $row->name, + strval($row->contacts->first()->phone), + // $row->contacts->first()->email, + $row->employees()->first() == null ? '' : $row->employees()->first()->email, + $row->reference, + $row->created_at->format('d-m-Y') + ]; + } +} diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 8563f78a..1f7594f8 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -6,6 +6,7 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportsCustomers; use App\Classes\Modules\Exports\Services\ExportsTransactions; use App\Classes\Modules\Exports\Services\ExportsBookingTransactions; +use App\Classes\Modules\Exports\Services\ExportsLeadsTransactions; use App\Classes\Modules\Exports\Services\ExportsNullDebtors; use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions; @@ -61,4 +62,10 @@ class ExportCustomersToExcelController ob_end_clean(); return $response; } + + public function leadsData(ExportsLeadsTransactions $exportsLeadsTransactions, Request $request){ + $response = $exportsLeadsTransactions->download('leadsData.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } } \ No newline at end of file diff --git a/resources/views/pages/customers/index.blade.php b/resources/views/pages/customers/index.blade.php index 25099bc7..dc22b5b8 100644 --- a/resources/views/pages/customers/index.blade.php +++ b/resources/views/pages/customers/index.blade.php @@ -263,6 +263,9 @@