|
Server IP : 10.128.40.6 / Your IP : 216.73.217.20 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/python/../ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
// $from = '2020-04-01';
// $to = '2020-04-01';
// exit();2557
// phpinfo();
// exit() ;
function calcul_duree_faurma($dureD ,$dureF)
{
$h_fin = substr($dureF, 0, 2);
$m_fin = substr($dureF, 2,2);
$h_deb = substr($dureD, 0, 2);
$m_deb = substr($dureD, 2,2);
if ( ! isset ( $h_fin ) ) {
$presta_Hduree = 0;
} else {
$endmins = ( 60 * (int) ( $h_fin ) ) + $m_fin;
$startmins = ( 60 * $h_deb ) + $m_deb;
$presta_Hduree = $endmins - $startmins;
}
if ( $presta_Hduree < 0 ) {
$presta_Hduree = 0;
}
return $presta_Hduree ;
}
$_GET['salarie_id'] = 2898 ;
$_GET['date'] = '2023-11-01' ;
if(isset($_GET['salarie_id']))
$salarie_id = $_GET['salarie_id'];
else
$salarie_id = 2722;
$TMCPROCLIENTID = 10824;
function count_week_days($__date_from, $__date_to, $__holidays_between=array(), $__weekend_days=array()) {
$total_days_count = $__date_to > $__date_from ? round(($__date_to - $__date_from)/(24*3600)) : 0;
$full_weeks_count = floor($total_days_count/7);
$weekend_days_count = $full_weeks_count*count($__weekend_days);
$days_left_uncovered = $total_days_count - $full_weeks_count*7;
for($i = 0; $i < $days_left_uncovered; $i++) {
$date_to_check = $i ? strtotime("+{$i} day", $__date_from) : $__date_from;
if(in_array(date('N', $date_to_check), $__weekend_days)) {
$weekend_days_count++;
}
}
$week_days_count = $total_days_count - $weekend_days_count - count($__holidays_between);
return $week_days_count;
}
function type_pre_GET ($value =12)
{
$tab = array(10 => 'Viste medicale', 11 => 'Entretien', 12 => 'Autre ');
return $tab[$value] ;
}
function convertToHoursMins($time, $format = '%02d:%02d') {
if ($time < 1) {
return;
}
$hours = floor($time / 60);
$minutes = ($time % 60);
return sprintf($format, $hours, $minutes);
}
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$req_sal=dbi_query("SELECT * FROM `salarie` WHERE `salarie_statut` = '1' ") ;
$temp_in = 0 ;
while( $res_sal =dbi_fetch_row($req_sal)){
echo "==> $temp_in <br/>" ;
$salarie_id = $res_sal['salarie_id'] ;
$etablissement_id = $res_sal['etablissement_id'] ;
// echo "==jj>".$etablissement_id."<br>" ;
if(isset($_GET['date'])){
$data = array();
$now = new DateTime();
$start = dateformaint($_GET['date']);
$end = date("Ymt", strtotime($_GET['date']));
// $end = $now -> format('Ymt');
$date = $start ;
$i=0 ;
while ($date <= $end )
{
$q = dbi_query("
SELECT * FROM PRESTATIONS p where presta_date_debut <= $date AND (p.presta_date_fin >= $date OR p.presta_date_fin IS NULL)
AND ( p.presta_id IN (select presta_id FROM PRESTATIONS WHERE salarie_id = $salarie_id ) OR p.presta_id IN ( select presta_id FROM PRESTATIONS_MODIF WHERE salarie_id = $salarie_id ) )
AND ( p.presta_recur IS NULL OR p.presta_recur NOT IN ( SELECT presta_id FROM PRESTATIONS where presta_date_fin < $date ) )
");
while($prest = dbi_fetch_row($q))
{
$date_presta_sem = $prest['presta_date_debut'] ;
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest['presta_id']." order by start, modif_id ") ;
while (($m = dbi_fetch_row($q1)) && $date >= $m['start'])
{
// if( $m['presta_sem'] != NULL ) $date_presta_sem = $m['start'];
if( $prest['presta_sem'] > 1 ) {
if($m['presta_jour'] !== NULL && $date >= $m['start']) {
$date_presta_sem = $m['start'];
$date_presta_sem = date("Ymd", strtotime('monday this week', strtotime(int2date_autre_format($date_presta_sem))));
}
}
$prest['salarie_id'] = $m['salarie_id'] === NULL ? $prest['salarie_id'] : $m['salarie_id'] ;
$prest['presta_sem'] = $m['presta_sem'] === NULL ? $prest['presta_sem'] : $m['presta_sem'] ;
$prest['presta_jour'] = $m['presta_jour'] === NULL ? $prest['presta_jour'] : $m['presta_jour'] ;
$prest['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $prest['presta_Hdeb'] : $m['presta_Hdeb'] ;
$prest['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $prest['presta_Hduree'] : $m['presta_Hduree'] ;
$prest['chantier_id'] = $m['chantier_id'] === NULL ? $prest['chantier_id'] : $m['chantier_id'] ;
$prest['presta_forfait'] = $m['presta_forfait'] === NULL ? $prest['presta_forfait'] : $m['presta_forfait'] ;
}
if( $prest['salarie_id'] == $salarie_id ) {
$day = date("w", strtotime( int2date_autre_format($date)));
// if( $day == $prest['presta_jour']){
if( $day == $prest['presta_jour'] OR ( $date == $prest['presta_date_debut'] && $prest['presta_date_debut'] == $prest['presta_date_fin'] ) ){
// $istart = str_pad($prest['presta_Hdeb'] / 10000 , 2, '0', STR_PAD_LEFT) ;
$hstart = str_pad((int)($prest['presta_Hdeb'] / 10000) , 2, '0', STR_PAD_LEFT) ;
// $hstart = str_pad(round($prest['presta_Hdeb'] / 10000, 0) , 2, '0', STR_PAD_LEFT) ;
$mstart = str_pad(($prest['presta_Hdeb'] % 10000)/100 , 2, '0', STR_PAD_LEFT);
$hend = str_pad(round(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']) / 10000, 0) , 2, '0', STR_PAD_LEFT) ;
$mend = str_pad((addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']) % 10000)/100 , 2, '0', STR_PAD_LEFT);
$istart = int2date_autre_format($date).' '.$hstart.':'.$mstart.':00';
$iend = int2date_autre_format($date).' '.$hend.':'.$mend.':00';
$EXP = dbi_fetch_row(dbi_query("SELECT date_presta FROM EXCEPTIONS WHERE presta_id = ".$prest['presta_id']." AND date_presta = ".$date." " )) ; ;
if($EXP ){} else {
if( $prest['presta_sem'] == 1 )
{
$Clt = dbi_fetch_row(dbi_query("SELECT * FROM client WHERE client_id = ".$prest['client_id'] ." " )) ;
$data[$i]['id'] = $prest["presta_id"];
if($prest['client_id'] == $TMCPROCLIENTID)
$data[$i]['title'] = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$prest['prestation_motif'];
else
$data[$i]['title'] = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$Clt["client_nom"];
// $data[$i]['title'] = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$Clt["client_nom"];
$data[$i]['start'] = $istart;
$data[$i]['end'] = $iend;
$data[$i]['date'] = $date;
if( $prest['presta_date_debut'] == $prest['presta_date_fin'] )
{
if( $prest['prestation_type'] == 1 ){
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#007bf';
$data[$i]['textColor'] = '#007bf';
}
else if( $prest['prestation_type'] == 2 )
{
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#28a745';
$data[$i]['textColor'] = '#28a745';
}
else if( $prest['prestation_type'] == 3 )
{
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#ffc107';
$data[$i]['textColor'] = '#ffc107';
}
else if( $prest['prestation_type'] == 5 ){
$data[$i]['backgroundColor'] = '#C0392B';
$data[$i]['borderColor'] = '#C0392B';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 6 ){
$data[$i]['backgroundColor'] = '#8E44AD';
$data[$i]['borderColor'] = '#8E44AD';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 8 ){
$data[$i]['backgroundColor'] = '#0AF3D7';
$data[$i]['borderColor'] = '#0AF3D7';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 9 ){
$data[$i]['backgroundColor'] = '#FFA07A';
$data[$i]['borderColor'] = '#FFA07A';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 10 ){
$data[$i]['backgroundColor'] = '#A9CCE3';
$data[$i]['borderColor'] = '#A9CCE3';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 10 ){
$data[$i]['backgroundColor'] = '#A9CCE3';
$data[$i]['borderColor'] = '#A9CCE3';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 13 ){ // type ==> autre prestation spécifique
$data[$i]['backgroundColor'] = '#FF33AC';
$data[$i]['borderColor'] = '#FF33AC';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 14 ){ // type ==> trajet
$data[$i]['backgroundColor'] = '#86FF33';
$data[$i]['borderColor'] = '#86FF33';
$data[$i]['textColor'] = '#000000';
}
else if( $prest['prestation_type'] == 15 ){ // type ==> bureau
$data[$i]['backgroundColor'] = '#DAF7A6';
$data[$i]['borderColor'] = '#DAF7A6';
$data[$i]['textColor'] = '#000000';
}
else
{
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#e83e8c';
$data[$i]['textColor'] = '#e83e8c';
}
}
else
{
if( $prest['prestation_type'] == 1 ){
$data[$i]['backgroundColor'] = '#007bf';
$data[$i]['borderColor'] = '#007bf';
}
else if( $prest['prestation_type'] == 2 )
{
$data[$i]['backgroundColor'] = '#28a745';
$data[$i]['borderColor'] = '#28a745';
}
else if( $prest['prestation_type'] == 3 )
{
$data[$i]['backgroundColor'] = '#ffc107';
$data[$i]['borderColor'] = '#ffc107';
}
else
{
$data[$i]['backgroundColor'] = '#e83e8c';
$data[$i]['borderColor'] = '#e83e8c';
}
}
// $data[$i]['textEscape'] = false ;
// $data[$i]['backgroundColor'] = '#00a65a';
// $data[$i]['backgroundColor'] = '#00a65a';
// backgroundColor: '#00a65a', //Success (green)
// borderColor : '#00a65a' //Success (green)
++$i;
}
else
{
$nbre =count_week_days(strtotime(int2date_autre_format($date_presta_sem,'d.m.Y')), strtotime(int2date_autre_format($date,'d.m.Y')));
// $nbre = dateDifference(int2date_autre_format($date_presta_sem,'m/d/Y'),int2date_autre_format($date,'m/d/Y'));
$modolo = $nbre % $prest['presta_sem'] ;
// ECHO $modolo.' ------> '.$date_presta_sem.' ****** '.$date.' $$$ '.$nbre.'<br>';
if( $modolo == 0) {
$Clt = dbi_fetch_row(dbi_query("SELECT * FROM client WHERE client_id = ".$prest['client_id'] ." " )) ;
$data[$i]['id'] = $prest["presta_id"];
if($prest['client_id'] == $TMCPROCLIENTID)
$data[$i]['title'] = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$prest['prestation_motif'];
else
$data[$i]['title'] = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$Clt["client_nom"]." ".$chain_information;
$data[$i]['start'] = $istart;
$data[$i]['end'] = $iend;
$data[$i]['date'] = $date;
if( $prest['presta_date_debut'] == $prest['presta_date_fin'] )
{
if( $prest['prestation_type'] == 1 ){
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#007bf';
$data[$i]['textColor'] = '#007bf';
}
else if( $prest['prestation_type'] == 2 )
{
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#28a745';
$data[$i]['textColor'] = '#28a745';
}
else if( $prest['prestation_type'] == 3 )
{
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#ffc107';
$data[$i]['textColor'] = '#ffc107';
}
else
{
$data[$i]['backgroundColor'] = '#ffffff';
$data[$i]['borderColor'] = '#e83e8c';
$data[$i]['textColor'] = '#e83e8c';
}
}
else
{
if( $prest['prestation_type'] == 1 ){
$data[$i]['backgroundColor'] = '#007bf';
$data[$i]['borderColor'] = '#007bf';
}
else if( $prest['prestation_type'] == 2 )
{
$data[$i]['backgroundColor'] = '#28a745';
$data[$i]['borderColor'] = '#28a745';
}
else if( $prest['prestation_type'] == 3 )
{
$data[$i]['backgroundColor'] = '#ffc107';
$data[$i]['borderColor'] = '#ffc107';
}
else
{
$data[$i]['backgroundColor'] = '#e83e8c';
$data[$i]['borderColor'] = '#e83e8c';
}
}
++$i;
}
}
}
}
}
// echo date("Ymd", strtotime( int2date_autre_format($date))).' !! '.$prest['presta_id'].' $$ '.$prest['presta_jour'].'<br>';
}
// $date = time2int($time) ;
$date = date("Ymd", strtotime("+1 day", strtotime($date)));
}
// $qabs= dbi_query("SELECT * FROM salarie_absence
// where salarie_id = ".$salarie_id) ;
// while ($Labs = dbi_fetch_row($qabs))
// {
// $descabs = dbi_query("SELECT absence_type_description FROM absence_type where absence_type_id ='".$Labs['absence_type_id']."'");
// $motif = dbi_fetch_row($descabs) ;
// $data[$i]['id'] = $Labs["salarie_absence_id"];
// if(empty($Labs["salarie_absence_date_fin"]) OR $Labs["salarie_absence_date_fin"] ==0)
// {
// $data[$i]['title'] = $motif['absence_type_description'].' : '.int2date_autre_format($Labs["salarie_absence_date_debut"],'d/m/Y').' - Pas de Date Fin' ;
// $data[$i]['end'] = int2date_autre_format($end).' 18:00:00';
// }
// else
// {
// $data[$i]['title'] = $motif['absence_type_description'].' : '.int2date_autre_format($Labs["salarie_absence_date_debut"],'d/m/Y').' - '.int2date_autre_format($Labs["salarie_absence_date_fin"],'d/m/Y') ;
// $data[$i]['end'] = int2date_autre_format($Labs["salarie_absence_date_fin"]).' '.$Labs["salarie_absence_heure_fin"].':00';
// }
// $data[$i]['start'] = int2date_autre_format($Labs["salarie_absence_date_debut"]).' '.$Labs["salarie_absence_heure_debut"].':00';
// $data[$i]['date'] = int2date_autre_format($Labs["salarie_absence_date_debut"]);
// $data[$i]['backgroundColor'] = '#C0C0C0';
// $data[$i]['borderColor'] = '#C0C0C0';
// ++$i;
// }
$taille = count($data) ;
// echo "==> $taille <br>" ;
echo "<pre>" ;
print_r($data) ;
echo "</pre>" ;
for($i=0 ; $i<$taille ; $i++)
{
// echo "==> ".$data[$i]['id']." <br>" ;
// echo "==> ".$data[$i]['start']." <br>" ;
$date_jour = substr($data[$i]['start'], 0, -9);
// echo "==> ".$date_jour." <br>" ;
$date_jour_f=dateformaint($date_jour) ;
// echo "==> ".$date_jour_f." <br>" ;
$heure_debut = substr($data[$i]['start'], 11, 8);
// echo "==> ".$heure_debut." <br>" ;
$heure_debut_f = heure2int_faurmat($heure_debut) ;
// echo "===KK====> ".$heure_debut_f." <br>" ;
$heure_fin = substr($data[$i]['end'], 11, 8);
// echo "==> ".$heure_fin." <br>" ;
$heure_fin_f = heure2int_faurmat($heure_fin) ;
// echo "=====JJ==> ".$heure_fin_f." <br>" ;
$duree = calcul_duree_faurma($heure_debut_f,$heure_fin_f) ;
// echo "$heure_debut_f========$heure_fin_f=======OOOOO>".$duree."<br>" ;
// $heure_fin_f = heure2int_faurmat($heure_fin) ;
// echo "=======> ".$heure_fin_f." <br>" ;
$temp_in ++ ;
dbi_query("INSERT INTO `prestation_jour` (`prestation_jour_id`, `salarie_id`, `date_jour`, `date_jour_f`, `heure_debut`, `heure_fin`, `duree`, `heure_debut_f`, `heure_fin_f` ,etablissement_id )
VALUES (NULL, '$salarie_id', '$date_jour', '$date_jour_f', '$heure_debut', '$heure_fin', '$duree', '$heure_debut_f', '$heure_fin_f' , '$etablissement_id')") ;
}
// echo "<pre>" ;
// print_r($data) ;
// echo "</pre>" ;
// $a = dbi_query("SELECT * FROM `disponibilite` ORDER BY `disponibilite_id` DESC") ;
// while($res = dbi_fetch_row($a)){
/******************************* update absence *****************************************/
// $req3=dbi_query("SELECT * FROM `salarie_absence`") ;
// while($res3=dbi_fetch_row($req3)){
// $start_absence = int2date_autre_format($res3['salarie_absence_date_debut'])." ".$res3['salarie_absence_heure_debut'].":00" ;
// $end_absence = int2date_autre_format($res3['salarie_absence_date_fin'])." ".$res3['salarie_absence_heure_fin'].":00" ;
// dbi_query("UPDATE `salarie_absence` SET `start_absence` = '".$start_absence."', `end_absence` = '".$end_absence."' WHERE `salarie_absence`.`salarie_absence_id` = ".$res3['salarie_absence_id']) ;
// echo "D==>".$start_absence."<br/>" ;
// echo "F==>".$end_absence."<br/>" ;
// }
/******************************* fin *****************************************/
$a = dbi_query("SELECT * FROM `disponibilite` ORDER BY `disponibilite_id` DESC") ;
while($res = dbi_fetch_row($a)){
$heure_deb = substr($res['disponibilite_heurs_debu'] , 11, 8);
$heure_fin = substr($res['disponibilite_heurs_fin'], 11, 8);
echo " $heure_deb ===> $heure_fin <br>" ;
switch ($res['disponibilite_jour']) {
case 'Lundi':
$day_availability = 'monday' ;
break;
case 'Mardi':
$day_availability = 'tuesday' ;
break;
case 'Mercredi':
$day_availability = 'wednesday' ;
break;
case 'Jeudi':
$day_availability = 'thursday' ;
break;
case 'Vendredi':
$day_availability = 'friday' ;
break;
case 'Samedi':
$day_availability = 'saturday' ;
break;
case 'Dimanche':
$day_availability = 'sunday' ;
break;
}
dbi_query("UPDATE `disponibilite` SET `day_availability` = '$day_availability' , `heure_deb` = '$heure_deb', `heure_fin` = '$heure_fin' WHERE `disponibilite`.`disponibilite_id` = ".$res['disponibilite_id']) ;
}
// echo json_encode($data);
}}
?>
