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

1134 lines
18 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 = getResultatVMSpecialite($year,$roleid,$sql);
echo getMonitoringMainBar(2,$roleid).getMonitoringVisiteSubBar(4,$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 sp&#233;cialit&#233; en', $year, true).
'<hr>
<div class="form-row">
<div class="form-group col-md-6">
<label for="Specialite">Sp&#233;cialit&#233;</label>
<input class="form-control mb-4 w-20" type="text" name="Specialite" placeholder="Rechercher" onKeyUp="SpecialiteFiltre(this)">
</div>
'.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');
?>
<div class="modal fade" id="graphicalModal">
<div class="modal-dialog modal-lg" >
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" >Nombre de visites par spécialité</h4>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody" style="overflow:auto;">
<div id="chart1" style="height: 400px; position: relative;" ></div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
var region =<?php echo json_encode($region); ?>;
document.getElementById("region").selected = true;
var pharmacies = [];
function convertArray(data) {
var a=[];
var c=[];
if(data.length > 0) {
pharmacies = [0,0,0,0,0,0,0,0,0,0,0,0,0];
for(var i = 0; i < data.length; i++){
var row = data[i];
if ( row['accounttypeid'] != 11 && row['accounttypeid'] != 12 ){ // Éliminer=> Pharmacie hospitalière and Pharmacie
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[0]);
b[0]=row[0];
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[0]);
b[0]=row[0];
c[a.length-1]=b;
}
}else{
if(row['month'] !== null && row['nbr'] !== null)
pharmacies[row['month']] = pharmacies[row['month']]+parseInt(row['nbr']);
}
}
}
return c
}
//filtre
function SpecialiteFiltre(e) {
var res = result.filter(a => a.accounttype.toUpperCase().includes(e.value.toUpperCase()) );
loadTable(convertArray(res));
}
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 = "";
var ligneTotal = row[1]+row[2]+row[3]+row[4]+row[5]+row[6]+row[7]+row[8]+row[9]+row[10]+row[11]+row[12];
if(ligneTotal < 1) continue;
$('#tabcenter').append(
"<tr class='center borderline'"+click+">"
+"<td >"+row[0]+"</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>
<script>
// code for chart
function DisplayBarChart(data,accounttype) {
var c=[];
$.jqplot.config.enablePlugins = true;
var ticks = ['janvier','février','mars','avril','mai','juin', 'juillet','août','septembre','octobre','novembre','décembre'];
var maxValue=Math.max.apply(null, data);
for(var i = 0; i < data.length; i++){
var a=[];
a[0]=ticks[i];
a[1]=parseInt(data[i]);
c[i]=a;
}
var plot3 = $.jqplot('chart1', [c], {
title: this.title='<h4>'+accounttype+'<h4>',
seriesDefaults: {
renderer: $.jqplot.PieRenderer,
rendererOptions: {
showDataLabels: true,
padding: 10,
sliceMargin: 6,
shadow: false,
dataLabelPositionFactor: 0.75
}
},
legend: {
show: true,
location: 's',
fontSize: '10pt',
rendererOptions: {
numberRows: 1
}
},
highlighter: {
show: true,
useAxesFormatters: false,
tooltipFormatString: '%s',
}
});
}
// get selected row values of table for chart
document.querySelector("#tabcenter").addEventListener("click",event => {
var data=[];
let dataTr = event.target.parentNode;
let dataRes = dataTr.querySelectorAll("td")[0].innerText;
var accounttype = dataTr.querySelectorAll("td")[0].innerText;//get name of accounttype
for (var x = 0; x < 12; x++) {
data[x] = dataTr.querySelectorAll("td")[x+1].innerText;
}
const reducer = (accumulator, currentValue) => accumulator + currentValue; //calculate sum of array
if(data.reduce(reducer) > 0){
$("#graphicalModal").modal(); // Launch modal bootstrap
$('#graphicalModal').on('shown.bs.modal', function () {
$("#chart1").empty(); //empty the old chart
DisplayBarChart(data,accounttype);
})
}
});
</script>
<style>
#scrollbar::-webkit-scrollbar {
width: 10px;
height: 10px;
}
#scrollbar::-webkit-scrollbar-thumb {
background: #aaa;
border-radius: 10px;
}
#scrollbar::-webkit-scrollbar-track {
background: #F0F0F0;
border-radius: 10px;
}
#scrollbar::-webkit-scrollbar-thumb:horizontal:hover,
#scrollbar::-webkit-scrollbar-thumb:vertical:hover {
background: #999999;
border-radius: 10px;
}
//jquery.jqplot.css
/*rules for the plot target div. These will be cascaded down to all plot elements according to css rules*/
.jqplot-target {
position: relative;
color: #666666;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1em;
/* height: 300px;
width: 400px;*/
}
/*rules applied to all axes*/
.jqplot-axis {
font-size: 0.75em;
}
.jqplot-xaxis {
margin-top: 10px;
}
.jqplot-x2axis {
margin-bottom: 10px;
}
.jqplot-yaxis {
margin-right: 10px;
}
.jqplot-y2axis,
.jqplot-y3axis,
.jqplot-y4axis,
.jqplot-y5axis,
.jqplot-y6axis,
.jqplot-y7axis,
.jqplot-y8axis,
.jqplot-y9axis,
.jqplot-yMidAxis {
margin-left: 10px;
margin-right: 10px;
}
/*rules applied to all axis tick divs*/
.jqplot-axis-tick,
.jqplot-xaxis-tick,
.jqplot-yaxis-tick,
.jqplot-x2axis-tick,
.jqplot-y2axis-tick,
.jqplot-y3axis-tick,
.jqplot-y4axis-tick,
.jqplot-y5axis-tick,
.jqplot-y6axis-tick,
.jqplot-y7axis-tick,
.jqplot-y8axis-tick,
.jqplot-y9axis-tick,
.jqplot-yMidAxis-tick {
position: absolute;
white-space: pre;
}
.jqplot-xaxis-tick {
top: 0px;
/* initial position untill tick is drawn in proper place */
left: 15px;
/* padding-top: 10px;*/
vertical-align: top;
}
.jqplot-x2axis-tick {
bottom: 0px;
/* initial position untill tick is drawn in proper place */
left: 15px;
/* padding-bottom: 10px;*/
vertical-align: bottom;
}
.jqplot-yaxis-tick {
right: 0px;
/* initial position untill tick is drawn in proper place */
top: 15px;
/* padding-right: 10px;*/
text-align: right;
}
.jqplot-yaxis-tick.jqplot-breakTick {
right: -20px;
margin-right: 0px;
padding: 1px 5px 1px 5px;
/* background-color: white;*/
z-index: 2;
font-size: 1.5em;
}
.jqplot-y2axis-tick,
.jqplot-y3axis-tick,
.jqplot-y4axis-tick,
.jqplot-y5axis-tick,
.jqplot-y6axis-tick,
.jqplot-y7axis-tick,
.jqplot-y8axis-tick,
.jqplot-y9axis-tick {
left: 0px;
/* initial position untill tick is drawn in proper place */
top: 15px;
/* padding-left: 10px;*/
/* padding-right: 15px;*/
text-align: left;
}
.jqplot-yMidAxis-tick {
text-align: center;
white-space: nowrap;
}
.jqplot-xaxis-label {
margin-top: 10px;
font-size: 11pt;
position: absolute;
}
.jqplot-x2axis-label {
margin-bottom: 10px;
font-size: 11pt;
position: absolute;
}
.jqplot-yaxis-label {
margin-right: 10px;
/* text-align: center;*/
font-size: 11pt;
position: absolute;
}
.jqplot-yMidAxis-label {
font-size: 11pt;
position: absolute;
}
.jqplot-y2axis-label,
.jqplot-y3axis-label,
.jqplot-y4axis-label,
.jqplot-y5axis-label,
.jqplot-y6axis-label,
.jqplot-y7axis-label,
.jqplot-y8axis-label,
.jqplot-y9axis-label {
/* text-align: center;*/
font-size: 11pt;
margin-left: 10px;
position: absolute;
}
.jqplot-meterGauge-tick {
font-size: 0.75em;
color: #999999;
}
.jqplot-meterGauge-label {
font-size: 1em;
color: #999999;
}
table.jqplot-table-legend {
margin-top: 12px;
margin-bottom: 12px;
margin-left: 12px;
margin-right: 12px;
}
table.jqplot-table-legend,
table.jqplot-cursor-legend {
background-color: rgba(255, 255, 255, 0.6);
border: 1px solid #cccccc;
position: absolute;
font-size: 0.75em;
}
td.jqplot-table-legend {
vertical-align: middle;
}
/*
These rules could be used instead of assigning
element styles and relying on js object properties.
*/
/*
td.jqplot-table-legend-swatch {
padding-top: 0.5em;
text-align: center;
}
tr.jqplot-table-legend:first td.jqplot-table-legend-swatch {
padding-top: 0px;
}
*/
td.jqplot-seriesToggle:hover,
td.jqplot-seriesToggle:active {
cursor: pointer;
}
.jqplot-table-legend .jqplot-series-hidden {
text-decoration: line-through;
}
div.jqplot-table-legend-swatch-outline {
border: 1px solid #cccccc;
padding: 1px;
}
div.jqplot-table-legend-swatch {
width: 0px;
height: 0px;
border-top-width: 5px;
border-bottom-width: 5px;
border-left-width: 6px;
border-right-width: 6px;
border-top-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-right-style: solid;
}
.jqplot-title {
top: 0px;
left: 0px;
padding-bottom: 0.5em;
font-size: 1.2em;
}
table.jqplot-cursor-tooltip {
border: 1px solid #cccccc;
font-size: 0.75em;
}
.jqplot-cursor-tooltip {
border: 1px solid #cccccc;
font-size: 0.75em;
white-space: nowrap;
background: rgba(208, 208, 208, 0.5);
padding: 1px;
}
.jqplot-highlighter-tooltip,
.jqplot-canvasOverlay-tooltip {
border: 1px solid #cccccc;
font-size: 0.75em;
white-space: nowrap;
background: rgba(208, 208, 208, 0.5);
padding: 1px;
}
.jqplot-point-label {
font-size: 0.75em;
z-index: 2;
}
td.jqplot-cursor-legend-swatch {
vertical-align: middle;
text-align: center;
}
div.jqplot-cursor-legend-swatch {
width: 1.2em;
height: 0.7em;
}
.jqplot-error {
/* Styles added to the plot target container when there is an error go here.*/
text-align: center;
}
.jqplot-error-message {
/* Styling of the custom error message div goes here.*/
position: relative;
top: 46%;
display: inline-block;
}
div.jqplot-bubble-label {
font-size: 0.8em;
/* background: rgba(90%, 90%, 90%, 0.15);*/
padding-left: 2px;
padding-right: 2px;
color: rgb(20%, 20%, 20%);
}
div.jqplot-bubble-label.jqplot-bubble-label-highlight {
background: rgba(90%, 90%, 90%, 0.7);
}
div.jqplot-noData-container {
text-align: center;
background-color: rgba(96%, 96%, 96%, 0.3);
}
</style>
</body>
</html>