Untitled

 avatar
unknown
plain_text
3 years ago
8.8 kB
4
Indexable

<?php $year=date('Y'); ?>

<?php if($this->session->userdata('level')=='admin'): ?>
  <div class="col-12">
    <div class="row">


      <div class="col-md-4">
       <div class="card card-dark bg-primary-gradient">
        <div class="card-body pb-0">
          <div class="h1 fw-bold float-right">Tahun <?=$year?></div>
          <?php foreach($totalpenjualan as $totaljual){ ?>
            <h2 class="mb-2">Rp. <?=number_format($totaljual['totalpenjualan'],0,',','.');?></h2>
          <?php } ?>
          
          <p>Total Penjualan</p>
          <div class="pull-in sparkline-fix chart-as-background">

          </div>
        </div>
      </div>
    </div>


    <div class="col-md-4">
     <div class="card card-dark bg-secondary-gradient">
      <div class="card-body pb-0">
       <div class="h1 fw-bold float-right">Tahun <?=$year?></div>
       <?php foreach($totalpembelian as $totalbeli){ ?>
        <h2 class="mb-2">Rp. <?=number_format($totalbeli['totalpembelian'],0,',','.');?></h2>
      <?php } ?>
      <p>Total Pembelian</p>
      <div class="pull-in sparkline-fix chart-as-background">

      </div>
    </div>
  </div>
</div>


<div class="col-md-4">
 <div class="card card-dark bg-success2">
  <div class="card-body pb-0">
   <div class="h1 fw-bold float-right">Tahun <?=$year?></div>
   <?php foreach($totalpengeluaran as $totalkeluar){ ?>
    <h2 class="mb-2">Rp. <?=number_format($totalkeluar['totalpengeluaran'],0,',','.');?></h2>
  <?php } ?>
  <p>Total Pengeluaran</p>
  <div class="pull-in sparkline-fix chart-as-background">

  </div>
</div>
</div>
</div>
</div>

<div class="card">

  <div class="card-header">
    <!-- <h3 class="card-title"><?=$deskripsi?></h3> -->

    <h3 class="card-title pull-right" style="font-family:Century Gothic;"> Log Activity</h3>

    <ul class="nav nav-pills nav-primary" id="pills-tab" role="tablist">
      <li class="nav-item">
       <a class="nav-link active tab1" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">All</a>
     </li>
     <li class="nav-item">
       <a class="nav-link tab2" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">Edit</a>
     </li>

   </ul>
 </div>
 <!-- /.card-header -->
 <div class="card-body">


  <div class="tab-content mt-2 mb-3" id="pills-tabContent">
    <div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">



      <div class="table-responsive">
        <table id="datatables" class="table table-bordered table-hover">
          <thead>
            <tr>

              <th style="width: 70px; text-align: left;">No.</th>
              <th style="width: 165px;">Time</th>
              <th style="width: 100px;">Actor</th>
              <th>Keterangan</th>
            </tr>
          </thead>
          <tbody id="log_add">
          </tbody>
        </table>
      </div>

    </div>
    <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
      <div class="table-responsive">
        <table id="datatables2" class="table table-bordered table-hover">
          <thead>
            <tr>
              <tr>

                <th style="width: 70px; text-align: left;">No.</th>
                <th style="width: 165px;">Time</th>
                <th style="width: 100px;">Actor</th>
                <th>Keterangan</th>
              </tr>
            </thead>
            <tbody id="log_edit">
            </tbody>
          </table>
        </div>

      </div>

    </div>
  </div>
  <!-- /.card-body -->
</div>
<!-- /.card -->


</div>
<!-- /.col -->
<?php endif; ?>




<?php  if($this->session->userdata('level')=='kasir'): ?>

  <div class="row">


    <div class="col-md-4">
     <div class="card card-dark bg-primary-gradient">
      <div class="card-body pb-0">
        <div class="h1 fw-bold float-right">Tahun <?=$year?></div>
        <?php foreach($totalpenjualan as $totaljual){ ?>
          <h2 class="mb-2">Rp. <?=number_format($totaljual['totalpenjualan'],0,',','.');?></h2>
        <?php } ?>

        <p>Total Penjualan</p>
        <div class="pull-in sparkline-fix chart-as-background">

        </div>
      </div>
    </div>
  </div>
  <div class="col-md-4">
   <div class="card card-dark bg-secondary-gradient">
    <div class="card-body pb-0">
     <div class="h1 fw-bold float-right">Tahun <?=$year?></div>
     <?php foreach($totalpembelian as $totalbeli){ ?>
      <h2 class="mb-2">Rp. <?=number_format($totalbeli['totalpembelian'],0,',','.');?></h2>
    <?php } ?>
    <p>Total Pembelian</p>
    <div class="pull-in sparkline-fix chart-as-background">

    </div>
  </div>
</div>
</div>
<div class="col-md-4">
 <div class="card card-dark bg-success2">
  <div class="card-body pb-0">
   <div class="h1 fw-bold float-right">Tahun <?=$year?></div>
   <?php foreach($totalpengeluaran as $totalkeluar){ ?>
    <h2 class="mb-2">Rp. <?=number_format($totalkeluar['totalpengeluaran'],0,',','.');?></h2>
  <?php } ?>
  <p>Total Pengeluaran</p>
  <div class="pull-in sparkline-fix chart-as-background">

  </div>
</div>
</div>
</div>
</div>


<?php endif; ?>


<?php if($this->session->userdata('level')=='produksi'): 

  redirect('/produksi', 'refresh');  
  ?>
  

<?php endif; ?>


<?php  if($this->session->userdata('level')=='admin toko'): ?>

  <div class="row">


    <div class="col-md-4">
      <div class="card card-dark bg-primary-gradient">
        <div class="card-body pb-0">
          <div class="h1 fw-bold float-right">Tahun <?=$year?></div>
          <?php foreach($totalpemakaian as $pakai){ ?>
            <h2 class="mb-2">Rp. <?=number_format($pakai['totalpemakaian'],0,',','.');?></h2>
          <?php } ?>
          
          <p>Total Pemakaian Bahan Baku</p>
          <div class="pull-in sparkline-fix chart-as-background">

          </div>
        </div>
      </div>
    </div>


  <?php endif; ?>
</div>

<script src="<?=base_url()?>assets/js/core/jquery.3.2.1.min.js"></script>
<script>
  $(document).ready(function(){
$.ajaxSetup({
              data: {
                '<?php echo $this->security->get_csrf_token_name(); ?>' : '<?php echo $this->security->get_csrf_hash(); ?>'
              }
            });

  show_logAdd(); //call function show all product

 
  function show_logAdd(){
    $.ajax({
      type  : 'ajax',
      url   : '<?php echo site_url('Home/log_add')?>',
      async : false,
      dataType : 'json',
      // beforeSend: function(){
      //   swal({
      //     title: 'Tunggu',
      //     allowEscapeKey: false,
      //     allowOutsideClick: false,
      //     onOpen: () => {
      //       swal.showLoading();
      //     }
      //   })
      // },
      success : function(data){
        var html = '';
        var i;
        var no;
        no = 1; 

        for(i=0; i<data.length; i++){

          html += '<tr>'+
          '<td style="text-left: right; width:70px;">'+no+'</td>'+


          '<td>'+data[i].waktu+'</td>'+
          '<td>'+data[i].username+'</td>'+
          '<td>'+data[i].ket+'</td>'+
          '</tr>';
          no++;

        }
        $('#log_add').html(html);
         $('#datatables').dataTable({
    "aLengthMenu":[[5,10,25,50,75,-1],[5,10,25,50,75,"All"]]
  });
        swal.close();
      }

    });
  }



  show_logEdit(); //call function show all product

  function show_logEdit(){
    $.ajax({
      type  : 'ajax',
      url   : '<?php echo site_url('Home/log_edit')?>',
      async : false,
      dataType : 'json',
      // beforeSend: function(){
      //   swal({
      //     title: 'Tunggu',
      //     allowEscapeKey: false,
      //     allowOutsideClick: false,
      //     onOpen: () => {
      //       swal.showLoading();
      //     }
      //   })
      // },
      success : function(data){
        var html = '';
        var i;
        var no;
        no = 1; 

        for(i=0; i<data.length; i++){

          html += '<tr>'+
          '<td style="text-left: right; width:70px;">'+no+'</td>'+


          '<td>'+data[i].waktu+'</td>'+
          '<td>'+data[i].username+'</td>'+
          '<td>'+data[i].ket+'</td>'+
          '</tr>';
          no++;

        }
        $('#log_edit').html(html);
        
  $('#datatables2').dataTable({
    "aLengthMenu":[[5,10,25,50,75,-1],[5,10,25,50,75,"All"]]
  });

        swal.close();
      }

    });
  }

});


</script>