par
piotrowski-s » 13 sept. 2012, 14:14
Bonjour à tous,
J'ai généré nombreux graphiques sur une page et j'essaie de les enregistrer dans un fichier pdf en utilisant html2pdf.
J'ai donc fait quelque chose comme ça:
J'utilise souvent html2pdf pour générer du contenu à partir de php pour pdf en utilisant la fonction eval.
Mais là, je suis un peu perdu.
J'ai ce code:
<?php session_start();
// on vérifie toujours qu'il s'agit d'un membre qui est connecté
if (!isset($_SESSION['login'])) {
// si ce n'est pas le cas, on le redirige vers l'accueil
header ('Location: ../index.php');
exit();
}
require_once('Connections/localhost.php');
mysql_select_db( $database_localhost ); ?>
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="fckeditor/ckeditor.js">
CKEDITOR.replace( 'textarea_id',
{
uiColor: '#EE0000'
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Statistiques employes</title>
<?php if(isset($_GET['date_mouvement'])){ $_POST['date_mouvement']= $_GET['date_mouvement'] ;} ; ?>
<?php if(isset($_GET['date_mouvement2'])){ $_POST['date_mouvement2']= $_GET['date_mouvement2'] ;} ; ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Statistiques de l\'employe <?php $sql="SELECT * FROM `gestionnaire` WHERE `id`='".$_GET['id']."'";
$result=mysql_query($sql) or die(__LINE__.mysql_error().$sql);
$donnees=mysql_fetch_assoc($result); echo $donnees['nom'].' '.$donnees['prenom'] ; echo ' Du ' ;if(!isset($_POST['date_mouvement'])) { echo date('d-m-Y') ; } else { echo date('d-m-y', strtotime($_POST['date_mouvement'])).' Au '.date('d-m-y', strtotime($_POST['date_mouvement2'])) ; }?>'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Statistique Employe',
data: [
<?php $sql="SELECT * FROM `liste_actions`" ;
$rqt=mysql_query($sql) or die;
while($don=mysql_fetch_assoc($rqt)) {?><?php echo "['".$don['libelle']."'," ; ?><?php if(!isset($_POST['date_mouvement'])){ $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d').' 00:00:00'."' AND `date` <= '".date('Y-m-d').' 23:59:59'."'"; } else { $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d', strtotime($_POST['date_mouvement'])).' 00:00:00'."' AND `date` <= '".date('Y-m-d', strtotime($_POST['date_mouvement2'])).' 23:59:59'."'";};$exe=mysql_query($cont) or die;if(mysql_num_rows($result)!=0){ $nb=mysql_num_rows($exe)/mysql_num_rows($result);}else{$nb=0;} ; echo round($nb, 2)."],"; ?><?php } ?>
]
}]
});
});
});
</script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
var colors = Highcharts.getOptions().colors,
categories = [<?php $sql="SELECT * FROM `liste_actions`" ;
$rqt=mysql_query($sql) or die;
while($don=mysql_fetch_assoc($rqt)) {?>'<?php echo $don['libelle'] ; ?>',<?php } ?>],
name = 'Evolution des Actions de l\'Employe sur la periode selectionnee',
data = [
<?php $sql="SELECT * FROM `liste_actions`" ;
$rqt=mysql_query($sql) or die; $i=0;
while($don=mysql_fetch_assoc($rqt)) {?><?php if(!isset($_POST['date_mouvement'])){ $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d').' 00:00:00'."' AND `date` <= '".date('Y-m-d').' 23:59:59'."'"; } else { $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d', strtotime($_POST['date_mouvement'])).' 00:00:00'."' AND `date` <= '".date('Y-m-d', strtotime($_POST['date_mouvement2'])).' 23:59:59'."'";};$exe=mysql_query($cont) or die; ; echo '{y:'.$nb=mysql_num_rows($exe); ?>, color: colors[<?php echo ++$i; ; ?>],
},<?php } ?>
];
function setChart(name, categories, data, color) {
chart.xAxis[0].setCategories(categories, false);
chart.series[0].remove(false);
chart.addSeries({
name: name,
data: data,
color: color || 'white'
}, false);
chart.redraw();
}
chart = new Highcharts.Chart({
chart: {
renderTo: 'container2',
type: 'column'
},
title: {
text: 'Actions effectuees par l\'employe <?php echo $donnees['nom'].' '.$donnees['prenom'] ; echo ' Du ' ;if(!isset($_POST['date_mouvement'])) { echo date('d-m-Y') ; } else { echo date('d-m-y', strtotime($_POST['date_mouvement'])).' Au '.date('d-m-y', strtotime($_POST['date_mouvement2'])) ; }?>'
},
subtitle: {
text: ''
},
xAxis: {
categories: categories
},
yAxis: {
title: {
text: 'Total D\'actions effectuees par <?php echo $donnees['nom'].' '.$donnees['prenom'] ; ?>'
}
},
plotOptions: {
column: {
point: {
events: {
click: function() {
var drilldown = this.drilldown;
}
}
},
dataLabels: {
enabled: true,
color: colors[0],
style: {
fontWeight: 'bold'
},
formatter: function() {
return this.y +'';
}
}
}
},
tooltip: {
formatter: function() {
var point = this.point,
s = this.x +':<b>'+ this.y +'</b><br/>';
if (point.drilldown) {
s += 'Click to view '+ point.category +' versions';
} else {
s += '';
}
return s;
}
},
series: [{
name: name,
data: data,
color: 'white'
}],
exporting: {
enabled: false
}
});
});
});
</script>
<?php
function getDatesBetween($start, $end)
{
if($start > $end)
{
return false;
}
$sdate = strtotime("$start +1 day");
$edate = strtotime($end);
$dates = array();
for($i = $sdate; $i < $edate; $i += strtotime('+1 day', 0))
{
$dates[] = "'".date('d-m-Y', $i)."'";
}
return $dates;
}
function getDatesBetween2($start, $end)
{
if($start > $end)
{
return false;
}
$sdate = strtotime("$start +1 day");
$edate = strtotime($end);
$dates2 = array();
for($i = $sdate; $i < $edate; $i += strtotime('+1 day', 0))
{
$dates2[] = "'".date('Y-m-d', $i)."'";
}
return $dates2;
}
function getDatesBetween3($start, $end)
{
if($start > $end)
{
return false;
}
$sdate = strtotime("$start +1 day");
$edate = strtotime($end);
$dates3 = array();
for($i = $sdate; $i < $edate; $i += strtotime('+1 day', 0))
{
$dates3[] = "'".date('Y-m-d', $i)."'";
}
return $dates3;
}
; if(!isset($_POST['date_mouvement'])) { $date1=date('Y-m-d') ; } else { $date1= date('Y-m-d', strtotime($_POST['date_mouvement'])) ; };
if(!isset($_POST['date_mouvement'])) { $date2=date('Y-m-d') ; } else {$date2= date('Y-m-d', strtotime($_POST['date_mouvement2'])) ; } ;
$dates = getDatesBetween($date1, $date2);
$dates2 = getDatesBetween2($date1, $date2);
$dates3 = getDatesBetween3($date1, $date2);
?>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container3',
type: 'area'
},
title: {
text: 'Evolution des honoraires apportes par l\'employe <?php echo $donnees['nom'].' '.$donnees['prenom'] ; echo ' Du ' ;if(!isset($_POST['date_mouvement'])) { echo date('d-m-Y') ; } else { echo date('d-m-y', strtotime($_POST['date_mouvement'])).' Au '.date('d-m-y', strtotime($_POST['date_mouvement2'])) ; }?>'
},
subtitle: {
text: 'Etude menee selon les theoremes de Glivenko-Cantelli'
},
xAxis: {
categories: [<?php if(!empty($dates)){ echo implode(", ",$dates) ;}else{
$yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
echo "'".date('d-m-Y',($yesterday))."','".date('d-m-Y')."','".date('d-m-Y',($tomorrow))."'" ;};?>],
tickmarkPlacement: 'on',
rotation: -45,
title: {
enabled: true
}
},
yAxis: {
title: {
text: 'Euros'
},
labels: {
formatter: function() {
return this.value ;
}
}
},
tooltip: {
formatter: function() {
return ''+
'Honoraires' +': '+ Highcharts.numberFormat(this.y, 0, ',') +' Euros ';
}
},
plotOptions: {
area: {
lineColor: '#666666',
lineWidth: 1,
marker: {
lineWidth: 1,
lineColor: '#666666'
}
}
},
series: [{
name: 'Periode n',
data: [<?php if(!empty($dates2)) { $i2=0 ;
while($i2<count($dates2))
{$query2="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`=".$dates2[$i2];
$resultat2 = mysql_query($query2) or die(mysql_error());
$rowing2 = mysql_fetch_array($resultat2);
if($rowing2['SUM(honoraires)']!= NULL) {echo $rowing2['SUM(honoraires)'].', ';}else{echo '0, ';} ;
++$i2;
};
}
else
{
$yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
$yet = mktime(0, 0, 0, date("m") , date("d"), date("Y"));
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$query22="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',($yesterday))."'";
$resultat22 = mysql_query($query22) or die(mysql_error());
$rowing22 = mysql_fetch_array($resultat22);
if($rowing22['SUM(honoraires)']!= NULL) {echo $rowing22['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query2="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d')."'";
$resultat2 = mysql_query($query2) or die(mysql_error());
$rowing2 = mysql_fetch_array($resultat2);
if($rowing2['SUM(honoraires)']!= NULL) {echo $rowing2['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query23="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d', $tomorrow)."'";
$resultat23 = mysql_query($query23) or die(mysql_error());
$rowing23 = mysql_fetch_array($resultat23);
if($rowing23['SUM(honoraires)']!= NULL) {echo $rowing23['SUM(honoraires)'].', ';}else{echo '0, ';} ; }
?>]
}, {
name: 'Periode n-1',
data: [<?php if(!empty($dates3)) {$i3=0;
while($i3<count($dates3))
{$query254="SELECT
SUM(honoraires)
FROM
versements
WHERE
`date_reception`=date(".($dates3[$i3])." - INTERVAL 1 YEAR)";
$resultat254 = mysql_query($query254) or die(mysql_error());
$rowing254 = mysql_fetch_array($resultat254);
if($rowing254['SUM(honoraires)']!= NULL) {echo $rowing254['SUM(honoraires)'].', ';}else{echo '0, ';} ;
++$i3;
};
}
else
{
$yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y")-1);
$yet = mktime(0, 0, 0, date("m") , date("d"), date("Y")-1);
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")-1);
$query22="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',($yesterday))."'";
$resultat22 = mysql_query($query22) or die(mysql_error());
$rowing22 = mysql_fetch_array($resultat22);
if($rowing22['SUM(honoraires)']!= NULL) {echo $rowing22['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query2="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',$yet)."'";
$resultat2 = mysql_query($query2) or die(mysql_error());
$rowing2 = mysql_fetch_array($resultat2);
if($rowing2['SUM(honoraires)']!= NULL) {echo $rowing2['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query23="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',$tomorrow)."'";
$resultat23 = mysql_query($query23) or die(mysql_error());
$rowing23 = mysql_fetch_array($resultat23);
if($rowing23['SUM(honoraires)']!= NULL) {echo $rowing23['SUM(honoraires)'].', ';}else{echo '0, ';} ; }
?>]
},]
});
});
});
</script>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<?php ob_start(); ?>
<page backtop="50mm" backbottom="30mm" >
<page_header>
</page_header>
<page_footer>
</page_footer>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container2" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container3" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<script type="text/javascript">
CKEDITOR.replace( 'editor1', {
filebrowserBrowseUrl : 'pdw_file_browser/index.php?editor=ckeditor',
filebrowserImageBrowseUrl : 'pdw_file_browser/index.php?editor=ckeditor&filter=image',
filebrowserFlashBrowseUrl : 'pdw_file_browser/index.php?editor=ckeditor&filter=flash',
height:"20cm", width:"20cm",
}
);
</script>
<?php $content=ob_get_contents();
ob_end_clean();
require_once('html2pdf.class.php');
$html2pdf = new HTML2PDF('P','A4','fr');
$html2pdf->WriteHTML($content);
$path= 'courriers';
if(file_exists($path))
{
mkdir($path.'/'.$_GET['n_doss']);
}
else
{
mkdir($path);
mkdir($path.'/'.$_GET['n_doss']);
}
$html2pdf->Output($path.'/'.$_GET['n_doss'].'/'.$_POST['nom_login'].'-'.date('d-m-Y').'.pdf', 'F');
$url=$path.'/'.$_GET['n_doss'].'/'.$_POST['nom_login'].'-'.date('d-m-Y').'.pdf';
$sql="INSERT INTO `courrier-envoye` SET
qui = '".$_SESSION['login']."',
quoi = '".$_POST['nom_courrier']."',
quand = '".date('Y-m-d')."',
n_doss= '".$_GET['n_doss']."',
url= '".$url."'";
$req=mysql_query($sql) or die(__LINE__.mysql_error().$sql);
header('Location: '.$url);
?>
</page>
</body>
</html>
mais la chose est que cela ne sauve pas le graphique, mais seuls les divs vides comme ça:
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container2" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container3" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
Bien entendu les graphiques sont générés correctement si je n'essai pas de les enregistrer.
le tout sur la page php avec les divs bien remplis.
Je suis un peu perdu.
Si quelqu'un sait comment je pourrais procéder.
Bien entendu je n'ai pas de messages d'erreur.
Par avance merci pour votre aide.
Bonjour à tous,
J'ai généré nombreux graphiques sur une page et j'essaie de les enregistrer dans un fichier pdf en utilisant html2pdf.
J'ai donc fait quelque chose comme ça:
J'utilise souvent html2pdf pour générer du contenu à partir de php pour pdf en utilisant la fonction eval.
Mais là, je suis un peu perdu.
J'ai ce code:
[php]<?php session_start();
// on vérifie toujours qu'il s'agit d'un membre qui est connecté
if (!isset($_SESSION['login'])) {
// si ce n'est pas le cas, on le redirige vers l'accueil
header ('Location: ../index.php');
exit();
}
require_once('Connections/localhost.php');
mysql_select_db( $database_localhost ); ?>
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="fckeditor/ckeditor.js">
CKEDITOR.replace( 'textarea_id',
{
uiColor: '#EE0000'
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Statistiques employes</title>
<?php if(isset($_GET['date_mouvement'])){ $_POST['date_mouvement']= $_GET['date_mouvement'] ;} ; ?>
<?php if(isset($_GET['date_mouvement2'])){ $_POST['date_mouvement2']= $_GET['date_mouvement2'] ;} ; ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Statistiques de l\'employe <?php $sql="SELECT * FROM `gestionnaire` WHERE `id`='".$_GET['id']."'";
$result=mysql_query($sql) or die(__LINE__.mysql_error().$sql);
$donnees=mysql_fetch_assoc($result); echo $donnees['nom'].' '.$donnees['prenom'] ; echo ' Du ' ;if(!isset($_POST['date_mouvement'])) { echo date('d-m-Y') ; } else { echo date('d-m-y', strtotime($_POST['date_mouvement'])).' Au '.date('d-m-y', strtotime($_POST['date_mouvement2'])) ; }?>'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Statistique Employe',
data: [
<?php $sql="SELECT * FROM `liste_actions`" ;
$rqt=mysql_query($sql) or die;
while($don=mysql_fetch_assoc($rqt)) {?><?php echo "['".$don['libelle']."'," ; ?><?php if(!isset($_POST['date_mouvement'])){ $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d').' 00:00:00'."' AND `date` <= '".date('Y-m-d').' 23:59:59'."'"; } else { $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d', strtotime($_POST['date_mouvement'])).' 00:00:00'."' AND `date` <= '".date('Y-m-d', strtotime($_POST['date_mouvement2'])).' 23:59:59'."'";};$exe=mysql_query($cont) or die;if(mysql_num_rows($result)!=0){ $nb=mysql_num_rows($exe)/mysql_num_rows($result);}else{$nb=0;} ; echo round($nb, 2)."],"; ?><?php } ?>
]
}]
});
});
});
</script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
var colors = Highcharts.getOptions().colors,
categories = [<?php $sql="SELECT * FROM `liste_actions`" ;
$rqt=mysql_query($sql) or die;
while($don=mysql_fetch_assoc($rqt)) {?>'<?php echo $don['libelle'] ; ?>',<?php } ?>],
name = 'Evolution des Actions de l\'Employe sur la periode selectionnee',
data = [
<?php $sql="SELECT * FROM `liste_actions`" ;
$rqt=mysql_query($sql) or die; $i=0;
while($don=mysql_fetch_assoc($rqt)) {?><?php if(!isset($_POST['date_mouvement'])){ $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d').' 00:00:00'."' AND `date` <= '".date('Y-m-d').' 23:59:59'."'"; } else { $cont="SELECT `id` FROM `commentaire` WHERE `action`='".$don['id']."' AND `user`='".$donnees['login']."' AND `date` >= '".date('Y-m-d', strtotime($_POST['date_mouvement'])).' 00:00:00'."' AND `date` <= '".date('Y-m-d', strtotime($_POST['date_mouvement2'])).' 23:59:59'."'";};$exe=mysql_query($cont) or die; ; echo '{y:'.$nb=mysql_num_rows($exe); ?>, color: colors[<?php echo ++$i; ; ?>],
},<?php } ?>
];
function setChart(name, categories, data, color) {
chart.xAxis[0].setCategories(categories, false);
chart.series[0].remove(false);
chart.addSeries({
name: name,
data: data,
color: color || 'white'
}, false);
chart.redraw();
}
chart = new Highcharts.Chart({
chart: {
renderTo: 'container2',
type: 'column'
},
title: {
text: 'Actions effectuees par l\'employe <?php echo $donnees['nom'].' '.$donnees['prenom'] ; echo ' Du ' ;if(!isset($_POST['date_mouvement'])) { echo date('d-m-Y') ; } else { echo date('d-m-y', strtotime($_POST['date_mouvement'])).' Au '.date('d-m-y', strtotime($_POST['date_mouvement2'])) ; }?>'
},
subtitle: {
text: ''
},
xAxis: {
categories: categories
},
yAxis: {
title: {
text: 'Total D\'actions effectuees par <?php echo $donnees['nom'].' '.$donnees['prenom'] ; ?>'
}
},
plotOptions: {
column: {
point: {
events: {
click: function() {
var drilldown = this.drilldown;
}
}
},
dataLabels: {
enabled: true,
color: colors[0],
style: {
fontWeight: 'bold'
},
formatter: function() {
return this.y +'';
}
}
}
},
tooltip: {
formatter: function() {
var point = this.point,
s = this.x +':<b>'+ this.y +'</b><br/>';
if (point.drilldown) {
s += 'Click to view '+ point.category +' versions';
} else {
s += '';
}
return s;
}
},
series: [{
name: name,
data: data,
color: 'white'
}],
exporting: {
enabled: false
}
});
});
});
</script>
<?php
function getDatesBetween($start, $end)
{
if($start > $end)
{
return false;
}
$sdate = strtotime("$start +1 day");
$edate = strtotime($end);
$dates = array();
for($i = $sdate; $i < $edate; $i += strtotime('+1 day', 0))
{
$dates[] = "'".date('d-m-Y', $i)."'";
}
return $dates;
}
function getDatesBetween2($start, $end)
{
if($start > $end)
{
return false;
}
$sdate = strtotime("$start +1 day");
$edate = strtotime($end);
$dates2 = array();
for($i = $sdate; $i < $edate; $i += strtotime('+1 day', 0))
{
$dates2[] = "'".date('Y-m-d', $i)."'";
}
return $dates2;
}
function getDatesBetween3($start, $end)
{
if($start > $end)
{
return false;
}
$sdate = strtotime("$start +1 day");
$edate = strtotime($end);
$dates3 = array();
for($i = $sdate; $i < $edate; $i += strtotime('+1 day', 0))
{
$dates3[] = "'".date('Y-m-d', $i)."'";
}
return $dates3;
}
; if(!isset($_POST['date_mouvement'])) { $date1=date('Y-m-d') ; } else { $date1= date('Y-m-d', strtotime($_POST['date_mouvement'])) ; };
if(!isset($_POST['date_mouvement'])) { $date2=date('Y-m-d') ; } else {$date2= date('Y-m-d', strtotime($_POST['date_mouvement2'])) ; } ;
$dates = getDatesBetween($date1, $date2);
$dates2 = getDatesBetween2($date1, $date2);
$dates3 = getDatesBetween3($date1, $date2);
?>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container3',
type: 'area'
},
title: {
text: 'Evolution des honoraires apportes par l\'employe <?php echo $donnees['nom'].' '.$donnees['prenom'] ; echo ' Du ' ;if(!isset($_POST['date_mouvement'])) { echo date('d-m-Y') ; } else { echo date('d-m-y', strtotime($_POST['date_mouvement'])).' Au '.date('d-m-y', strtotime($_POST['date_mouvement2'])) ; }?>'
},
subtitle: {
text: 'Etude menee selon les theoremes de Glivenko-Cantelli'
},
xAxis: {
categories: [<?php if(!empty($dates)){ echo implode(", ",$dates) ;}else{
$yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
echo "'".date('d-m-Y',($yesterday))."','".date('d-m-Y')."','".date('d-m-Y',($tomorrow))."'" ;};?>],
tickmarkPlacement: 'on',
rotation: -45,
title: {
enabled: true
}
},
yAxis: {
title: {
text: 'Euros'
},
labels: {
formatter: function() {
return this.value ;
}
}
},
tooltip: {
formatter: function() {
return ''+
'Honoraires' +': '+ Highcharts.numberFormat(this.y, 0, ',') +' Euros ';
}
},
plotOptions: {
area: {
lineColor: '#666666',
lineWidth: 1,
marker: {
lineWidth: 1,
lineColor: '#666666'
}
}
},
series: [{
name: 'Periode n',
data: [<?php if(!empty($dates2)) { $i2=0 ;
while($i2<count($dates2))
{$query2="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`=".$dates2[$i2];
$resultat2 = mysql_query($query2) or die(mysql_error());
$rowing2 = mysql_fetch_array($resultat2);
if($rowing2['SUM(honoraires)']!= NULL) {echo $rowing2['SUM(honoraires)'].', ';}else{echo '0, ';} ;
++$i2;
};
}
else
{
$yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
$yet = mktime(0, 0, 0, date("m") , date("d"), date("Y"));
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$query22="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',($yesterday))."'";
$resultat22 = mysql_query($query22) or die(mysql_error());
$rowing22 = mysql_fetch_array($resultat22);
if($rowing22['SUM(honoraires)']!= NULL) {echo $rowing22['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query2="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d')."'";
$resultat2 = mysql_query($query2) or die(mysql_error());
$rowing2 = mysql_fetch_array($resultat2);
if($rowing2['SUM(honoraires)']!= NULL) {echo $rowing2['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query23="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d', $tomorrow)."'";
$resultat23 = mysql_query($query23) or die(mysql_error());
$rowing23 = mysql_fetch_array($resultat23);
if($rowing23['SUM(honoraires)']!= NULL) {echo $rowing23['SUM(honoraires)'].', ';}else{echo '0, ';} ; }
?>]
}, {
name: 'Periode n-1',
data: [<?php if(!empty($dates3)) {$i3=0;
while($i3<count($dates3))
{$query254="SELECT
SUM(honoraires)
FROM
versements
WHERE
`date_reception`=date(".($dates3[$i3])." - INTERVAL 1 YEAR)";
$resultat254 = mysql_query($query254) or die(mysql_error());
$rowing254 = mysql_fetch_array($resultat254);
if($rowing254['SUM(honoraires)']!= NULL) {echo $rowing254['SUM(honoraires)'].', ';}else{echo '0, ';} ;
++$i3;
};
}
else
{
$yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y")-1);
$yet = mktime(0, 0, 0, date("m") , date("d"), date("Y")-1);
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")-1);
$query22="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',($yesterday))."'";
$resultat22 = mysql_query($query22) or die(mysql_error());
$rowing22 = mysql_fetch_array($resultat22);
if($rowing22['SUM(honoraires)']!= NULL) {echo $rowing22['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query2="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',$yet)."'";
$resultat2 = mysql_query($query2) or die(mysql_error());
$rowing2 = mysql_fetch_array($resultat2);
if($rowing2['SUM(honoraires)']!= NULL) {echo $rowing2['SUM(honoraires)'].', ';}else{echo '0, ';} ;
$query23="SELECT SUM(honoraires)
FROM versements WHERE `date_reception`='".date('Y-m-d',$tomorrow)."'";
$resultat23 = mysql_query($query23) or die(mysql_error());
$rowing23 = mysql_fetch_array($resultat23);
if($rowing23['SUM(honoraires)']!= NULL) {echo $rowing23['SUM(honoraires)'].', ';}else{echo '0, ';} ; }
?>]
},]
});
});
});
</script>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<?php ob_start(); ?>
<page backtop="50mm" backbottom="30mm" >
<page_header>
</page_header>
<page_footer>
</page_footer>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container2" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container3" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<script type="text/javascript">
CKEDITOR.replace( 'editor1', {
filebrowserBrowseUrl : 'pdw_file_browser/index.php?editor=ckeditor',
filebrowserImageBrowseUrl : 'pdw_file_browser/index.php?editor=ckeditor&filter=image',
filebrowserFlashBrowseUrl : 'pdw_file_browser/index.php?editor=ckeditor&filter=flash',
height:"20cm", width:"20cm",
}
);
</script>
<?php $content=ob_get_contents();
ob_end_clean();
require_once('html2pdf.class.php');
$html2pdf = new HTML2PDF('P','A4','fr');
$html2pdf->WriteHTML($content);
$path= 'courriers';
if(file_exists($path))
{
mkdir($path.'/'.$_GET['n_doss']);
}
else
{
mkdir($path);
mkdir($path.'/'.$_GET['n_doss']);
}
$html2pdf->Output($path.'/'.$_GET['n_doss'].'/'.$_POST['nom_login'].'-'.date('d-m-Y').'.pdf', 'F');
$url=$path.'/'.$_GET['n_doss'].'/'.$_POST['nom_login'].'-'.date('d-m-Y').'.pdf';
$sql="INSERT INTO `courrier-envoye` SET
qui = '".$_SESSION['login']."',
quoi = '".$_POST['nom_courrier']."',
quand = '".date('Y-m-d')."',
n_doss= '".$_GET['n_doss']."',
url= '".$url."'";
$req=mysql_query($sql) or die(__LINE__.mysql_error().$sql);
header('Location: '.$url);
?>
</page>
</body>
</html>
[/php]
mais la chose est que cela ne sauve pas le graphique, mais seuls les divs vides comme ça:
[html]<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container2" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="container3" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
[/html]
Bien entendu les graphiques sont générés correctement si je n'essai pas de les enregistrer.
le tout sur la page php avec les divs bien remplis.
Je suis un peu perdu.
Si quelqu'un sait comment je pourrais procéder.
Bien entendu je n'ai pas de messages d'erreur.
Par avance merci pour votre aide.