403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  D:/wamp/www/sipapbd_2019/application/modules/laporan_lain/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/wamp/www/sipapbd_2019/application/modules/laporan_lain/controllers/laporan_lain.php
<?php
class Laporan_lain  extends Core_Laporan {

  public function __construct()
  {
    parent::__construct();
    $this->modul_name = 'laporan_lain';
    $this->load->model('laporan_lain_model','data_model');
    $this->load->model('auth/login_model', 'auth');
    $this->load->helper('file');

    $this->xml_file = 'lap_lain.xml';
    $this->xml_custom = 'lap_lain_custom.xml';
    $this->xml_temp = 'lap_lain_temp.xml';
    $this->path = "./assets/fr/output/";
    $this->path2pdftk = dirname( realpath(SELF) )."/assets/pdftk/";
  }

  public function index()
  {
    $report = $this->load->library('report_builder');
    $data['modul'] = $this->modul_name;
    $html = $this->report_builder->get_html_menu($this->xml_file, $this->xml_custom, $this->xml_temp);
    $data['ul'] = $html;

    $data['title']= get_title('Laporan');
    $data['main_content']='laporan_lain_view';
    $data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
    $this->load->view('layout/template',$data);
  }

  function proses($tipe = '', $area = '', $grup = '', $unit = '')
  {
    if ( $tipe == '' || $area == '' || $grup == '' || $unit == '' )
    {
      echo 'Parameter tidak lengkap';
      return FALSE;
    }

    $format = $this->input->post('format');
    $this->tipe = intval($tipe);
    $this->area = intval($area);
    $this->group = intval($grup);
    $this->unit = intval($unit);

    if (! $report = $this->read_xml() )
    {
      return FALSE;
    }

    $param['fr3'] = $this->fr3;
    $param['nama'] = $this->nama_laporan;
    $param['format'] = $format ? $format : 'pdf';
    // parameter default
    foreach($this->default_param as $key => $val)
    {
      $param['opt'][$key] = $val;
    }

    $post = $this->input->post();
    if (!empty($post))
    {
      foreach( $post as $key => $value )
      {
        $param['opt'][ $key ] = $value;
      }
    }

    switch ($param['fr3'] )
    {
      case 'All_RKA_DPA.fr3' :  // cetak semua form RKA dan DPA
          $this->proses_all_rka_dpa($param);
          break;

      case 'All_RKA.fr3' :  // cetak semua form RKA
          $this->proses_all_rka($param);
          break;

      case 'RKADPA\RKA22.fr3' :  // cetak semua form RKA 22
          $param['opt']['id'] = 0;
          $this->start($param);
          break;

      case 'ALL_RKA221.fr3' :  // cetak semua form RKA 221
          $this->proses_all_rka221($param);
          break;

      case 'All_DPA.fr3' :  // cetak semua form DPA
          $this->proses_all_dpa($param);
          break;

      case 'RKADPA\DPA22.fr3' :  // cetak semua form DPA 22
          $param['opt']['id'] = 0;
          $this->start($param);
          break;

      case 'ALL_DPA221.fr3' :  // cetak semua form DPA 221
          $this->proses_all_dpa221($param);
          break;

      case 'All_DPA_SKPD.fr3' :  // cetak semua pengesahan DPA
          $this->proses_all_dpa_skpd($param);
          break;

      default:
        $this->start($param);
    }
  }

  private function createpdf($param)
  {
    $data  = 'ReportName='. $param['fr3'] ."\n";
    $data .= 'OutputType='. $param['format'] ."\n";
    $data .= 'DriverName='.$this->db->dbdriver."\n";
    $data .= 'Connection=DB Express'."\n";
    $data .= 'DBPort='.$this->db->port."\n";
    $data .= 'DBServer='.$this->db->hostname."\n";
    $data .= 'DBName='.$this->db->database."\n";
    $data .= 'DBUser='. $this->db->username."\n";
    $data .= 'DBPassword='. $this->db->password."\n";

    if (isset($param['opt'])) {
      foreach($param['opt'] as $key => $value){
        $data.=$key.'='.$value."\n";
      }
    }

    $in = tempnam($this->path2cache, "in");
    write_file($in, $data);
    $out = basename($in, '.tmp');
    $outfile = $this->path2output.$out;

    if( PHP_OS == 'WIN32' || PHP_OS == 'WINNT')
    {
      exec($this->path2engine.'RepEngine.exe "'.$in.'" "'.$outfile.'"');
    }
    else
    {
      exec('DISPLAY=:100 wine '.$this->path2engine.'RepEngine.exe "'.$in.'" "'.$outfile.'" 2>'.$this->path2engine.'RepEngine.log');
    }

    return $out;
  }

  private function get_halaman($filename)
  {
    if (!$fp = @fopen($filename,"r"))
    {
      return 1;
    }
    else {
      $max=0;
      while(!feof($fp)) {
        $line = fgets($fp,255);
        if (preg_match('/\/Count [0-9]+/', $line, $matches)){
          preg_match('/[0-9]+/',$matches[0], $matches2);
          if ($max<$matches2[0]) $max=$matches2[0];
        }
      }
      fclose($fp);
      return $max;
    }
  }

