1
|
|
|
#!/usr/bin/php -f |
2
|
|
|
<?php |
3
|
|
|
/** |
4
|
|
|
* FlexiPeeHP - Odeslat Upomínky ? |
5
|
|
|
* |
6
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
7
|
|
|
* @copyright (G) 2017-2019 Vitex Software |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Example\FlexiPeeHP; |
11
|
|
|
|
12
|
|
|
include_once './config.php'; |
13
|
|
|
include_once '../vendor/autoload.php'; |
14
|
|
|
|
15
|
|
|
$invoicer = new \FlexiPeeHP\FakturaVydana(); |
16
|
|
|
|
17
|
|
|
function getOverdueInvoices($invoicer) |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
$result = null; |
22
|
|
|
$invoicer->defaultUrlParams['order'] = 'datVyst@A'; |
23
|
|
|
$invoicer->defaultUrlParams['relations'] = 'adresar,kontakt'; |
24
|
|
|
$invoices = $invoicer->getColumnsFromFlexibee([ |
25
|
|
|
'id', |
26
|
|
|
'kod', |
27
|
|
|
'stavUhrK', |
28
|
|
|
'firma', |
29
|
|
|
'buc', |
30
|
|
|
'varSym', |
31
|
|
|
'specSym', |
32
|
|
|
'sumCelkem', |
33
|
|
|
'duzpPuv', |
34
|
|
|
'datVyst'], |
35
|
|
|
"(stavUhrK is null OR stavUhrK eq 'stavUhr.castUhr') AND storno eq false", |
36
|
|
|
'id'); |
37
|
|
|
|
38
|
|
|
if ($invoicer->lastResponseCode == 200) { |
39
|
|
|
$result = $invoices; |
40
|
|
|
} |
41
|
|
|
return $result; |
42
|
|
|
} |
43
|
|
|
$firmer = new \FlexiPeeHP\Adresar(); |
44
|
|
|
|
45
|
|
|
foreach (getOverdueInvoices($invoicer) as $invoice) { |
46
|
|
|
$invoicer->setData($invoice, true); |
47
|
|
|
|
48
|
|
|
$firmer->setMyKey($invoicer->getDataValue('firma')); |
49
|
|
|
|
50
|
|
|
$mail = new \Ease\Mailer($firmer->getNotificationEmailAddress(), |
51
|
|
|
sprintf(_('Overdue invoice: %s'), $invoice['kod']), |
52
|
|
|
sprintf(_('Please pay %s,-'), $invoice['sumCelkem'])); |
53
|
|
|
|
54
|
|
|
$mail->addFile($invoicer->downloadInFormat('pdf', '/tmp/'), |
55
|
|
|
\FlexiPeeHP\Formats::$formats['PDF']['content-type']); |
56
|
|
|
$mail->addFile($invoicer->downloadInFormat('isdocx', '/tmp/'), |
57
|
|
|
\FlexiPeeHP\Formats::$formats['ISDOCx']['content-type']); |
58
|
|
|
|
59
|
|
|
$mail->send(); |
60
|
|
|
} |
61
|
|
|
|