From 60ca21e8663e600217f489dfaffe269c800d59ce Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Sat, 10 Jun 2023 10:19:16 +0530 Subject: [PATCH] susee --- DB/golf.sql | 495 ----------------- app/Config/App.php | 2 + app/Config/Database.php | 2 +- app/Config/Email.php | 6 +- app/Config/Routes.php | 1 + app/Controllers/Admin_controller.php | 578 +++++++++++++++++++- app/Controllers/Common_controller.php | 76 ++- app/Controllers/Member_controller.php | 679 +++++++++++++++++++++++- app/Controllers/PaymentController.php | 407 +++++++++++++- app/Controllers/Sendmail_controller.php | 276 +++++++++- app/Controllers/Test_controller.php | 48 +- app/Models/transaction_model.php | 14 +- app/Views/changepassword.php | 26 + app/Views/checkout.php | 358 +++++++++++-- app/Views/member_form.php | 4 +- app/Views/member_login.php | 146 ++++- app/Views/memberaccess.php | 41 +- app/Views/membership.php | 154 +++++- app/Views/myaccount.php | 168 +++++- app/Views/set_password.php | 22 +- app/Views/transactions_list.php | 81 ++- app/Views/user_form.php | 6 +- app/Views/users_password.php | 27 +- 23 files changed, 2997 insertions(+), 620 deletions(-) delete mode 100644 DB/golf.sql diff --git a/DB/golf.sql b/DB/golf.sql deleted file mode 100644 index a60c90e..0000000 --- a/DB/golf.sql +++ /dev/null @@ -1,495 +0,0 @@ --- phpMyAdmin SQL Dump --- version 5.2.0 --- https://www.phpmyadmin.net/ --- --- Host: 127.0.0.1 --- Generation Time: May 17, 2023 at 02:42 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(255) 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, 'Member Registration Template', 1, 'Hi %name% , Please confirm your email address by clicking the link below.', '

\n

Hi %name% , \nPlease confirm your email address by clicking the link\n below.\n

', 'gowtham.manavalan.la@gmail.com,suseendhiran1999@gmail.com', 'demo', 1, '2023-05-17 06:40:10', '0000-00-00 00:00:00', 0, 0), -(10, 'User Registration Template', 2, 'Please login by clicking the link below.', '

Please login by clicking the link below.

', 'suseendhiran1999@gmail.com', 'Demo', 1, '2023-05-17 06:55:57', '0000-00-00 00:00:00', 0, 0), -(12, 'OTP Template', 3, 'Please use the verification code below on the Golf Evolution Website.', '

Please use the verification code below on the Golf Evolution Website.

', 'suseendhiran1999@gmail.com', 'Demo', 1, '2023-05-17 11:57:55', '0000-00-00 00:00:00', 0, 0), -(14, 'Change Password Verification Template', 4, 'Hello %name% ! , Your password changed successfully...', '

Hello %name% ! , Your password changed successfully...

