Xml TO PDF

Petit nouveau ! | 5 Messages

19 mai 2014, 13:30

Bonjour

Je débute en php .... et j'ai besoin d'aide pour finaliser un projet

J'ai un site qui affiche les résultats sous forme d'un xml, et j'ai un bouton qui devrait permettre de générer un pdf mais je n'y arrive pas

j'ai essayé différentes méthodes XML2PHP, fpdf mais je ne m'y prend peut être pas correctement

Peut on generer directement ?

Merci pour voter aide

Avatar de l’utilisateur
Modérateur PHPfrance
Modérateur PHPfrance | 8675 Messages

19 mai 2014, 15:59

salut,

sans code on ne peux pas trop t'aider.
tu affiche un xml directement dans le navigateur (ça doit pas être super top à lire).

si c'est du html html2pdf doit pouvoir t'aider.

sinon explique un peu mieux ce que tu veux faire.
c'est le fichier (avec les tags xml et tout) qui doit être dans le pdf ?
Ou c'est les données du XML qui doivent être dans le pdf ?
dans le second cas il faut par courir le xml (par exemple avec simplexml) pour utiliser les données.
ensuite FPDF peux très bien faire l'affaire.


@+
Il en faut peu pour être heureux ......

Petit nouveau ! | 5 Messages

19 mai 2014, 16:11

Bonjour,

Le xml est mis en forme avec xsl.

J'ai une page result.php qui va creer mon XML ensuite dans celui ci j'ai trois boutons dont un pour imprimer voici le code :

[xml]<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl:template match="/">
<html>
<head>
<title>Compte rendu laboratoire</title>
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="document/docroot" />/css/report.css
</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
<script language="JavaScript">
function PopUp(mylink, windowname)
{
var sizes;

if (windowname=='comments')
sizes = 'width=600,height=400,scrollbars=yes,status=no,resizable=yes';
else
sizes = 'width=605,left=200,top=100,height=450,scrollbars=no,status=no,resizeable=yes';
if (! window.focus)
return true;

var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, sizes);
return false;
}

function ReadCookie(cookieName)
{
var theCookie=""+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=="")
return "";
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1)
ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function AddAnal(user,request)
{
var url = "../reqform.php?user="+user+"&request="+request;
window.open(url);
}

function BackToURL()
{
var origin = ReadCookie("MDSOrigin");
if (origin.indexOf('req_list') == -1)
history.go(-3);
else
history.go(-2);
}

