228 lines
6.2 KiB
PHP
228 lines
6.2 KiB
PHP
<?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", '', "", "");
|
|
}
|
|
|
|
if(isset($_POST['valider'])) {
|
|
$currentdate = date('Y-m-d h:i:s', time());
|
|
$currentuser = $_SESSION["glpiname"];
|
|
|
|
$qtcompt1 = '';
|
|
$qtcompt2 = '';
|
|
$qtcontrole = '';
|
|
$usercomp1 = '';
|
|
$datecomp1 = '';
|
|
$usercomp2 = '';
|
|
$datecomp2 = '';
|
|
$usercontrole = '';
|
|
$datecontrole = '';
|
|
if($_POST['comptage'] == "comptage1") {
|
|
$qtcompt1 = $_POST['quantity'];
|
|
$usercomp1 = $currentuser;
|
|
$datecomp1 = $currentdate;
|
|
}
|
|
if($_POST['comptage'] == "comptage2") {
|
|
$qtcompt2 = $_POST['quantity'];
|
|
$usercomp2 = $currentuser;
|
|
$datecomp2 = $currentdate;
|
|
}
|
|
if($_POST['comptage'] == "comptage3") {
|
|
$qtcontrole = $_POST['quantity'];
|
|
$usercontrole = $currentuser;
|
|
$datecontrole = $currentdate;
|
|
}
|
|
|
|
saveInventaire($_POST['depot'], $_POST['qr-label'], $_POST['numlot'], $_POST['zone'], '0', $qtcompt1, $qtcompt2, $qtcontrole, $usercomp1, $datecomp1, $usercomp2, $datecomp2, $usercontrole, $datecontrole);
|
|
echo "
|
|
<script type=\"text/javascript\">
|
|
alert(\"Article ".$lib." Créer Avec Succès\");
|
|
</script>
|
|
";
|
|
Html::redirect("inventaire.immo.php");
|
|
}
|
|
|
|
$all = 1;
|
|
|
|
$depots = getDepots();
|
|
//$results = getArticles($all);
|
|
$msg = "Confirmez-vous l\'enregistrement ?";
|
|
|
|
$results = getArticles($all);
|
|
|
|
/*if (file_exists($file_name) == false) {
|
|
$results = getArticles($all);
|
|
cache_write($file_name, json_encode($results));
|
|
}else{
|
|
$results = json_decode(cache_read($file_name), true);
|
|
}
|
|
|
|
echo count($results);
|
|
*/
|
|
|
|
$checkbtn = '';
|
|
//if($_SESSION["glpiname"] == 'itapplications')
|
|
$checkbtn = '<label id="btncheck">check</label>';
|
|
|
|
echo '<div>
|
|
<form method="post" id="formulaire" name="formulaire" autocomplete="off">
|
|
<input type="hidden" id="_glpi_csrf_token" name="_glpi_csrf_token" value="'.Session::getNewCSRFToken().'">
|
|
<label>Depot</label>
|
|
<select id="depot" name="depot" required style="height:25px">';
|
|
echo '<option value=""></option>';
|
|
foreach($depots as $row) {
|
|
echo '<option value="'.$row['DEP_CODE'].'">'.$row['DEP_NOM'].'</option>';
|
|
}
|
|
echo '</select>
|
|
<br><br>
|
|
<div>
|
|
<input type="radio" id="comptage1" name="comptage" value="comptage1" checked>
|
|
<label>Comptage 1</label>
|
|
</div>
|
|
<br>
|
|
<div>
|
|
<input type="radio" id="comptage2" name="comptage" value="comptage2">
|
|
<label>Comptage 2</label>
|
|
</div>
|
|
<br>
|
|
<div>
|
|
<input type="radio" id="comptage3" name="comptage" value="comptage3">
|
|
<label>Controle</label>
|
|
</div>
|
|
<br><br>
|
|
<label>Article</label>
|
|
<input type="text" id="qr-label" name="qr-label" required>
|
|
<img id="img-scan" src="../pics/scanimg.jpg" style="vertical-align:bottom;width:26px;height:18px"/>
|
|
<label id="article-label"></label>
|
|
<br><br>
|
|
<label>Numero Serie</label>
|
|
<select id="numlot" name="numlot"><option value=""></option></select>
|
|
<br><br>
|
|
<label>Zone</label>
|
|
<select id="zone" name="zone"><option value=""></option></select>
|
|
<br><br>
|
|
<label>Quantité</label>
|
|
<input type="number" step="any" id="quantity" name="quantity" required>
|
|
<br><br>
|
|
<input type="submit" name="valider" id="valider" value="Envoyer" class="vsubmit" onclick="return(confirm(\''.$msg.'\'));">
|
|
|
|
</form>
|
|
</div>
|
|
|
|
|
|
<div> <video hidden style="max-width:500px" id="qr-video"></video> </div>
|
|
<div id="show-region" style="max-width:500px; display:none"></div>';
|
|
//'.$checkbtn;
|
|
|
|
// echo "<a href='./Sophal inventory.apk'>Telecharger l'application sur<img src='../pics/download.png' style='width:150px;display:inline-block;'/></a>";
|
|
|
|
|
|
Html::footer();
|
|
|
|
?>
|
|
|
|
<!--
|
|
<script src="../js/qr-scanner.umd.min.js"></script>
|
|
<script src="../js/qr-scanner-worker.min.js"></script>
|
|
-->
|
|
|
|
<script type="module">
|
|
|
|
import QrScanner from "../js/qr-scanner.min.js";
|
|
QrScanner.WORKER_PATH = '../js/qr-scanner-worker.min.js';
|
|
|
|
document.getElementById('img-scan').addEventListener('click', (e) => {
|
|
|
|
if(document.getElementById('show-region').style.display == "none")
|
|
document.getElementById('show-region').style.display = "block";
|
|
else
|
|
document.getElementById('show-region').style.display = "none";
|
|
});
|
|
|
|
|
|
var results = <?php echo json_encode($results); ?>;
|
|
var found = false;
|
|
|
|
$(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="">Inventaire</a></li>'+
|
|
'</ul>');
|
|
});
|
|
|
|
|
|
function check() {
|
|
var te = document.getElementById('qr-label').value;
|
|
found = false;
|
|
var numlot = document.getElementById('numlot');
|
|
for (var option in numlot){
|
|
numlot .remove(option);
|
|
}
|
|
var zone = document.getElementById('zone');
|
|
for (var option in zone){
|
|
zone.remove(option);
|
|
}
|
|
setLabel(te);
|
|
}
|
|
|
|
function setLabel(text) {
|
|
|
|
if(!found) {
|
|
|
|
document.getElementById('qr-label').value = text;
|
|
|
|
var resart = results.filter(a => a.ART_CODE == text);
|
|
document.getElementById('article-label').innerHTML = resart[0]['ART_LIB'];
|
|
|
|
var selectedDepot = document.getElementById('depot').value;
|
|
var res = results.filter(a => a.DEP_CODE.toUpperCase().includes(selectedDepot.toUpperCase()));
|
|
res = res.filter(a => a.ART_CODE.toUpperCase() == text.toUpperCase());
|
|
|
|
var numlot = document.getElementById('numlot');
|
|
var zone = document.getElementById('zone');
|
|
var count = 0;
|
|
res.forEach(a => {
|
|
var lotnum = a['STK_NUMLOT'];
|
|
if(lotnum != '') {
|
|
var opt = document.createElement('option');
|
|
opt.value = lotnum;
|
|
opt.innerHTML = lotnum;
|
|
numlot.appendChild(opt);
|
|
count = count+1;
|
|
}
|
|
var stkzone = a['STK_ZONE'];
|
|
if(stkzone != '') {
|
|
var opt = document.createElement('option');
|
|
opt.value = stkzone;
|
|
opt.innerHTML = stkzone;
|
|
zone.appendChild(opt);
|
|
}
|
|
});
|
|
if(count == 1) {
|
|
numlot.lastElementChild.selected = true;
|
|
}
|
|
|
|
found = true;
|
|
}
|
|
}
|
|
|
|
//document.getElementById('btncheck').addEventListener("click", check, false);
|
|
|
|
const video = document.getElementById('qr-video');
|
|
const qrScanner = new QrScanner(video, result => setLabel(result));
|
|
qrScanner.start().then(() => {
|
|
document.getElementById('show-region').appendChild(qrScanner.$canvas);
|
|
});
|
|
|
|
</script>
|