Skip to content

Commit

Permalink
v0.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Jan 4, 2021
1 parent ad5687c commit 59c2dfb
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 158 deletions.
49 changes: 22 additions & 27 deletions README.md
Expand Up @@ -25,10 +25,12 @@ Debian/Ubuntu

Pro Linux jsou k dispozici .deb balíčky. Prosím použijte repo:

```shell
echo "deb http://repo.vitexsoftware.cz $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vitexsoftware.list
sudo wget -O /etc/apt/trusted.gpg.d/vitexsoftware.gpg http://repo.vitexsoftware.cz/keyring.gpg
sudo apt update
sudo apt install abraflexi-mailer
```

Po instalaci balíku jsou v systému k dispozici tyto nové příkazy:

Expand All @@ -38,30 +40,11 @@ Po instalaci balíku jsou v systému k dispozici tyto nové příkazy:
* **abraflexi-send-unsent-attachments** - odešle neodeslané s přílohami
* **abraflexi-show-unsent** - vypíše neodeslané doklady

Závislosti
----------

Tento nástroj ke svojí funkci využívá následující knihovny:

* [**EasePHP Framework**](https://github.com/VitexSoftware/php-ease-core) - pomocné funkce např. logování
* [**AbraFlexi**](https://github.com/Spoje-NET/AbraFlexi) - komunikace s [AbraFlexi](https://flexibee.eu/)
* [**AbraFlexi Bricks**](https://github.com/VitexSoftware/AbraFlexi-Bricks) - používají se třídy Zákazníka, Upomínky a Upomínače


Testování:
----------

K dispozici je základní test funkcionality spustitelný příkazem **make test** ve zdrojové složce projektu

Pouze testovací faktury a platby se vytvoří příkazem **make pretest**
![Prepare](https://raw.githubusercontent.com/VitexSoftware/php-abraflexi-mailer/master/doc/preparefortesting.png "Preparation")

Test sestavení balíčku + test instalace balíčku + test funkce balíčku obstarává [Vagrant](https://www.vagrantup.com/)

Konfigurace
-----------

S provádí uvedenín direktiv do .env souboru, jejich definicí jako konstant, nebo nastavením proměnných prostředí.
Debianí balíček konfiurák očekává ve složce /etc/abraflexi-mailer, kde je k dispozici vzorový sobor .env.template


```
Expand All @@ -87,6 +70,25 @@ EASE_LOGGER="console|syslog" - způsob logování



Závislosti
----------

Tento nástroj ke svojí funkci využívá následující knihovny:

* [**EasePHP Framework**](https://github.com/VitexSoftware/php-ease-core) - pomocné funkce např. logování
* [**AbraFlexi**](https://github.com/Spoje-NET/php-abraflexi) - komunikace s [AbraFlexi](https://flexibee.eu/)
* [**AbraFlexi Bricks**](https://github.com/VitexSoftware/AbraFlexi-Bricks) - používají se třídy Zákazníka, Upomínky a Upomínače



Poděkování
----------

Tento software by nevznikl pez podpory:

[ ![Spoje.Net](doc/spojenet.gif?raw=true "Spoje.Net s.r.o.") ](https://spoje.net/)


Další software pro AbraFlexi
---------------------------

Expand All @@ -97,10 +99,3 @@ Další software pro AbraFlexi
* [Monitoring funkce AbraFlexi serveru](https://github.com/VitexSoftware/monitoring-plugins-abraflexi)
* [AbraFlexi server bez grafických závislostí](https://github.com/VitexSoftware/abraflexi-server-deb)

Poděkování
----------

Tento software by nevznikl pez podpory:

[ ![Spoje.Net](doc/spojenet.gif?raw=true "Spoje.Net s.r.o.") ](https://spoje.net/)

79 changes: 0 additions & 79 deletions abraflexi-mailer.1

This file was deleted.

4 changes: 4 additions & 0 deletions bin/abraflexi-send
@@ -0,0 +1,4 @@
#!/bin/bash
php -f /usr/lib/abraflexi-mailer/SendDocument.php $1 $2 $3


2 changes: 1 addition & 1 deletion bin/abraflexi-send-unsent
@@ -1,2 +1,2 @@
#!/bin/bash
php -f /usr/lib/flexibee-mailer/SendUnsent.php
php -f /usr/lib/abraflexi-mailer/SendUnsent.php
2 changes: 1 addition & 1 deletion bin/abraflexi-send-unsent-with-attachments
@@ -1,2 +1,2 @@
#!/bin/bash
php -f /usr/lib/flexibee-mailer/SendUnsentAttachments.php
php -f /usr/lib/abraflexi-mailer/SendUnsentAttachments.php
4 changes: 4 additions & 0 deletions bin/abraflexi-show-unsent
@@ -0,0 +1,4 @@
#!/bin/bash
php -f /usr/lib/abraflexi-mailer/ShowUnsent.php


24 changes: 1 addition & 23 deletions debian/changelog
@@ -1,29 +1,7 @@
abraflexi-mailer (0.8.6) UNRELEASED; urgency=medium
abraflexi-mailer (0.1) UNRELEASED; urgency=medium

[ vitex ]
* Rename Composer Package in Debian to be Composer 2.0 valid
* Configuration is get from Enviroment if /etc/abraflexi/cliet.json does not exist.

[ CyberVitexus ]
* create /var/lib/abraflexi-mailer at first install
* debian package installation fix
* Release target added
* Release target added
* Release target added
* separate AbraFlexi mailer init command
* "Send Unsent mail" tool added

-- CyberVitexus <vitex@exiv.jinonice.czf> Fri, 14 Aug 2020 15:25:26 +0200

abraflexi-mailer (0.7.6) experimental; urgency=medium

[ Vítězslav Dvořák ]
* Initial release
* Package Update
* Deps Update
* Packager deps update
* Deb Fix
* pull-bank command


-- vitex <vitex@hosting.vitexsoftware.cz> Mon, 19 Nov 2018 19:51:04 +0100
4 changes: 2 additions & 2 deletions debian/install
@@ -1,5 +1,5 @@
debian/conf/composer.json usr/lib/abraflexi-mailer/
src/* usr/lib/abraflexi-mailer/
src/AbraFlexi/Mailer/* usr/lib/abraflexi-mailer/Mailer/
#src/AbraFlexi/Mailer/* usr/lib/abraflexi-mailer/Mailer/
bin/* usr/bin/
mailer.json etc/abraflexi/
.env.template etc/abraflexi-mailer
3 changes: 0 additions & 3 deletions debian/manpages

This file was deleted.

3 changes: 0 additions & 3 deletions debian/postinst
Expand Up @@ -12,9 +12,6 @@ if [ "$1" = "configure" ]; then
mkdir -p /var/lib/composer /var/lib/abraflexi-mailer
chown $WEBUSER:$WEBUSER /var/lib/composer /var/lib/abraflexi-mailer /usr/lib/abraflexi-mailer/ -R
su - $WEBUSER -s /bin/bash -c 'COMPOSER_HOME="/var/lib/composer" composer --no-dev -o install -d /usr/lib/abraflexi-mailer/'

abraflexi-mailer-init

fi


Expand Down
13 changes: 2 additions & 11 deletions debian/rules 100644 → 100755
Expand Up @@ -5,14 +5,5 @@

override_dh_install:
dh_install
sed -i -e 's/..\/vendor/\/var\/lib\/abraflexi-mailer/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/Init.php
sed -i -e 's/..\/vendor/\/var\/lib\/abraflexi-mailer/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/ParujPrijateFaktury.php
sed -i -e 's/..\/vendor/\/var\/lib\/abraflexi-mailer/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/ParujVydaneFaktury.php
sed -i -e 's/..\/vendor/\/var\/lib\/abraflexi-mailer/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/ParujFakturyNew2Old.php
sed -i -e 's/..\/vendor/\/var\/lib\/abraflexi-mailer/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/StahniBanku.php
sed -i -e 's/\.\./\/etc\/abraflexi/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/Init.php
sed -i -e 's/\.\./\/etc\/abraflexi/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/ParujPrijateFaktury.php
sed -i -e 's/\.\./\/etc\/abraflexi/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/ParujVydaneFaktury.php
sed -i -e 's/\.\./\/etc\/abraflexi/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/ParujFakturyNew2Old.php
sed -i -e 's/\.\./\/etc\/abraflexi/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/StahniBanku.php
sed -i -e 's/\.\./\/etc\/abraflexi/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/SendUnsent.php
sed -i -e 's/..\/vendor/\/var\/lib\/abraflexi-mailer/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/*.php
sed -i -e 's/\.\./\/etc\/abraflexi-mailer/g' debian/abraflexi-mailer/usr/lib/abraflexi-mailer/*.php
10 changes: 8 additions & 2 deletions src/AbraFlexi/Mailer/Mailer.php
Expand Up @@ -171,18 +171,24 @@ public function addQrCode($size = 200) {
['width' => $size, 'height' => $size, 'title' => $this->document->getRecordCode()]));
}

/**
*
* @return array
*/
public function addAttachments() {
$attachments = Priloha::getAttachmentsList($this->document);

$attached = [];
if ($attachments) {
foreach ($attachments as $attachmentID => $attachment) {
if (Priloha::saveToFile($attachmentID, sys_get_temp_dir())) {
$tmpfile = sys_get_temp_dir() . '/' . $attachment['nazSoub'];
$this->addFile($tmpfile, $attachment['contentType']);
$this->cleanup[] = $tmpfile;
}
$attached[$attachmentID] = $attachment['nazSoub'];
}
}
}
return $attached;
}

public function send() {
Expand Down
73 changes: 73 additions & 0 deletions src/SendDocument.php
@@ -0,0 +1,73 @@
<?php

/**
* abraflexi-send-document
*
* @copyright (c) 2018-2021, Vítězslav Dvořák
*/

namespace AbraFlexi\Mailer;

use AbraFlexi\FakturaVydana;
use AbraFlexi\RO;
use Ease\Functions;
use Ease\Html\PTag;
use Ease\Shared;

define('APP_NAME', 'SentDocument');
define('EASE_LOGGER', 'syslog|console');
require_once '../vendor/autoload.php';
$shared = new Shared();
if(file_exists('../.env')){
$shared->loadConfig('../.env', true);
}

$document = $argv[1];
$evidence = array_key_exists(2, $argv) ? $argv[2] : 'faktura-vydana';

if ($argc > 2) {

$documentor = new FakturaVydana(RO::code($document), ['evidence' => $evidence, 'ignore404' => true]);
$documentor->logBanner(Functions::cfg('APP_NAME'));

if ($documentor->lastResponseCode == 200) {

$to = (array_key_exists(3, $argv) ? $argv[3] : $documentor->getEmail());
$documentor->addStatusMessage(RO::uncode($documentor->getRecordCode()) . "\t" . RO::uncode($documentor->getDataValue('firma')) . "\t" . $to . "\t" . $documentor->getDataValue('poznam'), 'success');

$mailer = new Mailer($documentor, $to);

if (array_key_exists('poznam', $documentor->getColumnsInfo())) {
preg_match_all('/cc:[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/i', $documentor->getDataValue('poznam'), $ccs);
if (!empty($ccs[0])) {
$mailer->setMailHeaders(['Cc' => str_replace('cc:', '', implode(',', $ccs[0]))]);
}
}

if (array_key_exists('popis', $documentor->getColumnsInfo())) {
$mailer->addItem(new PTag($documentor->getDataValue('popis')));
}

$documentor->addStatusMessage(_('Attaching') . ': ' . implode(',', $mailer->addAttachments()));

if (array_key_exists('juhSum', $documentor->getColumnsInfo())) {
if (Functions::cfg('ADD_QRCODE')) {
$mailer->addQrCode();
}
}

if (array_key_exists('stavMailK', $documentor->getColumnsInfo())) {
$result = ($mailer->send() && $documentor->sync(['id' => $documentor->getRecordIdent(), 'stavMailK' => 'stavMail.odeslano']));
} else {
$result = $mailer->send();
}
} else {
$documentor->addStatusMessage(sprintf(_('Cannot read %s %s'), $evidence, $document));
}
} else {
echo _('AbraFlexi Document Sender') . "\n";
echo "abraflexi-send-document <DocID> [evidence-code] [recipent@email,another@recipient] \n";
echo "abraflexi-send-document VF1-7326/2020 faktura-vydana \n";
}


6 changes: 2 additions & 4 deletions src/SendUnsent.php
Expand Up @@ -11,10 +11,8 @@
define('EASE_APPNAME', 'OdeslatNeodeslane');
require_once '../vendor/autoload.php';
$shared = new Shared();
if (file_exists('../client.json')) {
$shared->loadConfig('../client.json', true);
}
if (file_exists('../.env')) {

if(file_exists('../.env')){
$shared->loadConfig('../.env', true);
}

Expand Down
4 changes: 3 additions & 1 deletion src/SendUnsentAttachments.php
Expand Up @@ -15,7 +15,9 @@
define('EASE_LOGGER', 'syslog|console');
require_once '../vendor/autoload.php';
$shared = new Shared();
$shared->loadConfig('../.env', true);
if(file_exists('../.env')){
$shared->loadConfig('../.env', true);
}

$invoicer = new \AbraFlexi\FakturaVydana();

Expand Down
4 changes: 3 additions & 1 deletion src/ShowUnsent.php
Expand Up @@ -12,7 +12,9 @@
define('EASE_LOGGER', 'syslog|console');
require_once '../vendor/autoload.php';
$shared = new Shared();
$shared->loadConfig('../.env', true);
if (file_exists('../.env')) {
$shared->loadConfig('../.env', true);
}

$invoicer = new \AbraFlexi\FakturaVydana();

Expand Down

0 comments on commit 59c2dfb

Please sign in to comment.