<?php
$base_url = base_url();
$this->load->view('layout/frontend/header', array('base_url' => $base_url, '$username' => @$username));
$this->load->view('layout/frontend/sidebar', array('base_url' => $base_url));
?>
<div class="main-content">

    <div class="page-content">
        <div class="page-header">
            <h1>
                Thông tin cá nhân
                <small>
                    <i class="icon-double-angle-right"></i>
                    <?php echo @$username; ?>
                </small>
            </h1>
        </div><!-- /.page-header -->

        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="user-profile row" id="user-profile-3">
                    <div class="col-sm-offset-1 col-sm-10">

                        <div class="tabbable">
                            <ul class="nav nav-tabs padding-16">
                                <li class="active" >
                                    <a id="edit-basic-tab" href="#edit-basic" data-toggle="tab">
                                        <i class="green icon-edit bigger-125"></i>
                                        Thông tin cá nhân
                                    </a>
                                </li>

                                <li >
                                    <a id="edit-password-tab" href="#edit-password" data-toggle="tab">
                                        <i class="blue icon-key bigger-125"></i>
                                        Đổi mật khẩu
                                    </a>
                                </li>

                                <li >
                                    <a id="account-info-tab" href="#account-info" data-toggle="tab">
                                        <img src="<?php echo $base_url; ?>assets/img/payment.png" width="16" class="img-responsive pull-left">
                                        Thông tin tài khoản
                                    </a>
                                </li>
                                <li >
                                    <a id="services-register-tab" href="#services-register" data-toggle="tab">
                                        <i class="blue icon-cog bigger-125"></i>
                                        Đăng ký dịch vụ
                                    </a>
                                </li>
                            </ul>

                            <div class="tab-content profile-edit-tab-content">
                                <div class="tab-pane in active" id="edit-basic">
                                    <form id="frm1" role="form" class="form-horizontal">
                                        <h4 class="header blue bolder smaller">Thông tin cá nhân</h4>

                                        <div class="row">

                                            <div class="vspace-xs"></div>

                                            <div class="col-sm-9">
                                                <div class="form-group">
                                                    <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Số điện thoại</label>

                                                    <div class="col-sm-8">
                                                        <input type="text" name="username" value="<?php echo @$username; ?>" placeholder="Số điện thoại" id="form-field-username" class="col-xs-12 col-sm-10" disabled>
                                                    </div>
                                                </div>

                                                <div class="space-4"></div>
							
                                                <div class="form-group">
                                                    <label for="form-field-first" class="col-sm-4 control-label no-padding-right">Họ và tên</label>
													<label class="block clearfix has-error">
														
														<div class="col-sm-8">
															<input type="text" name="fullname" value="<?php echo @$fullname; ?>" placeholder="Họ và tên" id="form-field-first" class="col-xs-12 col-sm-10" <?php if ($can_edit == 0) echo 'disabled'; ?>>

														</div>
														<small><div class="col-sm-8 help-block" id="fullname_err"> </div></small>
													</label>
                                                </div>

                                                <div class="space-4"></div>

                                                <div class="form-group">
                                                    <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Đơn vị</label>

                                                    <div class="col-sm-8">
                                                        <input type="text" name="school" value="<?php echo @$school; ?>" placeholder="Đơn vị" id="form-field-username" class="col-xs-12 col-sm-10">
                                                    </div>
                                                </div>

                                                <div class="space-4"></div>

                                                <div class="form-group">
                                                    <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Tỉnh / Thành phố</label>

                                                    <div class="col-sm-8">
                                                        <!--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"-->
														<select name="province" id="form-field-province" class="col-xs-12 col-sm-10">
															<option></option>
														<?php foreach ($provinces as $key=>$pro):?>
															<option value="<?php echo $key;?>" <?php if($province==$key) echo "selected"; ?>><?php echo $pro; ?></option>
														<?php endforeach;?>
														</select>
                                                    </div>
                                                </div>
												<!--div class="form-group">
                                                    <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>

                                                    <div class="col-sm-8">
                                                        <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">
                                                    </div>
                                                </div-->
						
                                            </div>
											<div class="col-sm-3">
											<!--<h4><small><a href="#" data-toggle="modal" data-target="#changeProfile"><i>Đổi số điện thoại</i></a></small></h4>-->
											</div>
                                        </div>
                                        <div class="space-4"></div>

                                        <div class="clearfix form-actions">
                                            <div class="col-md-offset-3 col-md-9">
                                                <button type="button" onclick="return updateInfo(<?php echo @$us_id; ?>);" class="btn btn-info">
                                                    <i class="icon-ok bigger-110"></i>
                                                    Cập nhật
                                                </button>
												
                                            </div>
											<div class="col-md-offset-3 col-md-9"><label id="updating" style="display: none;"><span class="icon-refresh icon-refresh-animate"></span> Đang xử lý...</label>
											</div>
                                        </div> 
                                    </form>
                                </div>


                                <div class="tab-pane" id="edit-password">
									<form id="frm2" class="form-horizontal" role="form">
										<h4 class="header blue bolder smaller">Đổi mật khẩu</h4>
										<div class="form-group">
											<label for="form-field-passwd" class="col-sm-3 control-label no-padding-right">Mật khẩu cũ</label>
											<div class="col-sm-9">
												<label class="block clearfix has-error">
													<span class="input-icon">
														<input type="password" name="passwd" id="form-field-pass1">
														<i class="icon-lock blue"></i>
													</span>

													<small><div class="help-block" id="passwd_old_err"> </div></small>
												</label>
												
											</div>
										</div>
										
										<div class="form-group">
											<label for="form-field-pass1" class="col-sm-3 control-label no-padding-right">Mật khẩu mới</label>

											<div class="col-sm-9">
												<label class="block clearfix has-error">
													<span class="input-icon">
														<input type="password" name="passwd_new" id="form-field-pass1">
														<i class="icon-lock blue"></i>
													</span>
													<small><div class="help-block" id="passwd_new_err"> </div></small>
												</label>
											</div>
										</div>

										<div class="space-4"></div>

										<div class="form-group">
											<label for="form-field-pass2" class="col-sm-3 control-label no-padding-right">Gõ lại mật khẩu mới</label>
											<div class="col-sm-9">
												<label class="block clearfix has-error">
													<span class="input-icon">
														<input type="password" name="confirm_passwd_new" id="form-field-pass2">
													</span>
													<small><div class="help-block" id="confirm_passwd_new_err"> </div></small>
												</label>
											</div>
										</div>
										<div class="clearfix form-actions">
											<div class="col-md-offset-3 col-md-9">
												<button type="button" onclick="return changePassword(<?php echo @$us_id; ?>);"  class="btn btn-info">
													<i class="icon-ok bigger-110"></i>
													Thay đổi
												</button>
											</div>
										</div>
										
										</form>
				
										<!--div class="alert alert-block alert-success">
											
											<p>
												Quý vị cũng có thể thay đổi mật khẩu bằng cách dùng số điện thoại <strong><?php echo $username; ?></strong> và soạn tin theo cú pháp: <strong>SBG MK [MatKhauMoi]</strong> gửi tới <strong>8062</strong> (500đ/tin). 
											<p/>
										</div-->
                                </div>

                                <div class="tab-pane" id="account-info">
                                    <form id="frm3" class="form-horizontal" role="form">
                                        <h4 class="header blue bolder smaller">Thông tin tài khoản</h4>
										<div class="col-sm-12">
											<h4>Số tiền trong tài khoản SBG Online: <b><span class="blue" id="topup-money"><?php echo number_format(@$acc_balanced, 0); ?> VNĐ <span></b></h4>

                                        </div>									
                                        <h4 class="header blue bolder smaller">Nạp tiền bằng thẻ cào</h4>
                                        <div class="col-sm-8">
                                            <div class="form-group">
                                                <label for="form-field-pass1" class="col-sm-2 control-label no-padding-right">Mã thẻ</label>

                                                <div class="col-sm-10">
                                                    <input type="text" id="pin_card" name="pin_card" class="form-control">
                                                </div>
                                            </div>

                                            <div class="space-4"></div>

                                            <div class="form-group">
                                                <label for="form-field-pass2" class="col-sm-2 control-label no-padding-right">Serial</label>

                                                <div class="col-sm-10">
                                                    <input type="text" id="card_serial" name="card_serial" class="form-control">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-4">
                                            <button type="button" id="btn-charge" onclick="return chargeCard(<?php echo @$us_id; ?>);" class="btn btn-success">
                                                <i class="icon-ok bigger-110"></i>
                                                Tiếp tục
                                            </button>
											<div class="space-4"></div>
											<label id="charging" style="display: none;"><span class="icon-refresh icon-refresh-animate"></span> Xin chờ...</label>
                                            <div class="space-4"></div>
                                            <a onclick="tradeHistory(<?php echo $us_id; ?>, 1);" data-toggle="modal"><i class="icon-archive"></i> Lịch sử giao dịch</a>
                                        </div>
                                        <div class="clearfix">

                                        </div>
                                        <h4 class="header blue bolder smaller">Nạp tiền bằng tài khoản gốc</h4>
                                        <div class="alert alert-block alert-success">						
                                            <p>
                                                <span <?php if(($is_viettel==1)) /*echo 'style="display: none;"'*/{?> >Sử dụng thuê bao <strong><?php echo @$username; ?></strong> soạn tin nhắn: <strong>SBG NAP [SoTien] gửi 8062</strong>.<?php } ?> </span><br/>
                                                Nếu Quý vị sử dụng thuê bao Viettel khác thì soạn tin nhắn: <strong>SBG NAP [SoTien] <?php  echo $username; ?> gửi tới 8062</strong>.
          
                                            </p>
                                        </div>
                                    </form>
                                </div>
                                <div class="tab-pane" id="services-register">
                                    <!--<form action="<?php echo base_url();?>frontend/user/packageRegister"  class="form-horizontal" id="package_register"> -->
                                    <form action="<?php echo base_url();?>frontend/user/packageRegister" method="POST" class="form-horizontal" id="package_register">
                                        <h4 class="header blue bolder smaller">Thông tin dịch vụ &nbsp;&nbsp;&nbsp;<a onclick="regisHistory(<?php echo $us_id; ?>, 1);" data-toggle="modal"><i class="icon-archive"></i> Lịch sử đăng ký dịch vụ</a></h4>
										<div class="col-sm-6">
                                            <h4><b>Thời hạn sử dụng</b></h4> <h3><b><span class="blue"><?php echo isset($expire_date) && strtotime($expire_date)>0 ? date('d/m/Y', strtotime($expire_date)) : '';?> </span></b></h3>
                                        </div> 
										<div class="col-sm-6">
                                            <h4>Số tiền trong tài khoản SBG Online</h4><h3> <span id="vip-regis-money"> <?php echo number_format(@$acc_balanced, 0); ?></span> VNĐ <span id="add_money" style="cursor:pointer" class="badge" >Nạp thêm tiền</span></h3>
                                        </div>

                                        <h4 class="header blue bolder smaller">Đăng ký / Gia hạn dịch vụ</h4>

                                        <h5>Mời Quý vị chọn các gói dịch vụ sau:</h5>
                                        <div class="errors" id="package_register">
                                            
                                        </div>
                                        <div class="alert alert-block alert-success">						
                                            <table class="table">
                                                <tbody>
                                                    <?php foreach ($packages as $index=>$package)
                                                    {
                                                    ?>
                                                    <tr>
                                                        <td class="center">
                                                            <label>
                                                                <input <?php if($index==0) {echo "checked='checked'";}?> type="radio" value="<?php echo $package['p_id'];?>" name="p_id" class="ace" />
                                                                <span class="lbl"></span>
                                                            </label>
                                                        </td>
                                                        <td><?php echo $package['p_name'];?></td>
                                                        <td><?php echo $package['p_period'],' tháng (', number_format($package['p_price'], 0); ?> VNĐ)</td>
                                                        
                                                    </tr>
                                                    <?php } ?>
                                                    
                                                </tbody>
                                            </table>
                                            <button type="submit" class="btn btn-success">Tiếp tục</button>
                                        </div>
                                        
                                               <?php if ($is_viettel==true) { ?>
                                        <h4 class="header blue bolder smaller"></h4>
                                        <div class="alert alert-block alert-success">						
                                            <p>
                                                Quý vị cũng có thể sử dụng số điện thoại&nbsp;<strong><?php echo $username;?></strong> và soạn tin theo cú pháp: <strong>SBG VIP 1</strong> (hay VIP 3, VIP 6, VIP 12) <strong>gửi tới 8062</strong> (Hệ thống sẽ trừ tiền trên tài khoản chính của số điện thoại&nbsp;<strong><?php echo $username;?></strong>)
                                        </p>
                                        </div>
                                            <?php } ?>
                                            
                                        
                                    </form>
                                </div>

                            </div>
                        </div>
                    </div><!-- /span -->
                </div>

                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div><!-- /.main-content -->
