<?php
ob_start();
require 'database.inc.php';
?>
<html>

<head>
	<meta http-equiv='content-type' content='text/html;charset=utf-8'>
	<title>WebBike V<?php echo VERSION; ?></title>
	<script src="jquery/jquery-1.8.3.min.js"></script>
	<script src="jquery/jquery-ui-1.9.2.custom.min.js"></script>
	<script src="jquery/jquery.ui.datepicker-fr-CH.min.js"></script>
	<SCRIPT language=JavaScript src='valideformulaire.js' type=text/javascript></SCRIPT>

	<?php
	$size = 2;
	if ($ligne = Poste::getPostesByIP()) {
		$size = $ligne['Size'];
	}
	echo "<link href='css/style$size.css' rel='stylesheet' media='screen'>\n";

	echo "<link href='" . CSS_FOLDER . "style.css' rel='stylesheet' media='screen'>\n"
	?>
	<SCRIPT language=JavaScript src="milonic_src.js" type=text/javascript></SCRIPT>
	<script language=JavaScript>
		if (ns4) _d.write("<scr" + "ipt language=JavaScript src=mmenuns4.js><\/scr" + "ipt>");
		else _d.write("<scr" + "ipt language=JavaScript src=mmenudom.js><\/scr" + "ipt>");
	</script>

	<!--
