Browse Source

Saisie numéros mobiles et adresses mails contacts & entreprise

Alexandre MOTTIER 1 year ago
parent
commit
c4a691a709
7 changed files with 44 additions and 19 deletions
  1. 12 3
      ajoutcontact.php
  2. 2 2
      ajoutentreprise.php
  3. 8 6
      index.php
  4. 6 2
      infocontact.php
  5. 12 3
      modifcontact.php
  6. 2 2
      modifentreprise.php
  7. 2 1
      rechercheemploi.sql

+ 12 - 3
ajoutcontact.php

@@ -43,8 +43,9 @@ $conn = null;
         $poste = str_replace("'", "\'", $poste);
         $mobile = $_POST['Mobile'];
         $entreprise = $_POST['IDEntreprise'];
+        $mail = $_POST['Mail'];
 
-        $sql = "INSERT INTO Contact (Prenom, Nom, Poste, Mobile, IDEntreprise, IDUser) VALUES ('$prenom', '$nom', '$poste', '$mobile', '$entreprise', '$idsession')";
+        $sql = "INSERT INTO Contact (Prenom, Nom, Poste, Mobile, IDEntreprise, IDUser, Mail) VALUES ('$prenom', '$nom', '$poste', '$mobile', '$entreprise', '$idsession', '$mail')";
         mysqli_query($conn, $sql);
     }
 ?>
@@ -77,10 +78,18 @@ $conn = null;
     </tr>
     <tr>
       <td>
-        <label for="Mobile">Numéro de mobile :</label>
+        <label for="Mobile">Numéro de mobile (format 0102030405) :</label>
       </td>
       <td>
-        <input type="text" name="Mobile" >
+        <input type="text" name="Mobile" pattern="0[0-9]{9}" >
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <label for="Mail">Adresse e-mail :</label>
+      </td>
+      <td>
+        <input type="email" name="Mail" >
       </td>
     </tr>
     <tr>

+ 2 - 2
ajoutentreprise.php

@@ -57,10 +57,10 @@ include("class/sqlconnect.php");
         </tr>
         <tr>
           <td>
-            <label for="NumeroTel">Numéro de téléphone de la société : (facultatif)</label>
+            <label for="NumeroTel">Numéro de téléphone de la société : (format 0102030405)</label>
           </td>
           <td>
-            <input type="text" id="NumeroTel" name="NumeroTel">
+            <input type="text" id="NumeroTel" name="NumeroTel" pattern="0[0-9]{9}">
           </td>
         </tr>
       </table>

+ 8 - 6
index.php

@@ -82,16 +82,18 @@ echo "<table>";
 echo "<tr><th>Société</th><th>Contact</th><th>Adresse</th><th>Statut</th><th>Entretiens</th></tr>";
 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
     if (!empty($row['Mobile'])) {
-        $mobile = '(' . $row['Mobile'] . ')';
+        $mobile = strval($row["Mobile"]);
+        $mobile = substr($mobile, 0, 2) . "." . substr($mobile, 2, 2) . "." . substr($mobile, 4, 2) . "." . substr($mobile, 6, 2) . "." . substr($mobile, 8, 2);
+        $mobile = '&nbsp;<br>(' . $mobile . ')';
     } else {
         $mobile = '';
     }
     echo "<tr>";
-    echo "<td>&nbsp; " . "<a href='modifentreprise.php?ID=" . $row['EntrepriseID'] . "'> " . $row['NomSociete'] . " </a>&nbsp;</td>";
-    echo "<td>&nbsp; " . "<a href='infocontact.php?ID=" . $row['ID'] . "'> " . $row['Prenom'] . ' ' . $row['Nom'] . ' ' . $mobile . "</a> " . " &nbsp;</td>";
-    echo "<td>&nbsp; " . $row['Adresse'] . " &nbsp;</td>";
-    echo "<td>&nbsp; " . $row['Statut'] . " &nbsp;</td>";
-    echo "<td> " . "<a href='infoentretien.php?ID=" . $row['ID'] . "'>&nbsp; Afficher les entretiens &nbsp;</a>" . " &nbsp;</td>";
+    echo "<td>" . "<a href='modifentreprise.php?ID=" . $row['EntrepriseID'] . "'>&nbsp;" . $row['NomSociete'] . "&nbsp;</a></td>";
+    echo "<td>" . "<a href='infocontact.php?ID=" . $row['ID'] . "'>&nbsp;" . $row['Prenom'] . ' ' . $row['Nom'] . ' ' . $mobile . "</a></td>";
+    echo "<td>&nbsp;" . $row['Adresse'] . "&nbsp;</td>";
+    echo "<td>&nbsp;" . $row['Statut'] . "&nbsp;</td>";
+    echo "<td>" . "<a href='infoentretien.php?ID=" . $row['ID'] . "'>&nbsp;Afficher les entretiens&nbsp;</a></td>";
     echo '</tr>';
 }
 

+ 6 - 2
infocontact.php

