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/../MCPRO/entetes/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/TEST/../MCPRO/entetes/../facturemail.php
<?php
// lllk

// Turn off all error reporting
error_reporting(0);
include 'includes/config_tmcpro2.php' ; 
include 'includes/stable_functions_tmcpro.php' ;



function envoyer_email($type, $id,$s) {

$facturation = dbi_fetch_row(dbi_query("SELECT client_facture_mail,client_nom, f.num_fact,f.fact_id, date_fact FROM facture f JOIN client c USING (client_id) WHERE f.fact_id='$id'"));

if(false !== filter_var($facturation['client_facture_mail'], FILTER_VALIDATE_EMAIL)) {
// include 'code/facture-pdf.php' ;
$facture = new Facture ($id) ;
// $s = $facture->Output('','S');

	global $agence;

		define('EMAIL_EXPEDITEUR', 'MC PRO');
		define('EMAIL_EXPEDITEUR_ADRESSE','comptabilite@mc-pro.fr');

	
	$boundary = md5(uniqid(rand())) ;
	$headers = "Content-Type: multipart/mixed; boundary=\"$boundary\"\n" ;
	$headers .= "Content-Transfer-Encoding: base64\n" ;
	$headers .= "From: \"".EMAIL_EXPEDITEUR."\" <".EMAIL_EXPEDITEUR_ADRESSE.">\n" ;
	$headers .= "MIME-Version: 1.0\n" ;

	$txt='';
	$html='';
	



// echo "SELECT client_facture_mail,client_nom, f.num_fact,f.fact_id, date_fact FROM facture f JOIN client c USING (client_id) WHERE f.fact_id='$id'";

// $client_mail_Fact = 'sofian.elmghari59@gmail.com';
$client_mail_Fact = $facturation['client_facture_mail'];
$date=$facturation['date_fact'];
$date_fact=$facturation['date_fact'];
$date=substr($date, 0,4).'/'.substr($date, 4,2).'/'.substr($date, 6,2);

$attachment = chunk_split(base64_encode($s));
$msg .= "--$boundary\r\n";
$msg.= "Content-type: text/html; charset=\"iso-8859-1\"\n\n";
$msg.= "Cher Client,<br/>Veuillez trouver en pi&egrave;ce jointe votre facture du $date<br/>Vous en souhaitant bonne r&eacute;ception.<br/>Cordialement,<br/>L'&eacute;quipe MC PRO<br/>PS :  Pour vos r&egrave;glements par ch&egrave;que, nous vous remercions de les envoyer &agrave; l'adresse suivante : MC PRO - 525 Avenue Laennec - 83140 Six-Fours-Les-Plages   <br/><br/><br/>";
$msg .= "--$boundary\r\n";

$msg .= "--$boundary\r\n";

$msg .= "Content-Type: application/pdf; name=\"$file\"\r\n";

$msg .= "Content-Transfer-Encoding: base64\r\n";

$msg .= "Content-Disposition: inline; filename=\"$id\"\r\n";

$msg .= "\r\n";

$msg .= $attachment . "\r\n";
$msg .= "\r\n\r\n";

$msg .= "--$boundary--\r\n";


mail(''.$client_mail_Fact.'', "Votre facture MC PRO", $msg, $headers);
}
	// header("Location:testmail.php");
	// exit;
}

			if(isset($_POST['mois']) && isset($_POST['annee']) && isset($_POST['client_ids'] )){
				
				$facts =array();
				$from = $_POST['annee'].'-'.$_POST['mois'].'-01';
				$to = date('Y-m-t', strtotime($from));
				$CLIENTIN = ' IN ( ';
				foreach ($_POST['client_ids'] as $client_id)
				{
					$CLIENTIN .= "$client_id ,";
				}	
				$CLIENTIN .= ' 0 ) ';	
				
				
				// echo  $CLIENTIN.' ***** ';
				// $pre=get_prest_sem( $CLIENTIN,$from,$to);
				// echo "<pre>";
				// print_r($pre);
				// echo "<pre>";
				$too   = dateformaint($to) ;
				$fromm  = dateformaint($from);
				

				

				
				
				$annee = $_POST['annee'];
				$mois = $_POST['mois'];

				include 'code/facture-pdf.php' ; //avec entet
				$rf = dbi_query("SELECT * FROM facture  WHERE date_debut>=$fromm AND date_fin<=$too  AND client_id $CLIENTIN  ") ;
				while($fs = dbi_fetch_row($rf))
					{
						// echo '<pre>';
						
						// print_r($fs);
						// echo '<pre>';
									$s = $pdf->Output('','S');
// envoyer_email('facture',$fact_id,$s);
						envoyer_email('facture',$fs['fact_id'],$s);
						// $facts[]=array($fs['client_id'],$fs['fact_id'],$fs['date_debut'],$fs['date_fin'],$fs['date_fact']);
					}
			}		


