AnonSec Team
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/MCPRO/js/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/MCPRO/js/../relancesuiv111111.php
<?php
exit() ; 
include_once 'code/init.php';
print_header ();
// echo "yaxxx <br/>" ; 
if(isset($_POST['tmp']))
{
// echo "----->".$_POST['tmp']."<br/>" ; 
// echo "----->".$_POST['fact']."<br/>" ; 

// echo "----->".$_POST['factcheck']."<br/>" ; 
	if (!is_dir("courrier"))
	{
		mkdir("courrier", 0777) ;
		chmod("courrier", 0777) ;
	}
	if (!is_dir("courrier/".$_POST['tmp']))
	{
		mkdir("courrier/".$_POST['tmp'], 0777) ;
		chmod("courrier/".$_POST['tmp'], 0777) ;
	}
	include_once 'includes/tmpp_pdf.php' ;

	if(isset($_POST['tmp'])) include 'template_CDD.php';

	$pdf = new Template ($lecontenu,$letitre,$lecour);

	$nompdf="yassinkom";
	$path = "courrier/".$_POST['tmp']."/".$nompdf.".pdf";

	$pdf->Output($path, 'F') ;
	
	
	
	 header("Content-disposition: attachment; filename=courrier/".$_POST['tmp']."/".$nompdf.".pdf" );
	//header("Content-Disposition: attachment;location:courrier/".$_POST['tmp']."/".$nompdf.".pdf" );
	header("Content-Type: application/force-download");
	header("Content-Transfer-Encoding: binary");
	header("location:courrier/".$_POST['tmp']."/".$nompdf.".pdf" );
	header("Content-Length: ".filesize($path));
	header("Pragma: no-cache");
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
	header("Expires: 0");
	// exit();
	//echo $path;
	 readfile($path);

	
	}
	echo " testo <br/>" ; 
	print_header ('','','style="margin-top:15px; padding:20px;"');
$ordre_nom="ASC";
	if(!empty($_GET['ordre_nom']) && $_GET['ordre_nom']=="ASC")
 {
 $ordre_nom="DESC";
 
 }
 	if(!empty($_GET['ordre_nom']) && $_GET['ordre_nom']=="DESC")
 {
 $ordre_nom="ASC";
 
 }
    function nbJours($debut, $fin) {
        // 60 secondes X 60 minutes X 24 heures dans une journée
        $nbSecondes= 60*60*24;
 
        $debut_ts = strtotime($debut);
        $fin_ts = strtotime($fin);
        $diff = $fin_ts - $debut_ts;
        return round($diff / $nbSecondes);
    }
function get_bureau_drop_down($name = '', $param = '', $value ='', $choose = 'auto')
{
	global $agence ;
	if(!is_array($value))
	$value = array($value) ;
	$ret = "<select onchange='GetIdBureau()'; name=\"$name\" $param>".((in_array('', $value) || in_array('0', $value)) && count($value) == 1 && $choose == 'auto' || $choose === true ? '<option value="" selected  style="font-weight:bold"></option>' : '') ;
	$q = dbi_query("SELECT * FROM bureau WHERE agence_id=".$agence." ORDER BY nom_agence") ;
	while($res = dbi_fetch_row($q)) {
		$ret .= sprintf('<option value="%s"%s>%s </option>', $res['id_bureau'], in_array($res['id_bureau'], $value) ? ' selected' : '', $res['nom_agence']) ;
	}
	return $ret."</select>" ;
}
$where2='';
if($_GET['id'] && !empty($_GET['id']) )
{
   if($_GET['id']>0)
	{
		$id=$_GET['id'];
		$tabbursel=dbi_fetch_row((dbi_query('select * from bureau where id_bureau='.$_GET['id'].' and agence_id='.$agence.''))) ;
		$id_bureau=$tabbursel['id_bureau'];
		$nom_bureau=$tabbursel['nom_agence'];
		$where1=" AND ID_Bureau != $id_bureau ";
		$where2=" AND client_bureau = $id_bureau ";
    }
	elseif($_GET['id']=="INDEFINI")
	{
	$id_bureau=$_GET['id'];
	$where2=" AND client_bureau='0' ";
	$selected='selected="selected"';
	}
}
$CA=0; // le chifre d'affaire , mais maintenant on affiche la somme des solde 
$solde_affiche_haut = 0 ;
$SO = 0 ;  
?>
<script language="Javascript">
   function GetIdBureau()
   {
		var id="";
  	  id = document.bureau_form.client_bureau.value ;
	if( id > 0 || id=="INDEFINI" )
	  window.location = "solde.php?id="+id;
	  	else
	window.location = "solde.php";
   }
