crm-summit/app/Views/activities_count.php

116 lines
4.9 KiB
PHP
Raw Normal View History

2024-04-24 13:20:52 +07:00
<?= $this->extend('layouts/main.php') ?>
<?= $this->section('content') ?>
<div class="page-wrapper">
<div class="container-fluid">
<div class="row page-titles">
<div class="col-md-5 align-self-center">
<h4 class="text-themecolor">Activities Count</h4>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form action="" method="post">
<div class="row mb-2">
<div class="col md-6">
<div class="input-group input-group-sm">
<span class="input-group-text d-flex align-items-center justify-content-center" style="width: 80px;">From</span>
<input class="form-control form-control-sm" type="date" name="opendate" value="<?=$opendate;?>"/>
</div>
</div>
<div class="col md-6">
<div class="input-group input-group-sm">
<span class="input-group-text d-flex align-items-center justify-content-center" style="width: 80px;">To</span>
<input class="form-control form-control-sm" type="date" name="closedate" value="<?=$closedate;?>"/>
</div>
</div>
</div>
<div class="row mb-2">
<div class="input-group input-group-sm">
<span class="input-group-text d-flex align-items-center justify-content-center" style="width: 80px;">Pos</span>
<select class="form-control form-control-sm" name="pos" >
<?php
foreach($userpos as $qid => $qname) {
if($qid == $pos) { echo "<option value='$qid' selected>$qname</option>"; }
else { echo "<option value='$qid'>$qname</option>"; }
}
?>
</select>
</div>
</div>
<button type="submit" class="btn btn-success btn-sm text-white float-end"> <i class="fa fa-check"></i> Submit</button>
</form>
</div>
</div>
</div>
</div>
<?php
if(isset($count)) {
?>
<div class="row mt-2">
<div class="col-12">
<div class="card">
<div class="card-body">
<button class="btn btn-success btn-xs text-white float-end mb-3" onclick="exportToExcel()"> <i class="fa fa-file-excel"></i> EXCEL </button>
<div class="table-responsive">
<table id="myTable" class="table small display border">
<thead class="table-info">
<tr>
<th style="width:40%;">Name</th>
<th>CR</th>
<th>IR</th>
<th>MN</th>
<th>SP</th>
<th>PR</th>
<th>RF</th>
<th>TR</th>
<th style="text-align: center;">Total</th>
</tr>
</thead>
<tbody>
<?php foreach($count as $row) : ?>
<tr <?php if( session()->get('userid') == $row['userid'] ) {echo "style='background-color:#d3e9eb;'";} ?>>
<td><?= $row['firstname'] . ' ' . $row['lastname'];?></td>
<td><?= $row['CR'];?></td>
<td><?= $row['IR'];?></td>
<td><?= $row['MN'];?></td>
<td><?= $row['SP'];?></td>
<td><?= $row['PR'];?></td>
<td><?= $row['RF'];?></td>
<td><?= $row['TR'];?></td>
<td style="text-align: center;"><?= $row['total']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<?= $this->endSection() ?>
<?= $this->section('script') ?>
<!-- SCRIPT EXPORT TABLE TO EXCEL -->
<script>
function exportToExcel() {
const data = document.getElementById("myTable"); //const data = $("#myTable")[0]; kalo pake jquery
var ws = XLSX.utils.table_to_sheet(data);
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Sheet 1");
XLSX.writeFile(wb, "ActivityCount.xlsx");
}
</script>
<?= $this->endSection() ?>