', 'suseendhiran1999@gmail.com', 'Demo', 1, '2023-05-17 12:02:14', '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%'), -(3, 2, 'User Name', '%name%'), -(4, 3, 'User Name', '%name%'), -(5, 3, 'OTP', '%otp%'), -(6, 4, 'Name', '%name%'); - --- -------------------------------------------------------- - --- --- 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$kOboUqGu66RUC2sfUe/1zuMP0u/6QiNieEgCCCOS08RSYhJjnPbt6', 787918, 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, 30, 18, 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'), -(16, 4, 'Evo Pack 2', 'Presales', 48, 48, 0, 0, '2023-06-17', 1000, 1, '2023-05-17 10:38:23', '2023-05-17 10:38:23'), -(17, 4, 'Evo Pack 1', 'Presales', 24, 24, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:38:23', '2023-05-17 10:38:23'), -(18, 4, 'Evo Pack 2', 'Regular', 40, 40, 0, 0, '2023-06-17', 1000, 1, '2023-05-17 10:39:10', '2023-05-17 10:39:10'), -(19, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:17', '2023-05-17 10:39:17'), -(20, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:20', '2023-05-17 10:39:20'), -(21, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:20', '2023-05-17 10:39:20'), -(22, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:20', '2023-05-17 10:39:20'), -(23, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:20', '2023-05-17 10:39:20'), -(24, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:20', '2023-05-17 10:39:20'), -(25, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:21', '2023-05-17 10:39:21'), -(26, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:21', '2023-05-17 10:39:21'), -(27, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:21', '2023-05-17 10:39:21'), -(28, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:21', '2023-05-17 10:39:21'), -(29, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:21', '2023-05-17 10:39:21'), -(30, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:21', '2023-05-17 10:39:21'), -(31, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:22', '2023-05-17 10:39:22'), -(32, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:22', '2023-05-17 10:39:22'), -(33, 4, 'Evo Pack 1', 'Regular', 20, 20, 0, 0, '2023-06-17', 550, 1, '2023-05-17 10:39:22', '2023-05-17 10:39:22'); - --- -------------------------------------------------------- - --- --- 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$IEWpmjmJFPrI4ww/vcqeHeu5uVyChqmA333iiK0glDjZAvV34gjWa', 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'), -(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=13; - --- --- 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=15; - --- --- AUTO_INCREMENT for table `email_template_variables` --- -ALTER TABLE `email_template_variables` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; - --- --- AUTO_INCREMENT for table `member` --- -ALTER TABLE `member` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=92; - --- --- AUTO_INCREMENT for table `member_credits` --- -ALTER TABLE `member_credits` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; - --- --- 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/App.php b/app/Config/App.php index 5ee4b23..8accd2b 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -17,7 +17,9 @@ class App extends BaseConfig * * http://example.com/ */ + // public string $baseURL = 'https://mprkv.co.in/devbook'; public string $baseURL = 'http://localhost/golf_backend'; + /** * Allowed Hostnames in the Site URL other than the hostname in the baseURL. diff --git a/app/Config/Database.php b/app/Config/Database.php index 3c9e058..7e6cf1a 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -34,7 +34,7 @@ class Database extends Config // 'username' => 'root', // 'password' => '', // 'database' => 'golf', - 'DBDriver' => 'mysqli', + 'DBDriver' => 'MySQLi', 'DBPrefix' => '', 'pConnect' => false, 'DBDebug' => true, diff --git a/app/Config/Email.php b/app/Config/Email.php index 9c77bbe..262c60e 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -28,17 +28,17 @@ class Email extends BaseConfig /** * SMTP Server Address */ - public string $SMTPHost = 'smtp.gmail.com'; + public string $SMTPHost = 'bh-in-11.webhostbox.net'; /** * SMTP Username */ - public string $SMTPUser = 'suseendhiran.1702117@srit.org'; + public string $SMTPUser = 'devbook@mprkv.co.in'; /** * SMTP Password */ - public string $SMTPPass = 'zlquygyjcjacvuqr'; + public string $SMTPPass = 'DevBook@2023'; /** * SMTP Port diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2ccbdd8..48ce927 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -96,6 +96,7 @@ $routes->match(['get','post'],'/rule','Admin_controller::rule'); $routes->match(['get','post'],'/booked_slot','Admin_controller::booked_slot'); $routes->match(['get','post'],'/manage_availability','Admin_controller::manage_availability'); $routes->match(['get','post'],'/add_to_cart_package','Admin_controller::add_to_cart_package'); +$routes->match(['post'],'/order_details','Admin_controller::order_details'); diff --git a/app/Controllers/Admin_controller.php b/app/Controllers/Admin_controller.php index f4233cc..f853df1 100644 --- a/app/Controllers/Admin_controller.php +++ b/app/Controllers/Admin_controller.php @@ -1,347 +1,690 @@ session = session(); + $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(); + $this->VariableModel = new Variable_model(); + $this->RuleModel = new Rule_model(); + $this->Cart_token_model = new Cart_token_model(); + $this->ZipcodeModel = new Zipcode_model(); + + $this->TransactionModel = new Transaction_model(); + helper(['form', 'url']); + } + public function index() + { + + $data=[]; + + //$database = \Config\Database::connect(); + + + if($this->request->getmethod() == 'post') + { + $email = $this->request->getVar('email'); + //echo $email; die(); + $password = $this->request->getVar('password'); + $userdata = $this->UserModel->verifyEmail($email); + //print_r($userdata); die(); + + if($userdata) + { + if (password_verify($password, $userdata['password'])) + { + + $this->session->set('logged_user',$userdata['id']); + return redirect()->to(base_url().'admin_home'); + } + else{ + $this->session->setTempdata('error','sorry wrong password entered for the Email',3); + return redirect()->to(base_url()."admin"); + } + }else + { + $this->session->setTempdata('error','sorry Email does not exist',3); + return redirect()->to(base_url()."admin"); + } + } + return view('admin_login'); + } - + + + + + + + public function admin_logout() + { + session()->remove('logged_user'); + session()->destroy(); + return redirect()->to(base_url()."admin"); + } + + public function users_list() + { + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + $data['userList'] = $this->UserModel->where('users.id != ',session()->get('logged_user') )->findAll(); + echo view('layout/header',$userdata); + echo view('users_list',$data); + echo view('layout/footer'); + } + + + public function user_edit($user_id = null , $check = null) + { + + if($this->request->getmethod() == 'post') + { + //update member details + $UserData = $this->request->getVar(); + $user_id = $this->request->getVar('id'); + $this->UserModel->where('id', $user_id )->set($UserData)->update(); + if ($this->request->getVar('profile_check') == 'profile_edit') { + return redirect()->to(base_url()."admin_profile/".md5($user_id)); + } + return redirect()->to(base_url()."users_list"); + + } + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + $zip = $this->ZipcodeModel->findAll(); + $output = ''; + foreach($zip as $row) + { + $output .= ''; + } + $data['zipcode'] = $output; + $data['userList'] = $this->UserModel ->select('users.* , zipcode.code as zipcode') + ->join('zipcode', 'users.pincode = zipcode.id', 'left') + ->where('md5(users.id)', $user_id ) + ->find(); + + + if ($check != null) { + $data['check'] = 'profile_edit'; + }else{ + $data['check'] = ''; + } + //print_r($data);die(); + echo view('layout/header',$userdata); + echo view('user_form',$data); + echo view('layout/footer'); + + } + + public function user_add() + { + if($this->request->getmethod() == 'post') + { + $password = ''; + $characters = array_merge(range('A','Z'), range('a','z'), range('0','9'), array('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=')); + for($i = 0; $i < 8; $i++) { + $password .= $characters[array_rand($characters)]; + } + //insert member details + $userData = $this->request->getVar(); + $userData['password'] = $password; + $userdata = $this->UserModel->save($userData); + if ($userdata) + { + $sendmail_controller = new Sendmail_controller(); + $get_data = $sendmail_controller->index($this->request->getVar('email') , $password , 3 ); + + return redirect()->to(base_url()."users_list"); + } + + }else{ + + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + $zip = $this->ZipcodeModel->findAll(); + $output = ''; + foreach($zip as $row) + { + $output .= ''; + } + $data['zipcode'] = $output; + $data['check']= null; + echo view('layout/header',$userdata); + echo view('user_form',$data); + echo view('layout/footer'); + } + + + + } + + 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"); + } + + + public function admin_profile($user_id = null) + { + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + + $data['userList'] = $this->UserModel->select('users.* , zipcode.code as zipcode') + ->join('zipcode', 'users.pincode = zipcode.id', 'left') + ->where('md5(users.id)', $user_id ) + ->find(); + + // print_r($data);die(); + echo view('layout/header',$userdata); + echo view('profile',$data); + echo view('layout/footer'); + + } + + public function profilepic_insert() + { + + if($this->request->getmethod() == 'post') + { + $path = ROOTPATH ."/public/assets/images/users"; + if($this->request->getFile('profile')) + { + $img = $this->request->getFile('profile'); + if ($img->isValid() && ! $img->hasMoved()) + { + //$newName = $img->getRandomName(); + $f_type=$_FILES['profile']['name']; + $data['profile'] = $f_type; + $this->UserModel->where('id', $this->request->getVar('id') )->set($data)->update(); + $img->move($path, $f_type); + return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id'))); + } + else + { + return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id'))); + } + } + else + { + return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id'))); + } + } + + } + + + + + public function credits_pack_list() + { + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + $data['PackageData'] = $this->PackagesModel->findAll(); + echo view('layout/header',$userdata); + echo view('credits_pack_list',$data); + echo view('layout/footer'); + } + + + public function credits_pack_edit($pack_id = null) + { + + if($this->request->getmethod() == 'post') + { + //update member details + + $PackData = $this->request->getVar(); + $pack_id = $this->request->getVar('id'); + $this->PackagesModel->where('id', $pack_id )->set($PackData)->update(); + return redirect()->to(base_url()."credits_pack_list"); + + } + + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + + $data['PackageData'] = $this->PackagesModel->where('md5(id)', $pack_id )->find(); + + //print_r($data);die(); + echo view('layout/header',$userdata); + echo view('credits_pack_form',$data); + echo view('layout/footer'); + + } + + public function credits_pack_add() + { + + if($this->request->getmethod() == 'post') + { + //insert member details + $PackData = $this->request->getVar(); + $this->UserModel->save($PackData); + return redirect()->to(base_url()."credits_pack_list"); + + } + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + echo view('layout/header',$userdata); + echo view('credits_pack_form'); + echo view('layout/footer'); + + } + + public function user_password_change() + { + + if($this->request->getmethod() == 'post') + { + //insert member details + $UserData = $this->request->getVar(); + $old_password = $this->request->getVar('old_password'); + $data = $this->UserModel->where('id', $this->request->getVar('id') )->find(); + if (password_verify($old_password ,$data[0]['password'])) + { + $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 + { + $this->session->setTempdata('error',"Entered wrong old password",3); + return redirect()->to(base_url()."user_password_change"); + } + } + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + echo view('layout/header',$userdata); + echo view('users_password',$userdata); + echo view('layout/footer'); + + } + + + public function transactions_list($member_id =null) { if($member_id == null) { $userdata['userdata'] = $this->dModel->getLoggedInUserData(session()->get('logged_user')); - $data['creditsData'] = $this->creditsModel->select('member_credits.* , member.name as member_name ') - ->join('member', 'member_credits.member_id = member.id', 'left') - ->orderBy('member_credits.created_at' , 'desc') + + $data['creditsData'] = $this->TransactionModel->select('transactions.* , member.name as member_name ') + ->join('member', 'transactions.member_id = member.id', 'left') + ->orderBy('transactions.created_at' , 'desc') ->findAll(); + //echo '
';   echo print_r($data['creditsData']); '
'; echo view('layout/header',$userdata); echo view('transactions_list',$data); echo view('layout/footer'); @@ -349,201 +692,416 @@ class Admin_controller extends BaseController }else{ $userdata['userdata'] = $this->dModel->getLoggedInUserData(session()->get('logged_user')); - $creditsData = $this->creditsModel->select('member_credits.* , member.name as member_name ') - ->join('member', 'member_credits.member_id = member.id', 'left') - ->where('md5(member_credits.member_id)', $member_id ) - ->orderBy('member_credits.created_at' , 'desc') + + $creditsData = $this->TransactionModel->select('transactions.* , member.name as member_name ') + ->join('member', 'transactions.member_id = member.id', 'left') + ->orderBy('transactions.created_at' , 'desc') + ->where('md5(transactions.member_id)', $member_id ) ->findAll(); - $output = '
'; + $output = '
DatePointsCostPack / Indidual
'; foreach ($creditsData as $row) { - $output .=''; + $date = new DateTime($row['created_at']); + if($row['status'] == 'success'){ + $cost = json_decode($row['transaction'] , true)['payment']['amount_money']['amount']; + }else{$cost='';} + $output .=''; } echo $output .= '
Order IdOrder DateTransaction IdCostPurchased byStatus
'.$row['created_at'].''.$row['credit_points'].''.$row['cost'].''.$row['package_name'].'
'.$row['order_id'].''.$date->format('M-d-Y').''.$row['transaction_id'].''.$cost.''.$row['member_name'].''.$row['status'].'
'; } } + + public function order_details() + { + + $member_id = $this->request->getVar('member_id'); + $order_id = $this->request->getVar('order_id'); + $creditsData = $this->creditsModel->select('member_credits.* , member.name as member_name ') + ->join('member', 'member_credits.member_id = member.id', 'left') + ->orderBy('member_credits.created_at' , 'desc') + ->where('member_credits.member_id', $member_id ) + ->where('member_credits.order_id', $order_id ) + ->findAll(); + // echo 'member_id ='.$member_id; echo 'order_id ='.$order_id; echo '
';   echo print_r($creditsData); '
'; die(); + $output = '
'; + foreach ($creditsData as $row) { + + + $output .=''; + } + echo $output .= '
Order IdPackage NameCostTotal AmountCredits
'.$row['order_id'].''.$row['package_name'].''.$row['cost'].''.$row['cost_with_tax'].''.$row['credit_points'].'
'; + + + } + + + public function user_forgot_password() + { + if($this->request->getmethod() == 'get') + { + $this->session->setTempdata('user',"user",3); + return view('forgot_password.php'); + } + else if($this->request->getmethod() == 'post') + { + + $email = $this->request->getVar('email'); + $user_data = $this->UserModel->where('email', $email)->find(); + if ($user_data) + { + $otp = rand(1000 , 9999); + $sendmail_controller = new Sendmail_controller(); + $sendmail_controller->index($this->request->getVar('email') , $otp , 2 ); + $data['status'] = 'success'; + $data['otp'] = $otp; + echo json_encode($data); + } + else + { + $data['status'] = 'failed'; + echo json_encode($data); + } + + } + } + + 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"); + } + + public function rule() + { + if($this->request->getmethod() == 'get') + { + $userdata['userdata'] = $this->dModel->getLoggedInUserData(session()->get('logged_user')); + $ruledata['rule_data'] = $this->RuleModel->findAll(); + echo view('layout/header',$userdata); + echo view('rule.php',$ruledata); + echo view('layout/footer'); + } + else if($this->request->getmethod() == 'post') + { + $id = $this->request->getVar('id'); + $data['data'] = $this->request->getVar('rule_name'); + $data['value'] = $this->request->getVar('value'); + $updatedata = $this->RuleModel->where('id', $id )->set($data)->update(); + if($updatedata) + echo true; + else + echo false; + } + } + + public function booked_slot() + { + if($this->request->getmethod() == 'get') + { + $userdata['userdata'] = $this->dModel->getLoggedInUserData(session()->get('logged_user')); + // $ruledata['rule_data'] = $this->RuleModel->findAll(); + echo view('layout/header',$userdata); + echo view('booked_slot.php'); + echo view('layout/footer'); + } + else if($this->request->getmethod() == 'post') + { + echo 'hi'; + } + } + + public function manage_availability() + { + if($this->request->getmethod() == 'get') + { + $userdata['userdata'] = $this->dModel->getLoggedInUserData(session()->get('logged_user')); + // $ruledata['rule_data'] = $this->RuleModel->findAll(); + echo view('layout/header',$userdata); + echo view('manage_availability.php'); + echo view('layout/footer'); + } + else if($this->request->getmethod() == 'post') + { + echo 'hi'; + } + } + + // public function add_to_cart_package() + // { + // $data = $this->request->getVar(); + // $data['table_name'] = 'packages_and_pricing'; + // $save_data = $this->Wp_php_token_model->save($data); + // echo $save_data; + // } + + // public function continue_shopping($param) + // { + // $token_exist = $this->Wp_php_token_model->where('token', $param )->find(); + // if ($token_exist) + // return $token_exist[0]['token']; + // else + // return false; + // } + + // ----------------------------------------------- + } + diff --git a/app/Controllers/Common_controller.php b/app/Controllers/Common_controller.php index 99d3baa..722390b 100644 --- a/app/Controllers/Common_controller.php +++ b/app/Controllers/Common_controller.php @@ -1,70 +1,140 @@ session = session(); + $this->MemberModel = new Member_model(); + $this->UserModel = new User_model(); + $this->dModel = new Dashboard_model(); + $this->cModel = new Common_model(); + helper(['form']); + } + public function index() + { + + + } + + function fetch_country() + { + echo $this->cModel->fetch_country(); + } + + function fetch_state() + { + if($this->request->getVar('country_id')) + { + echo $this->cModel->fetch_state($this->request->getVar('country_id')); + } + } + + function fetch_city() + { + if($this->request->getVar('state_id')) + { + echo $this->cModel->fetch_city($this->request->getVar('state_id')); + } + } + + function check_if_mail_exists() + { + if($this->request->getVar('table')) + { + if($this->request->getVar('table') == 'member') - $data = $this->MemberModel->where('email', $this->request->getVar('email'))->find(); + + $data = $this->MemberModel->where('email', $this->request->getVar('email'))->where('is_active', 1)->find(); + else if($this->request->getVar('table') == 'users') - $data = $this->UserModel->where('email', $this->request->getVar('email'))->find(); + + $data = $this->UserModel->where('email', $this->request->getVar('email'))->where('is_active', 1)->find(); + if ($data) + { + echo true; + } + else + { + echo false; + } + } + } - + + + + + // ----------------------------------------------- + } + diff --git a/app/Controllers/Member_controller.php b/app/Controllers/Member_controller.php index e54dd42..b471b33 100644 --- a/app/Controllers/Member_controller.php +++ b/app/Controllers/Member_controller.php @@ -1,668 +1,1339 @@ 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->cartModel = new Cart_model(); + $this->CreditsUsageTrackingModel = new Credits_usage_tracking_model(); + $this->Cart_token_model = new Cart_token_model(); + $this->MemberAddressModel = new Member_address_model(); - $this->TransactionModel = new transaction_model(); + + $this->TransactionModel = new Transaction_model(); + $this->RuleModel = new Rule_model(); + $this->ZipcodeModel = new Zipcode_model(); + helper('form'); + } + public function index() + { + $data=[]; + + + if($this->request->getmethod() == 'post') + { + $email = $this->request->getVar('email'); + //echo $email; die(); + $password = $this->request->getVar('password'); + $memberdata = $this->MemberModel->verifyEmail($email); + + + if($memberdata) + { + if ($memberdata['is_email_verified']) + { + + if (password_verify($password, $memberdata['password'])) + { + $token = $this->session->get("token"); + $this->session->set('logged_user',$memberdata['id']); + $this->session->set('logged_user_name',$memberdata['name']); + $this->session->set('logged_user_email',$memberdata['email']); + if ($token) + { + $tokendata = $this->Cart_token_model->where('md5(token)', $token )->findAll(); + foreach ($tokendata as $value) + { + $data['member_id'] = $memberdata['id']; + $data['pack_id'] = $value['primary_id']; + $data['count'] = $value['count']; + $successdata = $this->cartModel->save($data); + if ($successdata) + { + $deletedata = $this->Cart_token_model->where('id', $value['id'] )->delete(); + } + } + return redirect()->to(base_url().'payment'); + } + else + { + // $this->member_dashboard(); + return redirect()->to(base_url().'member_home'); + } + + } + else{ + $this->session->setTempdata('error','sorry wrong password entered for the Email',3); + $this->session->setTempdata('l_email',$this->request->getVar('email'),3); + $this->session->setTempdata('l_password',$this->request->getVar('password'),3); return redirect()->to(base_url()); + } + } + else{ + $this->session->setTempdata('error','Sorry your mail is not verified.please check your mail',3); + $this->session->setTempdata('email',$this->request->getVar('email'),3); + $this->session->setTempdata('password',$this->request->getVar('password'),3); return redirect()->to(base_url()); + } + + }else + { + $this->session->setTempdata('error','sorry email is not exist',3); + $this->session->setTempdata('email',$this->request->getVar('email'),3); + $this->session->setTempdata('password',$this->request->getVar('password'),3); return redirect()->to(base_url()); + } + + }else{ // get method + //return view('member_login'); + if(session()->has('logged_user')) + { + return redirect()->to(base_url().'member_home'); + //$this->member_dashboard(); + } + else + { + return view('myaccount'); + + } + } + + + } + + public function logout() + { + session()->remove('logged_user'); + session()->destroy(); + return redirect()->to(base_url()); + } + + public function register() + { + if($this->request->getmethod() == 'post') + { + //insert member details + $MemberData = $this->request->getVar(); + // Generate a random verification code + $verification_code = rand(10 , 99 ).rand(10 , 99 ).rand(10 , 99 ); + $MemberData['verification_code'] = $verification_code; + $insert_data = $this->MemberModel->save($MemberData); + if($insert_data) + { + + $sendmail_controller = new Sendmail_controller(); + $sendmail_controller->index($this->request->getVar('email') , $MemberData['verification_code'] , 1); + return redirect()->to(base_url()); + } + else + { + // Show error message + echo 'Error in registering user. Please try again.'; + } + // return redirect()->to(base_url()); + + } + $data['country']=$this->cModel->fetch_country(); + return view('member_registration',$data); + } + + + public function members_list() + { + + + + + $id = session()->get('logged_user'); + $userdata['userdata']=$this->dModel->getLoggedInUserData($id); + $data['Membersdata'] = $this->MemberModel->findAll(); + + + + echo view('layout/header',$userdata); + echo view('members_list',$data); + echo view('layout/footer'); + } + + public function member_deactivate($id = null) + { + + $this->MemberModel->where('md5(id)', $id )->set(array( 'is_active' => 0))->update(); + return redirect()->to(base_url()."members_list"); + + } + + public function member_activate($id = null) + { + + $this->MemberModel->where('md5(id)', $id )->set(array( 'is_active' => 1))->update(); + return redirect()->to(base_url()."members_list"); + + } + + + public function member_edit($member_id = null) + { + + if($this->request->getmethod() == 'post') + { + //update member details + + $MemberData = $this->request->getVar(); + $member_id = $this->request->getVar('id'); + $this->MemberModel->where('id', $member_id )->set($MemberData)->update(); + return redirect()->to(base_url()."members_list"); + + } + + $logged_user_id = session()->get('logged_user'); + $userdata['userdata']=$this->dModel->getLoggedInUserData($logged_user_id); + $zip = $this->ZipcodeModel->findAll(); + $output = ''; + foreach($zip as $row) + { + $output .= ''; + } + $data['zipcode'] = $output; + $data['Memberdata'] = $this->MemberModel->select('member.* , zipcode.code as zipcode') + ->join('zipcode', 'member.pincode = zipcode.id', 'left') + ->where('md5(member.id)', $member_id ) + ->find(); + + echo view('layout/header',$userdata); + echo view('member_form',$data); + echo view('layout/footer'); + + } + + public function member_add() + { + + if($this->request->getmethod() == 'post') + { + //insert member details + $MemberData = $this->request->getVar(); + // Generate a random verification code + $verification_code = rand(10 , 99 ).rand(10 , 99 ).rand(10 , 99 ); + $MemberData['verification_code'] = $verification_code; + $insert_data = $this->MemberModel->save($MemberData); + if($insert_data) + { + // 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()."members_list"); + + } + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + $zip = $this->ZipcodeModel->findAll(); + $output = ''; + foreach($zip as $row) + { + $output .= ''; + } + $data['zipcode'] = $output; + echo view('layout/header',$userdata); + echo view('member_form',$data); + echo view('layout/footer'); + + } + + public function forgot_password() + { + if($this->request->getmethod() == 'get') + { + return view('forgot_password.php'); + } + else if($this->request->getmethod() == 'post') + { + + $email = $this->request->getVar('email'); + $user_data = $this->MemberModel->where('email', $email)->find(); + echo $user_data; + // echo $user_data; + if ($user_data) + { + $otp = rand(1000 , 9999 ); + // $sendmail_controller = new Sendmail_controller(); + $get_data = $Sendmail_controller->index($this->request->getVar('email') , $otp , 2 ); + $data['status'] = 'success'; + $data['otp'] = $otp; + echo json_encode($data); + } + else + { + $data['status'] = 'failed'; + echo json_encode($data); + } + + } + } + + public function change_password_form() + { + if($this->request->getmethod() == 'post') + { + $otp = $this->request->getVar('otp'); + $verify_otp = $this->request->getVar('verify_otp'); + if ($this->request->getVar('user') == 'user') + { + if ($otp == $verify_otp) + { + $email = $this->request->getVar('email'); + $data = $this->UserModel->where('email', $email)->find(); + if ($data) + { + $this->session->setTempdata('id',$data[0]['id'],3); + $this->session->setTempdata('email',$data[0]['email'],3); + $this->session->setTempdata('mail_success', "OTP verification sucessfully",3); + return view('set_password.php'); + } + } + else + { + $this->session->setTempdata('error', "You entered wrong OTP.Please retry",3); + return view('forgot_password.php'); + } + } + else + { + if ($otp == $verify_otp) + { + $email = $this->request->getVar('email'); + $data = $this->MemberModel->where('email', $email)->find(); + if ($data) + { + $this->session->setTempdata('id',$data[0]['id'],3); + $this->session->setTempdata('email',$data[0]['email'],3); + $this->session->setTempdata('mail_success', "OTP verification sucessfully",3); + return view('changepassword.php'); + } + } + else + { + $this->session->setTempdata('error', "You entered wrong OTP.Please retry",3); + return view('forgot_password_otp.php'); + } + } + } + } + + + public function set_password($id) + { + if($this->request->getmethod() == 'get') + { + $user_data = $this->MemberModel->where('md5(id)', $id)->find(); + $this->session->setTempdata('id',$user_data[0]['id'],3); + $this->session->setTempdata('email',$user_data[0]['email'],3); + if(!$user_data[0]['password'] == null) + $this->session->setTempdata('mail_success', "Email verification sucessfull",3); + else + $this->session->setTempdata('mail_success', "Email already verified . Please set password",3); + return view('changepassword.php'); + } + } + + public function update_password() + { + if($this->request->getmethod() == 'post') + { + if ($this->request->getVar('user') == 'user') + { + $userData = $this->request->getVar(); + $user_id = $this->request->getVar('id'); + $this->UserModel->where('id', $user_id )->set($userData)->update(); + $this->session->setTempdata('mail_success', "Password set sucessfully",3); + return redirect()->to(base_url()."admin"); + } + else + { + $MemberData = $this->request->getVar(); + $member_id = $this->request->getVar('id'); + $this->MemberModel->where('id', $member_id )->set($MemberData)->update(); + $this->session->setTempdata('mail_success', "Password set sucessfully",3); + return redirect()->to(base_url()); + } + } + } + + + + + public function buy_pack() + { + //insert member details + $array = $this->request->getVar(); + //print_r($array);die(); + $newArray = array(); + foreach ($array as $key => $value) { + $newKey = substr($key, 0, -2); + $newArray[$newKey] = $value; + } + //print_r($newArray);die(); + $packageData = $this->PackagesModel->where('id',$newArray['pack_id'])->find(); + //print_r($packageData);die(); + $today = date("Y-m-d"); + + $credits_data['member_id'] = $newArray['member_id']; + $credits_data['package_name'] = $packageData[0]['package_name']; + $credits_data['package_type'] = $packageData[0]['package_type']; + $credits_data['credit_points'] = $packageData[0]['credit'] * $newArray['pack_count']; + $credits_data['running_balance'] = $packageData[0]['credit'] * $newArray['pack_count']; + $credits_data['expired_points'] = 0; + $credits_data['expiring_date'] = date('Y-m-d', strtotime('+1 month', strtotime($today))); + $credits_data['cost'] = $packageData[0]['cost']; + //print_r($credits_data);die(); + $insert_data = $this->creditsModel->save($credits_data); + if($insert_data) + { + echo true; + }else{ + echo false; + } + + + } + + + + public function use_points() + { + + $FormData = $this->request->getVar(); + + + //print_r($FormData);die(); + $needed_points = $FormData['points']; + + $count = $this->creditsModel->selectSum('running_balance')->where('member_id',$FormData['member_id'])->get()->getRow()->running_balance; + if($count > $needed_points) + { + $creditsData = $this->creditsModel->where('member_id',$FormData['member_id'])->findAll(); + //$newArray = array(); + foreach ($creditsData as $creditsDataindex => $creditsDataValue) { + if($creditsDataValue['expiring_date'] > date("Y-m-d")) + { + $temp_needed_points = $needed_points; + if($creditsDataValue['running_balance'] != 0 && $needed_points > 0) + { + + $needed_points = ($needed_points - $creditsDataValue['running_balance']); + if($needed_points < 0 ){ + $running_balance = $creditsDataValue['running_balance'] - $temp_needed_points; + $this->update_credit_package_data($creditsDataValue['id'] , array( 'running_balance'=>$running_balance , 'used_points'=> $creditsDataValue['used_points'] + $creditsDataValue['running_balance'] - $running_balance)); + $this->CreditsUsageTrackingModel->save(array('member_id'=>$FormData['member_id'],'member_credits_id'=>$creditsDataValue['id'], 'used_points'=>($creditsDataValue['running_balance'] - $running_balance),'slot_date_time'=>date("Y-m-d"))); + }else { $running_balance = 0; + $this->update_credit_package_data($creditsDataValue['id'] , array( 'running_balance'=>$running_balance , 'used_points'=> $creditsDataValue['used_points'] + $creditsDataValue['running_balance'] - $running_balance)); + $this->CreditsUsageTrackingModel->save(array('member_id'=>$FormData['member_id'],'member_credits_id'=>$creditsDataValue['id'], 'used_points'=>($creditsDataValue['running_balance'] - $running_balance),'slot_date_time'=>date("Y-m-d"))); + } + //$newArray[$creditsDataValue['running_balance']] = array('needed_points'=>$needed_points , 'running_balance'=>$running_balance , 'used_points'=> $creditsDataValue['running_balance'] - $running_balance); + + }else{ + + } + + }else{ + + } + + } + + echo true; + + }else{ + echo "u need to purchase points"; + } + + + + + } + + public function update_credit_package_data($id , $array) + { + $this->creditsModel->where('id', $id )->set($array)->update(); + } + + + public function add_to_cart() + { + //insert member details + $array = $this->request->getVar(); + //print_r($array);die(); + $newArray = array(); + foreach ($array as $key => $value) { + $newKey = substr($key, 0, -2); + $newArray[$newKey] = $value; + } + //print_r($newArray);die(); + $insert_data = $this->cartModel->save($newArray); + if($insert_data) + { + echo true; + }else{ + echo false; + } + } + + public function cart_checkout() + { + + $CartData = $this->cartModel->where('member_id',session()->get('logged_user'))->findAll(); + + + $today = date("Y-m-d"); + foreach ($CartData as $creditsDataindex => $creditsDataValue) + { + $packageData = $this->PackagesModel->where('id',$creditsDataValue['pack_id'])->find(); + + $credits_data['member_id'] = session()->get('logged_user'); + $credits_data['package_name'] = $packageData[0]['package_name']; + $credits_data['package_type'] = $packageData[0]['package_type']; + $credits_data['credit_points'] = $packageData[0]['credit'] ; + $credits_data['running_balance'] = $packageData[0]['credit'] ; + $credits_data['expired_points'] = 0; + $credits_data['expiring_date'] = date('Y-m-d', strtotime('+1 month', strtotime($today))); + $credits_data['cost'] = $packageData[0]['cost']; + $insert_data = $this->creditsModel->save($credits_data); + if($insert_data) + { + $this->cartModel->where('id',$creditsDataValue['id'])->delete(); + } + } + echo true; + } + + + public function scheduler() + { + + $Data = $this->creditsModel->select('member_credits.* , member.name as member_name , member.email as member_email ') + ->join('member', 'member_credits.member_id = member.id', 'left') + ->findAll(); + + foreach ($Data as $index => $Value) + { + if(strtotime('-3 days', strtotime($Value['expiring_date'])) == strtotime(date("Y-m-d"))) + { + $sendmail_controller = new Sendmail_controller(); + $message = 'Hai '. $Value['member_name']. ' Your pack will expire with in three days'; + $sendmail_controller->index($Value['member_email'] , null , 5); + } + } + + } + + + + public function member_address_form() + { + + $id = $this->request->getVar('id'); + $data['userAddress'] = $this->MemberAddressModel->where('member_id',session()->get('logged_user'))->where('id',$id)->find(); + echo view('member_address_form',$data); + + } + + public function member_address_edit() + { + + $array = $this->request->getVar(); + $id = $this->request->getVar('id'); + $update =$this->MemberModel->where('id', $id )->set($array)->update(); + echo true; + + + } + public function member_password_edit() + { + + $array = $this->request->getVar(); - $id = $this->request->getVar('id'); + + $id = $this->session->get('logged_user'); + $update =$this->MemberModel->where('id', $id )->set($array)->update(); + return redirect()->to(base_url()."member_logout"); + + + } + + public function check_old_password() + { + $id = $this->request->getVar('id'); + $old_password = $this->request->getVar('old_password'); + $data =$this->MemberModel->where('id', $id )->find(); + if(password_verify($old_password , $data[0]['password'])) + echo 1; + else + echo 0; + } + + public function member_dashboard() + { + if(!session()->has('logged_user')) + { + return redirect()->to(base_url()); + } - $creditsData = $this->creditsModel->where('member_id',$this->session->get('logged_user'))->orderBy('id' , 'ASC')->findAll(); + + $creditsData = $this->creditsModel->where('member_id',$this->session->get('logged_user'))->where('is_active',1)->orderBy('id' , 'ASC')->findAll(); + $recent_expiry = $this->creditsModel->select('expiring_date')->selectSum('running_balance', 'no_of_credits')->groupBy('expiring_date')->orderBy('expiring_date', 'asc')->where('member_id',$this->session->get('logged_user'))->where('is_active',1)->first(); + if($recent_expiry){ + $data['no_of_credits'] = $recent_expiry['no_of_credits']; + $data['expiring_date'] = $recent_expiry['expiring_date']; + }else{ + $data['no_of_credits'] = ''; + $data['expiring_date'] = ''; + } + + + $data['credit_data'] = []; + $data['avaiable_credit'] = 0; + // $data['no_of_credits']; + // $data['expiry_date']; + $data['profile'] = $this->MemberModel->select('member.* , zipcode.code as zipcode') + ->join('zipcode', 'member.pincode = zipcode.id', 'left') + ->where('member.id', session()->get('logged_user')) + ->find(); + foreach ($creditsData as $creditsDataindex => $creditsDataValue) + { + + $data['avaiable_credit'] = $data['avaiable_credit'] + $creditsDataValue['running_balance']; + $creditsDataValue['avaiable_credit'] = $data['avaiable_credit']; + array_push($data['credit_data'] , $creditsDataValue); + + } + + $TransactionData = $this->TransactionModel->where('member_id', session()->get('logged_user'))->where('status', 'success')->findAll(); + $data['TransactionData'] = []; + foreach ($TransactionData as $TransactionDatakey => $TransactionDatavalue) { + $credit_data = $this->creditsModel->where('member_id', session()->get('logged_user')) + ->select('package_name') + ->select('cost') + ->select('credit_points') + ->select('expiring_date') + ->selectSum('credit_points', 'creditPointsSum') + ->selectSum('cost', 'costSum') + ->selectCount('package_name', 'pack_count') + ->groupBy('package_name') + ->where('order_id',$TransactionDatavalue['order_id']) + ->where('is_active',1) + ->findAll(); + $TransactionDatavalue['credit_data'] = $credit_data; + array_push($data['TransactionData'] ,$TransactionDatavalue); + } + $data['gst'] = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value; + $data['pst'] = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value; + $zip = $this->ZipcodeModel->findAll(); + $output = ''; + foreach($zip as $row) + { + $output .= ''; + } + $data['zipcode'] = $output; + echo view('memberaccess',$data); //dashboard + } + + public function zipcode_data() + { + $id = $this->request->getVar('id'); + $data = $this->ZipcodeModel->where('id' , $id)->find(); + if($data) + echo json_encode($data); + else + echo 0; + } + + + + // ----------------------------------------------- + } + diff --git a/app/Controllers/PaymentController.php b/app/Controllers/PaymentController.php index 5ce3836..fd11742 100644 --- a/app/Controllers/PaymentController.php +++ b/app/Controllers/PaymentController.php @@ -1,401 +1,802 @@ session = session(); + $this->MemberModel = new Member_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->cartModel = new Cart_model(); + $this->CreditsUsageTrackingModel = new Credits_usage_tracking_model(); - $this->TransactionModel = new transaction_model(); + + $this->TransactionModel = new Transaction_model(); + $this->RuleModel = new Rule_model(); + $this->Cart_token_model = new Cart_token_model(); + $this->MemberAddressModel = new Member_address_model(); + $this->ZipcodeModel = new Zipcode_model(); + } + + + public function index($token = null) + { + if($this->request->getmethod() == 'post') + { + + if(!session()->has('logged_user')) + { + $count = $this->request->getVar('count'); + foreach ($count as $key => $value) + { + $this->Cart_token_model->where('id', $this->request->getVar('cart_token_id')[$key] )->set(array( 'count' => $value ))->update(); + } + $this->session->set('token',$token); + return redirect()->to(base_url()); + } + else{ + + $this->payment_form(); + } + + } else { + + $this->payment_form(); + } + } + + + + + + public function payment_form() + { + if(!session()->has('logged_user')) + { + return redirect()->to(base_url()); + } + $CartData = $this->cartModel->where('member_id',session()->get('logged_user'))->findAll(); + $count = count($CartData); + if($count) + { + $credit_pack_expiry_duration = $this->RuleModel->select('value')->where('rule_key', 1 )->get()->getRow()->value; + $gst = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value; + $pst = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value; + $today = date("Y-m-d"); + $days = "+".$credit_pack_expiry_duration." days"; + $amount = 0; + $item_count = 0; + + + if($CartData[0]['order_id'] == null) + { + $orderId = 'EGF'.rand(10,100).rand(10,100).rand(10,100); + }else{ + $orderId = $CartData[0]['order_id']; + } + + + $packageArray = []; + for($i=0;$i<$count;$i++) + { + + + + $packageData = $this->PackagesModel->where('id',$CartData[$i]['pack_id'])->find(); + $packageData[0]['count'] = $CartData[$i]['count']; + array_push($packageArray , $packageData[0]); + $cost = $packageData[0]['cost'] * $CartData[$i]['count']; + + $credits_data['member_id'] = session()->get('logged_user'); + $credits_data['package_name'] = $packageData[0]['package_name']; + $credits_data['package_type'] = $packageData[0]['package_type']; + $credits_data['credit_points'] = $packageData[0]['credit']; + $credits_data['running_balance'] = $packageData[0]['credit']; + $credits_data['expired_points'] = 0; + $credits_data['expiring_date'] = date('Y-m-d', strtotime($days, strtotime($today))); + $credits_data['cost'] = $packageData[0]['cost']; + $credits_data['is_active'] = 0; + $credits_data['order_id'] = $orderId; + $credits_data['cost_with_tax'] = round( ( $packageData[0]['cost'] + (($packageData[0]['cost'] * ($gst + $pst) ) / 100) ) , 2 ); + + $creditsModel_pack_count = $this->creditsModel->selectCount('id')->where('package_name',$packageData[0]['package_name'])->where('order_id',$orderId)->where('member_id', session()->get('logged_user'))->get()->getRow()->id; + $single_pack_no_of_count = $CartData[$i]['count'] - $creditsModel_pack_count; + // if($CartData[0]['order_id'] == null) + // { + for($j=0;$j<$single_pack_no_of_count;$j++) + { + $insert_data = $this->creditsModel->save($credits_data); + } + + $this->cartModel->where('id', $CartData[$i]['id'] ) + ->where('member_id', session()->get('logged_user')) + ->set(array( 'order_id' => $orderId ))->update(); + // } + + + $amount = $amount + $cost; + $item_count = $item_count + $CartData[$i]['count']; + } + + $data['amount'] = $amount; + $data['item_count'] = $item_count; + $data['order_id'] = $orderId; + $data['gst'] = $gst; + $data['pst'] = $pst; + $data['packageArray'] = $packageArray; + $data['userdata'] = $this->MemberModel->select('member.* , zipcode.code as zipcode') + ->join('zipcode', 'member.pincode = zipcode.id', 'left') + ->where('member.id', session()->get('logged_user')) + ->find(); + $if_trans_exist = $this->TransactionModel->where('member_id', session()->get('logged_user')) + ->where('order_id', $orderId )->find(); + if($if_trans_exist){ + //skip insertion + }else{ + //Trancaction Table initial entry for this transaction + $TrancactionData['status'] = 'initialized'; + $TrancactionData['member_id'] = session()->get('logged_user'); + $TrancactionData['order_id'] = $orderId; + $insert = $this->TransactionModel->save($TrancactionData); + } + + $zip = $this->ZipcodeModel->findAll(); + $output = ''; + foreach($zip as $row) + { + $output .= ''; + } + $data['zipcode'] = $output; + + echo view('checkout',$data); + + } else { return redirect()->to(base_url()."view/".md5(session()->get('logged_user'))); } + } + + + + public function processPayment() + { + try { + + if ($_SERVER['REQUEST_METHOD'] != 'POST') { + error_log('Received a non-POST request'); + echo 'Request not allowed'; + http_response_code(405); + return; + } - include 'App\Libraries\LocationInfo.php'; + + + include 'app/Libraries/LocationInfo.php'; + + $json = file_get_contents('php://input'); + $data = json_decode($json); + $gst = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value; + $pst = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value; + $token = $data->token; + $idempotencyKey = $data->idempotencyKey; + $amount = $data->amount; + $order_id = $data->order_id; + $add = $data->address; + parse_str( $add, $address); + + + + //print_r($add);die(); + + $Final_amount = round( ( $amount + (($amount * ($gst + $pst) ) / 100) ) , 2 ); + + $square_client = new SquareClient([ + 'accessToken' => getenv('SQUARE_ACCESS_TOKEN'), + 'environment' => getenv('ENVIRONMENT'), + 'userAgentDetail' => 'golf_evo', // Remove or replace this detail when building your own app + ]); + + $payments_api = $square_client->getPaymentsApi(); + + // To learn more about splitting payments with additional recipients, + // see the Payments API documentation on our [developer site] + // (https://developer.squareup.com/docs/payments-api/overview). + + $money = new Money(); + // Monetary amounts are specified in the smallest unit of the applicable currency. + // This amount is in cents. It's also hard-coded for $1.00, which isn't very useful. + $money->setAmount($Final_amount); + + // Set currency to the currency for the location + $money->setCurrency($location_info->getCurrency()); + + //print_r($money); die(); + + try { + // Every payment you process with the SDK must have a unique idempotency key. + // If you're unsure whether a particular payment succeeded, you can reattempt + // it with the same idempotency key without worrying about double charging + // the buyer. + $create_payment_request = new CreatePaymentRequest($token, $idempotencyKey, $money); + $create_payment_request->setLocationId($location_info->getId()); + + $response = $payments_api->createPayment($create_payment_request); + + if ($response->isSuccess()) { + + $data = json_encode($response->getResult()); + $result = json_decode( $data ,true); + //Trancaction Table Data + $TrancactionData['status'] = 'success'; + //$TrancactionData['member_id'] = session()->get('logged_user'); + $TrancactionData['first_name'] = $address['name']; + $TrancactionData['last_name'] = $address['last_name']; + $TrancactionData['address'] = $address['address']; + $TrancactionData['state'] = $address['state']; + $TrancactionData['city'] = $address['city']; + $TrancactionData['zip_code'] = $address['pincode']; + // $TrancactionData['order_id'] = $order_id; + $TrancactionData['transaction_id'] = $result['payment']['id']; + $TrancactionData['payment_order_id'] = $result['payment']['order_id']; + $TrancactionData['transaction'] = json_encode($response->getResult()); + $update = $this->TransactionModel->where('member_id', session()->get('logged_user')) + ->where('order_id', $order_id ) + ->set($TrancactionData)->update(); + if( $update) + { + $this->creditsModel->where('order_id', $order_id )->where('member_id', session()->get('logged_user')) + ->set(array( 'is_active' => 1 , 'transaction_id' => $result['payment']['id'] ))->update(); + $this->cartModel->where('order_id', $order_id )->delete(); + } + + echo json_encode($response->getResult()); + + + } else { + $data = json_encode($response->getErrors()); + $result = json_decode( $data ,true); + //Trancaction Table Data + $TrancactionData['status'] = 'failed'; + // $TrancactionData['member_id'] = session()->get('logged_user'); + $TrancactionData['first_name'] = $address['name']; + $TrancactionData['last_name'] = $address['last_name']; + $TrancactionData['address'] = $address['address']; + $TrancactionData['state'] = $address['state']; + $TrancactionData['city'] = $address['city']; + $TrancactionData['zip_code'] = $address['pincode']; + //$TrancactionData['order_id'] = $order_id; + $TrancactionData['transaction'] = json_encode($response->getErrors()); + $update = $this->TransactionModel->where('member_id', session()->get('logged_user')) + ->where('order_id', $order_id ) + ->set($TrancactionData)->update(); + if( $update) + { + + $this->creditsModel->where('order_id', $order_id )->delete(); + $this->cartModel->where('order_id', $order_id )->set(array('order_id'=>null))->update(); + } + + echo json_encode(array('errors' => $response->getErrors())); + } + } catch (ApiException $e) { + echo json_encode(array('errors' => $e)); + } + } catch (\Exception $e) { + // Handle exceptions + + // Example: Logging the exception + log_message('error', 'Exception: ' . $e->getMessage()); + + // Example: Displaying a custom error message + echo 'An exception occurred: ' . $e->getMessage(); + } catch (\Error $e) { + // Handle errors + + // Example: Logging the error + log_message('error', 'Error: ' . $e->getMessage()); + + // Example: Displaying a custom error message + echo 'An error occurred: ' . $e->getMessage(); + } + } + + + + + public function payment_success( $local_order_id = null) + { + if( $local_order_id != null) + { + $data['TransactionData'] = $this->TransactionModel->where('order_id', $local_order_id )->where('member_id', session()->get('logged_user'))->find(); + if($data['TransactionData']){ + $memberCredits = $this->creditsModel->where('order_id', $local_order_id ) + ->where('member_id', session()->get('logged_user')) + ->select('package_name') + ->select('cost') + ->selectSum('credit_points', 'credit_points') + ->selectSum('cost', 'costSum') + ->selectCount('package_name', 'pack_count') + ->groupBy('package_name')->findAll(); + + if($data['TransactionData'][0]['is_mail_triggered'] == 0){ + $sendmail_controller = new Sendmail_controller(); + $mail = $sendmail_controller->index(session()->get('logged_user_email') , null , 5); + if($mail == true){ + $this->TransactionModel->where('order_id', $local_order_id )->set(array('is_mail_triggered'=>1))->update(); + } + } + + $Subtotal = 0; + foreach ($memberCredits as $key => $ele) { + $Subtotal = $Subtotal + $ele['costSum']; + } + $data['memberCredits'] =$memberCredits; + + $data['order_id'] = $local_order_id; + $timestamp = strtotime($data['TransactionData'][0]['created_at']); + $data['formattedDate'] = date('l, F j, Y', $timestamp); + $data['Subtotal'] = $Subtotal; + $data['gst'] = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value; + $data['pst'] = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value; + $data['card_brand'] = json_decode($data['TransactionData'][0]['transaction'] , true)['payment']['card_details']['card']['card_brand']; + $data['last_4'] = json_decode($data['TransactionData'][0]['transaction'] , true)['payment']['card_details']['card']['last_4']; + // echo '
';
+
                 // print_r(  $data['memberCredits']);
+
                 // echo '
'; + // die(); + echo view('payment',$data); + }else{ + echo 'invalid order_id'; + } + } + + } + + public function payment_failed( $local_order_id = null) + { + if( $local_order_id != null) + { + $data['TransactionData'] = $this->TransactionModel->where('order_id', $local_order_id )->where('member_id', session()->get('logged_user'))->find(); + if($data['TransactionData']){ + + $data['category'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['category']; + $data['code'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['code']; + $data['detail'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['detail']; + $data['order_id'] = $data['TransactionData'][0]['order_id']; + $timestamp = strtotime($data['TransactionData'][0]['created_at']); + $data['formattedDate'] = date('l, F j, Y', $timestamp); + + echo view('payment_failed',$data); + }else{ + echo 'invalid order_id'; + } + } + + } + + + + } + + + + + + diff --git a/app/Controllers/Sendmail_controller.php b/app/Controllers/Sendmail_controller.php index 88969fa..877078e 100644 --- a/app/Controllers/Sendmail_controller.php +++ b/app/Controllers/Sendmail_controller.php @@ -1,269 +1,535 @@ session = session(); - $this->MemberModel = new Member_model(); + + $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(); - $this->TransactionModel = new transaction_model(); + + $this->TransactionModel = new Transaction_model(); + helper(['form', 'url']); + + } + public function index($to,$code,$return) + { + try{ + $email = \Config\Services::email(); - $email->setFrom('suseendhiran.1702117@srit.org', 'suseendhiran'); + + $email->setFrom('devbook@mprkv.co.in', 'GolfEvo'); + $email->setTo($to); + // login user change passowrd => type 4 + if($return == 4) + { + $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"; + $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'); + } + // 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) + { + $data['id'] = '1'; + $user_data = $this->MemberModel->where('email', $to)->find(); + $data['to'] = $to; + $data['code'] = $code; + $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'); + } + // payment => type 5 + else if($return == 5) + { + + $TransactionData = $this->TransactionModel->where('member_id', session()->get('logged_user'))->orderBy('created_at', 'DESC')->first(); + $Transaction_id = $TransactionData['transaction_id']; + $timestamp = strtotime($TransactionData['created_at']); + $Transaction_date = date('l, F j, Y', $timestamp); + $amount = json_decode($TransactionData['transaction'] , true)['payment']['amount_money']['amount']; + $payment_method = json_decode($TransactionData['transaction'] , true)['payment']['source_type']; + + $data['id'] = $return; + $temp_data = $this->MailModel->where('type' , $return)->where('is_active' , 1)->find(); + if ($temp_data[0]['to']) + $email->setCC($temp_data[0]['to']); + if ($temp_data) { + $data['html'] = str_replace("%name%",session()->get('logged_user_name'),$temp_data[0]['html']); + $data['html'] = str_replace("%id%",$Transaction_id,$temp_data[0]['html']); + $data['html'] = str_replace("%method%",$payment_method,$temp_data[0]['html']); + $data['html'] = str_replace("%date%", $Transaction_date,$temp_data[0]['html']); + $data['html'] = str_replace("%amount%",$amount,$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'); + } + $email->setMessage($message); + if ($email->send()) + { + if ($return == 1) + $this->session->setTempdata('mail_success', "Please check your mail to verify",3); + + if ($return == 5) + return true; + + + } + else + { + $error = $email->printDebugger(); + //echo 'Email sending failed: ' . $error; + } + } catch (EmailException $e) { - // echo 'Email sending failed: ' . $e->getMessage(); + + echo 'Email sending failed: ' . $e->getMessage(); + } + } + + public function verify_email($verification_code) + { + // Get the user data corresponding to the verification code + $user_data = $this->MemberModel->where('md5(verification_code)', $verification_code)->find(); + if($user_data) + { + //print_r($user_data);die(); + if($user_data[0]['is_email_verified'] == 0) + { + // Update the users status + // $update_data = $this->MemberModel->update_status($user_data['id']); + $data['is_email_verified'] = 1; + $update_data = $this->MemberModel->where('id', $user_data[0]['id'] )->set($data)->update(); + if($update_data) + { + return redirect()->to(base_url()."set_password/".md5($user_data[0]['id'])); + } + else + { + // Show error message + echo 'Error in verifying email. Please try again.'; + } + } + else + { + // Show error message + // echo 'Email already verified.'; + return redirect()->to(base_url()."set_password/".md5($user_data[0]['id'])); + } + } + else + { + // Show error message + echo 'Invalid verification code.'; + } + } + + public function forgot_password() + { + $this->session->setTempdata('user',"member",3); + if($this->request->getmethod() == 'get') + { + return view('forgot_password_otp.php'); + } + else if($this->request->getmethod() == 'post') + { + + $email = $this->request->getVar('email'); + $user_data = $this->MemberModel->where('email', $email)->where('is_email_verified', 1 )->find(); + if ($user_data) + { + $otp = rand(1000 , 9999); + $this->index($this->request->getVar('email') , $otp , 2 ); + $data['status'] = 'success'; + $data['otp'] = $otp; + echo json_encode($data); + } + else + { + $data['status'] = 'failed'; + echo json_encode($data); + } + + } + } + + + } \ No newline at end of file diff --git a/app/Controllers/Test_controller.php b/app/Controllers/Test_controller.php index 4802f88..04b70f7 100644 --- a/app/Controllers/Test_controller.php +++ b/app/Controllers/Test_controller.php @@ -1,44 +1,88 @@ session = session(); + $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(); + $this->VariableModel = new Variable_model(); + $this->RuleModel = new Rule_model(); + $this->Cart_token_model = new Cart_token_model(); + $this->cartModel = new Cart_model(); - $this->TransactionModel = new transaction_model(); + + $this->TransactionModel = new Transaction_model(); + helper(['form', 'url']); + } + public function index($token = null) + { + + + + + } + // ----------------------------------------------- + } + diff --git a/app/Models/transaction_model.php b/app/Models/transaction_model.php index 9c1c3ec..f577db1 100644 --- a/app/Models/transaction_model.php +++ b/app/Models/transaction_model.php @@ -1,13 +1,25 @@ + @@ -49,6 +62,7 @@ pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" placeholder="Enter password" name="password" required> +
@@ -62,6 +76,18 @@ + diff --git a/app/Views/checkout.php b/app/Views/checkout.php index 9641eaf..992a843 100644 --- a/app/Views/checkout.php +++ b/app/Views/checkout.php @@ -1,270 +1,540 @@ + + + + + + + + + + + Checkout - Golf Evolution + + + + /assets/member_images/favicon.png" sizes="192x192" /> + /assets/member_images/favicon.png" /> + + + + /assets/member_css/front-style.css"> + + + + + + + + + + + + + +
+
+
+
+

Check Out

+
+
+ + +
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ - + + +
+
+ - + + +
+
+ +
+
+ + + +
+
+
+

Payment Method

+
+
+ + +
+
+
+ + + + +
+ +
+
+
+
+ + + -
-
- -
-
-
-
-

Order Summary

-
-
- -
-
-
$
-
- -
-

Items () :

-

$

-
-
-

PST (%) :

-

$

-
-
-

GST (%) :

-

$

-
-
-
Order Total :
-
$
-
-
-
-

By placing your order, you agree to our company privacy policy and condition of use.

- - -
+
-
+
--> +
+
+ + + +
+ +
+ +
+ +
+ +

Order Summary

+ +
+ +
+ + + +
+ +
+ +
$
+ +
+ + + +
+ +

Items () :

+ +

$

+ +
+ +
+ +

PST (%) :

+ +

$

+ +
+ +
+ +

GST (%) :

+ +

$

+ +
+ +
+ +
Order Total :
+ +
$
+ +
+ +
+ +
+ +

By placing your order, you agree to our company privacy policy and condition of use.

+ + + + + +
+ +
+ + + +
+ +
+ + +
+ + + + + + + + + + + + + + diff --git a/app/Views/member_form.php b/app/Views/member_form.php index 00be610..565b5b1 100644 --- a/app/Views/member_form.php +++ b/app/Views/member_form.php @@ -89,7 +89,7 @@
- +
@@ -97,7 +97,7 @@
- +
diff --git a/app/Views/member_login.php b/app/Views/member_login.php index 6803d41..9a649ee 100644 --- a/app/Views/member_login.php +++ b/app/Views/member_login.php @@ -1,121 +1,241 @@ + + + + Log In | Member + + + + + + + + + + + + + + + + + + + /assets/css/style.css" rel="stylesheet" type="text/css" /> + + + + +
+
+
+
+
+ +
+ +
+ + +

