-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual_lead.php
401 lines (373 loc) · 25.1 KB
/
manual_lead.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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<?php include('inc_meta_header.php'); ?>
<title>
<?php
$page_link_url = basename($_SERVER['PHP_SELF']);
$plu_del_ext = rtrim($page_link_url, ' .php');
echo $plu_del_rep = ucwords(str_replace("_", " ", $plu_del_ext));
?>
<?php include('inc_page_title.php'); ?>
</title>
<?php include('inc_head.php'); ?>
<script>
var xport = {
_fallbacktoCSV: true,
toXLS: function(tableId, filename) {
this._filename = (typeof filename == 'undefined') ? tableId : filename;
//var ieVersion = this._getMsieVersion();
//Fallback to CSV for IE & Edge
if ((this._getMsieVersion() || this._isFirefox()) && this._fallbacktoCSV) {
return this.toCSV(tableId);
} else if (this._getMsieVersion() || this._isFirefox()) {
alert("Not supported browser");
}
//Other Browser can download xls
var htmltable = document.getElementById(tableId);
var html = htmltable.outerHTML;
this._downloadAnchor("data:application/vnd.ms-excel" + encodeURIComponent(html), 'xls');
},
toCSV: function(tableId, filename) {
this._filename = (typeof filename === 'undefined') ? tableId : filename;
// Generate our CSV string from out HTML Table
var csv = this._tableToCSV(document.getElementById(tableId));
// Create a CSV Blob
var blob = new Blob([csv], {
type: "text/csv"
});
// Determine which approach to take for the download
if (navigator.msSaveOrOpenBlob) {
// Works for Internet Explorer and Microsoft Edge
navigator.msSaveOrOpenBlob(blob, this._filename + ".csv");
} else {
this._downloadAnchor(URL.createObjectURL(blob), 'csv');
}
},
_getMsieVersion: function() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf(".", msie)), 10);
}
var trident = ua.indexOf("Trident/");
if (trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf("rv:");
return parseInt(ua.substring(rv + 3, ua.indexOf(".", rv)), 10);
}
var edge = ua.indexOf("Edge/");
if (edge > 0) {
// Edge (IE 12+) => return version number
return parseInt(ua.substring(edge + 5, ua.indexOf(".", edge)), 10);
}
// other browser
return false;
},
_isFirefox: function() {
if (navigator.userAgent.indexOf("Firefox") > 0) {
return 1;
}
return 0;
},
_downloadAnchor: function(content, ext) {
var anchor = document.createElement("a");
anchor.style = "display:none !important";
anchor.id = "downloadanchor";
document.body.appendChild(anchor);
// If the [download] attribute is supported, try to use it
if ("download" in anchor) {
anchor.download = this._filename + "." + ext;
}
anchor.href = content;
anchor.click();
anchor.remove();
},
_tableToCSV: function(table) {
// We'll be co-opting `slice` to create arrays
var slice = Array.prototype.slice;
return slice
.call(table.rows)
.map(function(row) {
return slice
.call(row.cells)
.map(function(cell) {
return '"t"'.replace("t", cell.textContent);
})
.join(",");
})
.join("\r\n");
}
};
</script>
<?php
if (isset($_GET['del'])) {
$del = $_GET['del'];
//UPDATE SQL Statement
$sql = "DELETE FROM `calling_lead` WHERE ID = $del";
$sql = "DELETE FROM `calling_lead_comments` WHERE LEAD_R_ID = $del";
mysqli_query($link, "DELETE FROM `calling_lead` WHERE ID = $del");
mysqli_query($link, "DELETE FROM `calling_lead_comments` WHERE LEAD_R_ID = $del");
mysqli_query($link, "DELETE FROM `calling_comments_call` WHERE Cl_ID = $del");
echo ("<script>location='" . basename($_SERVER['PHP_SELF']) . "?delete=y'</script>");
}
//============ Approve Unapprove in List ================
if (isset($_REQUEST['actc'])) {
$RID = $_REQUEST['id'];
if ($_REQUEST['actc'] == 'app') {
$sql = "UPDATE admin SET STATUS='1' WHERE ID=$RID ";
} else if ($_REQUEST['actc'] == 'unapp') {
$sql = "UPDATE admin SET STATUS='0' WHERE ID=$RID ";
}
if (!mysqli_query($link, $sql)) {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
echo ("<script>location='" . basename($_SERVER['PHP_SELF']) . "'</script>");
}
?>
<style>
.pm_0 {
padding: 0;
margin: 0;
}
</style>
<body class="nav-md" style="height: 100vh;">
<div class="container body">
<div class="main_container">
<div class="col-md-3 left_col">
<?php include('inc_nav.php'); ?>
</div>
<?php include('inc_header.php'); ?>
<!-- breadcrumb -->
<div class="breadcrumb_content">
<div class="breadcrumb_text"><a href="dashboard.php">Dashboard</a> / <?php echo $plu_del_rep; ?>
</div>
</div>
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<?php
$date_from = '';
$date_to = '';
$agent = '';
$agent_filter = '';
$date_filter = '';
$err_html = '';
if (isset($_POST['search'])) {
if (isset($_POST['date_from']) && !empty($_POST['date_from']) && isset($_POST['date_to']) && !empty($_POST['date_to'])) {
$date_from = $_POST['date_from'];
$date_to = $_POST['date_to'];
if (isset($_POST['agent']) && !empty($_POST['agent'])) {
$agent = $_POST['agent'];
$agent_filter = "AND USERID='$agent'";
}
$date_filter = "AND DATE(DATED) BETWEEN '$date_from' AND '$date_to' $agent_filter";
} else {
if (empty($date_from) && empty($date_to)) {
$err_html = '<div class="alert alert-danger">
<div class="container"><strong>Both Dates are Required</strong></div>
</div>';
} else {
if (empty($date_from)) {
$err_html = '<div class="alert alert-danger">
<div class="container"><strong>From Date is Required</strong></div>
</div>';
}
if (empty($date_to)) {
$err_html = '<div class="alert alert-danger">
<div class="container"><strong>To Date is Required</strong></div>
</div>';
}
}
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div class="col-lg-12 pm_0" style="display: flex;flex-direction: row; justify-content: center;">
<div class="col-lg-3 pm_0">
<input type="date" class="form-control input-date-picker datepicker-dropdown " id="date_from" name="date_from" placeholder="Start Date" autocomplete="off" value="<?php if (!empty($date_from)) {
echo $_POST['date_from'];
} ?>" />
</div>
<div class="col-lg-1 pm_0">
<span class="input-group-addon" style="padding: 9px 0;"><i class="fa fa-angle-left"></i> <span class="text-danger">*</span> From DATE To <span class="text-danger">*</span> <i class="fa fa-angle-right"></i></span>
</div>
<div class="col-lg-3 pm_0">
<input type="date" class="form-control input-date-picker" id="date_to" name="date_to" placeholder="End Date" autocomplete="off" value="<?php if (!empty($date_to)) {
echo $_POST['date_to'];
} ?>" />
</div>
<div class="col-lg-1 pm_0">
<span class="input-group-addon" style="padding: 9px 0;"> Agent </span>
</div>
<div class="col-lg-3 pm_0">
<select name="agent" class="form-control">
<option selected hidden disabled>SELECT</option>
<?php
$calling_lead_agents = mysqli_query($link, "SELECT * FROM `calling_lead_agents`");
foreach ($calling_lead_agents as $calling_lead_agent) {
?>
<option value="<?php echo $calling_lead_agent['ID']; ?>" <?php if (!empty($agent) && $calling_lead_agent['ID'] == $agent) {
echo "selected";
} ?>><?php echo $calling_lead_agent['PERSON_NAME']; ?></option>
<?php
}
?>
</select>
</div>
<div class="col-lg-1">
<button type="submit" name="search" class="btn btn-success col-lg-12"><i class="fa fa-search"></i> Search</button>
</div>
</div>
</form>
<?php echo $err_html; ?>
<div class="page-title">
<div class="title_left">
<h3><?php echo $plu_del_rep; ?></h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title" style="display: flex;flex-direction: row; justify-content: space-between;">
<h4><?php echo $plu_del_rep; ?></h4>
<ul class="nav navbar-right panel_toolbox">
<li><a href="<?php echo basename($_SERVER['REQUEST_URI']) ?>" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" title="Page Refresh"><i class="fa fa-refresh"></i></a></li>
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
<li>
<button type="button" id="btnExport" onclick="javascript:xport.toCSV('example');" class="btn btn-default"><i class="fa fa-download"></i> Export to CSV</button>
</li>
</ul>
</div>
<div class="x_content">
<table id="example" class="col-lg-12 table-striped table-condensed cf tbl">
<thead class="cf">
<tr>
<th>#</th>
<th>DATED</th>
<th>RMS ID</th>
<th>Phone</th>
<th>Email</th>
<th>Sending Country</th>
<th>Preffered Country</th>
<th>USER</th>
<th>Lead Status</th>
<th class="al-center">Action</th>
<td style="display: none;">Comments</td>
</tr>
</thead>
<tbody>
<?php
if (isset($_POST['search']) && !empty($date_filter)) {
$calling_leads = mysqli_query($link, "SELECT * FROM `calling_lead` WHERE MANUAL_LEAD='1' $date_filter");
if (mysqli_num_rows($calling_leads) > 0) {
foreach ($calling_leads as $index => $calling_lead) {
$ID = $calling_lead['ID'];
$DATED = $calling_lead['DATED'];
$RMS_ID = $calling_lead['RMS_ID'];
$PHONE = $calling_lead['PHONE'];
$EMAIL = $calling_lead['EMAIL'];
$PREFFERED_COUNTRY_ISO3 = $calling_lead['PREFFERED_COUNTRY'];
$SENDING_COUNTRY_ISO3 = $calling_lead['SENDING_COUNTRY'];
$USERID = $calling_lead['USERID'];
$U_DATED = $calling_lead['U_DATED'];
$LEAD_STATUS = $calling_lead['LEAD_STATUS'];
$LEAD_STATUS_DATED = $calling_lead['LEAD_STATUS_DATED'];
$STATUS = $calling_lead['STATUS'];
$PREFFERED_COUNTRY = mysqli_fetch_array(mysqli_query($link, "SELECT `name` FROM `currencies` WHERE iso3='$PREFFERED_COUNTRY_ISO3'"));
$SENDING_COUNTRY = mysqli_fetch_array(mysqli_query($link, "SELECT `name` FROM `currencies` WHERE iso3='$SENDING_COUNTRY_ISO3'"));
$calling_lead_comments = mysqli_query($link, "SELECT * FROM `calling_lead_comments` WHERE LEAD_R_ID='$ID'");
$calling_comments_call = mysqli_query($link, "SELECT * FROM `calling_comments_call` WHERE Cl_ID='$ID'");
$calling_lead_comments_count = 0;
$calling_comments_call_count = 0;
if (mysqli_num_rows($calling_lead_comments) > 0) {
$calling_lead_comments_count = mysqli_num_rows($calling_lead_comments);
}
if (mysqli_num_rows($calling_comments_call) > 0) {
$calling_comments_call_count = mysqli_num_rows($calling_comments_call);
}
if ($LEAD_STATUS != NULL) {
$result_lead_status = mysqli_query($link, "SELECT * FROM `lead_status` WHERE ID='$LEAD_STATUS'");
$rows_ls = mysqli_fetch_array($result_lead_status);
$STATUS_TITLE_STATUS = $rows_ls['STATUS_HEADING'];
}
$result_calling_lead_agents = mysqli_fetch_array(mysqli_query($link, "SELECT * FROM `calling_lead_agents` WHERE ID='$USERID'"));
if (!empty($result_calling_lead_agents)) {
$PERSON_NAME = $result_calling_lead_agents['PERSON_NAME'];
} else {
$PERSON_NAME = '';
}
?>
<tr>
<td></td>
<td data-title="Date"><?php echo $DATED; ?></td>
<td data-title="Rmsid"><small><?php echo $RMS_ID; ?></small></td>
<td data-title="Phone"><?php echo $PHONE; ?></td>
<td data-title="Email"><?php echo $EMAIL; ?></td>
<td data-title="Sending_country"><?php if (!empty($SENDING_COUNTRY)) {
echo $SENDING_COUNTRY['name'];
} ?></td>
<td data-title="Preffered_country"><?php if (!empty($PREFFERED_COUNTRY)) {
echo $PREFFERED_COUNTRY['name'];
} ?></td>
<td><?php echo $PERSON_NAME; ?><br><small><?php echo $U_DATED; ?></small></td>
<td>
<?php if ($LEAD_STATUS != NULL) { ?>
<?php echo $STATUS_TITLE_STATUS; ?><br>
<small><?php echo $LEAD_STATUS_DATED; ?></small>
<?php
} ?>
</td>
<td data-title="Action" class="al-center"><a href="calling_lead_comment_preview.php?id=<?php echo $ID; ?>&mnl=1" data-toggle="tooltip" data-placement="top" title="Preview" class="btn btn-success btn-sm"><i class="fa fa-search"></i></a><a href="<?php echo basename($_SERVER['PHP_SELF']) . "?del=" . $ID ?>" onclick="javascript:return confirm('Are you sure you want to delete ?')" data-toggle="tooltip" data-placement="top" title="Delete" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
<td style="display: none;"> <?php $counter = 1;
foreach ($calling_lead_comments as $calling_lead_comment) {
$LEAD_CMT_ID = $calling_lead_comment['LEAD_CMT_ID'];
$lead_comments = mysqli_query($link, "SELECT * FROM `lead_comments` WHERE ID='$LEAD_CMT_ID'");
if (mysqli_num_rows($lead_comments) > 0) {
$lead_comments_row = mysqli_fetch_array($lead_comments);
$COMMENT_HEADING = $lead_comments_row['HEADING'];
if ($COMMENT_HEADING == "Other") {
$COMMENT_AREA = $calling_lead_comment['COMMENT_AREA'];
} else {
$COMMENT_AREA = '';
}
} else {
$COMMENT_HEADING = '';
}
$result_statuses_i = mysqli_query($link, "SELECT `STATUS_HEADING` FROM `lead_status` WHERE ID='$calling_lead_comment[LEAD_STATUS]'");
while ($row_sts_i = mysqli_fetch_array($result_statuses_i)) {
$STATUS_HEADING_sts_i = $row_sts_i['STATUS_HEADING'];
}
if ($counter < $calling_lead_comments_count) {
echo $COMMENT_AREA_clcs = "<strong>" . $STATUS_HEADING_sts_i . ':- </strong>' . $COMMENT_HEADING . ': ' . $COMMENT_AREA . ' [ Date: ' . $calling_lead_comment['DATED'] . ' ]';
echo "\r\n";
} else {
echo $COMMENT_AREA_clcs = "<strong>" . $STATUS_HEADING_sts_i . ':- </strong>' . $COMMENT_HEADING . ': ' . $COMMENT_AREA . ' [ Date: ' . $calling_lead_comment['DATED'] . ' ] ';
}
$counter++;
} ?></td>
</tr>
<?php }
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
<?php include('inc_footer.php'); ?>
</div>
</div>
<?php include('inc_foot.php'); ?>
<script>
$(document).ready(function() {
$('#example').DataTable();
setTimeout(function() {
$('.alert').slideUp('slow');
}, 3000);
});
</script>