Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. public function descargardoc($id)
  2. {
  3. // New Word document
  4. setlocale(LC_TIME, 'es');
  5. //return $id;
  6. $data = $this->getData($id);
  7. $status = $this->getStatus($id);
  8. $date = date('Y-m-d');
  9. $fecha_documento = $this->getFecha($data);
  10. $fecha_ingreso = $this->getFechaIngreso($data);
  11. $fecha_inicio_reduc = $this->getFechaReducJor($data);
  12.  
  13. echo date('H:i:s') , " Create new PhpWord object" , PHP_EOL;
  14. $phpWord = new PhpOfficePhpWordPhpWord();
  15.  
  16. $document = $phpWord->loadTemplate('doc/reduccion_de_jornada.docx');
  17.  
  18. //Mapeo de Variables
  19.  
  20. $document->setValue('ciudad', ($data['ciudad']) );
  21. $document->setValue('fecha_documento', $fecha_documento );
  22. $document->setValue('nombre_persona', ($data['nombre_persona']) );
  23. $document->setValue('apellido1', ($data['apellido1']) );
  24. $document->setValue('apellido2', ($data['apellido2']) );
  25. $document->setValue('dni', ($data['dni']) );
  26. $document->setValue('domicilio', ($data['domicilio']) );
  27. $document->setValue('calle', ($data['calle']) );
  28. $document->setValue('nrocalle', ($data['nrocalle']) );
  29. $document->setValue('piso', ($data['piso']) );
  30. $document->setValue('puerta', ($data['puerta']) );
  31. $document->setValue('codpostal', ($data['codpostal']) );
  32. $document->setValue('ciudad', ($data['ciudad']) );
  33. $document->setValue('nombre_empresa', ($data['nombre_empresa']) );
  34. $document->setValue('fecha_ingreso', $fecha_ingreso );
  35. $document->setValue('puesto_trabajo', ($data['puesto_trabajo']) );
  36. $document->setValue('categoria_profesional', ($data['categoria_profesional']) );
  37. $document->setValue('porcentaje_reduccion', ($data['porcentaje_reduccion']) );
  38. $document->setValue('razon_reduccion', ($data['razon_reduccion']) );
  39. $document->setValue('ini_horario_reduc', ($data['ini_horario_reduc']) );
  40. $document->setValue('fin_horario_reduc', ($data['fin_horario_reduc']) );
  41. $document->setValue('fecha_inicio_reduc', $fecha_inicio_reduc );
  42. $document->setValue('fin_dia_reduc', ($data['fin_dia_reduc']) );
  43. $document->setValue('preaviso', ($data['preaviso']) );
  44.  
  45.  
  46.  
  47. $name = 'Doc'."$id".'-'.'ReduJornada'."$date".'.docx';
  48. echo date('H:i:s'), " Write to Word2007 format", PHP_EOL;
  49. $document->saveAs($name);
  50. rename($name, storage_path()."/word/{$name}");
  51. $file= storage_path(). "/word/{$name}";
  52.  
  53. //$file= storage_path(). "/word/{$name}";
  54.  
  55. $headers = array(
  56. //'Content-Type: application/msword',
  57. 'Content-Type: vnd.openxmlformats-officedocument.wordprocessingml.document'
  58. );
  59.  
  60. $response = Response::download($file, $name, $headers);
  61. ob_end_clean();
  62.  
  63. return $response;
  64.  
  65.  
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement