public function pdfAction($annee, $format) { $this->get('sdis_affichage.comservice')->purger(); $pdf = new PDF(); $pdf->addPage('p', $format); $pdf->SetFont('Arial', 'B', 12); $pdf->SetXY(60, 7); if ($annee != 0) { $pdf->Write(0, 'PLANNING DES TOURNUS DE PIQUETS ' . $annee); } else { $pdf->Write(0, 'PLANNING DES TOURNUS DE PIQUETS ' . date('Y')); } $pdf->Ln(7); if ($format == 'A3') { $largeur = array(12, 15, 15, 8, 8, 8, 8, 50, 50, 50, 50); $deportX = 134; } else { $largeur = array(10, 10, 10, 8, 8, 8, 8, 33, 33, 33, 33); $deportX = 105; } $entetes = array("Date", '', '', 'Serv', 'Renf', 'Serv', 'Renf', 'Chef d\'intervention', 'Chef de groupe', 'Chauffeur', 'Intervenant'); $mois = array('', 'janv', 'févr', 'mars', 'avr', 'mai', 'juin', 'juil', 'août', 'sept', 'oct', 'nov', 'déc'); $jours = array('DI', 'LU', 'MA', 'ME', 'JE', 'VE', 'SA'); //Têtes de colonnes $pdf->SetFillColor(0, 0, 0); $pdf->SetTextColor(255); $pdf->SetDrawColor(0, 0, 0); if ($format == 'A3') { $pdf->SetFont('Arial', '', 10); } else { $pdf->SetFont('Arial', '', 8); } for ($i = 0; $i < count($entetes); $i++) { $pdf->Cell($largeur[$i], 7, $entetes[$i], 1, 0, 'C', true); } $pdf->Ln(); //Récuperer les piquets $piquets = $this->getDoctrine()->getManager()->getRepository('SdisAffichageBundle:Piquets')->findby(array(), array('debut' => 'ASC')); $pdf->SetTextColor(0); $pdf->SetDrawColor(0, 0, 0); if ($format == 'A3') { $pdf->SetFont('Arial', '', 8); } else { $pdf->SetFont('Arial', '', 6); } foreach ($piquets as $piquet) { if ($piquet->getCoachOfficier() != null or $format == 'A3') { $hauteur = 8; } else { $hauteur = 4; } $debut = $piquet->getDebut(); $fin = $piquet->getFin(); $pdf->Cell($largeur[0], $hauteur, utf8_decode($jours[$debut->format('w')]) . '-' . utf8_decode($jours[$fin->format('w')]), 1, 0); $pdf->Cell($largeur[1], $hauteur, $debut->format('d') . ' ' . utf8_decode($mois[$debut->format('n')]), 1, 0); $pdf->Cell($largeur[2], $hauteur, $fin->format('d') . ' ' . utf8_decode($mois[$fin->format('n')]), 1, 0); $rgb = $this->hex2rgb($piquet->getSectionService()->getCouleur()); $pdf->setFillColor($rgb[0], $rgb[1], $rgb[2]); $pdf->Cell($largeur[3], $hauteur, '', 1, 0, '', true); $rgb = $this->hex2rgb($piquet->getSectionRenfort()->getCouleur()); $pdf->setFillColor($rgb[0], $rgb[1], $rgb[2]); $pdf->Cell($largeur[4], $hauteur, '', 1, 0, '', true); $pdf->Cell($largeur[5], $hauteur, $piquet->getSectionService(), 1, 0); $pdf->Cell($largeur[6], $hauteur, $piquet->getSectionRenfort(), 1, 0); if ($piquet->getCoachOfficier() != null) { $pdf->Cell($largeur[7], 4, utf8_decode($piquet->getChefIntervention()), 'LTR', 2); $pdf->Cell($largeur[7], 4, utf8_decode($piquet->getCoachOfficier()), 'LRB', 0); $pdf->SetXY($deportX, $pdf->GetY() - 4); } else { $pdf->Cell($largeur[7], $hauteur, utf8_decode($piquet->getChefIntervention()), 1, 0); } $pdf->Cell($largeur[8], $hauteur, utf8_decode($piquet->getChefGroupe()), 1, 0); $pdf->Cell($largeur[9], $hauteur, utf8_decode($piquet->getChauffeur()), 1, 0); $pdf->Cell($largeur[10], $hauteur, utf8_decode($piquet->getIntervenant()), 1, 0); $pdf->Ln(); } $reponse = new Response(); $reponse->headers->set('Content-Type', 'application/pdf'); $pdf->Output(); return $reponse; }