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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
| <SCRIPT type="text/javascript">
<!--
function AfficheWarning()
{
alert("La fiche n\'a pas pu être insérée : une fiche pour le poisson est déjà créée !");
}
-->
</SCRIPT>
<?php require_once('../Connections/connexionMysql.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if (isset($_GET['MEMBRE_ID'])) {
$GetMembreID=$_GET['MEMBRE_ID'];
}
else
if(isset($_POST['MEMBRE_ID'])){ $GetMembreID=$_GET['MEMBRE_ID'];}
$row_Fiche="";
$ExistFiche="";
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2"))
{
echo $_POST['MEMBRE_ID'];
if(isset($GetMembreID)) $_POST['MEMBRE_ID'] =$GetMembreID ;
$ExistFiche = sprintf("SELECT 'NOT_EXISTS' from maintenance_poissons where not exists (select 1 from maintenance_poissons where poisson_id = %s and membre_id = %s)",GetSQLValueString($_POST['cmbPoissons'], "int"), GetSQLValueString($GetMembreID, "int"));
mysql_select_db($database_connexionMysql, $connexionMysql);
$ResultFiche = mysql_query($ExistFiche, $connexionMysql) or die(mysql_error());
$row_Fiche = mysql_fetch_assoc($ResultFiche);
if ($row_Fiche !=""){
echo $row_Fiche;
$insertSQL = sprintf("INSERT INTO maintenance_poissons (POISSON_ID, MEMBRE_ID, POISSON_GRADE, REPRODUCTION, QUANTITE, DIFFUSION) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['cmbPoissons'], "int"),
GetSQLValueString($GetMembreID, "int"),
GetSQLValueString($_POST['cmbGrade'], "text"),
GetSQLValueString(isset($_POST['chkReproduction']) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['txtQte'], "int"),
GetSQLValueString(isset($_POST['chkDiffusion']) ? "true" : "", "defined","1","0"));
mysql_select_db($database_connexionMysql, $connexionMysql);
$Result1 = mysql_query($insertSQL, $connexionMysql) or die(mysql_error());
}
else
echo '<script>AfficheWarning();</script>';
}
mysql_select_db($database_connexionMysql, $connexionMysql);
$query_rsGrade = "SELECT * FROM type_poissons";
$rsGrade = mysql_query($query_rsGrade, $connexionMysql) or die(mysql_error());
$row_rsGrade = mysql_fetch_assoc($rsGrade);
$totalRows_rsGrade = mysql_num_rows($rsGrade);
$colPoisson_rsPoissons = "%";
if (isset($_GET['nom_scientifique'])) {
$colPoisson_rsPoissons = $_GET['nom_scientifique'];
}
$colPoisson_rsPoissons = "%";
if (isset($_GET['nom_scientifique'])) {
$colPoisson_rsPoissons = $_GET['nom_scientifique'];
}
mysql_select_db($database_connexionMysql, $connexionMysql);
$query_rsPoissons = sprintf("SELECT POISSON_ID, POISSON_NOM_S FROM poissons WHERE POISSON_NOM_S like CONCAT('%%',%s,'%%') ORDER BY POISSON_NOM_S", GetSQLValueString($colPoisson_rsPoissons, "text"));
$rsPoissons = mysql_query($query_rsPoissons, $connexionMysql) or die(mysql_error());
$row_rsPoissons = mysql_fetch_assoc($rsPoissons);
$totalRows_rsPoissons = mysql_num_rows($rsPoissons);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
<style type="text/css">
.TitreCentré {
text-align: center;
font-size: 16px;
color: #000;
}
body {
background-color: #39F;
}
</style>
</head>
<body>
<p class="TitreCentré">Création d'une fiche de maintenance</p>
<form id="form1" name="form1" method="GET" action="FicheMaintenancePoissons_Create.php">
Remplissez la liste des poissons connu du site en pour les poissons dont le nom scientifique contient :
<label for="nom_scientifique"></label>
<input type="text" name="nom_scientifique" id="nom_scientifique" />
<input type="submit" name="cmdRechercher" id="cmdRechercher" value="remplir" />
</form>
<p> </p>
<p>Choisissez un poisson dans la liste ci dessous !</p>
<form id="form2" name="form2" method="POST" action="<?php echo $editFormAction; ?>">
<p>
<label for="cmbNomPoisson"></label>
</p>
<p>
<label for="txtmembreid"></label>
<input name="txtmembreid" type="text" id="txtmembreid" value="<?php echo $GetMembreID; ?>" />
</p>
<table width="800" border="1">
<tr>
<td width="135">Nom du poisson</td>
<td width="649"><label for="cmbPoissons"></label>
<select name="cmbPoissons" id="cmbPoissons">
<?php
do {
?>
<option value="<?php echo $row_rsPoissons['POISSON_ID']?>"><?php echo $row_rsPoissons['POISSON_NOM_S']?></option>
<?php
} while ($row_rsPoissons = mysql_fetch_assoc($rsPoissons));
$rows = mysql_num_rows($rsPoissons);
if($rows > 0) {
mysql_data_seek($rsPoissons, 0);
$row_rsPoissons = mysql_fetch_assoc($rsPoissons);
}
?>
</select></td>
</tr>
<tr>
<td>Grade maintenu</td>
<td><label for="cmbGrade"></label>
<select name="cmbGrade" id="cmbGrade">
<?php
do {
?>
<option value="<?php echo $row_rsGrade['POISSON_GRADE']?>"><?php echo $row_rsGrade['POISSON_GRADE']?></option>
<?php
} while ($row_rsGrade = mysql_fetch_assoc($rsGrade));
$rows = mysql_num_rows($rsGrade);
if($rows > 0) {
mysql_data_seek($rsGrade, 0);
$row_rsGrade = mysql_fetch_assoc($rsGrade);
}
?>
</select></td>
</tr>
<tr>
<td>Reproduction</td>
<td><input type="checkbox" name="chkReproduction" id="chkReproduction" />
<label for="chkReproduction"></label></td>
</tr>
<tr>
<td>Quantitée</td>
<td><label for="txtQte"></label>
<input type="text" name="txtQte" id="txtQte" /></td>
</tr>
<tr>
<td>Diffusion</td>
<td><input type="checkbox" name="chkDiffusion" id="chkDiffusion" />
<label for="chkDiffusion"></label></td>
</tr>
</table>
<p>
<span class="TitreCentré">
<input type="submit" name="cmdInserer" id="cmdInserer" value="Créer fiche" />
</span></p>
<p> </p>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsGrade);
mysql_free_result($rsPoissons);
?> |
Partager