Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a1a7d19b5 | ||
|
|
c3fd986144 |
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/read_write_xlsx.php';
|
||||||
$fileName = $_SERVER['DOCUMENT_ROOT'] . '/data/data.xlsx';
|
$fileName = $_SERVER['DOCUMENT_ROOT'] . '/data/data.xlsx';
|
||||||
function objectToArray($object, $fullJSON) {
|
function objectToArray($object, $fullJSON) {
|
||||||
return [$object -> id,
|
return [$object -> id,
|
||||||
@@ -23,22 +24,32 @@ function findRowIndex($id, $data) {
|
|||||||
return $rowCounter + 1;
|
return $rowCounter + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entityBody = '{"lastSave": 0, "timeWatchM": 23, "timeWatchW": 89, "timeWatchD": 34, "countWatchM": 65, "countWatchW": 56, "countWatchD": 9, "id":"test","watches":[{"actions":[]},{"actions":[]},{"actions":[]}]}';
|
$entityBody = '{"lastSave": 0, "timeWatchM": 0, "timeWatchW": 0, "timeWatchD": 0, "countWatchM": 0, "countWatchW": 0, "countWatchD": 0, "id":"test","watches":[{"actions":[]},{"actions":[]},{"actions":[]}]}';
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
$entityBody = file_get_contents('php://input');
|
$entityBody = file_get_contents('php://input');
|
||||||
}
|
$entityBodyObject = json_decode($entityBody);
|
||||||
|
|
||||||
$entityBodyObject = json_decode($entityBody);
|
echo "POST Request received.<br>";
|
||||||
|
|
||||||
|
if(property_exists($entityBodyObject, "id")) {
|
||||||
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/read_write_xlsx.php';
|
|
||||||
if(property_exists($entityBodyObject, "id")) {
|
|
||||||
$data = read_xls_file($fileName);
|
$data = read_xls_file($fileName);
|
||||||
|
|
||||||
|
foreach ($data as $row) {
|
||||||
|
echo "new Row: <br>";
|
||||||
|
foreach ($row as $cell) {
|
||||||
|
echo $cell." ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rowIndex = findRowIndex($entityBodyObject->id, $data);
|
$rowIndex = findRowIndex($entityBodyObject->id, $data);
|
||||||
$data[$rowIndex] = objectToArray($entityBodyObject, $entityBody);
|
$data[$rowIndex] = objectToArray($entityBodyObject, $entityBody);
|
||||||
write_xlsxFile($fileName, $data);
|
write_xlsxFile($fileName, $data);
|
||||||
|
echo "<br>Data saved.<br>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Genderwatch-protocol</h1>
|
<h1>Genderwatch-protocol</h1>
|
||||||
|
<a href="data/data.xlsx">Anonyme Daten herunterladen</a>
|
||||||
<h2 style="margin-left: 10px;">Aktuelles Thema</h2>
|
<h2 style="margin-left: 10px;">Aktuelles Thema</h2>
|
||||||
<table class="table-bordered">
|
<table class="table-bordered">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -14,15 +14,6 @@ function read_xls_file($filename){
|
|||||||
|
|
||||||
|
|
||||||
function write_xlsxFile($filename, $data) {
|
function write_xlsxFile($filename, $data) {
|
||||||
|
|
||||||
foreach ($data as $row) {
|
|
||||||
echo "new Row: <br>";
|
|
||||||
foreach ($row as $cell) {
|
|
||||||
echo $cell." ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$xlsx = SimpleXLSXGen::fromArray($data);
|
$xlsx = SimpleXLSXGen::fromArray($data);
|
||||||
$xlsx->saveAs($filename);
|
$xlsx->saveAs($filename);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user