<?php
//act_count
$data = $act_counter[0];
$nuser = intval($nuser[0]['nuser']);

$act_open = $data['act_open'];
$act_accept = $data['act_accept'];
$act_pending = $data['act_pending'];
$act_close = $data['act_close'];
$act_suspend = $data['act_suspend'];

$ir_y = $data['ir_y']; $mn_y = $data['mn_y']; $cr_y = $data['cr_y']; $sp_y = $data['sp_y']; $pr_y = $data['pr_y']; $tr_y = $data['tr_y']; $rf_y = $data['rf_y'];
$ir_yp = ceil( $data['ir_ya'] / $nuser ); $mn_yp = ceil( $data['mn_ya'] / $nuser ); $cr_yp = ceil( $data['cr_ya'] / $nuser ); $sp_yp = ceil( $data['sp_ya'] / $nuser ); $pr_yp = ceil( $data['pr_ya'] / $nuser ); $tr_yp = ceil( $data['tr_ya'] / $nuser ); $rf_yp = ceil( $data['rf_ya'] / $nuser );

$ir_m = $data['ir_m']; $mn_m = $data['mn_m']; $cr_m = $data['cr_m']; $sp_m = $data['sp_m']; $pr_m = $data['pr_m']; $tr_m = $data['tr_m']; $rf_m = $data['rf_m'];
$ir_mp = ceil( $data['ir_ma'] / $nuser ); $mn_mp = ceil( $data['mn_ma'] / $nuser ); $cr_mp = ceil( $data['cr_ma'] / $nuser ); $sp_mp = ceil( $data['sp_ma'] / $nuser ); $pr_mp = ceil( $data['pr_ma'] / $nuser ); $tr_mp = ceil( $data['tr_ma'] / $nuser ); $rf_mp = ceil( $data['rf_ma'] / $nuser );

$year = date('Y');
$today = date('Y-m-d');

foreach($stats as $qcode => $qstats) {
?>
<form action='<?=base_url()?>activities' method='post' id='<?=$qstats;?>actForm'>
<input type='hidden' name='userid' value='<?=$_SESSION['userid'];?>' />
<input type='hidden' name='opendate' value='<?=$year;?>-01-01' />
<input type='hidden' name='closedate' value='<?=$today;?>' />
<input type='hidden' name='status' value='<?=$qcode;?>' />
</form>
<?php
}
?>
<!-- Activity status counter -->
<div class="row justify-content-between">
	<div class="col">
		<div class="card rounded" id="oa">
			<div class="card-body" onclick="$('#OpenactForm').submit()">
				<div class="d-flex no-block align-items-center">
					<div >Open<br/>Activity</div>
					<div class="ms-auto">
						<h2><span class="counter"><?=$act_open;?></span></h2>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="col" >
		<div class="card rounded" id="aa">
			<div class="card-body" onclick="$('#AcceptactForm').submit()">
				<div class="d-flex no-block align-items-center">
					<div>Accepted<br/>Activity</div>
					<div class="ms-auto">
						<h2><span class="counter"><?=$act_accept;?></span></h2>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="col" >
		<div class="card rounded" id="pa">
			<div class="card-body" onclick="$('#PendingactForm').submit()">
				<div class="d-flex no-block align-items-center">
					<div>Pending<br/>Activity</div>
					<div class="ms-auto">
						<h2><span class="counter"><?=$act_pending;?></span></h2>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="col" >
		<div class="card rounded" id="sa">
			<div class="card-body" onclick="$('#SuspendactForm').submit()">
				<div class="d-flex no-block align-items-center">
					<div>Suspended<br/>Activity</div>
					<div class="ms-auto">
						<h2><span class="counter"><?=$act_suspend;?></span></h2>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="col">
		<div class="card rounded"  id="ca">
			<div class="card-body" onclick="$('#CloseactForm').submit()">
				<div class="d-flex no-block align-items-center">
					<div>Close<br/>Activity</div>
					<div class="ms-auto">
						<h2><span class="counter"><?=$act_close;?></span></h2>
					</div>
				</div>
			</div>
		</div>
	</div>
	
</div>
<!-- end act counter -->

<!-- Activity type counter per month / year -->
<div class="row justify-content-evenly">
	<div class="col-auto">
		<div class="card">
			<div class="card-content">
			<div class="card-body">
				<h3>IR</h3>
				<pre class='text-nowrap'>Y <?="$ir_y / $ir_yp";?><br/>M <?="$ir_m / $ir_mp";?></pre>
			</div>
			</div>
		</div>
	</div>

	<div class="col-auto">
		<div class="card">
			<div class="card-content">
			<div class="card-body">
				<h3>MN</h3>
				<pre class='text-nowrap'>Y <?="$mn_y / $mn_yp";?><br/>M <?="$mn_m / $mn_mp";?></pre>
			</div>
			</div>
		</div>
	</div>

	<div class="col-auto">
		<div class="card">
			<div class="card-content">
			<div class="card-body">
				<h3>CR</h3>
				<pre class='text-nowrap'>Y <?="$cr_y / $cr_yp";?><br/>M <?="$cr_m / $cr_mp";?></pre>
			</div>
			</div>
		</div>
	</div>

	<div class="col-auto">
		<div class="card">
			<div class="card-content">
			<div class="card-body">
				<h3>PR</h3>
				<pre class='text-nowrap'>Y <?="$pr_y / $pr_yp";?><br/>M <?="$pr_m / $pr_mp";?></pre>
			</div>
			</div>
		</div>
	</div>

	<div class="col-auto">
		<div class="card">
			<div class="card-content">
			<div class="card-body">
				<h3>SP</h3>
				<pre class='text-nowrap'>Y <?="$sp_y / $sp_yp";?><br/>M <?="$sp_m / $sp_mp";?></pre>
			</div>
			</div>
		</div>
	</div>

	<div class="col-auto">
		<div class="card">
			<div class="card-content">
			<div class="card-body">
				<h3>TR</h3>
				<pre class='text-nowrap'>Y <?="$tr_y / $tr_yp";?><br/>M <?="$tr_m / $tr_mp";?></pre>
			</div>
			</div>
		</div>
	</div>

	<div class="col-auto">
		<div class="card">
			<div class="card-content">
			<div class="card-body">
				<h3 class='text-nowrap'>RF</h3>
				<pre class='text-nowrap'>Y <?="$rf_y / $rf_yp";?><br/>M <?="$rf_m / $rf_mp";?></pre>
			</div>
			</div>
		</div>
	</div>
</div>
<!-- end act type counter -->