-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Progress bar #88
Comments
For one who wants to stay with jQuery UI. Include the progress bar: <div id="progressbar"></div> Initialize the progress bar: //Progress bar
$( "#progressbar" ).progressbar({
value: <?php cp_count_complete_tasks( cp_get_project_id() ); ?>,
max: <?php cp_count_tasks( cp_get_project_id() ); ?>
}); Count all task and tasklist: /**
* Count all tasks for specific project
*/
function cp_count_tasks( $project_id = 0 ){
global $wpdb;
$meta_key = '_cp-project-id';
$meta_value = $project_id;
$post_type = 'cp-tasks';
$completedtasks_sql = "SELECT p.ID
FROM $wpdb->postmeta pm
JOIN $wpdb->posts p ON (p.ID = pm.post_id)
WHERE pm.meta_key = '$meta_key'
AND pm.meta_value = '$meta_value'
AND p.post_type = '$post_type'
AND p.post_status = 'publish';
";
$completedtasks = $wpdb->get_col($wpdb->prepare($completedtasks_sql));
$task_status_list = array();
foreach ( $completedtasks as $item ) {
$task_status = cp_get_task_status( $item );
$task_status_list[] = $task_status;
}
$totaltasks = count ($task_status_list);
echo $totaltasks;
}
/**
* Count all completed tasks for specific project
*/
function cp_count_complete_tasks( $project_id = 0 ){
global $wpdb;
$meta_key = '_cp-project-id';
$meta_value = $project_id;
$post_type = 'cp-tasks';
$completedtasks_sql = "SELECT p.ID
FROM $wpdb->postmeta pm
JOIN $wpdb->posts p ON (p.ID = pm.post_id)
WHERE pm.meta_key = '$meta_key'
AND pm.meta_value = '$meta_value'
AND p.post_type = '$post_type'
AND p.post_status = 'publish';
";
$completedtasks = $wpdb->get_col($wpdb->prepare($completedtasks_sql));
$task_status_list = array();
foreach ( $completedtasks as $item ) {
$task_status = cp_get_task_status( $item );
$task_status_list[] = $task_status;
}
$completedtasks = count( array_keys( $task_status_list, "complete" ));
echo $completedtasks;
} |
Thanks for the contribution! I would highly suggest using WP_Query vs a custom database query. |
Thank you! |
True. If all you want is post IDs you could use get_posts() and specify the parameter 'fields' => 'ID'. That will only return IDs, and not the entire post data. |
The performance hit from loading all post data in this case will be very It's a good idea to use WP_Query where possible for a number of reasons. On 06/24/13 10:46, Brad Williams wrote:
|
Hi everyone, thanks for the contribution. But somehow i can't get it working. I have tried both codes in my content-single-project.php and also added the css definitions in new.css, without success. Could you give me a hint?! |
This is not an issue, more like an enhancement.
But a progress bar for the project, probably based on the task added vs tasks completed, would be a great enhancement to the project.
Something like this.
PHP:
CSS:
I'm not a programmer, so please excuse my mistakes.
The text was updated successfully, but these errors were encountered: