1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| if( $_GET[action] == 'stats' ){
//sélection des animateurs
$query = "SELECT DISTINCT * FROM joueurstagesanim";
$result = $new_sql->queryToArray( $query );
//sélection des frais pour chaque animateur
if( !empty($result) ){
foreach( $result as $val ){
$query2 = "SELECT DISTINCT * FROM joueurstagesbilan WHERE idAnim1 = '".$val[idAnim]."' OR idAnim2 = '".$val[idAnim]."' OR idAnim3 = '".$val[idAnim]."' GROUP BY idBilan";
$result2 = $new_sql->queryToArray( $query2 );
$tab = "";
if( !empty($result2) ){
foreach( $result2 as $val2 ){
$tab[] = $val2;
}
}
$listFrais[$val[idAnim]] = array( $val, $tab );
}
}
if( !empty($listFrais) ){
foreach( $listFrais as $val3 ){
/* initialisation des variables */
$kmsT = 0;
$fraisT = 0;
$dT = 0;
$totaux = 0;
$fraisDT = 0;
$dureeT = array();
if( !empty($val3[1]) ){
foreach( $val3[1] as $val4 ){
/* initialisation des variables */
$kmsAnim = 0;
$fraisAnim = 0;
$dureeAnim = "";
//sélection de la date du stage comme clé
$query3 = "SELECT dateTimeStage FROM joueurstages WHERE idStage = '".$val4[idStageRef]."' LIMIT 1";
$result3 = $new_sql->queryToArray( $query3 );
$key = $result3[0][dateTimeStage];
if( $val3[0][idAnim] == $val4[idAnim1] ){
$kmsAnim = $val4[kmAnim1];
$kmsT += $val4[kmAnim1];
$fraisAnim = $val4[fraisAnim1];
$fraisT += $val4[fraisAnim1];
if( $val4[dureeAnim1] != "nul" ){
$dureeAnim = $val4[dureeAnim1];
$dureeT[] = $val4[dureeAnim1];
}
}elseif( $val3[0][idAnim] == $val4[idAnim2] ){
$kmsAnim = $val4[kmAnim2];
$kmsT += $val4[kmAnim2];
$fraisAnim = $val4[fraisAnim2];
$fraisT += $val4[fraisAnim2];
if( $val4[dureeAnim2] != "nul" ){
$dureeAnim = $val4[dureeAnim2];
$dureeT[] = $val4[dureeAnim2];
}
}elseif( $val3[0][idAnim] == $val4[idAnim3] ){
$kmsAnim = $val4[kmAnim3];
$kmsT += $val4[kmAnim3];
$fraisAnim = $val4[fraisAnim3];
$fraisT += $val4[fraisAnim3];
if( $val4[dureeAnim3] != "nul" ){
$dureeAnim = $val4[dureeAnim3];
$dureeT[] = $val4[dureeAnim3];
}
}
$Anim[$val3[0][nomPrenomAnim]][stage][$key] = array( kmsAnim => $kmsAnim, fraisAnim => $fraisAnim, dureeAnim => $dureeAnim );
}
}
//sélection des paramètres
$query = "SELECT valueParamText FROM parameters WHERE titleParam = 'prixKm' LIMIT 1";
$result = $new_sql->queryToArray( $query );
$query1 = "SELECT valueParamText FROM parameters WHERE titleParam = 'prix1/2J' LIMIT 1";
$result1 = $new_sql->queryToArray( $query1 );
$query2 = "SELECT valueParamText FROM parameters WHERE titleParam = 'prix1J' LIMIT 1";
$result2 = $new_sql->queryToArray( $query2 );
$query3 = "SELECT valueParamText FROM parameters WHERE titleParam = 'prix1J1/2' LIMIT 1";
$result3 = $new_sql->queryToArray( $query3 );
$query4 = "SELECT valueParamText FROM parameters WHERE titleParam = 'prix2J' LIMIT 1";
$result4 = $new_sql->queryToArray( $query4 );
foreach( $dureeT as $valT ){
if( $valT == "1/2J" ){
$dT += 0.5;
$fraisDT += $result1[0][0];
}elseif( $valT == "1J" ){
$dT += 1;
$fraisDT += $result2[0][0];
}elseif( $valT == "1J1/2" ){
$dT += 1.5;
$fraisDT += $result3[0][0];
}elseif( $valT == "2J" ){
$dT += 2;
$fraisDT += $result4[0][0];
}
}
$totaux = $fraisDT + $fraisT + $kmsT*$result[0][0];
$Anim[$val3[0][nomPrenomAnim]][total] = array( kmsT => $kmsT, fraisT => $fraisT, dureeT => $dT, totaux => $totaux );
}
}
$smarty->assign('listFrais', $Anim);
$smarty->assign('action', $_GET[action]);
} |
Partager