diff --git a/ams_vendor.zip b/ams_vendor.zip deleted file mode 100644 index 99d3bb3..0000000 Binary files a/ams_vendor.zip and /dev/null differ diff --git a/application/core/MY_Model.php b/application/core/MY_Model.php index 52f739f..ca24795 100644 --- a/application/core/MY_Model.php +++ b/application/core/MY_Model.php @@ -316,4 +316,15 @@ function editBusiness() $this->db->update('business',$data); return true; } + + function checkUniqueValueInDataBase($table, $where, $data){ + + // echo $table, $where, $data; die; + + $this->db->select('*'); + $this->db->from($table); + $this->db->where($where, $data); + return $this->db->get()->result_array(); + + } } diff --git a/application/modules/Auth/controllers/Auth.php b/application/modules/Auth/controllers/Auth.php index f64a602..46b2d1d 100644 --- a/application/modules/Auth/controllers/Auth.php +++ b/application/modules/Auth/controllers/Auth.php @@ -41,25 +41,22 @@ public function __construct() */ public function index() { - - //echo site_url(); - // Example - if(check_auth()) - { + if(check_auth()){ redirect('Dashboard'); + }else{ + $this->layout->load_view('Auth/login'); } - else{ - $this->layout->load_view('Auth/login'); - } - // $this->load->view('welcome/welcome_message'); - // $this->load->view('welcome_message'); } public function authendicate() { $user = $this->auth_model->validate_user(); - // print_r($user);die(); - // echo hash_password('password');die(); + $business = $this->auth_model->validateBusiness($user->business_id); + + if ($user->business_id !== '0' && empty($business)) { + $this->session->set_flashdata('msg', "Business Deactivated Contact Administrator"); + redirect('login'); + } if (empty($user)) { $this->session->set_flashdata('msg', "username not avaiable"); redirect('login'); @@ -142,61 +139,73 @@ public function lost_your_password() $this->layout->load_view("Auth/otp_verification"); } - public function send__mail(){ + public function sendMail(){ // otp generator - $otp = rand ( 1000 , 9999 ); + $otp = rand(100000, 999999); $data['otp'] = $otp; - $mail = $this->input->post('email'); - $user = $this->auth_model->validate_user(); + $mail = $this->input->get('email'); + $where = 'email'; + $user = $this->auth_model->validateUserForOtp($mail, $where); + if (empty($user)) { $data['csrf_hash'] = $this->security->get_csrf_hash(); $data['status'] = "failed"; echo json_encode($data); } else{ - // $to = "suseendhiran1999@gmail.com"; // $mail - // $subject = "OTP"; - // $message = $otp; - // $success_msg = $this->auth_model->send_email($to, $subject, $message); $data['csrf_hash'] = $this->security->get_csrf_hash(); $data['status'] = "success"; $data['id'] = $user->id; + $data['email'] = $mail; + + $id = $user->id; + $table="users"; + $datas['otp'] = $otp; + $userData = $this->MY_Model->edit_option($datas, $id, $table); echo json_encode($data); } } public function verify_otp(){ - $generate_otp = $this->input->post('hidden_otp'); - $user_entered_otp = $this->input->post('otp'); - $id = $this->input->post('id'); - if ($generate_otp == $user_entered_otp) - { - $data['generate_otp'] = $generate_otp; - $data['user_entered_otp'] = $user_entered_otp; - $data['csrf_hash'] = $this->security->get_csrf_hash(); - $data['status'] = "success"; - $data['id'] = $id; - $htmlPage = $this->load->view('change_password_form.php',$data,true); - $data['htmlPage'] = $htmlPage; - echo json_encode($data); - } - else - { - $data['csrf_hash'] = $this->security->get_csrf_hash(); - $data['status'] = "failed"; - echo json_encode($data); - } + + $id = $this->input->post('id'); + $email = $this->input->post('email'); + $where = 'id'; + $user_entered_otp = $this->input->post('otp'); + $user = $this->auth_model->validateUserForOtp($id, $where); + + + if ($user->otp == $user_entered_otp) + { + $data['generate_otp'] = $generate_otp; + $data['user_entered_otp'] = $user_entered_otp; + $data['csrf_hash'] = $this->security->get_csrf_hash(); + $data['status'] = "success"; + $data['id'] = $id; + $data['email'] = $email; + $id = $id; + $table = "users"; + $datas['otp'] = ''; + $userData = $this->MY_Model->edit_option($datas, $id, $table); + $this->layout->load_view('Auth/change_password_form', $data); + } + else + { + $data['csrf_hash'] = $this->security->get_csrf_hash(); + $data['status'] = "failed"; + $data['id'] = $id; + $data['email'] = $email; + $this->layout->load_view("Auth/otp_verification", $data); + } } public function change_password() { - print_r($this->input->post('id')); die; - $id = $this->input->post('id'); + $id = $this->input->post('id'); $data['password'] = hash_password($this->input->post('password')); - $table="users"; - - $userData = $this->MY_Model->edit_option($data, $id, $table); + $table = "users"; + $userData = $this->MY_Model->edit_option($data, $id, $table); redirect('login'); } } diff --git a/application/modules/Auth/models/Auth_model.php b/application/modules/Auth/models/Auth_model.php index d75b091..15d4fd1 100644 --- a/application/modules/Auth/models/Auth_model.php +++ b/application/modules/Auth/models/Auth_model.php @@ -194,6 +194,41 @@ function validate_user() return false; } } + + // check valid user + function validateUserForOtp($data, $where) + { + + $this->db->select('*'); + $this->db->from('users'); + $this->db->where($where, $data); + $this->db->limit(1); + $query = $this->db->get(); + if($query->num_rows() == 1){ + return $query->row(); + }else{ + + return false; + } + } + + // check valid Business + function validateBusiness($business_id) + { + + $this->db->select('*'); + $this->db->from('business'); + $this->db->where('is_active', 1); + $this->db->where('uid', $business_id); + $this->db->limit(1); + $query = $this->db->get(); + if($query->num_rows() == 1){ + return $query->row(); + }else{ + + return false; + } + } // check valid staff diff --git a/application/modules/Auth/views/change_password_form.php b/application/modules/Auth/views/change_password_form.php index 551fac7..b084d84 100644 --- a/application/modules/Auth/views/change_password_form.php +++ b/application/modules/Auth/views/change_password_form.php @@ -35,6 +35,20 @@ position: relative; z-index: 3; } +body { + /* Set the background image URL */ + background-image: url("assets/appimg/bg-4.jpg") !important; + background-position: center !important; + background-repeat: no-repeat !important; + background-color: rgba(255, 255, 255, 0.7) !important; + +} + +h1, +a, +p { + color: #fff !important; +} @@ -42,20 +56,17 @@
+ action="Auth/change_password" enctype="multipart/form-data">

Change Password

- - + +
- +

diff --git a/application/modules/Auth/views/login.php b/application/modules/Auth/views/login.php index 811aa1b..84abc31 100644 --- a/application/modules/Auth/views/login.php +++ b/application/modules/Auth/views/login.php @@ -22,10 +22,28 @@ + + + - + +

@@ -44,20 +62,16 @@
-

session->flashdata('msg'); ?>

+ session->flashdata('msg'); ?>
- - -

diff --git a/application/modules/Auth/views/otp_verification.php b/application/modules/Auth/views/otp_verification.php index 84dfb4d..130f599 100644 --- a/application/modules/Auth/views/otp_verification.php +++ b/application/modules/Auth/views/otp_verification.php @@ -24,6 +24,12 @@ + + + + + + - -
+ + + + + diff --git a/application/modules/Business/controllers/Business.php b/application/modules/Business/controllers/Business.php index 303635d..5933b64 100644 --- a/application/modules/Business/controllers/Business.php +++ b/application/modules/Business/controllers/Business.php @@ -43,6 +43,8 @@ public function business_list() { $business_list = $this->Business_model->get_business_details(); + // echo '
';
+		// print_r($business_list); die;
 		$this->layout->set('tableData', $business_list);
         $this->layout->buffer('main_content', 'Business/business_list');
         $this->layout->render('default_layout');
@@ -248,11 +250,32 @@ public function edit_business()
     }
 
   public function delete_business($id)
-  {
-    $Data = $this->Business_model->delete_by_md5_id($id,user()->business_id,'asset');
+  {  
+	$data['is_active'] = 0;
+    $Data = $this->Business_model->delete_by_md5_id($id,$data);
 	redirect('Business/business_list');
   }
 
+  public function activate_business($id)
+  {  
+	$data['is_active'] = 1;
+    $Data = $this->Business_model->delete_by_md5_id($id,$data);
+	redirect('Business/business_list');
+  }
+
+  public function checkUniqueBusinessData()
+  {
+	$data = $this->input->get('value');
+	$table = 'business';
+	$where = $this->input->get('name');
+	$result = $this->MY_Model->checkUniqueValueInDataBase($table, $where, $data);
+	if(count($result)){
+		$this->output->set_output(true);
+	}else{ 
+		$this->output->set_output(false);
+	}
+  }
+
 	//===================== MODULES =================================================
   
   public function add_module()
diff --git a/application/modules/Business/models/Business_model.php b/application/modules/Business/models/Business_model.php
index 3a61c2f..9fcd114 100644
--- a/application/modules/Business/models/Business_model.php
+++ b/application/modules/Business/models/Business_model.php
@@ -7,7 +7,7 @@ public function get_business_details()
         $this->db->from('business B');
 		$this->db->join('state', 'state.id = B.state', 'left');
         $this->db->order_by('B.id','ASC');
-		$this->db->where('B.is_active', 1);
+		// $this->db->where('B.is_active', 1);
         $query = $this->db->get();
         $query = $query->result();  
         return $query;
@@ -25,14 +25,12 @@ public function get_business_by_md5_id($id)
         return $query;
     } 
 	
-    public function delete_by_md5_id($id,$business_id,$table)
+    public function delete_by_md5_id($id,$data)
     {
-        $this->db->where('md5(id)', $id);
-		$this->db->where('business_id', $business_id);
-		$this->db->set('is_active',0);
-        $this->db->update($table);
-        return;
-    } 
+        $this->db->where('id', $id);
+        $this->db->update('business', $data);
+  
+     } 
 
     public function get_business_modules($business_id)
     {
@@ -99,8 +97,7 @@ public function get_group_id_by_module_id($module_id)
         $this->db->where('module_id', $module_id);
         $query = $this->db->get();
         return $query->result();
-
-
     }
 
