Files
CRM/MonitoringVmTypeActivite.php
BACHIR SOULDI 2794e62571 first commit
2025-09-28 08:49:37 +01:00

157 lines
6.3 KiB
PHP

<?php
require_once 'MonitoringVMHeader.php';
require_once 'MonitoringDBRequest.php';
$sql="";
$region="All";
if(isOuestVMVP($roleid))
$region="OUEST";
else if(isEstVMVP($roleid))
$region="EST";
else if(isCentreVMVP($roleid))
$region="CENTRE";
if(isset($_POST['region'])){
$region = $_POST['region'];
switch ($region) {
case "All":
$sql="";
break;
case "OUEST":
$sql="and (ro.rolename='DIRECTEUR REGIONAL OUEST' or ro.rolename='SUPERVISEUR OUEST1' or ro.rolename='DELEGUE MEDICAL OUEST1' or ro.rolename='SUPERVISEUR OUEST2' or ro.rolename='DELEGUE MEDICAL OUEST2' or ro.rolename='DELEGUE MEDICAL OUEST')";
break;
case "CENTRE":
$sql="and (ro.rolename='DIRECTEUR REGIONAL CENTRE' or ro.rolename='SUPERVISEUR CENTRE1' or ro.rolename='DELEGUE MEDICAL CENTRE1' or ro.rolename='SUPERVISEUR CENTRE2' or ro.rolename='DELEGUE MEDICAL CENTRE2' or ro.rolename='DELEGUE MEDICAL CENTRE')";
break;
case "EST":
$sql="and (ro.rolename='DIRECTEUR REGIONAL EST' or ro.rolename='SUPERVISEUR EST1' or ro.rolename='DELEGUE MEDICAL EST1' or ro.rolename='SUPERVISEUR EST2' or ro.rolename='DELEGUE MEDICAL EST2' or ro.rolename='SUPERVISEUR EST3' or ro.rolename='DELEGUE MEDICAL EST3')";
break;
}
$year = $_POST['year'];
}
$result = getResultatVMTypeActivite($year,$roleid,$sql);
echo getMonitoringMainBar(2,$roleid).getMonitoringVisiteSubBar(3,$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 par Type d&#146;activité en', $year, true).
'<hr>
<div class="form-row">
'.getRegionSelectSubmit($roleid, true).'
</div>';
echo '<table id="tabcenter" class="table table-bordered table-striped" >
<tr class="center borderline">
<th id="Type" >Type d&#146;activité</th>
<th> janvier</th>
<th> février</th>
<th> mars</th>
<th>avril</th>
<th> mai</th>
<th>juin</th>
<th>juillet</th>
<th> août</th>
<th> septembre</th>
<th> octobre</th>
<th>novembre</th>
<th>décembre</th>
<th>Total</th>
</tr>
<tbody id="values"></tbody>
</table>
</div></div>';
$viewer->view('CustomDashboardFooter.tpl');
?>
<script>
var region =<?php echo json_encode($region); ?>;
document.getElementById("region").selected = true;
function convertArray(data) {
var a=[];
var c=[];
if(data.length > 0) {
for(var i = 0; i < data.length; i++){
var row = data[i];
if(row['activitytype'] == 'Mobile Call')
continue;
if(row['month'] !== null && row['nbr'] !== null){
if(a.indexOf(row[0]) == -1){
var b=[0,0,0,0,0,0,0,0,0,0,0,0,0];
a.push(row['activitytype']);
b[0]=row['activitytype'];
b[row['month']]=parseInt(row['nbr']);
c[a.length-1]=b;
} else{
b[row['month']]=parseInt(row['nbr']);
c[a.length-1]=b;
}
}else{
var b=[0,0,0,0,0,0,0,0,0,0,0,0,0];
a.push(row['activitytype']);
b[0]=row['activitytype'];
c[a.length-1]=b;
}
}
}
//console.log(c)
return c
}
function loadTable(data) {
$('#tabcenter tr').slice(1).remove();
if(data.length > 0) {
for(var i = 0; i < data.length; i++) {
var row = data[i];
var click = "";
$('#tabcenter').append(
"<tr class='center borderline'"+click+">"
+"<td >"+row[0].trim()+"</td>"
+"<td>"+row[1]+"</td>"
+"<td>"+row[2]+"</td>"
+"<td>"+row[3]+"</td>"
+"<td>"+row[4]+"</td>"
+"<td>"+row[5]+"</td>"
+"<td>"+row[6]+"</td>"
+"<td>"+row[7]+"</td>"
+"<td>"+row[8]+"</td>"
+"<td>"+row[9]+"</td>"
+"<td>"+row[10]+"</td>"
+"<td>"+row[11]+"</td>"
+"<td>"+row[12]+"</td>"
+"<td style=' background:#7f8fa6; color: #ffffff;'>"+(row[1]+row[2]+row[3]+row[4]+row[5]+row[6]+row[7]+row[8]+row[9]+row[10]+row[11]+row[12])+"</td>"
+"</tr>"
);
}
var totals = [];
var allTotals = 0;
for (var i = 1; i < 13; i++) {
var sum = 0;
for(var j = 0; j < data.length; j++) {
var row = data[j];
sum += row[i];
}
totals.push(sum);
allTotals += sum;
}
allTotals = parseInt(allTotals);
$('#tabcenter').append(
"<tfoot><tr class='center borderline'"+click+">"
+"<td style='font-weight:bold;'>TOTAL</td>"
+"<td style='font-weight:bold;'>"+totals[0]+"</td>"
+"<td style='font-weight:bold;'>"+totals[1]+"</td>"
+"<td style='font-weight:bold;'>"+totals[2]+"</td>"
+"<td style='font-weight:bold;'>"+totals[3]+"</td>"
+"<td style='font-weight:bold;'>"+totals[4]+"</td>"
+"<td style='font-weight:bold;'>"+totals[5]+"</td>"
+"<td style='font-weight:bold;'>"+totals[6]+"</td>"
+"<td style='font-weight:bold;'>"+totals[7]+"</td>"
+"<td style='font-weight:bold;'>"+totals[8]+"</td>"
+"<td style='font-weight:bold;'>"+totals[9]+"</td>"
+"<td style='font-weight:bold;'>"+totals[10]+"</td>"
+"<td style='font-weight:bold;'>"+totals[11]+"</td>"
+"<td style=' background:#7f8fa6; color: #ffffff; font-weight: bold;'>"+allTotals+"</td>"
+"</tr></tfoot>"
);
}
}
var result = <?php echo json_encode($result); ?>;
function loadByFullName() {
var fullnames = Array.prototype.slice.call(result).sort(function(a, b){
if(a.fullname < b.fullname) { return -1; }
if(a.fullname > b.fullname) { return 1; }
return 0;
});
loadTable(convertArray(fullnames));
}
loadByFullName();
</script>
</body>
</html>