<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\WithMultipleSheets;

//for using multiplesheets
use App\Exports\StaffInTurnover;
use App\Exports\StaffOutTurnover;
use App\Exports\InflationInPay;
use App\Exports\LevelandAreasofStaffAffect;
use App\Exports\DurationofService;
use App\Exports\SalaryScale;

class ExcelMultipleExport implements WithMultipleSheets
{
    private $data = [];

    //Use when have data
    public function __construct($newprod, $newprod1, $newprod2, $newprod3, $newprod4, $newprod5)
    {
        $this->data[0] = $newprod;
        $this->data[1] = $newprod1;
        $this->data[2] = $newprod2;
        $this->data[3] = $newprod3;
        $this->data[4] = $newprod4;
        $this->data[5] = $newprod5;
    }


    public function sheets(): array
    {
        $sheets = [];

        //for testing
        // $testdata = [[1, 2, 3],[4, 5, 6]];
        // $sheets['Staff In Turnover'] = new StaffInTurnover($testdata);
        // $sheets['Staff Out Turnover'] = new StaffOutTurnover($testdata);
        // $sheets['Inflation in Pay'] = new InflationInPay($testdata);
        // $sheets['Level and Areas of staff Affect'] = new LevelandAreasofStaffAffect($testdata);
        // $sheets['Duration of Service'] = new DurationofService($testdata);
        // $sheets['Salary Scale'] = new SalaryScale($testdata);

        //when have data
        $sheets['Staff In Turnover'] = new StaffInTurnover($this->data[0]);
        $sheets['Staff Out Turnover'] = new StaffOutTurnover($this->data[1]);
        $sheets['Inflation in Pay'] = new InflationInPay($this->data[2]);
        $sheets['Level and Areas of staff Affect'] = new LevelandAreasofStaffAffect($this->data[3]);
        $sheets['Duration of Service'] = new DurationofService($this->data[4]);
        $sheets['Salary Scale'] = new SalaryScale($this->data[5]);

        return $sheets;
    }
}
