-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
148 lines (130 loc) · 7.52 KB
/
contact.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!-- Authors: Owiny Ayorech
Date: July 31,2019
Version: 2.5
Functionality: Populate contacts from DB into card format -->
<?php include("pageSections/header.php");
include("pageSections/menu.php"); ?>
<main>
<div class="rounded sectionBox mainContent">
<?php
require "classes/dbConnect.php";
require "phpFunctions/functions.php";
// Get all agency and agent data
try{
$agencies = grabAllData('agencies','travelexperts','dbAdmin','L0g1n2db!');
$agents = grabAllData('agents','travelexperts','dbAdmin','L0g1n2db!');
}
catch(Exception $e){
echo "<p>Unable to display contacts at this point in time.</p>";
}
include_once("phpFunctions/contactAgent.php");
$counter = 1; // Counter to give each card/modal a unique id
// Array to store 1. Agency header, 2.All agents within an agency
$agencyData=[];
// Populating headers for agencies
foreach ($agencies as $agency){
$agencyData[(string) $agency['AgencyId']]['header']='
<section class="company-info">
<ul class="agency-info">
<!-- Company Contact Information -->
<h2><b>Agency Name: '.$agency['AgncyName'].'</b></h2>
<p class="company-info">Address: '.$agency['AgncyAddress'].'</p>
<p class="company-info">Phone Number: '.$agency['AgncyPhone'].'</p>
</ul>
</section>
';
$agencyData[(string) $agency['AgencyId']]['cardData']=[];
}
// Populating each agency with agents
foreach ($agents as $agent)
{
$title = utf8_encode($agent['Title']);
// Determines rating for an agent
$ratingMessage=' Rating pending';
if($agent['Rating']!=NULL){
$ratingMessage='Rating: <div id="rating'.$counter.'" class="ui star rating" data-rating="'.$agent['Rating'].'" data-max-rating="5"></div>';
}
// HTML formatting for agent card and modal
$currentCard = '
<div id="contactCard'.$counter.'" class="ui card">
<!-- MODAL '.$counter.' CODE -->
<div id="modal'.$counter.'" class="ui modal">
<div class="header">
Agent Contact Information
</div>
<div class="image content">
<div class="ui medium centered image">
<img class="modalImage" id="modalCard" src="'.$agent['Image'].'">
</div>
<div class="description">
<div class="ui header">'.$agent['AgtFirstName'].' '.$agent['AgtLastName'].'</div>
<!-- Agent Contact Information -->
<p>Phone#: '.$agent['AgtBusPhone'].'</p>
<p>Email: '.$agent['AgtEmail'].'</p>
<p>"'.$agent['Description'].'"</p>
<div class="ui grid form" action="" method="POST">
<table>
<tr>
<div class="focus field ui grid input">
<td><label class="four wide column" id="emailLabel" for="CustEmail">Email </label></td>
<td class="contactInput"><input class="ten wide column emailContact leftMargin" type="email" id="CustEmail" name="CustEmail" placeholder="Eg. john.doe@gmail.com" required="required"></td>
</div><br/>
</tr>
<tr>
<div class = "focus field ui grid input">
<td><label class="four wide column" id = "agentContactMessageLabel" for ="agentContactMessage">Message </label></td>
<td class="contactInput"><textarea class="ten wide column leftMargin" type="text" id="agentContactMessage"></textarea></td>
</div>
</tr>
</table>
</div>
</div>
</div>
<form class="modalForm actions" action="" method="post">
<div class="ui black deny button">
Back
</div>
<button type="submit" name="submit" class="contactButton ui button" value="'.$agent['AgentId'].'">
Contact Agent
</button>
</form>
</div>
<!-- CONTACT CARD '.$counter.' -->
<div class="ui centered small image imageDiv">
<img class="contactCardImage" id="'.$agent['AgtLastName'].'" src="'.$agent['Image'].'">
</div>
<div id="agentCardInfo" class="content">
<p class="header">'.$agent['AgtFirstName'].' '.$agent['AgtLastName'].'</p>
<div class="meta">
<span class="date">"'.$title.'"</span>
</div>
<div class="description">
'.$agent['AgtPosition'].'
</div>
</div>
<div class="extra">
'.
$ratingMessage.
'<button id="infoButton" class="ui button right floated">Info</button>
</div>
</div>
';
// Add agent to agency that he belongs to
array_push($agencyData[(string) $agent['AgencyId']]['cardData'],$currentCard);
$counter++; //counter for each contact card and modal
}
// Print out agency, then all agents beginning to that agency
foreach($agencyData as $agencyId){
echo "<div>".$agencyId['header']."</div>";
echo '<div class="ui five stackable cards">';
for ($i = 0; $i < count($agencyId['cardData']); $i++)
{
echo $agencyId['cardData'][$i];
}
echo '</div>';
}
?>
</div>
</main>
<script src="js/contact.js"></script>
<?php include ("pageSections/footer.php") ?>