get_var("SELECT MAX(CAST(SUBSTRING_INDEX(project_id, '.', -1) AS UNSIGNED)) FROM {$wpdb->prefix}projects WHERE project_id LIKE '{$prefix}.%'"); $new_id = $last_id ? $last_id + 1 : 1; return sprintf('%s.%03d.%03d.%03d', $prefix, 0, 0, $new_id); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { global $wpdb; $table_name = $wpdb->prefix . 'projects'; if (isset($_POST['create_project'])) { $project_type = sanitize_text_field($_POST['project_type']); $project_id = generate_project_id($project_type); $project_name = sanitize_text_field($_POST['project_name']); $location = sanitize_text_field($_POST['location']); $developer = sanitize_text_field($_POST['developer']); $start_date = sanitize_text_field($_POST['start_date']); $duration = intval($_POST['duration']); $estimated_reduction = floatval($_POST['estimated_reduction']); $sdg_targets = sanitize_textarea_field($_POST['sdg_targets']); $ccb_standards = sanitize_textarea_field($_POST['ccb_standards']); $wpdb->insert( $table_name, array( 'project_id' => $project_id, 'project_name' => $project_name, 'project_type' => $project_type, 'location' => $location, 'developer' => $developer, 'start_date' => $start_date, 'duration' => $duration, 'estimated_reduction' => $estimated_reduction, 'sdg_targets' => $sdg_targets, 'ccb_standards' => $ccb_standards ) ); echo '

Project created successfully with ID: ' . $project_id . '

'; } elseif (isset($_POST['apply_to_group'])) { $project_id = sanitize_text_field($_POST['project_id']); $group_id = sanitize_text_field($_POST['group_id']); $wpdb->update( $table_name, array('group_id' => $group_id), array('project_id' => $project_id) ); echo '

Project applied to group successfully.

'; } } ?> TenzaTrade Project Creation

Project and Group Information

Project Definition

Project Group

0 Shares