source: pro-violet-viettel/sourcecode/application/modules/frontend/views/user_infor.php

Last change on this file was 906, checked in by namnd, 10 years ago
File size: 4.0 KB
Line 
1<form id="admin_update_user_form">
2
3
4    <div class="col-xs-12"  style="margin: 5px;">
5        <div class="form-group">
6            <label for="form-field-first" class="col-sm-4 control-label no-padding-right">Họ và tên</label>
7            <div class="col-sm-8">
8                <input type="text" name="fullname" value="<?php echo @$user['fullname']; ?> " placeholder="Họ và tên" id="form-field-first" class="col-xs-12 col-sm-10">
9            </div>
10        </div>
11    </div>
12
13
14
15    <div class="col-xs-12"  style="margin: 5px;">
16        <div class="form-group">
17            <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Đơn vị</label>
18            <div class="col-sm-8">
19                <input type="text" name="school" value="<?php echo @$user['school']; ?>" placeholder="Đơn vị" id="form-field-username" class="col-xs-12 col-sm-10">
20            </div>
21        </div>
22    </div>
23
24    <div class="col-xs-12" style="margin: 5px;">
25        <div class="form-group">
26            <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Tỉnh / Thành phố</label>
27            <div class="col-sm-8">
28                <select name="province" id="form-field-province" class="form-field-province-user col-xs-12 col-sm-10">
29                                        <option></option>
30                    <?php foreach ($provinces as $key => $pro): ?>
31                        <option value="<?php echo $key; ?>" <?php if ($user['province'] == $key) echo "selected"; ?>><?php echo $pro; ?></option>
32                    <?php endforeach; ?>
33                </select>
34            </div>
35        </div>
36    </div>
37        <div class="col-xs-12" style="margin: 5px;">
38                <div class="form-group">
39                        <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
40                        <div class="col-sm-8">
41                                <select name="district" id="form-field-district" class="form-field-district-user col-xs-12 col-sm-10">
42
43                                </select>
44                        </div>
45                </div>
46        </div>
47
48    <input type="hidden" name="us_id" value="<?php echo $user['us_id'] ?>">
49    <?php
50    if (in_array("editUserInfo", $roles)) {
51        ?><div class="col-xs-12" style="margin: 5px;">
52            <div class="form-group">
53                <input  class="btn btn-primary pull-right " type="button" value="Cập nhật" onclick="admin_update_user();"/>
54            </div>
55        </div>
56        <?php
57    }
58    ?>
59</form>
60<script>
61var district_id = "<?php echo $user['district']; ?>";
62var province_id = "<?php echo $user['province']; ?>";
63
64$(document).ready(function(){
65        $(".form-field-province-user").change(function(){
66                changeEventProvince(province_id);
67        });
68        if ($(".form-field-province-user").val() !== 'undefined'){
69                checkSelectedDistrict(province_id);
70        }
71});
72
73function changeEventProvince(provinceId){
74        $(".form-field-district-user").html("");
75        $.ajax({
76        url: '/frontend/user/getDistrict/' + provinceId,
77        type: 'POST',
78        success: function (data, textStatus, jqXHR)
79        {
80            result = jQuery.parseJSON(data);
81                        content = "<option></option>";
82                        if (result != null){
83                                for (var i in result){                 
84                                        content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " "  + result[i].district_name + '</option>'
85                                }
86                        }
87                        $(".form-field-district-user").html(content);
88        }
89    });
90}
91
92function checkSelectedDistrict(provinceId){
93        $.ajax({
94        url: '/frontend/user/getDistrict/' + provinceId,
95        type: 'POST',
96        success: function (data, textStatus, jqXHR)
97        {
98            result = jQuery.parseJSON(data);   
99                        content = "<option></option>";
100                        if (result != null){
101                                for (var i in result){
102                                        if (result[i].district_id === district_id){
103                                                content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
104                                        }else{
105                                                content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " "  + result[i].district_name + '</option>';
106                                        }
107                                }
108                               
109                        }
110                        $(".form-field-district-user").html(content);
111        }
112    });
113}
114</script>
Note: See TracBrowser for help on using the repository browser.