/**
  * Genera un listado en PDF con todos clientes del comercial
  * separados por dia (el rutero)
  */
 public function HojaLlamadasAction()
 {
     if ($this->values['permisos']['permisosModulo']['LI']) {
         $idComercial = $this->request[2];
         $comercial = new Agentes($idComercial);
         $dia = $this->request[3];
         $dias = new DiasSemana($dia);
         $opciones = array('title' => 'Hoja de llamadas para el ' . strtoupper($dias->getDescripcion()) . ' del comercial ' . strtoupper($comercial->getNombre()));
         unset($comercial);
         unset($dias);
         //CREAR EL DOCUMENTO-------------------------------------------------------------
         $pdf = new HojaLlamadasPDF('L', 'mm', 'A4', $opciones);
         //$pdf->SetTopMargin($MEDIDAS['MargenSup']);
         //$pdf->SetLeftMargin($MEDIDAS['MargenIzq']);
         $pdf->SetAuthor("Informatica ALBATRONIC, SL");
         $pdf->SetTitle('Hoja de llamadas Ventas');
         $pdf->AliasNbPages();
         $pdf->SetFillColor(210);
         $pdf->AddPage();
         $pdf->SetAutoPageBreak(1, 15);
         $lis = new $this->entity();
         $rows = $lis->cargaCondicion("Id", "IDComercial='{$idComercial}' and Dia='{$dia}'", "OrdenCliente,IDZona ASC");
         unset($lis);
         //CUERPO-------------------------------------------------------------------------
         $pdf->SetFont('Courier', '', 8);
         foreach ($rows as $value) {
             $datos = new $this->entity($value['Id']);
             $pdf->Cell(10, 6, "", 0, 0);
             $pdf->Cell(100, 6, $pdf->DecodificaTexto($datos->getIDCliente()->getRazonSocial() . " - " . $datos->getIDCliente()->getNombreComercial(), 59), 0, 0);
             $pdf->Cell(20, 6, $pdf->DecodificaTexto($datos->getIDCliente()->getIDPoblacion()->getMunicipio(), 11), 0, 0);
             $pdf->Cell(45, 6, trim($datos->getIDCliente()->getTelefono() . " " . $datos->getIDCliente()->getMovil()), 0, 0);
             $pdf->Cell(10, 6, $datos->getIDCliente()->getLimiteRiesgo(), 0, 0, "R");
             $pdf->Ln();
             $dEntrega = new ClientesDentrega();
             $direcciones = $dEntrega->cargaCondicion("IDDirec", "IDCliente='{$datos->getIDCliente()->getIDCliente()}' and IDZona='{$datos->getIDZona()->getIDZona()}'");
             foreach ($direcciones as $direccion) {
                 $dEntrega = new ClientesDentrega($direccion['IDDirec']);
                 $pdf->Cell(15, 4, $dEntrega->getHorarioLlamadas(), 0, 0);
                 $pdf->Cell(0, 4, $dEntrega->getDireccion(), 0, 1);
             }
             unset($dEntrega);
             $pdf->Cell(0, 3, str_repeat("-", 159), 0, 1);
         }
         unset($datos);
         $archivo = "docs/docs" . $_SESSION['emp'] . "/pdfs/" . md5(date('d-m-Y H:i:s')) . ".pdf";
         $pdf->Output($archivo, 'F');
         unset($pdf);
         $this->values['archivo'] = $archivo;
         return array('template' => '_global/listadoPdf.html.twig', 'values' => $this->values);
     } else {
         return array('template' => '_global/forbiden.html.twig');
     }
 }