From d55e118c426ca49ee2859e7c8117302b399e4ec7 Mon Sep 17 00:00:00 2001 From: Denis <27.idea@gmail.com> Date: Sat, 20 Oct 2018 20:54:22 +0700 Subject: [PATCH] Add files via upload --- Example.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Example.php diff --git a/Example.php b/Example.php new file mode 100644 index 0000000..0458234 --- /dev/null +++ b/Example.php @@ -0,0 +1,59 @@ +load->library('cidoc'); + + // Preparing Data + $data = []; + for($i=0; $i<50; $i++){ + $name = 'Lorem Ipsum'; + if ($i > 11 && $i < 15) { + $name = 'Dolor Sit'; + } + + $data[] = array( + 'id' => $i+1, + 'date' => date('d M Y'), + 'name' => $name, + 'hit' => rand(0, 100), + 'status' => 'Complete', + ); + } + + // Preparing Table Header and Mapping Data + $header = array( + array('label' => 'ID.', 'data' => 'id'), + array('label' => 'Date', 'data' => 'date'), + array('label' => 'Name', 'data' => 'name'), + array('label' => 'Hit', 'data' => 'hit'), + array('label' => 'Status', 'data' => 'status'), + ); + + // Preparing Option Lib + $option = array( + 'title' => 'User Report', // Set the title of table + 'summary' => array( // Set summary or footer table + array( + 'label' => 'Total Hit', + 'column' => array( + 'hit' => array_sum(array_column($data, 'hit')), + ) + ) + ), + 'filter' => array( // Set more information on header + array('label' => 'Date', 'value' => date('d M Y')), + array('label' => 'Status', 'value' => 'Complete'), + ), + 'merged' => array('by' => 'name', 'except' => array('id', 'hit', 'date', 'status')), // Merge unique name data vertically + ); + + $this->cidoc->set($header, $data, $option)->createHTML(); // Output HTML + // $this->cidoc->set($header, $data, $option)->createExcel(); // Output Excel + // $this->cidoc->set($header, $data, $option)->createPDF(); // Output PDF + } +}