function BackToOrigin(origin)
{
document.location.href = origin;
}
</script>
</head>
<body>
<script name="JavaScript">
var request ='<xsl:value-of select="document/header/request/nummer" />';
var r = ReadCookie("CurrentRequest");
if (r != request) location.href='../index.php';
</script>
<xsl:element name="table">
<xsl:attribute name="class">ProtocolHeaderTable</xsl:attribute>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">LogoColumn</xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="document/logo" />
</xsl:attribute>
<xsl:attribute name="class">logo</xsl:attribute>
</xsl:element>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">PatientColumn</xsl:attribute>
<xsl:element name="table">
<xsl:attribute name="class">PatientTable</xsl:attribute>
<xsl:element name="tr">
<xsl:element name="th">
<xsl:attribute name="class">PatientTableHeader</xsl:attribute>
<xsl:attribute name="colspan">4</xsl:attribute>
Compte rendu laboratoire
</xsl:element>
</xsl:element>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="colspan">2</xsl:attribute>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">DateText</xsl:attribute>
Date :
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">DateData</xsl:attribute>
<xsl:value-of select="document/header/request/reqdate" />
</xsl:element>
</xsl:element>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">PatientDataText</xsl:attribute>
Nom Patient :
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">PatientData</xsl:attribute>
<xsl:value-of select="document/header/patient/name" />,
<xsl:value-of select="document/header/patient/fname" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">RequestDataText</xsl:attribute>
R&#233;f&#233;rence :
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">RequestData</xsl:attribute>
<xsl:value-of select="document/header/request/nummer" />
</xsl:element>
</xsl:element>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">PatientDataText</xsl:attribute>
Adresse :
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">PatientData</xsl:attribute>
<xsl:value-of select="document/header/patient/address" /><br/>
<xsl:value-of select="document/header/patient/zip" />
&#160;
<xsl:value-of select="document/header/patient/city" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">DoctorName</xsl:attribute>
<xsl:value-of select="document/header/doctor/fullname" />
</xsl:element>
<xsl:comment>
<xsl:if test="document/header/request/status!=''">
<xsl:element name="td">
<xsl:attribute name="colspan">2</xsl:attribute>
<xsl:choose>
<xsl:when test="document/header/request/status='F'">
<xsl:attribute name="class">RequestValidated</xsl:attribute>
Valid&#233; par : <xsl:value-of select="document/header/request/validator" />
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">RequestNotValidated</xsl:attribute>
Non valid&#233;
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
</xsl:comment>
</xsl:element>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">PatientDataText</xsl:attribute>
Date de naissance :
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">PatientData</xsl:attribute>
<xsl:value-of select="document/header/patient/birth" />
&#160;&#160;&#160;Sexe :
<xsl:choose>
<xsl:when test="document/header/patient/sex='M'">Masculin</xsl:when>
<xsl:when test="document/header/patient/sex='V'">F&#233;minin</xsl:when>
<xsl:when test="document/header/patient/sex='F'">F&#233;minin</xsl:when>
</xsl:choose>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="colspan">2</xsl:attribute>
<xsl:attribute name="class">RequestValidator</xsl:attribute>
<xsl:if test="document/header/request/status!='F'">
Partiel
</xsl:if>
<xsl:if test="document/header/request/status='F'">
Complet
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
<xsl:element name="table">
<xsl:attribute name="class">LaboratoryTable</xsl:attribute>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">Laboratory</xsl:attribute>
<xsl:value-of select="document/header/labo/name" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">Laboratory</xsl:attribute>
<xsl:value-of select="document/header/labo/fulladdress" />,&#160;<xsl:value-of select="document/header/labo/fullcity" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">Laboratory</xsl:attribute>
tel&#160;<xsl:value-of select="document/header/labo/tel" />,&#160;fax&#160;<xsl:value-of select="document/header/labo/fax" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">Laboratory</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="href">
mailto:<xsl:value-of select="document/header/labo/email" />
</xsl:attribute>
<xsl:attribute name="title">Cliquez ici pour nous envoyer un courriel</xsl:attribute>
<xsl:value-of select="document/header/labo/email" />
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
<xsl:element name="form">
<xsl:attribute name="method">post</xsl:attribute>
<xsl:attribute name="action">../testpdf.php</xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">request</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="document/header/request/nummer" /></xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">user</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="document/header/doctor/login" /></xsl:attribute>
</xsl:element>
<xsl:element name="table">
<xsl:attribute name="class">mainTable</xsl:attribute>
<xsl:element name="thead">
<xsl:element name="tr">
<xsl:element name="th">
<xsl:attribute name="class">mainTableHeader</xsl:attribute>
St.
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">mainTableHeader</xsl:attribute>
Nouv.
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">mainTableHeader</xsl:attribute>
Nom d'analyse
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">mainTableHeader</xsl:attribute>
R&#233;sultat / Commentaire
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">mainTableHeader</xsl:attribute>
Unit&#233;
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">mainTableHeader</xsl:attribute>
R&#233;f&#233;rence
</xsl:element>
</xsl:element>
</xsl:element>
<xsl:element name="tbody">
<xsl:for-each select="document/body/chapter">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableChapter</xsl:attribute>
<xsl:attribute name="colspan">6</xsl:attribute>
<xsl:value-of select="title" />
</xsl:element>
</xsl:element>
<xsl:if test="commentaar">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="colspan">6</xsl:attribute>
<xsl:attribute name="class">mainTableTextResult</xsl:attribute>
<xsl:for-each select="commentaar">
<xsl:value-of select="text" />
<br />
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
<xsl:for-each select="analyse">
<xsl:if test="subchapter">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableSubChapter</xsl:attribute>
<xsl:attribute name="colspan">6</xsl:attribute>
<xsl:value-of select="subchapter/name" />
</xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="subchapter/commentaar">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="colspan">6</xsl:attribute>
<xsl:attribute name="class">mainTableTextResult</xsl:attribute>
<xsl:for-each select="subchapter/commentaar">
<xsl:value-of select="text" />
<br />
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnStatus</xsl:attribute>
<xsl:choose>
<xsl:when test="validated='R' or validated='F'">
<xsl:choose>
<xsl:when test="patho='HH' or patho='>' or patho='LL' or patho='<'">
<xsl:choose>
<xsl:when test="validator!=''">
<xsl:element name="img">
<xsl:attribute name="class">mainTableStatusImage</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="/document/docroot" />/img/vinkje-groen.gif</xsl:attribute>
<xsl:attribute name="title">Valid&#233; par :<xsl:value-of select="validator" /></xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="img">
<xsl:attribute name="class">mainTableStatusImage</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="/document/docroot" />/img/vinkje-rood.gif</xsl:attribute>
<xsl:attribute name="title">Non valid&#233;</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:element name="img">
<xsl:attribute name="class">mainTableStatusImage</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="/document/docroot" />/img/vinkje-groen.gif</xsl:attribute>
<xsl:attribute name="title">Valide automatiquement</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnNew</xsl:attribute>
<xsl:choose>
<xsl:when test="viewed='0'">
<xsl:element name="img">
<xsl:attribute name="class">mainTableNewImage</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="/document/docroot" />/img/newsm.gif</xsl:attribute>
<xsl:attribute name="title">Ce r&#233;sultat a &#233;t&#233; ajout&#233; ou chang&#233; depuis votre derni&#232;re visite</xsl:attribute>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnName</xsl:attribute>
<xsl:value-of select="resflag"/>
<xsl:value-of select="naam" />
</xsl:element>
<xsl:element name="td">
<xsl:choose>
<xsl:when test="typeresultaat='N' or typeresultaat='S'">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="patho='-'">mainTableLowResult</xsl:when>
<xsl:when test="patho='L'">mainTableLowResult</xsl:when>
<xsl:when test="patho='LL'">mainTablePathoLowResult</xsl:when>
<xsl:when test="patho='<'">mainTablePathoLowResult</xsl:when>
<xsl:when test="patho='N'">mainTableNormalResult</xsl:when>
<xsl:when test="patho='+'">mainTableHighResult</xsl:when>
<xsl:when test="patho='H'">mainTableHighResult</xsl:when>
<xsl:when test="patho='HH'">mainTablePathoHighResult</xsl:when>
<xsl:when test="patho='>'">mainTablePathoHighResult</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="resultaat" />
</xsl:when>
<xsl:when test="typeresultaat='T'">
<xsl:if test="resultaat">
<xsl:attribute name="class">mainTableNormalResult</xsl:attribute>
<xsl:value-of select="resultaat" />
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnUnit</xsl:attribute>
<xsl:value-of select="eenheid" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnReference</xsl:attribute>
<xsl:value-of select="normaalwaarden" />
</xsl:element>
</xsl:element>
<xsl:if test="commentaar">
<xsl:if test="typeresultaat='N' or typeresultaat='S'">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnStatus</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnNew</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnName</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableTextResult</xsl:attribute>
<xsl:for-each select="commentaar">
<xsl:value-of select="text" />
<br />
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="typeresultaat='T'">
<xsl:if test="resultaat=''">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnStatus</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnNew</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnName</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableTextResult</xsl:attribute>
<xsl:for-each select="commentaar">
<xsl:value-of select="text" />
<br />
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="resultaat!=''">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnStatus</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnNew</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnName</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableTextResult</xsl:attribute>
<xsl:for-each select="commentaar">
<xsl:value-of select="text" />
<br />
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:if>
</xsl:if>
<xsl:if test="analcomment">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnStatus</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnNew</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableColumnName</xsl:attribute>
&#160;
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">mainTableTextResult</xsl:attribute>
<xsl:for-each select="analcomment">
<xsl:value-of select="text" />
<br />
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="antibiogram">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">mainTableABGram</xsl:attribute>
<xsl:attribute name="colspan">6</xsl:attribute>
<xsl:element name="table">
<xsl:attribute name="class">ABGramTable</xsl:attribute>
<xsl:for-each select="id">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">ABGramName</xsl:attribute>
<xsl:value-of select="name" />
</xsl:element>
<xsl:for-each select="result">
<xsl:element name="td">
<xsl:attribute name="class">ABGramResult</xsl:attribute>
<xsl:value-of select="value" />
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:for-each>
</xsl:element>
<xsl:element name="tfoot"></xsl:element>
</xsl:element>
<xsl:for-each select="document/body/profile">
<xsl:element name="table">
<xsl:attribute name="class">ProfileTable</xsl:attribute>
<xsl:element name="tr">
<xsl:element name="th">
<xsl:attribute name="class">ProfileTitle</xsl:attribute>
<xsl:attribute name="colspan">8</xsl:attribute>
<xsl:value-of select="profilename" />
</xsl:element>
<xsl:element name="tr">
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
Patient
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
onder=X-2SD
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
boven=X+2SD
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
gem.=X
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
1 SD
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
SD patient
</xsl:element>
<xsl:element name="th">
<xsl:attribute name="class">ProfileHeader</xsl:attribute>
eenheden
</xsl:element>
</xsl:element>
<xsl:for-each select="analyse">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailName</xsl:attribute>
<xsl:value-of select="naam"/>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailData</xsl:attribute>
<xsl:value-of select="resultaat" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailData</xsl:attribute>
<xsl:value-of select="minval" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailData</xsl:attribute>
<xsl:value-of select="maxval" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailData</xsl:attribute>
<xsl:value-of select="mean" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailData</xsl:attribute>
<xsl:value-of select="sd" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailData</xsl:attribute>
<xsl:value-of select="val" />
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="class">ProfileDetailData</xsl:attribute>
<xsl:value-of select="eenheid" />
</xsl:element>
</xsl:element>
</xsl:for-each>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="colspan">8</xsl:attribute>
<xsl:attribute name="class">ProfileLink</xsl:attribute>
Cliquez
<xsl:element name="a">
<xsl:attribute name="target">blank</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
ici
</xsl:element>
pour la graphique
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
<xsl:element name="div">
<xsl:attribute name="class">ButtonDivision</xsl:attribute>
<xsl:element name="input">
<xsl:attribute name="type">button</xsl:attribute>
<xsl:attribute name="value">Demande d'analyses</xsl:attribute>
<xsl:attribute name="title">Cliquez ici pour demander des analyses suppl&#233;mentaires</xsl:attribute>
<xsl:attribute name="onclick">
AddAnal("<xsl:value-of select="document/header/doctor/login"/>","<xsl:value-of select="document/header/request/nummer"/>")
</xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">submit</xsl:attribute>
<xsl:attribute name="value">fichier PDF</xsl:attribute>
<xsl:attribute name="title">Cliquez ici pour ce compte rendu en format PDF</xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">button</xsl:attribute>
<xsl:attribute name="value">Retour vers liste</xsl:attribute>
<xsl:attribute name="title">Retour vers la liste de demandes</xsl:attribute>
<xsl:attribute name="onclick">BackToOrigin("<xsl:value-of select="document/origin"/>")</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
[/xml]


Merci pour votre aide
Dernière édition par moogli le 19 mai 2014, 17:25, édité 1 fois.
Raison : bbcode

Avatar de l’utilisateur
Modérateur PHPfrance
Modérateur PHPfrance | 8675 Messages

19 mai 2014, 17:38

ça c'est une xslt que tu applique un xml (qui lui contient des données).

c'est le navigateur qui applique la xslt ou c'est via php ? (sablotron etc).
si php a le parse du html dans une variable tu peux rejouer la chose pour l'imprimer.

tu n'as pas d'autre solution pour créer un fichier pdf que d'avoir les données coté serveur.
Le parse de la xslt avec php est une solution, pour cela tu peux surement utiliser la classe xsltprocessor.


La le plus simple reste de faire une css pour le media print et d'utiliser le print du navigateur (envois avec JS) ?

@+
Il en faut peu pour être heureux ......

Petit nouveau ! | 5 Messages

19 mai 2014, 18:09

C'est du côté serveur qu'il se crée mais le pdf doit être fourni au client ns qu'ils disposent de pdf creator sur leur poste

'ai déjà passé beaucoup de temps dessus et je ne vois pas ... N'est il pas possible de convertir le xml en pdf , le xml est stocke sur le serveur mais là il n'a pas sa feuille de style ?

merci

Avatar de l’utilisateur
Modérateur PHPfrance
Modérateur PHPfrance | 8675 Messages

19 mai 2014, 21:24

ce que tu as fournit est une feuille de style xsl ==> <xsl:stylesheet

pour l'affichage tu as du code qui prend un fichier "le mouline" avec la feuille de style et fait la page html finale.

c'est ce code que tu toi trouver pour ne récupérer que le html final et utiliser html2pdf.

pour info tu trouveras un exemple d'envois au navigateur de fichier pdf dans la doc de la fonction header


@+
Il en faut peu pour être heureux ......

Petit nouveau ! | 5 Messages

20 mai 2014, 08:29

Bonjour

Voici la page qui génére les données
<?php session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <meta http-equiv="content-type" content='text/html; charset="UTF-8"' />
    <meta name='keywords' content='php grid, php datagrid, php data grid, datagrid sample, datagrid php, datagrid, grid php, datagrid in php, data grid in php, free php grid, free php datagrid, pear datagrid, datagrid paging' />
    <meta name='description' content='Advanced Power of PHP :: ApPHP DataGrid - Customized layout in Details Mode' />
    <meta content='Advanced Power of PHP' name='author'></meta>
    <link rel="stylesheet" href="styleserv.css" media="all" type="text/css"/>
    <title>serveur de resultats</title>

    <SCRIPT language="JavaScript">

       function getresults() {
       	try
        {
       		var selected_check = new Array();
       		var nb=-1;
       		for (i=0; i<5000; i++)
       		{
       			if (document.getElementById('f_checkbox_' + i).checked!=false) {
       				nb=nb+1;
       				selected_check[nb]= document.getElementById('f_checkbox_' + i).value;
       			}
       		}
        }
		catch (err)
		{
			window.location.href = 'getResults.php?nummer='+selected_check;
        	//window.open('getResults.php?nummer='+selected_check);
		}
       }

       function loadfive() {
	   try
       {
         for (i=0; i<5; i++)
	   	 {
	   	   document.getElementById('f_checkbox_'+i).checked = true;
	     }
       }
       catch (err)
       {

       }
       }
    </SCRIPT>

  </head>
<body onload="javascript:loadfive()">
<?php include ('language.php');
//('".$edit_curr_url."'+f_part+s_part+p_part+param).replace(/_RID_/g, rid).replace(/&/g, '&');   datagrid ligne 8055
?>
         <div id="conteneur">
                 <div id="navigation">
                    <div id="entete">
                        <div id="entete_interieure">

                           <h1>
                            <?php include('logos.php'); getMainlogo(); ?>
                            </h1>
                            <div id="menu">
                            <ul>
                            <?php echo'<li id="contact"><a href="Contact.php">'.$lang['TXT_MAIL'].'</a></li>'; ?>
                            <li id="deconnect"><?php echo $lang['TXT_DECONNEXION']; ?></li>
                            </ul>
                            </div>
                        </div><!--id entete interieure-->

                    </div><!--id entete-->

             <div id="menuPrincipal">
                         <ul>
                        <li><a href="index.php"><?php echo $lang ['TXT_ACCUEIL']; ?></a></li>
                <?php   echo '<li><a href="listeDossiers.php?userid='.$_SESSION['userid'].'">'.$lang ['TXT_SELECT'].'</a></li>' ?>
                <?php   echo '<li><a href="compte.php">'.$lang ['TXT_COMPTE'].'</a></li>' ?>
                        </ul>
                         <div id="choix_langue">
                           <span class="neerlandais"><a href="resultats.php?lang=NL">NL</a></span>
                           <span class="français"   ><a href="resultats.php?lang=FR">FR</a></span>
                         </div>



            </div><!--fin menuPrincipal-->
            <div id="visuelAccueil"><img src="images/imageslabo.png" alt="labo" /></div>
            </div><!--fin navigation-->


            <div id="global">

                    <div id="page">

                        <div id="colonneGauche">
                        <div id="hierarchie"><a href="index.php" ><?php echo $lang ['TXT_ACCUEIL']; ?></a>
              <?php     echo '> <a href="listeDossiers.php?userid='.$_SESSION['userid'].'">'.$lang ['TXT_SELECT'].'</a>' ?>    <!-- LA 27/06/2013 $_GET['userid'].'">'.$lang ['TXT_SELECT'].'</a>' ?> -->
              <?php     echo '> '.$lang ['TXT_RESULTATS'] ?> </div>
                        </div>
                        <div id="colonneCentre">


