1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
/**
* Ouvrir un *.doc document.
*
* @Route("/{donum}/open", name="dossier_open")
* @Method("GET")
* @Template()
*/
public function opendocAction($donum)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('AppBundle:Dossiers')->findOneBy(array('donum' => $donum));
if (!$entity) {
throw $this->createNotFoundException('Unable to find Dossiers entity.');
}
$ext = $entity->getDoassur()->getAssext();
// pour Mac
//$action = "open ";
//$path = "/Users/christianzirbes/Documents/exdoc_dossiers/";
//$ext = $ext."/";
// pour windows
$action = '"C:\\Program Files (x86)\\LibreOffice 4\\program\\swriter.exe" ';
$path = "C:\\Users\\ZIRBES\\Documents\\Compagnies\\";
$ext = $ext."\\";
$dossier = $donum.".doc";
$output = $action.$path.$ext.$dossier;
$process = new Process($output);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
$processOutput = $process->getOutput();
return array('output' => $processOutput);
//return $this->redirect($this->generateUrl('dossiers_show', array('donum' => $donum)));
} |
Partager