139 lines
3.0 KiB
PHP
139 lines
3.0 KiB
PHP
<?php
|
|
|
|
include ('../inc/includes.php');
|
|
include ('../inc/utils.class.php');
|
|
|
|
|
|
function insertFicheEvaluation($nom, $status){
|
|
|
|
$actif = 0;
|
|
if($status == 'on')
|
|
$actif = 1;
|
|
|
|
global $DB;
|
|
|
|
$query = "INSERT INTO fiche_evaluation (`nom_fiche_evaluation` , `actif`) VALUES (? , ?)";
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("si" , $nom,$actif);
|
|
|
|
$stmt->execute();
|
|
|
|
return $DB->insert_id();
|
|
}
|
|
|
|
function updateFicheEvaluation($id_fiche_evaluation, $nom, $status){
|
|
|
|
$actif = 0;
|
|
if($status == 'on')
|
|
$actif = 1;
|
|
|
|
global $DB;
|
|
|
|
$query = "UPDATE fiche_evaluation SET nom_fiche_evaluation = ? , actif= ? where id_fiche_evaluation = ?";
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("sii" , $nom,$actif,$id_fiche_evaluation);
|
|
|
|
$stmt->execute();
|
|
}
|
|
|
|
|
|
function insertLigneFicheEvaluation($idFicheEvaluation, $question, $reponses, $id_parent, $ordre, $comment, $imgUrl){
|
|
|
|
$status = 0;
|
|
if($comment == 'on')
|
|
$status = 1;
|
|
|
|
$myordre = $ordre;
|
|
if($ordre == '')
|
|
$myordre = 0;
|
|
|
|
global $DB;
|
|
|
|
$query = "INSERT INTO ligne_fiche_evaluation (`id_fiche_evaluation` , `question`, `reponses`, `id_parent`, `ordre`, `comment`, `img_url`) VALUES (?,?,?,?,?,?,?)";
|
|
//echo $query;
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("issiiis" , $idFicheEvaluation,$question,$reponses,$id_parent,$myordre,$status,$imgUrl);
|
|
|
|
$stmt->execute();
|
|
|
|
return $DB->insert_id();
|
|
}
|
|
|
|
function updateLigneFicheEvaluation($idLigneFicheEvaluation, $question, $reponses, $id_parent, $ordre, $comment, $imgUrl){
|
|
|
|
$status = 0;
|
|
if($comment == 'on')
|
|
$status = 1;
|
|
|
|
$myordre = $ordre;
|
|
if($ordre == '')
|
|
$myordre = 0;
|
|
|
|
global $DB;
|
|
|
|
$query = "UPDATE ligne_fiche_evaluation SET question = '".$question."', reponses = '".$reponses."', id_parent = ".$id_parent.", ordre = ".$myordre.", comment = ".$status.", img_url = '".$imgUrl."' where id_ligne_fiche_evaluation = ".$idLigneFicheEvaluation;
|
|
//echo $query;
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("ssiiisi" ,$question,$reponses,$id_parent,$myordre,$status,$imgUrl,$idLigneFicheEvaluation);
|
|
|
|
$stmt->execute();
|
|
}
|
|
|
|
|
|
function getFicheEvaluation($id_fiche_evaluation){
|
|
|
|
if(isInjection($id_fiche_evaluation)) {
|
|
echo "Not Allowed";
|
|
return null;
|
|
}
|
|
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT * from fiche_evaluation WHERE id_fiche_evaluation = ?";
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("i" , $id_fiche_evaluation);
|
|
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
if ($result->num_rows > 0) {
|
|
$rows = array();
|
|
while($row = $result->fetch_assoc()) {
|
|
$rows[] = $row;
|
|
}
|
|
return $rows[0];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
function getLignesFicheEvaluation($id_fiche_evaluation) {
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT * from ligne_fiche_evaluation WHERE id_fiche_evaluation = ?";
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("i" , $id_fiche_evaluation);
|
|
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
if ($result->num_rows > 0) {
|
|
$rows = array();
|
|
while($row = $result->fetch_assoc()) {
|
|
$rows[] = $row;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|