1 | #!/usr/bin/php -f |
||||
2 | <?php |
||||
3 | /** |
||||
4 | * FlexiPeeHP - Example how to find overdue invoices |
||||
5 | * |
||||
6 | * @author Vítězslav Dvořák <[email protected]> |
||||
7 | * @copyright (G) 2017 Vitex Software |
||||
8 | */ |
||||
9 | |||||
10 | namespace Example\FlexiPeeHP; |
||||
11 | |||||
12 | include_once './config.php'; |
||||
13 | include_once '../vendor/autoload.php'; |
||||
14 | |||||
15 | /** |
||||
16 | * Get Number of days overdue |
||||
17 | * |
||||
18 | * @param string $dueDate FlexiBee date |
||||
19 | * @return int |
||||
20 | */ |
||||
21 | function poSplatnosti($dueDate) |
||||
22 | { |
||||
23 | return intval(date_diff(\FlexiPeeHP\FlexiBeeRO::flexiDateToDateTime($dueDate), |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
24 | new \DateTime())->format('%a')); |
||||
25 | } |
||||
26 | |||||
27 | /** |
||||
28 | * Vrať faktury po splatnosti |
||||
29 | * |
||||
30 | * @param \FlexiPeeHP\FakturaVydana $invoicer |
||||
31 | * @return array |
||||
32 | */ |
||||
33 | function getOverdueInvoices($invoicer) |
||||
34 | { |
||||
35 | $result = null; |
||||
36 | $invoicer->defaultUrlParams['order'] = 'datVyst@A'; |
||||
37 | $invoicer->defaultUrlParams['relations'] = 'adresar,kontakt'; |
||||
38 | $invoices = $invoicer->getColumnsFromFlexibee([ |
||||
39 | 'id', |
||||
40 | 'kod', |
||||
41 | 'stavUhrK', |
||||
42 | 'firma', |
||||
43 | 'buc', |
||||
44 | 'varSym', |
||||
45 | 'specSym', |
||||
46 | 'sumCelkem', |
||||
47 | 'duzpPuv', |
||||
48 | 'datSplat', |
||||
49 | 'datVyst'], |
||||
50 | "(stavUhrK is null OR stavUhrK eq 'stavUhr.castUhr') AND storno eq false", |
||||
0 ignored issues
–
show
'(stavUhrK is null OR st...') AND storno eq false' of type string is incompatible with the type array expected by parameter $conditions of FlexiPeeHP\RO::getColumnsFromFlexiBee() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
51 | 'id'); |
||||
52 | |||||
53 | if ($invoicer->lastResponseCode == 200) { |
||||
54 | $result = $invoices; |
||||
55 | } |
||||
56 | return $result; |
||||
57 | } |
||||
58 | $statuser = new \FlexiPeeHP\Status(); |
||||
59 | $invoicer = new \FlexiPeeHP\FakturaVydana(); |
||||
60 | $firmer = new \FlexiPeeHP\Adresar(); |
||||
61 | |||||
62 | foreach (getOverdueInvoices($invoicer) as $invoice) { |
||||
63 | $kontakt = $firmer->getColumnsFromFlexibee(['nazev', 'email'], |
||||
64 | ['id' => $invoice['firma']]); |
||||
65 | |||||
66 | if (isset($kontakt[0]['email'])) { |
||||
67 | $invoicer->setMyKey($invoice['id']); |
||||
68 | |||||
69 | $to = $kontakt[0]['email']; |
||||
70 | $subject = sprintf(_('Overdue invoice: %s - %s days'), $invoice['kod'], |
||||
71 | poSplatnosti($invoice['datSplat'])); |
||||
72 | $body = sprintf(_('Please pay %s,-'), $invoice['sumCelkem']); |
||||
73 | |||||
74 | if ($statuser->getDataValue('licenseVariant') == 'basic') { |
||||
75 | $mail = new \Ease\Mailer($to, $subject, $body); |
||||
76 | $mail->addFile($invoicer->downloadInFormat('pdf', '/tmp/')); |
||||
77 | $mail->addFile($invoicer->downloadInFormat('isdoc', '/tmp/')); |
||||
78 | $mail->send(); |
||||
79 | } else { |
||||
80 | if ($invoicer->sendByMail($to, $subject, $body)) { |
||||
81 | $invoicer->addStatusMessage(spritnf(_('Message sent: %s to %s'), |
||||
0 ignored issues
–
show
The function
spritnf was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
82 | $subject, $to), 'mail'); |
||||
83 | } |
||||
84 | } |
||||
85 | } |
||||
86 | } |
||||
87 |