Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sql = 'Select ';
- $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, ';
- $sql.= ''.MAIN_DB_PREFIX.'facture.datef, ';
- $sql.= ''.MAIN_DB_PREFIX.'user.rowid ';
- $sql.= 'From ';
- $sql.= ''.MAIN_DB_PREFIX.'facturedet Inner Join ';
- $sql.= ''.MAIN_DB_PREFIX.'facture On '.MAIN_DB_PREFIX.'facturedet.fk_facture = '.MAIN_DB_PREFIX.'facture.rowid Inner Join ';
- $sql.= ''.MAIN_DB_PREFIX.'societe_commerciaux On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_soc = '.MAIN_DB_PREFIX.'facture.fk_soc Inner Join ';
- $sql.= ''.MAIN_DB_PREFIX.'user On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_user = '.MAIN_DB_PREFIX.'user.rowid ';
- $sql.= 'Where ';
- $sql.= "".MAIN_DB_PREFIX."facture.datef Between Date_Format(Now(), '%Y-%m-01') And CurDate() ";
- $sql.= 'GROUP BY '.MAIN_DB_PREFIX.'user.rowid ';
- $sql.= 'ORDER BY qty_sum DESC ';
- $resql = $db->query($sql) or die($db->error);
- $sql2 = 'Select ';
- $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, ';
- $sql2.= ''.MAIN_DB_PREFIX.'facture.datef, ';
- $sql2.= ''.MAIN_DB_PREFIX.'user.rowid ';
- $sql2.= 'From ';
- $sql2.= ''.MAIN_DB_PREFIX.'facture Inner Join ';
- $sql2.= ''.MAIN_DB_PREFIX.'societe_commerciaux On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_soc = '.MAIN_DB_PREFIX.'facture.fk_soc Inner Join ';
- $sql2.= ''.MAIN_DB_PREFIX.'user On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_user = '.MAIN_DB_PREFIX.'user.rowid ';
- $sql2.= 'Where ';
- $sql2.= "".MAIN_DB_PREFIX."facture.datef Between Date_Format(Now(), '%Y-%m-01') And CurDate() ";
- $sql2.= 'GROUP BY '.MAIN_DB_PREFIX.'user.rowid ';
- $sql2.= 'ORDER BY total_sum DESC ';
- $resql2 = $db->query($sql2) or die($db->error);
- while($row = $resql->fetch_assoc()) {
- print '<tr>';
- print '<td class="left nowrap"><a href="card.php?id='.$row['rowid'].'" target="_blank">'.$row['firstname'].' '.$row['lastname'].'</a></td>';
- print '<td class="right nowrap">';
- print number_format($comission, 2, '.', '');
- print '</td>';
- print '<td class="right nowrap">';
- print $row['qty_sum'];
- print '</td>';
- print '<td class="right nowrap">';
- print number_format($row['total_sum'], 2, '.', '');
- print '</td>';
- print '</tr>';
- }
Advertisement
Add Comment
Please, Sign In to add comment