Changeset 838


Ignore:
Timestamp:
Mar 27, 2015 9:49:55 AM (10 years ago)
Author:
namnd
Message:
 
Location:
pro-violet-viettel
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php

    r690 r838  
    99        parent::__construct();
    1010        $this->load->helper('cookie');
     11                $this->load->helper('language');
     12                $this->lang->load('messages', 'message');
    1113    }
    1214
     
    2527        $this->load->helper('pagging');
    2628        $this->load->model('collabolator_model');
     29                $provinces = lang('_PROVINCES_');
    2730        $data['current_page'] = $this->uri->segment(4, 1);
    2831        $data['itemsoptions'] = array(10, 25, 50, 100);
     
    6265        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
    6366        $data['total'] = $this->collabolator_model->countCollaborator($data); 
    64         $data['collaborators'] = $this->collabolator_model->getCollaborators($data);
     67               
     68                $collaborators = $this->collabolator_model->getCollaborators($data);
     69                foreach ($collaborators as $index => $collaborator){
     70                        $collaborator ['province'] = isset($provinces[$collaborator ['province']]) ? $provinces[$collaborator ['province']] : $collaborator ['province'];
     71                        $collaborators[$index] = $collaborator;
     72                }
     73        $data['collaborators'] = $collaborators;
    6574
    6675        $data['paging_url'] = base_url() . "/admin/cong_tac_vien/trang/";
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportAsistant.php

    r742 r838  
    199199        $data['num_links'] = 2;
    200200        $data['paging'] = pagging($data);
    201 
     201               
    202202        if ($this->input->is_ajax_request()) {
    203203            return $this->load->view('reportAsistant/listview_user', $data);
  • pro-violet-viettel/sourcecode/application/modules/admin/models/admin_model.php

    r770 r838  
    1818                $result = $this->db->query($query, array($login_name, $hash_password));         
    1919               
    20                 if($result->num_rows() == 1){
    21                     $admin = $result->row(0);
    22                     $query="SELECT * FROM tbladminrole LEFT JOIN tblrole ON tbladminrole.role_id=tblrole.role_id WHERE tbladminrole.admin_id= ".$admin->admin_id;
    23                     $result2 = $this->db->query($query);
    24                     $admin->roles=$result2;
    25                     return $admin;
     20                if($result->num_rows() == 1){
     21                        $admin = $result->row(0);
     22                        $query="SELECT * FROM tbladminrole LEFT JOIN tblrole ON tbladminrole.role_id=tblrole.role_id WHERE tbladminrole.admin_id= ".$admin->admin_id;
     23                        $result2 = $this->db->query($query);
     24                        $admin->roles=$result2;
     25                        return $admin;
    2626                     
    2727                }else
  • pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php

    r742 r838  
    1717            if ($data['search_field'] == "cellphone") {
    1818                                if(strlen($data['daterange_start'])>0){
    19                                         $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     19                                        $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR full_name LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    2020                                }else{
    21                                         $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
     21                                        $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR full_name LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
    2222                                }
    2323            } else {
     
    215215            if ($data['search_field'] == "cellphone") {
    216216                                if(strlen($data['daterange_start'])>0){
    217                                         $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     217                                        $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR full_name LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    218218                                }else{
    219                                         $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
     219                                        $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%' OR full_name LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
    220220                                }
    221221            } else {
     
    439439    }
    440440
     441        function check_login($login_name, $password)
     442        {
     443                $hash_password = md5($password);
     444                $query = "SELECT * FROM tblcollaborator WHERE  login_name = ? AND  passwd = ?";
     445                $result = $this->db->query($query, array($login_name, $hash_password));         
     446                        if($result->num_rows() == 1){
     447                                $collaborator = $result->row(0);
     448                                return $collaborator;
     449                     
     450                }else
     451                {
     452                        return null;
     453                }
     454        }
     455       
    441456}
  • pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php

    r818 r838  
    3333               
    3434                // tinh doanh thu theo thang
     35                $from = "tblpaidlog.paid_time >= '" . $input ['year'] . "-" . $input ['month'] . "-01 00:00:00'";
    3536                $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE $from AND $to  GROUP BY tbluser.province";
    3637                $query = $this->db->query ( $sql );
     
    133134                $data['totalDtn'] = $totalDtn;
    134135               
    135                 //return $provinces;
    136136                return $data;
    137137        }
  • pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/listview.php

    r719 r838  
    9797                                }
    9898                                ?>" id="cellphone" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Số điện thoại: activate to sort column ascending">Số điện thoại</th>
     99                                                                <th>Họ và tên</th>
    99100                                <th>Quận/Huyện</th>
    100101                                <th>Tỉnh/TP</th>
     
    130131
    131132                                    <td class=" "><a href="<?php echo base_url(); ?>admin/thong_ke_cong_tac_vien/<?php echo $collaborator['id']; ?>"><?php echo $collaborator['cellphone']; ?></a></td>
     133                                                                        <td class=" "><?php echo $collaborator['full_name']; ?></td>
    132134                                    <td class=" "><?php echo $collaborator['district']; ?></td>
    133135                                    <td class=" "><?php echo $collaborator['province']; ?></td>
  • pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php

    r818 r838  
    109109                                                                <td style="font-weight:bold;"><?php echo $totalTbn; ?></td>
    110110                                                                <td style="font-weight:bold;"><?php echo $totalDtng; ?></td>
    111                                                                 <td style="font-weight:bold;"><?php echo $totalDtng; ?></td>
     111                                                                <td style="font-weight:bold;"><?php echo $totalDtth; ?></td>
    112112                                                                <td style="font-weight:bold;"><?php echo $totalDtn; ?></td>
    113113                                                               
  • pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php

    r707 r838  
    179179                return 0;
    180180        }
     181       
     182        public function test(){
     183                $provinces = lang('_PROVINCES_');
     184                $this->load->library("PHPExcel");
     185                $file = './assets/danhsachquanhuyen.xls';
     186                $objPHPExcel = PHPExcel_IOFactory::load($file);
     187                $cell_collection = $objPHPExcel->getActiveSheet()->getCellCollection();
     188                foreach ($cell_collection as $cell) {
     189                        $column = $objPHPExcel->getActiveSheet()->getCell($cell)->getColumn();
     190                        $row = $objPHPExcel->getActiveSheet()->getCell($cell)->getRow();
     191                        $data_value = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue();
     192                       
     193                        if ($row == 1) {
     194                                $header[$row][$column] = $data_value;
     195                        } else {
     196                                $arr_data[$row][$column] = $data_value;
     197                        }
     198                }
     199               
     200                $data['header'] = $header;
     201                $data['values'] = $arr_data;
     202               
     203                foreach ($data['values'] as $index => $value){
     204                        foreach ($provinces as $provinceId => $province){
     205                                if ($value['C'] == $province) $data['values'][$index]['C'] = $provinceId;
     206                                if ($value['B'] >= 10){
     207                                        $data['values'][$index]['B'] = "0".$value['B'];
     208                                }else{
     209                                        $data['values'][$index]['B'] = "00".$value['B'];
     210                                }
     211                        }
     212                       
     213                }
     214               
     215                $dt = array();
     216                foreach ($data['values'] as $index => $value){
     217                       
     218                        $dt[$index]['district_id'] = $value['B'];
     219                        $dt[$index]['province_id'] = $value['C'];
     220                        $dt[$index]['district_name'] = $value['D'];
     221                        $dt[$index]['type'] = $value['E'];
     222                }
     223                //var_dump($dt);
     224                //$this->load->model ( 'user_model' );
     225                //$result = $this->user_model->insertDistrict($dt);
     226                //var_dump($result);
     227        }
    181228}
    182229
  • pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php

    r818 r838  
    6262            $us_id = $user_info['us_id'];
    6363            $user = $this->user_model->get_user_by_id($us_id);
     64                        //$us = array();
     65                        $user['district'] = $this->user_model->getDistrictByIdAndProvince($user['district'], $user['province']);
     66                       
    6467            $result['can_buy'] = 1;
    6568            $result['can_edit'] = 0;
     
    140143        //$user = $this->user_model->get_user_by_id($us_id);
    141144                $user = $this->user_model->getUserById($us_id);
     145                //$user['district'] = $this->user_model->getDistrictByIdAndProvince($user['district'], $user['province']);
    142146        $package = $this->servicepackage_model->getPackage($input['p_id']);
    143147        $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
     
    150154        $user['p_id'] = $package['p_id'];
    151155                $user['province'] = $input['province'];
     156                $user['district'] = $input['district'];
    152157        $this->user_model->updateUser($us_id, $user);
    153158        $user['expire_date'] = date("d-m-Y", (strtotime($user['expire_date'])));
     
    172177
    173178        $user = $this->user_model->get_user_by_id($us_id);
     179                $user['district'] = $this->user_model->getDistrictByIdAndProvince($user['district'], $user['province']);
    174180        $package = $this->servicepackage_model->getPackage($p_id);
    175181
     
    207213            parse_str($user);
    208214            $us = $this->user_model->get_user_by_id($us_id);
     215                        $us['district'] = $this->user_model->getDistrictByIdAndProvince($us['district'], $province);
    209216            $data = array('us_id' => $us_id, 'username' => $username, 'fullname' => $fullname,
    210                 'gender' => $gender, 'email' => $email, 'phone' => $phone, 'school' => $school, 'province' => $province,
     217                'gender' => $gender, 'email' => $email, 'phone' => $phone, 'school' => $school, 'province' => $province, 'district' => $us['district'],
    211218                'acc_balanced' => $us['acc_balanced'], 'expire_date' => $us['expire_date'], 'date_diff' => $this->dateDiff($us['expire_date'])
    212219            );
     
    476483               
    477484        }
     485       
     486        function getDistrict(){
     487               
     488                $user_info = $this->session->userdata('userInfo');
     489                if ($user_info) {
     490                        $result = array();
     491                        $provinceId = $this->uri->segment(4);
     492                        $this->load->model ( 'user_model' );
     493                        if ($provinceId){
     494                                $results = $this->user_model->getDistrictByProvince($provinceId);
     495                        }
     496                        echo json_encode($results);
     497                }else{
     498                        show_404();
     499                }
     500               
     501        }
    478502
    479503}
  • pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php

    r818 r838  
    173173                ), 'user' );
    174174                $u = array('province'=>$user['province'],
     175                                'district' => $user['district'],
    175176                                'updated_time'=>date('Y-m-d H:i:s')
    176177                                );
     
    617618        }
    618619       
     620        public function getDistrictByProvince($provinceId){
     621                $sql = "SELECT * FROM tbldistrict WHERE province_id = ?";
     622                $query = $this->db->query ( $sql, array (
     623                                $provinceId
     624                ) );
     625                $results = $query->result_array();
     626                return $results;
     627        }
     628       
     629        public function insertDistrict($data){
     630                $this->db->insert_batch('tbldistrict', $data);
     631                return $this->db->affected_rows();
     632        }
     633       
     634        public function getDistrictByIdAndProvince($districtId, $provinceId){
     635                $sql = "SELECT * FROM tbldistrict WHERE district_id = ? AND province_id = ?";
     636                $query = $this->db->query ( $sql,array ($districtId, $provinceId) );
     637                if ($query->num_rows () > 0) {
     638                        $row = $query->row_array ();
     639                        return $row;
     640                }
     641        }
     642       
    619643}
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php

    r819 r838  
    9292                                                        </div>
    9393                                                </div>
     94                                                <div class="form-group">
     95                                                        <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
     96                                                        <div class="col-sm-8">
     97                                                                <select name="district" id="form-field-district" class="input-large"></select>
     98                                                        </div>
     99                                                </div>
    94100
    95101                        Lưu Ü:
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/package_register_modal.php

    r753 r838  
    4848                                                        <label for="form-field-province" class="col-sm-4 control-label no-padding-right">Tỉnh / Thành phố</label>
    4949                                                        <div class="col-sm-8">
    50                                                                 <select name="province" id="form-field-province" class="input-large">
     50                                                                <select name="province" id="form-field-province" class="form-field-province input-large">
    5151                                                                        <option></option>
    5252                                                                <?php foreach (lang('_PROVINCES_') as $key=>$pro):?>
     
    5656                                                        </div>
    5757                                                </div>
    58                                                 <!--div class="form-group">
    59                                                         <label for="form-field-district" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
    60 
     58                                                <div class="form-group">
     59                                                        <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
    6160                                                        <div class="col-sm-8">
    62                                                                 <input type="text" name="district" value="<?php echo $user['district']; ?>" placeholder="Quận / Huyện" id="form-field-district" class="input-large">
     61                                                                <select name="district" id="form-field-district" class="form-field-district input-large">
     62                       
     63                                                                </select>
    6364                                                        </div>
    64                                                 </div-->
     65                                                </div>
    6566
    6667<?php if ($can_edit == 1) { ?>
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/user_infor.php

    r773 r838  
    2222    </div>
    2323
    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">Quận / Huyện</label>
    27             <div class="col-sm-8">
    28                 <input type="text" name="district" value="<?php echo $user['district']; ?>" placeholder="Quận / Huyện" id="form-field-username" class="col-xs-12 col-sm-10">
    29             </div>
    30         </div>
    31     </div>
    32 
    3324    <div class="col-xs-12" style="margin: 5px;">
    3425        <div class="form-group">
    3526            <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Tỉnh / Thành phố</label>
    3627            <div class="col-sm-8">
    37                 <select name="province" id="form-field-province" class="col-xs-12 col-sm-10">
     28                <select name="province" id="form-field-province" class="form-field-province col-xs-12 col-sm-10">
    3829                    <?php foreach ($provinces as $key => $pro): ?>
    3930                        <option value="<?php echo $key; ?>" <?php if ($user['province'] == $key) echo "selected"; ?>><?php echo $pro; ?></option>
     
    4334        </div>
    4435    </div>
     36        <div class="col-xs-12" style="margin: 5px;">
     37                <div class="form-group">
     38                        <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
     39                        <div class="col-sm-8">
     40                                <select name="district" id="form-field-district" class="form-field-district col-xs-12 col-sm-10">
     41
     42                                </select>
     43                        </div>
     44                </div>
     45        </div>
    4546
    4647    <input type="hidden" name="us_id" value="<?php echo $user['us_id'] ?>">
     
    5657    ?>
    5758</form>
     59<script>
     60var district_id = "<?php echo $user['district']; ?>";
     61$(".form-field-province").change(function(){
     62        changeEventProvince();
     63});
     64if ($(".form-field-province").val() !== 'undefined'){
     65        checkSelecteDistrict();
     66}
     67</script>
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php

    r773 r838  
    9696
    9797                                                <div class="space-4"></div>
    98 
     98                                                                                               
    9999                                                <div class="form-group">
    100100                                                    <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Tỉnh / Thành phố</label>
    101101
    102102                                                    <div class="col-sm-8">
    103                                                         <!--input type="text" name="province" value="<?php echo @$province; ?>" placeholder="Tỉnh / Thành phố" id="form-field-province" class="col-xs-12 col-sm-10"-->
    104                                                                                                                 <select name="province" id="form-field-province" class="col-xs-12 col-sm-10">
     103                                                     
     104                                                                                                                <select name="province" id="form-field-province" class="form-field-province col-xs-12 col-sm-10">
    105105                                                                                                                        <option></option>
    106106                                                                                                                <?php foreach ($provinces as $key=>$pro):?>
     
    110110                                                    </div>
    111111                                                </div>
    112                                                                                                 <!--div class="form-group">
     112                                                                                                <div class="space-4"></div>
     113                                                                                                <div class="form-group">
    113114                                                    <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
    114 
    115                                                     <div class="col-sm-8">
    116                                                         <input type="text" name="district" value="<?php echo @$district; ?>" placeholder="Quận / Huyện" id="form-field-district" class="col-xs-12 col-sm-10">
    117                                                     </div>
    118                                                 </div-->
     115                                                                                                        <div class="col-sm-8">
     116                                                                                                                <select name="district" id="form-field-district" class="form-field-district col-xs-12 col-sm-10">
     117                                                                       
     118                                                                                                                </select>
     119                                                                                                        </div>
     120                                                </div>
     121                                                                                               
    119122                                               
    120123                                            </div>
     
    516519<script type="text/javascript">
    517520        var url="<?php echo base_url();?>";
     521        var district_id = "<?php echo $district; ?>";
    518522        var current_tab="<?php echo $current_tab;?>";
    519523        //var current_balanced = <?php echo $acc_balanced; ?>;
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/sync.php

    r822 r838  
    3939                                        foreach($lst as $item){
    4040                                                $item = (array)$item;
    41                                
     41                                                $phoneNumber = $this->Services_model->formatPhoneNumber((string)$item['phone'], 2);
    4242                                                $data = array(
    4343                                                                'address'=> (string)$item['address'],
     
    4747                                                                'id'=>(int)$item['id'],
    4848                                                                'full_name'=>(string)$item['name'],
    49                                                                 'cellphone'=>(string)$item['phone'],
     49                                                                'passwd' => md5($phoneNumber),
     50                                                                'cellphone'=>$phoneNumber,
    5051                                                                'precinct'=>(string)$item['precinct'],
    5152                                                                'province'=>(string)$item['province'],
  • pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php

    r822 r838  
    449449         */
    450450        public function formatPhoneNumber ($phoneNumber, $direction = 1) {
     451                $result = $phoneNumber;
    451452                $aryMatch = array();
    452453                if (preg_match('/^(84)([0-9]{9,10})$/', $phoneNumber, $aryMatch) == 1 && $direction == 1) {
     
    461462                else if (preg_match('/^(0)([0-9]{9,10})$/', $phoneNumber, $aryMatch) == 1 && $direction == -1) {
    462463                        $result = '84'. $aryMatch[2];
     464                }
     465                else if (preg_match('/^[1,9]([0-9]{8,9})$/', $phoneNumber, $aryMatch) == 1 && $direction = 2) {
     466                        $result = '0'. $phoneNumber;
    463467                }
    464468               
     
    473477                                                                                                                                                                                                district = "'.$data['district'].'",
    474478                                                                                                                                                                                                email = "'.$data['email'].'",
    475                                                                                                                                                                                                 full_name = "'.$data['full_name'].'",
     479                                                                                                                                                                                                full_name = "'.$data['full_name'].'",
     480                                                                                                                                                                                                passwd = "'.$data['passwd'].'",
    476481                                                                                                                                                                                                cellphone = "'.$data['cellphone'].'",
    477482                                                                                                                                                                                                precinct = "'.$data['precinct'].'",
  • pro-violet-viettel/sourcecode/assets/css/custom.css

    r707 r838  
    310310
    311311#form-field-province {padding-left: 0;}
     312#form-field-district {padding-left: 0;}
  • pro-violet-viettel/sourcecode/assets/js/admin/user.js

    r818 r838  
    6060                success: function(data)
    6161                {
    62                    
    6362                        results = jQuery.parseJSON(data);
    64 
    6563                        $("#content-trade-histoty").html(results.modal);
    66 
    6764                }
    6865        });     
     
    9996        });
    10097}
     98
     99function checkSelecteDistrict(){
     100        provinceId = $(".form-field-province").val();
     101        $.ajax({
     102        url: '/frontend/user/getDistrict/' + provinceId,
     103        type: 'POST',
     104        success: function (data, textStatus, jqXHR)
     105        {
     106            result = jQuery.parseJSON(data);   
     107                        content = "";
     108                        if (result != null){
     109                                for (var i in result){
     110                                        if (result[i].district_id === district_id){
     111                                                content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
     112                                        }else{
     113                                                content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " "  + result[i].district_name + '</option>';
     114                                        }
     115                                }
     116                                $(".form-field-district").html(content);
     117                        }
     118        }
     119    });
     120}
     121
     122function changeEventProvince(){
     123        $(".form-field-district").html("");
     124        provinceId = $("#form-field-province").val();
     125        $.ajax({
     126        url: '/frontend/user/getDistrict/' + provinceId,
     127        type: 'POST',
     128        success: function (data, textStatus, jqXHR)
     129        {
     130            result = jQuery.parseJSON(data);
     131                        content = "";
     132                        if (result != null){
     133                                for (var i in result){                 
     134                                        content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " "  + result[i].district_name + '</option>'
     135                                }
     136                                $(".form-field-district").html(content);
     137                        }
     138        }
     139    });
     140}
  • pro-violet-viettel/sourcecode/assets/js/frontend/lecture.js

    r765 r838  
    193193        });
    194194
    195 })
     195});
     196
     197if ($("#form-field-province").val() !== 'undefined'){
     198        provinceId = $("#form-field-province").val();
     199        $.ajax({
     200        url: 'user/getDistrict/' + provinceId,
     201        type: 'POST',
     202        success: function (data, textStatus, jqXHR)
     203        {
     204            result = jQuery.parseJSON(data);
     205                        content = "";
     206                        if (result != null){
     207                                for (var i in result){                 
     208                                        content = content + '<option value="' + result[i].district_id + '">' + result[i].district_name + '</option>'
     209                                }
     210                                $("#form-field-district").html(content);
     211                        }
     212        }
     213    });
     214}
     215
     216$("#form-field-province").change(function(){
     217        provinceId = this.value;
     218        $.ajax({
     219        url: 'user/getDistrict/' + provinceId,
     220        type: 'POST',
     221        success: function (data, textStatus, jqXHR)
     222        {
     223            result = jQuery.parseJSON(data);
     224                        content = "";
     225                        if (result != null){
     226                                for (var i in result){                 
     227                                        content = content + '<option value="' + result[i].district_id + '">' + result[i].district_name + '</option>'
     228                                }
     229                                $("#form-field-district").html(content);
     230                        }
     231        }
     232    });
     233});
  • pro-violet-viettel/sourcecode/assets/js/frontend/user.js

    r820 r838  
    11function updateInfo(us_id) {
    22    $.ajax({
    3         url: 'update_user/' + us_id,
     3        url: '/frontend/user/update_user/' + us_id,
    44        type: 'POST',
    55        data: $("#frm1").serialize(),
     
    4242                $("#account-info-tab").click();
    4343            });
     44                       
     45                       
     46                        if ($(".form-field-province").val() !== 'undefined'){
     47                                checkSelecteDistrict();
     48                        }
     49                        $(".form-field-province").change(function(){
     50                                changeEventProvince();
     51                        });
     52                       
     53                       
     54                       
    4455            $("#finish_package_register").click(function () {
    4556                finish_package_register();
     
    274285        return x1 + x2;
    275286}
     287
     288function checkSelecteDistrict(){
     289        provinceId = $(".form-field-province").val();
     290        $.ajax({
     291        url: '/frontend/user/getDistrict/' + provinceId,
     292        type: 'POST',
     293        success: function (data, textStatus, jqXHR)
     294        {
     295            result = jQuery.parseJSON(data);   
     296                        content = "";
     297                        if (result != null){
     298                                for (var i in result){
     299                                        if (result[i].district_id === district_id){
     300                                                content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
     301                                        }else{
     302                                                content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " "  + result[i].district_name + '</option>';
     303                                        }
     304                                }
     305                                $(".form-field-district").html(content);
     306                        }
     307        }
     308    });
     309}
     310
     311if ($(".form-field-province").val() !== 'undefined'){
     312        checkSelecteDistrict();
     313}
     314
     315function changeEventProvince(){
     316        $(".form-field-district").html("");
     317        provinceId = $("#form-field-province").val();
     318        $.ajax({
     319        url: '/frontend/user/getDistrict/' + provinceId,
     320        type: 'POST',
     321        success: function (data, textStatus, jqXHR)
     322        {
     323            result = jQuery.parseJSON(data);
     324                        content = "";
     325                        if (result != null){
     326                                for (var i in result){                 
     327                                        content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " "  + result[i].district_name + '</option>'
     328                                }
     329                                $(".form-field-district").html(content);
     330                        }
     331        }
     332    });
     333}
     334
     335$(".form-field-province").change(function(){
     336        changeEventProvince();
     337});
Note: See TracChangeset for help on using the changeset viewer.