Commit 42cff0ca authored by schrieveslaach's avatar schrieveslaach

Display attached documents

parent f90a212c
Pipeline #37770523 passed with stages
in 5 minutes and 32 seconds
......@@ -28,7 +28,7 @@
.member {
width: 90%;
height: 7rem;
min-height: 7rem;
background: #fff;
border-radius: 2px;
margin: 0.1rem;
......@@ -37,6 +37,15 @@
padding: 0.3rem;
}
.member > .docs {
padding-top: 0.3rem;
padding-bottom: 0.3rem;
}
.member > .docs > a + a {
padding-left: 0.5rem;
}
.member:hover {
box-shadow: 0 4px 6px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.22);
}
......
import {library} from '@fortawesome/fontawesome-svg-core'
import {faFilePdf, faPrint, faTimes} from '@fortawesome/free-solid-svg-icons'
import {faFile, faFilePdf, faPrint, faTimes} from '@fortawesome/free-solid-svg-icons'
import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome'
import App from './app.vue';
import Modal from './modal.vue';
library.add(faFile);
library.add(faFilePdf);
library.add(faPrint);
library.add(faTimes);
......
......@@ -5,6 +5,13 @@
</p>
<p>{{ member.street }}</p>
<p>{{ member.zipcode }} {{ member.city }}</p>
<br v-if="Object.keys(member.files).length > 0">
<p class="docs" v-if="Object.keys(member.files).length > 0">
<a class="button" :href="`/remote.php/webdav${member.files[index]}`" v-for="index in Object.keys(member.files)">
<font-awesome-icon icon="file"/> {{ index }}
</a>
</p>
</div>
</template>
......
......@@ -4,7 +4,8 @@ namespace OCA\SPGVerein\Model;
use JsonSerializable;
class Member implements JsonSerializable {
class Member implements JsonSerializable
{
private $id;
private $salutation;
......@@ -16,7 +17,10 @@ class Member implements JsonSerializable {
private $city;
private $relatedMemberId;
function __construct(string $memberData) {
private $files;
function __construct(string $memberData)
{
$memberDataUtf8 = mb_convert_encoding($memberData, 'UTF-8', 'ISO-8859-1');
// These lines ensures that data after lastname is aligned correctly:
......@@ -32,7 +36,7 @@ class Member implements JsonSerializable {
$shift2 += $relatedId[1] === ' ' ? 1 : 0;
$shift2 += $relatedId[2] === ' ' ? 1 : 0;
$this->id = (int) substr($memberDataUtf8, 0, 10);
$this->id = (int)substr($memberDataUtf8, 0, 10);
$this->salutation = trim(substr($memberDataUtf8, 10, 15));
$this->title = trim(substr($memberDataUtf8, 25, 35));
$this->firstname = trim(substr($memberDataUtf8, 60, 35));
......@@ -40,20 +44,39 @@ class Member implements JsonSerializable {
$this->street = trim(substr($memberDataUtf8, 165, 35));
$this->zipcode = substr($memberDataUtf8, 200 + $shift, 5);
$this->city = trim(substr($memberDataUtf8, 205 + $shift, 40));
$this->relatedMemberId = (int) substr($memberDataUtf8, 1432 + $shift + $shift2, 10);
$this->relatedMemberId = (int)substr($memberDataUtf8, 1432 + $shift + $shift2, 10);
$this->files = array();
}
public function jsonSerialize() {
public function jsonSerialize()
{
return array(
"id" => $this->id,
"fullnames" => array($this->getFullname()),
"street" => $this->street,
"zipcode" => $this->zipcode,
"city" => $this->city,
"files" => $this->jsonFiles()
);
}
public function getFullname(): string {
private function jsonFiles(): array
{
$files = array();
foreach ($this->files as $file) {
$files[$file->getName()] = str_replace(
$file->getMountPoint()->getMountPoint() . "files",
"",
$file->getPath());
}
return $files;
}
public function getFullname(): string
{
$persons = $this->salutation;
if ($persons !== "") {
......@@ -69,36 +92,48 @@ class Member implements JsonSerializable {
return $persons . $this->firstname . " " . $this->lastname;
}
public function getId(): int {
public function getId(): int
{
return $this->id;
}
public function getLastname(): string {
public function getLastname(): string
{
return $this->lastname;
}
public function getFirstname(): string {
public function getFirstname(): string
{
return $this->firstname;
}
public function getStreet(): string {
public function getStreet(): string
{
return $this->street;
}
public function getZipcode(): string {
public function getZipcode(): string
{
return $this->zipcode;
}
public function getCity(): string {
public function getCity(): string
{
return $this->city;
}
public function belongsToMember(): bool {
public function belongsToMember(): bool
{
return $this->relatedMemberId > 0;
}
public function getRelatedMemberId(): int {
public function getRelatedMemberId(): int
{
return $this->relatedMemberId;
}
public function addFile($file)
{
array_push($this->files, $file);
}
}
......@@ -40,6 +40,9 @@ class Club
$i += self::MEMBER_DATA_FIELD_LENGTH - 4;
$member = new Member($memberData);
$this->addDocuments($clubFile, $member);
array_push($members, $member);
}
......@@ -49,6 +52,29 @@ class Club
return $members;
}
private function addDocuments(File $clubFile, Member $member) : array {
try {
$id = str_pad($member->getId(), 10, "0", STR_PAD_LEFT);
$searchPath = $clubFile->getParent()->getPath() . '/archiv/' . $id;
$archiveDirectories = $this->storage->search($id);
foreach ($archiveDirectories as $directory) {
if ($directory->getPath() === $searchPath) {
foreach ($directory->getDirectoryListing() as $archivedFile) {
error_log("mount: " . $archivedFile->getMountPoint()->getMountPoint() );
$member->addFile($archivedFile);
}
}
}
} catch(\OCP\Files\NotFoundException $e) {
}
return array();
}
private function openClubFile(string $club): File
{
$clubMemberFiles = $this->storage->search($club . self::MITGL_DAT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment