KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/peoplebee.in/___accounts-admin/app/Exports/BulkSalaryExport.php
<?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\HRMS\Salary;

class BulkSalaryExport implements FromCollection, WithHeadings
{
	/**
	 * @return \Illuminate\Support\Collection
	 */
    protected $branch_id, $for_month, $department_id, $admin_id;

    protected $start_date,$end_date;

    public function __construct($admin_id)
    {    
        $this->admin_id = $admin_id;         
    }
    
    
	public function collection()
	{

        $this->department_id = isset($_GET["department"]) ? $_GET["department"] : null;
        $this->branch_id = isset($_GET["branch_id"]) ? $_GET["branch_id"] : null;
        $this->start_date = isset($_GET["start_month"]) ? $_GET["start_month"] : null;
        $this->end_date = isset($_GET["end_month"]) ? $_GET["end_month"] : null;
        $this->for_month = isset($_GET["for_month"]) ? $_GET["for_month"] : null;

        
		$query = Salary::where("salaries.admin_id","=",$this->admin_id)
        ->leftJoin('employee_departments','employee_departments.id','=','salaries.department_id')
        ->leftJoin('schools','schools.id','=','salaries.branch_id')
        ->leftJoin('employees','employees.user_unique_id','=','salaries.user_unique_id')
        ->leftJoin('users','users.id','=','salaries.approved_by');
        
        //return $admin_id;
        if($this->start_date && $this->end_date)
        {
                
            $query = Salary::where("salaries.admin_id","=",$this->admin_id)
            ->where('salaries.for_month','>=',$this->start_date)
            ->where('salaries.for_month','<=',$this->end_date)
            ->leftJoin('employee_departments','employee_departments.id','=','salaries.department_id')
            ->leftJoin('schools','schools.id','=','salaries.branch_id')
            ->leftJoin('employees','employees.user_unique_id','=','salaries.user_unique_id')
            ->leftJoin('users','users.id','=','salaries.approved_by');
            
        }
        if($this->branch_id)
        {
            $query->where('salaries.branch_id',$this->branch_id);
        }
		if($this->department_id)
        {
            $query->where('salaries.branch_id',$this->branch_id);
        }

        if($this->for_month)
        {
           $query->where('salaries.for_month',$this->for_month); 
        }
		 
		$salary = $query->select(  
                "employees.employee_id",
                "schools.school",
                "employees.name as employee_name",
                "employee_departments.name as department_name",
                "employees.designation",
                "employees.mobile",
                "employees.email",
                "employees.dob",
                "employees.doj",
                "employees.pan_number",
                "salaries.ctc",
                "salaries.gross_salary",
                "salaries.net_salary",
                "salaries.working_day",
                "salaries.attendance_details",
                "salaries.for_month",
                "users.name as approved_by_name",
                "salaries.status"
            )->orderBy('salaries.created_at', 'DESC')->get();

            foreach($salary as $sl)
            {
                $attendance = json_decode($sl->attendance_details);
                $sl->absent = $attendance->absent;
                $sl->present = $attendance->present;
                $sl->holiday = $attendance->holiday;
                $sl->halfday = $attendance->halfday;
                $sl->total_overtime = $attendance->total_overtime;
                $sl->total_late = $attendance->total_late;
                unset($sl->attendance_details);
            }

            return $salary;
           
        
	}

	public function headings(): array
	{
		return [
            "Employee Id",
            "Branch Name",
            "Employee Name",
            "Department",
            "Designation",
            "Mobile",
            "Email",
            "Date Of Birth",
            "Date Of Joining",
            "PAN Number",
            "CTC",
            "Gross salary",
            "Net Salary",
            "Working Days",
            "Month",
            "Approved By",
            "Status",
            "Absent",
            "Present",
            "Holiday",
            "Halfday",
            "Overtime",
            "Late"
		];
	}
}

Anon7 - 2021