<?php

    $sql3 = "SELECT titulo, SUM(subtotal) AS totalizacaoGrade from grade WHERE grade.id_pedido = '$id' AND grade.dir = 3 GROUP by `titulo` ORDER BY `titulo`";

    $resultado3 = $mysqli->query($sql3);
    $row3 = $resultado3->fetch_array(MYSQLI_ASSOC);
?>
			<div class="row">
				<h3 style="text-align:center">Estatistica de Produção</h3>
			</div>
                <table class="table table-hover">
                    <thead>
                      <tr>
                      </tr>
                    </thead>

                    <tbody>
                        <?php 
                        $resultado3 = $mysqli->query($sql3);
                        while($row3 = $resultado3->fetch_array(MYSQLI_ASSOC)) { 
                        $progresso =  round((($row3['totalizacaoGrade'] * 100) / $totalg)) ;
                        switch ($progresso) {
                            case ($progresso <= 25);
                                $res = "progress-bar progress-bar-danger";
                            break;
                            
                            case ($progresso > 26) && ($progresso < 50);
                                $res = "progress-bar progress-bar-warning";
                            break;
                                
                            case ($progresso > 50) && ($progresso < 75);
                                $res = "progress-bar progress-bar-info";
                            break;
                            
                            default;
                                $res = "progress-bar progress-bar-success";
                           
                        }
                        
                        ?>
                        
                            <input type="hidden" id="id_grade" name="id_grade" value="<?php echo $row['titulo']; ?>" />
                            <input type="hidden" id="id" name="id" value="<?php echo $row3['totalizacaoGrade']; ?>" />
                            <input type="hidden" id="id2" name="id2" value="<?php echo $totalg ?>" />
                            
                            <tr>
                                <td> <?php echo $row3['titulo']; ?> - <?php echo $row3['totalizacaoGrade'];?> de <?php echo $totalg?>

                                    <div class="progress">
                                        <div class="<?php echo $res ?>" role="progressbar" aria-valuenow="<?php echo $progresso ?>" 
                                        aria-valuemin="0" aria-valuemax="100" style="width:<?php echo $progresso ?>%">
                                        <?php echo $progresso ?>%
                                        </div>
                                    </div>            
                                </td>
                            </tr>

                        <?php } ?>
                    </tbody>
                </table>