<SCRIPT language=JavaScript src="menu_data.js" type=text/javascript></SCRIPT>
-->

	<script language=JavaScript>
		//desactivation du F5 refraichisement
		document.onkeydown = mykeydown;
		document.onhelp = dsble_Help;
		ignore_submit = false;
		cancel_submit = false;
		force_submit = false;

		function dsble_Help() {
			return false;
		}
		actif = "info";

		function mykeydown(ev) {
			var code;
			var ff = false;
			if (ev) {
				ff = true;
				code = ev.which;
				event = ev;
			} else {
				code = event.keyCode;
			}
			if (code == 10) {}
			if (code == 13) {
				if (cancel_submit) {
					window.event.which = 9;
					window.event.returnValue = false;
				} else {
					if (ignore_submit) {
						ignore_submit = false;
						window.event.which = 9;
						window.event.returnValue = false;
					} else {
						if (force_submit) {
							document.forms[actif].submit();
						}
					}
				}
			}
		}

		function set_default(Type, Sous_type) {
			if (MustSave == 1) {
				alert("Vous devez sauver les changements!");
				return;
			}
			if (AsChange == 1) {
				if (!confirm("Perdre chamgements?")) {
					return;
				}
			}
			texte = "Type = " + Type + " Sous_Type = " + Sous_type;
			document.location.href = "fast.php?Type=" + Type + "&Sous_Type=" + Sous_type + "&NoVisu=0";
		}
	</script>
	<script language=JavaScript>
		_menuCloseDelay = 500 // The time delay for menus to remain visible on mouse out
		_menuOpenDelay = 150 // The time delay before menus open on mouse over
		_subOffsetTop = 0 // Sub menu top offset
		_subOffsetLeft = 0 // Sub menu left offset

		with(menuStyle = new mm_style()) {
			onbgcolor = "#00007F";
			oncolor = "#FFFFFF";
			offbgcolor = "#BFBFBF";
			offcolor = "#000000";
			bordercolor = "#BFBFBF";
			borderstyle = "raised";
			borderwidth = 2;
			separatorsize = "2";
			padding = 4;
			//fontsize="75%";
			fontsize = "100%";
			fontfamily = "tahoma, verdana";
			high3dcolor = "#eeeeee";
			low3dcolor = "#7F7F7F";
			swap3d = "1";
			subimage = "arrow.gif";
			subimagepadding = "2";
			followscroll = 10;
		}

		<?
		if (Test_User($lg_user, $lg_password) == TRUE) {
			echo 'with(milonic=new menuname("Main Menu")){' . "\n" .
				'style=menuStyle;' . "\n" .
				'top=10;' . "\n" .
				'left=10;' . "\n" .
				'alwaysvisible=1;' . "\n" .
				'followscroll="10";' . "\n" .
				'orientation="horizontal";' . "\n";
			if ($lg_menu1 != 0)
				echo 'aI("text=Articles;showmenu=Articles;");' . "\n";
			if ($lg_menu2 != 0)
				echo 'aI("text=Vehicules;showmenu=Vehicules;");' . "\n";
			if ($lg_menu3 != 0)
				echo 'aI("text=Clients;showmenu=Clients;");' . "\n";
			echo '}' . "\n" . "\n";
			if ($lg_menu1 != 0) {
				echo 'with(milonic=new menuname("Articles")){' . "\n" .
					'style=menuStyle;' . "\n";
				if ($lg_menu1 & 1)
					echo 'aI("text=Afficher article;align=center;clickfunction=set_default(1,1);");' . "\n";
				if ($lg_menu1 & 2)
					echo 'aI("text=Modifier article;align=center;clickfunction=set_default(1,2);");' . "\n";
				if ($lg_menu1 & 4)
					echo 'aI("text=Nouvel article;align=center;clickfunction=set_default(1,3);");' . "\n";
				if ($lg_menu1 & 8)
					echo 'aI("text=Copier article;align=center;clickfunction=set_default(1,4);");' . "\n";
				if ($lg_menu1 & 16)
					echo 'aI("text=Supprimer article;align=center;clickfunction=set_default(1,5);");' . "\n";
				echo '}' . "\n" . "\n";
			}
			if ($lg_menu2 != 0) {
				echo 'with(milonic=new menuname("Vehicules")){' . "\n" .
					'style=menuStyle;' . "\n";
				if ($lg_menu2 & 1)
					echo 'aI("text=Afficher vehicule;align=center;clickfunction=set_default(2,1);");' . "\n";
				if ($lg_menu2 & 2)
					echo 'aI("text=Modifier vehicule;align=center;clickfunction=set_default(2,2);");' . "\n";
				if ($lg_menu2 & 4)
					echo 'aI("text=Nouveau vehicule;align=center;clickfunction=set_default(2,3);");' . "\n";
				if ($lg_menu2 & 8)
					echo 'aI("text=Copier vehicule;align=center;clickfunction=set_default(2,4);");' . "\n";
				if ($lg_menu2 & 16)
					echo 'aI("text=Supprimer vehicule;align=center;clickfunction=set_default(2,5);");' . "\n";
				echo '}' . "\n" . "\n";
			}
			if ($lg_menu3 != 0) {
				echo 'with(milonic=new menuname("Clients")){' . "\n" .
					'style=menuStyle;' . "\n";
				if ($lg_menu3 & 1)
					echo 'aI("text=Afficher client;align=center;clickfunction=set_default(3,1);");' . "\n";
				if ($lg_menu3 & 2)
					echo 'aI("text=Modifier client;align=center;clickfunction=set_default(3,2);");' . "\n";
				if ($lg_menu3 & 4)
					echo 'aI("text=Nouveau client;align=center;clickfunction=set_default(3,3);");' . "\n";
				if ($lg_menu3 & 8)
					echo 'aI("text=Copier client;align=center;clickfunction=set_default(3,4);");' . "\n";
				if ($lg_menu3 & 16)
					echo 'aI("text=Supprimer client;align=center;clickfunction=set_default(3,5);");' . "\n";
				echo '}' . "\n" . "\n";
			}
			echo 'drawMenus();' . "\n" . "\n";
		}
		?>
	</script>
	<link href="style.css" rel="stylesheet" media="screen">
</head>