<?php

    $mode = isset($_REQUEST['f_mode']) ? $_REQUEST['f_mode'] : "";
    if (isset($_GET['dossier'])) // LA 27/06/2013
    { $_SESSION['dossier']=$_GET['dossier']; }



    ## +---------------------------------------------------------------------------+
    ## | 1. Creating & Calling:                                                    |
    ## +---------------------------------------------------------------------------+
    ##  *** define a relative (virtual) path to datagrid.class.php file
    ##  *** (relatively to the current file)
    ##  *** RELATIVE PATH ONLY ***
      include("connection.php");

      // dans le cas d'un seul résultat ou de la dermande du dernier on affiche celui ci
      if (isset($_GET['lastresults'])) {
        if ((nbNummer($_SESSION['dossier'], $nummer)==1)||($_GET['lastresults']==1)) {
        	if ($_GET['lastresults']==1)
            {header('Location:getResults.php?nummer='.$_SESSION['dossier']);
            }
            else
            {     header('Location:getResults.php?nummer='.$nummer);
            }
            }
      }

      // dans le cas contraire, on affiche la grille avec la liste de toutes les analyses
      define("DATAGRID_DIR", "");
      define("PEAR_DIR", DATAGRID_DIR."modules/pear/");
      require_once(DATAGRID_DIR.'datagrid.class.php');

      // includes database connection parameters
      include_once('install/config.inc.php');


      ob_start();
    ##  *** set needed options and create a new class instance
      $debug_mode = false;        /* display SQL statements while processing */
      $messaging = true;          /* display system messages on a screen */
      $unique_prefix = "f_";    /* prevent overlays - must be started with a letter */
      $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix);


    ##  *** set data source with needed options
    ##  *** put a primary key on the first place
      $sql= "select r.nummer, r.reqdate, (case when r.Status='R' then '".$lang ['TXT_RES_part']
	     ."'  				   when r.Status='P' then '".$lang ['TXT_RES_part']
	     ."'				   when r.Status='I' then '".$lang ['TXT_RES_part']
             ."'                                   when r.status='F' then '".$lang ['TXT_RES_complet']."' end) as state, concat(d.name, ' ', d.firstname) as doctor"
             ." from request r, users d"
             ." where dossier=".$_SESSION['dossier']// LA 27/06/2013 $_GET['dossier']
             ." and r.doctor=d.code";
      $default_order = array("r.reqdate"=>"DESC");
      $dgrid->DataSource("PEAR", "mysql", $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS, $sql, $default_order);
      $dgrid->controlsDisplayingType = "grouped";

    ## +---------------------------------------------------------------------------+
    ## | 2. General Settings:                                                      |
    ## +---------------------------------------------------------------------------+

     $dg_encoding = "utf8";
     $dg_collation = "utf8_unicode_ci";
     $dgrid->SetEncoding($dg_encoding, $dg_collation);
    ##  *** interface language

     $dg_language = $_SESSION['lang'];
     $dgrid->SetInterfaceLang($dg_language);
    ##  *** set direction: "ltr" or "rtr" (default - "ltr")
     $direction = "ltr";
     $dgrid->SetDirection($direction);
    ##  *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
     $layouts = array("view"=>"0", "details"=>"2", "filter"=>"1");##"edit"=>"1", "details"=>"2", "filter"=>"1");
     $dgrid->SetLayouts($layouts);


     $filtering_option = true;
     $show_search_type = true;
     $dgrid->AllowFiltering($filtering_option, $show_search_type);

     $filtering_fields = array(
     $lang ['TXT_TAB_DEMANDEUR'] => array("table"=>"d", "field"=>"name",  "source"=>"self", "show_operator"=>"false", "default_operator"=>"like%", "order"=>"ASC", "type"=>"textbox", "case_sensitive"=>"false", "comparison_type"=>"string"),
     );
     $dgrid->SetFieldsFiltering($filtering_fields);


    ##  *** set modes for operations ("type" => "link|button|image")
    ##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
     $modes = array(
        "add"	 =>array("view"=>false, "edit"=>false, "type"=>"link"),
        "edit"	 =>array("view"=>false, "edit"=>true,  "type"=>"image", "byFieldValue"=>""),
        "details" =>array("view"=>false, "edit"=>false, "type"=>"image"),
        "delete"  =>array("view"=>false, "edit"=>true,  "type"=>"image")
     );
     $dgrid->SetModes($modes);
    ##  *** allow scrolling on datagrid
    /// $scrolling_option = false;
    /// $dgrid->AllowScrollingSettings($scrolling_option);
    ##  *** set scrolling settings (optional)
    /// $scrolling_height = "200px";
    /// $dgrid->SetScrollingSettings($scrolling_height);
    ##  *** allow mulirow operations
     $multirow_option = true;
     $dgrid->AllowMultirowOperations($multirow_option);
     $multirow_operations = array(
        "delete"  => array("view"=>false),
        "details" => array("view"=>false)
     );
     $dgrid->SetMultirowOperations($multirow_operations);
    ##  *** set CSS class for datagrid
    ##  *** "default" or "blue" or "gray" or "green" or your css file relative path with name
     $css_class = "x-blue";
     $dgrid->SetCssClass($css_class);
    ##  *** set variables that used to get access to the page (like: my_page.php?act=34&id=56 etc.)
    /// $http_get_vars = array("id");
    /// $dgrid->SetHttpGetVars($http_get_vars);
    ##  *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
    ##  *** format (in wich mode to allow processing of another datagrids)
    ##  *** array("unique_prefix"=>array("view"=>true|false, "edit"=>true|false, "details"=>true|false));
     $anotherDatagrids = array("fp_"=>array("view"=>false, "edit"=>false, "details"=>false));
     $dgrid->SetAnotherDatagrids($anotherDatagrids);
    ##  *** set DataGrid caption

    if (isset($_GET['patient']))
    { $_SESSION['patient']=$_GET['patient']; }
     $dg_caption = "<b>".$lang ['TXT_TITRERES']."".$_SESSION['patient']."</b><br/> - <a href=listeDossiers.php?userid=".$_SESSION['userid'].">".$lang ['TXT_RETOURSELEC']."</a>";// LA 27/06/2013 $_GET['userid'].">".$lang ['TXT_RETOURSELEC']."</a>";
     $dgrid->SetCaption($dg_caption);

    ## +---------------------------------------------------------------------------+
    ## | 3. Printing & Exporting Settings:                                         |
    ## +---------------------------------------------------------------------------+
    ##  *** set printing option: true(default) or false
     $printing_option = false;
     $dgrid->AllowPrinting($printing_option);
    ##  *** set exporting option: true(default) or false
     $exporting_option = true;
     $export_all = false;
     $dgrid->AllowExporting($exporting_option, $export_all);
     $exporting_types = array("csv"=>"false", "xls"=>"false", "pdf"=>"FALSE", "xml"=>"FALSE"); // LA 09/13 liens pdf et xml
     $dgrid->AllowExportingTypes($exporting_types);

    ## +---------------------------------------------------------------------------+
    ## | 4. Sorting & Paging Settings:                                             |
    ## +---------------------------------------------------------------------------+
    ##  *** set sorting option: true(default) or false
     $sorting_option = true;
     $dgrid->AllowSorting($sorting_option);
    ##  *** set paging option: true(default) or false
     $paging_option = true;
     $rows_numeration = false;
     $numeration_sign = "N #";
     $dgrid->AllowPaging($paging_option, $rows_numeration, $numeration_sign);
    ##  *** set paging settings
     $bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
     $top_paging = array();
     $pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
     $default_page_size = 10;
     $dgrid->SetPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);



    ## +---------------------------------------------------------------------------+
    ## | 6. View Mode Settings:                                                    |
    ## +---------------------------------------------------------------------------+
    ##  *** set view mode table properties
    /// $vm_table_properties = array("width"=>"90%");
    /// $dgrid->SetViewModeTableProperties($vm_table_properties);
    ##  *** set columns in view mode
    ##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
    ##  ***      "barchart" : number format in SELECT SQL must be equal with number format in max_value
     $vm_colimns = array(
        "nummer"  =>array("header"=>$lang ['TXT_TAB_DEMANDE'], "type"=>"link", "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1",
                         "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false",
                         "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"nummer",
                         "field_key_1"=>"name", "field_key_2"=>"fname", "field_data"=>"name", "rel"=>"", "title"=>"", "target"=>"_self",
                         "href"=>"getResults.php?nummer={0}"),
        "reqdate" =>array("header"=>$lang ['TXT_TAB_DATE'],       "type"=>"label", "width"=>"130px", "align"=>"left",   "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),//"align"=>"left", "width"=>"130px", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal", "summarize"=>false, "on_js_event"=>""),
        "state"   =>array("header"=>$lang ['TXT_TAB_ETAT'],       "type"=>"label", "summarize"=>false, "align"=>"right",  "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
        "doctor"  =>array("header"=>$lang ['TXT_TAB_DEMANDEUR'], "type"=>"label", "summarize"=>false, "align"=>"right",  "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
      );
      $dgrid->SetColumnsInViewMode($vm_colimns);

    ## +---------------------------------------------------------------------------+
    ## | 7. Add/Edit/Details Mode Settings:                                        |
    ## +---------------------------------------------------------------------------+
    ##  *** set add/edit mode table properties
    /// $em_table_properties = array("width"=>"70%");
    /// $dgrid->SetEditModeTableProperties($em_table_properties);
    ##  *** set details mode table properties
    /// $dm_table_properties = array("width"=>"70%");
    /// $dgrid->SetDetailsModeTableProperties($dm_table_properties);
    ##  ***  set settings for add/edit/details modes
      $table_name  = "request";
      $primary_key = "nummer";
      $condition   = "";
    ##  $dgrid->SetTableEdit($table_name, $primary_key, $condition);
    ##  *** set columns in edit mode
    ##  *** first letter: r - required, s - simple (not required)
    ##  *** second letter: t - text(including datetime), n - numeric, a - alphanumeric, e - email, f - float, y - any, l - login name, z - zipcode, p - password, i - integer, v - verified
    ##  *** third letter (optional):
    ##          for numbers: s - signed, u - unsigned, p - positive, n - negative
    ##          for strings: u - upper,  l - lower,    n - normal,   y - any
    ##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
    ##  *** Ex.: type = textbox|textarea|label|date(yyyy-mm-dd)|datedmy(dd-mm-yyyy)|datetime(yyyy-mm-dd hh:mm:ss)|datetimedmy(dd-mm-yyyy hh:mm:ss)|image|password|enum|print|checkbox
    ##  *** make sure your WYSIWYG dir has 755 permissions
      $fill_from_array = array("10000"=>"10000", "250000"=>"250000", "5000000"=>"5000000", "25000000"=>"25000000", "100000000"=>"100000000");
      $em_columns = array(
        "delimiter_1"    =>array("inner_html"=>"<b>First Image</b><br />"),
        "delimiter_2"    =>array("inner_html"=>"<b>Second Image</b><br />"),

        //"region_id"        =>array("header"=>"Region",           "type"=>"textbox",  "width"=>"210px", "req_type"=>"rt", "title"=>"Region Name"),
        //"name"             =>array("header"=>"Country",          "type"=>"textbox",  "width"=>"210px", "req_type"=>"ry", "title"=>"Country Name", "unique"=>true),
       );
    ##  $dgrid->SetColumnsInEditMode($em_columns);


    ## +---------------------------------------------------------------------------+
    ## | 8. Bind the DataGrid:                                                     |
    ## +---------------------------------------------------------------------------+
    ##  *** bind the DataGrid and draw it on the screen
      $dgrid->Bind();
      ob_end_flush();
      echo
      	   '<center>'
		  .'  <p class="boutons">'
          .'    <input type="submit" class="submit" value="'.$lang['TXT_RESULTATS'].'" name="btnresults" onclick="javascript:getresults()"/>' 
          .'  </p>'
          .'</center>';





?>
 </div><!--fin colonneCentre-->
                       <div class="clear"></div>
                </div><!--fin page-->
                </div>
<?php
  include ("piedpage.php");
 ?>
            </div><!--fin conteneur-->

</body>
</html>
A est ce à partir de là que je dois repartir ?

merci

Petit nouveau ! | 5 Messages

20 mai 2014, 18:52

Bonjour

Voilà je pense avoir récupe mais le pdf qui s'affiche est vide pas de données et pas de structure document colonne cadre,...
<?php
  session_start();
  ini_set("display_errors",0);error_reporting(0);

    ?>
<?php 
 ob_start(); ?> 
 $contents ="<page>

       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>serveur de resultats</title>
  </head>
<body>
<?php include ('language.php'); ?>
<?php
  include ('configuration.php');
  require ('Var_Dump.php'); // make sure the pear package path is set in php.ini
  $_SESSION["ListOrigin"] = "";

  include "include/functions.inc.php";
  include "include/classes.inc.php";
  include "language/".$lang."/defines.inc";
  //echo $_GET['nummer']." ".$_SESSION['userid']." ".$_SESSION["dossier"];

  $req_arr   = explode (",", $_GET['nummer']);
  $code      = $_SESSION['userid'];
  $rsaFile   = getParameter('client', 'folder')."/RSA.ini";
  $fromwhere = "RSANew/resultats.php";
  $_SESSION["origin"]=$fromwhere;

  //print_r($req_arr);
  //$arr = array();
  //for ($i=1;$i<=count($req_arr); $i++)
  //{
  //	$x = "request".$i;
  //	if (${$x} != "") {
  //		array_push($arr,${$x});
  //	}
  //}
  krsort($req_arr);
  //print_r ($req_arr);



  define("OPEN", "open");
  define("CLOSE", "close");

  if (count($req_arr)>0)
  {
    $rto = 100;



  	if (count($req_arr)==1) {
  		$report    = new Report($req_arr[0],$fromwhere,$rsaFile);
    

	$xslfile   = getParameter('client', 'folder')."/xsl/report".$_SESSION['lang'].".xsl";
  		$report->MakeXML($xslfile);
 
      
  	}
  	else
  	{
  		$report    = new CumulReport($req_arr,$code,false,$rsaFile,$fromwhere);
    	$xslfile   = getParameter('client', 'folder')."/xsl/cumulT_".$_SESSION['lang'].".xsl";
  		$report->MakeXML($xslfile);
  		$file = $content->xmlfile;
  	}

  	

  }
?>
</body>
</html>
</page>";

<?php
$contents = $report ;
$contents = ob_get_contents(); 
  require_once(dirname(__FILE__).'/html2pdf/html2pdf.class.php');  
   $html2pdf = new HTML2PDF('P','A4','fr'); 
        $html2pdf->WriteHTML($contents); 
        ob_clean(); 
        $html2pdf->Output('exemple.pdf'); 
        
?>
merci pour votre aide