Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WS23 EWA Praktikum Pizzaservice
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Omar Ibrahim Arfa
WS23 EWA Praktikum Pizzaservice
Commits
8665aa6b
Commit
8665aa6b
authored
1 year ago
by
Omar Ibrahim Arfa
Browse files
Options
Downloads
Patches
Plain Diff
second commit to save progress on aufgabe 2
parent
2b6fd353
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Praktikum/Prak4/JS/Kunde.js
+70
-22
70 additions, 22 deletions
src/Praktikum/Prak4/JS/Kunde.js
src/Praktikum/Prak4/Kunde.php
+31
-44
31 additions, 44 deletions
src/Praktikum/Prak4/Kunde.php
with
101 additions
and
66 deletions
src/Praktikum/Prak4/JS/Kunde.js
+
70
−
22
View file @
8665aa6b
console
.
log
(
"
Loading Kunde.js ...
"
);
console
.
log
(
"
Loading Kunde.js ...
"
);
function
loadData
()
{
function
loadData
()
{
"
use strict
"
;
var
url
=
"
./Kundenstatus.php
"
;
var
url
=
"
./Kundenstatus.php
"
;
var
request
=
new
XMLHttpRequest
();
var
request
=
new
XMLHttpRequest
();
...
@@ -9,48 +9,96 @@ function loadData() {
...
@@ -9,48 +9,96 @@ function loadData() {
request
.
onload
=
function
()
{
request
.
onload
=
function
()
{
if
(
request
.
status
>=
200
&&
request
.
status
<
300
)
{
if
(
request
.
readyState
===
4
&&
request
.
status
>=
200
&&
request
.
status
<
300
)
{
if
(
request
.
responseText
!=
null
)
{
var
responseData
=
JSON
.
parse
(
request
.
responseText
);
var
responseData
=
JSON
.
parse
(
request
.
responseText
);
printData
(
responseData
);
process
(
responseData
);
}
console
.
error
(
"
Dokument ist leer
"
);
}
}
else
{
else
{
console
.
error
(
'
FEHLER DU HURENSOHN!
Statuscode:
'
+
request
.
status
);
console
.
error
(
'
Statuscode:
'
+
request
.
status
);
}
}
};
};
request
.
onerror
=
function
()
{
request
.
onerror
=
function
()
{
"
use strict
"
;
console
.
error
(
'
Net
work Erro
r
'
)
console
.
error
(
'
Net
zwerkfehle
r
'
)
};
};
//request.onreadystatechange = processData;
//request.onreadystatechange = processData;
request
.
send
();
request
.
send
();
}
}
//TODO: Make classes for Bestllung HTML Node and Pizza HTML Node
function
process
(
data
)
{
function
printData
(
data
)
{
"
use strict
"
;
var
outputElement
=
document
.
getElementById
(
"
o
utput
"
);
let
orderForm
=
document
.
getElementById
(
"
o
rderForm
"
);
outputElement
.
innerText
=
JSON
.
stringify
(
data
,
null
,
2
);
let
emptyBestellung
=
document
.
getElementById
(
"
bestellung
"
);
}
let
emptyPizza
=
document
.
getElementById
(
"
pizza
"
);
function
process
(
data
)
{
// TODO: HIER WEITER MACHEN SIMON AUS DER ZUKUNFT!
// Kopiere die Vorlage
}
let
copyBestellung
=
emptyBestellung
.
cloneNode
(
true
);
let
copyPizza
=
emptyPizza
.
cloneNode
(
true
);
copyBestellung
=
copyBestellung
.
cloneNode
(
true
);
// Lösche die Vorlage
emptyBestellung
.
remove
();
emptyPizza
.
remove
();
for
(
let
[
orderingID
,
order
]
of
Object
.
entries
(
data
))
{
let
address
=
order
[
"
Address
"
];
orderForm
.
append
(
copyBestellung
);
copyBestellung
=
copyBestellung
.
cloneNode
(
true
);
let
newBestellung
=
orderForm
.
lastElementChild
;
newBestellung
.
id
=
"
bestellung.
"
+
orderingID
;
newBestellung
.
firstElementChild
.
id
=
"
bestellung.legend.
"
+
orderingID
;
newBestellung
.
firstElementChild
.
innerText
=
"
Bestellung
"
+
orderingID
;
newBestellung
.
lastElementChild
.
remove
();
// lösche mitkopierte emptyPizza
let
orderList
=
order
[
"
OrderList
"
]
for
(
let
[
orderedArticleID
,
pizza
]
of
Object
.
entries
(
orderList
))
{
function
processData
()
{
let
name
=
pizza
[
"
Name
"
];
let
price
=
pizza
[
"
Price
"
];
let
status
=
pizza
[
"
Status
"
];
newBestellung
.
append
(
copyPizza
);
copyPizza
=
copyPizza
.
cloneNode
(
true
);
let
newPizza
=
newBestellung
.
lastElementChild
;
newPizza
.
id
=
"
pizza.
"
+
orderedArticleID
;
newPizza
.
firstElementChild
.
id
=
"
pizza.legend.
"
+
orderedArticleID
;
newPizza
.
firstElementChild
.
innerText
=
"
Pizza
"
+
name
;
let
inputs
=
newPizza
.
getElementsByTagName
(
"
input
"
);
for
(
let
input
of
inputs
)
{
input
.
name
=
orderedArticleID
;
// Places the checked-attribute for the individual pizza
if
(
input
.
type
===
"
radio
"
&&
parseInt
(
input
.
value
)
===
parseInt
(
status
))
{
input
.
checked
=
true
;
}
}
if
(
request
.
readyState
===
4
)
{
// Uebertragung = DONE
if
(
request
.
status
===
200
)
{
// HTTP-Status = OK
if
(
request
.
responseText
!=
null
)
process
(
request
.
responseText
);
// Daten verarbeiten
else
console
.
error
(
"
Dokument ist leer
"
);
}
}
else
console
.
error
(
"
Uebertragung fehlgeschlagen
"
);
}
}
}
}
window
.
onload
=
function
()
{
// TODO: tofix
window
.
onload
=
function
()
{
"
use strict
"
;
loadData
();
loadData
();
}
\ No newline at end of file
}
window
.
setInterval
(
loadData
,
2000
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Praktikum/Prak4/Kunde.php
+
31
−
44
View file @
8665aa6b
...
@@ -108,9 +108,7 @@ class Kunde extends Page
...
@@ -108,9 +108,7 @@ class Kunde extends Page
protected
function
generateView
():
void
protected
function
generateView
():
void
{
{
$data
=
$this
->
getViewData
();
//NOSONAR ignore unused $data
$data
=
$this
->
getViewData
();
//NOSONAR ignore unused $data
$this
->
generatePageHeader
(
'Kunde'
,
'./JS/Kunde.js'
,
true
);
//to do: set optional parameters
$this
->
generatePageHeader
(
'Kunde'
,
'./JS/Kunde.js'
,
false
);
//to do: set optional parameters
echo
"<section id='output'></section>"
;
if
(
count
(
$data
)
<=
0
)
{
if
(
count
(
$data
)
<=
0
)
{
echo
<<<
HTML
echo
<<<
HTML
...
@@ -125,48 +123,37 @@ HTML;
...
@@ -125,48 +123,37 @@ HTML;
echo
<<<
HTML
echo
<<<
HTML
<
section
id
=
"Kunde"
>
<
section
id
=
"Kunde"
>
<
h2
>
Kunde
</
h2
>
<
h2
>
Kunde
</
h2
>
<
form
id
=
"orderForm"
accept
-
charset
=
"UTF-8"
action
=
"#"
method
=
"post"
>
\n
<
form
accept
-
charset
=
"UTF-8"
action
=
"#"
method
=
"post"
>
\n
<
fieldset
id
=
"bestellung"
>
HTML
;
<
legend
id
=
"bestellung.legend"
>
Bestellung
X
</
legend
>
foreach
(
$data
as
$order
)
{
<
fieldset
id
=
"pizza"
disabled
>
$orderedArticleId
=
$order
->
getOrderedArticleId
();
<
legend
id
=
"pizza.legend"
>
Pizza
Y
</
legend
>
$orderingId
=
$order
->
getOrderingId
();
<
label
>
Bestellt
$status
=
array_fill
(
0
,
5
,
""
);
<
input
type
=
"radio"
name
=
"ordArtID"
value
=
"0"
>
$status
[
$order
->
getStatus
()]
=
"checked"
;
</
label
>
<
br
>
echo
<<<
HTML
<
label
>
<
fieldset
disabled
>
Im
Ofen
<
legend
>
Bestellung
{
$orderingId
}
</
legend
>
<
input
type
=
"radio"
name
=
"ordArtID"
value
=
"1"
>
<
label
>
</
label
>
<
br
>
Bestellt
<
input
type
=
"radio"
name
=
"
{
$orderedArticleId
}
"
value
=
"0"
{
$status
[
0
]}
>
<
label
>
</
label
>
<
br
>
Fertig
<
input
type
=
"radio"
name
=
"ordArtID"
value
=
"2"
>
<
label
>
</
label
>
<
br
>
Im
Ofen
<
input
type
=
"radio"
name
=
"
{
$orderedArticleId
}
"
value
=
"1"
{
$status
[
1
]}
>
<
label
>
</
label
>
<
br
>
Unterwegs
<
input
type
=
"radio"
name
=
"ordArtID"
value
=
"3"
>
<
label
>
</
label
>
<
br
>
Fertig
<
input
type
=
"radio"
name
=
"
{
$orderedArticleId
}
"
value
=
"2"
{
$status
[
2
]}
>
<
label
>
</
label
>
<
br
>
Geliefert
<
input
type
=
"radio"
name
=
"ordArtID"
value
=
"4"
>
<
label
>
</
label
>
Unterwegs
<
input
type
=
"radio"
name
=
"
{
$orderedArticleId
}
"
value
=
"3"
{
$status
[
3
]}
>
</
label
>
<
br
>
<
label
>
Geliefert
<
input
type
=
"radio"
name
=
"
{
$orderedArticleId
}
"
value
=
"4"
{
$status
[
4
]}
>
</
label
>
</
fieldset
>
\n
</
fieldset
>
\n
HTML
;
</
fieldset
>
\n
}
echo
<<<
HTML
</
form
>
\n
</
form
>
\n
</
section
>
\n
</
section
>
\n
HTML
;
HTML
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment