I am developing the online shop and , I have the following code allow user to manage their shipping addresses.
<section class="my-account-section">
    <div class="main-content">
        <div class="row">
            
            <div class="col-md-4">
                <?php $this->load->view('front-end/' . THEME . '/pages/my-account-sidebar') ?>
            </div>
            
            <div class="col-md-8 col-12" style="padding-right: 15px;padding-left: 15px;">
                <div class=' border-0'>
                    <form action="<?= base_url('my-account/add-address') ?>" method="POST" id="add-address-form" class="mt-4" style="padding:0rem 1.5rem 0.5rem 1.5rem !important;">
                        <div class="row">
                            <div class="col-md-12 col-sm-12 col-xs-12 form-group">
                                <label for="name" class="control-label">姓名</label>
                                <input type="text" class="form-control" id="address_name" name="name" placeholder="姓名" required/>
                            </div>
                            <div class="col-md-6 col-sm-12 col-xs-12 form-group">
                                <label for="mobile_number" class="control-label">主要聯絡號碼</label>
                                <input type="text" pattern="\d*" maxlength="16" class="form-control" id="mobile_number" name="mobile" placeholder="主要手機號碼" required />
                            </div>
                            <div class="col-md-6 col-sm-12 col-xs-12 form-group">
                                <label for="alternate_mobile" class="control-label">備用聯絡號碼</label>
                                <input type="text" class="form-control" pattern="\d*" maxlength="16" id="alternate_mobile" name="alternate_mobile" placeholder="如無可留空" />
                            </div>
                            <div class="col-md-12 col-sm-12 col-xs-12 form-group">
                                <label for="address" class="control-label">地址</label>
                                <textarea name="address" class="form-control" id="address" cols="30" rows="4" placeholder="請提供完整地址"></textarea>
                            </div>
                            
                            <div class="col-md-12 col-sm-12 col-xs-12 text-center">
                                <input type="submit" class="btn btn-primary" id="save-address-submit-btn" value="新增" />
                            </div>
                            <div class="col-md-12 col-sm-12 col-xs-12 text-center">
                                <div id="save-address-result"></div>
                            </div>
                        </div>
                    </form>
                    <div class="card-body">
                        <table id="address_list_table" class='table-striped' data-toggle="table" data-url="<?= base_url('my-account/get-address-list') ?>" data-click-to-select="true" data-side-pagination="server" data-pagination="false" data-page-list="[5, 10, 20, 50, 100, 200]" data-search="false" data-show-columns="false" data-show-refresh="false" data-trim-on-search="false" data-sort-name="id" data-sort-order="desc" data-mobile-responsive="true" data-toolbar="" data-show-export="true" data-maintain-selected="true" data-export-types='["txt","excel"]' data-query-params="queryParams" style="font-size: 15px;">
                            <thead>
                                <tr>
                                    <th data-field="id" data-sortable="true" data-visible="false"><?= !empty($this->lang->line('id')) ? $this->lang->line('id') : 'ID' ?></th>
                                    <th data-field="Address_Combined" data-sortable="true" data-events="editAddress">地址資料</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
            <!--end col-->
        </div>
        <!--end row-->
    </div>
    <!--end container-->
</section>

