first commit
This commit is contained in:
135
model_controller/article.existance.php
Normal file
135
model_controller/article.existance.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function checkFamCodeExist($fam){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT FAR_CODE FROM `Fam_Produit` WHERE FAR_CODE = ?";
|
||||
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("s" , $fam);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function checkSFamCodeExist($sfam){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT SFA_CODE FROM `Sous_Fam_Produit` WHERE SFA_CODE = ?";
|
||||
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("s" , $sfam);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function checkFamExist($fam){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT FAR_LIB FROM `Fam_Produit` WHERE FAR_LIB = ?";
|
||||
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("s" , $fam);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function checkSFamExist($sfam){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT SFA_LIB FROM `Sous_Fam_Produit` WHERE SFA_LIB = ?";
|
||||
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("s" , $sfam);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getFamLastId($code){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT count(*) c FROM `Fam_Produit` WHERE `FAR_CODE` LIKE '%?%'";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("s" , $code);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result) {
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function getSFamLastId($code){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT count(*) c FROM `Sous_Fam_Produit` WHERE `SFA_CODE` LIKE '%?%'";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("s" , $code);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result) {
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function addFamille($famcode,$famlib){
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO `Fam_Produit`(`FAR_CODE`, `FAR_LIB`, `immobilisation`) VALUES (?,?,1)";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ss" , $famcode,$famlib);
|
||||
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
function addSFamille($sfamcode,$sfamlib){
|
||||
Global $DB;
|
||||
|
||||
$query = "INSERT INTO `Sous_Fam_Produit`(`SFA_CODE`, `SFA_LIB`, `immobilisation`) VALUES (?,?,1)";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ss" , $sfamcode,$sfamlib);
|
||||
|
||||
return $stmt->execute();
|
||||
|
||||
}
|
||||
917
model_controller/articles.list.immo.php
Normal file
917
model_controller/articles.list.immo.php
Normal file
@ -0,0 +1,917 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
include ('../inc/utils.class.php');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function immodepot() {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT DEP_CODE from `Depot` where immobilisation = 1";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
$count = $result->num_rows;
|
||||
|
||||
$depots = "(";
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ($count > 0) {
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$depots = $depots."'".$row['DEP_CODE']."'";
|
||||
|
||||
if($i < $count-1)
|
||||
|
||||
$depots = $depots.",";
|
||||
|
||||
$i++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$depots = $depots.")";
|
||||
|
||||
return $depots;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function getArticles($all){
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`, `STK_ZONE`, `ART_LIBC`, `ART_UB_STK`, `SFA_LIB`, `FAR_LIB`, `STK_RESPONSABLE`, `A_ETAT`, `imgpath`, stk.`DEP_CODE`, stk.`STK_NUMLOT`, stk.`STK_REEL` FROM `Produit` p
|
||||
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
|
||||
WHERE stk.`DEP_CODE` in ".immodepot();
|
||||
|
||||
|
||||
|
||||
$query = $query."GROUP by p.`ART_CODE`";
|
||||
|
||||
//echo $query;
|
||||
|
||||
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getArticlesWithStock() {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`, `ART_LIBC`, `ART_UB_STK`, `SFA_LIB`, `FAR_LIB`, stk.`STK_NUMLOT`, stk.`STK_INV`, stk.`DEP_CODE` FROM `Produit` p
|
||||
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
|
||||
Where stk.`STK_REEL` > 0
|
||||
|
||||
GROUP by p.`ART_CODE`";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
if(getArticlInInventaire($row['DEP_CODE'], $row['ART_CODE'], $row['STK_NUMLOT']) == 0)
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getArticlInInventaire($depcode, $artcode, $stklot) {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT `DEP_CODE`, `ART_CODE`, `STK_NUMLOT`
|
||||
|
||||
FROM `Inventaire` Where `DEP_CODE` ='".$depcode."' and `ART_CODE` ='".$artcode."' and `STK_NUMLOT` ='".$stklot."'";
|
||||
|
||||
|
||||
|
||||
//echo $query;
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
/*$rows = array();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $rows;*/
|
||||
|
||||
if ($result->num_rows > 0)
|
||||
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function getStocks($all) {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT D.`DEP_NOM`, stk.`ART_CODE`, `ART_LIB`, `STK_NUMLOT`, `STK_INV`, `STK_DTINV`, `STK_ENTREE`, `STK_SORTIE`, `STK_REEL`, stk.`DEP_CODE`, FP.`FAR_LIB`, stk.`STK_RESPONSABLE` FROM `Stock2` stk
|
||||
|
||||
JOIN `Produit` P on P.ART_CODE = stk.`ART_CODE`
|
||||
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = P.`FAR_CODE`
|
||||
|
||||
JOIN `Depot` D on D.DEP_CODE = stk.`DEP_CODE`
|
||||
|
||||
";
|
||||
|
||||
if($all != 1)
|
||||
|
||||
$query = $query." Where STK_REEL > 0 ";
|
||||
|
||||
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getDepots() {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT * FROM `Depot` Where immobilisation = 1";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function getInventaire() {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT inv.`id`, inv.`DEP_CODE`, inv.`ART_CODE`, P.`ART_LIB`, dep.`DEP_NOM`, FP.`FAR_LIB`, `SFA_LIB`, inv.`STK_NUMLOT`, `STK_REEL` as Qt_reel, `Qt_compt1`, `usercomp1`, `datecomp1`, `Emplacement`, `Qt_compt2`, `usercomp2`, `datecomp2`, `Qt_controle`, `usercontrole`,`datecontrole` FROM `Inventaire` inv
|
||||
|
||||
JOIN `Produit` P on P.ART_CODE = inv.`ART_CODE`
|
||||
|
||||
LEFT JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = P.`SFA_CODE`
|
||||
|
||||
LEFT JOIN `Fam_Produit` FP on FP.FAR_CODE = P.`FAR_CODE`
|
||||
|
||||
LEFT JOIN `Depot` dep on dep.DEP_CODE = inv.`DEP_CODE`
|
||||
|
||||
LEFT JOIN `Stock2` stk on inv.`ART_CODE` = stk.`ART_CODE` and inv.`DEP_CODE` = stk.`DEP_CODE` and inv.`STK_NUMLOT` = stk.`STK_NUMLOT` and inv.`Emplacement` = stk.`STK_ZONE`
|
||||
|
||||
WHERE inv.`annee` = 2022 AND stk.`DEP_CODE` in ".immodepot();
|
||||
|
||||
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
$rows = array();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getInventaireId($idinv) {
|
||||
|
||||
|
||||
|
||||
if(isInjection($idinv)) {
|
||||
|
||||
echo "Not Allowed";
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT * FROM `Inventaire` inv
|
||||
|
||||
Where id = ".$idinv;
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
$rows = array();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $rows[0];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updateInventaire($invid, $qtcompt1, $qtcompt2, $qtcontrole) {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt1`='".$qtcompt1."', `Qt_compt2`='".$qtcompt2."', `Qt_controle`='".$qtcontrole."' where `id`='".$invid."'";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function saveInventaire($codedepot, $codearticle, $numlot, $emplacement, $qtreel, $qtcompt1, $qtcompt2, $qtcontrole, $usercomp1, $datecomp1, $usercomp2, $datecomp2, $usercontrole, $datecontrole) {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT `id` FROM `Inventaire` WHERE `DEP_CODE` = '".$codedepot."' and `ART_CODE` = '".$codearticle."' and `STK_NUMLOT` = '".$numlot."' and `Emplacement` = '".$emplacement."' and annee = 2022";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
$rows = array();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$inventaire = $rows[0];
|
||||
|
||||
|
||||
|
||||
if($qtcompt1 != '' && count($rows) < 1)
|
||||
|
||||
$query = "INSERT INTO `Inventaire`(`DEP_CODE`, `ART_CODE`, `STK_NUMLOT`, `Qt_reel`, `Qt_compt1`, `usercomp1`, `datecomp1`, `Emplacement`, `annee`) VALUES ('".$codedepot."','".$codearticle."','".$numlot."','".$qtreel."','".$qtcompt1."','".$usercomp1."','".$datecomp1."','".$emplacement."',2022)";
|
||||
// $query = "INSERT INTO `Inventaire`(`DEP_CODE`, `ART_CODE`, `STK_NUMLOT`, `Qt_reel`, `Qt_compt1`, `usercomp1`, `datecomp1`, `Emplacement`, `annee`) VALUES ('test','test','test',1,1,'test','".date('Y')."','test',2022)";
|
||||
|
||||
else {
|
||||
|
||||
if(count($rows) > 0 && $inventaire['id'] != "") {
|
||||
|
||||
$query = "";
|
||||
|
||||
if($qtcompt2 != '')
|
||||
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt2`=`Qt_compt2`+'".$qtcompt2."',`usercomp2`='".$usercomp2."',`datecomp2`='".$datecomp2."' where `id`=".$inventaire['id'];
|
||||
|
||||
else if ($qtcontrole != '')
|
||||
|
||||
$query = "UPDATE `Inventaire` SET `Qt_controle`=`Qt_controle`+'".$qtcontrole."',`usercontrole`='".$usercontrole."',`datecontrole`='".$datecontrole."' where `id`=".$inventaire['id'];
|
||||
|
||||
else if($qtcompt1 != '')
|
||||
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt1`=`Qt_compt1`+'".$qtcompt1."' where `id`=".$inventaire['id'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// echo $query;die;
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getFamille(){
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT p.FAR_CODE, FAR_LIB FROM `Produit` p JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE` JOIN `Sous_Fam_Produit` SFP on SFP.SFA_CODE = p.`SFA_CODE` JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE` GROUP BY FAR_LIB";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getAllFamilles(){
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT FAR_CODE, FAR_LIB FROM `Fam_Produit` WHERE immobilisation = 1";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSFamille(){
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT SFA_CODE, SFA_LIB FROM `Sous_Fam_Produit` WHERE immobilisation = 1";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getZonesMap(){
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT * FROM `Zones`";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[ $row['ZONE']] = $row['LOC_ZONE'];
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getZONES(){
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT * FROM `Zones`";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getArticlesOf($fam){
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
if($fam == "all"){
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`, `STK_NUMLOT` FROM `Produit` p
|
||||
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`";
|
||||
|
||||
}else{
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`, `STK_NUMLOT` FROM `Produit` p
|
||||
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
|
||||
WHERE SFP.`SFA_CODE` = \"$fam\" GROUP by p.`ART_CODE`";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getArticlesOfImmo($fam){
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
if($fam == "all"){
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB` ,stk.STK_NUMLOT ,stk.STK_ZONE FROM `Produit` p
|
||||
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
|
||||
WHERE stk.`DEP_CODE` in ".immodepot();
|
||||
|
||||
}else{
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`,stk.STK_NUMLOT ,stk.STK_ZONE FROM `Produit` p
|
||||
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
|
||||
WHERE stk.`STK_ZONE` = \"$fam\" GROUP by p.`ART_CODE`";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getDepotsMap() {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT * FROM `Depot`";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[$row['DEP_CODE']] = $row['DEP_NOM'];
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getTypeArt(){
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT `TYPE_CODE`, `TYPE_NOM` FROM `typearticle`";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getWUnit(){
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT `ART_UB_STK` UN FROM `Produit` WHERE ART_UB_STK != 'NULL' GROUP BY ART_UB_STK";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function saveProduct($codedepot,$codearticle,$fam,$sfam,$state,$zone,$lib,$responsable,$unite,$imgpath,$obs,$serial) {
|
||||
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "INSERT INTO `Stock2` (`DEP_CODE`, `ART_CODE`, `STK_NUMLOT`, `STK_INV`, `STK_DTINV`, `STK_ENTREE`, `STK_SORTIE`, `STK_REEL`, `STK_ZONE`, `STK_RESPONSABLE`, `A_ETAT`, `OBSERVATION`) VALUES ('".$codedepot."', '".$codearticle."', '".$serial."', '0', '".date("Y-m-d")."', '0', '0', '0', '".$zone."', '".$responsable."', '".$state."', '".$obs."') ";
|
||||
|
||||
$DB->query($query);
|
||||
|
||||
|
||||
|
||||
$query = "INSERT INTO `Produit`(`ART_CODE`, `FAR_CODE`, `SFA_CODE`, `ART_LIB`, `ART_UB_STK`, `imgpath`) VALUES ('".$codearticle."','".$fam."','".$sfam."','".$lib."','".$unite."','".$imgpath."')";
|
||||
|
||||
return $DB->query($query);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getCount($term){
|
||||
|
||||
global $DB;
|
||||
|
||||
|
||||
|
||||
$query = "SELECT count(*) c FROM `Produit` WHERE `ART_CODE` LIKE '%".$term."%'";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
|
||||
if ($result) {
|
||||
|
||||
return $result->fetch_assoc();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
487
model_controller/articles.list.php
Normal file
487
model_controller/articles.list.php
Normal file
@ -0,0 +1,487 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
include ('../inc/utils.class.php');
|
||||
|
||||
function NonImmodepot() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT DEP_CODE from `Depot` where immobilisation = 0";
|
||||
$result = $DB->query($query);
|
||||
$count = $result->num_rows;
|
||||
$depots = "(";
|
||||
$i = 0;
|
||||
if ($count > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$depots = $depots."'".$row['DEP_CODE']."'";
|
||||
if($i < $count-1)
|
||||
$depots = $depots.",";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$depots = $depots.")";
|
||||
return $depots;
|
||||
}
|
||||
|
||||
function getArticles($all){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`, `ART_LIBC`, `ART_UB_STK`, `SFA_LIB`, `FAR_LIB`, `imgpath`, stk.`DEP_CODE`,
|
||||
stk.`STK_NUMLOT`, stk.`STK_REEL`
|
||||
FROM `Produit` p
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
WHERE stk.`DEP_CODE` in ".NonImmodepot();
|
||||
if($all != 1)
|
||||
$query = $query." and STK_REEL > 0 ";
|
||||
|
||||
$query = $query."GROUP by p.`ART_CODE`";
|
||||
//echo $query; die;
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getArticlesWithStock() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`, `ART_LIBC`, `ART_UB_STK`, `SFA_LIB`, `FAR_LIB`, stk.`STK_NUMLOT`, stk.`STK_INV`, stk.`DEP_CODE` FROM `Produit` p
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
Where stk.`STK_REEL` > 0
|
||||
GROUP by p.`ART_CODE`";
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
if(getArticlInInventaire($row['DEP_CODE'], $row['ART_CODE'], $row['STK_NUMLOT']) == 0)
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getArticlInInventaire($depcode, $artcode, $stklot) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT `DEP_CODE`, `ART_CODE`, `STK_NUMLOT`
|
||||
FROM `Inventaire` Where `DEP_CODE` ='".$depcode."' and `ART_CODE` ='".$artcode."' and `STK_NUMLOT` ='".$stklot."'";
|
||||
|
||||
//echo $query;
|
||||
$result = $DB->query($query);
|
||||
/*$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
return $rows;*/
|
||||
if ($result->num_rows > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function getStocks($all) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT D.`DEP_NOM`, stk.`ART_CODE`, `ART_LIB`, `STK_NUMLOT`, `STK_INV`, `STK_DTINV`, `STK_ENTREE`, `STK_SORTIE`,
|
||||
`STK_REEL`, stk.`DEP_CODE`, FP.`FAR_LIB`, stk.`STK_RESPONSABLE`
|
||||
FROM `Stock2` stk
|
||||
JOIN `Produit` P on P.ART_CODE = stk.`ART_CODE`
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = P.`FAR_CODE`
|
||||
JOIN `Depot` D on D.DEP_CODE = stk.`DEP_CODE`";
|
||||
if($all != 1)
|
||||
$query = $query." where STK_REEL > 0 ";
|
||||
//echo $query;
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
//print_r($rows) ;die;
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getDepots() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM `Depot`";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function getInventaire() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT inv.`id`, inv.`DEP_CODE`, inv.`ART_CODE`, P.`ART_LIB`, dep.`DEP_NOM`, FP.`FAR_LIB`, `SFA_LIB`, inv.`STK_NUMLOT`, `STK_REEL` as Qt_reel, `Qt_compt1`, `usercomp1`, `datecomp1`, `Emplacement`, `Qt_compt2`, `usercomp2`, `datecomp2`, `Qt_controle`, `usercontrole`,`datecontrole`
|
||||
FROM `Inventaire` inv
|
||||
JOIN `Produit` P on P.ART_CODE = inv.`ART_CODE`
|
||||
LEFT JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = P.`SFA_CODE`
|
||||
LEFT JOIN `Fam_Produit` FP on FP.FAR_CODE = P.`FAR_CODE`
|
||||
LEFT JOIN `Depot` dep on dep.DEP_CODE = inv.`DEP_CODE`
|
||||
LEFT JOIN `Stock2` stk on inv.`ART_CODE` = stk.`ART_CODE` and inv.`DEP_CODE` = stk.`DEP_CODE` and inv.`STK_NUMLOT` = stk.`STK_NUMLOT`
|
||||
";
|
||||
|
||||
$result = $DB->query($query);
|
||||
$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function getInventaireId($idinv) {
|
||||
|
||||
if(isInjection($idinv)) {
|
||||
echo "Not Allowed";
|
||||
return null;
|
||||
}
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM `Inventaire` inv
|
||||
Where id = ".$idinv;
|
||||
$result = $DB->query($query);
|
||||
$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
return $rows[0];
|
||||
}
|
||||
|
||||
function updateInventaire($invid, $qtcompt1, $qtcompt2, $qtcontrole) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt1`='".$qtcompt1."', `Qt_compt2`='".$qtcompt2."', `Qt_controle`='".$qtcontrole."' where `id`='".$invid."'";
|
||||
$result = $DB->query($query);
|
||||
}
|
||||
|
||||
/*
|
||||
function saveInventaire($codedepot, $codearticle, $numlot, $emplacement, $qtreel, $qtcompt1, $qtcompt2,
|
||||
$qtcontrole, $usercomp1, $datecomp1, $usercomp2, $datecomp2, $usercontrole, $datecontrole) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT `id` FROM `Inventaire` WHERE `DEP_CODE` = '".$codedepot."'
|
||||
and `ART_CODE` = '".$codearticle."' and `STK_NUMLOT` = '".$numlot."' and (annee > 2021 or annee is null)" ;// and FORMAT(`Qt_reel`,2) = FORMAT('".$qtreel."',2)
|
||||
$result = $DB->query($query);
|
||||
$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(count($rows) > 0){
|
||||
$inventaire = $rows[0];
|
||||
}else{
|
||||
$inventaire = null;
|
||||
};
|
||||
|
||||
if($qtcompt1 != '' && count($rows) < 1)
|
||||
$query = "INSERT INTO `Inventaire`(`DEP_CODE`, `ART_CODE`, `STK_NUMLOT`, `Qt_reel`, `Qt_compt1`,
|
||||
`usercomp1`, `datecomp1`, `Emplacement`) VALUES ('".$codedepot."','".$codearticle."','".$numlot."','".$qtreel."',
|
||||
'".$qtcompt1."','".$usercomp1."','".$datecomp1."','')";
|
||||
else {
|
||||
if(count($rows) > 0 && $inventaire['id'] != "") {
|
||||
$query = "";
|
||||
if($qtcompt2 != '')
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt2`='".$qtcompt2."',`usercomp2`='".$usercomp2."',`datecomp2`='".$datecomp2."' where `id`=".$inventaire['id'];
|
||||
else if ($qtcontrole != '')
|
||||
$query = "UPDATE `Inventaire` SET `Qt_controle`='".$qtcontrole."',`usercontrole`='".$usercontrole."',`datecontrole`='".$datecontrole."' where `id`=".$inventaire['id'];
|
||||
else if($qtcompt1 != '')
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt1`='".$qtcompt1."',usercomp1='".$usercomp1."',`datecomp1`='".$datecomp1."' where `id`=".$inventaire['id'];
|
||||
}
|
||||
}
|
||||
//echo $query; die;
|
||||
$result = $DB->query($query);
|
||||
}
|
||||
|
||||
function getFamille(){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT FAR_LIB FROM `Produit` p JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE` JOIN `Sous_Fam_Produit` SFP on SFP.SFA_CODE = p.`SFA_CODE` JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE` GROUP BY FAR_LIB";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
function saveInventaire($codedepot, $codearticle, $numlot, $emplacement, $qtreel, $qtcompt1, $qtcompt2,
|
||||
$qtcontrole, $usercomp1, $datecomp1, $usercomp2, $datecomp2, $usercontrole, $datecontrole) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT `id` FROM `Inventaire` WHERE `DEP_CODE` = '".$codedepot."'
|
||||
and `ART_CODE` = '".$codearticle."' and `STK_NUMLOT` = '".$numlot."'" ;// and FORMAT(`Qt_reel`,2) = FORMAT('".$qtreel."',2)
|
||||
$result = $DB->query($query);
|
||||
$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(count($rows) > 0){
|
||||
$inventaire = $rows[0];
|
||||
}else{
|
||||
$inventaire = null;
|
||||
};
|
||||
|
||||
if(count($rows) < 1){
|
||||
if($qtcompt2 != ''){
|
||||
$query = "INSERT INTO `Inventaire`(`DEP_CODE`, `ART_CODE`, `STK_NUMLOT`, `Qt_reel`, `Qt_compt2`,
|
||||
`usercomp2`, `datecomp2`, `Emplacement`) VALUES ('".$codedepot."','".$codearticle."','".$numlot."','".$qtreel."',
|
||||
'".$qtcompt2."','".$usercomp2."','".$datecomp2."','')";
|
||||
}
|
||||
if($qtcompt1 != ''){
|
||||
$query = "INSERT INTO `Inventaire`(`DEP_CODE`, `ART_CODE`, `STK_NUMLOT`, `Qt_reel`, `Qt_compt1`,
|
||||
`usercomp1`, `datecomp1`, `Emplacement`) VALUES ('".$codedepot."','".$codearticle."','".$numlot."','".$qtreel."',
|
||||
'".$qtcompt1."','".$usercomp1."','".$datecomp1."','')";
|
||||
}
|
||||
}else {
|
||||
if(count($rows) > 0 && $inventaire['id'] != "") {
|
||||
$query = "";
|
||||
if($qtcompt2 != '')
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt2`= `Qt_compt2` + '".$qtcompt2."',`usercomp2`='".$usercomp2."',`datecomp2`='".$datecomp2."' where `id`=".$inventaire['id'];
|
||||
else if ($qtcontrole != '')
|
||||
$query = "UPDATE `Inventaire` SET `Qt_controle`= `Qt_controle` + '".$qtcontrole."',`usercontrole`='".$usercontrole."',`datecontrole`='".$datecontrole."' where `id`=".$inventaire['id'];
|
||||
else if($qtcompt1 != '')
|
||||
$query = "UPDATE `Inventaire` SET `Qt_compt1`= `Qt_compt1` + '".$qtcompt1."',usercomp1='".$usercomp1."',`datecomp1`='".$datecomp1."' where `id`=".$inventaire['id'];
|
||||
}
|
||||
|
||||
}
|
||||
$result = $DB->query($query);
|
||||
}
|
||||
|
||||
function getSFamille(){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT SFA_LIB FROM `Produit` p JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE` JOIN `Sous_Fam_Produit` SFP on SFP.SFA_CODE = p.`SFA_CODE` JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE` GROUP BY SFA_LIB";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getZONES(){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM `Zones`";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getArticlesOf($fam){
|
||||
|
||||
global $DB;
|
||||
|
||||
if($fam == "all"){
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB` FROM `Produit` p
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`";
|
||||
}else{
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB` FROM `Produit` p
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
WHERE SFP.`SFA_CODE` = \"$fam\" GROUP by p.`ART_CODE`";
|
||||
}
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getDepotsMap() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM `Depot`";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[$row['DEP_CODE']] = $row['DEP_NOM'];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getTypeArt(){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT `TYPE_CODE`, `TYPE_NOM` FROM `typearticle`";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getWUnit(){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT `ART_UB_STK` UN FROM `Produit` WHERE ART_UB_STK != 'NULL' GROUP BY ART_UB_STK";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function saveProduct($codedepot,$codearticle,$fam,$sfam,$zone,$lib,$responsable,$unite) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO `stock2` (`DEP_CODE`, `ART_CODE`, `STK_NUMLOT`, `STK_INV`, `STK_DTINV`, `STK_ENTREE`, `STK_SORTIE`, `STK_REEL`) VALUES ('".$codedepot."', '".$codearticle."', '', '0', '".date("Y-m-d")."', '0', '0', '0') ";
|
||||
|
||||
$DB->query($query);
|
||||
|
||||
$query = "INSERT INTO `Produit`(`DEPOT`, `ART_CODE`, `FAR_CODE`, `SFA_CODE`, `ZONE`, `ART_LIB`, `Responsable`, `ART_UB_STK`) VALUES ('".$codedepot."','".$codearticle."','".$fam."','".$sfam."','".$zone."','".$lib."','".$responsable."','".$unite."')";
|
||||
|
||||
$DB->query($query);
|
||||
|
||||
}
|
||||
|
||||
function getCount($term){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT count(*) c FROM `Produit` WHERE `ART_CODE` LIKE '%".$term."%'";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function getArticlesByStock($Stock){
|
||||
|
||||
global $DB;
|
||||
$all = 1;
|
||||
$query = "SELECT p.`ART_CODE`, `ART_LIB`
|
||||
FROM `Produit` p
|
||||
JOIN `Stock2` stk on p.`ART_CODE` = stk.`ART_CODE`
|
||||
JOIN `Sous_Fam_Produit` SFP on SFP.`SFA_CODE` = p.`SFA_CODE`
|
||||
JOIN `Fam_Produit` FP on FP.FAR_CODE = p.`FAR_CODE`
|
||||
WHERE stk.`DEP_CODE` = '".$Stock."'
|
||||
and (stk.annee > 2021 or stk.annee is null)";
|
||||
if($all != 1)
|
||||
$query = $query." and STK_REEL > 0 ";
|
||||
|
||||
$query = $query."GROUP by p.`ART_CODE`";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
51
model_controller/controleinventaire.immo.php
Normal file
51
model_controller/controleinventaire.immo.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
getInventaires();
|
||||
Html::redirect("../front/central.php");
|
||||
|
||||
|
||||
function immodepot() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT DEP_CODE from `Depot` where immobilisation = 1";
|
||||
$result = $DB->query($query);
|
||||
$count = $result->num_rows;
|
||||
$depots = "(";
|
||||
$i = 0;
|
||||
if ($count > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$depots = $depots."'".$row['DEP_CODE']."'";
|
||||
if($i < $count-1)
|
||||
$depots = $depots.",";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$depots = $depots.")";
|
||||
return $depots;
|
||||
}
|
||||
|
||||
function getInventaires() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM `Inventaire`
|
||||
WHERE `DEP_CODE` in ".immodepot();
|
||||
$result = $DB->query($query);
|
||||
$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
|
||||
if($row['Qt_compt1'] == $row['Qt_compt2']) {
|
||||
$query2 = "UPDATE `Inventaire` SET `Qt_controle`= `Qt_compt1` where `id`='".$row['id']."' and `Qt_controle` = 0";
|
||||
//echo $query2;
|
||||
$result2 = $DB->query($query2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
28
model_controller/controleinventaire.php
Normal file
28
model_controller/controleinventaire.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
getInventaires();
|
||||
Html::redirect("../front/central.php");
|
||||
|
||||
function getInventaires() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM `Inventaire`";
|
||||
$result = $DB->query($query);
|
||||
$rows = array();
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
|
||||
if($row['Qt_compt1'] == $row['Qt_compt2']) {
|
||||
$query2 = "UPDATE `Inventaire` SET `Qt_controle`= `Qt_compt1` where `id`='".$row['id']."' and `Qt_controle` = 0";
|
||||
//echo $query2;
|
||||
$result2 = $DB->query($query2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
22
model_controller/fiche.config.evaluation.list.php
Normal file
22
model_controller/fiche.config.evaluation.list.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function getFicheEvaluations(){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from fiche_evaluation";// WHERE actif = 1";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
138
model_controller/fiche.config.evaluation.php
Normal file
138
model_controller/fiche.config.evaluation.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
22
model_controller/fiche.evaluation.list.php
Normal file
22
model_controller/fiche.evaluation.list.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function getFicheEvaluations(){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from fiche_evaluation WHERE actif = 1";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
123
model_controller/fiche.evaluation.pdf.php
Normal file
123
model_controller/fiche.evaluation.pdf.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/utils.class.php');
|
||||
|
||||
function get_entete($idrfe){
|
||||
if(isInjection($idrfe)) { echo "Not Allowed"; return null; }
|
||||
global $DB;
|
||||
|
||||
|
||||
$query = "SELECT *,b.id_ligne_fiche_evaluation as id FROM ligne_fiche_evaluation as b ,`resultat_ligne_fiche_evaluation` as a
|
||||
WHERE a.id_ligne_fiche_evaluation = b.id_ligne_fiche_evaluation
|
||||
and `id_resultat_fiche_evaluation` = ? and b.ordre != 0
|
||||
and b.id_parent = 0 and b.comment = 0 ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $idrfe);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$res[] = $row;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_annee($idrfe){
|
||||
if(isInjection($idrfe)) { echo "Not Allowed"; return null; }
|
||||
global $DB;
|
||||
|
||||
|
||||
$query = "SELECT resultat_ligne_fiche_evaluation.reponse as annee
|
||||
FROM `resultat_ligne_fiche_evaluation`
|
||||
WHERE `id_resultat_fiche_evaluation` = ? LIMIT 1";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $idrfe);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$res[] = $row;
|
||||
}
|
||||
return $res[0]['annee'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_lignes($id,$idrfe){
|
||||
|
||||
global $DB;
|
||||
|
||||
$res = array();
|
||||
//$query = "SELECT * FROM ligne_fiche_evaluation as b ,`resultat_ligne_fiche_evaluation` as a
|
||||
//WHERE a.id_ligne_fiche_evaluation = b.id_ligne_fiche_evaluation and `id_resultat_fiche_evaluation` = ".$idrfe." and b.id_parent = ".$id."";
|
||||
|
||||
$query = "SELECT a.id_ligne_fiche_evaluation,b.id_parent, b.question,b.reponses,a.reponse,a.observation,c.date,c.eval
|
||||
FROM resultat_ligne_fiche_evaluation as a
|
||||
LEFT JOIN ligne_fiche_evaluation as b ON b.id_ligne_fiche_evaluation = a.id_ligne_fiche_evaluation
|
||||
LEFT JOIN resultat_ligne_fiche_eval_annuel as c ON a.id_ligne_fiche_evaluation = c.id_ligne_fiche_evaluation and c.id_resultat_fiche_evaluation = ?
|
||||
WHERE a.id_resultat_fiche_evaluation = ? and b.id_parent = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("iii" , $idrfe, $idrfe, $id);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$res[] = $row;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getUserId($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname, registration_number as matricule,users_id_supervisor from glpi_users where id= ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function getRiasecTestResults($idUser,$year){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM resultat_eval_psychotechnique WHERE user_id = ? and YEAR(test_date) = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii" , $idUser,$year);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
222
model_controller/fiche.evaluation.php
Normal file
222
model_controller/fiche.evaluation.php
Normal file
@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function getIdResultatFicheEvaluationCount() {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from id_resultat_fiche_evaluation_count";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
return $row['value'];
|
||||
}
|
||||
}
|
||||
|
||||
function increaseIdResultatFicheEvaluationCount() {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "UPDATE `id_resultat_fiche_evaluation_count` SET `value`=value+1";
|
||||
$DB->query($query);
|
||||
}
|
||||
|
||||
|
||||
function insertResultatLigneFicheEvaluation($idLigneFicheEvaluation, $idResultatFicheEvaluation, $idCandidat, $reponse, $observation){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO resultat_ligne_fiche_evaluation (`id_ligne_fiche_evaluation`, `id_resultat_fiche_evaluation`, `id_candidat`, `reponse`, `observation`) VALUES ('".$idLigneFicheEvaluation."','".$idResultatFicheEvaluation."','".$idCandidat."','".$reponse."', '".$observation."')";
|
||||
//echo $query;
|
||||
$DB->query($query);
|
||||
|
||||
return $DB->insert_id();
|
||||
}
|
||||
|
||||
function insertResultatLigneFicheEvaluationAnnuel($idLigneFicheEvaluation, $idResultatFicheEvaluation, $date, $eval){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO resultat_ligne_fiche_eval_annuel (`id_ligne_fiche_evaluation`, `id_resultat_fiche_evaluation`, `date`, `eval`) VALUES ('".$idLigneFicheEvaluation."','".$idResultatFicheEvaluation."','".$date."', '".$eval."')";
|
||||
//echo $query;
|
||||
$DB->query($query);
|
||||
|
||||
return $DB->insert_id();
|
||||
}
|
||||
|
||||
function isResultatFicheExist($idFicheEvaluation, $dateannuel, $employeeId) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation rlfe LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation where lfe.ordre = 0 and lfe.id_parent = 0 and lfe.id_fiche_evaluation = ".$idFicheEvaluation."
|
||||
and id_candidat = ".$employeeId." and reponse = '".$dateannuel."'";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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 = ".$id_fiche_evaluation;
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getLignesFicheEvaluation($id_fiche_evaluation){
|
||||
|
||||
if(isInjection($id_fiche_evaluation)) {
|
||||
echo "Not Allowed";
|
||||
return null;
|
||||
}
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from ligne_fiche_evaluation WHERE id_fiche_evaluation = ".$id_fiche_evaluation." order by ordre";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function getSubUsersfe($idUser) {
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor ='".$idUser."' and is_active=1 order by fullname";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function getGroups() {
|
||||
|
||||
global $DB;
|
||||
$groups = array();
|
||||
|
||||
$query = "SELECT * FROM glpi_groups";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$groups[] = $row;
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
function getGroupUsers($groupId) {
|
||||
|
||||
global $DB;
|
||||
$groups = array();
|
||||
|
||||
$query = "SELECT users_id FROM glpi_groups_users where groups_id = ".$groupId;
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$groups[] = $row['users_id'];
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
function evaluationTrack($idResultatFeval, $user) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO `evaluation_tracking`(`id_resultat_feval`, `user`, `comment`) VALUES ('".$idResultatFeval."', '".$user."', 'evaluation')";
|
||||
//echo $query;
|
||||
$DB->query($query);
|
||||
}
|
||||
|
||||
function cache_all_clear($root){
|
||||
$files = glob($root."/*");
|
||||
foreach($files as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getPreviousObjectifs($id_user){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT
|
||||
id_candidat,reponse
|
||||
FROM
|
||||
`resultat_ligne_fiche_evaluation`
|
||||
LEFT JOIN ligne_fiche_evaluation ON ligne_fiche_evaluation.id_ligne_fiche_evaluation = resultat_ligne_fiche_evaluation.id_ligne_fiche_evaluation
|
||||
WHERE
|
||||
ligne_fiche_evaluation.id_ligne_fiche_evaluation >= 597 AND ligne_fiche_evaluation.id_ligne_fiche_evaluation <= 619 AND reponse != '' AND id_candidat = ? AND id_resultat_fiche_evaluation =(
|
||||
SELECT rrr.id_resultat_fiche_evaluation from resultat_ligne_fiche_evaluation rrr
|
||||
WHERE rrr.reponse = year(CURRENT_DATE())-2 and id_candidat = ?
|
||||
)
|
||||
ORDER BY
|
||||
id_resultat_fiche_evaluation ASC;";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $id_user,$id_user);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
342
model_controller/fiche.evaluation_backup.php
Normal file
342
model_controller/fiche.evaluation_backup.php
Normal file
@ -0,0 +1,342 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
error_reporting(0);
|
||||
|
||||
|
||||
function getIdResultatFicheEvaluationCount() {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from id_resultat_fiche_evaluation_count";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
return $row['value'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getFicheEvaluation($id_fiche_evaluation){
|
||||
|
||||
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 getResultatLignesFicheEvaluation($id_fiche_evaluation, $currentuserId){
|
||||
|
||||
global $DB;
|
||||
|
||||
$idResultatFicheEvaluationCount = getIdResultatFicheEvaluationCount();
|
||||
if($currentuserId != "")
|
||||
$users = getSubSubUsers($currentuserId);
|
||||
|
||||
$myarray = [];
|
||||
|
||||
$query = "SELECT
|
||||
resultat_ligne_fiche_evaluation.*,
|
||||
ligne_fiche_evaluation.*,
|
||||
glpi_users.registration_number as matricule,
|
||||
glpi_users.name as fullname,
|
||||
_fn.value AS fonction,
|
||||
_st.value AS structure,
|
||||
_sup.name as superiorname
|
||||
FROM
|
||||
`resultat_ligne_fiche_evaluation`
|
||||
JOIN glpi_users ON glpi_users.id = resultat_ligne_fiche_evaluation.id_candidat
|
||||
left join ligne_fiche_evaluation on ligne_fiche_evaluation.id_ligne_fiche_evaluation = resultat_ligne_fiche_evaluation.id_ligne_fiche_evaluation
|
||||
LEFT JOIN glpi_users _sup ON
|
||||
_sup.id = glpi_users.users_id_supervisor
|
||||
LEFT JOIN picklist _fn ON
|
||||
_fn.id = glpi_users.id_fonction
|
||||
LEFT JOIN picklist _st ON
|
||||
_st.id = glpi_users.id_structure
|
||||
WHERE
|
||||
resultat_ligne_fiche_evaluation.id_ligne_fiche_evaluation = 508 ";
|
||||
|
||||
// for($i =0; $i < $idResultatFicheEvaluationCount; $i++) {
|
||||
// $query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
// LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
// WHERE rlfe.id_resultat_fiche_evaluation = ? and lfe.id_fiche_evaluation=?";
|
||||
|
||||
if($currentuserId != "") {
|
||||
$query = $query." and (resultat_ligne_fiche_evaluation.id_candidat = ?";
|
||||
|
||||
foreach($users as $user) {
|
||||
$query = $query." or resultat_ligne_fiche_evaluation.id_candidat = ".$user['id'];
|
||||
}
|
||||
$query = $query.") ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i",$currentuserId);
|
||||
$stmt = $DB->prepare($query);
|
||||
} else {
|
||||
// $query = $query." group by rlfe.id_resultat_fiche_evaluation";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
// $stmt->bind_param("ii", $i,$id_fiche_evaluation);
|
||||
}
|
||||
//echo $query;
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$finalarray[] = $rows;
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
// $finalarray = [];
|
||||
// foreach($myarray as $anrow) {
|
||||
// $query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
// LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
// WHERE rlfe.id_resultat_fiche_evaluation = ?";
|
||||
// $stmt = $DB->prepare($query);
|
||||
|
||||
// $stmt->bind_param("i", $anrow[0]['id_resultat_fiche_evaluation']);
|
||||
|
||||
// $stmt->execute();
|
||||
// $result = $stmt->get_result();
|
||||
|
||||
// if ($result->num_rows > 0) {
|
||||
// $rows = array();
|
||||
// while($row = $result->fetch_assoc()) {
|
||||
// $rows[] = $row;
|
||||
// }
|
||||
// $finalarray[] = $rows;
|
||||
// }
|
||||
// }
|
||||
|
||||
return $finalarray;
|
||||
}
|
||||
|
||||
|
||||
function getUserId($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where id=? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function getFUser($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT u.`id`,registration_number as matricule , CONCAT(realname,' ', firstname) as fullname,(select CONCAT(realname,' ', firstname) FROM `glpi_users` WHERE id = (SELECT users_id_supervisor FROM `glpi_users` WHERE id = ?) ) as superiorname, pl.`value` as fonction, pls.`value` as structure FROM `glpi_users` u
|
||||
LEFT JOIN `picklist` pl on u.`id_fonction` = pl.`id`
|
||||
LEFT JOIN `picklist` pls on u.`id_structure` = pls.`id`
|
||||
where u.`id` = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $idUser, $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSubSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subSubUsers = array();
|
||||
|
||||
$users = getSubUsers($idUser);
|
||||
foreach($users as $user) {
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user['id']);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$subSubUsers = array_merge($subSubUsers,$rows);
|
||||
}
|
||||
}
|
||||
$all = array_merge($subSubUsers,$users);
|
||||
|
||||
return $all;
|
||||
}
|
||||
|
||||
|
||||
function getSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function deleteLignesFicheEvaluation($id_fiche_evaluation) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_evaluation WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_eval_annuel WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function cache_write($filename,$content){
|
||||
|
||||
return file_put_contents($filename,$content);
|
||||
|
||||
}
|
||||
|
||||
function cache_read($filename){
|
||||
|
||||
return file_get_contents($filename);
|
||||
|
||||
}
|
||||
|
||||
function getHeaders(){
|
||||
global $DB;
|
||||
|
||||
|
||||
$query = "SELECT * from ligne_fiche_evaluation where id_fiche_evaluation = 24 and id_parent = 0 and ordre != 0";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = array();
|
||||
|
||||
while ($data = $result->fetch_assoc()) {
|
||||
$row[] = $data;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getEvalScore($id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT eval FROM `resultat_ligne_fiche_eval_annuel` WHERE id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii" , $id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function insertScore($user_id, $id_rfe, $score,$year){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO resultat_eval_scores (`user_id`, `type_id`, `id_rfe`, `score`) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE `score` = ?;";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("isiss" , $user_id,$year,$id_rfe,$score,$score);
|
||||
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
function getScore($user_id){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT score FROM `resultat_eval_scores` WHERE user_id = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user_id);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
267
model_controller/fiche.resultat.evaluation.edit.php
Normal file
267
model_controller/fiche.resultat.evaluation.edit.php
Normal file
@ -0,0 +1,267 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function getFicheEvaluationEdit($id_fiche_evaluation){
|
||||
|
||||
if(isInjection($id_fiche_evaluation)) {
|
||||
echo "Not Allowed";
|
||||
return array();
|
||||
}
|
||||
|
||||
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 array();
|
||||
}
|
||||
|
||||
function getResultatLignesFicheEvaluation($id_resultat_fiche_evaluation){
|
||||
|
||||
if(isInjection($id_resultat_fiche_evaluation)) {
|
||||
echo "Not Allowed";
|
||||
return array();
|
||||
}
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
WHERE rlfe.id_resultat_fiche_evaluation = ? group by lfe.id_fiche_evaluation";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $id_resultat_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
$annuel = getFicheEvaluationEdit($rows[0]['id_fiche_evaluation']);
|
||||
|
||||
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
WHERE rlfe.id_resultat_fiche_evaluation = ? order by lfe.ordre";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $id_resultat_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
|
||||
$rowssb = array();
|
||||
if($annuel) {
|
||||
$query = "SELECT date, eval FROM resultat_ligne_fiche_eval_annuel where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $row['id_resultat_fiche_evaluation'],$row['id_ligne_fiche_evaluation']);
|
||||
|
||||
$stmt->execute();
|
||||
$resultsb = $stmt->get_result();
|
||||
while($rowsb = $resultsb->fetch_assoc()) {
|
||||
$rowssb[] = $rowsb;
|
||||
}
|
||||
}
|
||||
if(!empty($rowssb))
|
||||
$rows[] = $row+$rowssb[0];
|
||||
else
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
//print_r($rows);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function getUserId($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname, registration_number as matricule from glpi_users where id=? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function isUserSupervisor($userId, $currentUserId) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname, users_id_supervisor from glpi_users where id=? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $userId);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
if($row['users_id_supervisor'] == $currentUserId)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function updateResultatLigneFicheEvaluationNoRepons($idResultatLigneFicheEvaluation, $observation) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "UPDATE resultat_ligne_fiche_evaluation SET observation = ? where id_resultat_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("si",$observation,$idResultatLigneFicheEvaluation);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function updateResultatLigneFicheEvaluation($idResultatLigneFicheEvaluation, $reponse, $observation) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "UPDATE resultat_ligne_fiche_evaluation SET reponse = ? , observation = ? where id_resultat_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ssi",$reponse,$observation,$idResultatLigneFicheEvaluation);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function updateResultatLigneFicheEvalAnnueld($idResultatLigneFicheEvaluation, $date) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation where id_resultat_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $idResultatLigneFicheEvaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$id1 = $rows[0]['id_resultat_fiche_evaluation'];
|
||||
$id2 = $rows[0]['id_ligne_fiche_evaluation'];
|
||||
|
||||
|
||||
if(evalAnnExists($id1,$id2)){
|
||||
$query = "UPDATE resultat_ligne_fiche_eval_annuel SET date = ? where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
$stmt->bind_param("sii",$date,$id1,$id2);
|
||||
}else{
|
||||
$query = "INSERT INTO resultat_ligne_fiche_eval_annuel (`id_ligne_fiche_evaluation`, `id_resultat_fiche_evaluation`, `date`, `eval`) VALUES (?,?,?, '0')";
|
||||
$stmt = $DB->prepare($query);
|
||||
$stmt->bind_param("iis", $id2,$id1,$date);
|
||||
}
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
|
||||
function evalAnnExists($id1,$id2){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from resultat_ligne_fiche_eval_annuel where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $id1,$id2);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows > 0) {
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function updateResultatLigneFicheEvalAnnuel($idResultatLigneFicheEvaluation, $eval) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation where id_resultat_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $idResultatLigneFicheEvaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$id1 = $rows[0]['id_resultat_fiche_evaluation'];
|
||||
$id2 = $rows[0]['id_ligne_fiche_evaluation'];
|
||||
$query = "UPDATE resultat_ligne_fiche_eval_annuel SET eval = ? where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("sii", $eval,$id1,$id2);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
|
||||
function evalTrack($idResultatFeval, $user) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO `evaluation_tracking`(`id_resultat_feval`, `user`, `comment`) VALUES (?, ?, 'suivi')";
|
||||
//echo $query;
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $idResultatFeval,$user);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
25
model_controller/fiche.resultat.evaluation.list.php
Normal file
25
model_controller/fiche.resultat.evaluation.list.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function getFicheEvaluations($flag){
|
||||
|
||||
global $DB;
|
||||
|
||||
if($flag == 'All')
|
||||
$query = "SELECT * from fiche_evaluation WHERE actif = 1";
|
||||
else
|
||||
$query = "SELECT * from fiche_evaluation WHERE actif = 1 and annuel = 1";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
319
model_controller/fiche.resultat.evaluation.php
Normal file
319
model_controller/fiche.resultat.evaluation.php
Normal file
@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function getIdResultatFicheEvaluationCount() {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from id_resultat_fiche_evaluation_count";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
return $row['value'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getFicheEvaluation($id_fiche_evaluation){
|
||||
|
||||
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 getResultatLignesFicheEvaluation($id_fiche_evaluation, $currentuserId){
|
||||
|
||||
global $DB;
|
||||
|
||||
$idResultatFicheEvaluationCount = getIdResultatFicheEvaluationCount();
|
||||
if($currentuserId != "")
|
||||
$users = getSubSubUsers($currentuserId);
|
||||
|
||||
$myarray = [];
|
||||
|
||||
for($i =0; $i < $idResultatFicheEvaluationCount; $i++) {
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
WHERE rlfe.id_resultat_fiche_evaluation = ? and lfe.id_fiche_evaluation=?";
|
||||
|
||||
if($currentuserId != "") {
|
||||
$query = $query." and (id_candidat = ?";
|
||||
|
||||
foreach($users as $user) {
|
||||
$query = $query." or id_candidat = ".$user['id'];
|
||||
}
|
||||
$query = $query.") order by lfe.ordre";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("iii", $i,$id_fiche_evaluation,$currentuserId);
|
||||
} else {
|
||||
$query = $query." group by rlfe.id_resultat_fiche_evaluation";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $i,$id_fiche_evaluation);
|
||||
}
|
||||
//echo $query;
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$myarray[] = $rows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$finalarray = [];
|
||||
foreach($myarray as $anrow) {
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
WHERE rlfe.id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $anrow[0]['id_resultat_fiche_evaluation']);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$finalarray[] = $rows;
|
||||
}
|
||||
}
|
||||
|
||||
return $finalarray;
|
||||
}
|
||||
|
||||
|
||||
function getUserId($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where id=? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function getFUser($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT u.`id`,registration_number as matricule , CONCAT(realname,' ', firstname) as fullname,(select CONCAT(realname,' ', firstname) FROM `glpi_users` WHERE id = (SELECT users_id_supervisor FROM `glpi_users` WHERE id = ?) ) as superiorname, pl.`value` as fonction, pls.`value` as structure FROM `glpi_users` u
|
||||
LEFT JOIN `picklist` pl on u.`id_fonction` = pl.`id`
|
||||
LEFT JOIN `picklist` pls on u.`id_structure` = pls.`id`
|
||||
where u.`id` = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $idUser, $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSubSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subSubUsers = array();
|
||||
|
||||
$users = getSubUsers($idUser);
|
||||
foreach($users as $user) {
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user['id']);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$subSubUsers = array_merge($subSubUsers,$rows);
|
||||
}
|
||||
}
|
||||
$all = array_merge($subSubUsers,$users);
|
||||
|
||||
return $all;
|
||||
}
|
||||
|
||||
|
||||
function getSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function deleteLignesFicheEvaluation($id_fiche_evaluation) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_evaluation WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_eval_annuel WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function cache_write($filename,$content){
|
||||
|
||||
return file_put_contents($filename,$content);
|
||||
|
||||
}
|
||||
|
||||
function cache_read($filename){
|
||||
|
||||
return file_get_contents($filename);
|
||||
|
||||
}
|
||||
|
||||
function getHeaders(){
|
||||
global $DB;
|
||||
|
||||
|
||||
$query = "SELECT * from ligne_fiche_evaluation where id_fiche_evaluation = 24 and id_parent = 0 and ordre != 0";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = array();
|
||||
|
||||
while ($data = $result->fetch_assoc()) {
|
||||
$row[] = $data;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getEvalScore($id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT eval FROM `resultat_ligne_fiche_eval_annuel` WHERE id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii" , $id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function insertScore($user_id, $id_rfe, $score,$year){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO resultat_eval_scores (`user_id`, `type_id`, `id_rfe`, `score`) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE `score` = ?;";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("isiss" , $user_id,$year,$id_rfe,$score,$score);
|
||||
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
function getScore($user_id){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT score FROM `resultat_eval_scores` WHERE user_id = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user_id);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
319
model_controller/fiche.resultat.evaluation222222.php
Normal file
319
model_controller/fiche.resultat.evaluation222222.php
Normal file
@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function getIdResultatFicheEvaluationCount() {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from id_resultat_fiche_evaluation_count";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
return $row['value'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getFicheEvaluation($id_fiche_evaluation){
|
||||
|
||||
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 getResultatLignesFicheEvaluation($id_fiche_evaluation, $currentuserId){
|
||||
|
||||
global $DB;
|
||||
|
||||
$idResultatFicheEvaluationCount = getIdResultatFicheEvaluationCount();
|
||||
if($currentuserId != "")
|
||||
$users = getSubSubUsers($currentuserId);
|
||||
|
||||
$myarray = [];
|
||||
|
||||
for($i =0; $i < $idResultatFicheEvaluationCount; $i++) {
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
WHERE rlfe.id_resultat_fiche_evaluation = ? and lfe.id_fiche_evaluation=?";
|
||||
|
||||
if($currentuserId != "") {
|
||||
$query = $query." and (id_candidat = ?";
|
||||
|
||||
foreach($users as $user) {
|
||||
$query = $query." or id_candidat = ".$user['id'];
|
||||
}
|
||||
$query = $query.") order by lfe.ordre";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("iii", $i,$id_fiche_evaluation,$currentuserId);
|
||||
} else {
|
||||
$query = $query." group by rlfe.id_resultat_fiche_evaluation";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $i,$id_fiche_evaluation);
|
||||
}
|
||||
//echo $query;
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$myarray[] = $rows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$finalarray = [];
|
||||
foreach($myarray as $anrow) {
|
||||
$query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
WHERE rlfe.id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $anrow[0]['id_resultat_fiche_evaluation']);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$finalarray[] = $rows;
|
||||
}
|
||||
}
|
||||
|
||||
return $finalarray;
|
||||
}
|
||||
|
||||
|
||||
function getUserId($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where id=? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function getFUser($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT u.`id`,registration_number as matricule , CONCAT(realname,' ', firstname) as fullname,(select CONCAT(realname,' ', firstname) FROM `glpi_users` WHERE id = (SELECT users_id_supervisor FROM `glpi_users` WHERE id = ?) ) as superiorname, pl.`value` as fonction, pls.`value` as structure FROM `glpi_users` u
|
||||
LEFT JOIN `picklist` pl on u.`id_fonction` = pl.`id`
|
||||
LEFT JOIN `picklist` pls on u.`id_structure` = pls.`id`
|
||||
where u.`id` = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $idUser, $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSubSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subSubUsers = array();
|
||||
|
||||
$users = getSubUsers($idUser);
|
||||
foreach($users as $user) {
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user['id']);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$subSubUsers = array_merge($subSubUsers,$rows);
|
||||
}
|
||||
}
|
||||
$all = array_merge($subSubUsers,$users);
|
||||
|
||||
return $all;
|
||||
}
|
||||
|
||||
|
||||
function getSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function deleteLignesFicheEvaluation($id_fiche_evaluation) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_evaluation WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_eval_annuel WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function cache_write($filename,$content){
|
||||
|
||||
return file_put_contents($filename,$content);
|
||||
|
||||
}
|
||||
|
||||
function cache_read($filename){
|
||||
|
||||
return file_get_contents($filename);
|
||||
|
||||
}
|
||||
|
||||
function getHeaders(){
|
||||
global $DB;
|
||||
|
||||
|
||||
$query = "SELECT * from ligne_fiche_evaluation where id_fiche_evaluation = 24 and id_parent = 0 and ordre != 0";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = array();
|
||||
|
||||
while ($data = $result->fetch_assoc()) {
|
||||
$row[] = $data;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getEvalScore($id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT eval FROM `resultat_ligne_fiche_eval_annuel` WHERE id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii" , $id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function insertScore($user_id, $id_rfe, $score,$year){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO resultat_eval_scores (`user_id`, `type_id`, `id_rfe`, `score`) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE `score` = ?;";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("isiss" , $user_id,$year,$id_rfe,$score,$score);
|
||||
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
function getScore($user_id){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT score FROM `resultat_eval_scores` WHERE user_id = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user_id);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
335
model_controller/fiche.resultat.evaluation_backup.php
Normal file
335
model_controller/fiche.resultat.evaluation_backup.php
Normal file
@ -0,0 +1,335 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
error_reporting(0);
|
||||
|
||||
|
||||
function getIdResultatFicheEvaluationCount() {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * from id_resultat_fiche_evaluation_count";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
return $row['value'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getFicheEvaluation($id_fiche_evaluation){
|
||||
|
||||
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 getResultatLignesFicheEvaluation($id_fiche_evaluation, $currentuserId){
|
||||
|
||||
global $DB;
|
||||
|
||||
$idResultatFicheEvaluationCount = getIdResultatFicheEvaluationCount();
|
||||
if($currentuserId != "")
|
||||
$users = getSubSubUsers($currentuserId);
|
||||
|
||||
$myarray = [];
|
||||
|
||||
$query = "SELECT
|
||||
resultat_ligne_fiche_evaluation.*,
|
||||
glpi_users.name,
|
||||
_fn.value as fonction,
|
||||
_st.value as structure,
|
||||
_sup.name
|
||||
FROM
|
||||
`resultat_ligne_fiche_evaluation`
|
||||
JOIN glpi_users ON glpi_users.id = resultat_ligne_fiche_evaluation.id_candidat
|
||||
left join glpi_users _sup on _sup.id = glpi_users.users_id_supervisor
|
||||
left join picklist _fn on _fn.id = glpi_users.id_fonction
|
||||
left join picklist _st on _st.id = glpi_users.id_structure
|
||||
WHERE
|
||||
id_ligne_fiche_evaluation = 508 ";
|
||||
|
||||
// for($i =0; $i < $idResultatFicheEvaluationCount; $i++) {
|
||||
// $query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
// LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
// WHERE rlfe.id_resultat_fiche_evaluation = ? and lfe.id_fiche_evaluation=?";
|
||||
|
||||
if($currentuserId != "") {
|
||||
$query = $query." and (id_candidat = ?";
|
||||
|
||||
foreach($users as $user) {
|
||||
$query = $query." or id_candidat = ".$user['id'];
|
||||
}
|
||||
$query = $query.") ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i",$currentuserId);
|
||||
} else {
|
||||
// $query = $query." group by rlfe.id_resultat_fiche_evaluation";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i",$id_fiche_evaluation);
|
||||
}
|
||||
// //echo $query;
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$finalarray[] = $rows;
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
// $finalarray = [];
|
||||
// foreach($myarray as $anrow) {
|
||||
// $query = "SELECT * from resultat_ligne_fiche_evaluation rlfe
|
||||
// LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation
|
||||
// WHERE rlfe.id_resultat_fiche_evaluation = ?";
|
||||
// $stmt = $DB->prepare($query);
|
||||
|
||||
// $stmt->bind_param("i", $anrow[0]['id_resultat_fiche_evaluation']);
|
||||
|
||||
// $stmt->execute();
|
||||
// $result = $stmt->get_result();
|
||||
|
||||
// if ($result->num_rows > 0) {
|
||||
// $rows = array();
|
||||
// while($row = $result->fetch_assoc()) {
|
||||
// $rows[] = $row;
|
||||
// }
|
||||
// $finalarray[] = $rows;
|
||||
// }
|
||||
// }
|
||||
|
||||
return $finalarray;
|
||||
}
|
||||
|
||||
|
||||
function getUserId($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where id=? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i", $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function getFUser($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT u.`id`,registration_number as matricule , CONCAT(realname,' ', firstname) as fullname,(select CONCAT(realname,' ', firstname) FROM `glpi_users` WHERE id = (SELECT users_id_supervisor FROM `glpi_users` WHERE id = ?) ) as superiorname, pl.`value` as fonction, pls.`value` as structure FROM `glpi_users` u
|
||||
LEFT JOIN `picklist` pl on u.`id_fonction` = pl.`id`
|
||||
LEFT JOIN `picklist` pls on u.`id_structure` = pls.`id`
|
||||
where u.`id` = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii", $idUser, $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers[0];
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSubSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subSubUsers = array();
|
||||
|
||||
$users = getSubUsers($idUser);
|
||||
foreach($users as $user) {
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user['id']);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$subSubUsers = array_merge($subSubUsers,$rows);
|
||||
}
|
||||
}
|
||||
$all = array_merge($subSubUsers,$users);
|
||||
|
||||
return $all;
|
||||
}
|
||||
|
||||
|
||||
function getSubUsers($idUser){
|
||||
|
||||
global $DB;
|
||||
$subUsers = array();
|
||||
|
||||
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where users_id_supervisor = ? ";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $idUser);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$subUsers[] = $row;
|
||||
}
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
return $subUsers;
|
||||
}
|
||||
|
||||
function deleteLignesFicheEvaluation($id_fiche_evaluation) {
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_evaluation WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$query = "DELETE FROM resultat_ligne_fiche_eval_annuel WHERE id_resultat_fiche_evaluation = ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $id_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function cache_write($filename,$content){
|
||||
|
||||
return file_put_contents($filename,$content);
|
||||
|
||||
}
|
||||
|
||||
function cache_read($filename){
|
||||
|
||||
return file_get_contents($filename);
|
||||
|
||||
}
|
||||
|
||||
function getHeaders(){
|
||||
global $DB;
|
||||
|
||||
|
||||
$query = "SELECT * from ligne_fiche_evaluation where id_fiche_evaluation = 24 and id_parent = 0 and ordre != 0";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = array();
|
||||
|
||||
while ($data = $result->fetch_assoc()) {
|
||||
$row[] = $data;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getEvalScore($id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT eval FROM `resultat_ligne_fiche_eval_annuel` WHERE id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("ii" , $id_resultat_fiche_evaluation,$id_ligne_fiche_evaluation);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function insertScore($user_id, $id_rfe, $score,$year){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "INSERT INTO resultat_eval_scores (`user_id`, `type_id`, `id_rfe`, `score`) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE `score` = ?;";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("isiss" , $user_id,$year,$id_rfe,$score,$score);
|
||||
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
function getScore($user_id){
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT score FROM `resultat_eval_scores` WHERE user_id = ?";
|
||||
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("i" , $user_id);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
246
model_controller/ordinateur.list.php
Normal file
246
model_controller/ordinateur.list.php
Normal file
@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
include ('../inc/utils.class.php');
|
||||
|
||||
|
||||
function getOrdinaturs($unity){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT c.name,c.serial FROM `glpi_computers` c
|
||||
JOIN glpi_locations l ON c.locations_id = l.id
|
||||
WHERE c.serial != '' and c.locations_id in
|
||||
(SELECT id FROM `glpi_locations` WHERE completename like '%".$unity."%')";
|
||||
|
||||
if($unity == 'ALL')
|
||||
$query = "SELECT name,serial FROM `glpi_computers`
|
||||
WHERE serial != ''";
|
||||
|
||||
$result = $DB->query($query);
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$rows = array();
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_inventory_Phone($phone_id){
|
||||
|
||||
global $DB;
|
||||
$res = array();
|
||||
$sql =" SELECT DISTINCT `glpi_phones`.id AS Phone_id,glpi_phonemodels.name AS modele , glpi_phonetypes.name AS types ,glpi_phonepowersupplies.name AS alimentation,
|
||||
glpi_phones.`number_line`,glpi_phones.users_id ,glpi_users.name AS user_name,glpi_phones.comment,glpi_phones.brand AS marque,
|
||||
glpi_phones.serial AS num_serie
|
||||
FROM `glpi_phones`
|
||||
LEFT JOIN `glpi_phonemodels` ON (glpi_phones.phonemodels_id = glpi_phonemodels.id )
|
||||
LEFT JOIN `glpi_phonetypes` ON (glpi_phones.phonetypes_id = glpi_phonetypes.id )
|
||||
LEFT JOIN glpi_users ON (glpi_phones.users_id = glpi_users.id )
|
||||
LEFT JOIN `glpi_phonepowersupplies` ON (glpi_phones.phonepowersupplies_id = glpi_phonepowersupplies.id )
|
||||
WHERE glpi_phones.is_deleted = 0 AND glpi_phones.is_template = 0 ";
|
||||
if ($phone_id == 'ALL'){
|
||||
$stmt = $DB->prepare($sql);
|
||||
}else{
|
||||
$sql = $sql."and glpi_phones.id = ?";
|
||||
$stmt = $DB->prepare($sql);
|
||||
$stmt->bind_param("i",$phone_id);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$res[] = $row;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function get_inventory_Monitor($monitor_id){
|
||||
|
||||
global $DB;
|
||||
$res = array();
|
||||
$sql =" SELECT glpi_monitors.id AS Monitor_id, glpi_manufacturers.name AS fabricant, glpi_monitors.serial AS serial ,
|
||||
`glpi_monitormodels`.`name` AS modele FROM `glpi_monitors`
|
||||
JOIN `glpi_manufacturers` ON `glpi_monitors`.`manufacturers_id` = `glpi_manufacturers`.`id`
|
||||
LEFT JOIN `glpi_monitormodels` ON `glpi_monitors`.`monitormodels_id` = `glpi_monitormodels`.`id`
|
||||
WHERE is_deleted = 0 AND is_template = 0 ";
|
||||
if ($monitor_id == 'ALL'){
|
||||
$stmt = $DB->prepare($sql);
|
||||
}else{
|
||||
$sql = $sql."and glpi_monitors.id = ?";
|
||||
$stmt = $DB->prepare($sql);
|
||||
$stmt->bind_param("i",$monitor_id);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$res[] = $row;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function get_inventory_NetworkEqui($monitor_id){
|
||||
|
||||
global $DB;
|
||||
$res = array();
|
||||
$sql =" SELECT glpi_networkequipments.id AS NwEquip_id, glpi_manufacturers.name AS fabricant, glpi_networkequipments.serial AS serial ,
|
||||
`glpi_networkequipmentmodels`.name AS modele FROM `glpi_networkequipments`
|
||||
JOIN `glpi_manufacturers` ON `glpi_networkequipments`.`manufacturers_id` = `glpi_manufacturers`.`id`
|
||||
LEFT JOIN `glpi_networkequipmentmodels` ON `glpi_networkequipments`.`networkequipmentmodels_id` = `glpi_networkequipmentmodels`.`id`
|
||||
WHERE is_deleted = 0 AND is_template = 0 ";
|
||||
if ($monitor_id == 'ALL'){
|
||||
$stmt = $DB->prepare($sql);
|
||||
}else{
|
||||
$sql = $sql."and glpi_networkequipments.id = ?";
|
||||
$stmt = $DB->prepare($sql);
|
||||
$stmt->bind_param("i",$monitor_id);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$res[] = $row;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function get_inventory_Printer($monitor_id){
|
||||
|
||||
global $DB;
|
||||
$res = array();
|
||||
$sql =" SELECT glpi_printers.id AS Printer_id, glpi_manufacturers.name AS fabricant, glpi_printers.serial AS serial ,
|
||||
`glpi_printermodels`.name AS modele FROM `glpi_printers`
|
||||
JOIN `glpi_manufacturers` ON `glpi_printers`.`manufacturers_id` = `glpi_manufacturers`.`id`
|
||||
LEFT JOIN `glpi_printermodels` ON `glpi_printers`.`printermodels_id` = `glpi_printermodels`.`id`
|
||||
WHERE is_deleted = 0 AND is_template = 0 ";
|
||||
if ($monitor_id == 'ALL'){
|
||||
$stmt = $DB->prepare($sql);
|
||||
}else{
|
||||
$sql = $sql."and glpi_printers.id = ?";
|
||||
$stmt = $DB->prepare($sql);
|
||||
$stmt->bind_param("i",$monitor_id);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$res[] = $row;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function get_inventory_Rack($monitor_id){
|
||||
|
||||
global $DB;
|
||||
$res = array();
|
||||
$sql =" SELECT glpi_racks.id AS Rack_id,glpi_racks.name AS Rack_name, glpi_manufacturers.name AS fabricant, glpi_racks.serial AS serial ,
|
||||
`glpi_rackmodels`.name AS modele FROM `glpi_racks`
|
||||
LEFT JOIN `glpi_manufacturers` ON `glpi_racks`.`manufacturers_id` = `glpi_manufacturers`.`id`
|
||||
LEFT JOIN `glpi_rackmodels` ON `glpi_racks`.`rackmodels_id` = `glpi_rackmodels`.`id`
|
||||
WHERE is_deleted = 0 AND is_template = 0 ";
|
||||
if ($monitor_id == 'ALL'){
|
||||
$stmt = $DB->prepare($sql);
|
||||
}else{
|
||||
$sql = $sql."and glpi_racks.id = ?";
|
||||
$stmt = $DB->prepare($sql);
|
||||
$stmt->bind_param("i",$monitor_id);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$res[] = $row;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function get_inventory_Ordinateur($computer_id){
|
||||
|
||||
global $DB;
|
||||
$res = array();
|
||||
$sql = "SELECT DISTINCT
|
||||
glpi_computers.id AS Computer_id, glpi_manufacturers.name AS fabricant, glpi_computers.serial AS serial,
|
||||
glpi_computertypes.name AS types, glpi_computermodels.name AS modele, glpi_users.id AS user_id,
|
||||
glpi_users.name AS user_name, glpi_computers.uuid , glpi_computers.comment AS comment , glpi_computers.serial as num_serie
|
||||
FROM glpi_computers
|
||||
LEFT JOIN glpi_states ON (glpi_computers.states_id = glpi_states.id )
|
||||
LEFT JOIN glpi_manufacturers ON (glpi_computers.manufacturers_id = glpi_manufacturers.id )
|
||||
LEFT JOIN glpi_computertypes ON (glpi_computers.computertypes_id = glpi_computertypes.id )
|
||||
LEFT JOIN glpi_computermodels ON (glpi_computers.computermodels_id = glpi_computermodels.id )
|
||||
LEFT JOIN glpi_items_operatingsystems ON (glpi_computers.id = glpi_items_operatingsystems.items_id AND glpi_items_operatingsystems.itemtype = 'Computer' )
|
||||
LEFT JOIN glpi_operatingsystems AS glpi_operatingsystems_8 ON (glpi_items_operatingsystems.operatingsystems_id = glpi_operatingsystems_8.id )
|
||||
LEFT JOIN glpi_locations ON (glpi_computers.locations_id = glpi_locations.id )
|
||||
LEFT JOIN glpi_users ON (glpi_computers.users_id = glpi_users.id )
|
||||
LEFT JOIN glpi_items_deviceprocessors ON (glpi_computers.id = glpi_items_deviceprocessors.items_id AND glpi_items_deviceprocessors.itemtype = 'Computer' )
|
||||
LEFT JOIN glpi_deviceprocessors AS glpi_deviceprocessors_7 ON (glpi_items_deviceprocessors.deviceprocessors_id = glpi_deviceprocessors_7.id )
|
||||
WHERE glpi_computers.is_deleted = 0 AND glpi_computers.is_template = 0 ";
|
||||
if ($computer_id == 'ALL'){
|
||||
$sql = $sql."GROUP BY glpi_computers.id";
|
||||
$stmt = $DB->prepare($sql);
|
||||
}else{
|
||||
$sql = $sql."and glpi_computers.id = ?
|
||||
GROUP BY glpi_computers.id";
|
||||
$stmt = $DB->prepare($sql);
|
||||
$stmt->bind_param("i",$computer_id);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
|
||||
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$res[] = $row;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
17
model_controller/save.article.pic.php
Normal file
17
model_controller/save.article.pic.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
|
||||
function updateProductPic($imglink,$codeart){
|
||||
|
||||
global $DB;
|
||||
|
||||
$query = "UPDATE `Produit` SET `imgpath`= ? where `ART_CODE`= ?";
|
||||
$stmt = $DB->prepare($query);
|
||||
|
||||
$stmt->bind_param("si" , $imglink,$codeart);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user