-
Notifications
You must be signed in to change notification settings - Fork 0
/
customers.php
202 lines (168 loc) · 5.11 KB
/
customers.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
<?php
$permission = "VIEW";
require_once('head.php');
require_once('bodystart.php');
?>
<script type="text/javascript">
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,',
template =
'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
base64 = function(s) {
return window.btoa(unescape(encodeURIComponent(s)))
},
format = function(s, c) {
return s.replace(/{(\w+)}/g, function(m, p) {
return c[p];
})
}
return function(table, name, filename) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {
worksheet: name || 'Worksheet',
table: table.innerHTML
}
document.getElementById("dlink").href = uri + base64(format(template, ctx));
document.getElementById("dlink").download = filename;
document.getElementById("dlink").click();
}
})();
var table;
var delStatus = "A";
var region;
$(document).ready(function() {
//refreshTable();
fillDropDown("api/getRegionList.php", "#region", true);
});
$(document).ready(function() {
$('#det').click(function() {
refreshTable();
});
});
$(document).ready(function() {
table = $('#customer').DataTable({
"pagingType": "full_numbers",
"lengthMenu": [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
"pageLength": 50,
"autoWidth": true,
"order": [],
"orderMulti": true,
"ajax": {
url: "api/getCustomerDetList.php",
data: function(d) {
// console.log("delstatus - "+delStatus);
d.delStatus = delStatus;
d.region = region;
}
},
"columns": [{
"data": "name"
},
{
"data": "description"
},
{
"data": "region_name"
},
{
"data": "active"
},
{
"data": "customer_id",
"render": function(data, type, row, meta) {
if (type === 'display') {
data = '<a href="viewcustomer.php?custid=' + data + '">View</a>';
}
return data;
}
}
]
});
});
function refreshTable() {
var checkBox = document.getElementById("actCheck");
if (checkBox.checked == true) {
delStatus = "A";
} else {
delStatus = "";
}
var stat = "";
$('#region :selected').each(function(i, sel) {
stat = "" + $(sel).val() + " " + stat;
});
region = stat.search("0") != -1 ? "" : stat.trim().replace(/ /g, ',');
// console.log("param 1 - " + region);
// console.log("param 0 - " + delStatus);
table.ajax.reload();
}
jQuery.ajaxSetup({
beforeSend: function() {
$('#loader').show();
$('#tableholder').hide();
},
complete: function() {
$('#loader').hide();
$('#tableholder').show();
},
success: function() {}
});
</script>
<legend>Customer Information</legend>
<div class="row">
<form id="opportunity-search">
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label class="control-label" for="status">Status</label>
<select id="region" name="region" class="form-control" multiple="multiple">
<option value="0">All</option>
</select>
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-4 col-lg-4">
<label for="Active-0">
<input type="checkbox" name="Active" id="actCheck" value="1" checked>
Active
</label>
</div>
<div class="col-xs-10 col-sm-4 col-md-4 col-lg-4">
<a href="addcustomer.php" class="btn btn-primary btn-lg float-right" type="button">
<span class="glyphicon glyphicon-plus"></span>
Add Customer
</a>
</div>
<div class="clearfix"></div>
<div class="col-xs-10 col-sm-4 col-md-4 col-lg-4">
<button id="det" name="det" type="button" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-search"></span>
Search
</button>
</div>
</form>
</div>
<br>
<form>
<div id="loader1">
<img id="loader" src="images/spinner.gif" style="display:none;" />
</div>
<div id="tableholder">
<input type="button" class="btn btn-default" onclick="tableToExcel('customer', 'Crux Report', 'cruxReport.xls')" value="Export to MS Excel">
<a id="dlink" style="display:none;"></a>
<div class="clearfix"></div><br>
<table id="customer" class="table table-striped" width="100%">
<thead>
<tr>
<th>Customer Name</th>
<th>Customer Description</th>
<th>Region</th>
<th>Status</th>
<th>Operation</th>
</tr>
</thead>
</table>
</div>
</div>
</form>
<?php
require_once('bodyend.php');
?>