Bläddra i källkod

Complete database operations

LaurentTreguier 9 år sedan
förälder
incheckning
2b5aac739d
3 ändrade filer med 30 tillägg och 11 borttagningar
  1. 10
    1
      controllers/data.php
  2. 11
    7
      controllers/document.php
  3. 9
    3
      controllers/promo.php

+ 10
- 1
controllers/data.php Visa fil

@@ -20,5 +20,14 @@ function data_extract()
20 20
 
21 21
 function alter_data()
22 22
 {
23
-    // TODO
23
+    $data = new Data($_POST["email"]);
24
+    
25
+    $data->setIdentifiant($_POST["identifiant"]);
26
+    $data->setNomFils($_POST["nom_fils"]);
27
+    $data->setPrenomFils($_POST["prenom_fils"]);
28
+    $data->setDdnFils($_POST["ddn_fils"]);
29
+    $data->setTelMobile($_POST["tel_mobile"]);
30
+    $data->setDate($_POST["date"]);
31
+    $data->setIp($_POST["ip"]);
32
+    $data->write();
24 33
 }

+ 11
- 7
controllers/document.php Visa fil

@@ -12,17 +12,21 @@ function document()
12 12
 
13 13
 function add_document()
14 14
 {
15
-    $options = [];
16
-    
17
-    foreach(["rang", "promo", "libelle"] as $field)
18
-        $options[$field] = $_POST[$field];
19
-    
20
-    File::addDocument($_FILES["document"], $options);
15
+    File::addDocument($_FILES["document"], [
16
+        "rang" => $_POST["rang"],
17
+        "promo" => $_POST["promo"],
18
+        "libelle" => $_POST["libelle"]
19
+    ]);
21 20
 }
22 21
 
23 22
 function alter_document()
24 23
 {
25
-    // TODO
24
+    $document = new Document($_POST["id"]);
25
+    
26
+    $document->setRang($_POST["rang"]);
27
+    $document->setPromo($_POST["promo"]);
28
+    $document->setLibelle($_POST["libelle"]);
29
+    $document->setFichier($_POST["fichier"]);
26 30
 }
27 31
 
28 32
 function delete_document()

+ 9
- 3
controllers/promo.php Visa fil

@@ -12,15 +12,21 @@ function promo()
12 12
 
13 13
 function add_promo()
14 14
 {
15
-    // TODO
15
+    Promo::addPromo([
16
+        "id" => $_POST["id"],
17
+        "libelle" => $_POST["libelle"]
18
+    ]);
16 19
 }
17 20
 
18 21
 function alter_promo()
19 22
 {
20
-    // TODO
23
+    $promo = new Promo($_POST["id"]);
24
+    
25
+    $promo->setLibelle($_POST["libelle"]);
26
+    $promo->write();
21 27
 }
22 28
 
23 29
 function delete_promo()
24 30
 {
25
-    // TODO
31
+    (new Promo($_POST["promo"]))->erase();
26 32
 }