Save new folder
This commit is contained in:
376
front/articles.list.immo.php
Normal file
376
front/articles.list.immo.php
Normal file
@ -0,0 +1,376 @@
|
||||
<?php
|
||||
|
||||
use Glpi\Event;
|
||||
|
||||
use function Sabre\Uri\split;
|
||||
|
||||
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", '', "", "");
|
||||
}
|
||||
|
||||
$all = 0;
|
||||
if(isset($_GET['all'])) {
|
||||
if($_GET['all'] == 1)
|
||||
$all = 1;
|
||||
}
|
||||
|
||||
$results = getArticles($all);
|
||||
$fams = getSFamille();
|
||||
$sitesMap = getDepotsMap();
|
||||
$zonesmap = getZonesMap();
|
||||
$zones = getZONES();
|
||||
|
||||
|
||||
echo "<div id='divImage' tabindex='-1'></div>";
|
||||
|
||||
|
||||
echo "<div class='center'> <H3 id='articlescount'></H3>
|
||||
|
||||
<a class='vsubmit' id='addbtnart' href='article.add.php' title='Ajouter'>Ajouter Article</a>
|
||||
<table border='0' id='tabcenter' class='tab_cadrehov js-dynamitable'>";
|
||||
echo"
|
||||
<tr class='tab_bg_2'>
|
||||
<th>";
|
||||
echo '
|
||||
<label></label>
|
||||
<select id="fam" name="Famille">';
|
||||
echo '<option value="" selected>TOUS LES ZONES</option>';
|
||||
foreach($zones as $row) {
|
||||
echo '<option value="'.$row['ZONE'].'">'.$row['ZONE'].'</option>';
|
||||
}
|
||||
echo "</select>";
|
||||
echo "</th>
|
||||
<th ></th>
|
||||
<th ></th>
|
||||
<th ></th>
|
||||
<th ></th>
|
||||
<th><a id=link>Exporter Par Zone</a></th>";
|
||||
echo'<th> </th><th> </th><th> </th><th> </th>
|
||||
</tr>';
|
||||
|
||||
echo"
|
||||
<tr class='tab_bg_2'>
|
||||
<th> <input class='center' type='text' name='site' placeholder='Site' onchange='sitechange(this)'></th>
|
||||
<th> <input class='center' type='text' name='zone' placeholder='Zone' onchange='zonechange(this)'></th>
|
||||
<th> <input class='center' type='text' name='codearticle' placeholder='Code Article' onchange='codearticlechange(this)'></th>
|
||||
<th ></th>
|
||||
<th ></th>
|
||||
<th> <input class='center' type='text' name='larticle' placeholder='Libelle Article' onchange='larticlechange(this)'></th>
|
||||
<th> <input class='center' type='text' name='state' placeholder='Etat' onchange='statechange(this)'></th>
|
||||
<th> <input class='center' type='text' name='famille' placeholder='Famille' onchange='famillechange(this)'></th>
|
||||
<th> <input class='center' type='text' name='sfamille' placeholder='Sous Famille' onchange='sfamillechange(this)'></th>
|
||||
<th> <input class='center' type='text' name='responsable' placeholder='Responsabilité' onchange='responsablechange(this)'></th>
|
||||
<th> <input class='center' type='text' name='unite' placeholder='Unite' onchange='unitechange(this)'></th>
|
||||
<th></th><th> </th><th> </th>
|
||||
</tr>
|
||||
<tr class='tab_bg_2'>
|
||||
<th >Site</th>
|
||||
<th >Zone</th>
|
||||
<th >Code Article</th>
|
||||
<th ></th>
|
||||
<th ></th>
|
||||
<th >Libelle Article</th>
|
||||
<th >Etat</th>
|
||||
<th >Famille</th>
|
||||
<th >Sous Famille</th>
|
||||
<th >Responsabilité</th>
|
||||
<th >Unite</th>
|
||||
<th >Export</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();
|
||||
|
||||
?>
|
||||
|
||||
<style type="text/css">
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
padding-top: 50px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgb(0, 0, 0);
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 9999;
|
||||
}.modal-content {
|
||||
position: relative;
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
margin: auto;
|
||||
width: 50%;
|
||||
-webkit-animation-name: animatetop;
|
||||
-webkit-animation-duration: 0.4s;
|
||||
animation-name: animatetop;
|
||||
animation-duration: 0.4s
|
||||
}.close-btn {
|
||||
float: right;
|
||||
color: lightgray;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
}.close-btn:hover {
|
||||
color: darkgray;
|
||||
cursor: pointer;
|
||||
}@-webkit-keyframes animatetop {
|
||||
from {top:-300px; opacity:0}
|
||||
to {top:0; opacity:1}
|
||||
}@keyframes animatetop {
|
||||
from {top:-300px; opacity:0}
|
||||
to {top:0; opacity:1}
|
||||
}
|
||||
.center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
/* Tooltip container */
|
||||
.tooltip {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
|
||||
}
|
||||
|
||||
/* Tooltip text */
|
||||
.tooltip .tooltiptext {
|
||||
visibility: hidden;
|
||||
width: 120px;
|
||||
background-color: black;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 5px 0;
|
||||
border-radius: 6px;
|
||||
|
||||
/* Position the tooltip text - see examples below! */
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
/* Show the tooltip text when you mouse over the tooltip container */
|
||||
.tooltip:hover .tooltiptext {
|
||||
visibility: visible;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
var articles = <?php echo json_encode($results); ?>;
|
||||
var sitesMap = <?php echo json_encode($sitesMap); ?>;
|
||||
var zonesmap = <?php echo json_encode($zonesmap); ?>;
|
||||
let localstream;
|
||||
let camerastarted = false;
|
||||
|
||||
function loadtable(resultsP) {
|
||||
|
||||
$('#tabcenter tr').slice(3).remove();
|
||||
|
||||
if(resultsP.length > 0) {
|
||||
|
||||
for(var i = 0; i < resultsP.length; i++) {
|
||||
var row = resultsP[i];
|
||||
let link = "";
|
||||
let img = '<td></td>';
|
||||
let pic = '<td></td>';
|
||||
// if(row['imgpath'] != ""){
|
||||
// link = row['imgpath'];
|
||||
// img = '<td valign="top" style="font-weight:bold"><img src="../pics/cam.png" name="'+link+'" onclick="showImagePopUp(this)" style="vertical-align:bottom;width:26px;height:18px;cursor: pointer;"/></td>';
|
||||
// }
|
||||
if(row['imgpath'] != "")
|
||||
//img = '<td valign="top" style="font-weight:bold"><img src="../pics/pic_placeholder.png" name="'+row['imgpath']+'" onclick="showImagePopUp(this)" style="vertical-align:bottom;width:26px;height:18px"/></td>';
|
||||
img = '<td valign="top" style="font-weight:bold"><i class="fas fa-file-image fa-2x" name="'+row['imgpath']+'" onclick="showImagePopUp(this)"/></td>';
|
||||
//pic = '<td valign="top" style="font-weight:bold"><img src="../pics/cam.png" name="'+row['ART_CODE']+'" onclick="showImagePopUp(this)" style="vertical-align:bottom;width:26px;height:18px"/></td>';
|
||||
pic = '<td valign="top" style="font-weight:bold"><i class="fas fa-camera fa-2x" name="'+row['ART_CODE']+'" onclick="showImagePopUp(this)"/></td>';
|
||||
|
||||
var resp = "";
|
||||
if(row['STK_RESPONSABLE'] != null)
|
||||
resp = row['STK_RESPONSABLE'];
|
||||
|
||||
$('#tabcenter').append(
|
||||
"<tr class='tab_bg_1'><td valign='top' style='font-weight:bold'>"+sitesMap[row['DEP_CODE']]+"</td><td valign='top' style='font-weight:bold'><div class='tooltip'>"+row['STK_ZONE']+"<span class='tooltiptext'>"+zonesmap[row['STK_ZONE']]+"</span></div></td><td valign='top' style='font-weight:bold'><a href='articleqrgen.php?artcode="+row['ART_CODE']+"&artlib="+row['ART_LIB']+"'>"+row['ART_CODE']+"</a></td>"+pic+img+"<td valign='top' style='font-weight:bold'><a href='inventair.immo.noqr.php?artcode="+row['ART_CODE']+"'>"+row['ART_LIB']+"</a></td><td valign='top' style='font-weight:bold'>"+row['A_ETAT']+"</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'>"+resp+"</td><td valign='top' style='font-weight:bold'>"+row['ART_UB_STK']+"</td><td valign='top' style='font-weight:bold'><a href='qrcode.pdf.php?artcode="+row['ART_CODE']+"&artlib="+row['ART_LIB']+"'> Exporter en PDF</a></td></tr>"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
document.getElementById("articlescount").innerHTML = resultsP.length + " article(s)";
|
||||
}
|
||||
|
||||
loadtable(articles);
|
||||
|
||||
function showImagePopUp(e){
|
||||
let link = $(e).attr('name');
|
||||
let holder = '<div class="modal" id="imageHolder" tabindex="-1">'+
|
||||
'<div class="modal-content" style="overflow-x:auto;">';
|
||||
|
||||
if(link.includes('/')){
|
||||
holder = holder + buildImage(link)
|
||||
$('#divImage').empty();
|
||||
$('#divImage').append(holder+'</div></div>');
|
||||
document.querySelector(".modal").style.display = "block";
|
||||
}else{
|
||||
holder = holder + buildCamera()
|
||||
$('#divImage').empty();
|
||||
$('#divImage').append(holder+'</div></div>');
|
||||
document.querySelector(".modal").style.display = "block";
|
||||
startCamera(link)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function buildImage(link){
|
||||
return '<span class="close-btn" onclick="closeImagePopup();">×</span>'+
|
||||
'<div><img id="output" src="'+link+'" style="width: 100%; height:400px;"/></div>'
|
||||
|
||||
}
|
||||
|
||||
function buildCamera(){
|
||||
|
||||
return '<span class="close-btn" onclick="closeImagePopup();">×</span>'+
|
||||
'<table border="0" class="center">'+
|
||||
'<tr>'+
|
||||
'<td><video id="video" width="380" height="280" autoplay></video></td>'+
|
||||
'<td><canvas id="canvas" width="380" height="280"></canvas></td>'+
|
||||
'</tr>'+
|
||||
'<tr>'+
|
||||
'<td><button id="click-photo">Prendre Photo</button></td>'+
|
||||
'<td><button id="save-photo" >Sauvgarder</button></td>'+
|
||||
'</tr>'+
|
||||
'</table>'
|
||||
}
|
||||
function getToken(){
|
||||
return "<?php echo Session::getNewCSRFToken();?>";
|
||||
}
|
||||
|
||||
async function startCamera(imgname) {
|
||||
|
||||
let click_button = document.querySelector("#click-photo");
|
||||
let save_button = document.querySelector("#save-photo");
|
||||
localstream = await navigator.mediaDevices.getUserMedia({ video: {
|
||||
facingMode: 'environment'
|
||||
}, audio: false });
|
||||
camerastarted = true;
|
||||
let image_data_url = "";
|
||||
let token = getToken();
|
||||
|
||||
document.querySelector("#video").srcObject = localstream;
|
||||
|
||||
click_button.addEventListener('click', function() {
|
||||
document.querySelector("#canvas").getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||
image_data_url = canvas.toDataURL();
|
||||
});
|
||||
|
||||
save_button.addEventListener('click', function() {
|
||||
localstream.getTracks().forEach(function(track) {
|
||||
track.stop();
|
||||
});
|
||||
camerastarted = false;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "article.list.savepic.php",
|
||||
data: {
|
||||
_glpi_csrf_token:token,
|
||||
imgdata: image_data_url,
|
||||
filename: imgname
|
||||
}
|
||||
})
|
||||
.done(function( msg ) {
|
||||
location.reload();
|
||||
})
|
||||
.fail(function(msg) {
|
||||
console.log(msg);
|
||||
});
|
||||
closeImagePopup();
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function closeImagePopup(){
|
||||
if(camerastarted)
|
||||
localstream.getTracks()[0].stop();
|
||||
document.querySelector(".modal").style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
function codearticlechange(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 famillechange(e) {
|
||||
var res = articles.filter(a => a.FAR_LIB.toUpperCase().includes(e.value.toUpperCase()));
|
||||
loadtable(res);
|
||||
}
|
||||
|
||||
function sfamillechange(e) {
|
||||
var res = articles.filter(a => a.SFA_LIB.toUpperCase().includes(e.value.toUpperCase()));
|
||||
loadtable(res);
|
||||
}
|
||||
|
||||
function sitechange(e){
|
||||
var res = articles.filter(a => a.DEP_CODE.toUpperCase().includes(e.value.toUpperCase()));
|
||||
loadtable(res);
|
||||
}
|
||||
|
||||
function zonechange(e){
|
||||
var res = articles.filter(a => a.STK_ZONE.toUpperCase().includes(e.value.toUpperCase()));
|
||||
loadtable(res);
|
||||
}
|
||||
|
||||
function responsablechange(e) {
|
||||
console.log(e.value.toUpperCase());
|
||||
var res = articles.filter(a => a.STK_RESPONSABLE.toUpperCase().includes(e.value.toUpperCase()));
|
||||
loadtable(res);
|
||||
}
|
||||
|
||||
$("#fam").on("change", function () {
|
||||
zonechange(this);
|
||||
var holder = document.getElementById("link");
|
||||
var v = this.value
|
||||
if(v == "")
|
||||
v = "all"
|
||||
holder.innerHTML = holder.setAttribute('href', "qrcode.pdf.immo.php?bulk="+v);
|
||||
holder.innerHTML = "Exporter Par Zone";
|
||||
});
|
||||
|
||||
function unitechange(e) {
|
||||
var res = articles.filter(a => a.ART_UB_STK.toUpperCase().includes(e.value.toUpperCase()));
|
||||
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="">Articles</a></li>'+
|
||||
'</ul>');
|
||||
var selected = document.getElementById("fam");
|
||||
var v = selected.value;
|
||||
if(v == "")
|
||||
v = "all"
|
||||
var holder = document.getElementById("link");
|
||||
holder.innerHTML = holder.setAttribute('href', "qrcode.pdf.immo.php?bulk="+v);
|
||||
holder.innerHTML = "Exporter Par Zone";
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user