Check(); include_once ("check_priv.php"); include_once ("user_menu.php"); $cn=DbConnect($_SESSION['g_dossier']); $User->AccessRequest($cn,EXP_IMP_ECR); if ( !isset ($_GET['p_periode'])) { echo 'Erreur : aucune periode demandée'; exit(0); } $sql_from=GetArray($cn,"select min(p_id) from parm_periode where p_exercice=".$_GET['p_periode']); $sql_to=GetArray($cn,"select max(p_id) from parm_periode where p_exercice=".$_GET['p_periode']); $ret=GetArray($cn,"select distinct j_poste::text from jrnx inner join tmp_pcmn on (pcm_val=j_poste) where j_tech_per >= ".$sql_from[0]['min']." and j_tech_per <= ".$sql_to[0]['max']." and j_poste not like '7%' and j_poste not like '6%' order by j_poste::text"); if ( $ret == null ) {echo 'Rien à exporter'; exit();} printf ("OUVERTURE\n"); // check if the account are balanced $sum=0; foreach ($ret as $poste_id) { $Poste=new poste($cn,$poste_id['j_poste']); // fill the object $Poste->get(); // build sql stmt $sql="j_tech_per >=". $sql_from[0]['min']." and j_tech_per <=".$sql_to[0]['max']; $result=$Poste->GetSoldeDetail($sql ); $Poste->label=str_replace(';','',$Poste->label); if ( $result['solde'] == 0 ) continue; if ( $result['debit'] > $result ['credit'] ) { printf ("d;%d;%s;%12.4f\n",$Poste->id,$Poste->label,$result['solde']); $sum+=$result['solde']; } else { printf ("c;%d;%s;%12.4f\n",$Poste->id,$Poste->label,$result['solde']); $sum-=$result['solde']; } } // $sum must be equal to 0 // $sum > 0 then deb is too big // $sum < 0 then cred is too big // rounded problem if ( round($sum,4) != 0.0 ) { printf("ATTENTION : COMPTE NON EQUILIBRE\n "); $msg = ($sum > 0)?" Debit plus grand de $sum":"Credit plus grand de $sum"; printf ("DIFFERENCE = $msg \n"); } ?>