Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions attributionFonctions/__add_agent.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<?php

require_once('agent.class.php');
require_once('agent.dao.php');



if(isset($_POST['nom'], $_POST['genre'], $_POST['tel'], $_POST['email'], $_POST['idfonction'])
and !empty($_POST['nom']) and !empty($_POST['genre']) and !empty($_POST['tel']) and !empty($_POST['email']) and !empty($_POST['idfonction'])) {

$a = new Agent(0, $_POST['nom'], $_POST['genre'], $_POST['tel'], $_POST['email'], $_POST['idfonction']);

$adao = new AgentDAO();
$adao->add($a);

header('Location: index.php');


} else {
echo 'Erreur dans les données envoyées';
}

<?php

require_once('agent.class.php');
require_once('agent.dao.php');

if(isset($_POST['nom'], $_POST['genre'], $_POST['tel'], $_POST['email'], $_POST['idfonction'])
and !empty($_POST['nom']) and !empty($_POST['genre']) and !empty($_POST['tel']) and !empty($_POST['email']) and !empty($_POST['idfonction'])) {

$a = new Agent(0, $_POST['nom'], $_POST['genre'], $_POST['tel'], $_POST['email'], $_POST['idfonction']);

$adao = new AgentDAO();
$adao->add($a);

header('Location: index.php');


} else {
echo 'Erreur dans les données envoyées';
}

?>
64 changes: 31 additions & 33 deletions attributionFonctions/__add_fonction.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
<?php

require_once('fonction.class.php');
require_once('fonction.dao.php');



if(isset($_POST['intitule'], $_POST['description'])
and !empty($_POST['intitule']) and !empty($_POST['description'])) {

$f = new Fonction(0, $_POST['intitule'], $_POST['description']);

$fdao = new FonctionDAO();

$lf = $fdao->getAllFonction();
$find = false;
foreach($lf as $fo) {
if($fo->getIntitule() == $f->getIntitule()) {
$find = true;
break;
}
}
if(!$find) {
$fdao->add($f);
}

header('Location: fonctions.php');


} else {
echo 'Erreur quelque part';
}

<?php

require_once('fonction.class.php');
require_once('fonction.dao.php');

if(isset($_POST['intitule'], $_POST['description'])
and !empty($_POST['intitule']) and !empty($_POST['description'])) {

$f = new Fonction(0, $_POST['intitule'], $_POST['description']);

$fdao = new FonctionDAO();

$lf = $fdao->getAllFonction();
$find = false;
foreach($lf as $fo) {
if($fo->getIntitule() == $f->getIntitule()) {
$find = true;
break;
}
}
if(!$find) {
$fdao->add($f);
}

header('Location: fonctions.php');


} else {
echo 'Erreur dans les données envoyées';
}

?>
26 changes: 26 additions & 0 deletions attributionFonctions/__add_tache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
require_once('tache.class.php');
require_once('tache.dao.php');


if (isset($_POST['description'], $_POST['datedebut'], $_POST['datefin'], $_POST['idagent'])
and !empty($_POST['description']) and !empty($_POST['datedebut']) and !empty($_POST['datefin']) and !empty($_POST['idagent'])) {

$tache = new Tache(0, $_POST['description'], $_POST['datedebut'], $_POST['datefin'], $_POST['idagent']);
$tdao = new TacheDAO();
$lt = $tdao->getAllTache();
$find = false;
foreach ($lt as $t) {
if ($tache->getDescription() == $t->getDescription()) {
$find = true;
}
}
if (!$find) {
$tdao->add($tache);
header('Location: taches.php');
}

}else{
echo 'Veillez renseigner tous les champs';
}
?>
14 changes: 14 additions & 0 deletions attributionFonctions/__modif_tache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
require_once('tache.dao.php');
require_once('tache.class.php');

if (isset($_POST['id'], $_POST['description'], $_POST['datedebut'], $_POST['datefin'], $_POST['idagent'])
and !empty($_POST['description']) and !empty($_POST['datedebut']) and !empty($_POST['datefin']) and !empty($_POST['idagent'])) {

$tdao = new TacheDAO();
$tdao->modify($_POST['id'], $_POST['description'], $_POST['datedebut'], $_POST['datefin'], $_POST['idagent']);
header('Location: taches.php');
}else{
echo 'Erreur dans les données envoyées';
}
?>
136 changes: 68 additions & 68 deletions attributionFonctions/agent.class.php
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
<?php

