"UEA", "KGM" => "KGM", "PCE" => "UB" ]; /** * Create a new job instance. * * @return void */ public function __construct(Order $order) { $this->order = $order; } /** * Execute the job. * * @return void */ public function handle() { /** @var Filesystem */ $disk = $this->getDisk(); /** @var OrderLine */ $orderlines = $this->order->lines; /** @var Customers */ $customer = $this->order->customer; /** @var Timeslot */ $timeslot = $this->order->timeslot; //insertion de la ligne d'en-têtes $csvlines[] = $this->header; foreach ($orderlines as $orderline) { $product = $orderline->product; $unité_commande = $product->order_unit ?? 'PCE'; //COLIS, KGM, PCE (faut il introduire un nouveau champs type unité de commande) $code_client = preg_replace('/[^\d]/', '', $customer->salarie->matricule); //matricule rh transmis sans les lettres de l'identifiant windows //convert to date object $datLivraison = Carbon::createFromFormat('d/m/Y H:i', $timeslot->day . " " . $timeslot->time); //on enleve un jour pour avoir le produit la veille $datLivraison = $datLivraison->subDay(); $oneline = [ $product->foodProduct->no_art, //21/01/2022 : suppression du pcb ici $code_client, $product->reference, "commande ferme", $unité_commande, $this->mode_commande[$unité_commande], //UEA,KGM,UB (respectivement selon le champ précédent) "", //on vide la colonne pcb comme demandé $datLivraison->format('d/m/Y'), //dd/mm/yyyy $orderline->quantity, $this->order->reference, ]; $csvlines[] = $oneline; } $data = $this->array2csv($csvlines, ";"); //$outputfilename = date("Ymd_His") . microtime(true) . ".csv"; $outputfilename = "BTQ_" . $this->order->reference . "_" . $code_client . "_" . $customer->salarie->nom . "_" . $customer->salarie->prenom . "_" . str_pad($customer->salarie->code_societe, 3, "0", STR_PAD_LEFT) . ".csv"; $disk->put($outputfilename, $data); //send this file by mail } }