Skip to content

Commit

Permalink
PHPSpreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
manh21 committed Oct 1, 2019
1 parent c608dd3 commit c65ae7a
Show file tree
Hide file tree
Showing 670 changed files with 178,213 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ user_guide_src/cilexer/pycilexer.egg-info/*
application/logs/*
!application/logs/index.html
!application/logs/.htaccess
/vendor/

2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
| Note: This will NOT disable or override the CodeIgniter-specific
| autoloading (application/config/autoload.php)
*/
$config['composer_autoload'] = FALSE;
$config['composer_autoload'] = 'vendor/autoload.php';

/*
|--------------------------------------------------------------------------
Expand Down
30 changes: 21 additions & 9 deletions application/controllers/admin/Data_pemilih.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public function index()
$start = intval($this->input->get('start'));

if ($q <> '') {
$config['base_url'] = base_url() . 'data_pemilih/index.html?q=' . urlencode($q);
$config['first_url'] = base_url() . 'data_pemilih/index.html?q=' . urlencode($q);
$config['base_url'] = base_url() . 'admin/data_pemilih/index.html?q=' . urlencode($q);
$config['first_url'] = base_url() . 'admin/data_pemilih/index.html?q=' . urlencode($q);
} else {
$config['base_url'] = base_url() . 'data_pemilih/index.html';
$config['first_url'] = base_url() . 'data_pemilih/index.html';
$config['base_url'] = base_url() . 'admin/data_pemilih/index.html';
$config['first_url'] = base_url() . 'admin/data_pemilih/index.html';
}

$config['per_page'] = 10;
Expand Down Expand Up @@ -127,13 +127,26 @@ public function create_action()
} else {
$getKelas = $this->Data_pemilih_model->getKelas($this->input->post('kelas'));

$nis = $this->input->post('nis', TRUE);
$username = $this->input->post('username', TRUE);
$password = $this->input->post('password', TRUE);

if (empty($username) && empty($password)) {
$username = $nis;
$password = $nis;
} elseif (!empty($username) && empty($password)) {
$password = $nis;
} elseif (empty($username) && empty(!$password)) {
$username = $nis;
}

$data = array(
'nis' => $this->input->post('nis', TRUE),
'username' => $this->input->post('username', TRUE),
'password' => $this->input->post('password', TRUE),
'nis' => $nis,
'username' => $username,
'password' => $password,
'nama' => $this->input->post('nama', TRUE),
'kelas' => $getKelas->kelas,
'idkelas' => $this->input->post('kelas'),
'idkelas' => $this->input->post('kelas', TRUE),
'jk' => $this->input->post('jk', TRUE),
'status' => 'Belum Memilih',
'aktif' => '1',
Expand All @@ -159,7 +172,6 @@ public function edit($id)
}

$row = $this->Data_pemilih_model->get_by_id($id);
$getKelas = $this->Data_pemilih_model->getKelas($id);

if ($row) {
$data = array(
Expand Down
43 changes: 43 additions & 0 deletions application/controllers/admin/Excel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

class Controllername extends CI_Controller
{

public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('ion_auth', 'form_validation');
$this->load->helper('url', 'language');
}

public function index()
{
if (!$this->ion_auth->logged_in()) {
// redirect them to the login page
redirect('admin/auth/login', 'refresh');
} else if (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins
{ // redirect them to the home page because they must be an administrator to view this
show_error('You must be an administrator to view this page.');
}

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');

$writer = new Xlsx($spreadsheet);

$filename = 'simple';

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '.xlsx"');
header('Cache-Control: max-age=0');
$writer->save('php://output');
}
}

/* End of file Controllername.php */
31 changes: 22 additions & 9 deletions application/views/back/data_pemilih/data_pemilih_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@
<div class="form-group">
<label for="varchar">Kelas<?php echo form_error('kelas') ?></label>
<?php
$dd_kelas_attribute = 'class="form-control select2" id="kelas"';
$dd_kelas_attribute = 'class="form-control select2 js-example-basic-single" id="kelas"';
echo form_dropdown('kelas', $dd_kelas, $kelas_selected, $dd_kelas_attribute);
?>
</div>
<div class="form-group">
<label for="varchar">L/P <?php echo form_error('jk') ?></label>
<input type="text" class="form-control" name="jk" id="jk" placeholder="L/P" value="<?php echo $jk; ?>" />
<label for="varchar">Jenis Kelamin <?php echo form_error('jk') ?></label>
<div class="form-group">
<input id="jk" name="jk" type="radio" class="form-control square-blue" <?php if ($jk == 'L') echo "checked"; ?> value="L" />
<label for="jk" class="">Laki - Laki</label>

<input id="jk" name="jk" type="radio" class="form-control square-blue" <?php if ($jk == 'P') echo 'checked'; ?> value="P" />
<label for="jk" class="">Perempuan</label>
</div>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>" />
</div>
Expand All @@ -64,13 +70,20 @@
<?php $this->load->view('back/js') ?>
<!-- Select2 -->
<script src="<?php echo base_url('assets/template/backend/') ?>bower_components/select2/dist/js/select2.full.min.js"></script>
<!-- iCheck 1.0.1 -->
<link href="<?php echo base_url('assets/template/backend/') ?>plugins/iCheck/square/blue.css" rel="stylesheet">
<script src="<?php echo base_url('assets/template/backend/') ?>plugins/iCheck/icheck.min.js"></script>
<script>
$(function() {
$(document).ready(function() {
$(".select2").select2({
placeholder: "Please Select"
});
});
//for iCheck
$('input[type="checkbox"].square-blue, input[type="radio"].square-blue').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue'
});

$(document).ready(function() {
$('.js-example-basic-single').select2({
placeholder: 'Select an option',
});;
});
</script>

Expand Down
6 changes: 3 additions & 3 deletions application/views/back/data_pemilih/data_pemilih_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<div class="row">
<div class="col-lg-12">
<div class="box">
<div class="box-header">
<!-- <div class="box-header">
<h3 class="box-title">Pemilih</h3>
</div>
</div> -->
<!-- /.box-header -->
<div class="box-body">
<div id="infoMessage"><?php echo $this->session->userdata('message') <> '' ? $this->session->userdata('message') : ''; ?></div>
Expand Down Expand Up @@ -71,7 +71,7 @@
<td><?php echo htmlspecialchars($data_pemilih->username, ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($data_pemilih->nama, ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($data_pemilih->kelas, ENT_QUOTES, 'UTF-8'); ?></td>
<td width="10px"><?php echo htmlspecialchars($data_pemilih->jk, ENT_QUOTES, 'UTF-8'); ?></td>
<td width="10px" class="text-center"><?php echo htmlspecialchars($data_pemilih->jk, ENT_QUOTES, 'UTF-8'); ?></td>
<td class="text-center"><a class="label label-success"><?php echo htmlspecialchars($data_pemilih->status, ENT_QUOTES, 'UTF-8'); ?></a></td>
<td class="text-center"><?php echo ($data_pemilih->aktif) ? anchor("admin/data_pemilih/deactivate/" . $data_pemilih->id, 'Active', 'class="label label-info"') : anchor("admin/data_pemilih/activate/" . $data_pemilih->id, 'Inactive', 'class="label label-info"'); ?></td>
<td class="text-center">
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"phpoffice/phpspreadsheet": "^1.9"
}
}
Loading

0 comments on commit c65ae7a

Please sign in to comment.