</div><!-- /.main-container-inner -->

<!-- <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a> -->
</div><!-- /.main-container -->

<div class="modal fade" id="trade-history" tabindex="-1" role="dialog"aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">Lịch sử giao dịch</h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th class="center">
									Từ
                                </th>
                                <th class="center">Số tiền (VNĐ)</th>
                                <th>
                                    <i class="icon-time bigger-110 hidden-480"></i>
                                    Thời gian
                                </th>
                            </tr>
                        </thead>
                        <tbody id="content-trade-histoty">
                        </tbody>
                    </table>
					<div>
						<div class="dataTables_paginate paging_bootstrap">
							<ul class="pagination">
							</ul>
						</div>
					</div>
                </div><!-- /.table-responsive -->
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="package_register_modal" tabindex="-1" role="dialog"aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">Đăng ký gói dịch vụ</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-block alert-success">						
                   
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="changeProfile" tabindex="-1" role="dialog"aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title">Thay đổi số điện thoại</h4>
				</div>
				<div class="modal-body">
				<div class="alert alert-block alert-success">						
					<?php echo lang('_SBG_USER_PHONENUM_CHANGE_MSG'); ?>
				</div>
			</div>
		</div>
	</div>
</div>

<div class="modal fade" id="changePassSuccess" tabindex="-1" role="dialog"aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title">Đổi mật khẩu</h4>
			</div>
			<div class="modal-body">
				<div class="alert alert-block alert-success"><center><?php echo lang('_SBG_USER_PASSWORD_CHANGE_SUCCESS_MSG'); ?></center></div>
				<center><button class="btn btn-primary" data-dismiss="modal">Đóng</button></center>
			</div>
		
		</div>
	</div>
</div>

<div class="modal fade" id="updateInfoSuccess" tabindex="-1" role="dialog"aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title">Cập nhật thông tin</h4>
			</div>
			<div class="modal-body">
				<div class="alert alert-block alert-success"><center><?php echo lang('_SBG_USER_UPDATE_INFO_SUCCESS_MSG'); ?><center></div>
				<center><button id="close" class="btn btn-primary" data-dismiss="modal">Đóng</button></center>
			</div>
		
		</div>
	</div>
</div>

<div class="modal fade" id="success_package_register_modal" tabindex="-1" role="dialog"aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title">Đăng kí thành công</h4>
			</div>
			<div class="modal-body">
				<div id="success_package_register_content" class="alert alert-block alert-success"><center></center></div>
				<center><button id="package_register_finish_button" class="btn btn-primary" data-dismiss="modal">Đóng</button></center>
			</div>
		
		</div>
	</div>
</div>

<div class="modal fade" id="success_charge" tabindex="-1" role="dialog"aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title">Nạp tiền</h4>
			</div>
			<div class="modal-body">
				<div id="success_charge_info" class="alert alert-block alert-success"><center></center></div>
				<center><button id="package_register_finish_button" data-dismiss="modal" class="btn btn-primary" >Đóng</button></center>
			</div>
		
		</div>
	</div>
