Skip to content

Commit

Permalink
bugfix: fixed country support for buyer and postal addresses on finan…
Browse files Browse the repository at this point in the history
…cial documents (separate fix for master branch)
  • Loading branch information
chilek committed Jan 18, 2018
1 parent a26c71e commit b0ef1d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 6 additions & 3 deletions lib/LMSDocuments/LMSTcpdfInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,10 @@ protected function invoice_buyer() {

$buyer .= $this->data['name'] . '<br>';
$buyer .= $this->data['address'] . '<br>';
$buyer .= $this->data['zip'] . ' ' . $this->data['city'] . '<br>';
$buyer .= $this->data['zip'] . ' ' . $this->data['city'];
if ($this->data['division_countryid'] && $this->data['countryid'] && $this->data['division_countryid'] != $this->data['countryid'])
$buyer .= ', ' . trans($this->data['country']);
$buyer .= '<br>';
if ($this->data['ten'])
$buyer .= trans('TEN') . ': ' . $this->data['ten'] . '<br>';
elseif ($this->data['ssn'])
Expand All @@ -675,8 +678,8 @@ protected function invoice_buyer() {
$postbox .= $this->data['zip'] . ' ' . $this->data['city'] . '<br>';
}

if ($this->data['division_countryid'] && $this->data['countryid'] && $this->data['division_countryid'] != $this->data['countryid'])
$postbox .= trans($this->data['country']) . '<br>';
if ($this->data['division_countryid'] && $this->data['post_countryid'] && $this->data['division_countryid'] != $this->data['post_countryid'])
$postbox .= ', ' . trans($this->data['post_country']) . '<br>';

$this->backend->SetFont('arial', 'B', 10);
$this->backend->writeHTMLCell(80, '', 125, 50, $postbox, 0, 1, 0, true, 'L');
Expand Down
12 changes: 6 additions & 6 deletions lib/LMSManagers/LMSFinanceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,19 +1109,17 @@ public function GetInvoiceContent($invoiceid)
(CASE WHEN d.post_address_id IS NULL THEN c.post_zip ELSE a2.zip END) AS post_zip,
(CASE WHEN d.post_address_id IS NULL THEN c.post_city ELSE a2.city END) AS post_city,
(CASE WHEN d.post_address_id IS NULL THEN c.post_postoffice ELSE a2.postoffice END) AS post_postoffice,
(CASE WHEN d.post_address_id IS NULL THEN c.post_countryid ELSE a2.country_id END) AS post_countryid
(CASE WHEN d.post_address_id IS NULL THEN c.post_countryid ELSE a2.country_id END) AS post_countryid,
cp.name AS post_country
FROM documents d
JOIN customeraddressview c ON (c.id = d.customerid)
LEFT JOIN countries cn ON (cn.id = d.countryid)
LEFT JOIN numberplans n ON (d.numberplanid = n.id)
LEFT JOIN vaddresses a ON d.recipient_address_id = a.id
LEFT JOIN vaddresses a2 ON d.post_address_id = a2.id
LEFT JOIN countries cp ON (d.post_address_id IS NOT NULL AND cp.id = a2.country_id) OR (d.post_address_id IS NULL AND cp.id = c.post_countryid)
WHERE d.id = ? AND (d.type = ? OR d.type = ? OR d.type = ?)', array($invoiceid, DOC_INVOICE, DOC_CNOTE, DOC_INVOICE_PRO))) {

if (!empty($result['post_address_id'])) {

}

$result['bankaccounts'] = $this->db->GetCol('SELECT contact FROM customercontacts
WHERE customerid = ? AND (type & ?) = ?',
array($result['customerid'], CONTACT_BANKACCOUNT | CONTACT_INVOICES | CONTACT_DISABLED,
Expand Down Expand Up @@ -1266,12 +1264,14 @@ public function GetNoteContent($id)
(CASE WHEN d.post_address_id IS NULL THEN c.post_zip ELSE a2.zip END) AS post_zip,
(CASE WHEN d.post_address_id IS NULL THEN c.post_city ELSE a2.city END) AS post_city,
(CASE WHEN d.post_address_id IS NULL THEN c.post_postoffice ELSE a2.postoffice END) AS post_postoffice,
(CASE WHEN d.post_address_id IS NULL THEN c.post_countryid ELSE a2.country_id END) AS post_countryid
(CASE WHEN d.post_address_id IS NULL THEN c.post_countryid ELSE a2.country_id END) AS post_countryid,
cp.name AS post_country
FROM documents d
JOIN customeraddressview c ON (c.id = d.customerid)
LEFT JOIN countries cn ON (cn.id = d.countryid)
LEFT JOIN numberplans n ON (d.numberplanid = n.id)
LEFT JOIN vaddresses a2 ON a2.id = d.post_address_id
LEFT JOIN countries cp ON (d.post_address_id IS NOT NULL AND cp.id = a2.country_id) OR (d.post_address_id IS NULL AND cp.id = c.post_countryid)
WHERE d.id = ? AND d.type = ?', array($id, DOC_DNOTE))) {

$result['bankaccounts'] = $this->db->GetCol('SELECT contact FROM customercontacts
Expand Down

0 comments on commit b0ef1d8

Please sign in to comment.