The stored addresses will get from my-account/get-address-list and calling the following function to get the data:
public function get_address_list($user_id = '')
    {
        $offset = 0;
        $limit = 10;
        $sort = 'id';
        $order = 'ASC';
        $multipleWhere = '';

        if (isset($_GET['user_id']) && !empty($_GET['user_id'])) {
            $where['user_id'] = $_GET['user_id'];
        }

        if (!empty($user_id)) {
            $where['user_id'] = $user_id;
        }

        if (isset($_GET['offset']))
            $offset = $_GET['offset'];
        if (isset($_GET['limit']))
            $limit = $_GET['limit'];

        if (isset($_GET['sort']))
            if ($_GET['sort'] == 'id') {
                $sort = "id";
            } else {
                $sort = $_GET['sort'];
            }
        if (isset($_GET['order']))
            $order = $_GET['order'];

        if (isset($_GET['search']) and $_GET['search'] != '') {
            $search = $_GET['search'];
            $multipleWhere = ['addr.name' => $search, 'addr.address' => $search, 'mobile' => $search, 'area' => $search, 'city' => $search, 'state' => $search, 'country' => $search, 'pincode' => $search];
        }

        $count_res = $this->db->select(' COUNT(addr.id) as `total` ,addr.*');

        if (isset($multipleWhere) && !empty($multipleWhere)) {
            $count_res->group_start();
            $count_res->or_like($multipleWhere);
            $count_res->group_end();
        }
        if (isset($where) && !empty($where)) {
            $count_res->where($where);
        }

        $address_count = $count_res->get('addresses addr')->result_array();

        foreach ($address_count as $row) {
            $total = $row['total'];
        }

        $search_res = $this->db->select('addr.*');

        if (isset($multipleWhere) && !empty($multipleWhere)) {
            $count_res->group_start();
            $search_res->or_like($multipleWhere);
            $count_res->group_end();
        }
        if (isset($where) && !empty($where)) {
            $search_res->where($where);
        }

        $address_search_res = $search_res->order_by($sort, $order)->limit($limit, $offset)->get('addresses addr')->result_array();
        $bulkData = array();
        $bulkData['total'] = $total;
        $rows = array();
        $tempRow = array();
        foreach ($address_search_res as $row) {

            $row = output_escaping($row);
            $default = $row['is_default'] == 1 ? 'Default' : 'Set as default';
            $btn = $row['is_default'] == 1 ? 'info' : 'secondary';
            $class = $row['is_default'] == 1 ? '' : 'default-address ';
            //$operate = '<a href="javascript:void(0)" style="text-decoration: underline dodgerblue !important;color: dodgerblue;" class="edit-address mb-1" title="Edit" data-id="' . $row['id'] . '" data-toggle="modal" data-target="#add-address-modal">修改</a> | ';
            $operate = '<a href="javascript:void(0)" style="text-decoration: underline dodgerblue !important;color: dodgerblue;" class="delete-address mb-1" title="Delete" data-id="' . $row['id'] . '">刪除</a> | ';
            $tempRow['id'] = $row['id'];
            $tempRow['name'] = $row['name'];
            $tempRow['type'] = $row['type'];
            $tempRow['mobile'] = (defined('ALLOW_MODIFICATION') && ALLOW_MODIFICATION == 0) ? str_repeat("X", strlen($row['mobile']) - 3) . substr($row['mobile'], -3) : $row['mobile'];
            $tempRow['alternate_mobile'] = $row['alternate_mobile'];
            $tempRow['address'] = $row['address'];
            $tempRow['landmark'] = $row['landmark'];
            $tempRow['area'] = $row['area'];
            $tempRow['area_id'] = $row['area_id'];
            $tempRow['city'] = $row['city'];
            $tempRow['city_id'] = $row['city_id'];
            $tempRow['state'] = $row['state'];
            $tempRow['pincode'] = $row['pincode'];
            $tempRow['system_pincode'] = $row['system_pincode'];
            $tempRow['pincode_name'] = $row['pincode'];
            $tempRow['country'] = $row['country'];
            $tempRow['action'] = $operate;
            $tempRow['choose_address'] = '<a onclick="chooseAddress(' . $row['id'] . ')" id="checkout-choose-address-' . $row['id'] . '" href="javascript:void(0)" style="text-decoration: underline dodgerblue !important;color: dodgerblue;" class="checkout-choose-address choose-address mb-1" data-id="' . $row['id'] . '">選擇為收貨地址</a> | ';
            $default_address = $row['is_default'] == 1 
            ? '<a style="cursor: default !important;color: #000;">預設地址</a>' 
            : '<a href="javascript:void(0)" style="text-decoration: underline dodgerblue !important;color: dodgerblue;" class="default-address" mb-1" title="' . $default . '" data-id="' . $row['id'] . '">設為預設</a>';
            $choose_address = $row['is_default'] == 1 
            ? '<a style="cursor: default !important;color: #000;">目前已選擇的地址</a>' 
            : '<a href="javascript:void(0)" style="text-decoration: underline dodgerblue !important;color: dodgerblue;" class="default-address" mb-1" title="' . $default . '" data-id="' . $row['id'] . '">選擇地址</a>';
            $tempRow['action'] = '<div style="float: right;">' . $operate . $default_address . '</div>';
            $tempRow['action_checkout'] = '<div style="float: right;">' . $operate . $choose_address . '</div>';
            $tempRow['Address_Combined'] = '<div>' . '<div style="">' . '姓名: ' . '<span id="edit-address-name-' . $row['id'] . '">' . $row['name'] . '</span>' . '<br>聯絡電話: ' . '<span id="edit-address-mobile-' . $row['id'] . '">' . $row['mobile'] . '</span>' . '<br>地址: ' . '<span id="edit-address-address-' . $row['id'] . '">' . str_replace("\r\n", "<br>", $row['address']) . '</span>' . '<br>類型: ' . '<span id="edit-address-type-' . $row['id'] . '">' . $row['type'] . '</span>' . '</div>' . $tempRow['action'] . '</div>';
            
            $tempRow['Address_Combined_Checkout'] = '<div>' . '<div style="">' . '姓名: ' . '<span id="edit-address-name-' . $row['id'] . '">' . $row['name'] . '</span>' . '<br>聯絡電話: ' . '<span id="edit-address-mobile-' . $row['id'] . '">' . $row['mobile'] . '</span>' . '<br>地址: ' . '<span id="edit-address-address-' . $row['id'] . '">' . str_replace("\r\n", "<br>", $row['address']) . '</span>' . '<br>類型: ' . '<span id="edit-address-type-' . $row['id'] . '">' . $row['type'] . '</span>' . '</div>' . $tempRow['action_checkout'] . '</div>';
            
            $rows[] = $tempRow;
        }
        $bulkData['rows'] = $rows;
        print_r(json_encode($bulkData));
    }

