Skip to content

Commit

Permalink
Company backup fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Nov 22, 2023
1 parent 7267e4c commit a202e7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/AbraFlexi/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,13 @@ public function saveBackupTo($filename)
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = '*/*';
$this->defaultHttpHeaders['Content-Type'] = 'application/x-winstrom-backup';
$this->performRequest('backup', 'GET');
$responseCode = $this->doCurlRequest(
$this->evidenceUrlWithSuffix('backup'),
'GET',
'winstrom-backup'
);
$this->defaultHttpHeaders = $headersBackup;
if ($this->lastResponseCode == 200) {
if ($responseCode == 200) {
if (file_put_contents($filename, $this->lastCurlResponse)) {
$result = true;
}
Expand Down
15 changes: 9 additions & 6 deletions src/AbraFlexi/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
*
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
*/
trait email {

trait email
{
/**
* Get recipient for documnet.
*
Expand All @@ -46,7 +46,8 @@ trait email {
*
* @return string
*/
public function getEmail() {
public function getEmail()
{
if (empty($this->getDataValue('kontaktEmail'))) {
$addresser = new Adresar($this->getDataValue('firma'), array_merge(['detail' => 'custom:email'], $this->getConnectionOptions()));
if (empty($addresser->getDataValue('email'))) {
Expand Down Expand Up @@ -74,7 +75,8 @@ public function getEmail() {
*
* @return string column divided list of email addresses
*/
public function getRecipients(string $purpose = '') {
public function getRecipients(string $purpose = '')
{
$recipients = [];
if (empty($this->getDataValue('kontaktEmail')) === false) {
$recipients[] = $this->getDataValue('kontaktEmail');
Expand Down Expand Up @@ -103,8 +105,9 @@ public function getRecipients(string $purpose = '') {
*
* @return string Contact role Fak|Obj|Nab|Ppt|Skl|Pok or ''
*/
public static function docTypeToPurpose($document) {
$purposeRaw = substr(str_replace('AbraFlexi\\', '', str_replace('Poptavka', 'Pptavka', get_class($document) ) ), 0, 3);
public static function docTypeToPurpose($document)
{
$purposeRaw = substr(str_replace('AbraFlexi\\', '', str_replace('Poptavka', 'Pptavka', get_class($document))), 0, 3);
return array_search($purposeRaw, ['Fak', 'Obj', 'Nab', 'Ppt', 'Skl', 'Pok']) === false ? '' : $purposeRaw;
}
}

0 comments on commit a202e7e

Please sign in to comment.