<?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 (@$use_package) 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-username" 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>. 
											<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-6">
											<h4>Số tiền trong tài khoản SBG Online: <b><span class="blue"><?php echo number_format(@$acc_balanced, 0); ?> VNĐ <span></b></h4>

                                        </div>
										<div class="col-sm-6">
											<h3>&nbsp; </h3>
                                        </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="form-field-pass1" 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="form-field-pass2" 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 href="#" data-toggle="modal" data-target="#trade-history"><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>
                                                Sử dụng thuê bao <strong><?php echo @$username; ?></strong> soạn tin nhắn: <strong>SBG NAP [sotien] gửi 8062</strong>. <br/>
                                                Nếu quí vị sử dụng thuê bao Viettel khác thì soạn tin nhắn: <strong>SBG NAP <?php echo $username; ?>
                                                    [sotien] 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ụ</h4>
										<div class="col-sm-6">
                                            <h4><b>Thời hạn sử dụng</b></h4> <h3><b><span class="blue"><?php if(strtotime($expire_date)>0) { echo date('d/m/Y', strtotime($expire_date));}else { echo '';} ?> </span></b></h3>
                                        </div> 
										<div class="col-sm-6">
                                            <h4>Số tiền trong tài khoản SBG Online</h4><h3> <?php echo number_format(@$acc_balanced, 0); ?> 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ý dịch vụ</h4>

                                        <h5>Cách 1: 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><?php echo $package['p_name'];?></td>
                                                        <td><?php echo $package['p_period'],' tháng (', number_format($package['p_price'], 0); ?> VNĐ)</td>
                                                        <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>
                                                    </tr>
                                                    <?php } ?>
                                                    
                                                </tbody>
                                            </table>
                                            <button type="submit" class="btn btn-success">Đăng ký</button>
                                        </div>
                                        
                                        <h5>Cách 2</h5>
                                        <h4>Soạn tin: SBG VIP [1 hay 3, 6, 12] gửi tới 8062</h4>
                                    </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">
                                    <label>
                                        <input type="checkbox" class="ace" />
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th>Số tiền</th>

                                <th>
                                    <i class="icon-time bigger-110 hidden-480"></i>
                                    Thời gian
                                </th>
                            </tr>
                        </thead>

                        <tbody>
                            <tr>
                                <td class="center">
                                    <label>
                                        <input type="checkbox" class="ace" />
                                        <span class="lbl"></span>
                                    </label>
                                </td>
                                <td>$45</td>
                                <td>Feb 12</td>
                            </tr>
                        </tbody>
                    </table>
                </div><!-- /.table-responsive -->
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="alert-payment" 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">Thông báo dịch vụ</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-block alert-success">						
                    <p>
                        Quí vị đã nạp thành công <b>10.000 </b>VND vào tài khoản <b>0168942155</b>, tài khoản hiện tại của quí vị là <b>20.000 </b>VND.
                    </p>
                </div>
            </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">						
					<p>
						Quí vị có thể thay đổi Số Điện thoại đang sử dụng bằng cách: Trên số điện thoại mới, quí vị soạn tin theo cú pháp: <strong>SBG DDT [SoDTCu] [MatKhau]</strong> gửi tới <strong>8062</strong>.
					</p>
				</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>Quí vị đã đổi mật khẩu thành công !</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>Quí vị đã cập nhật thông tin thành công!</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>Quí vị đã cập nhật thông tin thành công!</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>Quí vị đã nạp thành công [SoTien] vào tài khoản <?php echo $username; ?>, tài khoản ảo của quí vị là [TaiKhoanAO]!</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>Mã thẻ hoặc Serial không dúng hoặc đã được sử dụng. Quí vị hãy kiểm tra lại!</center></div>
				<center><button id="package_register_finish_button" data-dismiss="modal" class="btn btn-primary" >Đóng</button></center>
			</div>
		
		</div>
	</div>
</div>

<script type="text/javascript">
	var url="<?php echo base_url();?>";
	var current_tab="<?php echo $current_tab;?>";
</script>
<?php
$this->load->view('layout/frontend/footer', array('base_url' => $base_url, 'usjs' => array('assets/js/frontend/user.js')));
?>