Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function descargardoc($id)
- {
- // New Word document
- setlocale(LC_TIME, 'es');
- //return $id;
- $data = $this->getData($id);
- $status = $this->getStatus($id);
- $date = date('Y-m-d');
- $fecha_documento = $this->getFecha($data);
- $fecha_ingreso = $this->getFechaIngreso($data);
- $fecha_inicio_reduc = $this->getFechaReducJor($data);
- echo date('H:i:s') , " Create new PhpWord object" , PHP_EOL;
- $phpWord = new PhpOfficePhpWordPhpWord();
- $document = $phpWord->loadTemplate('doc/reduccion_de_jornada.docx');
- //Mapeo de Variables
- $document->setValue('ciudad', ($data['ciudad']) );
- $document->setValue('fecha_documento', $fecha_documento );
- $document->setValue('nombre_persona', ($data['nombre_persona']) );
- $document->setValue('apellido1', ($data['apellido1']) );
- $document->setValue('apellido2', ($data['apellido2']) );
- $document->setValue('dni', ($data['dni']) );
- $document->setValue('domicilio', ($data['domicilio']) );
- $document->setValue('calle', ($data['calle']) );
- $document->setValue('nrocalle', ($data['nrocalle']) );
- $document->setValue('piso', ($data['piso']) );
- $document->setValue('puerta', ($data['puerta']) );
- $document->setValue('codpostal', ($data['codpostal']) );
- $document->setValue('ciudad', ($data['ciudad']) );
- $document->setValue('nombre_empresa', ($data['nombre_empresa']) );
- $document->setValue('fecha_ingreso', $fecha_ingreso );
- $document->setValue('puesto_trabajo', ($data['puesto_trabajo']) );
- $document->setValue('categoria_profesional', ($data['categoria_profesional']) );
- $document->setValue('porcentaje_reduccion', ($data['porcentaje_reduccion']) );
- $document->setValue('razon_reduccion', ($data['razon_reduccion']) );
- $document->setValue('ini_horario_reduc', ($data['ini_horario_reduc']) );
- $document->setValue('fin_horario_reduc', ($data['fin_horario_reduc']) );
- $document->setValue('fecha_inicio_reduc', $fecha_inicio_reduc );
- $document->setValue('fin_dia_reduc', ($data['fin_dia_reduc']) );
- $document->setValue('preaviso', ($data['preaviso']) );
- $name = 'Doc'."$id".'-'.'ReduJornada'."$date".'.docx';
- echo date('H:i:s'), " Write to Word2007 format", PHP_EOL;
- $document->saveAs($name);
- rename($name, storage_path()."/word/{$name}");
- $file= storage_path(). "/word/{$name}";
- //$file= storage_path(). "/word/{$name}";
- $headers = array(
- //'Content-Type: application/msword',
- 'Content-Type: vnd.openxmlformats-officedocument.wordprocessingml.document'
- );
- $response = Response::download($file, $name, $headers);
- ob_end_clean();
- return $response;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement