diff --git a/class/objet.php b/class/objet.php index d97e3ebe2081ca196d14dd3dbf769165942ff90c..984c3e14627c2a49414bbafe001757c181183407 100644 --- a/class/objet.php +++ b/class/objet.php @@ -89,4 +89,44 @@ class Objet throw new Exception("RESULT : ".print_r($result,true)."\n".print_r($requete_prepare->errorInfo(),true)); } } + + public function update() + { + $dbName = self::dbName(); + $bdd = new Db(); + + $values = array(); + $params = array(); + foreach(array_keys(get_object_vars($this)) as $keyName) { + if($keyName == "primaryAttr") { continue; } + $params[$keyName] = $this->$keyName; + if($keyName == $this->primaryAttr) { continue; } + $values[$keyName] = $keyName." = :".$keyName; + } + + $req = "UPDATE ".$dbName." SET ".implode(",", array_values($values))." WHERE ".$this->primaryAttr." = :".$this->primaryAttr; + + $requete_prepare = $bdd->db->prepare($req); // on prépare notre requête + + if (!$requete_prepare) { + throw new Exception("PDO::errorInfo(): (STEP 1)\n". print_r($bdd->db->errorInfo(), true)); + } + + $result = $requete_prepare->execute($params); + + if($result != 1) { + throw new Exception("RESULT : ".print_r($result,true)."\n".print_r($requete_prepare->errorInfo(),true)); + } + } + + public function select($id) { + $dbName = self::dbName(); + $bdd = new Db(); + + $requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName." WHERE ".$this->primaryAttr." = :id"); // on prépare notre requête + $requete_prepare->execute(array("id" => $id)); + + $ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC); + $this->fromDb($ligne); + } } \ No newline at end of file diff --git a/controller/personne.php b/controller/personne.php index e53814d160caece32bef830a224fe39ec5e02078..9b1465fbc1a22ae834dce5a4e6fbee028c9d8a46 100644 --- a/controller/personne.php +++ b/controller/personne.php @@ -38,11 +38,13 @@ switch($action) { break; case "editPersonnel": $employe = new Employe(); + $employe->select($_GET['id']); $formConf = $employe->getForm(); include 'view/form.php'; break; case "editClient": $client = new Client(); + $client->select($_GET['id']); $formConf = $client->getForm(); include 'view/form.php'; break; diff --git a/css/custom_boostrap.css b/css/custom_boostrap.css index a76e9e664fcb10b11bce8a40d95247b85fd8e80a..3bac11097ea84a96136a67d0cdfff3e360d2665e 100644 --- a/css/custom_boostrap.css +++ b/css/custom_boostrap.css @@ -4,7 +4,7 @@ width: 100%; /* Set the fixed height of the footer here */ height: 30px; - background-color: #f5f5f5; + background-color: #108a93; } .footer-container { diff --git a/template/header.php b/template/header.php index acd2fd0b90342b74531179516d56514db1ae3d7e..b3d72b1638e5167054f465f7db98dd71f552ea63 100644 --- a/template/header.php +++ b/template/header.php @@ -12,9 +12,9 @@ <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="http://tuxa.sme.utc/~nf17p110/css/bootstrap.css"> - <link rel="stylesheet" href="http://tuxa.sme.utc/~nf17p110/css/custom_bootstrap.css"> - <link href="http://tuxa.sme.utc/~nf17p110/css/sticky-footer.css" rel="stylesheet"> + + <link rel="stylesheet" href="http://tuxa.sme.utc/~nf17p110/css/custom_bootstrap.css"> <!-- Optional theme --> <link rel="icon" type="image/png" href="http://tuxa.sme.utc/~nf17p110/img/logo.png" />