/
details.php
132 lines (127 loc) · 4.04 KB
/
details.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* Created by PhpStorm.
* User: randyjp
* Date: 4/29/15
* Time: 11:27 PM
*/
require_once "Complaint.php";
require_once "DataLayer.php";
require_once "lib.php";
$dl = new DataLayer();
$id = $_GET["id"];
$messages = array();
$success = true;
if(count($_POST)>0)
{
$id = $_POST["hiddenId"];
if(!empty($_POST["txtComments"]))
{
$dl->addCommentById($id, $_POST["txtComments"]);
$messages[] = "Comment Added Successfully";
}
else
{
$messages[] = "Comments can't be empty.";
$success = false;
}
}
if(empty($id))
{
header("location:index.php");
die();
}
$complaint = $dl->findComplaintById($id);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Complaints Details</title>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-offset-2 col-md-7">
<? echo displayMessages($messages,$success);?>
</div>
</div>
<div class="row">
<div class="col-md-offset-3 col-md-7">
<h1>Complaint # <?echo $complaint->getComplaintId();?></h1>
</div>
</div>
<div class="row">
<div class="col-md-offset-4 col-md-3">
<div class="image">
<img src="<? echo $complaint->getImage();?> " width="150px" height="150px" class="img-responsive">
</div>
</div>
<div class="row">
<div class="col-md-offset-2 col-md-7">
<table class="table table-bordered">
<thead>
<tr>
<th>Field</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Product</td>
<td><? echo $complaint->getProduct();?></td>
</tr>
<tr>
<td>Issue</td>
<td><? echo $complaint->getIssued();?></td>
</tr>
<tr>
<td>Sub-Issue</td>
<td><? echo $complaint->getSubIssue();?></td>
</tr>
<tr>
<td>Data Received</td>
<td><? echo $complaint->getDateReceived();?></td>
</tr>
<tr>
<td>Company</td>
<td><? echo $complaint->getCompany();?></td>
</tr>
<tr>
<td>Company Response</td>
<td><? echo $complaint->getCompanyResponse();?></td>
</tr>
<?
foreach($complaint->getComments() as $comment)
{
echo "<tr>
<td>Comment:</td>
<td>".$comment['Comment']."</td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-offset-2 col-md-7">
<form method="post" action="details.php">
<div class="form-group">
<label for="txtComments">Add Comment:</label>
<textarea rows="5" cols="30" class="form-control" name="txtComments" id="txtComments"></textarea>
<input type="hidden" value="<?echo $id;?>" name="hiddenId">
</div>
<input type="submit" name="btnComments" class="btn btn-primary col-md-12" value="Add Comment">
</form>
</div>
</div>
<div class="row">
<div class="col-md-5">
<a href="index.php">Back to main page</a>
</div>
</div>
</div>
</body>
</html>