329 lines
11 KiB
PHP
329 lines
11 KiB
PHP
<?php
|
|
|
|
|
|
use Glpi\Event;
|
|
|
|
include ('../inc/includes.php');
|
|
|
|
Session::checkLoginUser();
|
|
|
|
|
|
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpHeader("Decharge", '', $_SESSION["glpiname"]);
|
|
} else {
|
|
Html::header("Decharge", '', "", "");
|
|
}
|
|
|
|
|
|
|
|
function get_Users(){
|
|
|
|
global $DB;
|
|
|
|
$query = "SELECT id,concat(`realname`,' ',`firstname`) AS fullname
|
|
FROM `glpi_users`
|
|
WHERE is_deleted = 0 AND realname is not null AND firstname is not null";
|
|
$result = $DB->query($query);
|
|
|
|
if ($result->num_rows > 0) {
|
|
|
|
while($row = $result->fetch_assoc()) {
|
|
$res[] = $row;
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
|
|
|
|
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'>
|
|
<ul role='tablist' class='ui-tabs-nav ui-corner-all ui-helper-reset ui-helper-clearfix ui-widget-header'>
|
|
|
|
</ul>
|
|
<div id='ui-id-3' 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"]."/ajax/decharge.php' enctype='multipart/form-data'>
|
|
<div class='spaced' id='tabsbody'>
|
|
<table class='tab_cadre_fixe' id='mainformtable'>
|
|
<tbody>
|
|
<tr class='headerRow'>
|
|
<th colspan='2' class=''>Principal</th>
|
|
<th colspan='2' class=''></th>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>Utilisateur : </td>
|
|
<td width='30%'>
|
|
<select class='js-example-basic-single' name='id_user' id='id_user' onchange ='picklist_enchange();' required>
|
|
<option value=''>----</option>";
|
|
$Users = get_Users();
|
|
foreach ($Users as $user) {
|
|
echo '<option value="'.$user['id'].'">'.$user['fullname'].'</option>';
|
|
}
|
|
echo" </select>
|
|
</td>
|
|
<td width='20%'>Fonction : <span style='color:red'>*</span></td>
|
|
<td width='30%'>
|
|
<input style='width:80%;' id='fonction' type='text' name='fonction' value='' required>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
|
|
<td width='20%'>Date : </td>
|
|
<td width='30%'><input style='width:80%;' id='date' type='date' name='date' value='' required></td>
|
|
|
|
<td width='20%'>Type : <span style='color:red'>*</span></td>
|
|
<td width='30%'>
|
|
<select name='type' id='type' onchange='get_refernce();' required>
|
|
<option value='decharge'>Décharge</option>
|
|
<option value='contre decharge'>Contre Décharge</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class=''>
|
|
<td width='20%'>N° : <span style='color:red'>*</span></td>
|
|
<td width='30%'><input style='width:80%;' id='num' type='text' name='num' value='' required> </td>
|
|
<td width='20%'>Titre : <span style='color:red'>*</span></td>
|
|
<td width='30%'>
|
|
<select name='titre' id='titre' required>
|
|
<option value='M'>M</option>
|
|
<option value='Mme'>Mme</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>";
|
|
|
|
|
|
|
|
echo'<table class="tab_cadre_fixehov" id="dynamique" style="padding-top: 20px;">
|
|
<thead>
|
|
<tr>
|
|
<th></th>
|
|
<th class="">Désignation</th>
|
|
<th class="">Quantité</th>
|
|
<th class="" style="width:200px;">Fiche Technique</th>
|
|
<th class="">Etat</th>
|
|
</tr>
|
|
</thead>
|
|
<tfoot>
|
|
<tr>
|
|
<th></th>
|
|
<th class="">Désignation</th>
|
|
<th class="">Quantité</th>
|
|
<th class="">Fiche Technique</th>
|
|
<th class="">Etat</th>
|
|
</tr>
|
|
</tfoot>
|
|
<tbody id="result">
|
|
<tr class="tab_bg_2">
|
|
<td></td>
|
|
<td><input type="text" name="designation[]" required></td>
|
|
<td><input type="number" name="quantite[]" required></td>
|
|
<td><textarea cols="6" rows="6" name="fiche[]" style="margin: 0px; width: 429px; height: 57px;" required></textarea></td>
|
|
<td><input type="text" name="etat[]" required ></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<table class="tab_cadre_fixe">
|
|
<tr class="tab_bg_2">
|
|
<td><i name="add_lign" id="add_lign" class="fas fa-plus"></i> Ajouter</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>';
|
|
|
|
echo"
|
|
<div class='center'>
|
|
<button name='save' class='vsubmit'> Enregistrer </button>
|
|
<a href='".$CFG_GLPI["root_doc"]."/front/decharge.list.php' class='vsubmit' style='margin-left: 15px; background-color: #eba696;'> Annuler</a>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div>";
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpFooter();
|
|
} else {
|
|
Html::footer();
|
|
}
|
|
|
|
|
|
|
|
|
|
$link=$CFG_GLPI["root_doc"]."/front/ticket.php";
|
|
$root = $CFG_GLPI["root_doc"];
|
|
$user = Session::getCurrentInterface();
|
|
?>
|
|
|
|
|
|
<script>
|
|
var root = <?php echo json_encode($root); ?>;
|
|
var user = <?php echo json_encode($user); ?>;
|
|
get_refernce();
|
|
|
|
function supprimer(e){
|
|
$(e).parents("tr").remove();
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
|
|
$("#add_lign").click(function(){
|
|
|
|
var markup = "<tr class='tab_bg_2'>"
|
|
+"<td><i class='fa fa-trash deleteRow cursorPointer' onclick='supprimer(this)' title='Supprimer' style='display: inline-block;' ></i></td>"
|
|
+"<td><input type='text' name='designation[]' required></td>"
|
|
+"<td><input type='number' name='quantite[]' required></td>"
|
|
+"<td><textarea cols='6' rows='6' name='fiche[]' style='margin: 0px; width: 429px; height: 57px;' required></textarea></td>"
|
|
+"<td><input type='text' name='etat[]' required ></td>"
|
|
+"</tr>";
|
|
|
|
$("#dynamique").append(markup);
|
|
|
|
});
|
|
});
|
|
|
|
|
|
$("button[name='save']").click(function( event ) {
|
|
if($("#form")[0].checkValidity()) {
|
|
|
|
event.preventDefault();
|
|
$("button[name='save']").attr("disabled","disabled");
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: root+"/ajax/decharge.php?action=add",
|
|
data: $('#form').serialize()
|
|
})
|
|
.done(function( msg ) {
|
|
window.location = root+"/front/decharge.list.php";
|
|
})
|
|
.fail(function(msg) {
|
|
console.log(msg);
|
|
$("button[name='save']").removeAttr("disabled");
|
|
});
|
|
|
|
}
|
|
});
|
|
|
|
function add(data){
|
|
|
|
if(data['ordinateurs'].length > 0){
|
|
for(var i = 0; i < data['ordinateurs'].length; i++) {
|
|
var markup = "<tr class='tab_bg_2'>"
|
|
+"<td><i class='fa fa-trash deleteRow cursorPointer' onclick='supprimer(this)' title='Supprimer' style='display: inline-block;' ></i></td>"
|
|
+"<td><input type='text' name='designation[]' value='"+data['ordinateurs'][i][0]+"' required></td>"
|
|
+"<td><input type='number' name='quantite[]' value='"+data['ordinateurs'][i][1]+"' required></td>"
|
|
+"<td><textarea cols='6' rows='6' name='fiche[]' style='margin: 0px; width: 429px; height: 57px;' required>"+data['ordinateurs'][i][2]+"</textarea></td>"
|
|
+"<td><input type='text' name='etat[]' value='"+data['ordinateurs'][i][3]+"' required ></td>"
|
|
+"</tr>";
|
|
|
|
$("#dynamique").append(markup);
|
|
}
|
|
}
|
|
if(data['phones'].length > 0){
|
|
for(var p = 0; p < data['phones'].length; p++) {
|
|
var markup = "<tr class='tab_bg_2'>"
|
|
+"<td><i class='fa fa-trash deleteRow cursorPointer' onclick='supprimer(this)' title='Supprimer' style='display: inline-block;' ></i></td>"
|
|
+"<td><input type='text' name='designation[]' value='"+data['phones'][p][0]+"' required></td>"
|
|
+"<td><input type='number' name='quantite[]' value='"+data['phones'][p][1]+"' required></td>"
|
|
+"<td><textarea cols='6' rows='6' name='fiche[]' style='margin: 0px; width: 429px; height: 57px;' required>"+data['phones'][p][2]+"</textarea></td>"
|
|
+"<td><input type='text' name='etat[]' value='"+data['phones'][p][3]+"' required ></td>"
|
|
+"</tr>";
|
|
|
|
$("#dynamique").append(markup);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function get_utilisateur_equipments(){
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
url: root+"/ajax/decharge.php?action=user_equipments&userid="+$( "#id_user" ).val() ,
|
|
dataType: "json"
|
|
})
|
|
.done(function( data ) {
|
|
$("#result").empty()
|
|
//add(JSON.parse(data));
|
|
add(data);
|
|
})
|
|
.fail(function(msg) {
|
|
console.log(msg);
|
|
});
|
|
|
|
}
|
|
|
|
|
|
function get_fonction(){
|
|
$.ajax({
|
|
type: "GET",
|
|
url: root+"/ajax/decharge.php?action=get_utilisateur_fonction&userid="+$( "#id_user" ).val()
|
|
})
|
|
.done(function( msg ) {
|
|
$('#fonction').val(msg);
|
|
})
|
|
.fail(function(msg) {
|
|
console.log(msg);
|
|
});
|
|
|
|
}
|
|
|
|
function get_refernce(){
|
|
$.ajax({
|
|
type: "GET",
|
|
url: root+"/ajax/decharge.php?action=get_refernce&type="+$( "#type" ).val(),
|
|
dataType: "json"
|
|
})
|
|
.done(function( msg ) {
|
|
//var json_data = JSON.parse(msg);
|
|
var json_data = msg;
|
|
$('#num').val(json_data['last_num']+1);
|
|
})
|
|
.fail(function(msg) {
|
|
console.log(msg);
|
|
});
|
|
|
|
}
|
|
|
|
function picklist_enchange(){
|
|
get_utilisateur_equipments();
|
|
get_fonction();
|
|
}
|
|
|
|
var userlink;
|
|
if(user == "helpdesk"){
|
|
userlink ='<li class="breadcrumb_item"><a href="'+root+'/front/helpdesk.public.php" title="Accueil">Accueil</a></li>';
|
|
}else{
|
|
userlink = '<li class="breadcrumb_item"><a href="'+root+'/front/central.php" title="Accueil">Accueil</a></li>';
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
|
|
$("#c_ssmenu2").html('<ul>'+
|
|
userlink+
|
|
'<li class="breadcrumb_item"><a href="" title="">Administration</a></li>'+
|
|
'<li class="breadcrumb_item"><a href="'+root+'/front/decharge.list.php" class="here" title="Décharge"><i class="far fa-sticky-note"></i> Décharge</a></li>'+
|
|
'<span class="sr-only">Ajouter</span></a>'+
|
|
'</li>'+
|
|
'</ul>');
|
|
|
|
});
|
|
</script>
|
|
<!-- script pour liste déroulante -->
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('.js-example-basic-single').select2();
|
|
});
|
|
</script>
|