-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax-supply.php
78 lines (69 loc) · 2.45 KB
/
ajax-supply.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
<?php
/**
* User: swapnil
* Date: 7/6/13
* Time: 11:40 PM
* To change this template use File | Settings | File Templates.
*/
//ini_set('error_reporting', E_ALL);
//ini_set('display_errors', 1);
$res = array( 'result' => 'fail' );
include_once("appWideConfig.php");
if ( isset( $_REQUEST['action'] ) ) {
require_once("common/start.php");
switch ( $_REQUEST['action'] ) {
case 'get_project':
$query = $_REQUEST['query'];
$parameters = array(
'proonly' => 1,
'query' => $query
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SERVER_URL."/typeahead.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
break;
case 'get_project_detail':
$id = $_REQUEST['id'];
$parameters = array(
'proid' => $id
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SERVER_URL."/typeahead.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$projectDetails = curl_exec($ch);
curl_close($ch);
$projectDetails = json_decode( $projectDetails, TRUE );
// get Available Properties and Tower Info
require_once("includes/class_project.php");
$towerInfo = getTowerInfoByProjectId( $id, $db_project );
$availablePropInfo = getAvailablePropInfo( $id, $db_project );
$result = array();
$result['projDetail'] = $projectDetails[0];
$result['towerDetail'] = $towerInfo;
$result['availableDetail'] = $availablePropInfo;
$res = json_encode( $result );
break;
default:
# code...
$res = json_encode( $result );
break;
}
}
function getAvailablePropInfo( $projectId, $db_project ) {
$proObj = new Project( $db_project );
$res = $proObj->getAvailableProjectInfo( $projectId );
return $res;
}
function getTowerInfoByProjectId( $projectId, $db_project ) {
$proObj = new Project( $db_project );
$res = $proObj->getTowerInfoByProjectId( $projectId );
return $res;
}
echo $res;
exit;