jlamim

Correct Code

Apr 10th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public function submit ()
  2. {
  3. if(isset($_POST['cetak']))
  4. {
  5.  
  6. //do i wrong make variable data ?
  7. $data = $this->penjualan_model->cetak();
  8.  
  9. //is that correct put $data here ?
  10. $PDFContent=$this->load->view('admin/laporan/cetak_laporan', $data, true);
  11.  
  12. $url = 'http://freehtmltopdf.com';
  13.  
  14.  
  15. $apiConfigData = array('convert' => '',
  16. 'html' => $PDFContent,
  17. 'baseurl' => base_url(),
  18. 'width' => '210mm',
  19. 'enablejs' => 0,
  20. 'orientation' => 'portrait');
  21.  
  22.  
  23. //i'm still dont understand $data
  24. $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n",
  25. 'method' => 'POST',
  26. 'content' => http_build_query($apiConfigData)),);
  27.  
  28. $context = stream_context_create($options);
  29.  
  30. $result = file_get_contents($url, false, $context);
  31.  
  32. header('Content-type: application/pdf');
  33.  
  34. echo $result;
  35.  
  36.  
  37. }
  38.  
  39.  
  40.  
  41.  
  42. else if (isset($_POST['cari']))
  43. {
  44. $data['data'] = $this->penjualan_model->cetak();
  45. $this->load->view('admin/laporan/cari_laporan', $data);
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment