Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //controller Users//
- <?php
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- class Users extends CI_Controller {
- function __construct() {
- parent::__construct();
- $this->load->model('User');
- // for
- }
- function login() {
- $this->form_validation->set_rules('username', 'username', 'required');
- $this->form_validation->set_rules('password', 'password', 'required');
- $this->form_validation->set_error_delimiters('', '<br/>');
- if ($this->form_validation->run() == TRUE) {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $user = $this->User->checkLogin($username, $password);
- if (!empty($user)) {
- $sessionData['id_kasir'] = $user['id_kasir'];
- $sessionData['username'] = $user['username'];
- $sessionData['nama'] = $user['nama'];
- $sessionData['akses'] = $user['akses'];
- $sessionData['is_login'] = TRUE;
- $this->session->set_userdata($sessionData);
- if ($this->session->userdata('akses') == 'Admin') {
- $this->session->sess_expiration = 14400;
- redirect('admin/Dashboard');
- } else if ($this->session->userdata('akses') == 'Kasir'){
- $this->session->sess_expiration = 14400;
- redirect('kasir/Dashboard');
- }else{
- $this->session->sess_expiration = 14400;
- redirect('petugas/Dashboard');
- }
- }else{
- echo "<script>
- alert('Username/Password Salah atau Akun tidak aktif');
- </script>";
- }
- }
- $this->load->view('users/login');
- }
- function logout() {
- $this->session->sess_destroy();
- redirect('users/login');
- }
- }
- ?>
- //Models Users//
- <?php
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- class User extends CI_Model {
- var $table = 'tbl_kasir';
- function __construct() {
- parent::__construct();
- }
- function checkLogin($username, $password) {
- $this->db->select('*');
- $this->db->where('username', $username);
- $this->db->where('password', md5($password));
- $this->db->where('status', 'Aktif');
- $query = $this->db->get($this->table, 1);
- if ($query->num_rows() == 1) {
- return $query->row_array();
- }
- }
- }
- ?>
- //form login//
- <!-- Login Form -->
- <?php echo form_open('users/login',array('class' => 'js-validation-login form-horizontal push-30-t')); ?>
- <div class="form-group">
- <div class="col-xs-12">
- <div class="form-material form-material-primary floating">
- <input class="form-control" type="text" id="username" name="username" value="<?php echo set_value('username') ?>">
- <label for="username">Username</label>
- </div>
- </div>
- </div>
- <div class="form-group">
- <div class="col-xs-12">
- <div class="form-material form-material-primary floating">
- <input class="form-control" type="password" id="password" name="password">
- <label for="password">Password</label>
- </div>
- </div>
- </div>
- <div class="form-group push-30-t">
- <div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4">
- <button class="btn btn-sm btn-block btn-primary" type="submit">Log in</button>
- </div>
- </div>
- <?php echo form_close(); ?>
- <center>
- <small>
- <a class="font-w600" href="<?php echo base_url('tracking')?>" target="_blank">Tracking Buku Untuk Pembeli</a>
- </small>
- </center>
- <!-- END Login Form -->
- //controller dashboard admin//
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Dashboard extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- $this->general->cekAdminLogin();
- $this->_module = 'admin';
- $this->load->model('admin/M_dashboard','md');
- }
- public function index()
- {
- $year1 = $this->md->getTahun();
- $year = $year1['tahun'];
- $earning1 = $this->md->getTotal($year);
- $earning2 = $this->md->getTotal2($year);
- $total1= array();
- $total2= array();
- foreach ($earning1 as $tot) {
- $total1[] = $tot->total_pasok;
- }
- $bulan = $this->md->getBulan();
- $label = array();
- foreach ($bulan as $m) {
- $label[] = $m->bulan;
- }
- // batas
- foreach ($earning2 as $tot) {
- $total2[] = $tot->keuntungan;
- }
- $bulan2 = $this->md->getBulan2();
- $label2 = array();
- foreach ($bulan2 as $m) {
- $label2[] = $m->bulan;
- }
- // batas
- $data = array(
- 'jumlah_buku' => $this->md->hitungBuku()->num_rows(),
- 'jumlah_distributor' => $this->md->hitungDis()->num_rows(),
- 'untung' => $this->md->hitungUntung(),
- 'untung_hari' => $this->md->hitungUntungHari()
- );
- $data['label'] = json_encode($label);
- $data['tahun'] = $this->md->getTahun();
- $data['result1'] = json_encode($total1);
- $data['one'] = $year1['tahun'];
- $data['label2'] = json_encode($label2);
- $data['tahun2'] = $this->md->getTahun2();
- $data['result2'] = json_encode($total2);
- $data['one2'] = $year1['tahun'];
- $this->load->view('admin/dashboard',$data);
- }
- }
- /* End of file c_adashboard.php */
- /* Location: ./application/controllers/admin/c_adashboard.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement