forked from timschofield/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPDFGLJournalCN.php
155 lines (140 loc) · 6.33 KB
/
PDFGLJournalCN.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/* $Revision: 1.5 $2012.2CQZ二次修改 */
include('includes/session.php');
if (isset($_POST['JournalNo'])) {
$JournalNo=$_POST['JournalNo'];
$TypeID=$_POST['Type'];
} else if (isset($_GET['JournalNo'])) {
$JournalNo=$_GET['JournalNo'];
$TypeID=$_GET['Type'];
} else {
$JournalNo='';
$TypeID='';
}
if ($JournalNo=='Preview') {
$FormDesign = simplexml_load_file(sys_get_temp_dir().'/Journalc.xml');
} else {
$FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/Journalc.xml');
}
// Set the paper size/orintation
$PaperSize = $FormDesign->PaperSize;
$PageNumber=1;
$LineHeight=$FormDesign->LineHeight;
include('includes/PDFStarter.php');
$pdf->addInfo('Title', _('中国(甲式10)会计凭证') );
$pdf->addInfo('Author','webERP ' . 'CQZ二次修改');
$pdf->addInfo('Subject',_('会计凭证——中国式会计凭证--登录ERP打印或下载此凭证的用户:').$_SESSION['UsersRealName']);
$pdf->SetProtection(array('modify','copy','annot-forms'), '');
if ($JournalNo=='Preview') {
$LineCount = 2; // UldisN
} else {
$SQL="SELECT gltrans.type,
gltrans.typeno,
gltrans.trandate,
gltrans.account,
systypes.typename,
chartmaster.accountname,
gltrans.narrative,
gltrans.amount,
gltrans.tag,
tags.tagdescription,
gltrans.jobref
FROM gltrans
INNER JOIN chartmaster
ON gltrans.account=chartmaster.accountcode
INNER JOIN systypes
ON gltrans.type=systypes.typeid
LEFT JOIN tags
ON gltrans.tag=tags.tagref
WHERE gltrans.type='".$TypeID."'
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);
$Typemame=$MyRow['typename'];
include('includes/PDFGLJournalHeaderCN.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'];
}
if ( $MyRow['amount'] > 0) {
$DebitAmount = locale_number_format($MyRow['amount'],$_SESSION['CompanyRecord']['decimalplaces']);
$DebitTotal += $MyRow['amount'];
$CreditAmount = ' ';
} else {
$CreditAmount = locale_number_format(-$MyRow['amount'],$_SESSION['CompanyRecord']['decimalplaces']);
$CreditTotal += $MyRow['amount'];
$DebitAmount = ' ';
}
$pdf->SetTextColor(0,0,0);
if((mb_strlen($Narrative,'GB2312')+ substr_count($Narrative," "))>40){
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x+3,$Page_Height-$YPos-5,$FormDesign->Data->Column1->Length,$FormDesign->Data->Column1->FontSize, $Narrative);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x+3,$Page_Height-$YPos+3,$FormDesign->Data->Column2->Length,$FormDesign->Data->Column2->FontSize, $AccountCode);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x+3,$Page_Height-$YPos+3,$FormDesign->Data->Column3->Length,$FormDesign->Data->Column3->FontSize, $Description);
}else{
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x+3,$Page_Height-$YPos,$FormDesign->Data->Column1->Length,$FormDesign->Data->Column1->FontSize, $Narrative);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x+3,$Page_Height-$YPos,$FormDesign->Data->Column2->Length,$FormDesign->Data->Column2->FontSize, $AccountCode);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x+3,$Page_Height-$YPos,$FormDesign->Data->Column3->Length,$FormDesign->Data->Column3->FontSize, $Description);
}
$pdf->SetFont('helvetica', '', 10);
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column4->x+3,$Page_Height-$YPos,$FormDesign->Data->Column4->Length,$FormDesign->Data->Column4->FontSize,$DebitAmount , 'right');
$LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column5->x+3,$Page_Height-$YPos,$FormDesign->Data->Column5->Length,$FormDesign->Data->Column5->FontSize, $CreditAmount, 'right');
$YPos += $LineHeight;
$Counter++;
$DebitTotal1=locale_number_format($DebitTotal,$_SESSION['CompanyRecord']['decimalplaces'], 'right');
$CreditTotal1=locale_number_format(-$CreditTotal,$_SESSION['CompanyRecord']['decimalplaces'], 'right');
$pdf->SetFont('javiergb', '', 10);
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/PDFGLJournalHeaderCN.inc');
}
}
$pdf->setlineStyle(array('width'=>0.8));
$pdf->SetLineStyle(array('color'=>array(0,0,0)));
$pdf->Line($XPos=540, $Page_Height-$YPos+15, $FormDesign->Column33->endx,$Page_Height - $FormDesign->Column33->endy);
//end if need a new page headed up
//$pdf->addJpegFromFile('hjje.jpg',$FormDesign->Headings->Column7->x+3+20,$Page_Height - 282,110,28);
$pdf->SetTextColor(0,0,255);
$pdf->addText($FormDesign->Headings->Column7->x+3,$Page_Height-$FormDesign->Headings->Column7->y,$FormDesign->Headings->Column7->FontSize, _('合 计 金 额'));//$FormDesign->Headings->Column7->name
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('helvetica', '', 10);
$LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column8->x+3,$Page_Height - $FormDesign->Headings->Column8->y, $FormDesign->Headings->Column8->Length,$FormDesign->Headings->Column8->FontSize, $DebitTotal1, 'right');
$LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column9->x+3,$Page_Height - $FormDesign->Headings->Column9->y, $FormDesign->Headings->Column9->Length,$FormDesign->Headings->Column9->FontSize, $CreditTotal1, 'right');
$pdf->SetFont('javiergb', '', 10);
if ($LineCount == 0) { //UldisN
$Title = _('GRN Error');
include('includes/header.php');
prnMsg(_('There were no GRN 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'] . '_GRN_' . date('Y-m-d').'.pdf');//UldisN
$pdf->__destruct(); //UldisN
}
?>