  // cetak semua RKA + DPA dari SKPD yang dipilih
  private function proses_all_rka_dpa($param)
  {
    $command = "";
    $cacah_hal = 1;

    $result = $this->data_model->getRKA($param['opt']['id_skpd']);
    for($i = 0; $i < count($result); $i++){
      //------------------------------------------- RKA ------------------------------------------------
      if ($result[$i]['RKA'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA.fr3');
        $param['opt']['id'] = $result[$i]['RKA'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA1'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA1.fr3');
        $param['opt']['id'] = $result[$i]['RKA1'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA21'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA21.fr3');
        $param['opt']['id'] = $result[$i]['RKA21'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      elseif ($result[$i]['RKA22'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA22.fr3');
        $param['opt']['id'] = $result[$i]['RKA22'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA221'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA221.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKAL'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKAL.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA31'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA31.fr3');
        $param['opt']['id'] = $result[$i]['RKA31'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA32'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA32.fr3');
        $param['opt']['id'] = $result[$i]['RKA32'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      //*------------------------------------------- DPA ------------------------------------------------
      if ($result[$i]['DPA'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA.fr3');
        $param['opt']['id'] = $result[$i]['DPA'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA1'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA1.fr3');
        $param['opt']['id'] = $result[$i]['DPA1'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA21'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA21.fr3');
        $param['opt']['id'] = $result[$i]['DPA21'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA22'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA22.fr3');
        $param['opt']['id'] = $result[$i]['DPA22'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA221'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA221.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPAL'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPAL.fr3');
        $param['opt']['id'] = '0';
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA31'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA31.fr3');
        $param['opt']['id'] = $result[$i]['DPA31'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA32'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA32.fr3');
        $param['opt']['id'] = $result[$i]['DPA32'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
    }

    $data = 'ReportName='. $param['fr3'] ."\n";
    $data .= 'OutputType='. $param['format'] ."\n";
    $in   = tempnam($this->path2cache, "in");
    write_file($in, $data);
    $out   = basename( $in, '.tmp');
    $output = $this->path.$out.".pdf";

    if( PHP_OS == 'WIN32' || PHP_OS == 'WINNT')
    {
      exec($this->path2pdftk."pdftk $command output $output");
    }
    else
    {
      // pdftk harus sudah di install di server linux
      exec("pdftk $command output $output");
    }

    $response = (object) NULL;
    $response->sql = $this->db->queries;
    $response->jml = count($result);
    if (file_exists($output))
    {
      $response->isSuccessful = TRUE;
      $response->id = $out;
      $response->nama = 'Laporan_Semua_RKA_dan_DPA';
      $response->message = 'Laporan sukses dibuat.';
    }
    else
    {
      $response->isSuccessful = FALSE;
      $response->message = 'Laporan gagal dibuat.';
    }
    echo json_encode($response);
  }

  // cetak semua RKA dari SKPD yang dipilih
  private function proses_all_rka($param)
  {
    $command = "";
    $cacah_hal = 1;

    $result = $this->data_model->getRKA($param['opt']['id_skpd']);
    for($i = 0; $i < count($result); $i++){
      //------------------------------------------- RKA ------------------------------------------------
      if ($result[$i]['RKA'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA.fr3');
        $param['opt']['id'] = $result[$i]['RKA'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA1'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA1.fr3');
        $param['opt']['id'] = $result[$i]['RKA1'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA21'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA21.fr3');
        $param['opt']['id'] = $result[$i]['RKA21'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA22'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA22.fr3');
        $param['opt']['id'] = $result[$i]['RKA22'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA221'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA221.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKAL'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKAL.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA31'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA31.fr3');
        $param['opt']['id'] = $result[$i]['RKA31'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['RKA32'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\RKA32.fr3');
        $param['opt']['id'] = $result[$i]['RKA32'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
    }

    $data = 'ReportName='. $param['fr3'] ."\n";
    $data .= 'OutputType='. $param['format'] ."\n";
    $in   = tempnam($this->path2cache, "in");
    write_file($in, $data);
    $out   = basename( $in, '.tmp');
    $output = $this->path.$out.".pdf";

    if( PHP_OS == 'WIN32' || PHP_OS == 'WINNT')
    {
      exec($this->path2pdftk."pdftk $command output $output");
    }
    else
    {
      // pdftk harus sudah di install di server linux
      exec("pdftk $command output $output");
    }

    $response = (object) NULL;
    if (file_exists($output))
    {
      $response->isSuccessful = TRUE;
      $response->id = $out;
      $response->nama = 'Laporan_Semua_RKA';
      $response->message = 'Laporan sukses dibuat.';
    }
    else
    {
      $response->isSuccessful = FALSE;
      $response->message = 'Laporan gagal dibuat.';
    }
    echo json_encode($response);
  }

  // cetak semua RKA 221 dari SKPD yang dipilih
  private function proses_all_rka221($param)
  {
    $result = $this->data_model->getRKA($param['opt']['id_skpd']);
    for($i = 0; $i < count($result); $i++)
    {
      if ($result[$i]['RKA221'] > 0)
      {
        $param['fr3'] = get_report('RKADPA\RKA221.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
      }
    }

    $out   = basename( $outfile, '.pdf');
    $output = $this->path.$out.".pdf";

    $response = (object) NULL;
    if (file_exists($output))
    {
      $response->isSuccessful = TRUE;
      $response->id = $out;
      $response->nama = 'Laporan_Semua_RKA221';
      $response->message = 'Laporan sukses dibuat.';
    }
    else
    {
      $response->isSuccessful = FALSE;
      $response->message = 'Laporan gagal dibuat.';
    }
    echo json_encode($response);
  }

  // cetak semua DPA dari SKPD yang dipilih
  private function proses_all_dpa($param)
  {
    $command = "";
    $cacah_hal = 1;

    $result = $this->data_model->getRKA($param['opt']['id_skpd']);
    for($i = 0; $i < count($result); $i++){
      if ($result[$i]['DPA'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA.fr3');
        $param['opt']['id'] = $result[$i]['DPA'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA1'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA1.fr3');
        $param['opt']['id'] = $result[$i]['DPA1'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA21'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA21.fr3');
        $param['opt']['id'] = $result[$i]['DPA21'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA22'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA22.fr3');
        $param['opt']['id'] = $result[$i]['DPA22'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA221'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA221.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPAL'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPAL.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA31'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA31.fr3');
        $param['opt']['id'] = $result[$i]['DPA31'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
      if ($result[$i]['DPA32'] > 0)
      {
        $param['opt']['hal_no'] = $cacah_hal;
        $param['fr3'] = get_report('RKADPA\DPA32.fr3');
        $param['opt']['id'] = $result[$i]['DPA32'];
        $outfile = $this->createpdf($param);
        if (file_exists($this->path2output.$outfile.".ok"))
        {
          $cacah_hal += $this->get_halaman($this->path2output.$outfile.".pdf");
          $command = $command.$this->path.$outfile.'.pdf ';
        }
      }
    }

    $data = 'ReportName='. $param['fr3'] ."\n";
    $data .= 'OutputType='. $param['format'] ."\n";
    $in   = tempnam($this->path2cache, "in");
    write_file($in, $data);
    $out   = basename( $in, '.tmp');
    $output = $this->path.$out.".pdf";

    if( PHP_OS == 'WIN32' || PHP_OS == 'WINNT')
    {
      exec($this->path2pdftk."pdftk $command output $output");
    }
    else
    {
      // pdftk harus sudah di install di server linux
      exec("pdftk $command output $output");
    }

    $response = (object) NULL;
    if (file_exists($output))
    {
      $response->isSuccessful = TRUE;
      $response->id = $out;
      $response->nama = 'Laporan_Semua_DPA';
      $response->message = 'Laporan sukses dibuat.';
    }
    else
    {
      $response->isSuccessful = FALSE;
      $response->message = 'Laporan gagal dibuat.';
    }
    echo json_encode($response);
  }

  // cetak semua DPA 221 dari SKPD yang dipilih
  private function proses_all_dpa221($param)
  {
    $result = $this->data_model->getRKA($param['opt']['id_skpd']);
    for($i = 0; $i < count($result); $i++)
    {
      if ($result[$i]['DPA221'] > 0)
      {
        $param['fr3'] = get_report('RKADPA\DPA221.fr3');
        $param['opt']['id'] = '0';
        $param['opt']['id_skpd'] = $result[$i]['ID_SKPD'];
        $outfile = $this->createpdf($param);
      }
    }

    $out   = basename( $outfile, '.pdf');
    $output = $this->path.$out.".pdf";

    $response = (object) NULL;
    if (file_exists($output))
    {
      $response->isSuccessful = TRUE;
      $response->id = $out;
      $response->nama = 'Laporan_Semua_DPA221';
      $response->message = 'Laporan sukses dibuat.';
    }
    else
    {
      $response->isSuccessful = FALSE;
      $response->message = 'Laporan gagal dibuat.';
    }
    echo json_encode($response);
  }

  // cetak semua Pengesahan DPA SKPD yang dipilih
  private function proses_all_dpa_skpd($param)
  {
    $result = $this->data_model->getDPASKPD($param['opt']['id_skpd']);
    for($i = 0; $i < count($result); $i++)
    {
      if ($result[$i]['DPA'] > 0)
      {
        $param['fr3'] = get_report('Laporan\Pengesahan_DPA.fr3');
        $param['opt']['id'] = $result[$i]['DPA'];
        $outfile = $this->createpdf($param);
      }
    }

    $out   = basename( $outfile, '.pdf');
    $output = $this->path.$out.".pdf";

    $response = (object) NULL;
    if (file_exists($output))
    {
      $response->isSuccessful = TRUE;
      $response->id = $out;
      $response->nama = 'Laporan_Pengesahan_DPA';
      $response->message = 'Laporan sukses dibuat.';
    }
    else
    {
      $response->isSuccessful = FALSE;
      $response->message = 'Laporan gagal dibuat.';
    }
    echo json_encode($response);
  }

}

Youez - 2016 - github.com/yon3zu
LinuXploit