forked from emaijala/MLInvoice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvoice_printer_offer_email.php
More file actions
61 lines (52 loc) · 2.05 KB
/
invoice_printer_offer_email.php
File metadata and controls
61 lines (52 loc) · 2.05 KB
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
<?php
/*******************************************************************************
MLInvoice: web-based invoicing application.
Copyright (C) 2010-2016 Ere Maijala
This program is free software. See attached LICENSE.
*******************************************************************************/
/*******************************************************************************
MLInvoice: web-pohjainen laskutusohjelma.
Copyright (C) 2010-2016 Ere Maijala
Tämä ohjelma on vapaa. Lue oheinen LICENSE.
*******************************************************************************/
require_once 'invoice_printer_offer.php';
require_once 'invoice_printer_email_trait.php';
class InvoicePrinterOfferEmail extends InvoicePrinterOffer
{
use InvoicePrinterEmailTrait;
protected function getDefaultBody()
{
return isset($this->senderData['offer_email_body'])
? $this->senderData['offer_email_body'] : '';
}
protected function getDefaultSubject()
{
return isset($this->senderData['offer_email_subject'])
? $this->senderData['offer_email_subject'] : '';
}
protected function emailPostProcess($success)
{
if ($success) {
$res = mysqli_param_query(
'SELECT invoice_open FROM {prefix}invoice_state WHERE id=?',
[$this->invoiceData['state_id']]
);
$open = mysqli_fetch_value($res);
if ($open) {
$res = mysqli_query_check(
'SELECT id FROM {prefix}invoice_state WHERE invoice_open=1'
. ' AND invoice_offer=1 AND invoice_offer_sent=1'
. ' ORDER BY order_no'
);
$stateId = mysqli_fetch_value($res);
// Mark invoice offered
if (null !== $stateId) {
mysqli_param_query(
'UPDATE {prefix}invoice SET state_id=? WHERE id=?',
[$stateId, $this->invoiceId]
);
}
}
}
}
}