|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/peoplebee.in/___accounts-admin/app/Exports/ |
Upload File : |
<?php
namespace App\Exports;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Support\Facades\Session;
use App\Models\{
User
};
use App\Models\accounting\AccountDeliveryChallan;
class DeliveryChallanExport implements FromCollection, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
private $admin_id;
public function __construct($admin_id,)
{
$this->admin_id = $admin_id;
}
public function collection()
{
$start_date = isset($_GET["start_date"]) ? $_GET["start_date"] : null;
$end_date = isset($_GET["end_date"]) ? $_GET["end_date"] : null;
$query = AccountDeliveryChallan::where("account_delivery_challans.admin_id","=",$this->admin_id)
->leftJoin("account_customers","account_customers.id","=","account_delivery_challans.customer_id");
if($start_date && $end_date)
{
$query->whereDate("account_delivery_challans.created_at",">=",$start_date);
$query->whereDate("account_delivery_challans.created_at","<=",$end_date);
}
$customer = $query->select(
"account_customers.name as customer_name",
"account_delivery_challans.challan_number",
"account_delivery_challans.challan_date",
"account_delivery_challans.po_number",
"account_delivery_challans.description",
"account_delivery_challans.shipping_charge",
"account_delivery_challans.subtotal",
"account_delivery_challans.cgst_total",
"account_delivery_challans.sgst_total",
"account_delivery_challans.igst_total",
"account_delivery_challans.cess_total",
"account_delivery_challans.grand_total",
"account_delivery_challans.status"
)->orderBy('account_delivery_challans.created_at', 'DESC')->get();
return $customer;
}
public function headings(): array
{
return [
"Customer Name",
"Challan Number",
"Challan Date",
"PO Number",
"Description",
"Shipping Charge",
"Subtotal",
"CGST Total",
"SGST Total",
"IGST Total",
"Cess Total",
"Grand Total",
"Status"
];
}
}