42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Docx_model extends MY_Model {
|
|
|
|
protected $service_url = 'http://office.pensare.nl';
|
|
|
|
function create_word_document($html, $filename){
|
|
// echo $html;
|
|
// die;
|
|
$data = $this->get_file_contents($html);
|
|
|
|
$this->download_file_contents($filename.'.docx', $data);
|
|
}
|
|
|
|
private function download_file_contents($filename, $data){
|
|
$this->load->helper('download');
|
|
|
|
force_download($filename, $data);
|
|
}
|
|
|
|
private function get_file_contents($html){
|
|
$curl = curl_init();
|
|
// Haalt een string op (file_get_contents)
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_RETURNTRANSFER => 1,
|
|
CURLOPT_URL => $this->service_url,
|
|
CURLOPT_POST => 1,
|
|
CURLOPT_POSTFIELDS => array(
|
|
'html' => $html
|
|
)
|
|
));
|
|
// Uitvoeren van het request, respons is een string
|
|
$response = curl_exec($curl);
|
|
|
|
// sluiten van het request
|
|
curl_close($curl);
|
|
|
|
return $response;
|
|
}
|
|
|
|
|
|
} |