</div>

<div class="modal fade" id="not_success_charge" tabindex="-1" role="dialog"aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title">Nạp tiền</h4>
			</div>
			<div class="modal-body">
				<div id="no_success_charge_info" class="alert alert-block alert-success"><center></center></div>
				<center><button id="package_register_finish_button" data-dismiss="modal" class="btn btn-primary" >Đóng</button></center>
			</div>
		
		</div>
	</div>
</div>

<div class="modal fade" id="regis-history" tabindex="-1" role="dialog"aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">Lịch sử đăng ký dịch vụ</h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th class="center">
									Từ
                                </th>
								<th class="center">
									Số tiền (VNĐ)
                                </th>
                                <th class="center"> Dịch vụ </th>
                                <th>
                                    <i class="icon-time bigger-110 hidden-480"></i>
                                    Thời gian
                                </th>
                            </tr>
                        </thead>
                        <tbody id="content-regis-histoty">
                        </tbody>
                    </table>
					<div>
						<div class="dataTables_paginate paging_bootstrap">
							<ul class="pagination">
							</ul>
						</div>
					</div>
                </div><!-- /.table-responsive -->
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
	var url="<?php echo base_url();?>";
	var current_tab="<?php echo $current_tab;?>";
	//var current_balanced = <?php echo $acc_balanced; ?>;
</script>
<?php
$this->load->view('layout/frontend/footer', array('base_url' => $base_url, 'usjs' => array('assets/js/frontend/user.js')));
?>