Intraface_modules_debtor_Visitor_Pdf::visit()   F
last analyzed

Complexity

Conditions 58
Paths > 20000

Size

Total Lines 311
Code Lines 200

Duplication

Lines 73
Ratio 23.47 %

Code Coverage

Tests 0
CRAP Score 3422

Importance

Changes 0
Metric Value
cc 58
eloc 200
nc 175507456
nop 2
dl 73
loc 311
rs 2
c 0
b 0
f 0
ccs 0
cts 238
cp 0
crap 3422

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Creates a pdf of a debtor. The class implements the visitor pattern.
4
 *
5
 * The debtor must comply with a certain interface.
6
 *
7
 * PHP version 5
8
 *
9
 * TODO Put in the doc instead of having it started up.
10
 *
11
 * <code>
12
 * $file = new FileHandler($file_id);
13
 * $report = new Debtor_Report_Pdf($file);
14
 * $report->visit($debtor);
15
 * </code>
16
 *
17
 * @package Intraface_Debtor
18
 * @author Lars Olesen <[email protected]>
19
 * @author Sune Jensen <[email protected]>
20
 */
21
class Intraface_modules_debtor_Visitor_Pdf extends Intraface_modules_debtor_Pdf
22
{
23
    /**
24
     * Constructor
25
     *
26
     * @param object $translation Used to do the translation in the class
27
     * @param object $file        File to use for the header
28
     *
29
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
30
     */
31 1
    function __construct($translation, $file = null)
32
    {
33 1
        parent::__construct($translation, $file);
34 1
    }
35
36
    /**
37
     * Visitor for the debtor
38
     *
39
     * @param object $debtor The debtor to be written
40
     *
41
     * @return void
42
     */
43
    function visit($debtor, $onlinepayment = null)
44
    {
45
        $this->doc = $this->getDocument();
46
47 View Code Duplication
        if (!empty($this->file) and $this->file->get('id') > 0) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as and instead of && is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
48
            $this->doc->addHeader($this->file->get('file_uri_pdf'));
49
        }
50
51
        $this->doc->setY('-5');
52
53
        $contact = $debtor->contact->address->get();
54
        if (is_object($debtor->contact_person)) {
55
            $contact["attention_to"] = $debtor->contact_person->get("name");
56
        }
57
        $contact['number'] = $debtor->contact->get('number');
58
59
        $intranet_address = $debtor->getIntranetAddress();
60
        $intranet = $intranet_address->get();
61
62
        $intranet = array_merge($intranet, $debtor->getContactInformation());
63
64
        $this->docinfo[0]["label"] = $this->translation->get($debtor->get('type').' number').":";
0 ignored issues
show
Bug introduced by
The property docinfo does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
65
        $this->docinfo[0]["value"] = $debtor->get("number");
66
        $this->docinfo[1]["label"] = "Dato:";
67
        $this->docinfo[1]["value"] = $debtor->get("dk_this_date");
68
        if ($debtor->get("type") != "credit_note" && $debtor->get("due_date") != "0000-00-00") {
69
            $this->docinfo[2]["label"] = $this->translation->get($debtor->get('type').' due date').":";
70
            $this->docinfo[2]["value"] = $debtor->get("dk_due_date");
71
        }
72
73
        $this->addRecieverAndSender($contact, $intranet, $this->translation->get($debtor->get('type')), $this->docinfo);
74
75
        $this->doc->setY('-'.$this->doc->get("font_spacing"));
76
77
        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
78
            $this->doc->nextPage(true);
79
        }
80
81
        if ($debtor->get('message')) {
82
            $text = explode("\r\n", $debtor->get('message'));
83 View Code Duplication
            foreach ($text as $line) {
84
                if ($line == "") {
85
                    $this->doc->setY('-'.$this->doc->get("font_spacing"));
86
                    if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
87
                        $this->doc->nextPage(true);
88
                    }
89
                } else {
90
                    while ($line != "") {
91
                        $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
92
                        $line = $this->doc->addTextWrap($this->doc->get('margin_left'), $this->doc->get('y'), $this->doc->get('content_width'), $this->doc->get("font_size"), $line);
93
                        $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
94
                        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
95
                            $this->doc->nextPage(true);
96
                        }
97
                    }
98
                }
