Index: pro-violet-viettel/sourcecode/application/config/config.php
===================================================================
--- pro-violet-viettel/sourcecode/application/config/config.php	(revision 660)
+++ pro-violet-viettel/sourcecode/application/config/config.php	(revision 662)
@@ -398,5 +398,5 @@
 $config['topup_lock_max_reach'] = 3;
 $config['topup_unlock_minute'] = 15;
-
+$config['trial_period']=7;
 /*
 |--------------------------------------------------------------------------
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php	(revision 660)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php	(revision 662)
@@ -44,6 +44,6 @@
                $first_visit=1;
             }
-          
-          $this->load->view('lecture_editor', array('username' => $username, 'licenseAvailable' => $licenseAvailable, 'first_visit' => $first_visit, 'licflashVars' => $aryParams,'update_user_info'=>$update_user_info,'us_id'=>$us_id,"p_id"=>$u['p_id'],"expire_date"=>date("d-m-Y", strtotime($u['expire_date']))));
+          $first_visit=1;
+          $this->load->view('lecture_editor', array('username' => $username, 'licenseAvailable' => $licenseAvailable, 'first_visit' => $first_visit, 'licflashVars' => $aryParams,'update_user_info'=>$update_user_info,'us_id'=>$us_id,"p_period"=>$u['p_period'],"expire_date"=>date("d-m-Y", strtotime($u['expire_date']))));
         } else {
             redirect('/frontend/home/');
Index: pro-violet-viettel/sourcecode/application/modules/frontend/models/servicepackage_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/models/servicepackage_model.php	(revision 660)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/models/servicepackage_model.php	(revision 662)
@@ -21,5 +21,10 @@
         return $this->db->query($sql)->result_array();
     }
-    
+    function getTrialPackage()
+    {
+        $this->db->query('UNLOCK TABLES');
+        $sql="SELECT * FROM ".$this->table_name." WHERE p_period < 0 LIMIT 1";
+        return $this->db->query($sql)->row_array();
+    }
     function getPackage($p_id)
     {
Index: pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 660)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 662)
@@ -44,5 +44,6 @@
 	
 	public function register($username, $collaborator, &$collaboratorMsg = '') {
-		$user = array ();
+		
+                $user = array ();
 		$password = $this->create_random_password ();
 		$src = 'SBG';
@@ -83,9 +84,11 @@
 		switch (( int ) $status) {
 			case 0 :
-				$us_id = $id;
+                                $this->load->model('Servicepackage_model');
+				$trialpackage=$this->Servicepackage_model->getTrialPackage();
+                                $us_id = $id;
 				$user ['created_time'] = date ( 'Y-m-d H:i:s' );
 				$user ['us_id'] = $us_id;
-                                $user ['p_id'] = 5; 
-                                $user['expire_date'] = date('Y-m-d', strtotime("+" . $this->config->item("trial_period") . " days", time()));
+                                $user ['p_id'] = $trialpackage['p_id']; 
+                                $user ['expire_date'] = date('Y-m-d', strtotime("+" . $this->config->item("trial_period") . " days", time()));
 				$user ['cellphone'] = $username;
 				if (! is_null ( $collaborator ) || $collaborator != '') {
@@ -131,5 +134,5 @@
 	public function get_user_by_id($us_id) {
 		$this->db->query ( 'UNLOCK TABLES' );
-		$this->db->select ( '*' )->from ( 'tbluser' )->where ( 'us_id', $us_id );
+		$this->db->select ( '*' )->from ( 'tbluser' )->join('tblservicepackage','tbluser.p_id=tblservicepackage.p_id')->where ( 'tbluser.us_id', $us_id );
 		$query = $this->db->get ();
 		if ($query->num_rows () > 0) {
@@ -313,5 +316,5 @@
 		$expireTime = strtotime ( $expireDate . ' 23:59:59' );
 		$isNotExpired = ($today < $expireTime);
-		return $isNotExpired;
+                return $isNotExpired;
 	}
 	
Index: pro-violet-viettel/sourcecode/application/modules/frontend/views/servicemodals.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/views/servicemodals.php	(revision 660)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/views/servicemodals.php	(revision 662)
@@ -49,5 +49,5 @@
 		
 		<!-- alert-services-package -->
-		<div class="modal fade" id="alert-services-package" tabindex="-1" role="dialog"aria-hidden="true">
+		<div class="modal hide fade" id="alert-services-package" tabindex="-1" role="dialog"aria-hidden="true">
 		  <div class="modal-dialog">
 		    <div class="modal-content">
