<?php
      $db_s->query($sql);
      if ($db_s->next_record() != 1)            echo '<div class="AucunResultat">Aucun résulat.</div>';
      else
      {
            $db_s->seek(0);
      ?>
            <h1>PC utilisé</h1>
            <table class="tableau">
            <thead>
                  <tr>
                        <th class="h_g" width="150px">Modèle</th>
                        <th class="h_g" width="60px">Tag</th>
                        <th class="h_g" width="120px">Date</th>
                        <th class="h_g" width="150px">Localisation</th>
                        <th class="h_g" width="120px">Utilisateur actuel</th>
                        <th class="h_g" width="50px">4ème</th>
                        <th class="h_g" width="50px">3ème</th>
                        <th class="h_g" width="50px">2ème</th>
                        <th class="h_g" width="50px">1er</th>
                  </tr>
            </thead>
            <tbody>
            
<?php
            while ($db_s->next_record())
            {
                  
                  
                  $i=1;
                  $j=0;
                  $sql_sub = 'SELECT  * FROM `inv_portable` WHERE `tag`="'.$db_s->f('tag').'" ORDER BY `tag`, `date` DESC';
                  $db_s2->query($sql_sub);
                  while ($db_s2->next_record())
                  {
                        
                        $j =  $db_s2->num_rows();
                        if ($i==1)
                        {
                                    
                              if ($db_s2->f('user') == 'stock')
                              {      // PC en stock
                                    $i=6;
                              }
                              else
                              {      
                                    // Premier passages
                                    echo '<tr ';
                                    if ($k==1)      { echo 'bgcolor="#dae1ef">'; $k=0; }
                                    else            { echo '>'; $k=1; }
                                          echo '<td align="center" class="m_g">' .$db_s2->f('modele'). '</td>';
                                          echo '<td align="center" class="m_g">' .$db_s2->f('tag'). '</td>';
                                          echo '<td align="center" class="m_g">' .FormeDateCourt($db_s2->f('date')). '</td>';
                                          echo '<td align="center" class="m_g">' .$db_s2->f('loc'). '</td>';
                                    // Premier utilisateur
                                    echo '<td><strong>'.$db_s2->f('user').'</strong></td>';
                              }
                              $i++;
                        }
                        
                        if ($i<=5 && $i >2)
                        {
                              if($db_s2->f('user')!='' && $db_s2->f('user')!='stock')
                              {
                                    echo '<td>'.$db_s2->f('user').'</td>';
                                    $i++;
                              }
                        }
                        else
                        {      // PC en stock
                              $i++;
                        }
                  }
                  
            
                  for ($j = $i;$j <= 6; $j++)
                  {
                        echo '<td> . </td>';
                        $i++;
                  }
                  echo '</tr>';
                  ?>
                  
                  
<?php
                  
                  
            }
            ?>
      </tbody>
      </table>
      
<?php } ?>
Partager