X7ROOT File Manager
Current Path:
/home/hamdjcne/app.hamdalillahitravel.com/app/Controllers
home
/
hamdjcne
/
app.hamdalillahitravel.com
/
app
/
Controllers
/
ðŸ“
..
📄
.DS_Store
(6 KB)
📄
Accounts.php
(52.25 KB)
📄
Activity.php
(4.49 KB)
📄
Analytics.php
(12.22 KB)
📄
Api.php
(41.41 KB)
📄
Auth.php
(34.64 KB)
📄
BaseController.php
(1.77 KB)
📄
Dashboard.php
(42.95 KB)
📄
Notification.php
(6.22 KB)
📄
Order.php
(118.16 KB)
📄
Service.php
(61.77 KB)
📄
Settings.php
(40.13 KB)
📄
Staff.php
(67.17 KB)
📄
Tour.php
(32.09 KB)
📄
Wallets.php
(43.15 KB)
📄
Webhook.php
(5.14 KB)
Editing: Auth.php
<?php namespace App\Controllers; class Auth extends BaseController { public function index() { return $this->login(); } ///// LOGIN public function login() { // check login $log_id = $this->session->get('hdt_id'); if(!empty($log_id)) return redirect()->to(site_url('dashboard')); $data['current_language'] = $this->session->get('current_language'); if($this->request->getMethod() == 'post') { $email = $this->request->getVar('email'); $password = $this->request->getVar('password'); if(!$email || !$password) { echo $this->Crud->msg('danger', 'Please provide Email and Password'); } else { // check user login detail $user_id = $this->Crud->read_field2('email', $email, 'password', md5($password), 'user', 'id'); if(empty($user_id)) { echo $this->Crud->msg('danger', 'Invalid Authentication!'); } else { $role_id = $this->Crud->read_field('id', $user_id, 'user', 'role_id'); $role = $this->Crud->read_field('id', $role_id, 'access_role', 'name'); $activate = $this->Crud->read_field('id', $user_id, 'user', 'activate'); if($activate == 0){ echo $this->Crud->msg('danger', 'Account not Activated.<br>Contact Administrator.'); die; } $up_data['last_log'] = date(fdate); $up_data['status'] = 1; $this->Crud->updates('id', $user_id, 'user', $up_data); ///// store activities $this->session->set('hdt_id', $user_id); $code = $this->Crud->read_field('id', $user_id, 'user', 'fullname'); $action = $code.' logged in'; $this->Crud->activity('authentication', $user_id, $action, $user_id); echo $this->Crud->msg('success', 'Login Successful!'); echo '<script>window.location.replace("'.site_url('dashboard').'");</script>'; } } die; } $data['title'] = 'Log In - '.app_name; return view('auth/login', $data); } ///// REGISTER////////////////////////// public function register() { $data['current_language'] = $this->session->get('current_language'); if($this->request->getMethod() == 'post') { $fullname = $this->request->getPost('fullname'); $email = $this->request->getPost('email'); $password = $this->request->getPost('password'); $phone = $this->request->getPost('phone'); $confirm = $this->request->getPost('confirm_password'); $agree = $this->request->getPost('toc'); $Error = ''; if($this->Crud->check('email', $email, 'user') > 0) {$Error .= 'Email Taken <br/>';} if($password != $confirm) {$Error .= 'Password Not Match';} if(empty($agree)) {$Error .= 'You must agree to Terms and Conditions';} if(empty($phone)) {$Error .= 'Enter Phone Number';} if($Error) { echo $this->Crud->msg('danger', $Error); die; } if (!empty($_POST['bot_check'])) { die("Bot detected! Form submission blocked."); } if (isset($_POST['timestamp'])) { $time_taken = time() - $_POST['timestamp']; if ($time_taken < 5) { // Less than 5 seconds = suspicious die("Bot detected! Form submission too fast."); } } $ins_data['fullname'] = $fullname; $ins_data['role_id'] = $this->Crud->read_field('name', 'Customer', 'access_role', 'id'); $ins_data['email'] = $email; $ins_data['phone'] = $phone; $ins_data['is_member'] = 1; $ins_data['activate'] = 1; $ins_data['password'] = md5($password); $ins_data['reg_date'] = date(fdate); $ins_id = $this->Crud->create('user', $ins_data); if ($ins_id > 0) { // Fetch user details $fullname = $this->Crud->read_field('id', $ins_id, 'user', 'fullname'); $email = $this->Crud->read_field('id', $ins_id, 'user', 'email'); $phone = $this->Crud->read_field('id', $ins_id, 'user', 'phone'); $action = $fullname . ' Created Account '; $this->Crud->activity('authentication', $ins_id, $action, $ins_id); echo $this->Crud->msg('success', 'Registration Successful! Please Login'); echo '<script>window.location.replace("'.site_url('auth').'");</script>'; } else { echo $this->Crud->msg('danger', 'Please Try Again Later'); } die; } $data['title'] = 'Register - '.app_name; return view('auth/register', $data); } public function otp($param1='') { $email = $this->request->getPost('email') ?? ''; $activation_code = $this->request->getPost('activation_code') ?? ''; // echo $email; if($param1 == 'validate_code'){ // Validate email and OTP $user = $this->Crud->read_field2('email', $email, 'activation_code', $activation_code, 'user', 'id'); if ($user) { // Activate account $this->Crud->updates('id', $user, 'user', ['activate' => 1, 'activation_code' => null]); $up_data['last_log'] = date(fdate); $up_data['status'] = 1; $this->Crud->updates('id', $user, 'user', $up_data); ///// store activities $this->session->set('hdt_id', $user); $code = $this->Crud->read_field('id', $user, 'user', 'fullname'); $action = $code.' Validated Accouunt'; $this->Crud->activity('authentication', $user, $action); $action = $code.' logged in'; $this->Crud->activity('authentication', $user, $action); echo $this->Crud->msg('success', 'Account Activation Successful!'); echo '<script>window.location.replace("'.site_url('dashboard').'");</script>'; } else { echo $this->Crud->msg('danger', 'Invalid Email or Activation Code!'); } } if($param1 == 'resend_otp'){ // Check if email exists in the database $user = $this->Crud->read_field('email', $email, 'user', 'id'); if ($user) { // Generate new OTP $activation_code = rand(100000, 999999); $this->Crud->updates('id', $user, 'user', ['activation_code' => $activation_code]); // echo $user; // Get API Key and Email Config from DB $api_key = $this->Crud->read_field('name', 'termil_api', 'setting', 'value'); $email_config = $this->Crud->read_field('name', 'termii_email_config', 'setting', 'value'); // Fetch user details $fullname = $this->Crud->read_field('id', $user, 'user', 'fullname'); $email = $this->Crud->read_field('id', $user, 'user', 'email'); $phone = $this->Crud->read_field('id', $user, 'user', 'phone'); // Send OTP via SMS if ($phone) { $phone = '234' . substr($phone, 1); $sms_data = [ 'api_key' => $api_key, 'to' => $phone, 'from' => 'N-Alert', 'sms' => "Your ".app_name." activation code is: $activation_code", 'type' => 'plain', 'channel' => 'dnd' ]; $this->Crud->termii('post', 'sms/send', $sms_data); } // Send OTP via WhatsApp if ($phone) { $whatsapp_data = [ 'api_key' => $api_key, 'to' => $phone, 'from' => 'N-Alert', 'sms' => "Your ".app_name." activation code is: $activation_code", 'type' => 'plain', 'channel' => 'whatsapp_otp' ]; $this->Crud->termii('post', 'sms/send', $whatsapp_data); } // Send OTP via Email if ($email) { $email_data = [ 'email_address' => $email, 'api_key' => $api_key, 'email_configuration_id' => $email_config, 'code' => $activation_code ]; $this->Crud->termii('post', 'email/otp/send', $email_data); } echo "<script> setTimeout(() => {document.getElementById('resendOtpBtn').disabled = false;}, 60000);</script>"; echo $this->Crud->msg('success', 'OTP Sent Successful!'); } else { echo $this->Crud->msg('danger', 'Invalid Email'); } } } public function forgot($param1="", $param2="") { // check login $log_id = $this->session->get('hdt_id'); //send reset code if($param1 == 'code'){ if($this->request->getMethod() == 'post') { $email = $this->request->getVar('email'); if($email) { $user_id = $this->Crud->read_field('email', $email, 'user', 'id'); if(empty($user_id)) { echo $this->Crud->msg('danger', translate_phrase('Invalid Email!')); } else { $reset = substr(md5(time().rand()), 0, 6); if($this->Crud->updates('id', $user_id, 'user', array('reset'=>$reset)) > 0) { $fullname = $this->Crud->read_field('id', $user_id, 'user', 'fullname'); // send email if($email) { $msg = 'Dear '.ucwords($fullname).'<br><br> We have received a request to reset your password for '.app_name.'. To proceed with resetting your password, please use the following reset code:<br><br> Reset Code: '.$reset.'<br> If you did not request this password reset or if you have any concerns about the security of your account, please contact our support team immediately at '.push_email.'<br><br>. Thank you for your cooperation.'; $this->Crud->send_email($email, 'Password Reset Code Request', $msg); } $data['code'] = $reset; echo $this->Crud->msg('success', translate_phrase('Reset Code sent to your Email!')); $this->session->set('fl_code', $reset); $this->session->set('fl_email', $email); echo '<script> $("#bb_ajax_form").hide(800); $("#bb_ajax_form3").hide(); $("#bb_ajax_form2").show(800); $("#bb_ajax_msg2").html("<h5 class=text-success>'.translate_phrase('Reset Code Sent!').'</h5>"); </script>'; } } } die; } } //confrim reset code if($param1 == 'confirm_code'){ if($this->request->getMethod() == 'post') { $code = $this->request->getVar('code'); if(!empty($code)){ $reset = $this->session->get('fl_code'); if($reset != $code){ echo $this->Crud->msg('danger', translate_phrase('Invalid Reset Code!')); } else { echo '<script> $("#bb_ajax_form2").hide(800); $("#bb_ajax_form3").show(800); $("#bb_ajax_msg3").html("<h5 class=text-success>'.translate_phrase('Reset Code Confirmed!').'</h5>"); </script>'; } } die; } } //new password if($param1 == 'password'){ if($this->request->getMethod() == 'post') { $password = $this->request->getVar('password'); $email = $this->session->get('fl_email'); if(!empty($email) && !empty($password)) { $user_id = $this->Crud->read_field('email', $email, 'user', 'id'); if(empty($user_id)) { echo $this->Crud->msg('warning', 'Invalid Email!'); } else { $msg = $user_id; if($this->Crud->updates('id', $user_id, 'user', array('password'=>md5($password),'reset'=>'')) > 0) { echo $this->Crud->msg('success', 'Password Reset Successfully!'); ///// store activities $code = $this->Crud->read_field('id', $user_id, 'user', 'fullname'); $action = $code.' reset Password '; $this->Crud->activity('authentication', $user_id, $action, $user_id); $this->session->set('fl_code', ''); $this->session->set('fl_email', ''); echo '<script>window.location.replace("'.site_url('auth').'");</script>'; } else { echo $this->Crud->msg('info', 'No Changes..!'); } } } die; } } $data['current_language'] = $this->session->get('current_language'); $data['title'] = translate_phrase('Reset Password').' - '.app_name; return view('auth/forgot', $data); } /////////////Check if Email Exist//////////////////// public function check_email() { $email = $this->request->getVar('email'); if($email) { if($this->Crud->check('email', $email, 'user') <= 0) { echo '<span class="text-success small">Email Available</span>'; } else { echo '<span class="text-danger small">Email Taken</span>'; } die; } } //////////////Check if Password Matchs//////////////////////////// public function check_password($param1 = '', $param2 = '') { if($param1 && $param2) { if($param1 == $param2) { echo '<span class="text-success small">Password Matched</span>'; } else { echo '<span class="text-danger small">Password Not Matched</span>'; } die; } } public function verify_email($id) { if($id) { if($this->Crud->updates('id', $id, 'user', array('activate'=>1)) > 0) { echo '<br><span class="text-success">Account Verified. Please login.</span>'; // send welcome email $subject = 'Welcome'; $fullname = $this->Crud->read_field('id', $id, 'user', 'fullname'); $email = $this->Crud->read_field('id', $id, 'user', 'email'); $role_id = $this->Crud->read_field('id', $id, 'user', 'role_id'); $role = $this->Crud->read_field('id', $role_id, 'access_role', 'name'); $state_id = $this->Crud->read_field('id', $id, 'user', 'state_id'); $state = $this->Crud->read_field('id', $state_id, 'state', 'name'); $body = ''; // send to customer if($role == 'Customer') { $body = ' <h2>Hi Highly Valued Customer, <b>'.$fullname.'</b></h2> <p>Welcome to <b>'.app_name.'</b>! We are thrilled to have you on board, and we believe you have made the best choice for your fuel delivery needs.</p> <p>Be assured that your experience with us is safe, reliable, and convenient. Our user-friendly app makes it easy to order fuel at the click of a button, ensuring that quality fuel is delivered fast and directly to your exact location.</p> <p>Here is what you can do on our platform:</p> <ul> <li>Order premium fuel at competitive prices</li> <li>Track your delivery in real-time</li> </ul> <p><a href="'.site_url().'" class="button">Visit Our Website</a></p> <p>Explore our website and app to get started. If you have any questions about your order or our services, our team is here to help. We look forward to providing you with the best fuel delivery experience!</p> <b>Management</b><br/> <i>Signed</i><br/> <a href="'.app_website.'"><b>'.app_name.'</b></a> '; } if($body != '') { $this->Crud->send_email($email, $subject, $body); } return redirect()->to(site_url('auth/login')); } else { echo '<span class="text-danger">Verification Failed! Please try later.</span>'; } } die; } ///// LOGOUT public function logout() { $user_id = $this->session->get('hdt_id'); if(empty($user_id)){ $user_id = 0; } ///// store activities $code = $this->Crud->read_field('id', $user_id, 'user', 'fullname'); $action = $code.' logged out'; $this->Crud->activity('authentication', $user_id, $action, $user_id); if(!empty($this->session->get('hdt_id'))) $this->session->remove('hdt_id'); return redirect()->to(site_url('login')); } ////////////Profile//////////////////////////// public function profile($param1='', $param2='') { // check login $log_id = $this->session->get('hdt_id'); if(empty($log_id)) return redirect()->to(site_url('auth')); $role_id = $this->Crud->read_field('id', $log_id, 'user', 'role_id'); $role = strtolower($this->Crud->read_field('id', $role_id, 'access_role', 'name')); $main_email = $this->Crud->read_field('id', $log_id, 'user', 'email'); $data['log_id'] = $log_id; $data['role'] = $role; if($param1 == 'update'){ if($this->request->getMethod() == 'post') { $email = $this->request->getVar('email'); $fullname = $this->request->getVar('firstname').' '.$this->request->getVar('surname'); $phone = $this->request->getVar('phone'); $lga_id = $this->request->getVar('lga_id'); $address = $this->request->getVar('address'); $state_id = $this->request->getVar('state_id'); $img_id = $this->request->getVar('img_id'); if(!$email || !$fullname) { echo $this->Crud->msg('danger', 'Full Name and Email field(s) missing'); die; } if(empty($phone)) {echo $this->Crud->msg('danger', 'Enter Phone Number');} if($email != $main_email) { if($this->Crud->check('email', $email, 'user') > 0) { echo $this->Crud->msg('danger', 'Email already taken, try another'); die; } } //// Image upload if(file_exists($this->request->getFile('avatar'))) { $path = 'assets/images/users/'.$log_id.'/'; $file = $this->request->getFile('avatar'); $getImg = $this->Crud->img_upload($path, $file); if(!empty($getImg->path)) $img_id = $this->Crud->save_image($log_id, $getImg->path); if($role == 'merchant'){ $img_id = $getImg->path; } } $state = $this->Crud->read_field('name', $state_id, 'state', 'id'); $lga = $this->Crud->read_field('name', $lga_id, 'city', 'id'); // update profile $upd_data['email'] = $email; $upd_data['fullname'] = $fullname; $upd_data['phone'] = $phone; $upd_data['lga_id'] = $lga; $upd_data['address'] = $address; $upd_data['state_id'] = $state; if($role == 'merchant'){ $upd_data['logo'] = $img_id; } else { $upd_data['img_id'] = $img_id; } if($this->Crud->updates('id', $log_id, 'user', $upd_data) > 0) { echo $this->Crud->msg('success', 'Record Updated'); $code = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = $code.' Updated Account Profile Information '; $this->Crud->activity('authentication', $log_id, $action); echo '<script>location.reload(false);</script>'; } else { echo $this->Crud->msg('info', 'No Changes'); } die; } } if($param1 == 'reset_password'){ if($this->request->getMethod() == 'post') { $current_password = $this->request->getVar('current_password'); $new_password = $this->request->getVar('new_password'); if($this->Crud->check2('id', $log_id, 'password', md5($current_password) , 'user') == 0){ echo $this->Crud->msg('info', 'Incorrect Password'); } else { $upd = $this->Crud->updates('id', $log_id, 'user', array('password'=>md5($new_password))); if($upd > 0){ echo $this->Crud->msg('success', 'Password Updated!!'); $code = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = $code.' Updated Account Password'; $this->Crud->activity('authentication', $log_id, $action); echo '<script>location.reload(false);</script>'; } else { echo $this->Crud->msg('info', 'No Changes!!'); } } die; } } if($param1 == 'reset_pin'){ if($this->request->getMethod() == 'post') { $password = $this->request->getVar('password'); $otp = $this->request->getVar('otp'); $pin = $this->request->getVar('pin'); if($this->Crud->check2('id', $log_id, 'reset', $otp , 'user') == 0){ echo $this->Crud->msg('info', 'Invalid OTP. Try Again'); } else { if($this->Crud->check2('id', $log_id, 'password', md5($password) , 'user') == 0){ echo $this->Crud->msg('info', 'Incorrect Password'); } else{ $upd = $this->Crud->updates('id', $log_id, 'user', array('pin'=>$pin, 'reset'=>'')); if($upd > 0){ echo $this->Crud->msg('success', 'Transaction Pin Updated!!'); $code = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = $code.' Updated Account Transaction Pin'; $this->Crud->activity('authentication', $log_id, $action); echo '<script>location.reload(false);</script>'; } else { echo $this->Crud->msg('info', 'No Changes!!'); } } } die; } } $data['email'] = $this->Crud->read_field('id', $log_id, 'user', 'email'); $data['fullname'] = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $lga_id = $this->Crud->read_field('id', $log_id, 'user', 'lga_id'); $data['city'] = $this->Crud->read_field('id', $lga_id, 'city', 'name'); $data['phone'] = $this->Crud->read_field('id', $log_id, 'user', 'phone'); $data['address'] = $this->Crud->read_field('id', $log_id, 'user', 'address'); $state_id = $this->Crud->read_field('id', $log_id, 'user', 'state_id'); $data['state'] = $this->Crud->read_field('id', $state_id, 'state', 'name'); $data['country_id'] = $this->Crud->read_field('id', $log_id, 'user', 'country_id'); $img_id = $this->Crud->read_field('id', $log_id, 'user', 'img_id'); $logo = $this->Crud->read_field('id', $log_id, 'user', 'logo'); $data['state_id'] = $state_id; $data['lga_id'] = $lga_id; $data['img_id'] = $img_id; if(!empty($logo)){ $data['img'] = $logo; } else { $data['img'] = $this->Crud->image($img_id, 'big'); } $fullname = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $data['title'] = 'Profile - '.app_name; $data['page_active'] = 'profile'; return view('auth/profile', $data); } public function referral($referral_code){ // Check if the referral ID exists in the database $referrer_id = $this->Crud->read_field('referral_code', $referral_code, 'user', 'id'); if ($referrer_id) { // Store referral ID in session $this->session->set('referral_id', $referrer_id); // Redirect to the registration page with referral ID return redirect()->to('/auth/register'); } else { $this->session->set('referral_id', ''); // If referral ID is invalid, redirect to register without referral return redirect()->to('/auth/register'); } } ////////////Change Password//////////////////////////// public function password() { // check login $log_id = $this->session->get('hdt_id'); if(empty($log_id)) return redirect()->to(site_url('auth')); $data['log_id'] = $log_id; if($this->request->getMethod() == 'post') { $old = $this->request->getVar('old'); $new = $this->request->getVar('new'); $confirm = $this->request->getVar('confirm'); if($this->Crud->check2('id', $log_id, 'password', md5($old), 'user') <= 0) { echo $this->Crud->msg('danger', 'Current Password not correct'); } else { if($new != $confirm) { echo $this->Crud->msg('info', 'New and Confirm Password not matched'); } else { if($this->Crud->updates('id', $log_id, 'user', array('password'=>md5($new))) > 0) { echo $this->Crud->msg('success', 'Password changed successfully'); } else { echo $this->Crud->msg('danger', 'Please try later'); } } } die; } $data['title'] = 'Change Password - '.app_name; $data['page_active'] = 'profile'; return view('profile/password', $data); } /////////////Get state from Country//////////////////// public function get_state($country_id) { $states = ''; $state_id = $this->request->getGet('state_id'); $all_states = $this->Crud->read_single_order('country_id', $country_id, 'state', 'name', 'asc'); if(!empty($all_states)) { foreach($all_states as $as) { $s_sel = ''; if(!empty($state_id)) if($state_id == $as->id) $s_sel = 'selected'; $states .= '<option value="'.$as->id.'" '.$s_sel.'>'.$as->name.'</option>'; } } echo $states; die; } public function get_city($state_id) { $states = ''; $all_states = $this->Crud->read_single_order('state_id', $state_id, 'city', 'name', 'asc'); if($state_id == 'all'){ $all_states = $this->Crud->read_order('city', 'name', 'asc'); } if(!empty($all_states)) { foreach($all_states as $as) { $s_sel = ''; $states .= '<option value="'.$as->id.'" '.$s_sel.'>'.$as->name.'</option>'; } } echo $states; die; } public function get_territory($state_id) { $states = ''; $all_states = $this->Crud->read_single_order('state_id', $state_id, 'territory', 'name', 'asc'); if(!empty($all_states)) { foreach($all_states as $as) { $s_sel = ''; $states .= '<option value="'.$as->id.'" '.$s_sel.'>'.$as->name.'</option>'; } } echo $states; die; } public function language($lang_id){ if(!empty($lang_id)){ $lang = $this->Crud->read_field('id', $lang_id, 'language_code', 'name'); $this->session->set('current_language', $lang); echo '<script>location.reload(false);</script>'; } } //////////////////////Manage Users/////////////////////////// public function users($param1='', $param2='', $param3='') { // check session login if($this->session->get('hdt_id') == ''){ $request_uri = uri_string(); $this->session->set('kgf_redirect', $request_uri); return redirect()->to(site_url('auth')); } else { $log_id = $this->session->get('hdt_id'); $role_id = $this->Crud->read_field('id', $log_id, 'user', 'role_id'); $role = strtolower($this->Crud->read_field('id', $role_id, 'access_role', 'name')); $role_c = $this->Crud->module($role_id, 'users', 'create'); $role_r = $this->Crud->module($role_id, 'users', 'read'); $role_u = $this->Crud->module($role_id, 'users', 'update'); $role_d = $this->Crud->module($role_id, 'users', 'delete'); if($role_r == 0){ return redirect()->to(site_url('dashboard')); } $data['role'] = $role; $data['role_c'] = $role_c; } $table = 'user'; $form_link = site_url('auth/users'); if($param1){$form_link .= '/'.$param1;} if($param2){$form_link .= '/'.$param2.'/';} if($param3){$form_link .= $param3;} $data['user_id'] = $log_id; $data['role_id'] = $role_id; // pass parameters to view $data['param1'] = $param1; $data['param2'] = $param2; $data['param3'] = $param3; $data['form_link'] = $form_link; // manage record if($param1 == 'manage') { // prepare for delete if($param2 == 'delete') { if($param3) { $edit = $this->Crud->read_single('id', $param3, $table); //echo var_dump($edit); if(!empty($edit)) { foreach($edit as $e) { $data['d_id'] = $e->id; } } if($this->request->getMethod() == 'post'){ $del_id = $this->request->getVar('d_user_id'); if($this->Crud->deletes('id', $del_id, $table) > 0) { echo $this->Crud->msg('success', 'Record Deleted'); echo '<script>location.reload(false);</script>'; } else { echo $this->Crud->msg('danger', 'Please try later'); } die; } } } else { // prepare for edit if($param2 == 'edit') { if($param3) { $edit = $this->Crud->read_single('id', $param3, $table); if(!empty($edit)) { foreach($edit as $e) { $data['e_id'] = $e->id; $data['e_activate'] = $e->activate; $data['e_role_id'] = $e->role_id; } } } } //profile view if($param2 == 'profile') { $vendor_id = $param3; $data['v_id'] = $vendor_id; $data['v_name'] = $this->Crud->read_field('id', $vendor_id, 'user', 'fullname'); $data['v_phone'] = $this->Crud->read_field('id', $vendor_id, 'user', 'phone'); $data['v_email'] = $this->Crud->read_field('id', $vendor_id, 'user', 'email'); $v_img_id = $this->Crud->read_field('id', $vendor_id, 'user', 'img_id'); $data['v_img'] = base_url($this->Crud->image($v_img_id, 'big')); $v_status = $this->Crud->read_field('id', $vendor_id, 'user', 'activate'); if(!empty($v_status)) { $v_status = '<span class="text-success">VERIFIED</span>'; } else { $v_status = '<span class="text-danger">UNVERIFIED</span>'; } $data['v_status'] = $v_status; $data['v_address'] = $this->Crud->read_field('id', $vendor_id, 'user', 'address'); $v_state_id = $this->Crud->read_field('id', $vendor_id, 'user', 'state_id'); $data['v_state'] = $this->Crud->read_field('id', $v_state_id, 'state', 'name'); $v_country_id = $this->Crud->read_field('id', $vendor_id, 'user', 'country_id'); $data['v_country'] = $this->Crud->read_field('id', $v_country_id, 'country', 'name'); } if($this->request->getMethod() == 'post'){ $user_i = $this->request->getVar('user_id'); $activate = $this->request->getVar('activate'); $role_id = $this->request->getVar('role_id'); // do create or update if($user_i) { $upd_data = array( 'activate' => $activate, 'role_id' => $role_id ); $upd_rec = $this->Crud->updates('id', $user_i, $table, $upd_data); if($upd_rec > 0) { echo $this->Crud->msg('success', 'Updated'); echo '<script>location.reload(false);</script>'; } else { echo $this->Crud->msg('info', 'No Changes'); } die; } } } } // record listing if($param1 == 'load') { $limit = $param2; $offset = $param3; $rec_limit = 25; $item = ''; if(empty($limit)) {$limit = $rec_limit;} if(empty($offset)) {$offset = 0;} if(!empty($this->request->getPost('state_id'))) { $state_id = $this->request->getPost('state_id'); } else { $state_id = ''; } if(!empty($this->request->getPost('status'))) { $status = $this->request->getPost('status'); } else { $status = ''; } $search = $this->request->getPost('search'); //echo $search; $log_id = $this->session->get('hdt_id'); if(!$log_id) { $item = '<div class="text-center text-muted">Session Timeout! - Please login again</div>'; } else { $all_rec = $this->Crud->filter_user('', '', $log_id, $state_id, $status, $search); if(!empty($all_rec)) { $counts = count($all_rec); } else { $counts = 0; } $query = $this->Crud->filter_user($limit, $offset, $log_id, $state_id, $status, $search); if(!empty($query)) { foreach($query as $q) { $id = $q->id; $fullname = $q->fullname; $email = $q->email; $phone = $q->phone; $address = $q->address; $state = $this->Crud->read_field('id', $q->state_id, 'state', 'name'); $img = $this->Crud->image($q->img_id, 'big'); $activate = $q->activate; $u_role = $this->Crud->read_field('id', $q->role_id, 'access_role', 'name'); $reg_date = date('M d, Y h:i A', strtotime($q->reg_date)); $approved = ''; if($activate == 1) { $color = 'success'; $approve_text = 'Account Activated'; $approved = '<span class="text-primary"><i class="ri-check-circle-line"></i></span> '; } else { $color = 'danger'; $approve_text = 'Account Deactivated'; } // add manage buttons if($role_u != 1) { $all_btn = ''; } else { $all_btn = ' <div class="text-right"> <a href="javascript:;" class="text-primary pop" pageTitle="Manage '.$fullname.'" pageName="'.base_url('auth/users/manage/edit/'.$id).'"> <i class="ri-ball-pen-line"></i> Edit </a><br/><br/> <a href="javascript:;" class="text-danger pop" pageTitle="Delete '.$fullname.'" pageName="'.base_url('auth/users/manage/delete/'.$id).'"> <i class="ri-delete-bin-4-line"></i> Delete </a> </div> '; } $item .= ' <li class="list-group-item"> <div class="row pt-7"> <div class="col-3 col-md-1"> <img alt="" src="'.site_url($img).'" class="avatar-md rounded-circle img-thumbnail" /> </div> <div class="col-9 col-sm-3 col-md-3 mb-2" > <div class="single"> <div class="text-muted" style="font-size: 12px;">'.$reg_date.'</div> <b class="text-primary" style="font-size: 16px;"><a href="javascript:;" class="text-primary pop" pageTitle="'.$fullname.' Profile" pageName="'.base_url('auth/users/manage/profile/'.$id).'" pageSize="modal-lg">'.strtoupper($fullname).'</a> </b> </div> </div> <div class="col-12 col-sm-4 col-md-4 mb-1"> <div class="text-muted font-size-12">'.strtoupper($u_role).'</div> <div class="font-size-14" style="font-size:14px"> '.$email.'<br> <span class="text-danger font-size-12">'.$phone.'</span> </div> </div> <div class="col-12 col-sm-3 col-md-3 mb-1"> <div class="font-size-14" style="font-size:14px"> '.$address.' <div><b>'.$state.'</b></div> </div> </div> <div class="col-12 col-sm-1 col-md-1" align="right"> <b class="font-size-12">'.$all_btn.'</b> </div> </div> </li> '; } } } if(empty($item)) { $resp['item'] = ' <div class="text-center text-muted"> <br/><br/><br/><br/> <i class="ri-team-line" style="font-size:150px;"></i><br/><br/>No User Returned </div> '; } else { $resp['item'] = $item; } $resp['count'] = $counts; $more_record = $counts - ($offset + $rec_limit); $resp['left'] = $more_record; if($counts > ($offset + $rec_limit)) { // for load more records $resp['limit'] = $rec_limit; $resp['offset'] = $offset + $limit; } else { $resp['limit'] = 0; $resp['offset'] = 0; } echo json_encode($resp); die; } if($param1 == 'manage') { // view for form data posting $data['page_active'] = 'users'; return view('auth/user_form', $data); } else { // view for main page // for datatable //$data['table_rec'] = 'auth/users/list'; // ajax table //$data['order_sort'] = '0, "asc"'; // default ordering (0, 'asc') //$data['no_sort'] = '5,6'; // sort disable columns (1,3,5) $data['title'] = 'Users - '.app_name; $data['page_active'] = 'users'; return view('auth/user', $data); } } public function tezt(){ $fullname = 'aDmin'; $email = 'Kennethjames23@yahoo.com'; $phone = '07031549500'; // Get API Key and Email Config from DB $api_key = $this->Crud->read_field('name', 'termil_api', 'setting', 'value'); $email_config = $this->Crud->read_field('name', 'termii_email_config', 'setting', 'value'); $activation_code = '123456'; // Send OTP via SMS if ($phone) { $phone = '234' . substr($phone, 1); $sms_data = [ 'api_key' => $api_key, 'to' => $phone, 'from' => 'N-Alert', 'sms' => "Your ".app_name ." activation code is: $activation_code", 'type' => 'plain', 'channel' => 'dnd' ]; echo $this->Crud->termii('post', 'sms/send', $sms_data); } // Send OTP via WhatsApp if ($phone) { $phone = '234' . substr($phone, 1); $whatsapp_data = [ 'api_key' => $api_key, 'to' => $phone, 'from' => 'N-Alert', 'sms' => $activation_code, 'type' => 'plain', 'channel' => 'WhatsApp_otp' ]; echo $this->Crud->termii('post', 'sms/send', $whatsapp_data); } // Send OTP via Email if ($email) { $email_data = [ 'email_address' => $email, 'api_key' => $api_key, 'email_configuration_id' => $email_config, 'code' => $activation_code ]; echo $this->Crud->termii('post', 'email/otp/send', $email_data); } } }
Upload File
Create Folder