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
23 changes: 23 additions & 0 deletions attributionFonctions/__add_tache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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'])) {

$a = new Tache(0, $_POST['description'], $_POST['datedebut'], $_POST['datefin'], $_POST['idagent']);

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

header('Location: taches.php');


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

?>
26 changes: 26 additions & 0 deletions attributionFonctions/__changer_fonction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

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



if(isset($_POST['send'])){
echo $_GET['id'];
echo $_POST['idfonction'];
$fdao = new AgentDAO();
$fdao->Update($_POST['id'],$_POST['idfonction']);





header('Location: index.php');


} else {

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

?>
100 changes: 56 additions & 44 deletions attributionFonctions/agent.dao.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,57 @@
<?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 getNombreAgent($idfonction) {
$req = $this->bdd->prepare('SELECT COUNT(*) FROM agent WHERE idfonction = :idfonction');
$req->execute(array('idfonction' => $idfonction));

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

function Update($id, $idfontion) {
$req = $this->bdd->prepare("UPDATE agent set idfonction= :idfonction where id=:id");
$req->execute(array(
'idfonction' => $idfontion,
'id' => $id
));
}




}

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

if(isset($_POST['desc'], $_POST['datdeb'], $_POST['datef'])
and !empty($_POST['desc']) and !empty($_POST['datdeb']) and !empty($_POST['datef'])) {

$fdao = new TacheDAO();

$fdao->Update($_SESSION['identifiant'],$_POST['desc'],$_POST['datdeb'],$_POST['datef']);


header('Location: taches.php');


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

?>
80 changes: 80 additions & 0 deletions attributionFonctions/changer_tache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
session_start();
$_SESSION['identifiant']=$_GET['id'];


?>
<!doctype>
<html>
<head>
<title>Attribution des fonctions</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<?php include_once('head.php'); ?>

<div>
<h2>Modifier une tache</h2>
<form method="post" action="change_tache.php">
<label for="description">Description :</label>
<input type="text" name="desc" id="description" /><br />
<label for="datedebut">Date début :</label>
<input type="date" name="datdeb" id="datedebut" /><br />
<label for="datefin">Date fin :</label>
<input type="date" name="datef" id="datefin" /><br />
<input type="submit" value="Modifier" />
</form>
</div>
<div>
<h2>Liste des tâches</h2>
<?php

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

$tdao = new TacheDAO();
$lt = $tdao->getAllTache();
$adao = new AgentDAO();
$la = $adao->getAllAgent();

echo '<table>';
echo '
<tr>
<th>N°</th>
<th>DESCRIPTION</th>
<th>DATE DEBUT</th>
<th>DATE FIN</th>
<th>AGENT</th>
</tr>
';
$compteur = 1;
foreach($lt as $t) {
echo '<tr>
<td>'.$compteur.'</td>
<td>'.$t->getDescription().'</td>
<td> <strong>Du</strong> '.date("d",strtotime($t->getDatedebut())).'-'.date("m",strtotime($t->getDatedebut())).'-'.date("Y",strtotime($t->getDatedebut())).'</td>
<td> <strong>Du</strong> '.date("d",strtotime($t->getDatefin())).'-'.date("m",strtotime($t->getDatefin())).'-'.date("Y",strtotime($t->getDatefin())).'</td>
';

foreach($la as $a) {
if($t->getIdAgent() == $a->getId()) {
echo '
<td>'.$a->getNom().'</td>
';
break;
}
}


$compteur++;
}
echo '</table>';
?>
</div>

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

if(isset($_GET['id'])
and !empty($_GET['id'])) {
$fdao = new TacheDAO();
$fdao->Delete($_GET['id']);
header('Location: taches.php');


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

?>
Loading