</script>
 <style type="text/css">
div#hdp {
     border:1;
position:absolute;
     top:0;
     left:25px;
}
</style>
<br/>
<br/>
<br/>

<table style="position:absolute; top:35px;  right:20px;">
<form id="bureau_form" name="bureau_form" method="POST" action="suivreg.php">
		<tr>
				<td align="left" valign="top" class="td_listing0" >Bureau :</td>
				<td align="left" valign="top" class="td_listing0">
				<select id="client_bureau" name="client_bureau" onchange="GetIdBureau()";>
				<option selected="selected" value=""> TOUS </option>
				<?php if(isset($id_bureau) && isset($nom_bureau)) { ?>
						<option selected="selected" value="<?=$id_bureau ?>"><?=$nom_bureau?></option>
				<?php } ?>

					<?php 
							$Reqbureau=dbi_query("select * from bureau where agence_id=$agence $where1") or die(mysql_error());
							while($listbureau=dbi_fetch_row($Reqbureau)){ ?>
				<option value="<?php echo $listbureau['id_bureau']?>"><?php echo $listbureau['nom_agence'] ?></option>
							<?php } ?>
				<option <?=$selected ?> value="INDEFINI">INDEFINI</option>
				</select>
				  </td>
			</tr>
</form>
</table>
<div id="tab">
<!--
<table align="left"   >
        <tbody><tr>
          <TH align="center" ><A href="recouvrement.php?ordre_nom=<?php echo $ordre_nom?>"style="cursor:pointer; font-weight:bold;color: white; text-decoration:none;text-transform : uppercase;font-size: 14px;" >Nom client</A><SPAN class="sort">&uarr;</SPAN></TH>
		  <TH align="center" >Solde</TH>
		  <TH align="center" >Nombre de factures</TH>
          <TH align="center" >DERNIER PAIEMENT</TH>
          <TH align="center" >ERREUR REGLEMENT</TH>		
		  <TH align="center" >SUIVI</TH>
		  <TH align="center" >ADMIN</TH>
		  <TH align="center" >suive</TH>
		  </tr><tbody>
		  -->

<?php
$Client=array();
// echo "<pre>" ; 
// print_r($Client) ; 
// echo "</pre>" ; 