Related Controller functions:
public function add_address()
    {
        if ($this->ion_auth->logged_in()) {
            $this->form_validation->set_rules('type', 'Type', 'trim|xss_clean');
            //$this->form_validation->set_rules('country_code', 'Country Code', 'trim|xss_clean');
            $this->form_validation->set_rules('name', 'Name', 'trim|xss_clean|required');
            $this->form_validation->set_rules('mobile', 'Mobile', 'trim|numeric|xss_clean|required');
            $this->form_validation->set_rules('alternate_mobile', 'Alternative Mobile', 'trim|numeric|xss_clean');
            $this->form_validation->set_rules('address', 'Address', 'trim|xss_clean|required');
            //$this->form_validation->set_rules('landmark', 'Landmark', 'trim|xss_clean');
            /*
            $this->form_validation->set_rules('city_name', 'City', 'trim|xss_clean');
            $this->form_validation->set_rules('area_name', 'Area', 'trim|xss_clean');
            $this->form_validation->set_rules('area_id', 'Area', 'trim|xss_clean');
            $this->form_validation->set_rules('city_id', 'City', 'trim|xss_clean');
            $this->form_validation->set_rules('pincode', 'Pincode', 'trim|numeric|xss_clean');
            $this->form_validation->set_rules('state', 'State', 'trim|xss_clean|required');
            $this->form_validation->set_rules('country', 'Country', 'trim|xss_clean|required');
            $this->form_validation->set_rules('latitude', 'Latitude', 'trim|xss_clean');
            $this->form_validation->set_rules('longitude', 'Longitude', 'trim|xss_clean');
            */


            if (!$this->form_validation->run()) {
                $this->response['error'] = true;
                $this->response['message'] = validation_errors();
                $this->response['data'] = array();
                print_r(json_encode($this->response));
                return false;
            }

            $arr = $this->input->post(null, true);
            $arr['user_id'] = $this->data['user']->id;
            $this->address_model->set_address($arr);
            $res = $this->address_model->get_address($this->data['user']->id, false, true);
            $this->response['error'] = false;
            $this->response['message'] = 'Address Added Successfully';
            $this->response['data'] = $res;
            print_r(json_encode($this->response));
            return false;
        } else {
            $this->response['error'] = true;
            $this->response['message'] = 'Unauthorized access is not allowed';
            print_r(json_encode($this->response));
            return false;
        }
    }

    public function edit_address()
    {
        if ($this->ion_auth->logged_in()) {
            $this->form_validation->set_rules('id', 'Id', 'trim|required|numeric|xss_clean');
            $this->form_validation->set_rules('type', 'Type', 'trim|xss_clean');
            //$this->form_validation->set_rules('country_code', 'Country Code', 'trim|xss_clean');
            $this->form_validation->set_rules('name', 'Name', 'required|trim|xss_clean');
            $this->form_validation->set_rules('mobile', 'Mobile', 'required|trim|numeric|xss_clean');
            $this->form_validation->set_rules('alternate_mobile', 'Alternative Mobile', 'trim|numeric|xss_clean');
            $this->form_validation->set_rules('address', 'Address', 'trim|xss_clean');
            /*
            $this->form_validation->set_rules('landmark', 'Landmark', 'trim|xss_clean');
            $this->form_validation->set_rules('area_id', 'Area', 'trim|xss_clean');
            $this->form_validation->set_rules('city_id', 'City', 'trim|xss_clean');
            $this->form_validation->set_rules('pincode', 'Pincode', 'trim|numeric|xss_clean');
            $this->form_validation->set_rules('state', 'State', 'required|trim|xss_clean');
            $this->form_validation->set_rules('country', 'Country', 'required|trim|xss_clean');
            */
            if (!$this->form_validation->run()) {
                $this->response['error'] = true;
                $this->response['message'] = validation_errors();
                $this->response['data'] = array();
                print_r(json_encode($this->response));
                return false;
            }
            // print_R($_POST);
            $this->address_model->set_address($_POST);
            $res = $this->address_model->get_address(null, $_POST['id'], true);
            $this->response['error'] = false;
            $this->response['message'] = 'Address updated Successfully';
            $this->response['data'] = $res;
            print_r(json_encode($this->response));
            return false;
        } else {
            $this->response['error'] = true;
            $this->response['message'] = 'Unauthorized access is not allowed';
            print_r(json_encode($this->response));
            return false;
        }
    }

    //delete_address
    public function delete_address()
    {
        if ($this->ion_auth->logged_in()) {
            $this->form_validation->set_rules('id', 'Id', 'trim|required|numeric|xss_clean');
            if (!$this->form_validation->run()) {
                $this->response['error'] = true;
                $this->response['message'] = validation_errors();
                $this->response['data'] = array();
                print_r(json_encode($this->response));
                return false;
            }
            $this->address_model->delete_address($_POST);
            $this->response['error'] = false;
            $this->response['message'] = 'Address Deleted Successfully';
            $this->response['data'] = array();
            print_r(json_encode($this->response));
            return false;
        } else {
            $this->response['error'] = true;
            $this->response['message'] = 'Unauthorized access is not allowed';
            print_r(json_encode($this->response));
            return false;
        }
    }

    //set default_address
    public function set_default_address()
    {
        if ($this->ion_auth->logged_in()) {
            $this->form_validation->set_rules('id', 'Id', 'trim|required|numeric|xss_clean');
            if (!$this->form_validation->run()) {
                $this->response['error'] = true;
                $this->response['message'] = validation_errors();
                $this->response['data'] = array();
                print_r(json_encode($this->response));
                return false;
            }
            $_POST['is_default'] = true;
            $this->address_model->set_address($_POST);
            $this->response['data_id'] = $_POST['id'];
            $this->response['error'] = false;
            $this->response['message'] = 'Set as default successfully';
            $this->response['data'] = array();
            print_r(json_encode($this->response));
            return false;
        } else {
            $this->response['error'] = true;
            $this->response['message'] = 'Unauthorized access is not allowed';
            print_r(json_encode($this->response));
            return false;
        }
    }