Login

+ + + +
+
+
+ + + getTempdata('mail_success')):?> +
+ getTempdata('mail_success'); ?> +
+ + + + getTempdata('error')):?> +
+ getTempdata('error'); ?> +
+ -
- - -
+ + +
- -
- -
-
- -
-
-
+ + + + +
+ + +
+ + + +
+ + + +
+ +
+ + + +
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+ + +
+
+ + + + + +
+
+ +
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/memberaccess.php b/app/Views/memberaccess.php index 8f7fdb8..54db721 100644 --- a/app/Views/memberaccess.php +++ b/app/Views/memberaccess.php @@ -16,6 +16,16 @@ + @@ -101,11 +111,11 @@

Expiry Date : format('M-d-Y'); ?>

0) - echo ' '; + echo '
'.$credit_data[$i]['running_balance'].'
'; else - echo ' '; + echo '
'.$credit_data[$i]['used_points'].'
'; ?> - +
@@ -161,10 +171,10 @@ Credit Usage $credit_data_value) { ?> - table-bottom"> + ">

Pack Cost : $

Pack Credits : Nos

Pack Expiry : format('M-d-Y'); ?>

- x + $ @@ -179,8 +189,8 @@ table-bottom"> + Taxes - Taxes PST (%) $ @@ -247,11 +257,11 @@

- +

- +
@@ -274,10 +284,11 @@

- +
@@ -334,5 +345,17 @@ $(document).ready(function(){ + \ No newline at end of file diff --git a/app/Views/membership.php b/app/Views/membership.php index 68104e6..7deb504 100644 --- a/app/Views/membership.php +++ b/app/Views/membership.php @@ -1,148 +1,296 @@ + + + Evo Membership - Golf Evolution + + + + /assets/member_images/favicon.png" sizes="192x192" /> + /assets/member_images/favicon.png" /> + + + + /assets/member_css/front-style.css"> + + + + + + + + + + +
+
+
+
+
+
+

Evo Membership

+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English.

+
+
+
+
+
+
- /assets/member_images/vector-3.png" width="68" height="80" alt="" class="mb-3"/> + + /assets/member_images/Vector-3.png" width="68" height="80" alt="" class="mb-3"/> +
Lorem Ipsum Lorem
+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
- /assets/member_images/vector-4.png" width="68" height="80" alt="" class="mb-3"/> + + /assets/member_images/Vector-4.png" width="68" height="80" alt="" class="mb-3"/> +
Lorem Ipsum Lorem
+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
- /assets/member_images/vector-5.png" width="68" height="80" alt="" class="mb-3"/> + + /assets/member_images/Vector-5.png" width="68" height="80" alt="" class="mb-3"/> +
Lorem Ipsum Lorem
+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
+
+
+ +
+
+
+
+

Get Credit Packs on
Pre-Sales Offer

+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
+
+
+
+
/assets/member_images/Offer.png"/ width="43" height="71">
+ /assets/member_images/cart-icon.png" alt="" width="70" height="70"/> +
+
+
$
+
+ Taxes
+
Credits
+
+
1 Credit at $
+ Add To Cart +
+
+
+
+
/assets/member_images/Offer.png"/ width="43" height="71">
+ /assets/member_images/cart-icon.png" alt="" width="70" height="70"/> +
+
+
$
+
+ Taxes
+
Credits
+
+
1 Credit at $
+ Add To Cart +
+
+
+
+
+
+
+ +
);"> +
+
+
+

How it Works

+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
+
Lorem Ipsum
+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
+
Lorem Ipsum
+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
+
Lorem Ipsum
+

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
Have a question? Reach us
+
+ +
+ +
+
+
+
+ + + + + + diff --git a/app/Views/myaccount.php b/app/Views/myaccount.php index 0c1f631..989aac9 100644 --- a/app/Views/myaccount.php +++ b/app/Views/myaccount.php @@ -1,136 +1,294 @@ + + + + My Account - Golf Evolution + + + + /assets/member_images/favicon.png" sizes="192x192" /> + + + /assets/member_css/front-style.css"> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/set_password.php b/app/Views/set_password.php index 94d7d51..fe527f7 100644 --- a/app/Views/set_password.php +++ b/app/Views/set_password.php @@ -26,6 +26,14 @@ .parsley-errors-list>li { color: red !important; } +.field-icon { + float: right; + margin-left: -35px; + margin-top: 12px; + margin-right: 12px; + position: relative; + z-index: 3; +} @@ -76,6 +84,7 @@ title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" required class="form-control" name="password">
+