456 lines
18 KiB
PHP
456 lines
18 KiB
PHP
<div id="overlay" style="display:none;">
|
|
<div class="spinner"></div>
|
|
<br />
|
|
Exporting...
|
|
</div <div class="panel panel-flat" style="background-color: aliceblue;">
|
|
<div class="panel-body">
|
|
<div class="row">
|
|
<div id="lineoption">
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-lg-3">
|
|
<!-- Current server load -->
|
|
<div class="panel">
|
|
<div class="panel-heading">
|
|
<h5>Tracked Email Items</h5>
|
|
</div>
|
|
<div>
|
|
<form id="tracked-email-form" autocomplete="off">
|
|
<div style="padding: 10px">
|
|
<div class="date">
|
|
<div class="search-by-range">
|
|
<div class="col-lg-6">
|
|
<input type="search" name="start_date" id="start_date" value="<?= $start_date ?>" class="form-control" placeholder="Start date"/>
|
|
</div>
|
|
<div class="col-lg-6">
|
|
<input type="search" name="end_date" id="end_date" value="<?= $end_date ?>" class="form-control" placeholder="End date"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<!-- <div class="member_id_filter">
|
|
<label for="member_id_filter" class="font-weight-bold col-form-label">
|
|
Member ID
|
|
</label>
|
|
<div class="">
|
|
<input type="search" name="member_id_filter" id="member_id_filter" value="<?= $member_id_filter ?>" class="form-control" />
|
|
</div>
|
|
</div> -->
|
|
<div class="row" style="margin-top: 5px;">
|
|
<div class="form-group subject col-md-6">
|
|
<label for="subject" class="font-weight-bold">
|
|
Subject
|
|
</label>
|
|
<div class="">
|
|
<input type="search" name="subject" id="subject" value="<?= $subject ?>" class="form-control" placeholder="Subject" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group sender col-md-6">
|
|
<label for="message_from" class="font-weight-bold">
|
|
Sender
|
|
</label>
|
|
<div class="">
|
|
<input type="search" name="message_from" id="message_from" value="<?= $message_from ?>" class="form-control" placeholder="Sender" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-right">
|
|
<input type="button" name="search" id="search" value="Search" class="btn btn-info" />
|
|
<input type="button" id="exportZIP" value="Export" class="btn btn-warning" />
|
|
</div>
|
|
<input type="hidden" name="member_id" id="member_id" value="<?= $member_id ?>" class="form-control" />
|
|
</div>
|
|
</form>
|
|
<span style="color:red" id="message"></span>
|
|
<div class="alert alert-danger" id="print-error-msg" style="display:none">
|
|
<a href="#" class="close">×</a>
|
|
<p id="error-msg"></p>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<div class="panel-heading mb-20" style="margin-top: 10px">
|
|
<div class="heading-elements">
|
|
<?php if (is_array($tpages)) { ?><table>
|
|
<tr>
|
|
<td>Page <?= $tpage ?> out of <?= $ttotal_pages ?></td>
|
|
<td><?= $pagination_config['full_tag_open'] ?>
|
|
<?php foreach ($tpages as $key => $val) {
|
|
if ($member_tracked_offset == $val) {
|
|
echo $pagination_config['cur_tag_open'] . $key . $pagination_config['cur_tag_close'];
|
|
} else {
|
|
echo $pagination_config['num_tag_open'] .
|
|
"<a href='#'
|
|
onclick=\"viewMemberActionLimitOffset(
|
|
'EMAILOTHER',
|
|
${member_id},
|
|
'${limit}',
|
|
'${val}',
|
|
'subject=${subject}&message_from=${message_from}',
|
|
'member_tracked'
|
|
);
|
|
return false;\">
|
|
${key}
|
|
</a>" . $pagination_config['num_tag_close'];
|
|
}
|
|
}
|
|
echo $pagination_config['full_tag_close']; ?></td>
|
|
</tr>
|
|
</table><?php } ?>
|
|
</div>
|
|
</div>
|
|
<div class="panel-body" style="padding: 0">
|
|
<div class="table-responsive tbl-small">
|
|
<?= $member_tracked ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- /current server load -->
|
|
</div>
|
|
|
|
<div class="col-lg-9">
|
|
<div class="panel">
|
|
<div class="panel-heading">
|
|
<h5>Parsed Email Receipts</h5>
|
|
</div>
|
|
<div>
|
|
<form name="parsed_email_form" id="parsed-email-form" autocomplete="off">
|
|
<div class="form-group" style="padding: 0 20px">
|
|
<div class="travel_date">
|
|
<label for="start_travel_date" class="font-weight-bold col-form-label">
|
|
Receipt Date
|
|
</label>
|
|
<div class="search-by-range">
|
|
<div class="">
|
|
<input type="search" name="start_travel_date" id="start_travel_date" value="<?= $start_travel_date ?>" class="form-control" placeholder="Start date"/>
|
|
</div>
|
|
<div class="">
|
|
<input type="search" name="end_travel_date" id="end_travel_date" value="<?= $end_travel_date ?>" class="form-control" placeholder="End date"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="cost">
|
|
<label for="cost_start" class="font-weight-bold col-lg-1 col-form-label">
|
|
Amount
|
|
</label>
|
|
<div class="search-by-range">
|
|
<div class="">
|
|
<input type="search" maxlength="10" name="cost_start" id="cost_start" value="<?= $cost_start ?>" class="form-control" placeholder="Amount from" />
|
|
</div>
|
|
<div class="">
|
|
<input type="search" maxlength="10" name="cost_end" id="cost_end" value="<?= $cost_end ?>" class="form-control" placeholder="Amount to" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<input type="button" name="search_parsed_email" id="search_parsed_email" value="Search" class="btn btn-info" />
|
|
</div>
|
|
</form>
|
|
<?php if (!empty($errors)) { ?>
|
|
<div class="alert alert-danger" id="parsed-email-error-msg">
|
|
<a href="#" class="close">×</a>
|
|
<p id="error-msg">
|
|
<?php foreach ($errors as $ele) { ?>
|
|
<p><?= $ele ?></p>
|
|
<?php } ?>
|
|
</p>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
<div class="panel-heading mt-20">
|
|
<div class="heading-elements">
|
|
<?php if (is_array($pages)) { ?><table>
|
|
<tr>
|
|
<td>Page <?= $page ?> out of <?= $total_pages ?></td>
|
|
<td><?= $pagination_config['full_tag_open'] ?>
|
|
<?php foreach ($pages as $key => $val) {
|
|
if ($member_parsedemail_offset == $val) {
|
|
echo $pagination_config['cur_tag_open'] . $key . $pagination_config['cur_tag_close'];
|
|
} else {
|
|
echo $pagination_config['num_tag_open'] .
|
|
"<a href='#' onclick=\"viewMemberActionLimitOffset(
|
|
'EMAILOTHER',
|
|
${member_id},
|
|
'${limit}',
|
|
'${val}',
|
|
generateParamsFromForm('parsed-email-form'),
|
|
'member_parsedemail'
|
|
);
|
|
return false;\">${key}</a>"
|
|
. $pagination_config['num_tag_close'];
|
|
}
|
|
}
|
|
echo $pagination_config['full_tag_close']; ?></td>
|
|
</tr>
|
|
</table><?php } ?>
|
|
</div>
|
|
</div>
|
|
<div class="panel-body" style="padding: 0">
|
|
<div class="table-responsive">
|
|
<?= $member_parsedemail ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- /members online -->
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/assets/js/plugins/pickers/datepicker.js"></script>
|
|
<script type="text/javascript">
|
|
if(typeof window.email_other_paging_state === "undefined"){
|
|
window.email_other_paging_state = {
|
|
member_tracked: {
|
|
offset: 0
|
|
},
|
|
member_parsedemail: {
|
|
offset: 0
|
|
},
|
|
};
|
|
}
|
|
function viewMemberActionLimitOffset(action_name, member_id, limit, offset, params, type) {
|
|
|
|
$('#transp_detail').html('Processing...');
|
|
$('#acc' + member_id).prop('disabled', true);
|
|
|
|
//save data
|
|
type = type || '';
|
|
if(type === 'member_parsedemail' || type === 'member_tracked'){
|
|
window.email_other_paging_state[type].offset = offset;
|
|
}
|
|
|
|
$.ajax({
|
|
url: "/member/viewMemberAction?proc=PROCESS&action_name=" + action_name +
|
|
"&member_id=" + member_id +
|
|
"&limit=" + limit +
|
|
"&member_parsedemail_offset="+ window.email_other_paging_state.member_parsedemail.offset +
|
|
"&member_tracked_offset="+ window.email_other_paging_state.member_tracked.offset +
|
|
'&' + params
|
|
}).done(function(data) {
|
|
$('#transp_detail').html(data);
|
|
$('#acc' + member_id).prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function generateParamsFromForm(form) {
|
|
return $('#' + form).serialize();
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$('#search').on('click', function(event) {
|
|
event.preventDefault();
|
|
viewMemberActionLimitOffset(
|
|
'EMAILOTHER', <?= $member_id ?>, '50', '0', $('#tracked-email-form').serialize(),'member_tracked');
|
|
})
|
|
|
|
$('#search_parsed_email').on('click', function(event) {
|
|
event.preventDefault();
|
|
viewMemberActionLimitOffset(
|
|
'EMAILOTHER', <?= $member_id ?>, '50', '0', $('#parsed-email-form').serialize(),'member_parsedemail');
|
|
})
|
|
|
|
$("#start_date, #start_travel_date").datepicker({
|
|
defaultDate: "+1w",
|
|
changeMonth: true,
|
|
numberOfMonths: 3,
|
|
format: 'yyyy-mm-dd',
|
|
onClose: function(selectedDate) {
|
|
$("#start_date, #start_travel_date").datepicker("option", "minDate", selectedDate);
|
|
}
|
|
})
|
|
|
|
$("#end_date, #end_travel_date").datepicker({
|
|
defaultDate: "+1w",
|
|
changeMonth: true,
|
|
numberOfMonths: 3,
|
|
format: 'yyyy-mm-dd',
|
|
onClose: function(selectedDate) {
|
|
$("#end_date, #end_travel_date").datepicker("option", "maxDate", selectedDate);
|
|
}
|
|
})
|
|
|
|
$('.close').on('click', function() {
|
|
$(this).parent().toggle();
|
|
})
|
|
|
|
$('#exportZIP').on('click', function(e) {
|
|
$('#message').empty();
|
|
e.preventDefault();
|
|
|
|
// validate upload form
|
|
// $("#tracked-email-form").validate({
|
|
// rules: {
|
|
// member_id_filter: {
|
|
// required: true,
|
|
// number: true
|
|
// }
|
|
// },
|
|
// messages: {
|
|
// member_id_filter: {
|
|
// required: 'Please input Member ID',
|
|
// number: 'Please input number'
|
|
// }
|
|
// }
|
|
// });
|
|
|
|
if ($("#tracked-email-form").valid() === false) {
|
|
return;
|
|
}
|
|
|
|
$('#overlay').fadeIn();
|
|
|
|
export_zip_file()
|
|
.then((data) => {
|
|
})
|
|
.catch(error => {
|
|
|
|
$('message').append('<b>Something went wrong !!!</b>');
|
|
|
|
}).finally(() => {
|
|
|
|
$('#overlay').fadeOut();
|
|
|
|
});
|
|
})
|
|
|
|
function export_zip_file() {
|
|
return new Promise(function(resolve, reject) {
|
|
const params = {
|
|
proc: 'PROCESS',
|
|
action_name: 'EMAILOTHER',
|
|
member_id: '<?= $member_id ?>',
|
|
export: 'ZIP',
|
|
filters: $('#tracked-email-form').serialize()
|
|
};
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.onerror = function() {
|
|
reject(Error("Network Error"));
|
|
};
|
|
|
|
xhr.open('POST', '/member/viewMemberAction', true);
|
|
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
xhr.onload = function() {
|
|
if (xhr.status == 200) {
|
|
// get file name
|
|
let filename = "";
|
|
const disposition = xhr.getResponseHeader('Content-Disposition');
|
|
if (disposition && disposition.indexOf('attachment') !== -1) {
|
|
const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
|
|
const matches = filenameRegex.exec(disposition);
|
|
if (matches != null && matches[1]) {
|
|
filename = matches[1].replace(/['"]/g, '');
|
|
}
|
|
}
|
|
|
|
let a = document.createElement('a');
|
|
let url = window.URL.createObjectURL(this.response);
|
|
a.href = url;
|
|
a.download = filename;
|
|
document.body.append(a);
|
|
a.click();
|
|
a.remove();
|
|
|
|
resolve(xhr.response);
|
|
} else if (xhr.status == 404) {
|
|
|
|
$('#message').append(`<b>Data Not Found!!!</b>`);
|
|
$('#overlay').fadeOut();
|
|
|
|
} else {
|
|
|
|
reject(Error(xhr.statusText));
|
|
|
|
}
|
|
};
|
|
|
|
xhr.responseType = 'blob';
|
|
xhr.send(new URLSearchParams(params).toString());
|
|
})
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style>
|
|
#parsed-email-form .form-group {
|
|
display: flex;
|
|
align-items: flex-end;
|
|
}
|
|
#tracked-email-form .form-group {
|
|
display: flex;
|
|
}
|
|
|
|
.cost,
|
|
.duration,
|
|
.travel_date,
|
|
.distance,
|
|
.subject,
|
|
.sender,
|
|
.surge {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.search-by-range {
|
|
display: flex;
|
|
align-items: flex-end;
|
|
}
|
|
|
|
.search-by-range div {
|
|
padding: 1px;
|
|
}
|
|
|
|
#overlay {
|
|
background: #ffffff;
|
|
color: #666666;
|
|
position: fixed;
|
|
height: 100%;
|
|
width: 100%;
|
|
z-index: 5000;
|
|
top: 0;
|
|
left: 0;
|
|
float: left;
|
|
text-align: center;
|
|
padding-top: 25%;
|
|
opacity: .80;
|
|
}
|
|
|
|
.spinner {
|
|
margin: 0 auto;
|
|
height: 64px;
|
|
width: 64px;
|
|
animation: rotate 0.8s infinite linear;
|
|
border: 5px solid firebrick;
|
|
border-right-color: transparent;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
@keyframes rotate {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
|
|
.btn-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.tbl-small td{
|
|
padding: 5px !important;
|
|
}
|
|
</style>
|