<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class ExtractionCSV extends Mailable
{
    use Queueable, SerializesModels;

    protected $csv;
    protected $pdf;
    protected $pdf_simple;
    protected $csv_rs;//Reliquat stock
    protected $pdf_rs;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($csv, $pdf, $pdf_simple, $csv_rs, $pdf_rs)
    {
        $this->csv = $csv;
        $this->pdf = $pdf;
        $this->pdf_simple = $pdf_simple;
        $this->csv_rs = $csv_rs;
        $this->pdf_rs = $pdf_rs;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        // return mail with an attachment
        return $this->view('emails.extractionCSV')
            /*->from('extractionCsv@avogreen.fr', 'Extraction PDF & CSV')*/
            ->subject(date('dmY').' - Etat Précommande & Reliquat')
            ->attach($this->csv, [
                'as' => date('dmY').' AVOGREEN RESERVATION.csv',
                //'mime' => 'application/pdf',
            ])
            ->attach($this->pdf, [
                'as' => date('dmY').' AVOGREEN RESERVATION.pdf',
                //'mime' => 'application/pdf',
            ])
            ->attach($this->pdf_simple, [
                'as' => date('dmY').' AVOGREEN RESERVATION SIMPLE.pdf',
                //'mime' => 'application/pdf',
            ])
            ->attach($this->csv_rs, [
                'as' => date('dmY').' AVOGREEN Reliquat stock.csv',
                //'mime' => 'application/pdf',
            ])
            ->attach($this->pdf_rs, [
                'as' => date('dmY').' AVOGREEN Reliquat stock.pdf',
                //'mime' => 'application/pdf',
            ]);
    }
}
