Files
MYSOPHAL/front/resultatinventaire.immo.php
2025-08-07 13:15:31 +01:00

214 lines
8.4 KiB
PHP
Raw Permalink Blame History

<?php
use Glpi\Event;
include ('../model_controller/articles.list.immo.php');
Session::checkLoginUser();
//Html::redirect($CFG_GLPI["root_doc"]."central.php");
if (Session::getCurrentInterface() == "helpdesk") {
Html::helpHeader("DRH", '', $_SESSION["glpiname"]);
} else {
Html::header("DRH", '', "", "");
}
$results = getInventaire();
echo "<a href='../model_controller/controleinventaire.immo.php'>Controle</a>
<div onclick=\"exportThisWithParameter('tabcenter', 'inventaire.xls')\" style=\"cursor: pointer; border: 1px solid #ccc; text-align: center;width:19%;\">Exporter Vers Excel</div>
<div class='center'> <H3 id='articlescount'></H3>
<table border='0' id='tabcenter' class='tab_cadrehov js-dynamitable'>
<tr class='tab_bg_2'>
<th ></th>
<th> <input class='center' type='text' name='cdepot' placeholder='Code Depot' onchange='cdepotchange(this)'></th>
<th> <input class='center' type='text' name='codedepot' placeholder='Depot' onchange='codedepotchange(this)'></th>
<th> <input class='center' type='text' name='clarticle' placeholder='Code Article' onchange='clarticlechange(this)'></th>
<th> <input class='center' type='text' name='larticle' placeholder='Libelle Article' onchange='larticlechange(this)'></th>
<th> <input class='center' type='text' name='famille' placeholder='Famille' onchange='famchange(this)'></th>
<th> <input class='center' type='text' name='sfamille' placeholder='Sous Famille' onchange='sfamchange(this)'></th>
<th> <input class='center' type='text' name='numlot' placeholder='Numero Serie' onchange='numlotchange(this)'></th>
<th> <input class='center' type='text' name='zone' placeholder='Zone' onchange='zonechange(this)'></th>
<th hidden> </th>
<th> <input class='center' type='text' name='qtc1' placeholder='Quantité Comptage1' onchange='qtc1change(this)'></th>
<th> <input class='center' type='text' name='qtc2' placeholder='Quantité Comptage2' onchange='qtc2change(this)'></th>
<th> <input class='center' type='text' name='qtctrl' placeholder='Quantité Controle' onchange='qtctrlchange(this)'></th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
<tr class='tab_bg_2'>
<th ><a href=''></a></th>
<th class=''>Code Depot</th>
<th class=''>Depot</th>
<th class=''>Code Article</th>
<th class=''>Libelle Article</th>
<th class=''>Famille</th>
<th class=''>Sous Famille</th>
<th class=''>Numero de Serie</th>
<th class=''>Zone</th>
<th class='' hidden>Stock Reel</th>
<th class=''>Quantité Comptage1</th>
<th class=''>Quantité Comptage2</th>
<th class=''>Quantité Controle</th>
<th class=''>User Comptage 1</th>
<th class=''>User Comptage 2</th>
<th class=''>User Controle</th>
<th class='' hidden>Date Comptage 1</th>
<th class='' hidden>Date Comptage 2</th>
<th class='' hidden>Date Controle</th>
</tr>
";
if(isset($results)) {
} else {
echo "<tr style=' text-align: center;'><td colspan='3'>Aucune donn<6E>e trouv<75>e</td></tr>";
}
echo"
</table>
</div>";
Html::footer();
?>
<script>
var articles = <?php echo json_encode($results); ?>;
var username = <?php echo json_encode($_SESSION["glpiname"]); ?>;
function loadtable(resultsP) {
$('#tabcenter tr').slice(2).remove();
if(resultsP.length > 0) {
for(var i = 0; i < resultsP.length; i++) {
var row = resultsP[i];
var color = "";
if(row['Qt_compt1'] == 0 || row['Qt_compt1'] != row['Qt_compt2']) {
color = "red";
}
if(row['Qt_compt2'] == 0) {
color = "orange";
}
if(row['Qt_compt1'] != 0 && row['Qt_compt1'] == row['Qt_compt2'])
color = "green";
var colorarticle = "";
if(row['Qt_controle'] != 0 && row['Qt_controle'] == row['Qt_reel'])
colorarticle = "blue";
var editbtn = "";
if(username == 'itapplications' || username == 'admin')
editbtn = "<td ><a href='editresultinventaire.php?idinv="+row['id']+"' >Modifier</a></td>";
$('#tabcenter').append(
"<tr class='tab_bg_1'><td valign='top'></td><td valign='top'>"+row['DEP_CODE']+"</td><td valign='top' style='font-weight:bold'><a href=''>"+row['DEP_NOM']+"</a></td><td valign='top' style='background-color:"+colorarticle+"'>"+row['ART_CODE']+"</td><td valign='top' style='font-weight:bold'>"+row['ART_LIB']+"</td><td valign='top' style='font-weight:bold'>"+row['FAR_LIB']+"</td><td valign='top' style='font-weight:bold'>"+row['SFA_LIB']+"</td><td valign='top' style='font-weight:bold'>"+row['STK_NUMLOT']+"</td><td valign='top' style='font-weight:bold'>"+row['Emplacement']+"</td><td valign='top' style='font-weight:bold' hidden>"+row['Qt_reel']+"</td><td valign='top'>"+row['Qt_compt1']+"</td><td valign='top'>"+row['Qt_compt2']+"</td><td valign='top' style='background-color:"+color+"'>"+row['Qt_controle']+"</td><td valign='top'>"+row['usercomp1']+"</td><td valign='top'>"+row['usercomp2']+"</td><td valign='top'>"+row['usercontrole']+"</td><td valign='top' hidden>"+row['datecomp1']+"</td><td valign='top' hidden>"+row['datecomp2']+"</td><td valign='top' hidden>"+row['datecontrole']+"</td>"+editbtn+"</tr>"
);
}
document.getElementById("articlescount").innerHTML = resultsP.length + " resultat inventaire(s)";
}
}
loadtable(articles);
function cdepotchange(e) {
var res = articles.filter(a => a.DEP_CODE.toUpperCase().includes(e.value.toUpperCase()));
loadtable(res);
}
function codedepotchange(e) {
var res = articles.filter(a => a.DEP_NOM.toUpperCase().includes(e.value.toUpperCase()));
loadtable(res);
}
function clarticlechange(e) {
var res = articles.filter(a => a.ART_CODE.toUpperCase().includes(e.value.toUpperCase()));
loadtable(res);
}
function larticlechange(e) {
var res = articles.filter(a => a.ART_LIB.toUpperCase().includes(e.value.toUpperCase()));
loadtable(res);
}
function famchange(e) {
var resf = articles.filter(a => a.FAR_LIB.toUpperCase().includes(e.value.toUpperCase()));
loadtable(resf);
}
function numlotchange(e) {
var res = articles.filter(a => a.STK_NUMLOT.toUpperCase().includes(e.value.toUpperCase()));
loadtable(res);
}
function qtc1change(e) {
var res = articles.filter(a => a.Qt_compt1 == e.value);
if(e.value == '')
res = articles;
loadtable(res);
}
function qtc2change(e) {
var res = articles.filter(a => a.Qt_compt2 == e.value);
if(e.value == '')
res = articles;
loadtable(res);
}
function qtctrlchange(e) {
var res = articles.filter(a => a.Qt_controle == e.value);
if(e.value == '')
res = articles;
loadtable(res);
}
$(document).ready(function(){
$("#c_ssmenu2").html('<ul>'+
'<li class="breadcrumb_item"><a href="central.php" title="Accueil">Accueil</a></li>'+
'<li class="breadcrumb_item"><a href="" title="">Resultat Inventaire</a></li>'+
'</ul>');
});
</script>
<script>
var exportThisWithParameter = (function () {
var uri = 'data:application/vnd.ms-excel;base64,',
template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta http-equiv=Content-Type content="text/html; charset=utf-8"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets> <x:ExcelWorksheet><x:Name>{worksheet}</x:Name> <x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions> </x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook> </xml><![endif]--></head><body> <table>{table}</table></body></html>',
base64 = function (s) {
return window.btoa(unescape(encodeURIComponent(s)))
},
format = function (s, c) {
return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; })
}
return function (tableID, excelName) {
tableID = document.getElementById(tableID)
var ctx = { worksheet: excelName || 'Worksheet', table: tableID.innerHTML }
// window.location.href = uri + base64(format(template, ctx))
var link = document.createElement("a");
link.download = excelName;
//link.charset = 'utf-8';
link.href = uri + base64(format(template, ctx));
link.click();
}
})()
</script>