170 lines
5.7 KiB
PHP
170 lines
5.7 KiB
PHP
<?php
|
|
|
|
|
|
|
|
require_once 'include/utils/utils.php';
|
|
|
|
require_once 'includes/Loader.php';
|
|
|
|
require_once 'QCMGenerationFunction.php';
|
|
|
|
vimport ('includes.runtime.EntryPoint');
|
|
|
|
require_once 'SUtiles.php';
|
|
|
|
@session_start();
|
|
|
|
|
|
|
|
|
|
|
|
global $adb;
|
|
|
|
|
|
|
|
|
|
|
|
$current_user = Users_Record_Model::getCurrentUserModel();
|
|
|
|
$roleid = $current_user->get('roleid');
|
|
|
|
$userId = $current_user->get('id');
|
|
|
|
|
|
|
|
|
|
|
|
$IDProduits = array();
|
|
|
|
if($_GET["produit1_id"] != ""){
|
|
|
|
array_push( $IDProduits,$_GET["produit1_id"]);
|
|
|
|
}
|
|
|
|
if ($_GET["produit2_id"] != ""){
|
|
|
|
array_push( $IDProduits , $_GET["produit2_id"]);
|
|
|
|
}
|
|
|
|
if ($_GET["produit3_id"] != ""){
|
|
|
|
array_push( $IDProduits,$_GET["produit3_id"]);
|
|
|
|
}
|
|
|
|
if ($_GET["produit4_id"] != ""){
|
|
|
|
array_push( $IDProduits,$_GET["produit4_id"]);
|
|
|
|
}
|
|
|
|
if ($_GET["produit5_id"] != ""){
|
|
|
|
array_push( $IDProduits,$_GET["produit5_id"]);
|
|
|
|
}
|
|
|
|
$origin = "";
|
|
|
|
if ($_GET["origin_id"] != ""){
|
|
|
|
$origin = $_GET["origin_id"];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//il a déjà passé cet questionnaire
|
|
|
|
function isFinished($id_formulaire , $id_account){
|
|
|
|
global $adb;
|
|
|
|
|
|
|
|
$query6= "SELECT * FROM `result_lignes_formulaire` , `formulaire` where formulaire.id_formulaire = '".$id_formulaire."' and result_lignes_formulaire.accountId = '".$id_account."' and formulaire.id_formulaire = result_lignes_formulaire.id_formulaire ";
|
|
|
|
$result6 =$adb->query($query6);
|
|
|
|
if($adb->num_rows($result6) > 0){
|
|
|
|
$res = true;
|
|
|
|
}else{
|
|
|
|
$res = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isFinishedV2($id_formulaire , $id_account, $origin){
|
|
|
|
global $adb;
|
|
|
|
|
|
|
|
$query6= "SELECT * FROM `result_lignes_formulaire` , `formulaire` where formulaire.id_formulaire = '".$id_formulaire."' and result_lignes_formulaire.accountId = '".$id_account."' and result_lignes_formulaire.origin = '".$origin."' and formulaire.id_formulaire = result_lignes_formulaire.id_formulaire ";
|
|
|
|
$result6 =$adb->query($query6);
|
|
|
|
$res = false;
|
|
|
|
if($adb->num_rows($result6) > 0 && $origin != "")
|
|
|
|
$res = true;
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSpecialite ($id_account){
|
|
|
|
global $adb;
|
|
|
|
|
|
|
|
$query4 = "SELECT account_type FROM `vtiger_account` where accountid='".$id_account."' ";
|
|
|
|
$result4 =$adb->query($query4);
|
|
|
|
$Specialite=array();
|
|
|
|
while ($recordinfo = $adb->fetch_array($result4)) {
|
|
|
|
$Specialite[] = $recordinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return html_entity_decode($Specialite[0]['account_type']);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//WHERE PRODUCT IS SET
|
|
|
|
function getAlLFormulaires($IDProduits , $specialite , $today , $roleid){
|
|
|
|
global $adb;
|
|
|
|
$Formulaires = array();
|
|
|
|
|
|
|
|
if(!empty($IDProduits)){
|
|
|
|
$table = implode(',', $IDProduits);
|
|
|
|
|
|
|
|
$query7= "SELECT * FROM formulaire where id_produit in (".$table.") and specialite ='".$specialite."' and date_debut <= '".$today."' and date_fin >= '".$today."' and `visible_pour` like '%::{$roleid}::%' ";
|
|
|
|
$result7 =$adb->query($query7);
|
|
|
|
|
|
|
|
while ($recordinfo = $adb->fetch_array($result7)) {
|
|
|
|
$Formulaires[] = $recordinfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $Formulaires;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//WHERE PRODUCT IS 0
|
|
|
|
function getAllFormulaireV2($specialite , $today , $roleid){
|
|
|
|
global $adb;
|
|
|
|
|
|
|
|
$query7= "SELECT * FROM formulaire where id_produit = 0 and specialite ='".$specialite."' and date_debut <= '".$today."' and date_fin >= '".$today."' and `visible_pour` like '%::{$roleid}::%' ";
|
|
|
|
$result7 =$adb->query($query7);
|
|
|
|
$Formulaires=array();
|
|
|
|
while ($recordinfo = $adb->fetch_array($result7)) {
|
|
|
|
$Formulaires[] = $recordinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $Formulaires;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$today = date("Y-m-d", strtotime('today'));
|
|
|
|
$ids_formulaires = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//WHERE PRODUCT IS SET
|
|
|
|
|
|
|
|
$Formulaires1 = getAlLFormulaires($IDProduits , getSpecialite ($_GET['accountID']) , $today , $roleid);
|
|
|
|
if( sizeof($Formulaires1) > 0 ){
|
|
|
|
for ($c = 0; $c < sizeof($Formulaires1); $c++) {
|
|
|
|
if(isFinished( $Formulaires1[$c]['id_formulaire'] , $_GET['accountID']) == false){
|
|
|
|
array_push($ids_formulaires , $Formulaires1[$c]['id_formulaire']) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//WHERE PRODUCT IS NULL
|
|
|
|
$Formulaires = getAllFormulaireV2(getSpecialite($_GET['accountID']) , $today , $roleid);
|
|
|
|
|
|
|
|
for ($y = 0; $y < sizeof($Formulaires); $y++) {
|
|
|
|
if(isFinished( $Formulaires[$y]['id_formulaire'] , $_GET['accountID']) == false){
|
|
|
|
array_push($ids_formulaires , $Formulaires[$y]['id_formulaire']) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Get Report For Supervisors (Mohammed Bechlaghem)
|
|
|
|
$Formulaires2 = getAlLFormulaires($IDProduits , "Toutes les specialites" , $today , $roleid);
|
|
|
|
$Formulaires3 = getAllFormulaireV2("Toutes les specialites" , $today , $roleid);
|
|
|
|
if( sizeof($Formulaires2) > 0 ){
|
|
|
|
for ($c = 0; $c < sizeof($Formulaires2); $c++) {
|
|
|
|
if(isFinishedV2( $Formulaires2[$c]['id_formulaire'] , $_GET['accountID'],$origin) == false){
|
|
|
|
array_push($ids_formulaires , $Formulaires2[$c]['id_formulaire']) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ($y = 0; $y < sizeof($Formulaires3); $y++) {
|
|
|
|
if(isFinishedV2( $Formulaires3[$y]['id_formulaire'] , $_GET['accountID'],$origin) == false){
|
|
|
|
array_push($ids_formulaires , $Formulaires3[$y]['id_formulaire']) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
header('Content-type: application/json');
|
|
|
|
echo json_encode( $ids_formulaires );
|
|
|
|
//print_r($ids_formulaires);
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|