375 lines
11 KiB
PHP
375 lines
11 KiB
PHP
<?php
|
|
|
|
|
|
use Glpi\Event;
|
|
|
|
include ('../inc/includes.php');
|
|
|
|
Session::checkLoginUser();
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpHeader("DRH", '', $_SESSION["glpiname"]);
|
|
} else {
|
|
Html::header("DRH", '', "", "");
|
|
}
|
|
|
|
function getIdeeInformation($id){
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT * from boite_idees where id = ? and user_id = ? ";
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("ii" , $id,$_SESSION["glpiID"]);
|
|
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
$res = array();
|
|
if ($result->num_rows > 0) {
|
|
$res = $result->fetch_assoc();
|
|
}
|
|
|
|
return $res;
|
|
|
|
|
|
}
|
|
|
|
function getfullnameResponsable($idResponsable){
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where id = ? ";
|
|
$stmt = $DB->prepare($query);
|
|
|
|
$stmt->bind_param("i" , $idResponsable);
|
|
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
if ($result->num_rows > 0) {
|
|
$Responsable = $result->fetch_assoc();
|
|
}else{
|
|
$Responsable['fullname'] = null;
|
|
$Responsable['id'] = null;
|
|
}
|
|
|
|
return $Responsable;
|
|
}
|
|
|
|
|
|
|
|
function getInformationUser(){
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT registration_number as matricule , realname as nom , firstname as prenom , users_id_supervisor as idResponsable
|
|
from glpi_users where id ='".$_SESSION["glpiID"]."' ";
|
|
$result = $DB->query($query);
|
|
|
|
if ($result->num_rows > 0) {
|
|
$InformationUser = $result->fetch_assoc();
|
|
// print_r( $InformationUser);
|
|
}
|
|
|
|
return $InformationUser;
|
|
}
|
|
|
|
function getFonction(){
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT picklist.value as fonction from glpi_users , picklist where glpi_users.id_fonction = picklist.id and glpi_users.id ='".$_SESSION["glpiID"]."' ";
|
|
$result = $DB->query($query);
|
|
|
|
if ($result->num_rows > 0) {
|
|
$fonction = $result->fetch_assoc();
|
|
}
|
|
|
|
if(!empty($fonction['fonction'])){
|
|
return $fonction['fonction'];
|
|
}else{
|
|
return $fonction = "";
|
|
}
|
|
|
|
}
|
|
|
|
function getStructure(){
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT picklist.value as structure from glpi_users , picklist
|
|
where glpi_users.id_structure = picklist.id and glpi_users.id ='".$_SESSION["glpiID"]."' ";
|
|
$result = $DB->query($query);
|
|
|
|
if ($result->num_rows > 0) {
|
|
$structure = $result->fetch_assoc();
|
|
}
|
|
|
|
if(!empty($structure['structure'])){
|
|
return $structure['structure'];
|
|
}else{
|
|
return $structure ="";
|
|
}
|
|
}
|
|
|
|
$InformationUser = getInformationUser();
|
|
$Responsable = getfullnameResponsable( $InformationUser['idResponsable'] );
|
|
$fonction = getFonction() ;
|
|
$structure = getStructure();
|
|
|
|
if(isset($Responsable['id'])){
|
|
$_SESSION['idResponsable'] = $Responsable['id'];
|
|
}else{
|
|
$_SESSION['idResponsable'] = null;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!isset($_GET['id'])){
|
|
|
|
echo "<div id='tabs1216654411' class='center vertical ui-tabs ui-corner-all ui-widget ui-widget-content ui-tabs-vertical ui-helper-clearfix ui-corner-left'>
|
|
<div id='ui-id-3' style='padding:0px;' aria-live='polite' aria-labelledby='ui-id-2' role='tabpanel' class='ui-tabs-panel ui-corner-bottom ui-widget-content' aria-hidden='false'>
|
|
|
|
<br>
|
|
<form id='form' name='form' method='post' action='".$CFG_GLPI["root_doc"]."/front/drh.boite.form.php' enctype='multipart/form-data'>
|
|
<input type='hidden' name='entities_id' value='0'>
|
|
<div class='spaced' id='tabsbody'>
|
|
<table class='tab_cadre_fixe' id='mainformtable'>
|
|
<tbody>
|
|
<tr class='headerRow'>
|
|
<th colspan='2' class=''>Boite à idées</th>
|
|
<th colspan='2' class=''>".date("Y-m-d")."</th>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>Matricule : </td>
|
|
<td width='30%'>
|
|
<input id='matricule' type='text' name='matricule' value='".$InformationUser['matricule']."' readonly>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>Responsable hiérarchique : <span style='color:red'>*</span></td>
|
|
<td colspan='3'>
|
|
<input size='40'id='responsable' type='text' name='responsable' value='".$Responsable['fullname']."' readonly>
|
|
</td>
|
|
</tr>
|
|
<tr class=''>
|
|
<td width='20%'>Nom : <span style='color:red'>*</span></td>
|
|
<td width='30%'>
|
|
<input id='nom' type='text' name='nom' value='".$InformationUser['nom']."' readonly>
|
|
|
|
</td>
|
|
<td width='20%'>Prénom : <span style='color:red'>*</span></td>
|
|
<td width='30%'>
|
|
<input id='prenom' type='text' name='prenom' value='".$InformationUser['prenom']."' readonly>
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>Fonction : </td>
|
|
<td width='30%'>
|
|
<input id='fonction' type='text' name='fonction' value='".$fonction."' readonly>
|
|
|
|
</td>
|
|
<td width='20%'>Structure : </td>
|
|
<td width='30%'>
|
|
<input id='structure' type='text' name='structure' value='".$structure."' readonly>
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr class='tab_bg_2'>
|
|
<td>Description</td>
|
|
<td colspan='3'>";
|
|
Html::textarea([
|
|
'name' => "description",
|
|
'enable_richtext' => true,
|
|
'required' => 1
|
|
]);
|
|
echo"</td></tr>";
|
|
|
|
|
|
echo"<tr class=''>
|
|
<td class='center' colspan='4'>
|
|
<div class='center'>
|
|
<button name='add' class='vsubmit' > Valider </button>
|
|
</div>
|
|
</td>
|
|
</tr>";
|
|
|
|
|
|
echo" </tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div>";
|
|
|
|
}elseif(isset($_GET['id'])){
|
|
|
|
if(!filter_var($_GET['id'], FILTER_VALIDATE_INT)) $_GET['id'] = 0;
|
|
$res = getIdeeInformation($_GET['id']);
|
|
if(sizeof($res) > 0){
|
|
|
|
echo "<div id='tabs1216654411' class='center vertical ui-tabs ui-corner-all ui-widget ui-widget-content ui-tabs-vertical ui-helper-clearfix ui-corner-left'>
|
|
<div id='ui-id-3' style='padding:0px;' aria-live='polite' aria-labelledby='ui-id-2' role='tabpanel' class='ui-tabs-panel ui-corner-bottom ui-widget-content' aria-hidden='false'>
|
|
|
|
<br>
|
|
|
|
<input type='hidden' name='entities_id' value='0'>
|
|
<div class='spaced' id='tabsbody'>
|
|
<table class='tab_cadre_fixe' id='mainformtable'>
|
|
<tbody>
|
|
<tr class='headerRow'>
|
|
<th colspan='2' class=''>Boite à idées</th>
|
|
<th colspan='2' class=''>".$res['dateTime_creation']."</th>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>Matricule : </td>
|
|
<td width='30%'>
|
|
<input id='matricule' type='text' name='matricule' value='".$res['matricule']."' readonly>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>Responsable hiérarchique : <span style='color:red'>*</span></td>
|
|
<td colspan='3'>
|
|
<input size='40'id='responsable' type='text' name='responsable' value='".$res['nom']." ".$res['prenom']."' readonly>
|
|
</td>
|
|
</tr>
|
|
<tr class=''>
|
|
<td width='20%'>Nom : <span style='color:red'>*</span></td>
|
|
<td width='30%'>
|
|
<input id='nom' type='text' name='nom' value='".$res['nom']."' readonly>
|
|
|
|
</td>
|
|
<td width='20%'>Prénom : <span style='color:red'>*</span></td>
|
|
<td width='30%'>
|
|
<input id='prenom' type='text' name='prenom' value='".$res['prenom']."' readonly>
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>Fonction : </td>
|
|
<td width='30%'>
|
|
<input id='fonction' type='text' name='fonction' value='".$res['fonction']."' readonly>
|
|
|
|
</td>
|
|
<td width='20%'>Structure : </td>
|
|
<td width='30%'>
|
|
<input id='structure' type='text' name='structure' value='".$res['structure']."' readonly>
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr class='tab_bg_2'>
|
|
<td>Description</td>
|
|
<td colspan='3'>";
|
|
Html::textarea([
|
|
'name' => "description",
|
|
'enable_richtext' => true,
|
|
'value' => $res['description'],
|
|
'editor_id' => 'description12'
|
|
]);
|
|
echo"</td></tr>";
|
|
|
|
echo" </tbody>
|
|
</table>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>";
|
|
}else{
|
|
//Html::redirect($CFG_GLPI["root_doc"]."/front/drh.boiteIdeesListe.php");
|
|
$text = "<div class='center'><br><br><img src='/glpidev/pics/warning.png' alt='Attention' title='Attention'><br><br><span class='b'>Vous n avez pas les droits requis pour réaliser cette action.</span></div>";
|
|
echo '<script>
|
|
$(document).ready(function(){
|
|
$("#page").html("'.$text.'");
|
|
});
|
|
</script>';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpFooter();
|
|
} else {
|
|
Html::footer();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$link=$CFG_GLPI["root_doc"];
|
|
$user = Session::getCurrentInterface();
|
|
?>
|
|
|
|
<script>
|
|
var link = <?php echo json_encode($link); ?>;
|
|
var user = <?php echo json_encode($user); ?>;
|
|
var userlink;
|
|
if(user == "helpdesk"){
|
|
userlink ='<li class="breadcrumb_item"><a href="'+link+'/front/helpdesk.public.php" title="Accueil">Accueil</a></li>';
|
|
}else{
|
|
userlink = '<li class="breadcrumb_item"><a href="'+link+'/front/central.php" title="Accueil">Accueil</a></li>';
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
|
|
$("#c_ssmenu2").html('<ul>'+
|
|
userlink+
|
|
'<li class="breadcrumb_item"><a href="" title="">Ressources Humaines</a></li>'+
|
|
'<li class="breadcrumb_item"><a href="'+link+'/front/drh.boiteIdeesListe.php" class="here" title="Boite à idées"><i class="far fa-sticky-note"></i> Boite à idées</a></li>'+
|
|
'<li class="icons_block"><span><a href="'+link+'/front/drh.boiteIdees.php" class="pointer" title="Ajouter"><i class="fa fa-plus"></i>'+
|
|
'<span class="sr-only">Ajouter</span></a>'+
|
|
'</li>'+
|
|
'</ul>');
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
<script>
|
|
var link = <?php echo json_encode($link); ?>;
|
|
$("button[name='add']").click(function( event ) {
|
|
if($("#form")[0].checkValidity()) {
|
|
event.preventDefault();//important
|
|
jQuery("button[name='add']").attr("disabled","disabled");
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "drh.boite.form.php",
|
|
data: $('#form').serialize()
|
|
|
|
})
|
|
.done(function( msg ) {
|
|
window.location = link+"/front/drh.boiteIdeesListe.php";
|
|
})
|
|
.fail(function(msg) {
|
|
$("button[name='add']").removeAttr("disabled");
|
|
});
|
|
|
|
}
|
|
});
|
|
|
|
|
|
</script>
|