/*
if(isset($_POST['clients']) && !empty($_POST['clients']) && !empty($_POST['from']) && !empty($_POST['to']) && !empty($_POST['datefacture'])){
// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
include 'includes/fch.php' ;
	// dateformaint($
$from=dateformaint($_POST['from']);
$to=dateformaint($_POST['to']);
$au=dateformaint($_POST['datefacture']);
$au1 = sprintf("%02d/%02d/%04d", substr($au, 6, 2), substr($au, 4, 2), substr($au, 0, 4)) ;
$prev=false;
$nb_prev=0;

	foreach ($_POST['clients'] as $client_id)
	{
		

// include 'includes/fch3.php' ;		
		// echo ' <br/>'."$client_id ,";
		
$_POST['fact_format']='n';
$textf=NULL;
$somme=$_POST[$client_id.'total'];		
$prev=false;
$nb_prev=0;
$facture = unserialize( base64_decode( $_POST[$client_id."facture"] ) );
$inter = unserialize( base64_decode( $_POST[$client_id."inter"] ) );
$numfact=dbi_query("SELECT * FROM ".TABLE_FACT." WHERE date_debut>=$from AND date_fin<=$to  AND client_id=$client_id ") ;
// echo "SELECT * FROM ".TABLE_FACT." WHERE date_debut>=$from AND date_fin<=$to  AND client_id=$client_id ";
// echo "SELECT * FROM ".TABLE_FACT." WHERE date_debut>=$from AND date_fin<=$to  AND client_id=$client_id AND agence_id=$agence";
$row_cnt = mysqli_num_rows($numfact);
if($row_cnt)
{

}
else
{
// $fact_id=creerFactureCh($client_id,0,$from,$to,$f,$au1, $_POST['fact_format'], $prev, $cumul, $nb_prev, $textf,$facture,$somme,$inter);
// echo ' ************** ';
}



	}	
			
	
}*/
// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
$where = '';	
if(isset($_POST['mois']) && isset($_POST['annee'])){
// $where = "  AND client_id NOT IN ( SELECT client_id FROM ".TABLE_FACT." WHERE date_debut>='".$_POST['annee'].''.$_POST['mois'].'01'."' AND date_fin<='".date('Ymt', strtotime($_POST['annee'].'-'.$_POST['mois'].'-01'))."'  ) ";						
}
if( !empty($_POST['from']) && !empty($_POST['to']) ){
// $where = "  AND client_id NOT IN ( SELECT client_id FROM ".TABLE_FACT." WHERE date_debut>='".$_POST['from']."' AND date_fin<='".$_POST['to']."'  ) ";						
}	
// ECHO $where;
// $where = '';
$date = date('Y-m-01');
$annee = $year = date('Y');
$mois = $month = date('m');
// if(isset($_POST['datefacture']))
// $datefacture = $_POST['datefacture'];
// else
// $datefacture = date('Y-m-d');

$months = array(
     1 => 'Janvier',
     2 => 'Février',
     3 => 'Mars',
     4 => 'Avril',
     5 => 'Mai',
     6 => 'Juin',
     7 => 'Juillet',
     8 => 'Août',
     9=> 'Septembre',
    10=> 'Octobre',
    11 => 'Novembre',
    12 => 'Décembre'
);


if(isset($_POST['mois']) && isset($_POST['annee'])){
	$datecal = $_POST['annee'].'-'.$_POST['mois'].'-01';
	$annee = $_POST['annee'];
	$mois = $_POST['mois'];
}

// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>AdminLTE 3 | Advanced form elements</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- 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">
  <!-- daterange picker -->
  <link rel="stylesheet" href="../plugins/daterangepicker/daterangepicker.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="../plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="../plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css">
  <!-- Tempusdominus Bbootstrap 4 -->
  <link rel="stylesheet" href="../plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- Select2 -->
  <link rel="stylesheet" href="../plugins/select2/css/select2.min.css">
  <link rel="stylesheet" href="../plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
  <!-- Bootstrap4 Duallistbox -->
  <link rel="stylesheet" href="../plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<!-- TOP MENU -->
  <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>
<!-- liens TOP MENU GAUCHE-->
      <li class="nav-item d-none d-sm-inline-block">
        <a href="index.php" class="nav-link">Accueil</a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <a href="#" class="nav-link">Lien 1</a>
      </li>
	   <li class="nav-item d-none d-sm-inline-block">
        <a href="#" class="nav-link">Lien 2</a>
      </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'); ?>
<div  class="modal fade" id="PrestUpt" 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="jalil" ></div>
							
							   
							</div>
						</div>