99
            }
100
        }
101
102
        // Headlines for the products
103
        $this->doc->setY('-40'); // space to the product list
104
105
        $apointX["varenr"] = 80;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$apointX was never initialized. Although not strictly required by PHP, it is generally a good practice to add $apointX = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
106
        $apointX["tekst"] = 90;
107
        $apointX["antal"] = $this->doc->get("right_margin_position") - 150;
108
        $apointX["enhed"] = $this->doc->get('right_margin_position') - 145;
109
        $apointX["pris"] = $this->doc->get('right_margin_position') - 60;
110
        $apointX["beloeb"] = $this->doc->get('right_margin_position');
111
        $apointX["tekst_width"] = $this->doc->get('right_margin_position') - $this->doc->get("margin_left") - $apointX["tekst"] - 60;
112
        $apointX["tekst_width_small"] = $apointX["antal"] - $this->doc->get("margin_left") - $apointX["tekst"];
113
114
115
        $this->doc->addText($apointX["varenr"] - $this->doc->getTextWidth($this->doc->get("font_size"), "Varenr."), $this->doc->get('y'), $this->doc->get("font_size"), "Varenr.");
116
        $this->doc->addText($apointX["tekst"], $this->doc->get('y'), $this->doc->get("font_size"), "Tekst");
117
        $this->doc->addText($apointX["antal"] - $this->doc->getTextWidth($this->doc->get("font_size"), "Antal"), $this->doc->get('y'), $this->doc->get("font_size"), "Antal");
118
        $this->doc->addText($apointX["pris"] - $this->doc->getTextWidth($this->doc->get("font_size"), "Pris"), $this->doc->get('y'), $this->doc->get("font_size"), "Pris");
119
        $this->doc->addText($apointX["beloeb"] - $this->doc->getTextWidth($this->doc->get("font_size"), "Beløb") -3, $this->doc->get('y'), $this->doc->get("font_size"), "Beløb");
120
121
        $this->doc->setY('-'.($this->doc->get("font_spacing") - $this->doc->get("font_size")));
122
123
        $this->doc->line($this->doc->get("margin_left"), $this->doc->get('y'), $this->doc->get('right_margin_position'), $this->doc->get('y'));
124
125
        // products
126
        $items = $debtor->getItems();
127
128
        $total = 0;
129
        if ($debtor->getCurrency()) {
130
            $total_currency = 0;
0 ignored issues
show
Unused Code introduced by
$total_currency is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
131
        }
132
133 View Code Duplication
        if (isset($items[0]["vat"])) {
134
            $vat = $items[0]["vat"];
0 ignored issues
show
Unused Code introduced by
$vat is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
135
        } else {
136
            $vat = 0;
0 ignored issues
show
Unused Code introduced by
$vat is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
137
        }
138
139
        $bg_color = 0;
