Advertisement
freddy0512

contorller

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