+  
 }
\ No newline at end of file
diff --git a/application/modules/Business/views/add_business.php b/application/modules/Business/views/add_business.php
index 0283e9a..3f3ce84 100644
--- a/application/modules/Business/views/add_business.php
+++ b/application/modules/Business/views/add_business.php
@@ -166,7 +166,7 @@ class="form-control" required>
                             
                             
- +
@@ -263,14 +263,31 @@ class="form-control">
- - - - - - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/application/modules/Business/views/business_list.php b/application/modules/Business/views/business_list.php index a32b209..d92ea11 100644 --- a/application/modules/Business/views/business_list.php +++ b/application/modules/Business/views/business_list.php @@ -1,78 +1,99 @@ - - -
-
- -
-
-
-
- - - - - - - - - - - - - - - - - - - + + + + +
+
+
+

Business Details

+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + $value) { ?> + + + + + + + + + + + + + + + + + + +
+
+
+
+

@@ -82,20 +103,20 @@ - + \ No newline at end of file diff --git a/application/modules/Business/views/edit_business.php b/application/modules/Business/views/edit_business.php index deb5fde..635dc2f 100644 --- a/application/modules/Business/views/edit_business.php +++ b/application/modules/Business/views/edit_business.php @@ -165,7 +165,7 @@ class="form-control"> style="color:red;">*
+ required="required" class="form-control" onkeyup="check_if_exists(this.id, this.value, this.name)" />