</div>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Facture</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active">Traitement des factures</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>


    <!-- Main content -->
    <section class="content">
		<div class="container-fluid">
		
			<div class="row">
				<!-- /.col -->
				<div class="col-md-12">
					<div class="card card-info" style='border:2px solid #17a2b8;'>
						<div class="card-header">
							<h3 class="card-title">Envoyer papier facture  par email </h3>
						</div>
						<!-- form start -->
						<form role="form" method='POST' action=''>	  
							<!-- /.card-header -->
							<div class="card-body" >
								<div class="row">
									<div class="col-12">
										<div class="form-group">
											<select class="duallistbox" multiple="multiple" style="height: 150px;" name="client_ids[]" id="client_ids[]">
														<?php   $req =dbi_query("SELECT * FROM client WHERE client_statut = '1' AND client_env_mail = 1 AND client_id IN (select client_id from chantier)  $where ORDER BY client_nom ASC") ;

																while(  $cli=dbi_fetch_row($req)) { ?>
																<option value="<?php echo $cli['client_id'] ; ?>" <?php if(in_array($cli['client_id'] , $_POST['client_ids'])) echo 'selected';?>><?php echo utf8_encode($cli['client_nom']); ?></option>
														<?php   }	?>
											</select>
										</div>
									</div>
							  
									<div class="col-sm-4">
									  <div class="form-group">
											<label>Année</label>
											<select name='annee' id='annee' class="form-control">
											<?php
												$earliest_year = 2018;
												foreach (range($year+3, $earliest_year) as $x) {
													print '<option value="'.$x.'"'.($x == $annee ? ' selected="selected"' : '').'>'.$x.'</option>';
												}
											?>
											</select>
									  </div>
									</div>
									<div class="col-sm-4">
										<div class="form-group">
											<label>Mois</label>
											<select name='mois' id='mois' class="form-control">
												<?php 
												foreach ($months as $key => $value) {
													$key  = sprintf("%02d",$key );
													print '<option value="'.$key.'"'.($key == $mois ? ' selected="selected"' : '').'>'.$value.'</option>';
												}	
												?>
											</select>
										</div>
									</div>	
									<div class="col-sm-4">
									  <div class="form-group"><label><br/></label>
										<button type="submit" class="btn btn-block bg-gradient-info">Envoyer la facture par email</button>
									  </div>
									</div>	
								</div>
							</div>
						</form>
					</div>
				</div> <!-- /.col -->
			</div><!-- /.row -->
		  
		<form role="form" method='POST' action=''>


		</form>	
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <footer class="main-footer">
    <div class="float-right d-none d-sm-block">
      <b>Version</b> 3.0.2
    </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>
<!-- Select2 -->
<script src="../plugins/select2/js/select2.full.min.js"></script>
<!-- Bootstrap4 Duallistbox -->
<script src="../plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.js"></script>
<!-- InputMask -->
<script src="../plugins/moment/moment.min.js"></script>
<script src="../plugins/inputmask/min/jquery.inputmask.bundle.min.js"></script>
<!-- date-range-picker -->
<script src="../plugins/daterangepicker/daterangepicker.js"></script>
<!-- bootstrap color picker -->
<script src="../plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="../plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Bootstrap Switch -->
<script src="../plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<!-- Page script -->
<script>
  $(function () {
$("#allcheck").click(function(){
    $('input:checkbox').not(this).prop('checked', this.checked);
});
	 var TOTALCA ="<?php echo number_format( $CATTC, 2, ',', ' ').'<sup> € </sup>';?>";
	$('#TOTALCA').html(TOTALCA);
	 var TOTALCAHT ="<?php echo number_format( $CAHT, 2, ',', ' ').'<sup> € </sup>';?>";
	$('#TOTALCAHT').html(TOTALCAHT); 	
    //Initialize Select2 Elements
    $('.select2').select2()

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

    //Datemask dd/mm/yyyy
    $('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({
      timePicker: true,
      timePickerIncrement: 30,
      locale: {
        format: 'MM/DD/YYYY hh:mm A'
      }
    })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )

    //Timepicker
    $('#timepicker').datetimepicker({
      format: 'LT'
    })
    
    //Bootstrap Duallistbox
    $('.duallistbox').bootstrapDualListbox()

    //Colorpicker
    $('.my-colorpicker1').colorpicker()
    //color picker with addon
    $('.my-colorpicker2').colorpicker()

    $('.my-colorpicker2').on('colorpickerChange', function(event) {
      $('.my-colorpicker2 .fa-square').css('color', event.color.toString());
    });

    $("input[data-bootstrap-switch]").each(function(){
      $(this).bootstrapSwitch('state', $(this).prop('checked'));
    });

  })
</script>
</body>
</html>

AnonSec - 2021