diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..44bd7d2 --- /dev/null +++ b/.htaccess @@ -0,0 +1,9 @@ +RewriteEngine On +RewriteBase / + +# If the requested file or directory exists, serve it directly +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d + +# Otherwise, route all requests to index.php +RewriteRule ^(.*)$ index.php [QSA,L] \ No newline at end of file diff --git a/README.md b/README.md index 5d0fb49..fb5dbc6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ - - # Module 3 - TFU A PHP-based web application for managing team campaigns and followups. @@ -8,10 +6,27 @@ A PHP-based web application for managing team campaigns and followups. ### Prerequisites -- PHP 7.4 or higher -- MySQL/MariaDB +- Docker and Docker Compose +- OR PHP 7.4 or higher with MySQL/MariaDB -### Installation +### Docker Installation (Recommended) + +1. Clone this repository to your local machine +2. Run the following command in the project root: +```bash +docker-compose up -d +``` +3. The services will be available at: + - Application: http://localhost:9000 + - PHPMyAdmin: http://localhost:8889 (credentials: root/root) +4. Import the database schema: + - Access PHPMyAdmin at http://localhost:8889 + - Login with username: root, password: root + - Create a new database named 'tfu_db' + - Import the `db.sql` file + - import the `migration.sql` file + +### Traditional Installation 1. Clone this repository to your local machine 2. Configure your database connection in `config.php` @@ -19,45 +34,42 @@ A PHP-based web application for managing team campaigns and followups. ### Running the Application +#### Using Docker (Recommended) +The application will be automatically running at http://localhost:9000 + +#### Using PHP Built-in Server Start the development server using: - ```bash - php -S localhost:9000 - ``` - Then visit `http://localhost:9000` in your web browser. -Admin Login `http://localhost:9000/admin/login` +### Login Credentials -admin@manaknight.com -a123456 +Admin Login `http://localhost:9000/admin/login` +- Email: admin@manaknight.com +- Password: a123456 Client Login `http://localhost:9000/client/login` - -emmy@manaknight.com -a123456 +- Email: emmy@manaknight.com +- Password: a123456 ## Features - Campaign management -- Team followup tracking +- Followup tracking - Add and edit campaign details - Database-driven application ## Core Project Files ├── README.md - ├── config.php # Database configuration - ├── db.sql # Database schema - ├── migration.sql # Database seed data - ├── index.php # Main entry point +├── docker-compose.yml # Docker configuration ## Tasks diff --git a/config.php b/config.php index 4fde537..545897c 100644 --- a/config.php +++ b/config.php @@ -9,7 +9,7 @@ class MkdConfig { $this->_config = [ - "project-name" => "Team Followup ", + "project-name" => "Mkd Project ", "project-type" => "", "programming-language" => "php", "user-type" => "", @@ -30,11 +30,11 @@ class MkdConfig "smtp-port" => 2525, "database" => 1, "database-type" => "sql", - "database-hostname" => "localhost", - "database-u-ser" => "root", - "database-password" => "", + "database-hostname" => "mysql", + "database-u-ser" => "tfu_user", + "database-password" => "tfu_password", "database-port" => "3306", - "database-name" => "team_followup_prod_test", + "database-name" => "tfu_db", "upload" => 0, "aws-version" => "", "aws-region" => "", diff --git a/db.sql b/db.sql index 0d1e85f..5cd0386 100644 --- a/db.sql +++ b/db.sql @@ -33,9 +33,9 @@ CREATE TABLE `calendar` ( DROP TABLE IF EXISTS `campaign`; CREATE TABLE `campaign` ( `id` int NOT NULL AUTO_INCREMENT, - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `file_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `file_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, `user_id` int unsigned NOT NULL, `created_at` date DEFAULT NULL, `updated_at` datetime DEFAULT NULL, @@ -124,7 +124,7 @@ CREATE TABLE `user` ( `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `role` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'admin', - `company` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'Team Follow Up', + `company` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'MKD Follow Up', `drive_access_token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, `drive_refresh_token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, `created_at` date DEFAULT NULL, diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..782e7d2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3.8' + +services: + php: + image: php:7.4-apache + ports: + - "9000:80" + volumes: + - .:/var/www/html + - ./docker/apache.conf:/etc/apache2/sites-available/000-default.conf + depends_on: + - mysql + # Install additional PHP extensions that might be needed + command: > + sh -c "apt-get update && + apt-get install -y libpq-dev && + docker-php-ext-install pdo pdo_mysql && + a2enmod rewrite && + apache2-foreground" + + mysql: + image: mysql:5.7 + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: tfu_db + MYSQL_USER: tfu_user + MYSQL_PASSWORD: tfu_password + ports: + - "3306:3306" + volumes: + - mysql_data:/var/lib/mysql + command: --sql_mode="" + + phpmyadmin: + image: phpmyadmin/phpmyadmin + ports: + - "8889:80" + environment: + PMA_HOST: mysql + MYSQL_ROOT_PASSWORD: root + depends_on: + - mysql + +volumes: + mysql_data: \ No newline at end of file diff --git a/docker/apache.conf b/docker/apache.conf new file mode 100644 index 0000000..5ddabe0 --- /dev/null +++ b/docker/apache.conf @@ -0,0 +1,13 @@ + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + \ No newline at end of file diff --git a/index.php b/index.php index 4ab8ebb..6315984 100644 --- a/index.php +++ b/index.php @@ -281,7 +281,7 @@ Route::add('/help', function () { @@ -325,6 +325,7 @@ Route::add('/admin/login', function () { // Insert data into the database using LicenseModel $userModel = new UserModel(); $result = $userModel->get_by_field('email', $email); + // var_dump($result);exit; if ($result) { if (password_verify($raw_password, $result['password']) && $result['status'] == 'active' && $result['role'] == 'admin') { diff --git a/layout/header/Adminleft_sidebar.php b/layout/header/Adminleft_sidebar.php index 6519f84..6ffe074 100644 --- a/layout/header/Adminleft_sidebar.php +++ b/layout/header/Adminleft_sidebar.php @@ -152,7 +152,7 @@