// echo "--------------------------------------------<br/>" ; 
$order='DESC ';
$query = dbi_query("SELECT f.client_id, client_pnom, client_nom, f.num_fact, c.client_reglement,
f.fact_id, total,total-sum(if(p.montant is null, 0, p.montant))-sum(if(a.montant is null, 0, a.montant)) AS paye,
if(a.montant is null, 0, a.montant) avoir,
f.date_fact, f.relance, IF(client_genre='SERENA',1,0) as serena
FROM ".TABLE_FACT." f
LEFT JOIN ".TABLE_PAIEMENT." p ON f.fact_id=p.fact_id AND f.client_id=p.client_id
LEFT JOIN ".TABLE_AVOIR." a ON f.fact_id = a.fact_id 
LEFT JOIN ".TABLE_CLIENT." c ON c.client_id = f.client_id
WHERE f.agence_id=$agence $where2
GROUP BY date_fact, f.fact_id, total
HAVING paye > 0.001
ORDER BY client_nom $order , client_pnom $order  , f.date_fact ASC ") ;
while($f = dbi_fetch_row($query))
	{
	$Client[$f['client_id']][]=$f;
	}
	
	$tmp = 0 ; 
	// echo "<pre>" ; 
    // print_r($Client) ; 
    // echo "</pre>" ;
	
	// echo "----------------> ".$Client[$a][0]['num_fact']."<br/>" ; 

	
$R=dbi_query("SELECT client_id id, concat(client_nom, ' ', client_pnom) civ, client_prospect, IF(client_genre='SERENA',1,0) as serena, IF(client_genre='FORMATION',1,0) as formation FROM ".TABLE_CLIENT." where agence_id=$agence ".( $_SESSION['client_actif']=='off' ? "" : "AND client_actif='0'")." AND client_prospect ='0' $where2 ORDER by client_nom $ordre_nom");
while($cl = dbi_fetch_row($R))
	{
			$client_id=$cl['id'];
			$a=$client_id ; 
	
		$q = dbi_query("SELECT sum(f.total)
FROM (
	(select -montant total from ".TABLE_PAIEMENT." where client_id= '".$client_id."' AND agence_id='$agence')
	union all
	(
		SELECT total-sum(if(a.montant is null, 0, a.montant)) AS total
		FROM ".TABLE_FACT." f
		LEFT JOIN ".TABLE_AVOIR." a ON f.fact_id = a.fact_id
		WHERE f.client_id= '".$client_id."'
		AND f.agence_id='$agence'
		GROUP BY f.fact_id, f.total
	)
) f") ;



$nb=count($Client[$client_id]);
list($solde) = dbi_fetch_row($q) ;
$CA+=$solde;
if(!empty($solde))
$solde=number_format($solde, 2, '. ', ' ');
list($regl) = dbi_fetch_row(dbi_query("select date from ".TABLE_PAIEMENT." where client_id=$a order by date DESC  limit 1")) ;
$date_haujourduit = date("d/m/Y");
$date_dernier=int2date($regl) ; 

//echo "date dernier facture ".$date_dernier."</br>" ;
//echo " date d'hojourdui est ".$date_haujourduit."</br>";

$date_haujd = explode("/", $date_haujourduit);
$date_dern = explode("/", $date_dernier);
$red = 0 ;
$bleu = 0 ;
$jour_d = $date_dern[0] ; 
$mois_d = $date_dern[1] ;
$anne_d = $date_dern[2] ; 
$jour_h = $date_haujd[0] ;
$mois_h = $date_haujd[1] ;
$anne_h = $date_haujd[2] ;
//echo "---->".$jour_d."<br/>" ;
//echo "---->".$mois_d."<br/>" ;
$dif_mois = $mois_h - $mois_d ;
$comp = 0 ; 
$nbrjour = 0 ;
for($i=$jour_d ; $i <=30 ; $i++ )
{
$comp = $comp + 1 ;
}
$nbrjour = $comp + $jour_h ;

//echo "********************".$nbrjour."<br/>";*/
//$yass=$anne_h - $ann_d ;
//echo "----->".$anne_h."<br/>" ;
$yass=$anne_h - $anne_d ;
$yass = 0 ;
$req_fact_nn=dbi_query("SELECT date_fact FROM `facture` WHERE facture.client_id = $a and `fact_id` not in ( select fact_id from paiement where facture.client_id = $a) and `fact_id` not in (select fact_id from avoir ) ") ;

list($req_fact_nn_nombre) = dbi_fetch_row(dbi_query("SELECT count(date_fact) FROM `facture` WHERE facture.client_id = $a and `fact_id` not in ( select fact_id from paiement where facture.client_id = $a) and `fact_id` not in (select fact_id from avoir ) "));

$req_fact=dbi_query("SELECT max(date_fact) as max_fact FROM facture,paiement WHERE facture.fact_id=paiement.fact_id and facture.client_id = $a") ;


	$Admin_pnomm = dbi_fetch_row(dbi_query("SELECT client_suivi_id,Admin_pnom  FROM  `client_suivi` , `administratif` WHERE administratif.Admin_ID = client_suivi.Admin_ID AND `client_id` =$a AND  client_suivi_clos=1 AND `suivi_id` =10 ORDER BY client_suivi_id DESC ")) ;
	
	// echo "---nom_adminn $nom_adminn <br/> " ;
	list($reg_fac) = dbi_fetch_row(dbi_query("SELECT  date_fact FROM `facture` WHERE client_id=$a order by date_fact DESC  limit 1 ")) ;
	
	 $date_hau = date("Y/m/d");

	 	 $reg_fact=int2date($reg_fac) ; 
	  // echo "============== $reg_fact <br/>" ;
	if($reg_fact != NULL)
	  {
     $date = DateTime::createFromFormat('d/m/Y', $reg_fact);
     $reg_fact= $date->format('Y/m/d');
	 }
	  if($date_dernier_paiment != NULL)
	  {
	  $date = DateTime::createFromFormat('d/m/Y', $date_dernier_paiment);	
      $date_dernier_paiment = $date->format('Y/m/d');
	  }
$dif_nobmb_hauj_et_der_fac = nbJours($reg_fact ,$date_hau );

$ya = dbi_fetch_row($req_fact_nn);
$yb = dbi_fetch_row($req_fact);
$var = $ya['max(date)'] ;
if($var != NULL)
{
$req_fac=dbi_query("SELECT  max(date_fact) FROM `facture` WHERE `fact_id` in ( select fact_id from paiement where date= $var) ") ;
$yy= dbi_fetch_row($req_fac);
}

 $dateP = $yy['max(date_fact)'] ; 
 $dateF = $y['date_fact'] ; 
 
// les suivé ************* les suivé *************** les suvé *************les suivé ******************* les suivé  

$suivmax = dbi_query("SELECT max(client_suivi_id) as idmaxs FROM `client_suivi` WHERE client_id = $a ") ;
$suivf = dbi_fetch_row($suivmax);
$r=$suivf['idmaxs'];

$suiv = dbi_query("SELECT * FROM `client_suivi`,`suivi` , suivi_biais WHERE client_id = $a and client_suivi.suivi_id = `suivi`.suivi_id and client_suivi.suivi_biais_id = suivi_biais.suivi_biais_id and suivi.suivi_id = 10 and client_suivi.client_suivi_clos = '0' ORDER BY suivi_date DESC") ;
$s = dbi_fetch_row($suiv) ;
//$suivv = $suivfitch['annotation'] ;
// la requet pour remplie la dernier collone suive pop 
$suv = dbi_fetch_row(dbi_query("SELECT *  FROM `client_suivi` WHERE `client_id` = $a AND  client_suivi_clos=1 ORDER BY client_suivi_id DESC ")) ;

$action = '';
if ($s['suivi_biais_id']=='4') 
$action = '<img src="images/icones/warning.gif" alt="Message repondeur" border="0" align="absmiddle">&nbsp;'.$s['suivi_biais_intitule'].' effectu&eacute;';
else if ($s['suivi_programme']=='1') 
$action = '<img src="images/icones/programme.gif" alt="Action programme" border="0" align="absmiddle">&nbsp;Pr&eacute;voir un '.strtolower($s['suivi_biais_intitule']);
else $action = $s['suivi_biais_intitule'].' effectu&eacute;';
if ($s['suivi_biais_id']=='6') 
$action = '<img src="images/controles-16.png" alt="Contr&ocirc;le au domicile du client" border="0" align="absmiddle">&nbsp;Pr&eacute;voir une '.strtolower($s['suivi_biais_intitule']);
// $total+= $l['montant_devis'];
if($s['suivi_date'])
$action = '<b>'.$action.' le '.mysql_datefr($s['suivi_date'],'-','Djma');
else
$action = "";
 
if(($ya["date_fact"] < $yb["max_fact"] && $solde > 0) or($dif_nobmb_hauj_et_der_fac > 30 && $solde != 0 ) or($req_fact_nn_nombre >= 2) )
{
/*echo "<pre>" ; 
print_r($suivfitch) ; 
echo "</pre>" ; 
exit() ; */


$i = 0 ;
?>
<form method="post">
<input type="hidden" name="tmp" value="<?=$a?>"> 
<table>
<tr>
<th colspan=6><?=$cl['civ']?>	solde   (<?=$solde?>)</th>
</tr>
<tr>
<td> Numéro </td> <td> Date</td> <td>Montant</td> <td></td>
<td rowspan=<?=$nb +1 ?>>
<SELECT name="fact" size="1">
<OPTION> Relance Niveau 2
<OPTION> Relance Niveau 3
<OPTION> Relance Niveau 4
</SELECT></td>
<td rowspan=<?=$nb+1?>><input type="submit" value="Cree"></td>
</tr>
<?
while ($i < $nb)
{
$date_dernier=int2date($Client[$a][$i]['date_fact']) ;
?>
<tr>
<td><?=$Client[$a][$i]['num_fact']?></td>
<td><?=$date_dernier?></td>
<td><?=$Client[$a][$i]['total']?></td>
<td><INPUT type="checkbox" name="factcheck" value="<?=$Client[$a][$i]['num_fact']?>"></td>
</tr>
<?
$i ++ ; 
}
?>
</table>
</form >
<?

$get = 'client_id='.$a ;
// echo '<td  ><b><a onclick="javascript:open_infos(\''.$a.'\')" >  </b></td>';
?><td><br/><br/></td>
<?


$tmp ++ ; 
//---------------------------affichage de suivi-------------------------------------------------------------


echo '</tr>';
$SO=$solde + $SO  ;
 $tabL[]=$solde;
}
}


$tailletabtabL=count($tabL);
$tmpss = 0 ;

?>

AnonSec - 2021