/var/www/hkosl.com/gld/view/user.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
<!DOCTYPE html>
<html lang="en">

<head>

    <?php include 'inc/headlinks.php'?>

    <link href="../assets/css/bootstrap-table.min.css" rel="stylesheet">

</head>

<body>

    <?php include 'inc/nav.php'?>


    <div class="container-fluid lightblueBg wrap">
        <div class="pageControl">
            <h1 class="pageTitle"> User Management </h1>
            <button type="button" class="btn btn-success longBtn" data-bs-toggle="modal" data-bs-target="#Add"><i
                    class="fas fa-plus"></i> Add User</button>
        </div>

        <div class="table-responsive">

            <table id="table" class="table">
                <thead>
                    <tr>

                        <th data-field="userid" data-sortable="true">User ID</th>
                        <th data-field="name" data-sortable="true">User Name</th>
                        <th data-field="type" data-sortable="true">User Type</th>
                        <th data-field="company" data-sortable="true">Company</th>
                        <th data-field="state" data-sortable="true">Status</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>


                    <tr>


                        <td>1234567890</td>
                        <td>
                            Yeung Yeung Jennifer Chan Fong
                        </td>
                        <td>System Admin</td>

                        <td>Government Logistics Department</td>
                        <td>
                            <div class="toggleBox">
                                <div class="checkbox">
                                    <input type="checkbox" class="toggleCheckBox" />
                                    <label></label>
                                </div>
                                <span class="label"> </span>
                            </div>
                        </td>
                        <td>
                            <button type="button" class="btn-outline-edit longBtn" data-bs-toggle="modal"
                                data-bs-target="#Edit">Edit</button>

                        </td>



                    </tr>

                </tbody>
            </table>
        </div>


    </div>


    <?php include 'modal/modal_user.html'?>



    <script src="../assets/js/custom.js"></script>

    <script src="../assets/js/bootstrap-table.min.js"></script>
    <script src="../assets/js/bootstrap-table-locale-all.min.js"></script>
    <script src="../assets/js/bootstrap-table-export.min.js"></script>
    <script>
    $(function() {



        //     $('.toggleCheckBox').change(function() {
        //         alert(12345);
        //     if(this.checked) {
        //         var returnVal = confirm("Are you sure?");
        //         $(this).prop("checked", returnVal);
        //     }
        //     $('#textbox1').val(this.checked);        
        // });


        var $table = $("#table"),
            $remove = $("#remove"),
            selections = [];





        // var columns = [{
        //         title: "User ID",
        //         field: "userid",
        //         sortable: true,
        //         valign: "middle",
        //         width: "120px"

        //     },
        //     {
        //         title: "User Name",
        //         field: "name",
        //         sortable: true,
        //         valign: "middle",
        //         width: "600px"

        //     },
        //     {
        //         title: "User Type",
        //         field: "type",
        //         sortable: true,

        //         valign: "middle"
        //     },

        //     {
        //         title: "Company",
        //         field: "company",
        //         sortable: true,
        //         valign: "middle",



        //     }, {
        //         title: "Status",
        //         field: "state",
        //         sortable: true,
        //         valign: "middle",


        //     }

        // ];


        $.ajax({
            url: "../assets/json/user.json",
            type: "get",

            data: {},
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: false,

            success: function(result) {
                var data = result.data;

                console.log(data);
                $table.bootstrapTable({


                    data: data,
                    columns: [{}, {}, {},{},{ 
                            field: '',
                            title: 'Status',
                            align: 'left',
                            valign: 'middle',
                            width:'150xp',
                            clickToSelect: false,
                            formatter: function(value, row, index) {
                                //return '<input name="elementname"  value="'+value+'"/>';
                                return `<div class="toggleBox">
                                <div class="checkbox">
                                    <input type="checkbox" class="toggleCheckBox" />
                                    <label></label>
                                </div>
                                <span class="label"> </span>
                            </div>`;
                            }},
                        {
                            field: '',
                            title: '',
                            align: 'right',
                            valign: 'middle',
                            clickToSelect: false,
                            formatter: function(value, row, index) {
                                //return '<input name="elementname"  value="'+value+'"/>';
                                return `<button type="button" class="btn-outline-edit longBtn" data-bs-toggle="modal"
                                data-bs-target="#Edit">Edit</button>`;
                            }
                        }
                    ],
                    classes: "table table-hover table-no-bordered",

                    sortClass: undefined, //被排序的TD元素的類名
                    undefinedText: "-", //當數據為undefined時顯示的字符
                    striped: true, //設置為true會有隔行變色效果
                    sortName: "number", //定義排序列,通過URL方式獲取數據填寫字段名,否則填寫下標
                    sortOrder: "desc", //定義排序方式,'asc'或者'desc'
                    sortStable: true, //設置為true將獲得穩定的排序,並添加position屬性到行數據中
                    sortable: true, //設置為false將禁止所有列的排序
                    pagination: true, //設置為true會在表格底部顯示分頁條
                    paginationLoop: false, //設置為true啟用分頁條無限循環的功能
                    onlyInfoPagination: false, //設置為true只顯示總數據,而不顯示分頁按鈕。需要設置pagination ='true'
                    pageNumber: 1, //設置分頁首頁頁碼
                    pageSize: 10, //設置分頁頁面數據條數
                    pageList: [1, 3, 5, 10,
                    "ALL"], //設置分頁可供選擇的頁面數據條數。設置為All或者Unlimited,則顯示所有記錄

                 

                });



            },
            error: function(xhr, status, errorThrown) {
                console.log(errorThrown + "\n" + status + "\n" + xhr.statusTex);
            },

        });






    });

    $(document).on('change', '.toggleCheckBox', function() {


        if (this.checked) {

            $(this).parent().parent().find(".label").addClass("greenText").removeClass("garyText").text(
                "Active");
        } else {
            $(this).parent().parent().find(".label").text("");
        }

    });
    </script>
</body>





</html>