140
141
        for ($i = 0, $max = count($items); $i <  $max; $i++) {
142
            $vat = $items[$i]["vat"];
143
144 View Code Duplication
            if ($bg_color == 1) {
145
                $this->doc->setColor(0.8, 0.8, 0.8);
146
                $this->doc->filledRectangle($this->doc->get("margin_left"), $this->doc->get('y') - $this->doc->get("font_spacing"), $this->doc->get('right_margin_position') - $this->doc->get("margin_left"), $this->doc->get("font_spacing"));
147
                $this->doc->setColor(0, 0, 0);
148
            }
149
150
            $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
151
            $this->doc->addText($apointX["varenr"] - $this->doc->getTextWidth($this->doc->get("font_size"), $items[$i]["number"]), $this->doc->get('y'), $this->doc->get("font_size"), $items[$i]["number"]);
152
153
            if ($items[$i]["unit"] != "") {
154
                $this->doc->addText($apointX["antal"] - $this->doc->getTextWidth($this->doc->get("font_size"), number_format($items[$i]["quantity"], 2, ",", ".")), $this->doc->get('y'), $this->doc->get("font_size"), number_format($items[$i]["quantity"], 2, ",", "."));
155
                $this->doc->addText($apointX["enhed"], $this->doc->get('y'), $this->doc->get("font_size"), $this->translation->get($items[$i]["unit"], 'product'));
156
                if ($debtor->getCurrency()) {
157
                    $this->doc->addText($apointX["pris"] - $this->doc->getTextWidth($this->doc->get("font_size"), $items[$i]["price_currency"]->getAsLocale('da_dk', 2)), $this->doc->get('y'), $this->doc->get("font_size"), $items[$i]["price_currency"]->getAsLocale('da_dk', 2));
158
                } else {
159
                    $this->doc->addText($apointX["pris"] - $this->doc->getTextWidth($this->doc->get("font_size"), $items[$i]["price"]->getAsLocale('da_dk', 2)), $this->doc->get('y'), $this->doc->get("font_size"), $items[$i]["price"]->getAsLocale('da_dk', 2));
160
                }
161
            }
162
            
163
            if ($debtor->getCurrency()) {
164
                $amount =  $items[$i]["quantity"] * $items[$i]["price_currency"]->getAsIso(2);
165
            } else {
166
                $amount =  $items[$i]["quantity"] * $items[$i]["price"]->getAsIso(2);
167
            }
168
            $total += $amount;
169
170
            $this->doc->addText($apointX["beloeb"] - $this->doc->getTextWidth($this->doc->get("font_size"), number_format($amount, 2, ",", ".")), $this->doc->get('y'), $this->doc->get("font_size"), number_format($amount, 2, ",", "."));
171
172
            $tekst = $items[$i]["name"];
173
            $first = true;
174
175
            while ($tekst != "") {
176
                if (!$first) {
177
                    // first line has already got coloured
178 View Code Duplication
                    if ($bg_color == 1) {
179
                        $this->doc->setColor(0.8, 0.8, 0.8);
180
                        $this->doc->filledRectangle($this->doc->get("margin_left"), $this->doc->get('y') - $this->doc->get("font_spacing"), $this->doc->get('right_margin_position') - $this->doc->get("margin_left"), $this->doc->get("font_spacing"));
181
                        $this->doc->setColor(0, 0, 0);
182
                    }
183
                    $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
184
                }
185
                $first = false;
186
187
188
                $tekst = $this->doc->addTextWrap($apointX["tekst"], $this->doc->get('y'), $apointX["tekst_width_small"], $this->doc->get("font_size"), $tekst);
189
                $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
190
                if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
191
                    $this->doc->nextPage(true);
192
                }
193
            }
194
195
            if ($items[$i]["description"] != "") {
196
                // space to the text
197
                $this->doc->setY('-'.($this->doc->get("font_spacing")/2));
198 View Code Duplication
                if ($bg_color == 1) {
199
                    $this->doc->setColor(0.8, 0.8, 0.8);
200
                    $this->doc->filledRectangle($this->doc->get("margin_left"), $this->doc->get('y'), $this->doc->get('right_margin_position') - $this->doc->get("margin_left"), $this->doc->get("font_spacing")/2);
201
                    $this->doc->setColor(0, 0, 0);
202
                }
203
204
                $desc_line = explode("\r\n", $items[$i]["description"]);
205
                foreach ($desc_line as $line) {
206
                    if ($line == "") {
207 View Code Duplication
                        if ($bg_color == 1) {
208
                            $this->doc->setColor(0.8, 0.8, 0.8);
209
                            $this->doc->filledRectangle($this->doc->get("margin_left"), $this->doc->get('y') - $this->doc->get("font_spacing"), $this->doc->get('right_margin_position') - $this->doc->get("margin_left"), $this->doc->get("font_spacing"));
210
                            $this->doc->setColor(0, 0, 0);
211
                        }
212
                        $this->doc->setY('-'.$this->doc->get("font_spacing"));
213
                        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
214
                            $this->doc->nextPage(true);
215
                        }
216
                    } else {
217
                        while ($line != "") {
218 View Code Duplication
                            if ($bg_color == 1) {
219
                                $this->doc->setColor(0.8, 0.8, 0.8);
220
                                $this->doc->filledRectangle($this->doc->get("margin_left"), $this->doc->get('y') - $this->doc->get("font_spacing"), $this->doc->get('right_margin_position') - $this->doc->get("margin_left"), $this->doc->get("font_spacing"));
221
                                $this->doc->setColor(0, 0, 0);
222
                            }
223
224
                            $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
225
                            $line = $this->doc->addTextWrap($apointX["tekst"], $this->doc->get('y') + 1, $apointX["tekst_width"], $this->doc->get("font_size"), $line); // Ups Ups, hvor kommer '+ 1' fra - jo ser du, ellers kappes det nederste af teksten!
226
                            $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
227
228
                            if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
229
                                $this->doc->nextPage(true);
230
                            }
231
                        }
232
                    }
233
                }
234
            }
235
236
            if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
237
                $this->doc->nextPage(true);
238
            }
239
240
            // If products with VAT and next post is without we add VAT.
241
            if (($vat == 1 && isset($items[$i+1]["vat"]) && $items[$i+1]["vat"] == 0) || ($vat == 1 && $i+1 >= $max)) {
242
                // If VAT on current product, but next has no VAT OR if VAT and last product
243
244
                ($bg_color == 1) ? $bg_color = 0 : $bg_color = 1;
245
246 View Code Duplication
                if ($bg_color == 1) {
247
                    $this->doc->setColor(0.8, 0.8, 0.8);
248
                    $this->doc->filledRectangle($this->doc->get("margin_left"), $this->doc->get('y') - $this->doc->get("font_spacing"), $this->doc->get('right_margin_position') - $this->doc->get("margin_left"), $this->doc->get("font_spacing"));
249
                    $this->doc->setColor(0, 0, 0);
250
                }
251
252
                $this->doc->setLineStyle(0.5);
253
                $this->doc->line($this->doc->get("margin_left"), $this->doc->get('y'), $this->doc->get('right_margin_position'), $this->doc->get('y'));
254
                $this->doc->setY('-'.($this->doc->get("font_size") + $this->doc->get("font_padding_top")));
255
                $this->doc->addText($apointX["tekst"], $this->doc->get('y'), $this->doc->get("font_size"), "<b>25% moms af ".number_format($total, 2, ",", ".")."</b>");
256
                $this->doc->addText($apointX["beloeb"] - $this->doc->getTextWidth($this->doc->get("font_size"), "<b>".number_format($total * 0.25, 2, ",", ".")."</b>"), $this->doc->get('y'), $this->doc->get("font_size"), "<b>".number_format($total * 0.25, 2, ",", ".")."</b>");
257
                $total = $total * 1.25;
258
                $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
259
                $this->doc->line($this->doc->get("margin_left"), $this->doc->get('y'), $this->doc->get('right_margin_position'), $this->doc->get('y'));
260
                $this->doc->setLineStyle(1);
261
                $this->doc->setY('-1');
262
            }
263
264
            ($bg_color == 1) ? $bg_color = 0 : $bg_color = 1;
265
        }
266
267
268
        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
269
            $this->doc->nextPage();
270
        }
271
272
        $this->doc->setLineStyle(1);
273
        $this->doc->line($this->doc->get("margin_left"), $this->doc->get('y'), $this->doc->get('right_margin_position'), $this->doc->get('y'));
