forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PDFGLJournal.php
114 lines (105 loc) · 3.95 KB
/
PDFGLJournal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/* $Revision: 1.5 $ */
include('includes/session.php');
if (isset($_POST['JournalNo'])) {
$JournalNo=$_POST['JournalNo'];
$Type = $_POST['Type'];
} else if (isset($_GET['JournalNo'])) {
$JournalNo=$_GET['JournalNo'];
$Type = $_GET['Type'];
} else {
$JournalNo='';
}
if (empty($JournalNo) OR empty($Type)) {
prnMsg(_('This page should be called with Journal No and Type'),'error');
include('includes/footer.php');
exit;
}
if ($JournalNo=='Preview') {
$FormDesign = simplexml_load_file(sys_get_temp_dir().'/Journal.xml');
} else {
$FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/Journal.xml');
}
// Set the paper size/orintation
$PaperSize = $FormDesign->PaperSize;
$PageNumber=1;
$line_height=$FormDesign->LineHeight;
include('includes/PDFStarter.php');
$pdf->addInfo('Title', _('General Ledger Journal') );
if ($JournalNo=='Preview') {
$LineCount = 2; // UldisN
} else {
$sql="SELECT gltrans.typeno,
gltrans.trandate,
gltrans.account,
chartmaster.accountname,
gltrans.narrative,
gltrans.amount,
gltrans.tag,
tags.tagdescription,
gltrans.jobref
FROM gltrans
INNER JOIN chartmaster
ON gltrans.account=chartmaster.accountcode
LEFT JOIN tags
ON gltrans.tag=tags.tagref
WHERE gltrans.type='" . $Type . "'
AND gltrans.typeno='" . $JournalNo . "'";
$result=DB_query($sql);
$LineCount = DB_num_rows($result); // UldisN
$myrow=DB_fetch_array($result);
$JournalDate=$myrow['trandate'];
DB_data_seek($result, 0);
include('includes/PDFGLJournalHeader.inc');
}
$counter=1;
$YPos=$FormDesign->Data->y;
while ($counter<=$LineCount) {
if ($JournalNo=='Preview') {
$AccountCode=str_pad('',10,'x');
$Date='1/1/1900';
$Description=str_pad('',30,'x');
$Narrative=str_pad('',30,'x');
$Amount='XXXX.XX';
$Tag=str_pad('',25,'x');
$JobRef=str_pad('',25,'x');
} else {
$myrow=DB_fetch_array($result);
if ($myrow['tag']==0) {
$myrow['tagdescription']='None';
}
$AccountCode = $myrow['account'];
$Description = $myrow['accountname'];
$Date = $myrow['trandate'];
$Narrative = $myrow['narrative'];
$Amount = $myrow['amount'];
$Tag = $myrow['tag'].' - '.$myrow['tagdescription'];
$JobRef = $myrow['jobref'];
}
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x,$Page_Height-$YPos,$FormDesign->Data->Column1->Length,$FormDesign->Data->Column1->FontSize, $AccountCode);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x,$Page_Height-$YPos,$FormDesign->Data->Column2->Length,$FormDesign->Data->Column2->FontSize, $Description);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x,$Page_Height-$YPos,$FormDesign->Data->Column3->Length,$FormDesign->Data->Column3->FontSize, $Narrative);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column4->x,$Page_Height-$YPos,$FormDesign->Data->Column4->Length,$FormDesign->Data->Column4->FontSize, locale_number_format($Amount,$_SESSION['CompanyRecord']['decimalplaces']), 'right');
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column5->x,$Page_Height-$YPos,$FormDesign->Data->Column5->Length,$FormDesign->Data->Column5->FontSize, $Tag);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column6->x,$Page_Height-$YPos,$FormDesign->Data->Column6->Length,$FormDesign->Data->Column6->FontSize, $JobRef, 'left');
$YPos += $line_height;
$counter++;
if ($YPos >= $FormDesign->LineAboveFooter->starty){
/* We reached the end of the page so finsih off the page and start a newy */
$PageNumber++;
$YPos=$FormDesign->Data->y;
include ('includes/PDFGrnHeader.inc');
} //end if need a new page headed up
}
if ($LineCount == 0) { //UldisN
$Title = _('Printing Error');
include('includes/header.php');
prnMsg(_('There were no Journals to print'),'warn');
echo '<br /><a href="'.$RootPath.'/index.php">' . _('Back to the menu') . '</a>';
include('includes/footer.php');
exit;
} else {
$pdf->OutputD($_SESSION['DatabaseName'] . '_Journal_' . date('Y-m-d').'.pdf');//UldisN
$pdf->__destruct(); //UldisN
}
?>