|
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/www/../../TMCPRO/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include_once 'code/init.php';
$_GET['date'] = '2024-04-08';
error_reporting(E_ALL);
ini_set("display_errors", 1);
function dateformaint ($yass)
{
$jour = substr($yass,8,2);
$mois = substr($yass,5,2);
$annee = substr($yass,0,4);
return date('Ymd', mktime(0,0,0,$mois, $jour, $annee)) ;
}
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 prestation 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 prestation WHERE salarie_id = $salarie_id ) OR p.presta_id IN ( select presta_id FROM presta_modif WHERE salarie_id = $salarie_id ) )
AND ( p.presta_recur IS NULL OR p.presta_recur NOT IN ( SELECT presta_id FROM prestation where presta_date_fin < $date ) )
");
while($prest = dbi_fetch_row($q))
{
$date_presta_sem = $prest['presta_date_debut'] ;
$q1 = dbi_query("SELECT * FROM presta_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))));
}
}
// bug nbr
if( $m['presta_sem'] != NULL ) $date_presta_sem = $m['start']; // bug nbr
$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'] ;
}
// // bug nbr : had la ligne li tla3t men taht
// $nbre =count_week_days(strtotime(int2date_autre_format($date_presta_sem,'d.m.Y')), strtotime(int2date_autre_format($date,'d.m.Y')));
$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';
}
}
print_r($prest) ;
$date = date("Ymd", strtotime("+1 day", strtotime($date)));
}
}
exit() ;
// ini_set('display_errors','on');
// error_reporting(E_ALL);
// echo "---$agence <br/>" ;
// echo "---->$agence <br/>" ;
// echo "<pre>" ;
// print_r($_POST);
// echo "<pre>" ;
if($agence==9)
{
echo "." ;
}
if (isset($_POST['fromday'], $_POST['frommonth'], $_POST['fromyear'], $_POST['today'], $_POST['tomonth'], $_POST['toyear'], $_POST['client_id']))
{
$au1 = sprintf("%04d%02d%02d", $_POST['factyear'], $_POST['factmonth'], $_POST['factday']) ;
include 'includes/factureV3.php' ;
$factures = array() ;
$from = sprintf("%04d%02d%02d", $_POST['fromyear'], $_POST['frommonth'], $_POST['fromday']) ;
$to = sprintf("%04d%02d%02d", $_POST['toyear'], $_POST['tomonth'], $_POST['today']) ;
$au = sprintf("%02d/%02d/%04d", $_POST['factday'], $_POST['factmonth'], $_POST['factyear']) ;
$textf=$_POST['textf'];
// Com : ne pas prendre en compte les factures envoy�es par mail
$nb_prev=0;
$cumul = $_POST['cumul']=="ok";
foreach($_POST['client_id'] as $client_id)
{
if (!is_dir("factures"))
{
mkdir("factures", 0755) ;
chmod("factures", 0755) ;
}
if (!is_dir("factures/$client_id"))
{
mkdir("factures/$client_id", 0755) ;
chmod("factures/$client_id", 0755) ;
}
if (!is_dir("factures/$client_id/prev"))
{
mkdir("factures/$client_id/prev", 0755) ;
chmod("factures/$client_id/prev", 0755) ;
}
$prev=false;
$chemFact="factures/$client_id/";
// on rajoute un param�tre pour une �ventuelle pr�visualisation
if( isset($_POST['Prev']) )
{
$prev=true;
$chemFact="factures/$client_id/prev/";
}
if ($fact_id = creerFacture($client_id,0,$from,$to,$f,$au, $_POST['fact_format'], $prev, $cumul, $nb_prev, $textf)) {
//$f = utf8_decode($f);
//$f = iconv('UTF-8', 'windows-1252', $f);
// exit(creerEntete ($client_id, $from, $au, $f));
$s = $f->Output('','S');
switch($_POST['fact_email']) {
case 'immediat-nopapier':
$email = dbi_fetch_row(dbi_query("SELECT client_email, client_fmail FROM ".TABLE_CLIENT." WHERE client_id='$client_id' AND agence_id = '$agence'")) ;
if($email['client_email']!='' && $email['client_fmail']=='1' && !$prev) {
dbi_query("UPDATE ".TABLE_FACT." f SET email_envoye=email_envoye+1 WHERE f.agence_id='$agence' AND f.fact_id='$fact_id'");
envoyer_email('facture',$fact_id,$s);
} else {
$f->Output($chemFact.$fact_id.".pdf", 'F') ;
$factures[] = $chemFact.$fact_id.".pdf" ;
}
break;
case 'immediat-papier':
$email = dbi_fetch_row(dbi_query("SELECT client_email, client_fmail FROM ".TABLE_CLIENT." WHERE client_id='$client_id' AND agence_id = '$agence'")) ;
if($email['client_email']!='' && $email['client_fmail']=='1' && !$prev) {
dbi_query("UPDATE ".TABLE_FACT." f SET email_envoye=email_envoye+1 WHERE f.agence_id='$agence' AND f.fact_id='$fact_id'");
envoyer_email('facture',$fact_id,$s);
}
$f->Output($chemFact.$fact_id.".pdf", 'F') ;
$factures[] = $chemFact.$fact_id.".pdf" ;
break;
case 'nopapier':
//rien pour cette facture...
break;
case 'papier':
$f->Output($chemFact.$fact_id.".pdf", 'F') ;
$factures[] = $chemFact.$fact_id.".pdf" ;
break;
}
}
$nb_prev++;
}
// if($agence == 9)
// {
// echo "" ;
// }
$fichier_pdf = "factures/$agence-".date('d-m-Y-H:i').".pdf";
pdf_concatene($factures, $fichier_pdf) ;
print_header ();
?>
<fieldset>
<legend>Facture créés</legend>
<table class="td_normal">
<?php
$i = 0;
foreach ($factures as $f)
printf('<tr><td class="td_listing%2$d"><a href="%1$s" target="_blank">%1$s</a></td></tr>', $f, $i++ % 2);
printf('<tr><td class="td_listing%2$d"><a href="%1$s" target="_blank">%3$s</a></td></tr>', $fichier_pdf, $i++ % 2, 'Toutes les factures générées');
echo '</table></fieldset>';
}
function file_type($file){
$path_chunks = explode("/", $file);
$thefile = $path_chunks[count($path_chunks) - 1];
$dotpos = strrpos($thefile, ".");
return strtolower(substr($thefile, $dotpos + 1));
}
function get_agence($file){
$dotpos = strrpos($thefile, ".");
return strtolower(substr($thefile, $dotpos - 1));
}
$res = opendir("factures/");
?>
<fieldset><legend>Nouvelle facture</legend>
<form action="e.php" method="post">
<table>
<tr>
<td>Du : </td>
<td colspan="2"><?php print_date_selection('from', (isset($from)?$from:$fact_du))?></td>
</tr>
<tr>
<td>Au : </td>
<td colspan="2"><?php print_date_selection('to', (isset($to)?$to:$fact_au))?></td>
</tr>
<tr>
<td valign="top">Clients : </td>
<td valign="top"><?=get_clients_drop_down('client_id[]', 'multiple', @$_POST['client_id'], false, true, true) ?>
<?php
if (!isset($_POST['client_id']))
$_POST['client_id'] = array();
//$q = dbi_query("SELECT client_id id, concat(client_nom, ' ', client_pnom) civ FROM ".TABLE_CLIENT." WHERE agence_id=$agence ORDER BY client_nom") ;
?>
<?php /*?>Clients : </td>
<td valign="top"><select name="client_id[]" multiple="multiple" size="20" style="width:280px">
<?php
while($c = dbi_fetch_row($q))
printf('<option value="%s"%s>%s</option>', $c['id'], in_array($c['id'], $_POST['client_id']) ? ' selected' : '', $c['civ']) ;
?>
</select><?php */
?></td>
<td valign="top"><a onclick="var select = document.forms[0].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.forms[0].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>Date de facturation : </td>
<td colspan="2"><?php print_date_selection('fact', $fact_au)?></td>
</tr>
<tr><td>Format de la facture : </td>
<td><select name="fact_format" >
<option value="n" selected>Simplifié</option>
<option value="d" >Detaill�</option>
</select>
</td></tr>
<tr><td>Envoi des factures par email : </td>
<td><select name="fact_email" >
<option value="immediat-nopapier">Envoyer immédiatement - Ne pas générer la facture papier</option>
<option value="immediat-papier" selected>Envoyer immédiatement - Générer la facture papier</option>
<option value="nopapier" >Ne pas envoyer - Ne pas générer la facture papier</option>
<option value="papier" >Ne pas envoyer - Générer la facture papier</option>
</select>
</td>
<td> <div style="float:right;"><b> Imprimer les facture avec nouveau entete: </b>
<input type="checkbox" >
</div> </td>
</tr>
<tr><td>Texte : </td><td><textarea name="textf" cols="40" rows="4"></textarea></td></tr>
<tr><td></td><td><div style="float:right;"><b>Affichage cumul : </b>
<input type="checkbox" name="cumul" value="ok">
</div></td></tr>
<tr>
<td colspan="2" align="right">
<input type="submit" class="bigbutton" value="Créer" onClick="this.disabled=true;this.form.submit();">
<input type="submit" name="Prev" value="Prévisualiser" class="bigbutton">
</td>
<td> </td>
</tr>
</table>
</form>
</fieldset>
</body>
</html>
