I'm trying to get my head around this below code, being relatively new to php/mysql its a bit of a head scratcher, the part i'm trying to work out is the progress/percentage part.
$prog = $tprog > 0 ? ($cprog/$tprog) * 100 : 0;
$prog = $prog > 0 ? number_format($prog,2) : $prog;
happy if someone can explain it?
<?php
$i = 1;
$stat = array("Started (Received by Client)","In-Progress (with Estimator)","Complete (Handed to Delivery)");
$where = "";
if($_SESSION['login_type'] == 2){
$where = " where manager_id = '{$_SESSION['login_id']}' ";
}elseif($_SESSION['login_type'] == 3){
$where = " where concat('[',REPLACE(user_ids,',','],['),']') LIKE '%[{$_SESSION['login_id']}]%' ";
}
$qry = $conn->query("SELECT * FROM project_list $where order by name asc");
while($row= $qry->fetch_assoc()):
$prog= 0;
$tprog = $conn->query("SELECT * FROM task_list where project_id = {$row['id']}")->num_rows;
$cprog = $conn->query("SELECT * FROM task_list where project_id = {$row['id']} and status = 3")->num_rows;
$prog = $tprog > 0 ? ($cprog/$tprog) * 100 : 0;
$prog = $prog > 0 ? number_format($prog,2) : $prog;
$prod = $conn->query("SELECT * FROM user_productivity where project_id = {$row['id']}")->num_rows;
if($row['status'] == 0 && strtotime(date('Y-m-d')) >= strtotime($row['start_date'])):
if($prod > 0 || $cprog > 0)
$row['status'] = 2;
else
$row['status'] = 1;
elseif($row['status'] == 0 && strtotime(date('Y-m-d')) > strtotime($row['end_date'])):
$row['status'] = 4;
endif;
?>