diff --git a/DB/golf.sql b/DB/golf.sql new file mode 100644 index 0000000..fe4abd3 --- /dev/null +++ b/DB/golf.sql @@ -0,0 +1,473 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.0 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: May 16, 2023 at 02:05 PM +-- Server version: 10.4.27-MariaDB +-- PHP Version: 7.4.33 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `golf` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `cart` +-- + +CREATE TABLE `cart` ( + `id` int(11) NOT NULL, + `member_id` int(11) NOT NULL, + `pack_id` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `city` +-- + +CREATE TABLE `city` ( + `id` int(11) NOT NULL, + `state_id` int(11) NOT NULL, + `name` varchar(20) NOT NULL, + `is_active` int(11) NOT NULL DEFAULT 1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `city` +-- + +INSERT INTO `city` (`id`, `state_id`, `name`, `is_active`) VALUES +(1, 1, 'Chennai', 1), +(2, 2, 'Cochin', 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `country` +-- + +CREATE TABLE `country` ( + `id` int(11) NOT NULL, + `name` varchar(50) NOT NULL, + `is_active` int(11) NOT NULL DEFAULT 1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `country` +-- + +INSERT INTO `country` (`id`, `name`, `is_active`) VALUES +(1, 'India', 1), +(2, 'Canada', 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `email_template` +-- + +CREATE TABLE `email_template` ( + `id` int(11) NOT NULL, + `name` varchar(50) NOT NULL, + `type` int(10) NOT NULL, + `text` mediumtext NOT NULL, + `html` mediumtext NOT NULL, + `to` varchar(50) NOT NULL, + `subject` varchar(255) NOT NULL, + `is_active` int(11) NOT NULL DEFAULT 1, + `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `created_by` int(11) NOT NULL, + `updated_by` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `email_template` +-- + +INSERT INTO `email_template` (`id`, `name`, `type`, `text`, `html`, `to`, `subject`, `is_active`, `created_at`, `updated_at`, `created_by`, `updated_by`) VALUES +(6, 'demo', 1, '', '
Hi\n%to%\n!\n
\n\n \n \n \n \n \n \n \n \n \n \n \n Thank\n
', 'demo@g.com', 'demo', 1, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `email_template_variables` +-- + +CREATE TABLE `email_template_variables` ( + `id` int(11) NOT NULL, + `type` int(10) NOT NULL, + `name` varchar(50) NOT NULL, + `variable_name` varchar(50) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `email_template_variables` +-- + +INSERT INTO `email_template_variables` (`id`, `type`, `name`, `variable_name`) VALUES +(1, 1, 'Member Name', '%name%'), +(2, 1, 'Verify Link', '%link%'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `member` +-- + +CREATE TABLE `member` ( + `id` int(11) NOT NULL, + `name` varchar(50) NOT NULL, + `email` varchar(50) NOT NULL, + `is_email_verified` int(11) NOT NULL DEFAULT 0, + `mobile` varchar(12) NOT NULL, + `address` varchar(50) NOT NULL, + `city` varchar(50) NOT NULL, + `state` varchar(50) NOT NULL, + `country` varchar(50) NOT NULL, + `pincode` int(10) NOT NULL, + `username` varchar(50) NOT NULL, + `password` varchar(100) NOT NULL, + `verification_code` int(10) NOT NULL, + `is_active` int(11) NOT NULL DEFAULT 1, + `created_by` int(11) NOT NULL, + `updated_by` int(11) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `member` +-- + +INSERT INTO `member` (`id`, `name`, `email`, `is_email_verified`, `mobile`, `address`, `city`, `state`, `country`, `pincode`, `username`, `password`, `verification_code`, `is_active`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES +(4, 'Gowthaman', 'gwm@gmail.com', 1, '9894638731', '1st st', '1', '1', '1', 650001, '', '$2y$10$XJD4E81SQtf7XaHZdCVJa.VA/FL1/4OIsL7ZDR1t7M1QnzQ87jb7K', 0, 1, 0, 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00'), +(5, 'test', 'test@gmail.com', 0, '9500625731', 'Bank Suruliyappan street', '1', '1', '1', 625528, '', '$2y$10$pa8XhW/xFapidAaFA7Zd1eDZMr4SxBGpHXCaJAh0fYH7ej6Ns3UUC', 0, 1, 0, 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00'), +(6, 'Jeeva', 'gowtham.manavalan.la@gmail.com', 1, '9500625731', 'Bank Suruliyappan street', '2', '2', '1', 625528, '', '$2y$10$imlV3IVeMxcb6JiF/yIqDuTrqXq7SEO7N4G9H74xuwTxAKGFUOqt.', 787918, 1, 0, 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00'), +(69, 'suseendhiran', 'suseendhiran13@gmail.com', 0, '7777777777', '1st street', 'Chennai', 'Tamil Nadu', '1', 656789, '', '', 958737, 1, 0, 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `member_credits` +-- + +CREATE TABLE `member_credits` ( + `id` int(11) NOT NULL, + `member_id` int(11) DEFAULT NULL, + `package_name` varchar(50) DEFAULT NULL, + `package_type` varchar(50) DEFAULT NULL, + `credit_points` int(11) DEFAULT NULL, + `running_balance` int(11) DEFAULT NULL, + `used_points` int(11) NOT NULL, + `expired_points` int(11) DEFAULT NULL, + `expiring_date` date DEFAULT NULL, + `cost` int(11) DEFAULT NULL, + `is_active` int(11) DEFAULT 1, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + `updated_at` timestamp NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `member_credits` +-- + +INSERT INTO `member_credits` (`id`, `member_id`, `package_name`, `package_type`, `credit_points`, `running_balance`, `used_points`, `expired_points`, `expiring_date`, `cost`, `is_active`, `created_at`, `updated_at`) VALUES +(11, 4, 'Evo Pack 2', 'Regular', 40, 0, 40, 0, '2023-06-11', 1000, 1, '2023-05-11 09:28:21', '2023-05-11 09:28:21'), +(12, 4, 'Evo Pack 1', 'Presales', 24, 0, 24, 0, '2023-06-11', 550, 1, '2023-05-11 09:28:22', '2023-05-11 09:28:22'), +(13, 4, 'Evo Pack 2', 'Presales', 48, 40, 8, 0, '2023-06-11', 1000, 1, '2023-05-11 09:33:47', '2023-05-11 09:33:47'), +(14, 4, 'Evo Pack 2', 'Presales', 48, 48, 0, 0, '2023-06-11', 1000, 1, '2023-05-11 09:53:51', '2023-05-11 09:53:51'), +(15, 4, 'Evo Pack 1', 'Presales', 24, 24, 0, 0, '2023-06-11', 550, 1, '2023-05-11 09:53:52', '2023-05-11 09:53:52'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `packages_and_pricing` +-- + +CREATE TABLE `packages_and_pricing` ( + `id` int(11) NOT NULL, + `package_name` varchar(50) DEFAULT NULL, + `package_type` varchar(50) DEFAULT NULL, + `credit` int(11) DEFAULT NULL, + `cost` int(11) DEFAULT NULL, + `is_active` int(11) NOT NULL DEFAULT 1, + `created_by` int(11) DEFAULT NULL, + `updated_by` int(11) DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `packages_and_pricing` +-- + +INSERT INTO `packages_and_pricing` (`id`, `package_name`, `package_type`, `credit`, `cost`, `is_active`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES +(3, 'Evo Pack 1', 'Regular', 20, 550, 1, 1, NULL, '2023-05-08 11:27:10', '2023-05-08 16:57:10'), +(4, 'Evo Pack 2', 'Regular', 40, 1000, 1, 1, NULL, '2023-05-08 11:27:10', '2023-05-08 16:57:10'), +(6, 'Evo Pack 1', 'Presales', 24, 550, 1, NULL, NULL, '2023-05-11 09:12:43', '2023-05-11 14:42:43'), +(7, 'Evo Pack 2', 'Presales', 48, 1000, 1, NULL, NULL, '2023-05-11 09:12:43', '2023-05-11 14:42:43'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `simulator` +-- + +CREATE TABLE `simulator` ( + `id` int(11) NOT NULL, + `type` varchar(50) NOT NULL, + `is_active` int(11) NOT NULL DEFAULT 1, + `created_by` int(11) NOT NULL, + `updated_by` int(11) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `slot` +-- + +CREATE TABLE `slot` ( + `id` int(11) NOT NULL, + `member_id` int(11) NOT NULL, + `slot_time` time NOT NULL, + `slot_date` date NOT NULL, + `is_active` int(11) NOT NULL DEFAULT 1, + `created_by` int(11) NOT NULL, + `updated_by` int(11) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `state` +-- + +CREATE TABLE `state` ( + `id` int(11) NOT NULL, + `country_id` int(11) NOT NULL, + `name` varchar(50) NOT NULL, + `is_active` int(11) NOT NULL DEFAULT 1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `state` +-- + +INSERT INTO `state` (`id`, `country_id`, `name`, `is_active`) VALUES +(1, 1, 'Tamilnadu', 1), +(2, 1, 'Kerala', 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `id` int(11) NOT NULL, + `role` varchar(50) DEFAULT NULL, + `name` varchar(100) DEFAULT NULL, + `profile` varchar(50) NOT NULL, + `email` varchar(155) DEFAULT NULL, + `address` varchar(255) NOT NULL, + `city` varchar(50) NOT NULL, + `state` varchar(50) NOT NULL, + `country` varchar(50) NOT NULL, + `pincode` int(10) NOT NULL, + `mobile` varchar(12) DEFAULT NULL, + `is_active` int(11) DEFAULT 1, + `user_name` varchar(100) DEFAULT NULL, + `password` varchar(100) DEFAULT NULL, + `created_by` int(11) DEFAULT NULL, + `updated_by` int(11) DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`id`, `role`, `name`, `profile`, `email`, `address`, `city`, `state`, `country`, `pincode`, `mobile`, `is_active`, `user_name`, `password`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES +(1, 'Admin', 'Admin', 'profile.jpg', 'admin@gmail.com', '1st street', '1', '1', '1', 656787, '986668877', 1, 'admin@gmail.com', '$2y$10$XJD4E81SQtf7XaHZdCVJa.VA/FL1/4OIsL7ZDR1t7M1QnzQ87jb7K', 0, NULL, '2023-05-03 16:30:22', '2023-05-03 16:30:22'), +(2, 'Admin', 'Gowtham', '', 'gwm@gmail.com', '131 ', '1', '1', '1', 652500, '6565656565', 0, NULL, NULL, NULL, NULL, '2023-05-06 12:06:31', '2023-05-06 12:06:31'), +(3, 'Coach', 'Jeeva', '', 'suseendhiran13@gmail.com', '', '2', '2', '1', 0, '986532365', 1, NULL, '$2y$10$U8q1UrDyFf30vpeWlymhf.ViELXqahqfG5JPKPdEQ4hdF8zSzdpbe', NULL, NULL, '2023-05-06 15:16:29', '2023-05-06 15:16:29'), +(4, 'Admin', 'Gowtham 0045', '', 'gowtham.manavalan.la@gmail.com', '', '1', '1', '1', 0, '09500625731', 1, NULL, '$2y$10$UHEtYAei5PoAteL6b0Fm/e7x94Kr8QmQyFHFcW6wq35juNqKvhyN2', NULL, NULL, '2023-05-06 16:24:23', '2023-05-06 16:24:23'), +(5, 'Coach', 'Susee', '', 'suss@gmail.com', 'Bank Suruliyappan street', '1', '1', '1', 625528, '9500625731', 1, NULL, '$2y$10$lNtNgQXFNWCYwyGwMUaYmOpE1MuLUShNvtl9hf5CAf5VEJRyDxDwa', NULL, NULL, '2023-05-08 13:02:43', '2023-05-08 13:02:43'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `cart` +-- +ALTER TABLE `cart` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `city` +-- +ALTER TABLE `city` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `country` +-- +ALTER TABLE `country` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `email_template` +-- +ALTER TABLE `email_template` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `email_template_variables` +-- +ALTER TABLE `email_template_variables` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `member` +-- +ALTER TABLE `member` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `member_credits` +-- +ALTER TABLE `member_credits` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `packages_and_pricing` +-- +ALTER TABLE `packages_and_pricing` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `simulator` +-- +ALTER TABLE `simulator` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `slot` +-- +ALTER TABLE `slot` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `state` +-- +ALTER TABLE `state` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `cart` +-- +ALTER TABLE `cart` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; + +-- +-- AUTO_INCREMENT for table `city` +-- +ALTER TABLE `city` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + +-- +-- AUTO_INCREMENT for table `country` +-- +ALTER TABLE `country` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + +-- +-- AUTO_INCREMENT for table `email_template` +-- +ALTER TABLE `email_template` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; + +-- +-- AUTO_INCREMENT for table `email_template_variables` +-- +ALTER TABLE `email_template_variables` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + +-- +-- AUTO_INCREMENT for table `member` +-- +ALTER TABLE `member` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=70; + +-- +-- AUTO_INCREMENT for table `member_credits` +-- +ALTER TABLE `member_credits` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; + +-- +-- AUTO_INCREMENT for table `packages_and_pricing` +-- +ALTER TABLE `packages_and_pricing` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; + +-- +-- AUTO_INCREMENT for table `simulator` +-- +ALTER TABLE `simulator` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `slot` +-- +ALTER TABLE `slot` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `state` +-- +ALTER TABLE `state` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/app/Config/Routes.php b/app/Config/Routes.php index fe4db8e..9556364 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -74,6 +74,12 @@ $routes->match(['get','post'],'/user_activate/(:any)','Admin_controller::user_ac $routes->match(['get'],'/transactions_list/(:any)','Admin_controller::transactions_list/$1'); $routes->match(['get'],'/transactions_list','Admin_controller::transactions_list'); $routes->match(['get','post'],'/user_forgot_password','Admin_controller::user_forgot_password'); +$routes->match(['get','post'],'/template_list','Admin_controller::template_list'); +$routes->match(['get','post'],'/email_temp','Admin_controller::email_temp'); +$routes->match(['get','post'],'/edit_email_temp/(:any)','Admin_controller::edit_email_temp/$1'); +$routes->match(['get','post'],'/mail_temp_deactivate/(:any)','Admin_controller::mail_temp_deactivate/$1'); +$routes->match(['get','post'],'/mail_temp_activate/(:any)','Admin_controller::mail_temp_activate/$1'); + diff --git a/app/Controllers/Admin_controller.php b/app/Controllers/Admin_controller.php index 97970be..145cdcb 100644 --- a/app/Controllers/Admin_controller.php +++ b/app/Controllers/Admin_controller.php @@ -7,6 +7,8 @@ use App\Models\Common_model; use App\Models\Member_credits_model; use App\Models\Packages_and_pricing_model; use App\Models\Credits_usage_tracking_model; +use App\Models\Email_template_model; +use App\Models\Variable_model; class Admin_controller extends BaseController { public $session; @@ -19,6 +21,8 @@ class Admin_controller extends BaseController $this->creditsModel = new Member_credits_model(); $this->PackagesModel = new Packages_and_pricing_model(); $this->CreditsUsageTrackingModel = new Credits_usage_tracking_model(); + $this->MailModel = new Email_template_model(); + $this->VariableModel = new Variable_model(); helper(['form', 'url']); } public function index() @@ -49,7 +53,7 @@ class Admin_controller extends BaseController } }else { - $this->session->setTempdata('error','sorry Email does not existe',3); + $this->session->setTempdata('error','sorry Email does not exist',3); return redirect()->to(base_url()."/admin"); } } @@ -151,18 +155,14 @@ class Admin_controller extends BaseController public function user_deactivate($id = null) { - $this->UserModel->where('md5(id)', $id )->set(array( 'is_active' => 0))->update(); return redirect()->to(base_url()."users_list"); - } public function user_activate($id = null) { - $this->UserModel->where('md5(id)', $id )->set(array( 'is_active' => 1))->update(); return redirect()->to(base_url()."users_list"); - } @@ -285,9 +285,19 @@ class Admin_controller extends BaseController $data = $this->UserModel->where('id', $this->request->getVar('id') )->find(); if (password_verify($old_password ,$data[0]['password'])) { - $this->UserModel->where('id', $this->request->getVar('id') )->set($UserData)->update(); - $this->session->setTempdata('mail_success',"Password changed successfully",3); - return redirect()->to(base_url()."admin"); + $user_data = $this->UserModel->where('id', $this->request->getVar('id') )->set($UserData)->update(); + if ($user_data) + { + $sendmail_controller = new Sendmail_controller(); + $get_data = $sendmail_controller->index($this->request->getVar('email') , null , 4 ); + $this->session->setTempdata('mail_success',"Password changed successfully",3); + return redirect()->to(base_url()."admin"); + } + else + { + $this->session->setTempdata('error',"Entered wrong old password",3); + return redirect()->to(base_url()."user_password_change"); + } } else { @@ -298,7 +308,7 @@ class Admin_controller extends BaseController $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); echo view('layout/header',$userdata); - echo view('users_password'); + echo view('users_password',$userdata); echo view('layout/footer'); } @@ -347,7 +357,8 @@ class Admin_controller extends BaseController if ($user_data) { $otp = rand(1000 , 9999); - $this->index($this->request->getVar('email') , $otp , 2 ); + $sendmail_controller = new Sendmail_controller(); + $sendmail_controller->index($this->request->getVar('email') , $otp , 2 ); $data['status'] = 'success'; $data['otp'] = $otp; echo json_encode($data); @@ -361,5 +372,85 @@ class Admin_controller extends BaseController } } + public function template_list() + { + if($this->request->getmethod() == 'get') + { + $userdata['template_data'] = $this->MailModel->findAll(); + $userdata['userdata'] = $this->dModel->getLoggedInUserData(session()->get('logged_user')); + echo view('layout/header',$userdata); + echo view('email_template_list.php'); + echo view('layout/footer'); + } + } + + public function email_temp() + { + if($this->request->getmethod() == 'get') + { + echo view('email.template.php'); + } + else if($this->request->getmethod() == 'post') + { + $data['name'] = $this->request->getVar('name'); + $data['to'] = $this->request->getVar('to'); + $data['subject'] = $this->request->getVar('subject'); + $data['html'] = $this->request->getVar('code'); + $data['text'] = $this->request->getVar('text'); + // $data['type'] = 1; + $mail_temp = $this->MailModel->save($data); + if ($mail_temp) + echo true; + else + echo false; + } + } + + public function edit_email_temp($temp_id = null) + { + if($this->request->getmethod() == 'get') + { + $temp_data = $this->MailModel->where('md5(id)' , $temp_id)->find(); + if ($temp_data) + { + $data['dropdownData'] = $this->VariableModel->where('type' , $temp_data[0]['type'])->findAll(); + $data['id'] = $temp_data[0]['id']; + $data['code'] = $temp_data[0]['html']; + $data['name'] = $temp_data[0]['name']; + $data['subject'] = $temp_data[0]['subject']; + $data['to'] = $temp_data[0]['to']; + $userdata['userdata'] = $this->dModel->getLoggedInUserData(session()->get('logged_user')); + echo view('layout/header',$userdata); + echo view("email.template.php" , $data); + echo view('layout/footer'); + } + } + else if($this->request->getmethod() == 'post') + { + $data['name'] = $this->request->getVar('name'); + $data['to'] = $this->request->getVar('to'); + $data['subject'] = $this->request->getVar('subject'); + $data['html'] = $this->request->getVar('code'); + $data['text'] = $this->request->getVar('text'); + $mail_temp = $this->MailModel->where('id', $this->request->getVar('id') )->set($data)->update(); + if ($mail_temp) + echo true; + else + echo false; + } + } + + public function mail_temp_deactivate($id = null) + { + $this->MailModel->where('md5(id)', $id )->set(array( 'is_active' => 0))->update(); + return redirect()->to(base_url()."template_list"); + } + + public function mail_temp_activate($id = null) + { + $this->MailModel->where('md5(id)', $id )->set(array( 'is_active' => 1))->update(); + return redirect()->to(base_url()."template_list"); + } + // ----------------------------------------------- } diff --git a/app/Controllers/Member_controller.php b/app/Controllers/Member_controller.php index d3a3ea9..80b8393 100644 --- a/app/Controllers/Member_controller.php +++ b/app/Controllers/Member_controller.php @@ -88,13 +88,9 @@ class Member_controller extends BaseController // Generate a random verification code $verification_code = rand(10 , 99 ).rand(10 , 99 ).rand(10 , 99 ); $MemberData['verification_code'] = $verification_code; - // print_r($MemberData);die(); $insert_data = $this->MemberModel->save($MemberData); if($insert_data) { - // Send the verification email - // return redirect()->to(base_url()."mail/".$this->request->getVar('email')."/".$verification_code); - // Send the verification email $sendmail_controller = new Sendmail_controller(); $sendmail_controller->index($this->request->getVar('email') , $MemberData['verification_code'] , 1); return redirect()->to(base_url()); diff --git a/app/Controllers/Sendmail_controller.php b/app/Controllers/Sendmail_controller.php index bdf0e8f..44f00be 100644 --- a/app/Controllers/Sendmail_controller.php +++ b/app/Controllers/Sendmail_controller.php @@ -1,6 +1,13 @@ session = session(); - $this->MemberModel = new Member_model(); + $this->session = session(); + $this->MemberModel = new Member_model(); + $this->UserModel = new User_model(); + $this->dModel = new Dashboard_model(); + $this->cModel = new Common_model(); + $this->creditsModel = new Member_credits_model(); + $this->PackagesModel = new Packages_and_pricing_model(); + $this->CreditsUsageTrackingModel = new Credits_usage_tracking_model(); + $this->MailModel = new Email_template_model(); + helper(['form', 'url']); } - public function index($to,$code,$return=null) + public function index($to,$code,$return) { $email = \Config\Services::email(); $email->setFrom('suseendhiran.1702117@srit.org', 'suseendhiran'); - $email->setTo($to); + $email->setTo($to); + // login user change passowrd => type 4 if($return == 4) { - $subject = 'Expire Alert'; - $message = $code; - } - else if ($return == 2) - { - $data['id'] = '2'; - $data['otp'] = $code; - $subject ='Verify your email address'; + $data['id'] = '4'; + $mem_data = $this->MemberModel->where('email', $to)->find(); + if ($mem_data) + { + $temp_data = $this->MailModel->where('type' , 4)->where('is_active' , 1)->find(); + if ($temp_data[0]['to']) + $email->setCC($temp_data[0]['to']); + if ($temp_data) { + $data['html'] = str_replace("%name%",$mem_data[0]['name'],$temp_data[0]['html']); + } + $message = view('verification_mail_temp',$data); + if ($temp_data[0]['is_active'] == 1) + $email->setSubject($temp_data[0]['subject']); + else + $email->setSubject('Password change'); + } + else + { + $user_data = $this->UserModel->where('email', $to)->find(); + $temp_data = $this->MailModel->where('type' , 4)->where('is_active' , 1)->find(); + if ($temp_data[0]['to']) + $email->setCC($temp_data[0]['to']); + if ($temp_data) { + $data['html'] = str_replace("%name%",$user_data[0]['name'],$temp_data[0]['html']); + } + $message = view('verification_mail_temp',$data); + } $message = view('verification_mail_temp',$data); + if ($temp_data[0]['is_active'] == 1) + $email->setSubject($temp_data[0]['subject']); + else + $email->setSubject('Password change'); } + // user => type 2 else if($return == 3) { + $user_data = $this->UserModel->where('email', $to)->find(); $data['id'] = '3'; $data['username'] = $to; $data['password'] = $code; $data['url'] = base_url()."admin"; - $subject ='Verify your email address'; + $temp_data = $this->MailModel->where('type' , 2)->where('is_active' , 1)->find(); + if ($temp_data[0]['to']) + $email->setCC($temp_data[0]['to']); + if ($temp_data) + $data['html'] = str_replace("%name%",$user_data[0]['name'],$temp_data[0]['html']); $message = view('verification_mail_temp',$data); + if ($temp_data[0]['is_active'] == 1) + $email->setSubject($temp_data[0]['subject']); + else + $email->setSubject('Username Password'); } - else + // otp => type 3 + else if ($return == 2) { + $data['id'] = '2'; + $data['otp'] = $code; + $mem_data = $this->MemberModel->where('email', $to)->find(); + if ($mem_data) + { + $temp_data = $this->MailModel->where('type' , 3)->where('is_active' , 1)->find(); + if ($temp_data[0]['to']) + $email->setCC($temp_data[0]['to']); + if ($temp_data) { + $html = str_replace("%name%",$mem_data[0]['name'],$temp_data[0]['html']); + $data['html'] = str_replace("%otp%",$code,$html); + } + $message = view('verification_mail_temp',$data); + if ($temp_data[0]['is_active'] == 1) + $email->setSubject($temp_data[0]['subject']); + else + $email->setSubject('OTP verification'); + } + else + { + $user_data = $this->UserModel->where('email', $to)->find(); + $temp_data = $this->MailModel->where('type' , 3)->where('is_active' , 1)->find(); + if ($temp_data[0]['to']) + $email->setCC($temp_data[0]['to']); + if ($temp_data) { + $html = str_replace("%name%",$user_data[0]['name'],$temp_data[0]['html']); + $data['html'] = str_replace("%otp%",$code,$html); + } + $message = view('verification_mail_temp',$data); + if ($temp_data[0]['is_active'] == 1) + $email->setSubject($temp_data[0]['subject']); + else + $email->setSubject('OTP verification'); + } + } + // member => type 1 + else if($return == 1) + { + // $email->setCC('another@another-example.com'); + // $email->setBCC('them@their-example.com'); + $user_data = $this->MemberModel->where('email', $to)->find(); $data['to'] = $to; $data['code'] = $code; - $data['url'] = base_url()."/verify_email/".md5($code); - $subject ='Verify your email address'; + $data['url'] = base_url()."verify_email/".md5($code); + $temp_data = $this->MailModel->where('type' , 1)->where('is_active' , 1)->find(); + if ($temp_data[0]['to']) + $email->setCC($temp_data[0]['to']); + if ($temp_data) + $data['html'] = str_replace("%name%",$user_data[0]['name'],$temp_data[0]['html']); $message = view('verification_mail_temp',$data); + if ($temp_data[0]['is_active'] == 1) + $email->setSubject($temp_data[0]['subject']); + else + $email->setSubject('Verify your email address'); } - $email->setSubject($subject); $email->setMessage($message); if ($email->send()) { @@ -85,10 +183,12 @@ class Sendmail_controller extends BaseController // Show error message echo 'Error in verifying email. Please try again.'; } - }else{ + } + else + { // Show error message echo 'Email already verified.'; - } + } } else { diff --git a/app/Models/email_template_model.php b/app/Models/email_template_model.php new file mode 100644 index 0000000..473938c --- /dev/null +++ b/app/Models/email_template_model.php @@ -0,0 +1,13 @@ + + + /assets/css/style.css" rel="stylesheet" type="text/css" /> + + @@ -63,7 +67,7 @@