-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Users models, controllers and views done.
- Loading branch information
Sam Bzez
authored
Nov 12, 2017
1 parent
61d6a8a
commit 441075d
Showing
28 changed files
with
786 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+80.5 KB
Screenshot-2017-11-12 localhost localhost monyckDB phpMyAdmin 4 7 5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
$bdd = mysqli_connect("localhost","root","rooted","monyckDB"); | ||
|
||
if (!$bdd) { | ||
echo "Erreur de connexion MySQL" . PHP_EOL; | ||
exit; | ||
} | ||
//N'oubliez pas de modifier le nom | ||
$project_name = 'Monycks'; | ||
|
||
session_start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
switch ($_GET['ticket']) { | ||
case "create": | ||
include ('views/createTicketView.php'); | ||
break; | ||
|
||
case "edit": | ||
include ('views/editTicketView.php'); | ||
break; | ||
|
||
case "list": | ||
include ('views/listTicketView.php'); | ||
break; | ||
|
||
//Actions | ||
case "createAction": | ||
include ('views/createTicketAction.php'); | ||
break; | ||
|
||
|
||
default: | ||
echo "<p style='font-size:99vh'>_404</p>"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
switch ($_GET['transfer']) { | ||
case "create": | ||
include ('views/createTransferView.php'); | ||
break; | ||
|
||
case "list": | ||
include ('views/listTransferView.php'); | ||
break; | ||
|
||
//Actions | ||
case "createAction": | ||
include ('views/createTransferAction.php'); | ||
break; | ||
|
||
default: | ||
echo "<p style='font-size:99vh'>_404</p>"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
switch ($_GET['user']) { | ||
case "create": | ||
include ('views/createUserView.php'); | ||
break; | ||
|
||
case "edit": | ||
include ('views/editUserView.php'); | ||
break; | ||
|
||
case "list": | ||
include ('views/listUserView.php'); | ||
break; | ||
|
||
//Actions | ||
case "createAction": | ||
include ('do/users/createUserAction.php'); | ||
break; | ||
|
||
case "editAction": | ||
include ('do/users/editUserAction.php'); | ||
break; | ||
|
||
case "deleteAction": | ||
include ('do/users/deleteUserAction.php'); | ||
break; | ||
|
||
default: | ||
echo "<p style='font-size:99vh'>_404</p>"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
$_SESSION['flash'] = '<h1>Ticket créé avec succès !</h1>'; | ||
|
||
header('Location:/'.$project_name.'/index.php?ticket=list'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
$_SESSION['flash'] = '<h1>Transfert effectué !</h1>'; | ||
|
||
header('Location:/'.$project_name.'/index.php?transfer=list'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
require ('models/users.php'); | ||
$l=$_POST["login"]; | ||
$fn=$_POST["firstname"]; | ||
$ln=$_POST["lastname"]; | ||
$sk=$_POST["skills"]; | ||
$m=$_POST["email"]; | ||
$pw=$_POST["password"]; | ||
//Fonction createUser() exécute la requête ! | ||
createUser($bdd,$l,$fn,$ln,$sk,$m,$pw); | ||
|
||
$_SESSION['flash'] = '<h1>User '.$_POST['login'].' créé avec succès !</h1>'; | ||
|
||
header('Location:/'.$project_name.'/index.php?user=list'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
require ('models/users.php'); | ||
$id=$_POST['id']; | ||
deleteUser($bdd,$id); | ||
|
||
$_SESSION['flash'] = '<h1>User '.$_POST['login'].' supprimé avec succès !</h1>'; | ||
|
||
header('Location:/'.$project_name.'/index.php?user=list'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
require ('models/users.php'); | ||
$id=$_POST['id']; | ||
$l=$_POST["login"]; | ||
$sk=$_POST["skills"]; | ||
$c=$_POST["credit"]; | ||
//Fonction createUser() exécute la requête ! | ||
editUser($bdd,$id,$l,$c,$sk); | ||
|
||
$_SESSION['flash'] = '<h1>User '.$_POST['login'].' édité avec succès !</h1>'; | ||
|
||
header('Location:/'.$project_name.'/index.php?user=list'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
function messageFlash() { | ||
if (isset($_SESSION['flash'])) { | ||
echo $_SESSION['flash']; | ||
unset($_SESSION['flash']); | ||
} | ||
} | ||
|
||
function coloredStatus($tk,$statID) { | ||
if($statID == 1) { | ||
echo '<h6 style="color:green;">'.$tk['status'].'</h6>'; | ||
} | ||
else if($statID == 2) { | ||
echo '<h6>'.$tk['status'].'</h6>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
include ('config.php'); | ||
include ('functions.php'); | ||
|
||
if (isset($_GET['ticket']) && $_GET['ticket'] != null) { | ||
include ('controllers/ticketController.php'); | ||
echo "<br>Controlleur Ticket avec la valeur: ". $_GET['ticket'].""; | ||
} | ||
else if (isset($_GET['user']) && $_GET['user'] != null) { | ||
include ('controllers/userController.php'); | ||
echo "<br>Controlleur User avec la valeur: ". $_GET['user'].""; | ||
} | ||
else if (isset($_GET['transfer']) && $_GET['transfer'] != null) { | ||
include('controllers/transferController.php'); | ||
echo "<br>Controlleur Transfer avec la valeur: ". $_GET['transfer'].""; | ||
} | ||
else { | ||
include('views/indexView.php'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
function getTicketList($bdd) { | ||
$result = $bdd->query(' | ||
SELECT o.*,t.*,u.id,st.*,u.firstname,s.* | ||
FROM offers o,tickets t,users u,skills s, status st | ||
WHERE o.id=t.`#id_offer` | ||
AND u.id=t.`#id_user` | ||
AND s.id=t.`#id_skills` | ||
AND st.id=t.`#status`'); | ||
return $result; | ||
} | ||
|
||
// id #id_ticket #id_user #amount time insurance | ||
// #id description #id_offer creationDate #status #id_user #id_skills | ||
// id firstname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
function getTransfersList($bdd) { | ||
$result = $bdd->query('SELECT * FROM transfert'); | ||
return $result->fetch_assoc(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
//GETTERS | ||
|
||
function getUsersList($bdd) { | ||
$result = $bdd->query('SELECT s.id,s.skillname,u.* FROM skills s,users u WHERE s.id=u.`#id_skills` '); | ||
return $result; | ||
} | ||
|
||
function getOneUser($bdd,$id) { | ||
$result = $bdd->query("SELECT s.id,s.skillname,u.* FROM skills s,users u WHERE s.id=u.`#id_skills` AND u.id='".$id."'"); | ||
return $result; | ||
} | ||
|
||
function getSkillsList($bdd) { | ||
$result = $bdd->query('SELECT * FROM skills'); | ||
return $result; | ||
} | ||
|
||
|
||
//SETTERS | ||
|
||
function createUser($bdd,$l,$fn,$ln,$sk,$m,$pw) { | ||
$bdd->query("INSERT INTO users (firstname, lastname, email,login, password, `#id_skills`) | ||
VALUES ('".$fn."','".$ln."','".$m."','".$l."','".$pw."',$sk)"); | ||
} | ||
|
||
function editUser($bdd,$id,$l,$c,$sk) { | ||
$bdd->query("UPDATE users SET login = '".$l."', credit = '".$c."', `#id_skills` = '".$sk."' WHERE users.id=$id"); | ||
} | ||
|
||
//DELETER | ||
|
||
function deleteUser($bdd,$id) { | ||
$bdd->query("DELETE FROM users WHERE users.id=$id"); | ||
} |
Oops, something went wrong.