<body>
	<?php
	if (Test_User($lg_user, $lg_password) == TRUE) {
		if (isset($Type) == False) {
			$Type = 1;
		}
		if (isset($Sous_Type) == False) {
			$Sous_Type = 2;
		}
		if (isset($Etape) == False) {
			$Etape = 0;
		}
		if (isset($NoVisu) == False) {
			$NoVisu = 0;
		}
		echo "<br><br>\n";
		switch ($Type) {
			case 1:
				switch ($Sous_Type) {
					case 1:
						echo "<big>Affichage article</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(1, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(1, $NoVisu);
								Affiche_Resultat_Recherche_Form(1, $NoVisu);
								break;
							case 2:
								Affiche_formulaire(1, AFFICHAGE, $no_division = 1, $clef = ${GetNomClef(1)}, $no_visu = $NoVisu);
								break;
						}
						break;
					case 2:
						echo "<big>Modifiaction article</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(1, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(1, $NoVisu);
								Affiche_Resultat_Recherche_Form(1, $NoVisu);
								break;
							case 2:
								if (isset($Modif))
									Valide_Modif(
										1,
										MODIFICATION,
										1,
										${GetNomClef(1)},
										$NoVisu,
										",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'",
										''
									);

								Affiche_formulaire(1, MODIFICATION, $no_division = 1, $clef = ${GetNomClef(1)}, $no_visu = $NoVisu);
								break;
							case 3:
								Valide_Modif(
									1,
									MODIFICATION,
									1,
									${GetNomClef(1)},
									$NoVisu,
									",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'",
									''
								);
								break;
						}
						break;
					case 3:
						echo "<big>Nouvel article</big><br>\n";
						switch ($Etape) {
							case 0:
								Affiche_formulaire(1, NOUVEAU, 1, '', $NoVisu);
								break;
							case 1:
								Valide_Modif(
									1,
									NOUVEAU,
									1,
									'',
									$NoVisu,
									", DateModif, PersonneModif",
									", '" . date("Y-m-d") . "', '" . addslashes($lg_user) . "'"
								);
								break;
						}
						break;
					case 4:
						echo "<big>Copier article</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(1, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(1, $NoVisu);
								Affiche_Resultat_Recherche_Form(1, $NoVisu);
								break;
							case 2:
								Affiche_formulaire(1, COPIE, 1, ${GetNomClef(1)}, $NoVisu);
								break;
							case 3:
								Valide_Modif(
									1,
									COPIE,
									1,
									'',
									$NoVisu,
									", DateModif, PersonneModif",
									", '" . date("Y-m-d") . "', '" . addslashes($lg_user) . "'"
								);
								break;
						}
						break;
					case 5:
						echo "<big>Supprimer article</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(1, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(1, $NoVisu);
								Affiche_Resultat_Recherche_Form(1, $NoVisu);
								break;
							case 2:
								Affiche_formulaire(1, SUPPRIMER, 1, ${GetNomClef(1)}, $NoVisu);
								break;
							case 3:
								Valide_Modif(1, SUPPRIMER, 1, ${GetNomClef(1)}, $NoVisu, "", "");
								break;
						}
						break;
				}
				break;
			case 2:
				switch ($Sous_Type) {
					case 1:
						echo "<big>Affichage véhicule</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(2, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(2, $NoVisu);
								Affiche_Resultat_Recherche_Form(2, $NoVisu);
								break;
							case 2:
								CheckAlertVhc(${GetNomClef(2)});
								Affiche_formulaire(2, AFFICHAGE, $no_division = 1, $clef = ${GetNomClef(2)}, $no_visu = $NoVisu);
								break;
						}
						break;
					case 2:
						echo "<big>Modifiaction véhicule</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(2, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(2, $NoVisu);
								Affiche_Resultat_Recherche_Form(2, $NoVisu);
								break;
							case 2:
								if (isset($Modif)) {
									$clef = Valide_Modif(
										2,
										MODIFICATION,
										1,
										${GetNomClef(2)},
										$NoVisu,
										",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'",
										''
									);
									if ($clef != ${GetNomClef(2)}) {
										echo "la cle a changé<br/>";
										header("Location: fast.php?NoChasis=$clef&Type=$Type&Sous_Type=$Sous_Type&Etape=2&NoVisu=$NoVisu");
									}
								}
								CheckAlertVhc(${GetNomClef(2)});
								Affiche_formulaire(2, MODIFICATION, $no_division = 1, $clef = ${GetNomClef(2)}, $no_visu = $NoVisu);
								break;
							case 3:
								Valide_Modif(
									2,
									MODIFICATION,
									1,
									${GetNomClef(2)},
									$NoVisu,
									",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'",
									''
								);
								break;
						}
						break;
					case 3:
						echo "<big>Nouveau véhicule</big><br>\n";
						switch ($Etape) {
							case 0:
								Affiche_formulaire(2, NOUVEAU, 1, '', $NoVisu);
								break;
							case 1:
								Valide_Modif(
									2,
									NOUVEAU,
									1,
									'',
									$NoVisu,
									", DateModif, PersonneModif",
									", '" . date("Y-m-d") . "', '" . addslashes($lg_user) . "'"
								);
								break;
						}
						break;
					case 4:
						echo "<big>Copier véhicule</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(2, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(2, $NoVisu);
								Affiche_Resultat_Recherche_Form(2, $NoVisu);
								break;
							case 2:
								Affiche_formulaire(2, COPIE, 1, ${GetNomClef(2)}, $NoVisu);
								break;
							case 3:
								Valide_Modif(
									2,
									COPIE,
									1,
									'',
									$NoVisu,
									", DateModif, PersonneModif",
									", '" . date("Y-m-d") . "', '" . addslashes($lg_user) . "'"
								);
								break;
						}
						break;
					case 5:
						echo "<big>Supprimer véhicule</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(2, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(2, $NoVisu);
								Affiche_Resultat_Recherche_Form(2, $NoVisu);
								break;
							case 2:
								Affiche_formulaire(2, SUPPRIMER, 1, ${GetNomClef(2)}, $NoVisu);
								break;
							case 3:
								Valide_Modif(2, SUPPRIMER, 1, ${GetNomClef(2)}, $NoVisu, "", "");
								break;
						}
						break;
				}
				break;
			case 3:
				switch ($Sous_Type) {
					case 1:
						echo "<big>Affichage client</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(3, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(3, $NoVisu);
								Affiche_Resultat_Recherche_Form(3, $NoVisu);
								break;
							case 2:
								CheckAlertClient(${GetNomClef(3)});
								Affiche_formulaire(3, AFFICHAGE, $no_division = 1, $clef = ${GetNomClef(3)}, $no_visu = $NoVisu);
								break;
						}
						break;
					case 2:
						echo "<big>Modifiaction client</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(3, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(3, $NoVisu);
								Affiche_Resultat_Recherche_Form(3, $NoVisu);
								break;
							case 2:
								if (isset($Modif))
									Valide_Modif(
										3,
										MODIFICATION,
										1,
										${GetNomClef(3)},
										$NoVisu,
										",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'",
										''
									);
								CheckAlertClient(${GetNomClef(3)});
								Affiche_formulaire(3, MODIFICATION, $no_division = 1, $clef = ${GetNomClef(3)}, $no_visu = $NoVisu);
								break;
							case 3:
								Valide_Modif(
									3,
									MODIFICATION,
									1,
									${GetNomClef(3)},
									$NoVisu,
									",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'",
									''
								);
								break;
						}
						break;
					case 3:
						echo "<big>Nouvel client</big><br>\n";
						switch ($Etape) {
							case 0:
								Affiche_formulaire(3, NOUVEAU, 1, '', $NoVisu);
								break;
							case 1:
								Valide_Modif(
									3,
									NOUVEAU,
									1,
									'',
									$NoVisu,
									", DateModif, PersonneModif",
									", '" . date("Y-m-d") . "', '" . addslashes($lg_user) . "'"
								);
								break;
						}
						break;
					case 4:
						echo "<big>Copier client</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(3, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(3, $NoVisu);
								Affiche_Resultat_Recherche_Form(3, $NoVisu);
								break;
							case 2:
								Affiche_formulaire(3, COPIE, 1, ${GetNomClef(3)}, $NoVisu);
								break;
							case 3:
								Valide_Modif(
									3,
									COPIE,
									1,
									'',
									$NoVisu,
									", DateModif, PersonneModif",
									", '" . date("Y-m-d") . "', '" . addslashes($lg_user) . "'"
								);
								break;
						}
						break;
					case 5:
						echo "<big>Supprimer client</big><br>\n";
						switch ($Etape) {
							case 0:
								Create_Recherche_Form(3, $NoVisu);
								break;
							case 1:
								Create_Recherche_Form(3, $NoVisu);
								Affiche_Resultat_Recherche_Form(3, $NoVisu);
								break;
							case 2:
								Affiche_formulaire(3, SUPPRIMER, 1, ${GetNomClef(3)}, $NoVisu);
								break;
							case 3:
								Valide_Modif(3, SUPPRIMER, 1, ${GetNomClef(3)}, $NoVisu, "", "");
								break;
						}
						break;
				}
				break;
		}
	}
	?>
</body>

</html>
<?php
ob_end_flush();
?>