-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraw.php
executable file
·195 lines (182 loc) · 6.7 KB
/
raw.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
<?php
require_once('configuration.php');
$config = new Config;
require_once('include/dbconnect.php');
$type = $_REQUEST['type'];
$ajax = new ajax;
switch ($type) {
/*********************************/
/******* Save New Company ********/
/*********************************/
case 'SaveCompany':
# Save a new company via ajax
echo $ajax->SaveCompany();
break;
case 'CompanySelectList':
# refresh the company select list with the new company selected
echo $ajax->CompanySelectList();
break;
/*********************************/
/*** Add a new Market Segment ****/
/*********************************/
case 'SaveMarketSegment':
# Save a new company via ajax
echo $ajax->SaveMarketSegment();
break;
case 'MarketSegmentSelectList':
# refresh the company select list with the new company selected
echo $ajax->MarketSegmentSelectList();
break;
case 'SaveClientRole':
# refresh the company select list with the new company selected
echo $ajax->SaveClientRole();
break;
case 'ClientRoleList':
# refresh the company select list with the new company selected
echo $ajax->ClientRoleList();
break;
case 'loadMoreOpps':
# load more opportunities in the opportunities table for the company (account)
echo $ajax->loadMoreOpps();
default:
break;
}
class ajax {
/*********************************/
/******* Save New Company ********/
/*********************************/
function SaveCompany() {
$Company_Name = $_REQUEST['Company_Name'];
$query = "INSERT INTO company (Company_ID,Company_Name,Company_Active) VALUES (NULL,'$Company_Name',1)";
$result = mysql_query($query);
if (mysql_affected_rows()>0) {
$res .= 1;
$id = mysql_insert_id();
} else {
$res .= 0;
$id = NULL;
}
return $id;
}
function CompanySelectList(){
$id = $_REQUEST['id'];
$datalist = $this->GetCompanies();
$html = '<select name="Client_Company_ID" id="CCI">';
while($row = mysql_fetch_object($datalist)) {
$html .= '<option value="'.$row->Company_ID.'"'; if ($row->Company_ID==$id) { $html .= ' selected'; } $html .= '>'.$row->Company_Name.'</option>';
}
$html .= '</select>';
return $html;
}
function GetCompanies() {
$query = "SELECT Company_ID,Company_Name FROM company WHERE Company_Active!=0 ";
$query .= "ORDER BY Company_Name";
$result = mysql_query($query);
return $result;
}
/*********************************/
/*** Add a new Market Segment ****/
/*********************************/
function SaveMarketSegment() {
$Company_MarketSegmentName = $_REQUEST['Company_MarketSegmentName'];
$query = "INSERT INTO company_market_segments (Company_MarketSegmentID,Company_MarketSegmentName,Company_MarketSegmentActive) VALUES (NULL,'$Company_MarketSegmentName',1)";
$result = mysql_query($query);
if (mysql_affected_rows()>0) {
$res .= 1;
$id = mysql_insert_id();
} else {
$res .= 0;
$id = NULL;
}
return $id;
}
function MarketSegmentSelectList(){
$id = $_REQUEST['id'];
$datalist = $this->GetMarketSegments();
$html = '<select name="Company_MarketSegment" id="CMS">';
while($row = mysql_fetch_object($datalist)) {
$html .= '<option value="'.$row->Company_MarketSegmentID.'"'; if ($row->Company_MarketSegmentID==$id) { $html .= ' selected'; } $html .= '>'.$row->Company_MarketSegmentName.'</option>';
}
$html .= '</select>';
return $html;
}
function GetMarketSegments() {
$query = "SELECT Company_MarketSegmentID,Company_MarketSegmentName FROM company_market_segments WHERE Company_MarketSegmentActive!=0 ";
$query .= "ORDER BY Company_MarketSegmentName";
$result = mysql_query($query);
return $result;
}
/*********************************/
/***** Add a new Client Role *****/
/*********************************/
function SaveClientRole() {
$Client_RoleName = $_REQUEST['Client_RoleName'];
$query = "INSERT INTO client_roles (Client_RoleID,Client_RoleName,Client_RoleActive) VALUES (NULL,'$Client_RoleName',1)";
$result = mysql_query($query);
if (mysql_affected_rows()>0) {
$res .= 1;
$id = mysql_insert_id();
} else {
$res .= 0;
$id = NULL;
}
return $id;
}
function ClientRoleList(){
$id = $_REQUEST['id'];
$datalist = $this->GetClientRoleList();
$html = '<select name="Client_RoleID" id="CRI">';
while($row = mysql_fetch_object($datalist)) {
$html .= '<option value="'.$row->Client_RoleID.'"'; if ($row->Client_RoleID==$id) { $html .= ' selected'; } $html .= '>'.$row->Client_RoleName.'</option>';
}
$html .= '</select>';
return $html;
}
function GetClientRoleList() {
$query = "SELECT Client_RoleID,Client_RoleName FROM client_roles WHERE Client_RoleActive!=0 ";
$query .= "ORDER BY Client_RoleName";
$result = mysql_query($query);
return $result;
}
function loadMoreOpps() {
$Company_ID = $_REQUEST['Company_ID'];
$Opp_LimitStart = $_REQUEST['Opp_LimitStart'];
$limit = 5;
$query = "SELECT Opp_ID,Opp_Name,opportunities.Opp_StageID,opportunities_stages.Opp_StageName,Opp_Amount,Opp_StartDate,Opp_CloseDate,Opp_Active
FROM opportunities ";
$querywhere .= "LEFT JOIN opportunities_stages ON opportunities_stages.Opp_StageID=opportunities.Opp_StageID
WHERE Opp_Active!=0 AND Opp_CompanyID='".$Company_ID."'";
//$queryorder .= " ORDER BY Opp_CloseDate ASC";
$querylimit .= " LIMIT $Opp_LimitStart,5";
$result = mysql_query($query.$querywhere.$queryorder.$querylimit);
$i=$Opp_LimitStart+1;
while($opp = mysql_fetch_object($result)){
$html .= '<tr id="tr'.$i.'">
<td class="a-l"><b>'.$opp->Opp_Name.'</b></td>
<td class="a-l">'.$opp->Opp_StageName.'</td>
<td class="a-r">$'.number_format($opp->Opp_Amount).'</td>
<td class="a-l">'.date('d/m/Y',strtotime($opp->Opp_CloseDate)).'</td>
<td class="a-r"><a href="index.php?c=company&task=editopp&Company_ID='.$row->Company_ID.'&id='.$opp->Opp_ID.'&redir='.urlencode('index.php?c=company&task=view&id='.$row->Company_ID).'" class="btn">Edit</a></td>
</tr>';
$i++;
}
//$html .= '<tr><td class="a-l" colspan="5"><b>'.$Opp_LimitStart.'<hr />'.$query.$querywhere.$queryorder.$querylimit.'</b></td></tr>';
$querytotal = "SELECT COUNT(*) FROM opportunities LEFT JOIN opportunities_stages ON opportunities_stages.Opp_StageID=opportunities.Opp_StageID
WHERE Opp_Active!=0 AND Opp_CompanyID='".$Company_ID."'";
$resulttotal = mysql_query($querytotal);
$totalrows = mysql_result($resulttotal, 0);
/*
if ($totalrows>$Opp_LimitStart+$limit) {
$html .= '<tfoot>';
$html .= '<tr><td colspan="5" style="text-align:center;">
<input type="hidden" id="Company_ID" value="'.$Company_ID.'">
<input type="hidden" id="Opp_Limit" value="'.$Opp_LimitStart+$limit.'">
<a href="#" class="btn" id="loadmore">Load More ('.($Opp_LimitStart+$limit).')</a>
</td></tr>';
$html .= '</tfoot>';
}
*/
return $html;
}
}
?>