par
charlottebardet » 25 avr. 2008, 12:11
Je vous met quand même la suite de ma classe achat pour un aperçu :
function Achat($debut,$fin) {
set_time_limit(600);
$this->debut = $debut;
$this->fin = $fin;
$this->color = 0;
}
/*
function calcul_TVA_TOTAL(){
$result = mssql_query("SELECT ligcom.code_tva, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY ligcom.code_tva
ORDER BY ligcom.code_tva");
$this->tva0_total = 0;
$this->qtetva0_total = 0;
$this->tva196_total = 0;
$this->qtetva196_total = 0;
$this->tva55_total = 0;
$this->qtetva55_total = 0;
$this->tva21_total = 0;
$this->qtetva21_total = 0;
while($rows = mssql_fetch_row($result)){
$this->montant_total = $this->montant_total + $rows[1]/10000;
$this->qte_total = $this->qte_total + $rows[2];
if($rows[0]=='0'){
$tva0++;
$this->tva0_total = $rows[1]/10000;
$this->qtetva0_total = $rows[2];
}
else if($rows[0]=='2'){
$tva196++;
$this->tva196_total = $rows[1]/10000;
$this->qtetva196_total = $rows[2];
}
else if($rows[0]=='3'){
$tva55++;
$this->tva55_total = $rows[1]/10000;
$this->qtetva55_total = $rows[2];
}
else if($rows[0]=='5'){
$tva21++;
$this->tva21_total = $rows[1]/10000;
$this->qtetva21_total = $rows[2];
}
}
}*/
function calcul_prix_TOTAL(){
$result = mssql_query("SELECT CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END
ORDER BY CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END");
$this->prix1_total = 0;
$this->qteprix1_total = 0;
$this->prix2_total = 0;
$this->qteprix2_total = 0;
$this->prix3_total = 0;
$this->qteprix3_total = 0;
while($rows = mssql_fetch_row($result)){
if($rows[0]=='prix1'){
$this->prix1_total = $rows[1]/10000;
$this->qteprix1_total = $rows[2];
}
else if($rows[0]=='prix2'){
$prix2++;
$this->prix2_total = $rows[1]/10000;
$this->qteprix2_total = $rows[2];
}
else if($rows[0]=='prix3'){
$prix3++;
$this->prix3_total = $rows[1]/10000;
$this->qteprix3_total = $rows[2];
}
}
}
function calcul_TVA_Grossiste(){
$result = mssql_query("SELECT com.type_com, ligcom.code_tva, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='G'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, ligcom.code_tva
ORDER BY com.type_com, ligcom.code_tva");
$this->tva0[1] = 0;
$this->qtetva0[1] = 0;
$this->tva196[1] = 0;
$this->qtetva196[1] = 0;
$this->tva55[1] = 0;
$this->qtetva55[1] = 0;
$this->tva21[1] = 0;
$this->qtetva21[1] = 0;
while($rows = mssql_fetch_row($result)){
$this->montant_grossiste = $this->montant_grossiste + $rows[2]/10000;
$this->qte_grossiste = $this->qte_grossiste + $rows[3];
if($rows[1]=='0'){
$this->tva0[1] = $rows[2]/10000;
$this->qtetva0[1] = $rows[3];
}
else if($rows[1]=='2'){
$this->tva196[1] = $rows[2]/10000;
$this->qtetva196[1] = $rows[3];
}
else if($rows[1]=='3'){
$this->tva55[1] = $rows[2]/10000;
$this->qtetva55[1] = $rows[3];
}
else if($rows[1]=='5'){
$this->tva21[1] = $rows[2]/10000;
$this->qtetva21[1] = $rows[3];
}
}
}
function calcul_prix_Grossiste(){
$result = mssql_query("SELECT com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='G'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END
ORDER BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END");
$this->prix1[1] = 0;
$this->qteprix1[1] = 0;
$this->prix2[1] = 0;
$this->qteprix2[1] = 0;
$this->prix3[1] = 0;
$this->qteprix3[1] = 0;
while($rows = mssql_fetch_row($result)){
if($rows[1]=='prix1'){
$this->prix1[1] = $rows[2]/10000;
$this->qteprix1[1] = $rows[3];
}
else if($rows[1]=='prix2'){
$this->prix2[1] = $rows[2]/10000;
$this->qteprix2[1] = $rows[3];
}
else if($rows[1]=='prix3'){
$this->prix3[1] = $rows[2]/10000;
$this->qteprix3[1] = $rows[3];
}
}
}
function calcul_TVA_Direct(){
$result = mssql_query("SELECT com.type_com, ligcom.code_tva, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='D'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, ligcom.code_tva
ORDER BY com.type_com, ligcom.code_tva");
$this->tva0[0] = 0;
$this->qtetva0[0] = 0;
$this->tva196[0] = 0;
$this->qtetva196[0] = 0;
$this->tva55[0] = 0;
$this->qtetva55[0] = 0;
$this->tva21[0] = 0;
$this->qtetva21[0] = 0;
while($rows = mssql_fetch_row($result)){
$this->montant_direct = $this->montant_direct + $rows[2]/10000;
$this->qte_direct = $this->qte_direct + $rows[3];
if($rows[1]=='0'){
$this->tva0[0] = $rows[2]/10000;
$this->qtetva0[0] = $rows[3];
}
else if($rows[1]=='2'){
$this->tva196[0] = $rows[2]/10000;
$this->qtetva196[0] = $rows[3];
}
else if($rows[1]=='3'){
$this->tva55[0] = $rows[2]/10000;
$this->qtetva55[0] = $rows[3];
}
else if($rows[1]=='5'){
$this->tva21[0] = $rows[2]/10000;
$this->qtetva21[0] = $rows[3];
}
}
}
function calcul_prix_Direct(){
$result = mssql_query("SELECT com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='D'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END
ORDER BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END");
$this->prix1[0] = 0;
$this->qteprix1[0] = 0;
$this->prix2[0] = 0;
$this->qteprix2[0] = 0;
$this->prix3[0] = 0;
$this->qteprix3[0] = 0;
while($rows = mssql_fetch_row($result)){
if($rows[1]=='prix1'){
$this->prix1[0] = $rows[2]/10000;
$this->qteprix1[0] = $rows[3];
}
else if($rows[1]=='prix2'){
$this->prix2[0] = $rows[2]/10000;
$this->qteprix2[0] = $rows[3];
}
else if($rows[1]=='prix3'){
$this->prix3[0] = $rows[2]/10000;
$this->qteprix3[0] = $rows[3];
}
}
}
/*function aff_tva($h,$sens){
if($h==-1){
$t[0] = $this->tva0_total;
$tx[0] = 1;
$t[1] = $this->tva21_total;
$tx[1] = 2;
$t[2] = $this->tva55_total;
$tx[2] = 3;
$t[3] = $this->tva196_total;
$tx[3] = 4;
}
else{
$t[0] = $this->tva0[$h];
$tx[0] = 1;
$t[1] = $this->tva21[$h];
$tx[1] = 2;
$t[2] = $this->tva55[$h];
$tx[2] = 3;
$t[3] = $this->tva196[$h];
$tx[3] = 4;
}
$temp = '';
$temp2 = '';
$longueur = count($t);
$desordre = true;
while($desordre){
$desordre = false;
for($i=0;$i<($longueur-1);$i++){
if($sens == 'ASC'){
if($t[$i]>$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
else{
if($t[$i]<$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
}
}
for($j = 0;$j<$longueur;$j++){
if($tx[$j]==1) $this->aff_tva0($h);
else if($tx[$j]==2) $this->aff_tva21($h);
else if($tx[$j]==3) $this->aff_tva55($h);
else if($tx[$j]==4) $this->aff_tva196($h);
}
}
*/
function aff_tva0($h){
if($h==-1){
if($this->tva0_total!=0){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> 0%</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva0_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva0_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva0_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
$this->color++;
}
}
else{
if($this->tva0[$h]!=0){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> 0%</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva0[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva0[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva0[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva0[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
$this->color++;
}
}
}
function aff_tva21($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva5'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva21_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva21_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva21_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva5'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva21[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva21[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva21[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva21[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_tva55($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva3'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva55_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva55_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva55_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva3'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva55[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva55[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva55[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva55[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_tva196($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva2'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva196_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva196_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva196_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva2'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva196[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva196[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva196[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva196[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_prix($h,$sens){
if($h==-1){
$t[0] = $this->prix1_total;
$tx[0] = 1;
$t[1] = $this->prix2_total;
$tx[1] = 2;
$t[2] = $this->prix3_total;
$tx[2] = 3;
}
else{
$t[0] = $this->prix1[$h];
$tx[0] = 1;
$t[1] = $this->prix2[$h];
$tx[1] = 2;
$t[2] = $this->prix3[$h];
$tx[2] = 3;
}
$temp = '';
$temp2 = '';
$longueur = count($t);
$desordre = true;
while($desordre){
$desordre = false;
for($i=0;$i<($longueur-1);$i++){
if($sens == 'ASC'){
if($t[$i]>$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
else{
if($t[$i]<$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
}
}
for($j = 0;$j<$longueur;$j++){
if($tx[$j]==1) $this->aff_prix1($h);
else if($tx[$j]==2) $this->aff_prix2($h);
else if($tx[$j]==3) $this->aff_prix3($h);
}
}
function aff_prix1($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Moins de 22,90€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix1_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix1_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->prix1_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Moins de 22,90€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix1[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix1[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->prix1[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->prix1[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_prix2($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Entre 22,90€ et 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix2_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix2_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->prix2_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Entre 22,90€ et 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix2[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix2[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->prix2[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->prix2[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_prix3($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Plus de 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix3_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix3_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->prix3_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Plus de 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix3[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix3[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->prix3[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->prix3[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
}
Je vous met quand même la suite de ma classe achat pour un aperçu :
[php]
function Achat($debut,$fin) {
set_time_limit(600);
$this->debut = $debut;
$this->fin = $fin;
$this->color = 0;
}
/*
function calcul_TVA_TOTAL(){
$result = mssql_query("SELECT ligcom.code_tva, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY ligcom.code_tva
ORDER BY ligcom.code_tva");
$this->tva0_total = 0;
$this->qtetva0_total = 0;
$this->tva196_total = 0;
$this->qtetva196_total = 0;
$this->tva55_total = 0;
$this->qtetva55_total = 0;
$this->tva21_total = 0;
$this->qtetva21_total = 0;
while($rows = mssql_fetch_row($result)){
$this->montant_total = $this->montant_total + $rows[1]/10000;
$this->qte_total = $this->qte_total + $rows[2];
if($rows[0]=='0'){
$tva0++;
$this->tva0_total = $rows[1]/10000;
$this->qtetva0_total = $rows[2];
}
else if($rows[0]=='2'){
$tva196++;
$this->tva196_total = $rows[1]/10000;
$this->qtetva196_total = $rows[2];
}
else if($rows[0]=='3'){
$tva55++;
$this->tva55_total = $rows[1]/10000;
$this->qtetva55_total = $rows[2];
}
else if($rows[0]=='5'){
$tva21++;
$this->tva21_total = $rows[1]/10000;
$this->qtetva21_total = $rows[2];
}
}
}*/
function calcul_prix_TOTAL(){
$result = mssql_query("SELECT CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END
ORDER BY CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END");
$this->prix1_total = 0;
$this->qteprix1_total = 0;
$this->prix2_total = 0;
$this->qteprix2_total = 0;
$this->prix3_total = 0;
$this->qteprix3_total = 0;
while($rows = mssql_fetch_row($result)){
if($rows[0]=='prix1'){
$this->prix1_total = $rows[1]/10000;
$this->qteprix1_total = $rows[2];
}
else if($rows[0]=='prix2'){
$prix2++;
$this->prix2_total = $rows[1]/10000;
$this->qteprix2_total = $rows[2];
}
else if($rows[0]=='prix3'){
$prix3++;
$this->prix3_total = $rows[1]/10000;
$this->qteprix3_total = $rows[2];
}
}
}
function calcul_TVA_Grossiste(){
$result = mssql_query("SELECT com.type_com, ligcom.code_tva, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='G'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, ligcom.code_tva
ORDER BY com.type_com, ligcom.code_tva");
$this->tva0[1] = 0;
$this->qtetva0[1] = 0;
$this->tva196[1] = 0;
$this->qtetva196[1] = 0;
$this->tva55[1] = 0;
$this->qtetva55[1] = 0;
$this->tva21[1] = 0;
$this->qtetva21[1] = 0;
while($rows = mssql_fetch_row($result)){
$this->montant_grossiste = $this->montant_grossiste + $rows[2]/10000;
$this->qte_grossiste = $this->qte_grossiste + $rows[3];
if($rows[1]=='0'){
$this->tva0[1] = $rows[2]/10000;
$this->qtetva0[1] = $rows[3];
}
else if($rows[1]=='2'){
$this->tva196[1] = $rows[2]/10000;
$this->qtetva196[1] = $rows[3];
}
else if($rows[1]=='3'){
$this->tva55[1] = $rows[2]/10000;
$this->qtetva55[1] = $rows[3];
}
else if($rows[1]=='5'){
$this->tva21[1] = $rows[2]/10000;
$this->qtetva21[1] = $rows[3];
}
}
}
function calcul_prix_Grossiste(){
$result = mssql_query("SELECT com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='G'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END
ORDER BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END");
$this->prix1[1] = 0;
$this->qteprix1[1] = 0;
$this->prix2[1] = 0;
$this->qteprix2[1] = 0;
$this->prix3[1] = 0;
$this->qteprix3[1] = 0;
while($rows = mssql_fetch_row($result)){
if($rows[1]=='prix1'){
$this->prix1[1] = $rows[2]/10000;
$this->qteprix1[1] = $rows[3];
}
else if($rows[1]=='prix2'){
$this->prix2[1] = $rows[2]/10000;
$this->qteprix2[1] = $rows[3];
}
else if($rows[1]=='prix3'){
$this->prix3[1] = $rows[2]/10000;
$this->qteprix3[1] = $rows[3];
}
}
}
function calcul_TVA_Direct(){
$result = mssql_query("SELECT com.type_com, ligcom.code_tva, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='D'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, ligcom.code_tva
ORDER BY com.type_com, ligcom.code_tva");
$this->tva0[0] = 0;
$this->qtetva0[0] = 0;
$this->tva196[0] = 0;
$this->qtetva196[0] = 0;
$this->tva55[0] = 0;
$this->qtetva55[0] = 0;
$this->tva21[0] = 0;
$this->qtetva21[0] = 0;
while($rows = mssql_fetch_row($result)){
$this->montant_direct = $this->montant_direct + $rows[2]/10000;
$this->qte_direct = $this->qte_direct + $rows[3];
if($rows[1]=='0'){
$this->tva0[0] = $rows[2]/10000;
$this->qtetva0[0] = $rows[3];
}
else if($rows[1]=='2'){
$this->tva196[0] = $rows[2]/10000;
$this->qtetva196[0] = $rows[3];
}
else if($rows[1]=='3'){
$this->tva55[0] = $rows[2]/10000;
$this->qtetva55[0] = $rows[3];
}
else if($rows[1]=='5'){
$this->tva21[0] = $rows[2]/10000;
$this->qtetva21[0] = $rows[3];
}
}
}
function calcul_prix_Direct(){
$result = mssql_query("SELECT com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END, sum(cast(ligcom.qterec_ligcom*ligcom.prixremht_ligcom as bigint)), sum(ligcom.qterec_ligcom)
FROM (ligcom LEFT JOIN com on ligcom.id_com=com.id_com)
WHERE ligcom.qterec_ligcom <> 0 AND com.type_com='D'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END >= '".$this->debut."'
AND CASE WHEN com.dtliv_com IS NOT NULL THEN (com.dtliv_com)
ELSE CASE WHEN com.dprevliv_com IS NOT NULL THEN (com.dprevliv_com)
ELSE (com.dtenvoi_com) END END <= '".$this->fin."'
GROUP BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END
ORDER BY com.type_com, CASE WHEN ligcom.prixcat_ligcom <= 2290 THEN 'prix1' ELSE CASE WHEN ligcom.prixcat_ligcom <= 15000 AND ligcom.prixcat_ligcom > 2290 THEN 'prix2' ELSE 'prix3' END END");
$this->prix1[0] = 0;
$this->qteprix1[0] = 0;
$this->prix2[0] = 0;
$this->qteprix2[0] = 0;
$this->prix3[0] = 0;
$this->qteprix3[0] = 0;
while($rows = mssql_fetch_row($result)){
if($rows[1]=='prix1'){
$this->prix1[0] = $rows[2]/10000;
$this->qteprix1[0] = $rows[3];
}
else if($rows[1]=='prix2'){
$this->prix2[0] = $rows[2]/10000;
$this->qteprix2[0] = $rows[3];
}
else if($rows[1]=='prix3'){
$this->prix3[0] = $rows[2]/10000;
$this->qteprix3[0] = $rows[3];
}
}
}
/*function aff_tva($h,$sens){
if($h==-1){
$t[0] = $this->tva0_total;
$tx[0] = 1;
$t[1] = $this->tva21_total;
$tx[1] = 2;
$t[2] = $this->tva55_total;
$tx[2] = 3;
$t[3] = $this->tva196_total;
$tx[3] = 4;
}
else{
$t[0] = $this->tva0[$h];
$tx[0] = 1;
$t[1] = $this->tva21[$h];
$tx[1] = 2;
$t[2] = $this->tva55[$h];
$tx[2] = 3;
$t[3] = $this->tva196[$h];
$tx[3] = 4;
}
$temp = '';
$temp2 = '';
$longueur = count($t);
$desordre = true;
while($desordre){
$desordre = false;
for($i=0;$i<($longueur-1);$i++){
if($sens == 'ASC'){
if($t[$i]>$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
else{
if($t[$i]<$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
}
}
for($j = 0;$j<$longueur;$j++){
if($tx[$j]==1) $this->aff_tva0($h);
else if($tx[$j]==2) $this->aff_tva21($h);
else if($tx[$j]==3) $this->aff_tva55($h);
else if($tx[$j]==4) $this->aff_tva196($h);
}
}
*/
function aff_tva0($h){
if($h==-1){
if($this->tva0_total!=0){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> 0%</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva0_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva0_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva0_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
$this->color++;
}
}
else{
if($this->tva0[$h]!=0){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> 0%</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva0[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva0[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva0[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva0[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
$this->color++;
}
}
}
function aff_tva21($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva5'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva21_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva21_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva21_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva5'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva21[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva21[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva21[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva21[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_tva55($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva3'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva55_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva55_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva55_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva3'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva55[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva55[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva55[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva55[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_tva196($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva2'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva196_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva196_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->tva196_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> <?php echo $_SESSION['tva2'].'%'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qtetva196[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->tva196[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->tva196[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->tva196[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_prix($h,$sens){
if($h==-1){
$t[0] = $this->prix1_total;
$tx[0] = 1;
$t[1] = $this->prix2_total;
$tx[1] = 2;
$t[2] = $this->prix3_total;
$tx[2] = 3;
}
else{
$t[0] = $this->prix1[$h];
$tx[0] = 1;
$t[1] = $this->prix2[$h];
$tx[1] = 2;
$t[2] = $this->prix3[$h];
$tx[2] = 3;
}
$temp = '';
$temp2 = '';
$longueur = count($t);
$desordre = true;
while($desordre){
$desordre = false;
for($i=0;$i<($longueur-1);$i++){
if($sens == 'ASC'){
if($t[$i]>$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
else{
if($t[$i]<$t[$i+1]){
$temp = $t[$i];
$temp2 = $tx[$i];
$t[$i] = $t[$i+1];
$tx[$i] = $tx[$i+1];
$t[$i+1] = $temp;
$tx[$i+1] = $temp2;
$desordre = true;
}
}
}
}
for($j = 0;$j<$longueur;$j++){
if($tx[$j]==1) $this->aff_prix1($h);
else if($tx[$j]==2) $this->aff_prix2($h);
else if($tx[$j]==3) $this->aff_prix3($h);
}
}
function aff_prix1($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Moins de 22,90€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix1_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix1_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->prix1_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Moins de 22,90€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix1[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix1[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->prix1[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->prix1[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_prix2($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Entre 22,90€ et 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix2_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix2_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->prix2_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Entre 22,90€ et 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix2[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix2[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->prix2[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->prix2[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
function aff_prix3($h){
if($h==-1){
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Plus de 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix3_total, 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix3_total, 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php if(isset($this->montant_total)) echo number_format(($this->prix3_total/$this->montant_total*100),3).'%'; ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td class="<?php echo 'RowHeader2'.($this->color%2); ?>" nowrap> Plus de 150€</td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->qteprix3[$h], 0, ',', ' '); ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap><?php echo number_format($this->prix3[$h], 2, ',', ' ').' €'; ?></td>
<td class="<?php echo 'Value2'.($this->color%2); ?>" nowrap>
<?php
if ($h == 1) {
if(isset($this->montant_grossiste)) echo number_format(($this->prix3[$h]/$this->montant_grossiste*100),3).'%';
} else {
if(isset($this->montant_direct)) echo number_format(($this->prix3[$h]/$this->montant_direct*100),3).'%';
}
?>
</td>
</tr>
<?php
}
$this->color++;
}
}
[/php]