class Agent {
private $id;
private $nom;
private $genre;
private $tel;
private $email;
private $idfonction;

function __construct($id, $nom, $genre, $tel, $email, $idfonction) {
$this->id = $id;
$this->nom = $nom;
$this->genre = $genre;
$this->tel = $tel;
$this->email = $email;
$this->idfonction = $idfonction;
}

function getId() {
return $this->id;
}

function getNom() {
return $this->nom;
}

function getGenre() {
return $this->genre;
}

function getTel() {
return $this->tel;
}

function getEmail() {
return $this->email;
}

function getIdfonction() {
return $this->idfonction;
}

function setId($id) {
$this->id = $id;
}

function setNom($nom) {
$this->nom = $nom;
}

function setGenre($genre) {
$this->genre = $genre;
}

function setTel($tel) {
$this->tel = $tel;
}

function setEmail($email) {
$this->email = $email;
}

function setIdfonction($idfonction) {
$this->idfonction = $idfonction;
}
}

<?php
class Agent {
private $id;
private $nom;
private $genre;
private $tel;
private $email;
private $idfonction;
function __construct($id, $nom, $genre, $tel, $email, $idfonction) {
$this->id = $id;
$this->nom = $nom;
$this->genre = $genre;
$this->tel = $tel;
$this->email = $email;
$this->idfonction = $idfonction;
}
function getId() {
return $this->id;
}
function getNom() {
return $this->nom;
}
function getGenre() {
return $this->genre;
}
function getTel() {
return $this->tel;
}
function getEmail() {
return $this->email;
}
function getIdfonction() {
return $this->idfonction;
}
function setId($id) {
$this->id = $id;
}
function setNom($nom) {
$this->nom = $nom;
}
function setGenre($genre) {
$this->genre = $genre;
}
function setTel($tel) {
$this->tel = $tel;
}
function setEmail($email) {
$this->email = $email;
}
function setIdfonction($idfonction) {
$this->idfonction = $idfonction;
}
}
?>
88 changes: 44 additions & 44 deletions attributionFonctions/agent.dao.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
<?php

require_once('connexion.dao.php');

class AgentDAO {
private $bdd;
function __construct() {
$this->bdd = Connexion::getConnexion();
}

function getAllAgent() {
$req = $this->bdd->query('SELECT * FROM agent');
$tabAgent = array();
while($data = $req->fetch()) {
$a = new Agent($data['id'], $data['nom'], $data['genre'], $data['tel'], $data['email'], $data['idfonction']);
$tabAgent[] = $a;
}

$req->closeCursor();

return $tabAgent;
}

function add(Agent $a) {
$req = $this->bdd->prepare('INSERT INTO agent(nom, genre, tel, email, idfonction)
VALUES(:nom, :genre, :tel, :email, :idfonction)');
$req->execute(array(
'nom' => $a->getNom(),
'genre' => $a->getGenre(),
'tel' => $a->getTel(),
'email' => $a->getEmail(),
'idfonction' => $a->getIdfonction()
));
}

function getNombreAgent($idfonction) {
$req = $this->bdd->prepare('SELECT COUNT(*) FROM agent WHERE idfonction = :idfonction');
$req->execute(array('idfonction' => $idfonction));

$resultat = $req->fetch()[0];
return $resultat;
}
}

<?php
require_once('connexion.dao.php');
class AgentDAO {
private $bdd;
function __construct() {
$this->bdd = Connexion::getConnexion();
}
function getAllAgent() {
$req = $this->bdd->query('SELECT * FROM agent');
$tabAgent = array();
while($data = $req->fetch()) {
$a = new Agent($data['id'], $data['nom'], $data['genre'], $data['tel'], $data['email'], $data['idfonction']);
$tabAgent[] = $a;
}
$req->closeCursor();
return $tabAgent;
}
function add(Agent $a) {
$req = $this->bdd->prepare('INSERT INTO agent(nom, genre, tel, email, idfonction)
VALUES(:nom, :genre, :tel, :email, :idfonction)');
$req->execute(array(
'nom' => $a->getNom(),
'genre' => $a->getGenre(),
'tel' => $a->getTel(),
'email' => $a->getEmail(),
'idfonction' => $a->getIdfonction()
));
}
function getAgentByFuntion($idfonction) {
$req = $this->bdd->prepare('SELECT COUNT(*) FROM agent WHERE idfonction = :idfonction');
$req->execute(array('idfonction' => $idfonction));
$resultat = $req->fetch()[0];
return $resultat;
}
}
?>
Loading