SHOW:
|
|
- or go back to the newest paste.
1 | - | $PDFContent = "page HTML CONTENT"; |
1 | + | public function submit () |
2 | { | |
3 | - | //API URL |
3 | + | if(isset($_POST['cetak'])) |
4 | { | |
5 | ||
6 | - | //API PARAMS |
6 | + | //data should be here then we dont need data anymore |
7 | - | $data = array('convert' => '', |
7 | + | $data['data'] = $this->penjualan_model->cetak(); |
8 | - | 'html' => $PDFContent, |
8 | + | $PDFContent=$this->load->view('admin/laporan/cetak_laporan', $data, true); |
9 | - | 'baseurl' => base_url(), |
9 | + | |
10 | - | 'width' => '210mm', |
10 | + | |
11 | - | 'enablejs' => 0, |
11 | + | $data = array('convert' => '', |
12 | - | 'orientation' => 'portrait'); |
12 | + | 'html' => $PDFContent, |
13 | 'baseurl' => base_url(), | |
14 | - | // use key 'http' even if you send the request to https://... |
14 | + | 'width' => '210mm', |
15 | 'enablejs' => 0, | |
16 | - | 'method' => 'POST', |
16 | + | 'orientation' => 'portrait'); |
17 | - | 'content' => http_build_query($data)),); |
17 | + | |
18 | - | //PREPARE OPTIONS VARIABLE |
18 | + | |
19 | $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", | |
20 | 'method' => 'POST', | |
21 | - | //GET PDF CONTENT |
21 | + | 'content' => http_build_query($data)),); |
22 | ||
23 | $context = stream_context_create($options); | |
24 | - | // set the pdf data as download content: |
24 | + | |
25 | $result = file_get_contents($url, false, $context); | |
26 | ||
27 | - | //OPEN PDF FILE IN YOUR BROWSER |
27 | + | |
28 | - | echo $result; |
28 | + | |
29 | echo $result; | |
30 | ||
31 | ||
32 | } | |
33 | ||
34 | ||
35 | ||
36 | ||
37 | else if (isset($_POST['cari'])) | |
38 | { | |
39 | $data['data'] = $this->penjualan_model->cetak(); | |
40 | $this->load->view('admin/laporan/cari_laporan', $data); | |
41 | ||
42 | } | |
43 | } |