mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
exports leads data to csv
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
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 Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Companies\Services\ListsCompanies;
|
||||
|
||||
class ExportsLeadsTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request, ListsCompanies $listsCompanies)
|
||||
{
|
||||
$this->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')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -263,6 +263,9 @@
|
||||
<div class="row no-margin">
|
||||
<div class="col bg-white padding-25">
|
||||
<div class="row tabsContainer tabContent hide m-l-0 m-r-0 hide" tab-name="customer-leads" v-if="$store.getters.isAdmin">
|
||||
<a :href="route('leads.export')" class="m-b-15" target="_blank">
|
||||
<button class="btn btn-success btn-xs">Export Leads Data</button>
|
||||
</a>
|
||||
<list-component key="2" section="leadCustomerListSection" :endpoint="route('api.company.list')" :options="{'business_type': 2, with_bookings:true, without_confirmed_payments: true, does_not_have_segments: [5]}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<company-component :data="data"></company-component>
|
||||
|
||||
@@ -102,6 +102,7 @@ Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\Export
|
||||
Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions');
|
||||
Route::get('/export/analytic/booking', 'Exports\ExportAnalyticToExcelController@bookingData');
|
||||
Route::get('/export/analytic/bills', 'Exports\ExportAnalyticToExcelController@billingData');
|
||||
Route::get('/export/customers/leads', 'Exports\ExportCustomersToExcelController@leadsData')->name('leads.export');
|
||||
|
||||
Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) {
|
||||
return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
|
||||
|
||||
Reference in New Issue
Block a user