source: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php @ 454

Last change on this file since 454 was 454, checked in by namnd, 11 years ago
File size: 2.6 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class User extends MX_Controller
4{
5        public function __construct()
6        {
7                parent::__construct();
8                $this->load->helper('cookie');
9        }
10       
11        public function profile()
12        {
13                $user = "us_id=9075011&username=0979947802&fullname=Nam Nguyen&gender=female&email=namndmk@gmail.com&phone=&school=&province=&status=4&errMsg=Account is not activated";
14                $data = $this->get_data($user);
15                $this->load->view('frontend/user_profile', $data);
16                /*
17                $user_info = $this->session->userdata('userInfo');
18                if ($user_info)
19                {
20                        $user = $user_info['user'];
21                        $data = $this->get_data($user);
22                        $this->load->view('/frontend/user_profile', $data);
23                       
24                }else
25                {
26                        redirect('/frontend/home');
27                }*/
28        }
29       
30        private function get_data($user)
31        {
32                $this->load->model('user_model');
33                $arr_users = explode("&", $user);
34                $str_id = $arr_users[0];
35                $str_username = $arr_users[1];
36                $str_fullname = $arr_users[2];
37                $str_gender = $arr_users[3];
38                $str_email = $arr_users[4];
39                $str_phone = $arr_users[5];
40                $str_school = $arr_users[6];
41                $str_province = $arr_users[7];
42                $str_money = $arr_users[8];
43                $str_level = $arr_users[9];
44                $arr_id = explode("=", $str_id);
45                $arr_username = explode("=", $str_username);
46                $arr_fullname = explode("=", $str_fullname);
47                $arr_gender = explode("=", $str_gender);
48                $arr_email = explode("=", $str_email);
49                $arr_phone = explode("=", $str_phone);
50                $arr_school = explode("=", $str_school);
51                $arr_province = explode("=", $str_province);
52                $arr_money = explode("=", $str_money);
53                $arr_level = explode("=", $str_level);
54                $us = $this->user_model->get_user_by_id($arr_id[1]);
55                $data = array('us_id'=>$arr_id[1], 'username'=>$arr_username[1], 'full_name'=>$arr_fullname[1],
56                                        'gender'=>$arr_gender[1], 'email'=>$arr_email[1], 'phone'=>$arr_phone[1], 'school'=>$arr_school[1],
57                                        'acc_balanced'=>$us['acc_balanced'], 'expire_date'=>$us['expire_date'], 'date_diff'=>$this->dateDiff($us['expire_date'])
58                                );
59                return $data;
60        }
61       
62        private function dateDiff($expire_date)
63        {
64                $date1 = date("Y-m-d");
65                $diff = abs(strtotime($expire_date) - strtotime($date1));
66                $years = floor($diff / (365*60*60*24));
67                $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
68                $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
69                if ($years>0){
70                        return $years." năm, ".$months." tháng, ".$days." ngày còn lại";
71                }
72                else{
73                        if ($months>0)
74                        {
75                                return  $months." tháng, ".$days." ngày còn lại";
76                        }
77                        else
78                        {
79                                return $days." ngày còn lại";
80                        }
81                }
82               
83        }
84}
Note: See TracBrowser for help on using the repository browser.