-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
230 lines (206 loc) · 6.91 KB
/
index.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
/**
* homepage of the application
*/
namespace Cat;
session_start();
require_once 'config.php';
require_once 'session.php';
include "views/header.php"; //echos to screen
require_once "classCat.php";
/*
* require = functions
* include - templates
*/
$test = new Cat();
$getAllRecords = $test->getAllCats();
$howManyCats = count($getAllRecords);//how many total cats?
?>
<script>
var num = <?=$howManyCats?>;
$(function() {
var html = [];
for (var i = 0; i < num; i++) {
//html.push('<div id="cat' + i + '">' + i + '</div>');
html.push('<div class="cat"></div>');
}
$("#container").append(html.join('')); // append all in one go
});
</script>
<style>
#container {
float:left;
width:100%;
display:none;
}
.cat {
width:20px;
height:9px;
background:red;
display:block;
margin:1em;
float:left;
}
</style>
<div id="container">
<ul>
<li><a href="" title="New Pet">New Pet</a></li>
<li><a href="" title="All Pets">All Pets</a></li>
<li><a href="" title="Search Pets">Search Pets</a></li>
<li><a href="" title="Settings">Settings</a></li>
</ul>
</div>
<h2 class="page_heading">View Current Cats</h2>
<p><?=$howManyCats?> total</p>
<table id="cat_list" class="tablesorter">
<thead>
<tr>
<td class="no_sort"></td>
<td>ID</td>
<td>Cat Name</td>
<td>Age</td>
<td>Gender</td>
<td>Date Created</td>
<td>Record Updated</td>
<td>Coloring</td>
<td>Hair Length</td>
<td>Current Mood</td>
<td>Weight</td>
<td>Have Catittude?</td>
<td class="no_sort">View</td>
<td class="no_sort">Edit</td>
<td class="no_sort">Delete</td>
</tr>
</thead>
<tbody>
<tr>
<?php
$yes = '1';
foreach( $getAllRecords as $record)
{
echo '<tr>';
if ($record['gender'] == 'Female') {
echo "<td class='female'>";
} else {
echo "<td>";
}
echo '<i class="fa fa-paw" aria-hidden="true"></i></td>';
echo '<td>' . $record['id'] . '</td>';
echo '<td>' . $record['catName'] . '</td>';
echo '<td>' . $record['age'] . '</td>';
echo '<td>' . $record['gender'] . '</td>';
echo '<td>' . $record['createTime'] . '</td>';
echo '<td>' . $record['updatedTime'] . '</td>';
echo '<td>' . $record['coloring'] . '</td>';
echo '<td>' . $record['hairLength'] . '</td>';
echo '<td>' . $record['currentMood'] . '</td>';
echo '<td>' . $record['weight'] . '</td>';
if ($record['hasCatittude'] === $yes) {
echo '<td>Yes</td>';
} else {
echo '<td>Nope</td>';
}
echo '<td class="icon"><a href="view.php?id=' . $record['id'] . '" title="edit"><i class="fa fa-eye" aria-hidden="true"></i></a>';
echo '<td class="icon"><a href="edit.php?id=' . $record['id'] . '" title="edit"><i class="fa fa-pencil" aria-hidden="true"></i></a>';
echo '<td class="icon"><a title="Delete Cat" id="delete_cat"><i class="fa fa-trash-o" aria-hidden="true"></i></a></td>';
echo '</tr>';
}
?>
</tr>
</tbody>
</table>
<?php
/*
* hide all below
$tater->setGender("gender fluid");
$tater->setWeight(23223);
$tater->setColoring("calico");
echo 'The weight of '. $tater->getName() . ' is ' . $tater->getWeight() . ' and the Gender is ' . $tater->getGender() . ' and ' . $tater->getName() . '\'s color is ' . $tater->getColoring() . '. Pretty groovy.<br /><br />';
//echo $tater->checkIsGenderApproved() ? 1 : 0;
/* create new cat called Rex */
/*
* hide all below
$rex = new Cat("Rex Daniels");
$rex->setGender("male");
$rex->setWeight(4343343);
$rex->setColoring("red");
echo 'The weight of '. $rex->getName() . ' is ' . $rex->getWeight() . ' and the Gender is ' . $rex->getGender() . ' and ' . $rex->getName() . '\'s color is ' . $rex->getColoring() . '. Pretty cool.<br /><br />';
/* create new cat called Bobcat */
/*
* hide all below
$bobcat = new Cat("Bobcat");
$bobcat->setWeight("rar");
echo $bobcat->getWeight();
echo "<br />";
echo "<br />";
/* set and return color */
/*
* hide all below
$rex->setColoring("brown");
echo $rex->getColoring();
echo "<br />";
echo "<br />";
//echo $rex->checkIsColorApproved() ? 1 : 0;
/* set and return mood with feedback response based on data */
/*
* hide all below
$rex->setMood("rowdy");
echo $rex->getName(). 'is currently ' . $rex->getMood() . '!';
echo "<br />";
echo "<br />";
//@TODO: i am torn if i should move this to a class method, or if i should leave in this page. i guess it will depend on how this app evolves when we start creating the userClass input phase
switch( $rex->getMood() ) {
case 'grumpy':
echo 'Uh oh, watch out - '. $rex->getName() .' is grumpy!';
break;
case 'sleepy':
echo 'Oh no, ' . $rex->getName() . ' is super sleepy. Put '. $rex->returnGenderPronounUsage() . ' pug to bed!';
break;
case 'rowdy':
echo 'Be careful, '. $rex->getName() . ' just tore up the living room. This pug is rowdy! Let '. $rex->returnGenderPronounUsage() . ' outside!!';
break;
case 'hungry':
echo 'Poor thing needs his food! Give '. $rex->getName() . ' some food!';
break;
case 'thirsty':
echo 'Your pug is thirsty! Give '. $rex->getName() . ' some water!';
break;
}
echo "<br />";
echo "<br />";
//echo $rex->checkIsMoodApproved() ? 1 : 0;
echo "<br />";
echo "<br />";
/* set and return hair length */
/*
* hide all below
$rex->setHairLength('long');
echo $rex->getName() . '\'s length of hair is '. $rex->getHairLength();
echo "<br />";
echo "<br />";
/* set and determind if cat has catitude */
//echo $rex->getCatitudeStatus();
/*
* hide all below
//@TODO: i am torn if i should move this to a class method, or if i should leave in this page. i guess it will depend on how this app evolves when we start creating the userClass input phase
switch($rex->getCatitudeStatus()) {
case 0:
echo 'currently '. $rex->getName() . ' does not have catitude. what a bummer.<br />';
break;
case 1:
echo 'currently '. $rex->getName() . ' does have catitude. nice!<br />';
break;
}
echo "<br />";
$tater->setHasCatitude(1);
//@TODO: i am torn if i should move this to a class method, or if i should leave in this page. i guess it will depend on how this app evolves when we start creating the userClass input phase
switch($tater->getCatitudeStatus()) {
case 0:
echo 'currently '. $tater->getName() . ' does not have catitude. what a bummer.<br />';
break;
case 1:
echo 'currently '. $tater->getName() . ' does have catitude. nice!<br />';
break;
}
*///used from the hide all data block
include "views/footer.php";