-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSP_step3.cfm
182 lines (163 loc) · 6.88 KB
/
DSP_step3.cfm
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
<cfparam name ="session.helm.filter.accountstatus" default="0,1">
<cfparam name = "session.helm.filter.resellerID" default="">
<cfparam name = "session.selectedUsers" default= "">
<cfparam name ="form.userID" default="">
<cfif StructKeyExists(URL,"resellerid")>
<cfset session.helm.filter.resellerID = URL.resellerID>
</cfif>
<cfif structkeyExists(form,"accountstatus")>
<cfset session.helm.filter.accountstatus = form.accountstatus>
</cfif>
<cfif StructKeyExists(form,"saveusers")>
<cfset session.selectedUsers = listremoveduplicates(form.users)>
<cfset alert.text = "Users saved successfully">
<cfset alert.type = "success">
</cfif>
<cfif structKeyExists(form,"clearUsers")>
<cfset session.selectedUsers = "">
<cfset alert.text = "Users list reset to 0">
<cfset alert.type = "success">
</cfif>
<form method="post">
<h2>Step 3 - Choose users to migrate</h2>
<div class="alert alert-info">
click on a reseller to display that resellers users.<br>
click the button to SELECT or REMOVE a user/reseller, your selection will be remembered between pages.<br />
<br />
</div>
<cfquery name="getUsers" datasource="helm">
<cfoutput>
select accountnumber,accounttype,accountstatus,firstname,lastname,companyname
from account
where accountstatus in (#session.helm.filter.accountstatus#)
<cfif StructKeyExists(form,"searchStr") AND form.searchStr neq "">
and ( accountNumber LIKE ('%#form.searchstr#%') OR
companyname LIKE ('%#form.searchstr#%') OR
firstname + ' ' + lastname LIKE ('%#form.searchstr#%')
)
<cfelse>
<cfif StructKeyExists(form,"viewUsers")>
AND accountNumber in (#ListQualify(session.selectedUsers,"'")#)
<cfelse>
<cfif session.helm.filter.resellerID is "">
and accounttype =1
<cfelse>
and reselleraccountnumber = <cfqueryparam cfsqltype="cf_sql_varchar" value="#session.helm.filter.resellerID#">
</cfif>
</cfif>
</cfif>
</cfoutput>
</cfquery>
<cfif structKeyExists(variables,"alert")>
<cfoutput><div class="alert alert-#alert.type#">#alert.text#</div></cfoutput>
</cfif>
<div class="span3 well">
<legend>USER Filter</legend>
Show users which are <br />
<cfoutput>
<input name="accountstatus" type="checkbox" value="0" #IIF(ListContains(session.helm.filter.accountstatus,0), "'checked'","")# /> Active<br />
<input name="accountstatus" type="checkbox" value="1" #IIF(ListContains(session.helm.filter.accountstatus,1), "'checked'","")# /> Suspended<br />
<input name="accountstatus" type="checkbox" value="2" #IIF(ListContains(session.helm.filter.accountstatus,2), "'checked'","")# /> Cancelled<br />
</cfoutput>
<br />
<input name="save" type="submit" value="Save Selection" class="btn btn-primary btn-small"/>
<br />
<br />
<cfif session.helm.filter.resellerID neq "">
<cfoutput>Currently showing users for Reseller ID: #session.helm.filter.resellerID#</cfoutput><br /><br />
<A HREF="index.cfm?step=3&resellerid=" class="btn btn-primary btn-small">Show Resellers</A>
<cfelse>
Currently showing Resellers. Select a reseller to view his users.
</cfif>
</div>
<div class="span3 well">
<legend>Search</legend>
Search by UserID, name or company<br />
<input type="text" name="searchStr" /><br />
<input name="search" type="submit" value="Search" class="btn btn-primary btn-small"/>
</div>
<div class="span3 well">
<legend>Results</legend>
<cfoutput>You currently have #ListLen(session.selectedusers)# users selected</cfoutput><br/><br />
<button name="clearUsers" type="submit" class="btn btn-primary btn-small">Reset List</button>
<button name="viewUsers" type="submit" class="btn btn-primary btn-small">View List</button>
</div>
<table class="table table-striped">
<thead class="fixedHeader">
<cfoutput>
<tr>
<td colspan="6" >Records: #getUsers.recordcount#</td>
</tr>
</cfoutput>
<tr>
<th><input type="button" id="selectAll" name="selectAll" value="Toggle All" class="btn btn-primary"></th><th>UserID</th><th>Account Type</th><th>Status</th><th>Comapny Name</th><th>Client Name</th>
</tr>
</thead>
<tbody class="scrollContent">
<cfoutput query="getUsers">
<tr>
<td><button data-toggle="buttons-checkbox" type="button" class="btn btn-default userID #IIF(ListFind(session.selectedUsers, accountnumber), "'active'","''")#" id="userID" value="#accountnumber#">#IIF(ListFind(session.selectedUsers, accountnumber), "'REMOVE'","'SELECT'")#</button></td>
<td><a href="index.cfm?step=3&resellerid=#accountnumber#">#accountnumber#</a></td><td><cfif accounttype is 0>ADMIN<cfelseif accounttype is 1>Reseller<cfelseif accounttype is 2>USER</cfif></td>
<td><cfif accountstatus is 0>ACTIVE<cfelseif accountstatus is 1>SUSPENDED<cfelseif accountstatus is 2>CANCELLED</cfif></td>
<td>#companyname#</td>
<td>#firstname# #lastname#</td>
</tr>
</cfoutput>
</tbody>
<tfoot>
<tr>
<td colspan="5"><input name="saveusers" type="submit" value="Save Selection" class="btn btn-primary"/>
</td>
</tr>
</tfoot>
</table>
<cfoutput>
<input type="hidden" name="users" id="users" size="40" value="#session.selectedUsers#"/>
</cfoutput>
<a href="index.cfm?step=2" class="btn btn-primary">« Back</a> <a href="index.cfm?step=4" class="btn btn-primary">Next »</a>
</form>
<script>
$(document).ready(function() {
//toogle all buttons
$('#selectAll').click(function() {
$('.userID').each(function() {
$(this).button('toggle');
if ($(this).hasClass('active'))
{
$(this).text('REMOVE');//button is active, so set text to REMOVE
$(this).text('SELECT');//button is NOT active, so set text to SELECT
getUsers = $('#users').val().split();//convert list to array
getUsers.push($(this).val()); //add button value to array
$('#users').val(getUsers.join()); //convert array back to list
}
else
{
var y = $('#users').val().split(',');
var remove = $(this).val();
y.splice( $.inArray(remove,y) ,1 ); //remove item from list
$('#users').val(y.join());
}
});
});
// add/remove userID's to the hidden form field when buttons clicked
$('.btn.userID').click(function() {
// we have to test the OPPOSITE of the active state because the button hasn't been toggled yet until AFTER this code runs.
// so when we are testing if it is ACTIVE, this is really going to be INACTIVE becaus eit will be changed after this runs.
if ($(this).hasClass('active'))
{
$(this).text('SELECT');
var y = $('#users').val().split(',');
var remove = $(this).val();
y.splice( $.inArray(remove,y) ,1 ); //remove item from list
$('#users').val(y.join());
}
else
{
$(this).text('REMOVE');
getUsers = $('#users').val().split();//convert list to array
getUsers.push($(this).val()); //add button value to array
$('#users').val(getUsers.join()); //convert array back to list
}
});
});
</script>