summaryrefslogtreecommitdiff
path: root/Database/meth_dbmission.php
diff options
context:
space:
mode:
Diffstat (limited to 'Database/meth_dbmission.php')
-rw-r--r--Database/meth_dbmission.php147
1 files changed, 112 insertions, 35 deletions
diff --git a/Database/meth_dbmission.php b/Database/meth_dbmission.php
index f39f0b6..92f8690 100644
--- a/Database/meth_dbmission.php
+++ b/Database/meth_dbmission.php
@@ -12,48 +12,125 @@ require_once(dirname( __FILE__ )."/dbmain.php");
class DbMission extends DbMain {
// Enregistrement d'une mission
- final public function register_mission($subject, $note, $review, $clientId, $proId) {
- // Vérification de l'existance de l'id de consultant
- $exist = $this->check_exist_pro($proId);
- // Si il existe
- if ($exist) {
- // Préparation de la requète pour enregistrement de la mission
- $reqAddMission = "INSERT INTO ".$this->tableMission."
- (date, subject, note, review, clientId, proId)
- VALUES (?, ?, ?, ?, ?, ?)";
- // Exécution de la requète
- $this->exec_cmd($reqAddMission,
- array(date("Y-m-d H:i:s"), $subject,
- $note, $review,
- $clientId, $proId
- )
- );
- // Retourne 1 pour réussite
- return 1;
- } else {
- // Retourne 0 pour échec
- return 0;
- }
+ final public function register_mission($subject, $clientId, $proId, $jobId) {
+ // Préparation de la requète pour enregistrement de la mission
+ $reqAddMission = "
+ INSERT INTO ".$this->tableMission."
+ (date, subject, clientId, proId, jobCategoryId)
+ VALUES
+ (?, ?, ?, ?, ?)";
+ // Exécution de la requète
+ $this->exec_cmd($reqAddMission, array(date("Y-m-d H:i:s"), $subject, $clientId, $proId, $jobId));
+ return 1;
+ }
+
+ // Enregistrement d'une mission
+ final public function accept_mission($missionId) {
+ // Préparation de la requète pour enregistrement de la mission
+ $reqAddMission = "
+ UPDATE
+ ".$this->tableMission."
+ SET
+ acceptedByPro = ?
+ WHERE
+ missionId = ?";
+ // Exécution de la requète
+ $this->exec_cmd($reqAddMission, array(date("Y-m-d H:i:s"), $missionId));
+ return 1;
+ }
+
+ final public function validate_mission_by_pro($missionId) {
+ // Préparation de la requète pour enregistrement de la mission
+ $reqAddMission = "
+ UPDATE
+ ".$this->tableMission."
+ SET
+ validatedByPro = ?
+ WHERE
+ missionId = ?";
+ // Exécution de la requète
+ $this->exec_cmd($reqAddMission, array(date("Y-m-d H:i:s"), $missionId));
+ return 1;
+ }
+
+ final public function validate_mission_by_client($missionId) {
+ // Préparation de la requète pour enregistrement de la mission
+ $reqAddMission = "
+ UPDATE
+ ".$this->tableMission."
+ SET
+ validatedByClient = ?
+ WHERE
+ missionId = ?";
+ // Exécution de la requète
+ $this->exec_cmd($reqAddMission, array(date("Y-m-d H:i:s"), $missionId));
+ return 1;
+ }
+
+ final public function review_mission($missionId, $review, $note) {
+ // Préparation de la requète pour enregistrement de la mission
+ $reqAddMission = "
+ UPDATE
+ ".$this->tableMission."
+ SET
+ review = ?, note = ?
+ WHERE
+ missionId = ?";
+ // Exécution de la requète
+ $this->exec_cmd($reqAddMission, array($review, $note, $missionId));
+ return 1;
}
// Récupérations des missions d'un pro par son id
- final public function get_mission_by_id($id) {
- $reqGetAllMission = "SELECT subject, note, review, lastname FROM ".$this->tableMission."
- LEFT JOIN ".$this->tableUserInfo."
- ON ".$this->tableMission.".missionId = ".$this->tableUserInfo.".userId
- WHERE proId = ?";
- $result = $this->exec_cmd($reqGetAllMission, array($id))->fetchAll(PDO::FETCH_ASSOC);
+ final public function get_mission_by_pro_id($proId) {
+ $reqGetAllMission = "
+ SELECT
+ missionId, date, subject, note, review,
+ acceptedByPro, validatedByClient,
+ validatedByPro, jobCategoryId, proId, lastname
+ FROM
+ ".$this->tableMission."
+ LEFT JOIN
+ ".$this->tableUserInfo."
+ ON
+ ".$this->tableMission.".proId = ".$this->tableUserInfo.".userId
+ WHERE
+ proId = ?";
+ $result = $this->exec_cmd($reqGetAllMission, array($proId))->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
- // Compte le nombre de mission d'un consultant par son nom
- final public function count_pro_missions_by_lastname($name) {
- $reqCountMission = "SELECT COUNT(*) FROM ".$this->tableMission."
- INNER JOIN ".$this->tableUserInfo."
- ON ".$this->tableMission.".proId = ".$this->tableUserInfo.".userId
- WHERE lastname = ?";
- $result = $this->exec_cmd($reqCountMission, array($name))->fetchAll(PDO::FETCH_ASSOC);
+ // Récupérations des missions d'un client par son id
+ final public function get_mission_by_client_id($clientId) {
+ $reqGetAllMission = "
+ SELECT
+ missionId, date, subject, note, review,
+ acceptedByPro, validatedByClient,
+ validatedByPro, jobCategoryId, lastname
+ FROM
+ ".$this->tableMission."
+ LEFT JOIN
+ ".$this->tableUserInfo."
+ ON
+ ".$this->tableMission.".proId = ".$this->tableUserInfo.".userId
+ WHERE
+ clientId = ?";
+ $result = $this->exec_cmd($reqGetAllMission, array($clientId))->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
+ // Compte le nombre de mission d'un consultant par son nom
+ final public function count_pro_missions_by_id($proId) {
+ $reqCountMission = "
+ SELECT COUNT(*) FROM
+ ".$this->tableMission."
+ INNER JOIN
+ ".$this->tableUserInfo."
+ ON
+ ".$this->tableMission.".proId = ".$this->tableUserInfo.".userId
+ WHERE
+ proId = ?";
+ $result = $this->exec_cmd($reqCountMission, array($proId))->fetchAll(PDO::FETCH_NUM);
+ return $result;
+ }
} \ No newline at end of file