|
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\AccountPurchaseBill;
class PurchaseBillExport 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 = AccountPurchaseBill::where("account_purchase_bills.admin_id","=",$this->admin_id)
->leftJoin("account_customers","account_customers.id","=","account_purchase_bills.vendor_id");
if($start_date && $end_date)
{
$query->whereDate("account_purchase_bills.created_at",">=",$start_date);
$query->whereDate("account_purchase_bills.created_at","<=",$end_date);
}
$customer = $query->select(
"account_customers.name as customer_name",
"account_purchase_bills.bill_number",
"account_purchase_bills.bill_date",
"account_purchase_bills.invoice_number",
"account_purchase_bills.po_number",
"account_purchase_bills.po_date",
"account_purchase_bills.due_date",
"account_purchase_bills.description",
"account_purchase_bills.shipping_charge",
"account_purchase_bills.subtotal",
"account_purchase_bills.cgst_total",
"account_purchase_bills.sgst_total",
"account_purchase_bills.igst_total",
"account_purchase_bills.cess_total",
"account_purchase_bills.grand_total",
"account_purchase_bills.status"
)->orderBy('account_purchase_bills.created_at', 'DESC')->get();
return $customer;
}
public function headings(): array
{
return [
"Customer Name",
"Bill Number",
"Bill Date",
"Invoice Number",
"PO Number",
"PO Date",
"Due Date",
"Description",
"Shipping Charge",
"Subtotal",
"CGST Total",
"SGST Total",
"IGST Total",
"Cess Total",
"Grand Total",
"Status"
];
}
}