Guest User

Untitled

a guest
Apr 13th, 2021
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.38 KB | None | 0 0
  1.     $sql = 'Select ';
  2.     $sql.= 'Sum('.MAIN_DB_PREFIX.'facturedet.qty) As qty_sum, '.MAIN_DB_PREFIX.'user.firstname, '.MAIN_DB_PREFIX.'user.lastname, '.MAIN_DB_PREFIX.'user.rowid, ';
  3.     $sql.= ''.MAIN_DB_PREFIX.'facture.datef, ';
  4.     $sql.= ''.MAIN_DB_PREFIX.'user.rowid ';
  5.     $sql.= 'From ';
  6.     $sql.= ''.MAIN_DB_PREFIX.'facturedet Inner Join ';
  7.     $sql.= ''.MAIN_DB_PREFIX.'facture On '.MAIN_DB_PREFIX.'facturedet.fk_facture = '.MAIN_DB_PREFIX.'facture.rowid Inner Join ';
  8.     $sql.= ''.MAIN_DB_PREFIX.'societe_commerciaux On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_soc = '.MAIN_DB_PREFIX.'facture.fk_soc Inner Join ';
  9.     $sql.= ''.MAIN_DB_PREFIX.'user On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_user = '.MAIN_DB_PREFIX.'user.rowid ';
  10.     $sql.= 'Where ';
  11.     $sql.= "".MAIN_DB_PREFIX."facture.datef Between Date_Format(Now(), '%Y-%m-01') And CurDate() ";
  12.     $sql.= 'GROUP BY '.MAIN_DB_PREFIX.'user.rowid ';
  13.     $sql.= 'ORDER BY qty_sum DESC ';
  14.     $resql = $db->query($sql) or die($db->error);
  15.  
  16.    
  17.     $sql2 = 'Select ';
  18.     $sql2.= 'Sum('.MAIN_DB_PREFIX.'facture.total) As total_sum, '.MAIN_DB_PREFIX.'user.firstname, '.MAIN_DB_PREFIX.'user.lastname, '.MAIN_DB_PREFIX.'user.rowid, ';
  19.     $sql2.= ''.MAIN_DB_PREFIX.'facture.datef, ';
  20.     $sql2.= ''.MAIN_DB_PREFIX.'user.rowid ';
  21.     $sql2.= 'From ';
  22.     $sql2.= ''.MAIN_DB_PREFIX.'facture Inner Join ';
  23.     $sql2.= ''.MAIN_DB_PREFIX.'societe_commerciaux On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_soc = '.MAIN_DB_PREFIX.'facture.fk_soc Inner Join ';
  24.     $sql2.= ''.MAIN_DB_PREFIX.'user On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_user = '.MAIN_DB_PREFIX.'user.rowid ';
  25.     $sql2.= 'Where ';
  26.     $sql2.= "".MAIN_DB_PREFIX."facture.datef Between Date_Format(Now(), '%Y-%m-01') And CurDate() ";
  27.     $sql2.= 'GROUP BY '.MAIN_DB_PREFIX.'user.rowid ';
  28.     $sql2.= 'ORDER BY total_sum DESC ';
  29.     $resql2 = $db->query($sql2) or die($db->error);
  30.  
  31.     while($row = $resql->fetch_assoc()) {
  32.        
  33.         print '<tr>';
  34.         print '<td class="left nowrap"><a href="card.php?id='.$row['rowid'].'" target="_blank">'.$row['firstname'].' '.$row['lastname'].'</a></td>';
  35.         print '<td class="right nowrap">';
  36.         print number_format($comission, 2, '.', '');
  37.         print '</td>';
  38.            
  39.         print '<td class="right nowrap">';
  40.         print $row['qty_sum'];
  41.         print '</td>';
  42.        
  43.         print '<td class="right nowrap">';
  44.         print number_format($row['total_sum'], 2, '.', '');
  45.         print '</td>';
  46.         print '</tr>';
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment