169 lines
4.2 KiB
PHP
169 lines
4.2 KiB
PHP
<?php
|
|
|
|
|
|
|
|
require_once 'MonitoringVMHeader.php';
|
|
|
|
require_once 'MonitoringDBRequest.php';
|
|
|
|
|
|
|
|
if(isset($_POST['year'])){
|
|
|
|
$year = $_POST['year'];
|
|
|
|
}
|
|
|
|
$result = getResultatVMPoructSpec($year,$roleid);
|
|
|
|
$accounttype = getAccountsType();
|
|
|
|
|
|
|
|
echo getMonitoringMainBar(2,$roleid).getMonitoringVisiteSubBar(7,$roleid).
|
|
|
|
'<div class="main-container main-container-Accounts">
|
|
|
|
<div id="scrollbar" style="margin:15px 15px 15px 15px; border:1px solid #ecf0f1; overflow-y: scroll; overflow-x: scroll; height:462.709px ;border:1px solid #bdc3c7;">'.
|
|
|
|
getTopTextSelect('Nombre de visites (Produit Par Specialite)', $year).
|
|
|
|
'<hr>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-4">
|
|
|
|
<label for="Produit">Produit</label>
|
|
|
|
<input class="form-control mb-4 w-20" type="text" name="Produit" placeholder="Rechercher" onKeyUp="ProduitFiltre(this)">
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
|
|
|
|
echo '<table id="tabcenter" class="table table-bordered table-striped" >
|
|
|
|
<tr class="center borderline">
|
|
|
|
<th id="productname">Produit</th>
|
|
|
|
';
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($accounttype); $i++){
|
|
|
|
|
|
|
|
echo '<th>';
|
|
|
|
|
|
|
|
echo $accounttype[$i]['accounttype'] ;
|
|
|
|
|
|
|
|
echo '</th>';
|
|
|
|
}
|
|
|
|
echo "<th>Total</th></tr>
|
|
|
|
|
|
|
|
|
|
|
|
</table>
|
|
|
|
</div></div>";
|
|
|
|
|
|
|
|
|
|
|
|
$viewer->view('CustomDashboardFooter.tpl');
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
var accounttype = <?php echo json_encode($accounttype); ?>;
|
|
|
|
|
|
|
|
function convertArray(data) {
|
|
|
|
|
|
|
|
var a=[];
|
|
|
|
var c=[];
|
|
|
|
var index;
|
|
|
|
|
|
|
|
if(data.length > 0) {
|
|
|
|
|
|
|
|
for(var i = 0; i < data.length; i++){
|
|
|
|
|
|
|
|
var row = data[i];
|
|
|
|
if(row['accounttypeid'] !== null && row['account_type'] !== null && row['nbr'] !== null){
|
|
|
|
|
|
|
|
if(a.indexOf(row['productname']) == -1){
|
|
|
|
|
|
|
|
index = accounttype.findIndex(img => img.accounttypeid === row['accounttypeid'])
|
|
|
|
|
|
|
|
var b=[];
|
|
|
|
a.push(row['productname']);
|
|
|
|
b[0]=row['productname'];
|
|
|
|
b[index+1]=parseInt(row['nbr']); // + 1 pour eliminer le premier champ produit
|
|
|
|
c[a.length-1]=b;
|
|
|
|
|
|
|
|
} else{
|
|
|
|
|
|
|
|
index = accounttype.findIndex(img => img.accounttypeid === row['accounttypeid'])
|
|
|
|
b[index+1]=parseInt(row['nbr']);
|
|
|
|
c[a.length-1]=b;
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
var b=[0];
|
|
|
|
a.push(row['productname']);
|
|
|
|
b[0]=row['productname'];
|
|
|
|
c[a.length-1]=b;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//filtre
|
|
|
|
function ProduitFiltre(e) {
|
|
|
|
var res = result.filter(a => a.productname.toUpperCase().includes(e.value.toUpperCase()) );
|
|
|
|
loadTable(convertArray(res));
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadTable(data){
|
|
|
|
|
|
|
|
var temp=[];
|
|
|
|
var total=0;
|
|
|
|
$('#tabcenter tr').slice(1).remove();
|
|
|
|
|
|
|
|
if(data.length > 0) {
|
|
|
|
|
|
|
|
for(var i = 0; i < data.length; i++) {
|
|
|
|
|
|
|
|
var row = data[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(var f = 0; f <= accounttype.length; f++) {
|
|
|
|
|
|
|
|
var totalcol = 0;
|
|
|
|
for(var b = 1; b < data.length; b++) {
|
|
|
|
if(f != 0 && data[b][f] !== undefined)
|
|
|
|
totalcol = totalcol + data[b][f];
|
|
|
|
}
|
|
|
|
if(f != 0 && totalcol>0) {
|
|
|
|
if(row[f] === undefined){
|
|
|
|
|
|
|
|
temp[f]="<td>"+0+"</td>";
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
temp[f]="<td>"+row[f]+"</td>";
|
|
|
|
|
|
|
|
if (f != 0) total=row[f]+total; //if pour eliminer le champ de produit
|
|
|
|
|
|
|
|
}
|
|
|
|
}else if (f == 0 ) {
|
|
|
|
temp[0]="<td>"+row[0]+"</td>";
|
|
|
|
} else {
|
|
|
|
var corresponding_th = document.querySelector('#tabcenter th:nth-child(' + (f+1) + ')');
|
|
|
|
corresponding_th.style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(total < 1) continue;
|
|
|
|
|
|
|
|
temp[f+1]="<td style=' background:#7f8fa6; color: #ffffff;'>"+total+"</td>";;
|
|
|
|
|
|
|
|
total=0;
|
|
|
|
|
|
|
|
$('#tabcenter').append("<tr>"+temp.toString()+"</tr>");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var result = <?php echo json_encode($result); ?>;
|
|
|
|
|
|
|
|
loadTable(convertArray(result));
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|