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
45 changes: 26 additions & 19 deletions attributionFonctions/__add_tache.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
<?php
require_once 'tache.class.php';
require_once 'tache.dao.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'])) {
$t=new tache(0,$_POST['description'], $_POST['datedebut'],$_POST['datefin'], $_POST['idagent']);
$tdao=new TacheDAO();
$lt=$tdao->getAllTache();

if(isset($_POST['idagent']) and isset($_POST['description']) and !empty($_POST['datedebut']) and !empty($_POST['datefin']))
{
$tache = new Tache(0, $_POST['description'], $_POST['datedebut'], $_POST['datefin'], $_POST['idagent']);
$tdao = new TacheDAO();

if($tdao->AddTache($tache) == true)
{
header('Location: taches.php');
$find = false;
foreach($lt as $ta) {
if($ta->getDescription() == $t->getDescription()) {
$find = true;
break;
}
}
else
{
header('Location: taches.php');
if(!$find) {
$tdao->add($t);
}
header('Location: taches.php');


}
else
{
echo 'Remplissez Tous Les Champs';
} else {
echo 'Erreur quelque part';
}





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

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

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


} else {
echo 'Erreur quelque part';
}
?>
13 changes: 12 additions & 1 deletion attributionFonctions/agent.dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ function add(Agent $a) {
));
}

function getOneAgent($idagent)
{
$req = $this->bdd->query("SELECT nom FROM agent WHERE id = $idagent");
$nomfind="";
while($data = $req->fetch()) {
$nomfind=$data['nom'];
}
return $nomfind;

}

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

$resultat = $req->fetch()[0];
$resultat = $req->fetch();
return $resultat;
}
}
Expand Down
97 changes: 34 additions & 63 deletions attributionFonctions/changer_tache.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,41 @@
<link rel="stylesheet" href="style.css" />
</head>
<body>
<?php include_once('head.php'); ?>

<div>
<h2>Changer une tâche de l Agent</h2>
<form method="post" action="__modif_tache.php">
<?php
require_once('agent.dao.php');
require_once 'tache.dao.php';

<?php
include_once('head.php');
require_once('tache.class.php');
require_once('tache.dao.php');
$tdao = new TacheDAO();

if(isset($_GET['id']))
{
$_tache = $tdao->getTache($_GET['id']);
if ($_tache != null)
{
echo
"<div>
<h2>Attribuer une tâche à un Agent</h2>
<form method=\"post\" action=\"\">
<label for=\"description\">Description :</label>
<input type=\"text\" name=\"description\" id=\"description\" value=\"".$_tache->getDescription()."\"/><br />
<label for=\"datedebut\">Date début :</label>
<input type=\"date\" name=\"datedebut\" id=\"datedebut\" /><br />
<label for=\"datefin\">Date fin :</label>
<input type=\"date\" name=\"datefin\" id=\"datefin\" value=\""."06/06/2017"."\"/><br />
<label for=\"idagent\">Agent :</label>
<select name=\"idagent\" id=\"idagent\">";
?>

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

$adao = new AgentDAO();
$la = $adao->getAllAgent();

foreach($la as $a) {
echo '
<option value="'.$a->getId().'">'.$a->getNom().'</option>
';
}

?>

<?php echo "</select><br />
<input type=\"submit\" value=\"Enregistrer\" name=\"editTache\"/>
</form>
</div>"; ?>

<?php
if(isset($_POST['editTache']))
{
$tache = new Tache($_tache->getId(), mysql_real_escape_string($_POST['description']), $_POST['datedebut'], $_POST['datefin'], $_POST['idagent']);
if($tdao->editTache($tache) == true)
{
if(isset($_GET['id']) and !empty($_GET['id'])) {
echo '<input type="hidden" name="id" value="'.$_GET['id'].'">';
$t=new TacheDAO();
$adao = new AgentDAO();
$id=$t->getOneAgent($_GET['id']);
$nom=$adao->getOneAgent($id);
} else {
header('Location: taches.php');
}
else
{
echo "Erreur Lors De La Mise A Jour";
}
}
}
}
include_once('foot.php');
?>
?>
<label for="description">Description :</label>
<input type="text" name="description" id="description" /><br />
<label for="datedebut">Date début :</label>
<input type="date" name="datedebut" id="datedebut" /><br />
<label for="datefin">Date fin :</label>
<input type="date" name="datefin" id="datefin" /><br />
<label for="idagent">Agent :</label>
<?php
echo '<input id="idagent" value="'.$nom. '">';

?>
<input type="hidden" name="idag" value=<?php echo $id; ?> />


<br><hr><input type="submit" value="Modifier" />
</form>
</div>
</body>
</html>


</<html>
50 changes: 15 additions & 35 deletions attributionFonctions/del_tache.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
<!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'); ?>
<?php

<div>

<?php
require_once('tache.class.php');
require_once('tache.dao.php');
require_once('tache.class.php');
require_once('tache.dao.php');


$tdao = new TacheDAO();

if(isset($_GET['id']))
{
$id = $_GET['id'];

if($tdao->delTache($id) === true)
{
echo "<p>Tache Supprimee Avec Succes</p>";
}
else
{
echo "<p>Tache Non Trouvee</p>";
}
}
?>
</div>
if(isset($_GET['id']) and !empty($_GET['id'])) {

<?php include_once('foot.php'); ?>
</body>
</html>
$tdao = new TacheDAO();
$tdao->del($_GET['id']);

header('Location: taches.php');


} else {
echo 'Erreur quelque part';
}

?>
9 changes: 4 additions & 5 deletions attributionFonctions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<?php
require_once('fonction.class.php');
require_once('fonction.dao.php');


$fdao = new FonctionDAO();
$lf = $fdao->getAllFonction();
Expand All @@ -51,10 +52,6 @@
require_once('fonction.dao.php');
require_once('agent.class.php');
require_once('agent.dao.php');

require_once('tache.class.php');
require_once('tache.dao.php');
$tdao = new TacheDAO();

$fdao = new FonctionDAO();
$lf = $fdao->getAllFonction();
Expand All @@ -75,6 +72,8 @@
</tr>
';
$compteur = 1;
require_once ('tache.dao.php');
$tadao=new TacheDAO();
foreach($la as $a) {
echo '<tr>
<td>'.$compteur.'</td>
Expand All @@ -92,7 +91,7 @@
break;
}
}
echo '<td>'.$tdao->getTacheNbr($a->getId()).'</td>';
echo '<td>'.$nb=$tadao->countFunction($a->getId()).'</td>';
echo '<td><a href="changer_fonction.php?id='.$a->getId().'&nom='.$a->getNom().'"><img src="change.jpg" alt="change" width="30px;" /></a></td>';
echo '</tr>';
$compteur++;
Expand Down
Loading