-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.php
More file actions
330 lines (304 loc) · 10.6 KB
/
main.php
File metadata and controls
330 lines (304 loc) · 10.6 KB
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<?php
//============================================================+
// File name : main.php
//
// Description : Displays all eztasker.com tasks along with google map.
//
// Author: Aditya Mathur
//
// (c) Copyright:
// Aditya Mathur
// eztasker.com
//
// License:
// Copyright (C) 2014 Aditya Mathur - eztasker.com
//============================================================+
session_start();
if(isset($_SESSION['li_uname111'])){
header('Location:./admin_home.php'); // jump to home page
}
elseif(isset($_SESSION['li_uname222'])){
$e=$_SESSION['li_uname222'];
$type=2;
$show=0;
$title="Task Poster";
$city=$_SESSION['city']; //Home city of poster
require_once './includes/db_config.php';
connect();
$rs=mysql_query("select poster_id from poster_profile where email ='".$e."' ");
$rows=mysql_fetch_array($rs);
$pid=$rows['poster_id'];
}
elseif(isset($_SESSION['li_uname333'])){
$e=$_SESSION['li_uname333'];
$type=3;
$show=0;
$title="Task Worker";
$city=$_SESSION['city']; //Home city of Worker
require_once './includes/db_config.php';
connect();
$rs=mysql_query("select worker_id from worker_profile where email ='".$e."' ");
$rows=mysql_fetch_array($rs);
$wid=$rows['worker_id'];
}
else{
//persist on default public home page
$e='';
$type=0;
$show=0;
$note='Search & Apply for tasks from the right pane by filling your desired task location, Zoom out/in map to view all the tasks.';
}
?>
<!-- Header -->
<?php include('./includes/header.php');?>
<div class="">
<!-- Menus -->
<?php include './includes/menu.php';?>
</div>
<div class="spacer"></div>
</div>
<!--Notifications for poster interface -->
<?php if($type==2){ ?>
<table>
<tr>
<td align="left"><?php include './notific_p.php';?></td>
<td><h3>( <?php echo $title;?> )</h3></td>
</tr>
</table>
<?php } ?>
<!--Notifications for worker interface -->
<?php if($type==3){ ?>
<table>
<tr>
<td align="left"><?php include './notific_w.php';?></td>
<td><h3>( <?php echo $title;?> )</h3></td>
</tr>
</table>
<?php } ?>
<!--Info bar -->
<?php if($type==0){ ?>
<h4 class="note">Note: <?php echo $note;?></h4>
<?php } ?>
<!-- Map.api -->
<?php function gmap(){ ?>
<iframe class="map-iframe" src='./map.php' scrolling="no"></iframe>
<br/>
<?php } ?>
<?php
//get page value for pagination
if(isset($_GET['start'])){
$start = $_GET['start'];
}else{
$start=0;
}
if(!$start){
$start=0;
}
$job_count="";
//handling default task-search
if(!isset($_GET['search'])){
$chk=0;
$category="";
$arrange="1";
//set queries
require_once './includes/db_config.php';
connect();
if($type==2){
$q= "SELECT * FROM task where poster_id='".$pid."' AND status=0 order by posted_date desc";
$_SESSION['query']=$q;
$show=1;
}
elseif($type==3){
$q= "SELECT * FROM task where status=0 AND location='".$city."' order by posted_date desc";
$_SESSION['query']=$q;
}
else{
$q= "SELECT * FROM task
WHERE status=0
ORDER BY address asc";
$_SESSION['query']=$q;
}
$result=mysql_query($q) or die(mysql_error());
$job_count=mysql_num_rows($result);
$result2=mysql_query($q) or die(mysql_error());
}
//handling Task-search
if(isset($_GET['search'])){
$show=0; //to show message
//Gathering data for search.
$chk=1;
$category=trim($_GET["category"]);
$search_loc=trim($_GET["search_loc"]);
$arrange=trim($_GET["arrange"]);
if($arrange=='1'){$str="posted_date asc";} if($arrange=='2'){$str="payment asc";}
if($arrange=='3'){$str="payment desc";} if($arrange=='4'){$str="posted_date desc";}
if($arrange=='5'){$str="deadline desc";}
//fields validations
if($search_loc == "" ){
$error= "error : You did not enter a location.";
$code= "2" ;
}
else{
//set queries
require_once './includes/db_config.php';
connect();
if($category == "" ){
$q= "SELECT * FROM task
WHERE location like '%$search_loc%'
AND status=0 ORDER BY $str";
}
elseif($category==11){
$q= "SELECT * FROM task
WHERE location like '%$search_loc%'
AND status=0 ORDER BY $str";
}else{
$q= "SELECT * FROM task
WHERE category='".$category."' && location like '%$search_loc%'
AND status=0 ORDER BY $str";
}
$_SESSION['query']=$q;
$result=mysql_query($q) or die(mysql_error());
$job_count=mysql_num_rows($result);
$result2=mysql_query($q) or die(mysql_error());
}
}
?>
<div class="main-table">
<div class="map"><?php
// pull entered location from db, otherwise display not found message
if($job_count>0){
while($row = mysql_fetch_array($result2)){
$location=$row['location'];
}
gmap();
}else{
if($type==2){
echo'<iframe class="map-iframe" src="info3.php";></iframe><br/><br/>';
}
else{
echo'<iframe class="map-iframe" src="info.php";></iframe><br/><br/>';
}
}
?>
</div>
<div class="jobsection"><!--Include Tooltips script-->
<?php require_once './includes/tooltip.php';?>
<!--Search Form-->
<form method="GET" action="">
<table class="main-table" id="table-hover">
<tr>
<td colspan="2"><?php if(isset($error)){echo'<p class=message >' .$error. ' <br></p>';}?></td>
</tr>
<tr>
<td><select name="category" title="Choose Task Category" >
<Option value="">Select Task Category</Option>
<option value="1" <?php if(isset($category) && $category ==1){echo "selected";}?>>Painting the fence</option>
<option value="2" <?php if(isset($category) && $category ==2){echo "selected";}?>>Mowing the lawn</option>
<option value="3" <?php if(isset($category) && $category ==3){echo "selected";}?>>Landscaping / gardening</option>
<option value="4" <?php if(isset($category) && $category ==4){echo "selected";}?>>Washing the dishes</option>
<option value="5" <?php if(isset($category) && $category ==5){echo "selected";}?>>Cleaning the bathroom</option>
<option value="6" <?php if(isset($category) && $category ==6){echo "selected";}?>>Changing light bulbs</option>
<option value="7" <?php if(isset($category) && $category ==7){echo "selected";}?>>Taking out the garbage</option>
<option value="8" <?php if(isset($category) && $category ==8){echo "selected";}?>>Laundry</option>
<option value="9" <?php if(isset($category) && $category ==9){echo "selected";}?>>Sweeping / dusting / vacuuming </option>
<option value="10"<?php if(isset($category) && $category ==10){echo "selected";}?>>Washing the car</option>
<option value="11"<?php if(isset($category) && $category ==11){echo "selected";}?>>Others</option>
</select>
<select name="arrange" title="Arange By" >
<option value="1" <?php if(isset($arrange) && $arrange ==1){echo "selected";}?>>By Date</option>
<option value="2" <?php if(isset($arrange) && $arrange ==2){echo "selected";}?>>Lowest Price First </option>
<option value="3" <?php if(isset($arrange) && $arrange ==3){echo "selected";}?>>Highest Price First </option>
<option value="4" <?php if(isset($arrange) && $arrange ==4){echo "selected";}?>>Most Recent</option>
<option value="5" <?php if(isset($arrange) && $arrange ==5){echo "selected";}?>>Near Deadline</option>
</select>
</td>
</tr>
<tr>
<td><input type="text" name="search_loc" size="65" title="Type desired task location" value="<?php if(isset($search_loc)){echo $search_loc;} ?>" <?php if(isset($code) && $code ==2){echo "class=error" ;} ?> >
<input type="submit" name="search" value="Search"></td>
</tr>
<!-- <tr><td colspan="2"><div class="hr"><hr/></div></td></tr> -->
</table>
</form>
<!--
<h4 align="center"><?php if($show==1){echo "You Posted ";}?> <?php echo $job_count; if($job_count==1){echo " Task ";}else{echo" Tasks ";}?> on EasyTasks.</h4>
-->
<table class="main-table" id="table-hover" >
<?php
//fetching data, based on 'query-batch' created above.
if($job_count>0){
//call to search with pagination method.
search($start,$job_count,$q,$category,$location,$arrange,$chk,$type);
}
?>
<?php
/* method to display task-search results */
function task($i,$id,$todo,$loc,$payment,$type){
echo'<tr><td colspan="5"><div class="hr"><hr/></div></td></tr>';
echo'<tr><td>'.$i.'.</td><td class="h">'.$todo.'</td>';
echo'<td>'.$loc.'</td>';
echo'<td>'.$payment.'</td>';
if($type==0 || $type==2 || $type==3){
$url=$id;
echo'<td><a title="Click to make offer for this task." href="job_apply1.php?t='.$url.'" class="but_pink">Make Offer</a></td></tr>';
}
else{
echo'<td><a href="job_apply1.php?$t='.$url.'" onclick = "javascript: return false;">Make Offer</a></td></tr>';
}
}
?>
<!--search method with pagination-->
<?php
function search($start,$job_count,$q,$category,$location,$arrange,$chk,$type){
require_once './includes/db_config.php';
connect();
$per_page = 9;
$foundnum=$job_count;
if(!$start) $start=0;
$append="LIMIT $start, $per_page";
$q= $q." ".$append;
$getquery = mysql_query($q);
$c=$start+1;
while($row= mysql_fetch_assoc($getquery))
{
$id=$row['task_id'];
$todo=$row['title'];
$currency=$row['currency'];
if($currency==1){$currency="Rs.";} if($currency==2){$currency="$";}
$payment=$row['payment'];
$payment= $currency." ".$payment; //concatenate
$location=$row['location'];
task($c,$id,$todo,$location,$payment,$type);// call to method task to display search list
$c++;
}
echo "<tr><td colspan=4><div class='hr'><hr/></div></td></tr>";
echo "</table>";
echo "<center>";
$prev = $start - $per_page;
$next = $start + $per_page;
if($chk!==0){
if (!($start<=0))
echo "<a class='h' href='main.php?category=$category&search_loc=$location&arrange=$arrange&search=Search&start=$prev'>Prev</a>"." ";
if (!($start>=$foundnum-$per_page)){
echo "<a class='h' href='main.php?category=$category&search_loc=$location&arrange=$arrange&search=Search&start=$next'>Next</a>";
}
}
else{
if (!($start<=0))
echo "<a class='h' href='main.php?start=$prev'>Prev</a>"." ";
if (!($start>=$foundnum-$per_page)){
echo "<a class='h' href='main.php?start=$next'>Next</a>";
}
}
//echo "<br>$q";
echo "</center>";
}
?>
</table><br/>
</div>
</div>
<!-- end page -->
<div class="clear"></div>
<!-- footer -->
<?php include('./includes/footer.php');?>