Project Type Management Controller Documentation
File: /controllers/projectKindController.php
Purpose: Manage project type definitions and categories
Last Updated: 2024-12-20
---
๐ Overview
Primary Functions
- โ Project type creation
- โ Project type listing
- โ Project type editing
- โ Project type soft deletion
- โ YouTube link integration
Related Controllers
- โข projectController.php - Uses project types
- โข projectReportController.php - Filters by type
---
๐๏ธ Database Tables
Primary Tables
| Table Name | Purpose | Key Columns |
|---|---|---|
| projectkind | Project type definitions | projectkindid, projectkindname, projectkindcomment, conditions |
| Table Name | Purpose | Relationship |
|---|---|---|
| youtubelink | Help videos | General reference |
๐ง Key Functions
1. add()
Purpose: Create new project type
Called By: POST action to ?do=add
Parameters:
- โข
$projectkindname(string) - Type name - โข
$projectkindcomment(string) - Type description
Returns: Project kind ID
Database Operations:
- โข INSERT into
projectkind
Business Logic:
1. Validate project type name
2. Set default conditions (active = 0)
3. Record creation timestamp and user
4. Insert new project type
Example:
$_POST['projectkindname'] = 'Construction Project';
$_POST['projectkindcomment'] = 'Building and construction works';
add();
2. edit($id)
Purpose: Load project type for editing
Called By: GET action to ?do=edit&id=$id
Parameters:
- โข
$id(int) - Project kind ID
Returns: Project kind data
Database Operations:
- โข SELECT from
accountmovement(Note: This appears to be an error)
Business Logic:
1. Load project kind data by ID
2. Return data for form population
3. tempdelete()
Purpose: Soft delete project type
Called By: GET action to ?do=tempdelete&projectkindid=$id
Parameters:
- โข
$projectkindid(int) - Project kind ID
Returns: Success/error redirect
Database Operations:
- โข UPDATE
projectkindSET conditions = 1
Business Logic:
1. Mark project type as inactive
2. Preserve data for historical references
---
๐ Main Workflows
Workflow 1: Project Type Creation
1. User accesses creation form
โ
2. Fill type name and description
โ
3. Submit form data
โ
4. Validate input fields
โ
5. Insert project type record
โ
6. Success/Error Response
Files Involved:
- โข View:
/views/default/projectkindview/add.html - โข Model:
/models/dto/Projectkind.class.php - โข DAO:
/models/mysql/ProjectkindMySqlDAO.class.php
Workflow 2: Project Type Management
1. Display project types list
โ
2. Select type for editing
โ
3. Load existing data
โ
4. Modify fields
โ
5. Save changes
โ
6. Update confirmation
---
๐ File Dependencies
Includes
include("../public/impOpreation.php");
include_once("../public/config.php");
include_once("dailyentryfun.php");
include("../public/include_dao.php");
Required Models
- โข Projectkind, YoutubeLink
Related Views
- โข
/views/default/projectkindview/add.html- Creation form - โข
/views/default/projectkindview/show.html- Types listing - โข
/views/default/projectkindview/edit.html- Edit form
---
๐ฏ URL Routes & Actions
| Action (`?do=`) | Method | Description | View Template | |
|---|---|---|---|---|
| (empty) | GET | Display creation form | add.html | |
| add | POST | Create new project type | - | |
| show | GET | List all project types | show.html | |
| tempdelete | GET | Soft delete project type | - | |
| edit | GET | Display edit form | edit.html | |
| sucess | GET | Success message | succes.html | |
| error | GET | Error message | error.html |
โ ๏ธ Known Issues & Fixes
Issue 1: Wrong DAO Reference in Edit Function (Line 146)
Problem: Function references $myAccountmovementRecord instead of project kind DAO
Cause: Copy-paste error from another controller
Fix: Replace with $myProjectkindRecord->load($id)
File: Lines 142-148
Issue 2: Inconsistent Variable Naming
Problem: Mixed use of $myProjectkind and $myProjectkindRecord
Cause: Inconsistent naming convention
Fix: Standardize variable names
File: Throughout controller
Issue 3: Missing Rollback on Error (Line 77)
Problem: Transaction rollback called on undefined $mytransactions
Cause: Transaction management not properly initialized
Fix: Add proper transaction initialization or remove rollback
File: Line 77
---
๐ Permissions & Security
Required Permissions
- โข Project type management access
Security Checks
include_once("../public/authentication.php");
Input Validation
- โข All POST data accessed via
$_POST(should usefilter_input()) - โข Session-based user tracking
---
๐ Notes
Important Considerations
- โข Project types are used in project creation
- โข Soft deletion preserves historical data
- โข Arabic comments in code indicate client requirements
- โข YouTube links provide contextual help
Future Improvements
- โป๏ธ Add project type templates
- โป๏ธ Implement type hierarchies
- โป๏ธ Add color coding for types
- โป๏ธ Enhance validation
Database Schema
CREATE TABLE projectkind (
projectkindid INT PRIMARY KEY AUTO_INCREMENT,
projectkindname VARCHAR(255),
projectkindcomment TEXT,
conditions TINYINT DEFAULT 0,
projectkinddate DATETIME,
userid INT
);
---
๐ Related Documentation
- โข Project Master
- โข Project Reports
- โข Authentication System