@@ -20,16 +20,20 @@ if (!isset($_SESSION['loggedin'])) {
 include('class/sqlconnect.php');
 $id = $_GET['ID'];
 
-$sql = "SELECT Contact.Prenom, Contact.Nom, Contact.Poste, Entreprise.NomSociete, Contact.Mobile FROM Contact JOIN Entreprise ON Contact.IDEntreprise = Entreprise.ID WHERE Contact.ID =$id";
+$sql = "SELECT Contact.Prenom, Contact.Nom, Contact.Poste, Entreprise.NomSociete, Contact.Mobile, Contact.Mail FROM Contact JOIN Entreprise ON Contact.IDEntreprise = Entreprise.ID WHERE Contact.ID =$id";
 $result = mysqli_query($conn, $sql);
 
+
 echo "<table style='border:1px solid #000;'>";
 while($row = $result->fetch_assoc()) {
+        $mobile = strval($row["Mobile"]);
+        $mobile2 = substr($mobile, 0, 2) . "." . substr($mobile, 2, 2) . "." . substr($mobile, 4, 2) . "." . substr($mobile, 6, 2) . "." . substr($mobile, 8, 2);
         echo "<tr><td style='border:1px solid #000;'>Prénom :</td><td style='border:1px solid #000;'>" . $row["Prenom"] . "</td></tr>";
         echo "<tr><td style='border:1px solid #000;'>Nom :</td><td style='border:1px solid #000;'>" . $row["Nom"] . "</td></tr>";
         echo "<tr><td style='border:1px solid #000;'>Poste :</td><td style='border:1px solid #000;'>" . $row["Poste"] . "</td></tr>";
         echo "<tr><td style='border:1px solid #000;'>Entreprise :</td><td style='border:1px solid #000;'>" . $row["NomSociete"] . "</td></tr>";
-        echo "<tr><td style='border:1px solid #000;'>Numéro de mobile :</td><td style='border:1px solid #000;'>" . $row["Mobile"] . "</td></tr>";
+        echo "<tr><td style='border:1px solid #000;'>Numéro de mobile :</td><td style='border:1px solid #000;'><a href='tel:" . $row["Mobile"] . "'>" . $mobile2 . "</a></td></tr>";
+        echo "<tr><td style='border:1px solid #000;'>Adresse e-mail :</td><td style='border:1px solid #000;'><a href='mailto:" . $row["Mail"] . "'>" . $row["Mail"] . "</a></td></tr>";
     };
 $conn->close();
 ?>

+ 12 - 3
modifcontact.php

@@ -71,10 +71,18 @@ if (!isset($_SESSION['loggedin'])) {
     </tr>
     <tr>
       <td>
-        <label>Numéro de mobile :</label>
+        <label>Numéro de mobile (format 0102030405) :</label>
       </td>
       <td>
-        <input type="text" name="Mobile" value="<?php echo $row['Mobile']; ?>">
+        <input type="text" name="Mobile" pattern="0[0-9]{9}" value="<?php echo $row['Mobile']; ?>">
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <label>Adresse e-mail :</label>
+      </td>
+      <td>
+        <input type="email" name="Mail" value="<?php echo $row['Mail']; ?>">
       </td>
     </tr>
     </table>
@@ -92,8 +100,9 @@ $poste = htmlentities($poste);
 $poste = str_replace("'", "\'", $poste);
 $entreprise = $_POST['IDEntreprise'];
 $mobile = $_POST['Mobile'];
+$mail = $_POST['Mail'];
 
-$sql = "UPDATE Contact SET Prenom='$prenom', Nom='$nom', Poste='$poste', IDEntreprise='$entreprise', Mobile='$mobile' WHERE ID='$id'";
+$sql = "UPDATE Contact SET Prenom='$prenom', Nom='$nom', Poste='$poste', IDEntreprise='$entreprise', Mobile='$mobile', Mail='$mail' WHERE ID='$id'";
 
 if ($conn->query($sql) === TRUE) {
     echo "Le contact a été modifié avec succès";

+ 2 - 2
modifentreprise.php

@@ -48,10 +48,10 @@ if (!isset($_SESSION['loggedin'])) {
     </tr>
     <tr>
       <td>
-        <label>Numéro de téléphone :</label>
+        <label>Numéro de téléphone (format 0102030405):</label>
       </td>
       <td>
-        <input type="text" name="NumeroTel" value="<?php echo $row['NumeroTel']; ?>">
+        <input type="text" name="NumeroTel" pattern="0[0-9]{9}" value="<?php echo $row['NumeroTel']; ?>">
       </td>
     </tr>
     <tr>

+ 2 - 1
rechercheemploi.sql

@@ -17,7 +17,8 @@ CREATE TABLE `Contact` (
   `Prenom` varchar(255) NOT NULL,
   `Nom` varchar(255) NOT NULL,
   `Poste` varchar(255) DEFAULT NULL,
-  `Mobile` varchar(255) DEFAULT NULL,
+  `Mobile` varchar(10) DEFAULT NULL,
+  `Mail` varchar(100) DEFAULT NULL,
   PRIMARY KEY (`ID`),
   KEY `IDEntreprise` (`IDEntreprise`),
   CONSTRAINT `Contact_ibfk_1` FOREIGN KEY (`IDEntreprise`) REFERENCES `Entreprise` (`ID`)