Advertisement
fiqriachmada

Custom.php

Mar 4th, 2021
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.16 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  4. // use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
  5. // use PhpOffice\PhpSpreadsheet\Reader\Xls;
  6. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  7. class Custom extends CI_Controller {
  8.     var $d;
  9.     var $in;
  10.  
  11.     public function __construct()
  12.     {
  13.         parent::__construct();
  14.         if(!isset($_SERVER['HTTP_REFERER'])) redirect('/');
  15.         $this->d = getSession($this);
  16.         $this->d->_notification = getNotification($this);
  17.         $this->d->_controller = $this->router->fetch_class();
  18.         $this->d->_method = $this->router->fetch_method();
  19.         loadLanguage($this, $this->d->_controller, $this->d->_method);
  20.         $this->in = getPostAsObject($this);
  21.         checkstatus($this);
  22.         if(!$this->session->userdata('authenticated')) {
  23.             redirect('/login');
  24.         }
  25.         helper_log();
  26.     }
  27.  
  28.     public function index()
  29.     {
  30.         $this->load->view('template_view');
  31.     }
  32.  
  33.     function laporan_pemasukan($arg1="", $arg2="")
  34.     {
  35.         if(empty($arg1)) $this->d->_action = 'view';
  36.         else $this->d->_action = $arg1;
  37.  
  38.         modelLoad($this,array('mtpb_header'));
  39.         if($this->d->_action == 'view'){
  40.             modelLoad($this,array('mreferensi_dokumen_pabean'));
  41.             $this->d->sdokumen_pabean = $this->mreferensi_dokumen_pabean->viewPosting(1);
  42.         } else if($this->d->_action == 'viewdt'){
  43.             modelLoad($this,array('mtpb_barang'));
  44.             $res = $this->mtpb_barang->viewCustomsIn($this->in);
  45.             printJSON($res);
  46.         } else if($this->d->_action == 'excel'){
  47.             printJSON($this->in);
  48.             // modelLoad($this,array('mtpb_barang'));
  49.             // $res = $this->mtpb_barang->viewCustomsIn($this->in);
  50.             // printJSON($res);
  51.         }
  52.  
  53.         $this->load->view('template_view', $this->d);
  54.     }
  55.  
  56.     function laporan_pengeluaran($arg1="", $arg2="")
  57.     {
  58.         if(empty($arg1)) $this->d->_action = 'view';
  59.         else $this->d->_action = $arg1;
  60.  
  61.         modelLoad($this,array('mtpb_header'));
  62.         if($this->d->_action == 'view'){
  63.             modelLoad($this,array('mreferensi_dokumen_pabean'));
  64.             $this->d->sdokumen_pabean = $this->mreferensi_dokumen_pabean->viewPosting(3);
  65.         } else if($this->d->_action == 'viewdt'){
  66.             modelLoad($this,array('mtpb_barang'));
  67.             $res = $this->mtpb_barang->viewCustomsOut($this->in);
  68.             printJSON($res);
  69.         }
  70.  
  71.         $this->load->view('template_view', $this->d);
  72.     }
  73.  
  74.     function laporan_wip($arg1="", $arg2="")
  75.     {
  76.         if(empty($arg1)) $this->d->_action = 'view';
  77.         else $this->d->_action = $arg1;
  78.  
  79.         $this->load->model('vt_customs');
  80.         if($this->d->_action == 'view'){
  81.  
  82.         } else if($this->d->_action == 'store'){
  83.  
  84.         } else if($this->d->_action == 'edit'){
  85.  
  86.         } else if($this->d->_action == 'update'){
  87.  
  88.         } else if($this->d->_action == 'delete'){
  89.  
  90.         } else if($this->d->_action == 'viewdt'){
  91.             $res = $this->vt_customs->viewWIP($this->in);
  92.             printJSON($res);
  93.         } else if($this->d->_action == ''){
  94.  
  95.         }
  96.  
  97.         $this->load->view('template_view', $this->d);
  98.     }
  99.     function custom_laporan_mutasi_bahan_baku($arg1="", $arg2="")
  100.     {
  101.         if(empty($arg1)) $this->d->_action = 'view';
  102.         else $this->d->_action = $arg1;
  103.  
  104.         $this->load->model('vt_customs');
  105.         if($this->d->_action == 'view'){
  106.  
  107.         } else if($this->d->_action == 'store'){
  108.  
  109.         } else if($this->d->_action == 'edit'){
  110.  
  111.         } else if($this->d->_action == 'update'){
  112.  
  113.         } else if($this->d->_action == 'delete'){
  114.  
  115.         } else if($this->d->_action == 'viewdt'){
  116.             $res = $this->vt_customs->viewWIP($this->in);
  117.             printJSON($res);
  118.        
  119.         } else if($this->d->_action == ''){
  120.  
  121.         }
  122.  
  123.         $this->load->view('template_view', $this->d);
  124.     }
  125.  
  126.     function laporan_mutasi_bahan_baku($arg1="", $arg2="")
  127.     {
  128.         if(empty($arg1)) $this->d->_action = 'view';
  129.         else $this->d->_action = $arg1;
  130.  
  131. //      $this->load->model('msales_approval');
  132.         if($this->d->_action == 'add'){
  133.             $this->d->_modal = array('referensi_dokumen_pabean');
  134.         } else if($this->d->_action == 'store'){
  135.  
  136.         } else if($this->d->_action == 'edit'){
  137.  
  138.         } else if($this->d->_action == 'update'){
  139.  
  140.         } else if($this->d->_action == 'delete'){
  141.  
  142.         } else if($this->d->_action == 'viewdt'){
  143.             modelLoad($this,array('mt_wh_detail'));
  144.             $res = $this->mt_wh_detail->viewMutationDT($this->in);
  145.             printJSON($res);
  146.         } else if($this->d->_action == 'toExcel'){
  147.             // printJSON($this->in);
  148.             $spreadsheet = new Spreadsheet();
  149.             $sheet = $spreadsheet->getActiveSheet();
  150.             $sheet->setCellValue('A1', 'No');
  151.             $sheet->setCellValue('B1', 'Kode Barang');
  152.             $sheet->setCellValue('C1', 'Kode External');
  153.             $sheet->setCellValue('D1', 'Nama Barang');
  154.             $sheet->setCellValue('E1', 'Unit');
  155.             $sheet->setCellValue('F1', 'Saldo Awal');
  156.             $sheet->setCellValue('G1', 'Pemasukan');
  157.             $sheet->setCellValue('H1', 'Pengeluaran');
  158.             $sheet->setCellValue('I1', 'Penyesuaian Adjustment');
  159.             $sheet->setCellValue('J1', 'Saldo Akhir');
  160.             $sheet->setCellValue('K1', 'Stock Opname');
  161.             $sheet->setCellValue('L1', 'Selisih');
  162.             $sheet->setCellValue('M1', 'Keterangan');
  163.             modelLoad($this,array('mt_wh_detail'));
  164.             $res = $this->mt_wh_detail->toExcel($this->in);
  165.             // printJSON($res);
  166.             $no = 1;
  167.             $x = 2;
  168.             foreach($res as $res) {
  169.                 $sheet->setCellValue('A' .$x, $no++);
  170.                 $sheet->setCellValue('B' .$x, $res->kode_barang);
  171.                 $sheet->setCellValue('C' .$x, $res->external_code);
  172.                 $sheet->setCellValue('D' .$x, $res->nama_barang);
  173.                 $sheet->setCellValue('E' .$x, $res->kode_satuan);
  174.                 $sheet->setCellValue('F' .$x, number_format($res->qty_begin,2));
  175.                 $sheet->setCellValue('G' .$x, number_format($res->qty_in,2));
  176.                 $sheet->setCellValue('H' .$x, number_format($res->qty_out,2));
  177.                 $sheet->setCellValue('I' .$x, number_format($res->qty_adjust,2));
  178.                 $sheet->setCellValue('J' .$x, number_format($res->qty_end,2));
  179.                 $sheet->setCellValue('K' .$x, number_format($res->qty_opname,2));
  180.                 $sheet->setCellValue('L' .$x, number_format($res->qty_selisih,2));
  181.                 $sheet->setCellValue('M' .$x, $res->description);
  182.                 $x++;
  183.             }
  184.             $styleArray = array(
  185.                 'borders' => array(
  186.                     'allBorders' => array(
  187.                         'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
  188.                     ),
  189.                 ),
  190.             );
  191.             $i = $x - 1;
  192.             foreach(range('A','M') as $columnID) {
  193.                 $sheet->getColumnDimension($columnID)
  194.                     ->setAutoSize(true);   
  195.             }
  196.             $sheet->getStyle('A1:M'.$i)->applyFromArray($styleArray);
  197.            
  198.             $writer = new Xlsx($spreadsheet);
  199.             header('Content-Type: application/vnd.ms-excel');
  200.             header('Content-Disposition: attachment;filename="'.$this->d->_controller . '/' . $this->d->_method.'.xlsx"');
  201.             header('Cache-Control: max-age=0');
  202.             $writer->save('php://output');
  203.         }
  204.  
  205.         $this->load->view('template_view', $this->d);
  206.     }
  207.  
  208.     function laporan_mutasi_bahan_bakar($arg1="", $arg2="")
  209.     {
  210.         if(empty($arg1)) $this->d->_action = 'view';
  211.         else $this->d->_action = $arg1;
  212.  
  213. //      $this->load->model('msales_approval');
  214.         if($this->d->_action == 'add'){
  215.             $this->d->_modal = array('referensi_dokumen_pabean');
  216.         } else if($this->d->_action == 'store'){
  217.  
  218.         } else if($this->d->_action == 'edit'){
  219.  
  220.         } else if($this->d->_action == 'update'){
  221.  
  222.         } else if($this->d->_action == 'delete'){
  223.  
  224.         } else if($this->d->_action == 'viewdt'){
  225. //          $res = $this->mreferensi_dokumen_pabean->viewDT($this->in);
  226. //          printJSON($res);
  227.         } else if($this->d->_action == ''){
  228.  
  229.         }
  230.  
  231.         $this->load->view('template_view', $this->d);
  232.     }
  233.  
  234.     function laporan_mutasi_barang_jadi($arg1="", $arg2="")
  235.     {
  236.         if(empty($arg1)) $this->d->_action = 'view';
  237.         else $this->d->_action = $arg1;
  238.  
  239. //      $this->load->model('msales_approval');
  240.         if($this->d->_action == 'add'){
  241.             $this->d->_modal = array('referensi_dokumen_pabean');
  242.         } else if($this->d->_action == 'store'){
  243.  
  244.         } else if($this->d->_action == 'edit'){
  245.  
  246.         } else if($this->d->_action == 'update'){
  247.  
  248.         } else if($this->d->_action == 'delete'){
  249.  
  250.         } else if($this->d->_action == 'viewdt'){
  251.             modelLoad($this,array('mt_wh_detail'));
  252.             $res = $this->mt_wh_detail->viewMutationDT($this->in);
  253.             printJSON($res);
  254.         } else if($this->d->_action == ''){
  255.  
  256.         }
  257.  
  258.         $this->load->view('template_view', $this->d);
  259.     }
  260.  
  261.     function laporan_mutasi_barang_modal($arg1="", $arg2="")
  262.     {
  263.         if(empty($arg1)) $this->d->_action = 'view';
  264.         else $this->d->_action = $arg1;
  265.  
  266. //      $this->load->model('msales_approval');
  267.         if($this->d->_action == 'add'){
  268.             $this->d->_modal = array('referensi_dokumen_pabean');
  269.         } else if($this->d->_action == 'store'){
  270.  
  271.         } else if($this->d->_action == 'edit'){
  272.  
  273.         } else if($this->d->_action == 'update'){
  274.  
  275.         } else if($this->d->_action == 'delete'){
  276.  
  277.         } else if($this->d->_action == 'viewdt'){
  278.             modelLoad($this,array('mt_wh_detail'));
  279.             $res = $this->mt_wh_detail->viewMutationDT($this->in);
  280.             printJSON($res);
  281.         } else if($this->d->_action == ''){
  282.  
  283.         }
  284.  
  285.         $this->load->view('template_view', $this->d);
  286.     }
  287.  
  288.     function laporan_mutasi_keperluan_penelitian($arg1="", $arg2="")
  289.     {
  290.         if(empty($arg1)) $this->d->_action = 'view';
  291.         else $this->d->_action = $arg1;
  292.  
  293. //      $this->load->model('msales_approval');
  294.         if($this->d->_action == 'add'){
  295.             $this->d->_modal = array('referensi_dokumen_pabean');
  296.         } else if($this->d->_action == 'store'){
  297.  
  298.         } else if($this->d->_action == 'edit'){
  299.  
  300.         } else if($this->d->_action == 'update'){
  301.  
  302.         } else if($this->d->_action == 'delete'){
  303.  
  304.         } else if($this->d->_action == 'viewdt'){
  305.             modelLoad($this,array('mt_wh_detail'));
  306.             $res = $this->mt_wh_detail->viewMutationDT($this->in);
  307.             printJSON($res);
  308.         } else if($this->d->_action == ''){
  309.  
  310.         }
  311.  
  312.         $this->load->view('template_view', $this->d);
  313.     }
  314.  
  315.     function laporan_mutasi_peralatan_kantor($arg1="", $arg2="")
  316.     {
  317.         if(empty($arg1)) $this->d->_action = 'view';
  318.         else $this->d->_action = $arg1;
  319.  
  320. //      $this->load->model('msales_approval');
  321.         if($this->d->_action == 'add'){
  322.             $this->d->_modal = array('referensi_dokumen_pabean');
  323.         } else if($this->d->_action == 'store'){
  324.  
  325.         } else if($this->d->_action == 'edit'){
  326.  
  327.         } else if($this->d->_action == 'update'){
  328.  
  329.         } else if($this->d->_action == 'delete'){
  330.  
  331.         } else if($this->d->_action == 'viewdt'){
  332.             modelLoad($this,array('mt_wh_detail'));
  333.             $res = $this->mt_wh_detail->viewMutationDT($this->in);
  334.             printJSON($res);
  335.         } else if($this->d->_action == ''){
  336.  
  337.         }
  338.  
  339.         $this->load->view('template_view', $this->d);
  340.     }
  341.  
  342.     function laporan_mutasi_sisa_produksi_scrap($arg1="", $arg2="")
  343.     {
  344.         if(empty($arg1)) $this->d->_action = 'view';
  345.         else $this->d->_action = $arg1;
  346.  
  347. //      $this->load->model('msales_approval');
  348.         if($this->d->_action == 'add'){
  349.             $this->d->_modal = array('referensi_dokumen_pabean');
  350.         } else if($this->d->_action == 'store'){
  351.  
  352.         } else if($this->d->_action == 'edit'){
  353.  
  354.         } else if($this->d->_action == 'update'){
  355.  
  356.         } else if($this->d->_action == 'delete'){
  357.  
  358.         } else if($this->d->_action == 'viewdt'){
  359.             modelLoad($this,array('mt_wh_detail'));
  360.             $res = $this->mt_wh_detail->viewMutationDT($this->in);
  361.             printJSON($res);
  362.         } else if($this->d->_action == ''){
  363.  
  364.         }
  365.  
  366.         $this->load->view('template_view', $this->d);
  367.     }
  368.  
  369. }
  370.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement