By: M. Polat
Date: 2014-10-06
Time: 10:44
|
MySQL->DOCX block with repeating records
Hello
I am using the the following Query for a docx template. In this query I have many records per person and I want to have a block. I want to have a code in a docx page that create per person on one page. Than meand, when I have 10 persons (PId) then I will have a docx file with 10 pages. For the next person it should add a second page an so on. The coloumn of personId is "PId".
Could please someone help me to create such a block? I am lost with the manuell. Or can someome give me some help where to read for such cases?
My Query: $TBS->MergeBlock('ml','mysql',"SELECT * FROM lohnpositionen Where RefId=$Id Order BY PId, Flag");
MyBlock: [ml.Num;block=w:tr] [ml.Art] [ml.PId] [ml.Menge] [ml.Ansatz] [ml.Total]
Thanks
mpol_ch
|
By: M. Polat
Date: 2014-10-06
Time: 14:46
|
Re: MySQL->DOCX block with repeating records
Just for additional Information. I am using now the following information but I am receiving no results. What am I doing wrong?
$TBS->LoadTemplate('tbs/vorlagen/vorlagelohn.docx');
$TBS->MergeBlock('main','mysql', 'SELECT PId,Num,Art,Flag,Prozent,Menge,Ansatz,Total FROM lohnpositionen');
$TBS->MergeBlock('sub', 'mysql', 'SELECT Num,Art,Flag,Prozent,Menge,Ansatz,Total FROM lohnpositionen WHERE (PId=%p1%)');
[main.PId;block=begin]
[sub.Num; p1=[main.PId]]
[main.PId;block=end]
and I am getting the following error:
TinyButStrong Error when merging block [sub]: MySql error message when opening the query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%p1%)' at line 1
TinyButStrong Error Show() Method: The output is cancelled by the OpenTBS plugin because at least one error has occured.
thanks
mpol_ch
|
By: M. Polat
Date: 2014-10-07
Time: 06:40
|
Re: MySQL->DOCX block with repeating records
Hello
I solved my problem witht the following code.
PHP Side:
$TBS->LoadTemplate('tbs/vorlagen/vorlagelohn.docx',OPENTBS_ALREADY_UTF8);
$TBS->MergeBlock('main','mysql', "SELECT PId,RefId,Datum,Vom,Bis,Monat,Jahr,Num,Art,Total FROM loehne WHERE Monat=$Monat AND Jahr=$Jahr AND RefId=$Id ");
$TBS->MergeBlock('sub', 'mysql', "SELECT Num,Art,Flag,Prozent,Menge,Ansatz,Total FROM lohnpositionen WHERE (PId ='%p1%') AND RefId=$Id");
$TBS->MergeBlock('subma','mysql', "SELECT maid,maanrede,maname,mavname,mastr,maplz,maort FROM mitarbeiter WHERE (maid ='%p1%')");
DOCX Side:
[main;block=begin]
Personal-Nr:[main.PId]
Datum:[main.Datum;frm=dd.mm.yyyy]
[subma;block=begin;p1=[main.PId]]
[subma.maanrede]
[subma.maname] [subma.mavname]
[subma.mastr]
[subma.maplz] [subma.maort]
[subma;block=end]
[sub.Num;block=w:tr;p1=[main.PId]] [sub.Art] [sub.Prozent] [sub.Menge] [sub.Ansatz] [sub.Total]
[main;block=end]
Thanks
mpol_ch
|