Skip to content

Instantly share code, notes, and snippets.

@mcseptian
Last active April 14, 2018 01:41
Show Gist options
  • Save mcseptian/506e51b90b2d33efb798b0105c9d25c1 to your computer and use it in GitHub Desktop.
Save mcseptian/506e51b90b2d33efb798b0105c9d25c1 to your computer and use it in GitHub Desktop.
Code Igniter files on limuny graph
<?php
//error_reporting(0);
class Harian extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function dataAll($intv1, $intv2) {
$query1 = $this->db->query("select id from laporan where start_time between '$intv1' and '$intv2'");
$jumlah = $query1->num_rows();
return $jumlah;
}
function dataUNY($intv1, $intv2) {
$query2 = $this->db->query("select id from laporan where (start_time between '$intv1' and '$intv2') and id_biaya = '1'");
$jumlah2 = $query2->num_rows();
return $jumlah2;
}
function dataUmum($intv1, $intv2) {
$query3 = $this->db->query("select id from laporan where (start_time between '$intv1' and '$intv2') and id_biaya = '2'");
$jumlah3 = $query3->num_rows();
return $jumlah3;
}
function dataFIP($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '__1%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function dataFBS($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '__2%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function dataMIPA($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '__3%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function dataFIS($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '__4%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function dataFT($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '__5%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function dataFIK($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '__6%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function dataFE($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '__8%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt1($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_1%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt2($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_2%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt3($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_3%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt4($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_4%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt5($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_5%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt6($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_6%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt7($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_7%'");
$jumlah = $query->num_rows();
return $jumlah;
}
function angkt8($intv1, $intv2) {
$query = $this->db->query("Select id from laporan where (start_time between '$intv1' and '$intv2') and user_id like '_8%'");
$jumlah = $query->num_rows();
return $jumlah;
}
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Data Pengunjung Harian Limuny</title>
<link rel="stylesheet" type="text/css" href="asset/styles/print.css" />
<link rel="stylesheet" type="text/css" href="asset/styles/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="asset/styles/jquery-ui.css" />
<script type="text/javascript" src="asset/js/jquery-3.2.1.slim.min.js"></script>
<script type="text/javascript" src="asset/js/popper.min.js"></script>
<script type="text/javascript" src="asset/js/bootstrap.min.js"></script>
<script type="text/javascript" src="asset/js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="asset/js/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$("#datepicker1").datepicker({
dateFormat: "yy-mm-dd",
});
});
$(function() {
$("#datepicker2").datepicker({
dateFormat: "yy-mm-dd",
});
});
</script>
<style>
.ui-datepicker-prev,
.ui-datepicker-next,
.ui-icon,
.ui-icon-circle-triangle-w {
background: #000;
}
</style>
</head>
<body>
<!-- Just an image -->
<nav class='navbar navbar-expand-lg navbar-light bg-light'>
<a class='navbar-brand' href='#'>
<img src='http://limuny.com/images/logo-hw.png'
width='30' height='30' alt=''>
</a>
<!-- Just a navigation bar -->
<button class='navbar-toggler' type='button'
data-toggle='collapse' data-target='#navbarSupportedContent'
aria-controls='navbarSupportedContent'
aria-expanded='false' aria-label='Toggle navigation'>
<span class='navbar-toggler-icon'></span>
</button>
<div class='collapse navbar-collapse'
id='navbarSupportedContent'>
<ul class='navbar-nav mr-auto'>
<li class='nav-item active'>
<a class='nav-link'
href='http://limuny.com/home'>Home
<span class='sr-only'>(current)</span>
</a>
</li>
<li class='nav-item'>
<a class='nav-link'
href='http://limuny.com/news'>News</a>
</li>
<li class='nav-item dropdown'>
<a class='nav-link dropdown-toggle' href='#'
id='navbarDropdown' role='button'
data-toggle='dropdown'
aria-haspopup='true'
aria-expanded='false'>
Operator
</a>
<div class='dropdown-menu'
aria-labelledby='navbarDropdown'>
<a class='dropdown-item'
href='http://limuny.com/cacti'>Server Status</a>
<a class='dropdown-item'
href='http://limuny.com/training'>Training</a>
<a class='dropdown-item'
href='http://limuny.com/tes'>Tes</a>
<div class='dropdown-divider'></div>
<a class='dropdown-item'
href='http://ad.s/tdl'>To Do List</a>
<a class='dropdown-item'
href='http://ad.s/adl'>Advertising System</a>
<a class='dropdown-item'
href='http://ad.s/cdl'>Server AdS Status</a>
<a class='dropdown-item'
href='http://ad.s/owncloud'>LimCloud</a>
</div>
</li>
<li class='nav-item'>
<a class='nav-link'
href='http://limuny.com/admin'>Login</a>
</li>
</ul>
<form class='form-inline my-2 my-lg-0'>
<button class='btn btn-outline-success my-2 my-sm-0'
id='print' onclick='window.print()'
type='button'>Print</button>
</form>
</div>
</nav>
<div class='container'>
<form method="post">
<div class='row'>
<div class='col'>
<div class='form-group'>
<label for='datepicker1'>Dari</label>
<input type='text' class='form-control'
id='datepicker1'
name='datepicker1'
placeholder=''>
</div>
</div>
<div class='col'>
<div class='form-group'>
<label for='datepicker2'>Sampai</label>
<input type='text' class='form-control'
id='datepicker2'
name='datepicker2'
placeholder=''>
</div>
</div>
<div class='form-group row'>
<div class='col-sm-10'>
<label
for='sbmt'>&nbsp;&nbsp;&nbsp;&nbsp;</label>
<button type='submit' id='sbmt' class='btn
btn-primary'>Submit</button>
</div>
</div>
</div>
</form>
<blockquote class='blockquote mb-0'>
<a href='http://limuny.com/index.php'><img
src='http://limuny.com/images/logo-hw.png'
alt='Limuny' class='float-right'>
</a>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<p>However, not everything that
can be counted counts, and
not everything that counts
can be counted.</p>
<footer class='blockquote-footer'>William Bruce Cameron from
<cite title='Source Title'>Informal Sociology: A Casual
Introduction to Sociological
Thinking(1963)
</cite>
</footer>
</blockquote>
<br/>
</div>
<div class="container" style="text-align: center;">
<?php
$a = date('Y-m-d H:i:s', strtotime('-1 months'));
$b = date('Y-m-d H:i:s');
if (isset($_POST["datepicker1"]) && isset($_POST["datepicker2"]))
{
$a = $_POST["datepicker1"] . " 00:00:00";
$b = $_POST["datepicker2"] . " 23:59:59";
}
echo "<div class='alert alert-success' role='alert'><h4>";
echo "Jumlah User Limuny mulai " . $a . " hingga " . $b;
echo "</h4></div>";
$lim = $this->harian->dataAll($a, $b);
$uny = $this->harian->dataUny($a, $b);
$umum = $this->harian->dataUmum($a, $b);
$dataFip = $this->harian->dataFip($a, $b);
$dataFbs = $this->harian->dataFbs($a, $b);
$dataMipa = $this->harian->dataMipa($a, $b);
$dataFis = $this->harian->dataFis($a, $b);
$dataFt = $this->harian->dataFt($a, $b);
$dataFik = $this->harian->dataFik($a, $b);
$dataFe = $this->harian->dataFe($a, $b);
$angkt1 = $this->harian->angkt1($a, $b);
$angkt2 = $this->harian->angkt2($a, $b);
$angkt3 = $this->harian->angkt3($a, $b);
$angkt4 = $this->harian->angkt4($a, $b);
$angkt5 = $this->harian->angkt5($a, $b);
$angkt6 = $this->harian->angkt6($a, $b);
$angkt7 = $this->harian->angkt7($a, $b);
$angkt8 = $this->harian->angkt8($a, $b);
?>
<br/><canvas id="newChart1"></canvas><br/>
<script type="text/javascript" src="asset/js/utils.js"></script>
<script type="text/javascript" src="asset/js/Chart.bundle.min.js"></script>
<script>
var ctx = document.getElementById(
'newChart1').getContext(
'2d');
var chart1 = new Chart(ctx, {
type: 'bar',
data: {
labels: [
"User UMUM",
"User Mahasiswa UNY",
"User TOTAL"
],
datasets: [{
label: "User",
backgroundColor: 'rgb(229, 34, 41)',
borderColor: 'rgb(229, 34, 41)',
data: [ <?php
echo $umum . "," . $uny . "," . $lim; ?>],
}]
},
options: {
responsive: true,
title: {
display: true,
text: 'User Limuny'
},
legend: {
position: 'right',
},
}
});
</script>
<?php
echo "<table class='table table-hover'>";
echo "<thead class='thead-dark'>";
echo " <tr>";
echo " <th scope='col'>JENIS USER </th>";
echo " <th scope='col'>JUMLAH</th>";
echo "</tr>";
echo "</thead>";
echo " <tr>";
echo " <td>UMUM</td>";
echo " <td>" . $umum . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>Mahasiswa UNY</td>";
echo " <td>" . $uny . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td >TOTAL</td>";
echo " <td >" . $lim . "</td>";
echo " </tr>";
echo "</table>"; ?>
<br/><canvas id="newChart2"></canvas><br/>
<script type="text/javascript" src="asset/js/utils.js"></script>
<script type="text/javascript" src="asset/js/Chart.bundle.min.js"></script>
<script>
var chartColors = window.chartColors;
var color = Chart.helpers.color;
var config = {
data: {
datasets: [{
data: [ <?php
echo $dataFip . "," . $dataFbs . "," . $dataMipa . "," . $dataFis . "," . $dataFt . "," . $dataFik . "," . $dataFe; ?>],
backgroundColor: [
color(chartColors.green).alpha(0.5).rgbString(),
color(chartColors.purple).alpha(0.5).rgbString(),
color(chartColors.blue).alpha(0.5).rgbString(),
color(chartColors.red).alpha(1).rgbString(),
color(chartColors.orange).alpha(0.5).rgbString(),
color(chartColors.yellow).alpha(0.5).rgbString(),
color(chartColors.red).alpha(0.5).rgbString(),
],
label: 'Fakultas'
}],
labels: [
'FIP',
'FBS',
'FMIPA',
'FIS',
'FT',
'FIK',
'FE'
]
},
options: {
responsive: true,
legend: {
position: 'right',
},
title: {
display: true,
text: 'User Mahasiswa per Fakultas'
},
scale: {
ticks: {
beginAtZero: true
},
reverse: false
},
animation: {
animateRotate: false,
animateScale: true
}
}
};
window.onload = function() {
var ctx = document.getElementById('newChart2');
window.myPolarArea = Chart.PolarArea(ctx, config);
};
</script>
<?php
echo "<table class='table table-hover'>";
echo "<thead class='thead-dark'>";
echo "<tr>";
echo " <th
scope='col'>FAKULTAS</th>";
echo " <th scope='col'>JUMLAH</th>";
echo "</tr>";
echo "</thead>";
echo " <tr>";
echo " <td>FIP</td>";
echo " <td>" . $dataFip . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>FBS</td>";
echo " <td>" . $dataFbs . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>FMIPA</td>";
echo " <td>" . $dataMipa . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>FIS</td>";
echo " <td>" . $dataFis . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>FT</td>";
echo " <td>" . $dataFt . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>FIK</td>";
echo " <td>" . $dataFik . "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>FE</td>";
echo " <td>" . $dataFe . "</td>";
echo " </tr>";
echo "</table>"; ?>
<br/><canvas id="newChart3"></canvas><br/>
<script type="text/javascript" src="asset/js/utils.js"></script>
<script type="text/javascript" src="asset/js/Chart.bundle.min.js"></script>
<script>
var cty = document.getElementById(
'newChart3').getContext(
'2d');
var roundChart = new Chart(cty, {
type: 'bar',
data: {
labels: ['2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018'],
datasets: [{
label: 'Mahasiswa',
backgroundColor: window.chartColors.grey,
borderColor: window.chartColors.grey,
data: [<?php
echo $angkt1 . "," . $angkt2 . "," . $angkt3 . "," . $angkt4 . "," . $angkt5 . "," . $angkt6 . "," . $angkt7 . "," . $angkt8; ?>],
fill: false,
pointRadius: 10,
pointHoverRadius: 15,
showLine: false // no line shown
}]
},
options: {
responsive: true,
title: {
display: true,
text: 'User Mahasiswa per Angkatan '
},
legend: {
position: 'right',
}
}
});
</script>
<?php
echo "
<table class='table table-hover'>
<thead class='thead-dark'>
<tr>";
echo "
<th scope='col'>ANGKATAN</th>";
echo "
<th scope='col'>JUMLAH</th>";
echo " </tr>
</thead>";
echo "
<tr>";
echo "
<td>2011</td>";
echo "
<td>" . $angkt1 . "</td>";
echo " </tr>";
echo "
<tr>";
echo "
<td>2012</td>";
echo "
<td>" . $angkt2 . "</td>";
echo " </tr>";
echo "
<tr>";
echo "
<td>2013</td>";
echo "
<td>" . $angkt3 . "</td>";
echo " </tr>";
echo "
<tr>";
echo "
<td>2014</td>";
echo "
<td>" . $angkt4 . "</td>";
echo " </tr>";
echo "
<tr>";
echo "
<td>2015</td>";
echo "
<td>" . $angkt5 . "</td>";
echo " </tr>";
echo "
<tr>";
echo "
<td>2016</td>";
echo "
<td>" . $angkt6 . "</td>";
echo " </tr>";
echo "
<tr>";
echo "
<td>2017</td>";
echo "
<td>" . $angkt7 . "</td>";
echo " </tr>";
echo "
<tr>";
echo "
<td>2018</td>";
echo "
<td>" . $angkt8 . "</td>";
echo " </tr>";
echo "</table>"; ?>
</div>
<div class='footer bg-light'>
<p class='lead float-left'>&copy; RnD Limuny 2016</p>
<p class='lead float-right'>Design by <a
href='https://github.com/mcseptian/'>mcseptian</a>
</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment