Bonjour,
J'ai un problème.
je m'explique j'ai une facturation a gérer il génère une facture par mois en regroupant les factures par mois par client en addtition tous ces services
mais ... j'aimerais pouvoir exclure de cette requête les factures qui proviennent du niveau 0 et génère une facture a part.
tout fonctionne bien mais je ne parvient pas a exclure cette facture certains id
alors ma question est ce que pour exclure en sql il faut faire : WHERE id NOT IN (14,12,1) ? et est ce que je peut faire un echo dans une requete sql du style :
$result1 = mysql_query("SELECT * FROM facture_sale_info WHERE id_client ='".$id_client__1."' ".Exclude_my_id($id)." GROUP BY month");
Exclude_my_id étant la première fonction ici dans mon code ?
Code PHP :
connexion();
//------------- cette fonction selectionne les facture a calculer
ob_start();
function Exclude_my_id($id_cus){
// exclure les facture directe !!! des commision
$this_req="";
$sql = 'SELECT id,prix,id_sales FROM facture_sale_info WHERE id_sales="'.$id_cus.'" LIMIT 0,1';
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$total = mysql_num_rows($req);
if ($total ==''){
}else {
$total = mysql_num_rows($req);
// on fait une boucle qui va faire un tour pour chaque enregistrement
while($data = mysql_fetch_assoc($req)) {
$this_req.=$data['id'].',';
}
$var_j_notK=substr($this_req,0,strlen($this_req)-1);
$varJ_NOT='AND != ('.$var_j_notK.')';
};return ob_get_clean();
}
// ------------- fin de cette fonction
//------------- debut du calcul du prix
$prix_total="";
$tabl=mysql_query("SELECT id FROM prefix_membres_info WHERE ref_sales='".$id."' ") or die (mysql_error());
$total_car = mysql_num_rows($tabl);
if ($total_car ==''){
$no_bill= "aucun";
echo'<tr class="';
$couleur++;
if($couleur == 1) echo'style1';
elseif($couleur == 2) { echo'style2'; $couleur=0; }
echo'"><td width="224">'.$no_bill.'</td><td width="194">'.$no_bill.'</td><td width="100">0.0</td><td></tr>';
}
else{
while ($donnees_tabl = mysql_fetch_array($tabl) )
{
$id_client = $donnees_tabl["id"];
///////// a ce stade on connait l'id du client
$this_req="";
// on va recherche tous id de notre vendeur en question ....
$sql = 'SELECT id FROM prefix_sales_info WHERE niv0="'.$id.'" OR niv1="'.$id.'" '.Exclude_my_id($id).'';
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$total = mysql_num_rows($req);
// on fait une boucle qui va faire un tour pour chaque enregistrement
while($data = mysql_fetch_assoc($req)) {
// on affiche les informations de l'enregistrement en cours
$this_req.='"'.$data['id'].'",';
}
////
$delcaract = substr($this_req,0,strlen($this_req)-1);
//echo 'id vendeur :'.$delcaract;
$tabl=mysql_query("SELECT id FROM prefix_membres_info WHERE ref_sales IN ($delcaract)") or die (mysql_error());
$total_car = mysql_num_rows($tabl);
while ($donnees_tabl = mysql_fetch_array($tabl) )
{
$id_client__1 = $donnees_tabl["id"];
$result1 = mysql_query("SELECT * FROM facture_sale_info WHERE id_client ='".$id_client__1."' GROUP BY month");
while ($row=mysql_fetch_array($result1))
{
$prix_client = $row["prix_level_0"];
$mont_j= $row["month"];
$year= $row["year"];
///commence a calucluer le prix du service ///
$prix_total+=+$prix_client;
echo'<tr class="';
$couleur++;
if($couleur == 1) echo'style1';
elseif($couleur == 2) { echo'style2'; $couleur=0; }
$clean_prix=str_replace ( '.', '</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">', $prix_total);
echo'" height="25"><td width="230" align="center"><div style="margin-top:0px"><span style="float:left;padding-top:4px;"><a href="trunk.php?id='.$id.'&year='.$anndefacture.'&month='.$moisdudebut.'&day1='.$donnees_tabl["day_s"].'" title="Votre facture" onclick="
Modalbox.show(this.href, {title: this.title, width:840}); return false;
" class="tinfo1">';
$transac=$id.$year.$mont_j;
generate_facture_number($transac);
echo '</a></span><span style="float:right;margin-right:4px"><a href="ex_sales.php?id='.$id.'&year='.$year.'&month='.$mont_j.'&day1='.$donnees_tabl["day_s"].'&key='.$id_services.'" title="Votre facture" target="_BLANK"><div style="position:absolute;margin-left:-65px; margin-top:4px">Télécharger</div><img src="images/Log_pdf.png" width="18" height="20" /></a></span></div></td><td width="200">';
echo "Du 01-".$mont_j."-$year au : ".date("t",mktime(0,0,0,$mont_j,1,$year))."-$mont_j-$year";
echo'</td><td width="103">';
echo ' <span style="color:#C5281f; font-size:14px">'._get_prix_from_id($id,$mont_j);
echo'</td><td width="134"><div style="margin-top:0px"><span style="float:left;padding-top:4px;">
'. $stat_.'</span><span style="float:right;margin-right:4px"><img src="images/Log_facture_att.png" width="22" height="20" /></span></div></td></tr>';
}
}////
}
}