Repository navigation
Expand file tree
/
Copy pathVazbaZDD.php
More file actions
130 lines (116 loc) · 6.93 KB
/
Copy pathVazbaZDD.php
File metadata and controls
130 lines (116 loc) · 6.93 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* AbraFlexi - Example how to show connection check InfoBox
*
* @author Vítězslav Dvořák <info@vitexsofware.cz>
* @copyright (G) 2017 Vitex Software
*/
namespace AbraFlexi\Bricks;
include_once './config.php';
include_once '../vendor/autoload.php';
include_once './common.php';
$modul = 'banka'; //pokladna
$documentID = null;
$this->banker->defaultUrlParams['detail'] = 'custom:id, poznam';
list( $method, $document ) = explode(':',
$this->getDataValue('poznam'));
if (empty($document)) {
$this->addStatusMessage('Dokument bez cisla', 'error');
} else {
switch ($method) {
case 'CASH':
$documentID = $this->getCashCode([
'ExtCode' => $document], 'ext');
$this->casher->ignore404(true);
$this->casher->defaultUrlParams['detail'] = 'id';
$this->casher->loadFromAbraFlexi(rawurlencode($documentID));
if ($this->casher->lastResponseCode == 200) {
$cashID = $this->casher->getDataValue('id');
$this->defaultHttpHeaders['Accept'] = 'text/html';
$this->setPostFields(http_build_query(['modul' => $modul,
'submit' => 'OK']));
$this->performRequest($invoiceID.'/vytvor-vazbu-zdd/'.$cashID,
'GET', 'json');
$responseArr = explode("\n",
$this->lastCurlResponse);
$result = true;
$message = '';
foreach ($responseArr as $lineNo => $responseLine) {
if (strstr($responseLine,
'<ul class = "abraflexi-errors">')) {
$message = trim($responseArr[$lineNo + 1]);
$result = false;
}
if (strstr($responseLine,
'<div class = "alert alert-success">')) {
$message = strip_tags(html_entity_decode(trim($responseArr[$lineNo
+ 1])));
$result = true;
}
}
if ($result === true) {
$this->addStatusMessage(empty($message) ? $this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$documentID
: $message, 'success');
} else {
$this->addStatusMessage($this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$documentID,
'warning');
}
} elseif ($this->casher->lastResponseCode == 404) {
$this->casher->addStatusMessage('Platba do pokladny nenalezena: '.$documentID,
'warning');
}
break;
case 'CARD':
if ($document[0] == 'K') {
$documentID = $this->getCardCode(['ExtCode' => $document],
'ext');
} else {
$documentID = $this->getCardCode(['IDDocumentItem' => $document],
'idd');
}
$this->banker->ignore404(true);
$this->banker->loadFromAbraFlexi(rawurlencode($documentID));
if ($this->banker->lastResponseCode == 200) {
$bankID = $this->banker->getDataValue('id');
$this->defaultHttpHeaders['Accept'] = 'text/html';
$this->setPostFields(http_build_query(['modul' => $modul,
'submit' => 'OK']));
$this->performRequest($invoiceID.'/vytvor-vazbu-zdd/'.$bankID,
'GET', 'json');
$responseArr = explode("\n",
$this->lastCurlResponse);
$result = true;
$message = '';
foreach ($responseArr as $lineNo => $responseLine) {
if (strstr($responseLine,
'<ul class = "abraflexi-errors">')) {
$message = trim($responseArr[$lineNo + 1]);
$result = false;
}
if (strstr($responseLine,
'<div class = "alert alert-success">')) {
$message = strip_tags(html_entity_decode(trim($responseArr[$lineNo
+ 1])));
$result = true;
}
}
if ($result === true) {
$this->addStatusMessage(empty($message) ? $this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$documentID
: $message, 'success');
} else {
$this->addStatusMessage($this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$documentID,
'warning');
}
} elseif ($this->banker->lastResponseCode == 404) {
$this->banker->addStatusMessage('Platba nenalezena: '.$documentID,
'warning');
}
break;
case 'BANKTRANSFER':
break;
default :
$this->addStatusMessage('Neznama platebni metoda '.$method
, 'warning');
}
}
$this->defaultHttpHeaders = $headersBackup;