How to use different units of measure in the same table

0

I have a page that shows a table with the monthly results of each project, each record being a different project.

The problem is that each project uses different units of measure to deliver its result and how do I define the unit of measure when creating the table in the database, I do not know how to do it for each project, ie, my table record can have unit of measurement.

page:

<!-- Main -->
        <div class="content-lg container">
            <div class="row margin-b-20">
                <div class="col-sm-6">
                    <h2>Prev x Real Month</h2>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12 sm-margin-b-50">

                    <script type="text/javascript">
                        //Pegar o ID do botão clicado 
                        function abreModal (idR)
                        {
                            $.post("/Teste_Obeya/ajax-gptw.php", 
                            { id : idR }, function(content){
                                $(".modal-body").html(content); 
                            }, 'html');
                        }
                    </script>


                            <?php

                            require 'conn.php';

                            //Conexão e consulta ao Mysql
                            $qry = mysqli_query($lnk, "select * from gptw");

                            //Pegando os nomes dos campos
                            $num_fields = mysqli_num_fields($qry);//Obtém o número de campos do resultado

                            for($i = 0;$i<$num_fields; $i++){//Pega o nome dos campos
                                $fields[] = mysqli_fetch_field_direct($qry,$i)->name;
                            }

                            //Montando o cabeçalho da tabela
                            $table = '<table class="table table-striped table-inverse"> <tr style="">';

                            for($i = 0;$i < $num_fields; $i++){
                                $table .= '<th>'.$fields[$i].'</th>';
                            }

                            //Montando o corpo da tabela
                            //Tá meio gambiarrado mas pelo menos funciona.

                            $table .= '<tbody>';
                                  $vermelho_jan = 0;
                                  $verde_jan = 0;
                                  $vermelho_fev = 0;
                                  $verde_fev = 0;
                                  $vermelho_mar = 0;
                                  $verde_mar = 0;
                                  $vermelho_abr = 0;
                                  $verde_abr = 0;
                                  $vermelho_mai = 0;
                                  $verde_mai = 0;
                                  $vermelho_jun = 0;
                                  $verde_jun = 0;
                                  $vermelho_jul = 0;
                                  $verde_jul = 0;
                                  $vermelho_ago = 0;
                                  $verde_ago = 0;
                                  $vermelho_set = 0;
                                  $verde_set = 0;
                                  $vermelho_out = 0;
                                  $verde_out = 0;
                                  $vermelho_nov = 0;
                                  $verde_nov = 0;
                                  $vermelho_dez = 0;
                                  $verde_dez = 0;
                              while($r = mysqli_fetch_array($qry)){

                                  $table .= '<tr>';
                                  if($r['ID'] > $r['ID']){
                                    $table .= '<td>'.$r['ID'].'</td>';
                                  }else{
                                    $table .= '<td>'.$r['ID'].'</td>';
                                  }
                                  if($r['KPI'] > $r['KPI']){
                                    $table .= '<td style="font-weight:bolder;">'.$r['KPI'].'</td>';
                                  }else{
                                    $table .= '<td style="font-weight:bolder;">'.$r['KPI'].'</td>';
                                  }
                                  if($r['PILOTE'] > $r['PILOTE']){
                                    $table .= '<td>'.$r['PILOTE'].'</td>';
                                  }else{
                                    $table .= '<td>'.$r['PILOTE'].'</td>';
                                  }

                                  //Aqui começam os meses
                                  if($r['JAN_PREV'] > $r['JAN_REAL']){
                                    $table .= '<td>'.$r['JAN_PREV'].'</td>';
                                    $table .= '<td style="background:#ff4545;">'.$r['JAN_REAL'].'</td>';
                                    $vermelho_jan += 1;
                                  }else{
                                    $table .= '<td>'.$r['JAN_PREV'].'</td>';
                                    $table .= '<td style="background:#c3f786;">'.$r['JAN_REAL'].'</td>';
                                    $verde_jan += 1;
                                  }
                                  if($r['FEV_PREV'] > $r['FEV_REAL']){
                                    $table .= '<td>'.$r['FEV_PREV'].'</td>';
                                    $table .= '<td style="background:#ff4545;">'.$r['FEV_REAL'].'</td>';
                                    $vermelho_fev += 1;
                                  }else{
                                    $table .= '<td>'.$r['FEV_PREV'].'</td>';
                                    $table .= '<td style="background:#c3f786;">'.$r['FEV_REAL'].'</td>';
                                    $verde_fev += 1;
                                  }
                                  if($r['MAR_PREV'] > $r['MAR_REAL']){
                                    $table .= '<td>'.$r['MAR_PREV'].'</td>';
                                    $table .= '<td style="background:#ff4545;">'.$r['MAR_REAL'].'</td>';
                                    $vermelho_mar += 1;
                                  }else{
                                    $table .= '<td>'.$r['MAR_PREV'].'</td>';
                                    $table .= '<td style="background:#c3f786;">'.$r['MAR_REAL'].'</td>';
                                    $verde_mar += 1;
                                  }
                                  if($r['ABR_PREV'] > $r['ABR_REAL']){
                                    $table .= '<td>'.$r['ABR_PREV'].'</td>';
                                    $table .= '<td style="background:#ff4545;">'.$r['ABR_REAL'].'</td>';
                                    $vermelho_abr += 1;
                                  }else{
                                    $table .= '<td>'.$r['ABR_PREV'].'</td>';
                                    $table .= '<td style="background:#c3f786;">'.$r['ABR_REAL'].'</td>';
                                    $verde_abr += 1;
                                  }
                                  if($r['MAI_PREV'] > $r['MAI_REAL']){
                                    $table .= '<td>'.$r['MAI_PREV'].'</td>';
                                    $table .= '<td style="background:#ff4545;">'.$r['MAI_REAL'].'</td>';
                                    $vermelho_mai += 1;
                                  }else{
                                    $table .= '<td>'.$r['MAI_PREV'].'</td>';
                                    $table .= '<td style="background:#c3f786;">'.$r['MAI_REAL'].'</td>';
                                    $verde_mai += 1;
                                  }
                                  if($r['JUN_PREV'] > $r['JUN_REAL']){
                                    $table .= '<td>'.$r['JUN_PREV'].'</td>';
                                    $table .= '<td style="background:#ff4545;">'.$r['JUN_REAL'].'</td>';
                                    $vermelho_jun += 1;
                                  }else{
                                    $table .= '<td>'.$r['JUN_PREV'].'</td>';
                                    $table .= '<td style="background:#c3f786;">'.$r['JUN_REAL'].'</td>';
                                    $verde_jun += 1;
                                  }
                                  if($r['JUL_PREV'] > $r['JUL_REAL']){
                                    $table .= '<td>'.$r['JUL_PREV'].'</td>';
                                    $table .= '<td style="background:#ff4545;">'.$r['JUL_REAL'].'</td>';
                                    $vermelho_jul += 1;
                                  }else{
                                    $table .= '<td>'.$r['JUL_PREV'].'</td>';
                                    $table .= '<td style="background:#c3f786;">'.$r['JUL_REAL'].'</td>';
                                    $verde_jul += 1;
                                  }
                                  if($r['AGO_PREV'] > $r['AGO_REAL']){
                                    $table .= '<td>'.$r['AGO_PREV'].'</td>';
                                    $table .= '<td >'.$r['AGO_REAL'].'</td>';
                                    $vermelho_ago += 1;
                                  }else{
                                    $table .= '<td>'.$r['AGO_PREV'].'</td>';
                                    $table .= '<td >'.$r['AGO_REAL'].'</td>';
                                    $verde_ago += 1;
                                  }
                                  if($r['SET_PREV'] > $r['SET_REAL']){
                                    $table .= '<td>'.$r['SET_PREV'].'</td>';
                                    $table .= '<td >'.$r['SET_REAL'].'</td>';
                                    $vermelho_set += 1;
                                  }else{
                                    $table .= '<td>'.$r['SET_PREV'].'</td>';
                                    $table .= '<td >'.$r['SET_REAL'].'</td>';
                                    $verde_set += 1;
                                  }
                                  if($r['OUT_PREV'] > $r['OUT_REAL']){
                                    $table .= '<td>'.$r['OUT_PREV'].'</td>';
                                    $table .= '<td >'.$r['OUT_REAL'].'</td>';
                                    $vermelho_out += 1;
                                  }else{
                                    $table .= '<td>'.$r['OUT_PREV'].'</td>';
                                    $table .= '<td >'.$r['OUT_REAL'].'</td>';
                                    $verde_out += 1;
                                  }
                                  if($r['NOV_PREV'] > $r['NOV_REAL']){
                                    $table .= '<td>'.$r['NOV_PREV'].'</td>';
                                    $table .= '<td >'.$r['NOV_REAL'].'</td>';
                                    $vermelho_nov += 1;
                                  }else{
                                    $table .= '<td>'.$r['NOV_PREV'].'</td>';
                                    $table .= '<td >'.$r['NOV_REAL'].'</td>';
                                    $verde_nov += 1;
                                  }
                                  if($r['DEZ_PREV'] > $r['DEZ_REAL']){
                                    $table .= '<td>'.$r['DEZ_PREV'].'</td>';
                                    $table .= '<td >'.$r['DEZ_REAL'].'</td>';
                                    $vermelho_dez += 1;
                                  }else{
                                    $table .= '<td>'.$r['DEZ_PREV'].'</td>';
                                    $table .= '<td >'.$r['DEZ_REAL'].'</td>';
                                    $verde_dez += 1;
                                  }



                                  // Adicionando botão de edição

                                  $table .= '<td><form action="qualite-edicao.php" method="post">'; 
                                  $table .= '<input type="hidden" name="ID" value="'.$r['ID'].'">';
                                  $table .= '<input type="hidden" name="KPI" value="'.$r['KPI'].'">';
                                  $table .= '<input type="hidden" name="PILOTE" value="'.$r['PILOTE'].'">';
                                  $table .= '<input type="hidden" name="JAN PREV" value="'.$r['JAN_PREV'].'">';
                                  $table .= '<input type="hidden" name="JAN REAL" value="'.$r['JAN_REAL'].'">';
                                  $table .= '<input type="hidden" name="FEV PREV" value="'.$r['FEV_PREV'].'">';
                                  $table .= '<input type="hidden" name="FEV REAL" value="'.$r['FEV_REAL'].'">';
                                  $table .= '<input type="hidden" name="MAR PREV" value="'.$r['MAR_PREV'].'">';
                                  $table .= '<input type="hidden" name="MAR REAL" value="'.$r['MAR_REAL'].'">';
                                  $table .= '<input type="hidden" name="ABR PREV" value="'.$r['ABR_PREV'].'">';
                                  $table .= '<input type="hidden" name="ABR REAL" value="'.$r['ABR_REAL'].'">';
                                  $table .= '<input type="hidden" name="MAI PREV" value="'.$r['MAI_PREV'].'">';
                                  $table .= '<input type="hidden" name="MAI REAL" value="'.$r['MAI_REAL'].'">';
                                  $table .= '<input type="hidden" name="JUN PREV" value="'.$r['JUN_PREV'].'">';
                                  $table .= '<input type="hidden" name="JUN REAL" value="'.$r['JUN_REAL'].'">';
                                  $table .= '<input type="hidden" name="JUL PREV" value="'.$r['JUL_PREV'].'">';
                                  $table .= '<input type="hidden" name="JUL REAL" value="'.$r['JUL_REAL'].'">';
                                  $table .= '<input type="hidden" name="AGO PREV" value="'.$r['AGO_PREV'].'">';
                                  $table .= '<input type="hidden" name="AGO REAL" value="'.$r['AGO_REAL'].'">';
                                  $table .= '<input type="hidden" name="SET PREV" value="'.$r['SET_PREV'].'">';
                                  $table .= '<input type="hidden" name="SET REAL" value="'.$r['SET_REAL'].'">';
                                  $table .= '<input type="hidden" name="OUT PREV" value="'.$r['OUT_PREV'].'">';
                                  $table .= '<input type="hidden" name="OUT REAL" value="'.$r['OUT_REAL'].'">';
                                  $table .= '<input type="hidden" name="NOV PREV" value="'.$r['NOV_PREV'].'">';
                                  $table .= '<input type="hidden" name="NOV REAL" value="'.$r['NOV_REAL'].'">';
                                  $table .= '<input type="hidden" name="DEZ PREV" value="'.$r['DEZ_PREV'].'">';
                                  $table .= '<input type="hidden" name="DEZ REAL" value="'.$r['DEZ_REAL'].'">';
                                  $table .= '<button class="btn btn-primary"><i class="fa fa-calendar-o" aria-hidden="true"></i></i> Editar </i></button>'; //
                                  $table .= '</form></td>';



                                  //MODAL COM OS GRÁFICOS
                                  $table .= '<td><form action="graf-qualite.php" method="post">'; 
                                  $table .= '<input type="hidden" name="ID" value="'.$r['ID'].'">';
                                  $table .= '<input type="hidden" name="KPI" value="'.$r['KPI'].'">';
                                  $table .= '<input type="hidden" name="PILOTE" value="'.$r['PILOTE'].'">';
                                  $table .= '<input type="hidden" name="JAN PREV" value="'.$r['JAN PREV'].'">';
                                  $table .= '<input type="hidden" name="JAN REAL" value="'.$r['JAN REAL'].'">';
                                  $table .= '<input type="hidden" name="FEV PREV" value="'.$r['FEV PREV'].'">';
                                  $table .= '<input type="hidden" name="FEV REAL" value="'.$r['FEV REAL'].'">';
                                  $table .= '<input type="hidden" name="MAR PREV" value="'.$r['MAR PREV'].'">';
                                  $table .= '<input type="hidden" name="MAR REAL" value="'.$r['MAR REAL'].'">';
                                  $table .= '<input type="hidden" name="ABR PREV" value="'.$r['ABR PREV'].'">';
                                  $table .= '<input type="hidden" name="ABR REAL" value="'.$r['ABR REAL'].'">';
                                  $table .= '<input type="hidden" name="MAI PREV" value="'.$r['MAI PREV'].'">';
                                  $table .= '<input type="hidden" name="MAI REAL" value="'.$r['MAI REAL'].'">';
                                  $table .= '<input type="hidden" name="JUN PREV" value="'.$r['JUN PREV'].'">';
                                  $table .= '<input type="hidden" name="JUN REAL" value="'.$r['JUN REAL'].'">';
                                  $table .= '<input type="hidden" name="JUL PREV" value="'.$r['JUL PREV'].'">';
                                  $table .= '<input type="hidden" name="JUL REAL" value="'.$r['JUL REAL'].'">';
                                  $table .= '<input type="hidden" name="AGO PREV" value="'.$r['AGO PREV'].'">';
                                  $table .= '<input type="hidden" name="AGO REAL" value="'.$r['AGO REAL'].'">';
                                  $table .= '<input type="hidden" name="SET PREV" value="'.$r['SET PREV'].'">';
                                  $table .= '<input type="hidden" name="SET REAL" value="'.$r['SET REAL'].'">';
                                  $table .= '<input type="hidden" name="OUT PREV" value="'.$r['OUT PREV'].'">';
                                  $table .= '<input type="hidden" name="OUT REAL" value="'.$r['OUT REAL'].'">';
                                  $table .= '<input type="hidden" name="NOV PREV" value="'.$r['NOV PREV'].'">';
                                  $table .= '<input type="hidden" name="NOV REAL" value="'.$r['NOV REAL'].'">';
                                  $table .= '<input type="hidden" name="DEZ PREV" value="'.$r['DEZ PREV'].'">';
                                  $table .= '<input type="hidden" name="DEZ REAL" value="'.$r['DEZ REAL'].'">';
                                  $table .= '<!-- Button -->
                                              <button type="button" class="btn btn-info button" data-toggle="modal" data-target="#exampleModal" name="button" onclick="abreModal(' . $r['ID'] .');">
                                                Gráfico
                                              </button>

                                              <!-- Modal -->

                                              <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" onload="click("button");">
                                                <div class="modal-dialog" role="document">
                                                  <div class="modal-content">
                                                    <div class="modal-header">
                                                      <h5 class="modal-title" id="exampleModalLabel">Gráfico</h5>
                                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                      </button>
                                                      </div>
                                                      <div class="modal-body">
                                                      </div>
                                                      <div class="modal-footer">
                                                          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                                      </div>
                                                  </div>
                                                </div>
                                              </div>'; //
                                  $table .= '</form></td>';

                              }


                              $table .= '<tr>
                                            <td></td>
                                            <td style="background-color:#c3f786; font-weight:bolder;">GREEN</td>
                                            <td style="background-color:#c3f786;"></td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_jan. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_fev. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_mar. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_abr. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_mai. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_jun. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_jul. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_ago. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_set. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_out. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_nov. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$verde_dez. '</td>
                                        </tr>';
                              $table .= '<tr>
                                            <td></td>
                                            <td style="background-color:#ff4545; font-weight:bolder;">RED</td>
                                            <td style="background-color:#ff4545;"></td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_jan. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_fev. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_mar. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_abr. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_mai. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_jun. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_jul. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_ago. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_set. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_out. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_nov. '</td>
                                            <td></td>
                                            <td style="font-weight:bolder;">' .$vermelho_dez. '</td>
                                        </tr>';

                              //Finalizando a tabela
                              $table .= '</tbody></table>';


                              //Imprimindo a tabela
                              echo '<div class="table-table" style="overflow-x:auto;">';
                              echo $table;
                      ?>

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

Picture of the page:

Please note that it's all two decimal places because it was set in the bank.

The bank exactly matches the image and is defined as two decimal places.

    
asked by anonymous 11.09.2018 / 17:45

0 answers