274
        if ($debtor->getCurrency()) {
275
            $currency_iso_code = $debtor->getCurrency()->getType()->getIsoCode();
276
            $debtor_total = $debtor->get("total_currency");
277
        } else {
278
            $currency_iso_code = 'DKK';
279
            $debtor_total = $debtor->get("total");
280
        }
281
282
        if ($debtor->get("round_off") == 1 && $debtor->get("type") == "invoice" && $total != $debtor_total) {
283
            $this->doc->setY('-'.($this->doc->get("font_size") + $this->doc->get("font_padding_top")));
284
            $this->doc->addText($apointX["enhed"], $this->doc->get('y'), $this->doc->get("font_size"), "I alt:");
285
            $this->doc->addText($apointX["beloeb"] - $this->doc->getTextWidth($this->doc->get("font_size"), number_format($total, 2, ",", ".")), $this->doc->get('y'), $this->doc->get("font_size"), number_format($total, 2, ",", "."));
286
            $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
287
288
            $total_text = "Total afrundet ".$currency_iso_code.":";
289
        } else {
290
            $total_text = "Total ".$currency_iso_code.":";
291
        }
292
293
        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
294
            $this->doc->nextPage(true);
295
        }
296
297
        $this->doc->setY('-'.($this->doc->get("font_size") + $this->doc->get("font_padding_top")));
298
        $this->doc->addText($apointX["enhed"], $this->doc->get('y'), $this->doc->get("font_size"), "<b>".$total_text."</b>");
299
        $this->doc->addText($apointX["beloeb"] - $this->doc->getTextWidth($this->doc->get("font_size"), "<b>".number_format($debtor_total, 2, ",", ".")."</b>"), $this->doc->get('y'), $this->doc->get("font_size"), "<b>".number_format($debtor_total, 2, ",", ".")."</b>");
300
        $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
301
        $this->doc->line($apointX["enhed"], $this->doc->get('y'), $this->doc->get('right_margin_position'), $this->doc->get('y'));
302
303
        // payment condition
304
        if ($debtor->get("type") == "invoice" || $debtor->get("type") == "order") {
305
            $parameter = array(
306
                "contact" => $debtor->contact,
307
                "payment_text" => ucfirst($this->translation->get($debtor->get('type')))." ".$debtor->get("number"),
308
                "amount" => $debtor->get("total"),
309
                "payment" => $debtor->get('payment_total'),
310
                "payment_online" => 0,
311
                "due_date" => $debtor->get("dk_due_date"),
312
                "girocode" => $debtor->get("girocode"));
313
314
            if (is_object($onlinepayment)) {
315
                $onlinepayment->getDBQuery()->setFilter('belong_to', $debtor->get("type"));
316
                $onlinepayment->getDBQuery()->setFilter('belong_to_id', $debtor->get('id'));
317
                $onlinepayment->getDBQuery()->setFilter('status', 2);
318
319
                foreach ($onlinepayment->getlist() as $p) {
320
                    $parameter['payment_online'] += $p["amount"];
321
                }
322
            }
323
324
325
            $this->addPaymentCondition($debtor->get("payment_method"), $parameter, $debtor->getPaymentInformation());
326
327
            $this->doc->setY('-'.$this->doc->get("font_spacing"));
328
329
            if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
330
                $this->doc->nextPage(true);
331
            }
332
333
            $text = explode("\r\n", $debtor->getInvoiceText());
334 View Code Duplication
            foreach ($text as $line) {
335
                if ($line == "") {
336
                    $this->doc->setY('-'.$this->doc->get("font_spacing"));
337
                    if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
338
                        $this->doc->nextPage(true);
339
                    }
340
                } else {
341
                    while ($line != "") {
342
                        $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
343
                        $line = $this->doc->addTextWrap($this->doc->get('margin_left'), $this->doc->get('y'), $this->doc->get('content_width'), $this->doc->get("font_size"), $line);
344
                        $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
345
346
                        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
347
                            $this->doc->nextPage(true);
348
                        }
349
                    }
350
                }
351
            }
352
        }
353
    }
354
}
355