J'ai regarder mon code mais je sèche
Je voudrais simplifier mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
function affichagecase($nomcomref,$daterdvref,$condition,$orderby,$visuel)
{					
$sql = "SELECT  t1.idclient, t2.nomclient, t2.prenomclient, t2.cp ,t2.ville, t2.telephone, t2.portable, t2.adresse, t4.couleur, t1.id,  t1.rdvcommheure , t1.rdvcomm, t1.confirmcom, t1.resultatrdv, t2.rdv   
FROM rdv  AS t1 
INNER JOIN prospet AS t2 
ON t2.id = t1.idclient AND (t1.idcomm='$nomcomref' OR t1.idcomm2='$nomcomref') $condition
LEFT JOIN zone AS t3 
ON t3.cp=t2.cp and t3.Idcomm='$nomcomref'  
LEFT JOIN couleur AS t4 
ON (t3.Idcouleurs=t4.Id   OR ISNULL(t4.couleur)) 
order BY t1.$orderby ASC";
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
	while($data = mysql_fetch_array($req)) 
		{			
	    	foreach ($data as $key => $value) {
        $$key = $value;
		}
		$nomclient = strtoupper($data['nomclient']);
		$prenomclient = ucfirst($data['prenomclient']);
		$ville = strtoupper($data['ville']);
		$telephone = chunk_split($data['telephone'],"2"," ");
		$portable = chunk_split($data['portable'],"2"," ");
		if(strlen($data['rdvcommheure']) == 3)
			{	
			$rdvcommheure = substr($data['rdvcommheure'],0,1)."h".substr($data['rdvcommheure'],1,2);
			}
		if(strlen($data['rdvcommheure']) == 4)
			{	
			$rdvcommheure = substr($data['rdvcommheure'],0,2)."h".substr($data['rdvcommheure'],2,2);			
			}	
 
		if(($confirm==0 or $confirm==0 )&& $datejour <= $rdvcommrefbase)
			{$couleurtd = 'bgcolor="#FFFF00"';}
		if(($confirm==1)  && $datejour <= $rdvcommrefbase)
			{$couleurtd ='bgcolor="#00FF00"';}	
		if(($rdv=='foire' || $rdv=='perso') && $datejour <= $rdvcommrefbase)
			{$couleurtd ='bgcolor="#FF00FF"';}
		if(($rdv=='recrutement tele' || $rdv=='recrutement commerciaux' or $rdv=='passage en salle' or $rdv=='Fournisseur (Bureau)' or $rdv=='Fournisseur deplacement' or $rdv=='Administratif' or $resultatrdv=='batiment') && $datejour <= $rdvcommrefbase)
			{$couleurtd ='bgcolor="#00FFFF"';}
		if($resultatrdv=='32' && $datejour <= $rdvcommrefbase)
			{$couleurtd ='bgcolor="#0000FF"';}
if($visuel=="rappel"){$couleurtd ='bgcolor="#FF0000"';}	
		if($data['couleur']==NULL)
		{$couleurtdzone ='bgcolor=""';}else{$couleurtdzone ='bgcolor="'.$data['couleur'].'"';}		
		echo("<table width=\"100\" border=\"1\"><tr><td width=\"45\">");
				if(($_SESSION['autorisation'] == 0 or $_SESSION['autorisation'] == 2) and $visuel!="rappel" )
					{	
					echo("<a href=\"index3.php?page=page/admin/agenda/index&page2=confirmation&id=$idclient&idrdv=$id\" >");
					echo("<strong>$rdvcommheure</strong></a></td>");				
					echo("<td width=\"139\" colspan=\"2\" $couleurtdzone><a href=\"impression/visurdv.php?id=$idclient&idrdv=$id&session=0\" target=\"_blank\">$nomclient<br>$prenomclient</a></td></tr>");
					}
					if($_SESSION['autorisation'] == 1 and $visuel!="rappel")
					{	
				echo("<strong>$rdvcommheure</strong></td>");					
				echo("<td width=\"139\" colspan=\"2\" $couleurtdzone><a href=\"impression/visurdv.php?id=$idclient&idrdv=$id&session=1\" target=\"_blank\">$nomclient<br>$prenomclient</a></td></tr>");
					}
					if($visuel=="rappel")
					{
					echo("<strong>Rappel");
					if($orderby=="rappel"){echo"<br>/Com";}
					echo("</strong><td width=\"139\" colspan=\"2\" $couleurtdzone><a href=\"index3.php?page=page/admin/agenda/index&page2=com/ficheraptelepro&id=$idclient\" target=\"_parent\">$nomclient<br>$prenomclient</a></td></tr>");	
					}
				if($idclient=='165' or $idclient=='5' or $idclient=='7' or $idclient=='4' or $idclient=='1' or $idclient=='2' or $idclient=='3' or $idclient=='6')
					{
					echo("<tr><td colspan=\"3\" $couleurtd > $confirmcom </td></tr>");				
					}
				else
					{
					echo("<tr><td colspan=\"3\" $couleurtd >");
					if($visuel!="rappel"){echo"$adresse<br>";}
					echo("$cp&nbsp;$ville");
					if(!empty($telephone)){echo("<br>$telephone");}
					if(!empty($portable)){echo("<br>$portable");}
					echo'</td></tr>';
					}
				echo'</table>';
 
		}
}