Related Model function:
function set_address($data)
    {

        $data = escape_array($data);
       
        $address_data = [];
       
        if (isset($data['user_id'])) {
            $address_data['user_id'] = $data['user_id'];
        }
        if (isset($data['id'])) {
            $address_data['id'] = $data['id'];
        }
        if (isset($data['type'])) {
            $address_data['type'] = $data['type'];
        }
        if (isset($data['name'])) {
            $address_data['name'] = $data['name'];
        }
        if (isset($data['mobile'])) {
            $address_data['mobile'] = $data['mobile'];
        }
        $address_data['country_code'] = (isset($data['country_code']) && !empty($data['country_code']) && is_numeric($data['country_code'])) ? $data['country_code'] : 0;

        if (isset($data['alternate_mobile'])) {
            $address_data['alternate_mobile'] = $data['alternate_mobile'];
        }

        if (isset($data['address'])) {
            $address_data['address'] = str_replace("\\r\\n", "\r\n", $data['address']);
        }

        if (isset($data['landmark'])) {
            $address_data['landmark'] = $data['landmark'];
        }
        $city = fetch_details('cities', ['id' => $data['city_id']], 'name');
        $area = fetch_details('areas', ['id' => $data['area_id']], 'name');

        if (isset($data['general_area_name'])) {
            // $address_data['general_area_name'] = isset($data['general_area_name']) && !empty($data['general_area_name']) ? $data['general_area_name'] : '';
            $address_data['area'] = isset($data['general_area_name']) && !empty($data['general_area_name']) ? $data['general_area_name'] : '';
        }
        if (isset($data['edit_general_area_name'])) {
            // $address_data['general_area_name'] = isset($data['general_area_name']) && !empty($data['general_area_name']) ? $data['general_area_name'] : '';
            $address_data['area'] = isset($data['edit_general_area_name']) && !empty($data['edit_general_area_name']) ? $data['edit_general_area_name'] : '';
        }
        // if (isset($data['area_id'])) {
        //     $address_data['area_id'] = isset($data['area_id']) && !empty($data['area_id']) ? $data['area_id'] : 0;
        //     $address_data['area'] = isset($area) && !empty($area) ?$area[0]['name'] : '';
        // }
        if (isset($data['city_id'])) {
            $address_data['city_id'] = (isset($data['city_id']) & !empty($data['city_id'])) ? $data['city_id'] : 0;
            $address_data['city'] = isset($city) && !empty($city) ? $city[0]['name'] : '';
        }
        if (isset($data['city_name'])) {
            $address_data['city'] = (isset($data['city_name']) & !empty($data['city_name'])) ? $data['city_name'] : $city[0]['name'];
        }
        if (isset($data['area_name']) && !empty($data['area_name'])) {
            $address_data['area'] = (isset($data['area_name']) & !empty($data['area_name'])) ? $data['area_name'] : $area[0]['name'];
        }
        if (isset($data['other_city']) && !empty($data['other_city'])) {
            $address_data['city'] = (isset($data['other_city']) && !empty($data['other_city'])) ? $data['other_city'] : $city[0]['name'];
        }
        if (isset($data['other_areas']) && !empty($data['other_areas'])) {
            $address_data['area'] = (isset($data['other_areas']) && !empty($data['other_areas'])) ? $data['other_areas'] : $area[0]['name'];
        }
        if (isset($data['pincode_name']) || isset($data['pincode'])) {
            $address_data['system_pincode'] = (isset($data['pincode_name']) && !empty($data['pincode_name'])) ? 0 : 1 ;
            $address_data['pincode'] = (isset($data['pincode_name']) && !empty($data['pincode_name'])) ? $data['pincode_name'] : $data['pincode'];
        }
        

        // if (isset($data['pincode'])) {
        //     $address_data['pincode'] = $data['pincode'];
        // }

        if (isset($data['state'])) {
            $address_data['state'] = $data['state'];
        }

        if (isset($data['country'])) {
            $address_data['country'] = $data['country'];
        }
        if (isset($data['latitude'])) {
            $address_data['latitude'] = $data['latitude'];
        }
        if (isset($data['longitude'])) {
            $address_data['longitude'] = $data['longitude'];
        }

        if (isset($data['id']) && !empty($data['id'])) {
            if (isset($data['is_default']) && $data['is_default'] == true) {
                $address = fetch_details('addresses', ['id' => $data['id']], '*');
                $this->db->where('user_id', $address[0]['user_id'])->set(['is_default' => '0'])->update('addresses');
                $this->db->where('id', $data['id'])->set(['is_default' => '1'])->update('addresses');
            }

            $this->db->set($address_data)->where('id', $data['id'])->update('addresses');
        } else {
            $this->db->insert('addresses', escape_array($address_data));
            $last_added_id = $this->db->insert_id();
            if (isset($data['is_default']) && $data['is_default'] == true) {
                $this->db->where('user_id', $data['user_id'])->set('is_default', '0')->update('addresses');
                $this->db->where('id', $last_added_id)->set('is_default', '1')->update('addresses');
            }
        }
    }

    function delete_address($data)
    {
        $this->db->delete('addresses', ['id' => $data['id']]);
    }

now I want to remake the design by using the popup modal that can call/open in anywhere to allow the user to manage their address instead of the page
here are the requirements:
1. user can view all stored address with details such as address, tel no., name etc.
2. user can edit stored address or set to the default address
3. user can add the new address
4. user can remove added address, with the confirm alert
5. if in the "checkout" page, a button "選擇為收貨地址" will be appear and allow the user update the shipping address for once time checkout (only for the current checkout, will not set to default)